diff --git a/src/dra/42398.c b/src/dra/42398.c index 6e37f9b987..fce41caafc 100644 --- a/src/dra/42398.c +++ b/src/dra/42398.c @@ -1033,7 +1033,7 @@ void func_800E414C(void) { RoomTeleport* temp_a1; s32 temp_a0; - if (!(D_8003C708.flags & 0x40)) { + if (!(D_8003C708.flags & FLAG_UNK_40)) { return; } @@ -1058,7 +1058,7 @@ void func_800E414C(void) { } PlaySfx(0x80); D_80097928 = 1; - if (D_8003C708.flags == 0x40) { + if (D_8003C708.flags == FLAG_UNK_40) { g_Player.D_80072EFC = 0x18; g_Player.padSim = PAD_LEFT; } else { @@ -1082,7 +1082,7 @@ void func_800E414C(void) { if (!g_UseDisk) { break; } - if (D_8003C708.flags == 0x40 && PLAYER.posX.i.hi < 0x78) { + if (D_8003C708.flags == FLAG_UNK_40 && PLAYER.posX.i.hi < 0x78) { func_801073C0(); g_CdStep = CdStep_LoadInit; g_LoadFile = CdFile_StageChr; @@ -1102,7 +1102,7 @@ void func_800E414C(void) { if (!g_UseDisk) { break; } - if (D_8003C708.flags == 0x40 && PLAYER.posX.i.hi >= 0x89) { + if (D_8003C708.flags == FLAG_UNK_40 && PLAYER.posX.i.hi >= 0x89) { func_801073C0(); g_CdStep = CdStep_LoadInit; g_LoadFile = CdFile_StageChr; diff --git a/src/dra/5087C.c b/src/dra/5087C.c index 3fd7ce1dc3..8b125b1d16 100644 --- a/src/dra/5087C.c +++ b/src/dra/5087C.c @@ -1080,7 +1080,7 @@ void DrawMapCursor(void) { bool func_800F27F4(s32 arg0) { if (arg0 == 0) { if (g_unkGraphicsStruct.D_800973FC != 0 || D_8006BB00 != 0 || - D_8003C708.flags & 0x60) { + D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) { return false; } D_801375C8 = 1; @@ -1192,10 +1192,10 @@ void RunMainEngine(void) { g_backbufferY = 0; func_800F14CC(); LoadRoomLayer(D_801375BC.def->tileLayoutId); - if (D_8003C708.flags & 0x20) { + if (D_8003C708.flags & FLAG_UNK_20) { LoadGfxAsync(ANIMSET_DRA(3)); } - if (D_8003C708.flags & 0x40) { + if (D_8003C708.flags & FLAG_UNK_40) { LoadGfxAsync(ANIMSET_DRA(4)); } D_80097910 = g_StagesLba[g_StageId].unk18; @@ -1206,7 +1206,7 @@ void RunMainEngine(void) { D_80097910 = MU_METAMORPHOSIS; #endif } - if ((D_8003C730 == 0) && !(D_8003C708.flags & 0x20)) { + if ((D_8003C730 == 0) && !(D_8003C708.flags & FLAG_UNK_20)) { PlaySfx(D_80097910); } D_80097928 = 0; @@ -1504,7 +1504,7 @@ void RunMainEngine(void) { UnMuteCd(); } else { UnMuteCd(); - if (!(D_8003C708.flags & 0x60)) { + if (!(D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20))) { PlaySfx(D_80097910); if (D_80097910 != 0) { D_80097928 = 0; @@ -1643,7 +1643,7 @@ void RunMainEngine(void) { D_801375A0 = PLAYER.posY.val; PLAYER.posX.i.hi = D_801375C0 + g_Tilemap.scrollX.i.hi; PLAYER.posY.i.hi = D_801375C4 + g_Tilemap.scrollY.i.hi; - if (D_8003C708.flags & 0x60) { + if (D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) { LoadGfxAsync(ANIMSET_DRA(1)); } func_800EA538(2); @@ -1661,10 +1661,10 @@ void RunMainEngine(void) { PLAYER.posY.i.hi = (u8)PLAYER.posY.i.hi; PLAYER.posX.i.hi = (u8)PLAYER.posX.i.hi; LoadRoomLayer(D_801375BC.def->tileLayoutId); - if (D_8003C708.flags & 0x20) { + if (D_8003C708.flags & FLAG_UNK_20) { LoadGfxAsync(ANIMSET_DRA(3)); } - if (D_8003C708.flags & 0x40) { + if (D_8003C708.flags & FLAG_UNK_40) { LoadGfxAsync(ANIMSET_DRA(4)); } g_Tilemap.x = diff --git a/src/dra/8D3E8.c b/src/dra/8D3E8.c index acbfef7ad8..ca734d06d7 100644 --- a/src/dra/8D3E8.c +++ b/src/dra/8D3E8.c @@ -2045,7 +2045,7 @@ void EntityGiantSpinningCross(Entity* self) { prim = &g_PrimBuf[self->primIndex]; while (prim != NULL) { prim->tpage = 0x1C; - prim->drawMode = 0x100 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_100 | DRAW_HIDE; prim = prim->next; } func_8011A290(self); diff --git a/src/ric/1AC60.c b/src/ric/1AC60.c index 097c8545eb..77be4819b1 100644 --- a/src/ric/1AC60.c +++ b/src/ric/1AC60.c @@ -157,7 +157,7 @@ void RicInit(s16 initParam) { g_Entities[1].primIndex = primIndex; g_Entities[1].flags |= FLAG_HAS_PRIMS; for (prim = &g_PrimBuf[primIndex]; prim != NULL; prim = prim->next) { - prim->drawMode = 0x102 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_100 | DRAW_UNK02 | DRAW_HIDE; } if (D_80097C98 == 6) { RicCreateEntFactoryFromEntity(playerPtr, FACTORY(BP_TELEPORT, 1), 0); diff --git a/src/ric/2C4C4.c b/src/ric/2C4C4.c index 899e95dbad..c4a4a701fc 100644 --- a/src/ric/2C4C4.c +++ b/src/ric/2C4C4.c @@ -924,7 +924,7 @@ void RicEntitySubwpnAxe(Entity* self) { self->ext.subwpnAxe.unk8B[sp10 + 4] = 0; self->ext.subwpnAxe.unk8B[sp10 + 8] = 0; } else { - prim->drawMode = 0x100 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_100 | DRAW_HIDE; } prim = prim->next; sp10++; @@ -1139,7 +1139,7 @@ void RicEntityCrashAxe(Entity* self) { self->ext.axeCrash.unk8B[sp10 + 4] = 0; self->ext.axeCrash.unk8B[sp10 + 8] = 0; } else { - prim->drawMode = 0x100 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_100 | DRAW_HIDE; } prim = prim->next; sp10++; @@ -2411,7 +2411,7 @@ void RicEntityCrashVibhuti(Entity* self) { } prim = &g_PrimBuf[self->primIndex]; for (i = 0; i < 9; i++) { - if (prim->drawMode & 8) { + if (prim->drawMode & DRAW_HIDE) { break; } prim = prim->next; diff --git a/src/ric/319C4.c b/src/ric/319C4.c index 2c3e23fdb6..88a2241764 100644 --- a/src/ric/319C4.c +++ b/src/ric/319C4.c @@ -1369,7 +1369,7 @@ void RicEntityAguneaCircle(Entity* self) { prim->v2 = prim->v3 = 0xD0; } prim->priority = 0xC2; - prim->drawMode = 0x200 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_200 | DRAW_HIDE; prim = prim->next; } self->ext.aguneaCrash.subweaponId = PL_W_CRASH_AGUNEA; diff --git a/src/ric/e_giant_spinning_cross.c b/src/ric/e_giant_spinning_cross.c index 97708f74a4..340ed0f4ea 100644 --- a/src/ric/e_giant_spinning_cross.c +++ b/src/ric/e_giant_spinning_cross.c @@ -140,7 +140,7 @@ void RicEntityCrashCrossBeam(Entity* self) { prim = &g_PrimBuf[self->primIndex]; while (prim != NULL) { prim->tpage = 0x1C; - prim->drawMode = 0x100 | DRAW_HIDE; + prim->drawMode = DRAW_UNK_100 | DRAW_HIDE; prim = prim->next; } self->ext.giantcross.subweaponId = PL_W_CRASH_CROSS_BEAM; diff --git a/src/saturn/zero.c b/src/saturn/zero.c index 7f98b05eee..6026f6ba2f 100644 --- a/src/saturn/zero.c +++ b/src/saturn/zero.c @@ -175,42 +175,42 @@ void func_06008588(int param_1) { puVar5 = &DAT_0605d6c0[param_1 * 4]; puVar6 = &DAT_0605CD90[param_1]; - if (puVar5->flags == 0) { + if (puVar5->tileFlags == 0) { return; } - if ((puVar5->flags & 1) != 0) { + if ((puVar5->tileFlags & 1) != 0) { cnt = func_0600F96C(puVar6->unkc, &DAT_060485e0, puVar6->unk18); DmaScroll(&DAT_060485e0, puVar6->dst0, cnt); } - if ((puVar5->flags & 2) != 0) { + if ((puVar5->tileFlags & 2) != 0) { cnt = func_0600F96C(puVar6->unk10, &DAT_060485e0, puVar6->unk1c); DmaScroll(&DAT_060485e0, puVar6->dst4, cnt); } - if ((puVar5->flags & 4) != 0) { + if ((puVar5->tileFlags & 4) != 0) { if (DAT_060086d4 == 4) { func_060089F0(puVar6); } else { func_0600871C(puVar6, &DAT_0605c680, param_1); } } - if ((puVar5->flags & 8) != 0) { + if ((puVar5->tileFlags & 8) != 0) { DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt); } - if ((puVar5->flags & 0x10) != 0) { + if ((puVar5->tileFlags & 0x10) != 0) { DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt); } - if ((puVar5->flags & 0x20) != 0) { + if ((puVar5->tileFlags & 0x20) != 0) { DmaScroll(puVar5->src, puVar5->dest, puVar5->cnt); } - if ((puVar5->flags & 0x40) != 0) { + if ((puVar5->tileFlags & 0x40) != 0) { cnt = func_0600F96C(puVar6->unkc, DMA_SRC_ADDR, puVar6->unk18); DmaScroll(DMA_SRC_ADDR, puVar6->dst0, cnt); } - if ((puVar5->flags & 0x80) != 0) { + if ((puVar5->tileFlags & 0x80) != 0) { cnt = func_0600F96C(puVar6->unk10, DMA_SRC_ADDR, puVar6->unk1c); DmaScroll(DMA_SRC_ADDR, puVar6->dst4, cnt); } - puVar5->flags = 0; + puVar5->tileFlags = 0; puVar5->cnt = 0; puVar5->dest = 0; puVar5->src = 0; diff --git a/src/saturn/zero.h b/src/saturn/zero.h index 44ced4fabe..434ce80b65 100644 --- a/src/saturn/zero.h +++ b/src/saturn/zero.h @@ -71,7 +71,7 @@ s32 func_0600F96C(s32, s32, s32); void DmaScroll(s32* src, s32* dest, u32 cnt); struct Unk0605d6c0 { - u32 flags; + u32 tileFlags; u32 src; u32 dest; u32 cnt; diff --git a/src/servant/play_sfx.h b/src/servant/play_sfx.h index 0c889ad76d..09aa36113e 100644 --- a/src/servant/play_sfx.h +++ b/src/servant/play_sfx.h @@ -37,7 +37,7 @@ void ProcessSfxState(Entity* entity) { break; case 5: - if ((*(s32*)&D_8003C708.flags & 0x60) != 0) { + if ((*(s32*)&D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) != 0) { g_PlaySfxStep = 99; DestroyEntity(entity); return; diff --git a/src/servant/servant_unk0.h b/src/servant/servant_unk0.h index 43e8137598..5039e37b30 100644 --- a/src/servant/servant_unk0.h +++ b/src/servant/servant_unk0.h @@ -4,7 +4,7 @@ s32 ServantUnk0(void) { if (D_8003C708.flags == 0x22) { return 1; } - if (D_8003C708.flags == 0x20) { + if (D_8003C708.flags == FLAG_UNK_20) { return 0; } return 2; @@ -13,7 +13,7 @@ s32 ServantUnk0(void) { return 0; } - if (D_8003C708.flags == 0x20) { + if (D_8003C708.flags == FLAG_UNK_20) { return 1; } return 2; diff --git a/src/st/e_red_door.h b/src/st/e_red_door.h index a38e11a5ff..b210b07175 100644 --- a/src/st/e_red_door.h +++ b/src/st/e_red_door.h @@ -258,7 +258,7 @@ void EntityRedDoor(Entity* self) { angle = self->ext.door.angle; prim = &g_PrimBuf[self->primIndex]; for (; prim != NULL; i++, prim = prim->next) { - if (!(prim->drawMode & 8)) { + if (!(prim->drawMode & DRAW_HIDE)) { if (!(self->params & 0x100)) { if (i == 0) { endX = prim->x0 = prim->x2 = diff --git a/src/st/e_skeleton.h b/src/st/e_skeleton.h index c3f6573912..b573db2a1b 100644 --- a/src/st/e_skeleton.h +++ b/src/st/e_skeleton.h @@ -276,7 +276,7 @@ void func_801C6678(Entity* self) { self->rotY = 0x200; self->unk6C = 0; self->hitboxState = 0; - self->drawFlags = self->drawFlags | 0xB; + self->drawFlags |= FLAG_DRAW_UNK8 | FLAG_DRAW_ROTY | FLAG_DRAW_ROTX; return; } diff --git a/src/st/e_stage_name.h b/src/st/e_stage_name.h index bddc19a260..08d1ccc0be 100644 --- a/src/st/e_stage_name.h +++ b/src/st/e_stage_name.h @@ -169,7 +169,7 @@ void EntityStageNamePopup(Entity* self) { prim->g2 = 0; prim->b2 = 0x38; prim->priority = 0xB0; - prim->drawMode = 0x15 | DRAW_HIDE; + prim->drawMode = DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP | DRAW_HIDE; LOW(prim->r1) = LOW(prim->r0); LOW(prim->r3) = LOW(prim->r2); prim = prim->next; @@ -190,7 +190,7 @@ void EntityStageNamePopup(Entity* self) { prim->u2 = prim->u0 = 4; prim->u1 = prim->u3 = primIndex = 0x78; // FAKE prim->priority = 0xC0; - prim->drawMode = 4 | DRAW_HIDE; + prim->drawMode = DRAW_COLORS | DRAW_HIDE; LOW(prim->r1) = LOW(prim->r0); LOW(prim->r2) = LOW(prim->r0); LOW(prim->r3) = LOW(prim->r0); @@ -211,7 +211,7 @@ void EntityStageNamePopup(Entity* self) { prim->g0 = 0x78; prim->b0 = 0xA8; prim->priority = 0xC0; - prim->drawMode = 4 | DRAW_HIDE; + prim->drawMode = DRAW_COLORS | DRAW_HIDE; LOW(prim->r1) = LOW(prim->r0); LOW(prim->r2) = LOW(prim->r0); LOW(prim->r3) = LOW(prim->r0); diff --git a/src/st/nz0/e_bloody_skeleton.c b/src/st/nz0/e_bloody_skeleton.c index 7b1f77d501..dba27e3515 100644 --- a/src/st/nz0/e_bloody_skeleton.c +++ b/src/st/nz0/e_bloody_skeleton.c @@ -126,7 +126,10 @@ void EntityBloodSkeleton(Entity* self) { if (AnimateEntity(animation, self) == 0) { self->hitPoints = 0; self->hitboxState = 3; - self->flags = g_api.enemyDefs[70].flags & 0x1FFFFFFF; + self->flags = + g_api.enemyDefs[70].flags & + ~(FLAG_DESTROY_IF_OUT_OF_CAMERA | + FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA | FLAG_UNK_20000000); SetStep(BLOOD_SKELETON_WALK); } } diff --git a/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs b/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs index f637cf2097..4979c5fb70 100644 --- a/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs +++ b/tools/lints/sotn-lint/src/bit_flag_line_transformer.rs @@ -36,6 +36,25 @@ impl EnumValue for u64 where ::Err: Debug { } // self->field &= ~4; // self->field &= 0xFFFB; // +// * bitwise-XOR assignment: +// self->field ^= ~4; +// self->field ^= 0xFFFB; +// +// * bitwise-OR +// self->field | 0x8300; +// +// * bitwise-AND +// self->field & 0x8200; +// +// * bitwise-XOR +// self->field ^ 0x8400; +// +// * equality +// if (self->field == 8) { +// +// * inequality +// if (self->field != 8) { +// // If a constant contains bits which are not represented by // enum values, no transformation will be made. pub struct BitFlagLineTransformer where ::Err: Debug { @@ -50,7 +69,7 @@ impl BitFlagLineTransformer where ::Err: Debug { let mut _enum_values: Vec<&'static (U, &'static str)> = Vec::new(); _enum_values.extend_from_slice(&enum_values[..]); _enum_values.sort_by(|(a, _), (b, _)| b.cmp(a)); - let pattern = format!(r"([.>]{}\s*(?:[&|]?)=\s*)([~]?)((?:0x)?[A-Fa-f0-9]*)(?:;)", field_name.to_string()); + let pattern = format!(r"([.>]{}\s*((?:(?:[&|=!^~]?)=)|(?:[&|^]))\s*)([~]?)((?:0x[A-Fa-f0-9]+)|0|(?:[1-9][0-9]*))([;),? ])", field_name.to_string()); let regex = Regex::new(&pattern).unwrap(); let safe_mask: U = enum_values.iter().fold(U::zero(), |mask, (bit, _)| mask | *bit); @@ -64,67 +83,71 @@ impl BitFlagLineTransformer where ::Err: Debug { } fn replace_enum(&self, captures: ®ex::Captures) -> String { - if let Some(assignment) = captures.get(1).map(|m| m.as_str().to_string()) { - if let Some(field_value_string) = captures.get(3).map(|m| m.as_str().to_string()) { - let inverted = captures.get(2).map(|m| m.as_str()) == Some("~"); - - // if it starts with 0x, hex string, otherwise int - let mut field_value: U; - if field_value_string.starts_with("0x") { - if let Ok(v) = U::from_str_radix(field_value_string.strip_prefix("0x").unwrap(), 16) { - field_value = v; - } else { - return captures.get(0) - .map_or_else(|| "".to_string(), |m| m.as_str().to_string()) - } - } else { - field_value = field_value_string.parse::().unwrap(); - } + if let (Some(prefix), Some(operator), Some(field_value_string), Some(terminal_string)) = ( + captures.get(1).map(|m| m.as_str().to_string()), + captures.get(2).map(|m| m.as_str().to_string()), + captures.get(4).map(|m| m.as_str().to_string()), + captures.get(5).map(|m| m.as_str().to_string())) { - if inverted { - field_value = !field_value; - } + let inverted = captures.get(3).map(|m| m.as_str()) == Some("~"); - let invert: String; - if field_value.count_ones() > ((size_of::() as u32) * 8 / 2) { - invert = "~".to_string(); - field_value = !field_value; + // if it starts with 0x, hex string, otherwise int + let mut field_value: U; + if field_value_string.starts_with("0x") { + if let Ok(v) = U::from_str_radix(field_value_string.strip_prefix("0x").unwrap(), 16) { + field_value = v; } else { - invert = "".to_string(); + return captures.get(0) + .map_or_else(|| "".to_string(), |m| m.as_str().to_string()) } + } else { + field_value = field_value_string.parse::().unwrap(); + } - // there are bits present which are not enum values, so ignore - if !((field_value & !self.safe_mask).is_zero()) { - return captures - .get(0) - .map_or_else(|| "".to_string(), |m| m.as_str().to_string()); - } + if inverted { + field_value = !field_value; + } - let mut rvalue: String; - if field_value.is_zero() { - rvalue = self.default_value.to_string(); - } else { - // n.b.! there may be values missing from the enums which would - // result in an incorrect value being produced. - rvalue = self.enum_values.iter() - .map(|(mask, name)| - if !((*mask & field_value).is_zero()) { - Some(name) - } else { - None - }) - .filter(|e| e.is_some()) - .map(|e| *e.unwrap()) - .collect::>() - .join(" | "); - - if field_value.count_ones() > 1 && - (invert == "~" || inverted) { - rvalue = format!("({})", rvalue); - } + let invert: String; + if field_value.count_ones() > ((size_of::() as u32) * 8 / 2) { + invert = "~".to_string(); + field_value = !field_value; + } else { + invert = "".to_string(); + } + + // there are bits present which are not enum values, so ignore + if !((field_value & !self.safe_mask).is_zero()) { + return captures + .get(0) + .map_or_else(|| "".to_string(), |m| m.as_str().to_string()); + } + + let mut rvalue: String; + if field_value.is_zero() { + rvalue = self.default_value.to_string(); + } else { + // n.b.! there may be values missing from the enums which would + // result in an incorrect value being produced. + rvalue = self.enum_values.iter() + .map(|(mask, name)| + if !((*mask & field_value).is_zero()) { + Some(name) + } else { + None + }) + .filter(|e| e.is_some()) + .map(|e| *e.unwrap()) + .collect::>() + .join(" | "); + + if field_value.count_ones() > 1 && + (operator == "^" || operator == "&" || operator == "|" || + invert == "~" || inverted) { + rvalue = format!("({})", rvalue); } - return format!("{}{}{};", assignment.to_string(), invert, rvalue); } + return format!("{}{}{}{}", prefix.to_string(), invert, rvalue, terminal_string); } captures .get(0) diff --git a/tools/lints/sotn-lint/src/drawflags.rs b/tools/lints/sotn-lint/src/drawflags.rs index 56d7af5ffc..527e252f18 100644 --- a/tools/lints/sotn-lint/src/drawflags.rs +++ b/tools/lints/sotn-lint/src/drawflags.rs @@ -106,4 +106,20 @@ mod tests { let result = FT.transform_line(input_line); assert_eq!(result, expected_line) } + + #[test] + fn test_equality() { + let input_line = "if (self->drawFlags == 8) {"; + let expected_line = "if (self->drawFlags == FLAG_DRAW_UNK8) {"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_inequality() { + let input_line = "if (self->drawFlags != 8) {"; + let expected_line = "if (self->drawFlags != FLAG_DRAW_UNK8) {"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } } diff --git a/tools/lints/sotn-lint/src/drawmodes.rs b/tools/lints/sotn-lint/src/drawmodes.rs index e43025dc03..9098aa9aa6 100644 --- a/tools/lints/sotn-lint/src/drawmodes.rs +++ b/tools/lints/sotn-lint/src/drawmodes.rs @@ -118,6 +118,21 @@ mod tests { let expected_line = "self->drawMode &= ~(DRAW_UNK_200 | DRAW_UNK_100);"; let result = DMT.transform_line(input_line); assert_eq!(result, expected_line) + } + #[test] + fn test_equality() { + let input_line = "if (self->drawMode == 8) {"; + let expected_line = "if (self->drawMode == DRAW_HIDE) {"; + let result = DMT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_inequality() { + let input_line = "if (self->drawMode != 8) {"; + let expected_line = "if (self->drawMode != DRAW_HIDE) {"; + let result = DMT.transform_line(input_line); + assert_eq!(result, expected_line) } } diff --git a/tools/lints/sotn-lint/src/flags.rs b/tools/lints/sotn-lint/src/flags.rs index 8960d9f5b7..92ed770aff 100644 --- a/tools/lints/sotn-lint/src/flags.rs +++ b/tools/lints/sotn-lint/src/flags.rs @@ -161,4 +161,44 @@ mod tests { let result = FT.transform_line(input_line); assert_eq!(result, expected_line) } + + #[test] + fn test_equality() { + let input_line = "if (self->flags == 256) {"; + let expected_line = "if (self->flags == FLAG_DEAD) {"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_inequality() { + let input_line = "if (self->flags != 256) {"; + let expected_line = "if (self->flags != FLAG_DEAD) {"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_bitwise_and() { + let input_line = "if (D_8003C708.flags & 0x60) {"; + let expected_line = "if (D_8003C708.flags & (FLAG_UNK_40 | FLAG_UNK_20)) {"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_bitwise_or() { + let input_line = "D_8003C708.flags | 0x40;"; + let expected_line = "D_8003C708.flags | FLAG_UNK_40;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } + + #[test] + fn test_bitwise_xor() { + let input_line = "D_8003C708.flags ^ 0x40;"; + let expected_line = "D_8003C708.flags ^ FLAG_UNK_40;"; + let result = FT.transform_line(input_line); + assert_eq!(result, expected_line) + } }