diff --git a/src/NpcAct100.cpp b/src/NpcAct100.cpp index c56b9d5e..0c7ec627 100644 --- a/src/NpcAct100.cpp +++ b/src/NpcAct100.cpp @@ -1,5 +1,7 @@ #include "NpcAct.h" +#include + #include "WindowsWrapper.h" #include "Bullet.h" @@ -21,7 +23,7 @@ void ActNpc100(NPCHAR *npc) switch (npc->act_no) { case 0: - npc->y += 0x2000; + npc->y += 16 * 0x200; npc->act_no = 1; break; } @@ -66,7 +68,7 @@ void ActNpc102(NPCHAR *npc) if (npc->act_no == 0) { npc->act_no = 1; - npc->y += 0x1000; + npc->y += 8 * 0x200; } if (++npc->ani_wait > 0) @@ -136,6 +138,8 @@ void ActNpc103(NPCHAR *npc) // Frog void ActNpc104(NPCHAR *npc) { + BOOL bJump; + RECT rcLeft[3] = { {0, 112, 32, 144}, {32, 112, 64, 144}, @@ -168,10 +172,8 @@ void ActNpc104(NPCHAR *npc) npc->act_no = 3; break; } - else - { - npc->bits &= ~NPC_IGNORE_SOLIDITY; - } + + npc->bits &= ~NPC_IGNORE_SOLIDITY; // Fallthrough case 1: ++npc->act_wait; @@ -246,16 +248,17 @@ void ActNpc104(NPCHAR *npc) break; } - BOOL bJump = FALSE; + bJump = FALSE; if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10) { if (npc->shock) bJump = TRUE; - if (npc->x < gMC.x - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000) + if (npc->x < gMC.x - (160 * 0x200) || npc->x > gMC.x + (160 * 0x200) || npc->y < gMC.y - (64 * 0x200) || npc->y > gMC.y + (64 * 0x200)) { - // For some reason this blank space is needed for the function to compile accurately + // This blank space is needed for the function to produce the same assembly. + // Chances are there used to be some commented-out code here. } else { @@ -309,7 +312,7 @@ void ActNpc105(NPCHAR *npc) npc->cond = 0; if (npc->act_wait < 5) - npc->y -= 0x200; + npc->y -= 1 * 0x200; npc->rect = rect[npc->ani_no]; } @@ -320,7 +323,7 @@ void ActNpc106(NPCHAR *npc) switch (npc->act_no) { case 0: - SetNpChar(105, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x180); + SetNpChar(105, npc->x, npc->y - (8 * 0x200), 0, 0, 0, NULL, 0x180); npc->act_no = 1; break; } @@ -347,7 +350,7 @@ void ActNpc107(NPCHAR *npc) npc->ani_wait = 0; for (i = 0; i < 4; ++i) - SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); // Fallthrough case 11: @@ -384,12 +387,12 @@ void ActNpc107(NPCHAR *npc) case 15: if (npc->act_wait / 2 % 2) { - npc->x += 0x200; + npc->x += 1 * 0x200; PlaySoundObject(11, 1); } else { - npc->x -= 0x200; + npc->x -= 1 * 0x200; } if (++npc->act_wait > 50) @@ -404,7 +407,7 @@ void ActNpc107(NPCHAR *npc) PlaySoundObject(12, 1); for (i = 0; i < 8; ++i) - SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); // Fallthrough case 17: @@ -438,7 +441,7 @@ void ActNpc107(NPCHAR *npc) PlaySoundObject(12, 1); for (i = 0; i < 4; ++i) - SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); } break; @@ -546,7 +549,7 @@ void ActNpc109(NPCHAR *npc) switch (npc->act_no) { case 0: - if (--npc->act_wait) + if (--npc->act_wait != 0) npc->act_no = 1; npc->ani_no = 0; @@ -560,7 +563,7 @@ void ActNpc109(NPCHAR *npc) npc->ani_no = 1; } - if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y) + if (npc->x - (32 * 0x200) < gMC.x && npc->x + (32 * 0x200) > gMC.x && npc->y - (32 * 0x200) < gMC.y && npc->y + (16 * 0x200) > gMC.y) { if (npc->x > gMC.x) npc->direct = 0; @@ -584,7 +587,7 @@ void ActNpc109(NPCHAR *npc) PlaySoundObject(12, 1); for (i = 0; i < 8; ++i) - SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); break; } @@ -604,6 +607,8 @@ void ActNpc109(NPCHAR *npc) // Puchi void ActNpc110(NPCHAR *npc) { + BOOL bJump; + RECT rcLeft[3] = { {96, 128, 112, 144}, {112, 128, 128, 144}, @@ -626,7 +631,7 @@ void ActNpc110(NPCHAR *npc) if (npc->direct == 4) { - if (Random(0, 1) != 0) + if (Random(0, 1)) npc->direct = 0; else npc->direct = 2; @@ -637,10 +642,8 @@ void ActNpc110(NPCHAR *npc) break; } - else - { - npc->bits &= ~NPC_IGNORE_SOLIDITY; - } + + npc->bits &= ~NPC_IGNORE_SOLIDITY; // Fallthrough case 1: ++npc->act_wait; @@ -715,16 +718,17 @@ void ActNpc110(NPCHAR *npc) break; } - BOOL bJump = FALSE; + bJump = FALSE; if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10) { if (npc->shock) bJump = TRUE; - if (npc->x < gMC.x - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000) + if (npc->x < gMC.x - (160 * 0x200) || npc->x > gMC.x + (160 * 0x200) || npc->y < gMC.y - (64 * 0x200) || npc->y > gMC.y + (64 * 0x200)) { - // For some reason this blank space is needed for the function to compile accurately + // This blank space is needed for the function to produce the same assembly. + // Chances are there used to be some commented-out code here. } else { @@ -782,7 +786,7 @@ void ActNpc111(NPCHAR *npc) case 0: npc->act_no = 1; npc->ani_no = 0; - npc->y -= 0x2000; + npc->y -= 16 * 0x200; break; case 1: @@ -798,7 +802,7 @@ void ActNpc111(NPCHAR *npc) case 2: if (npc->ym > 0) - npc->hit.bottom = 0x2000; + npc->hit.bottom = 16 * 0x200; if (npc->flag & 8) { @@ -837,6 +841,7 @@ void ActNpc111(NPCHAR *npc) else npc->rect = rcRight[npc->ani_no]; + // Use a different sprite if the player is wearing the Mimiga Mask if (gMC.equip & 0x40) { npc->rect.top += 32; @@ -845,7 +850,7 @@ void ActNpc111(NPCHAR *npc) if (npc->act_no == 4) { - npc->rect.bottom = npc->rect.top + npc->act_wait / 4; + npc->rect.bottom = npc->rect.top + (npc->act_wait / 4); if (npc->act_wait / 2 % 2) ++npc->rect.left; @@ -871,8 +876,8 @@ void ActNpc112(NPCHAR *npc) npc->act_no = 1; npc->ani_no = 0; npc->ani_wait = 0; - npc->x += 0x2000; - npc->y += 0x1000; + npc->x += 16 * 0x200; + npc->y += 8 * 0x200; PlaySoundObject(29, 1); // Fallthrough case 1: @@ -889,7 +894,7 @@ void ActNpc112(NPCHAR *npc) { npc->act_no = 3; npc->ani_no = 1; - npc->hit.bottom = 0x1000; + npc->hit.bottom = 8 * 0x200; } break; @@ -913,6 +918,7 @@ void ActNpc112(NPCHAR *npc) else npc->rect = rcRight[npc->ani_no]; + // Use a different sprite if the player is wearing the Mimiga Mask if (gMC.equip & 0x40) { npc->rect.top += 32; @@ -921,7 +927,7 @@ void ActNpc112(NPCHAR *npc) if (npc->act_no == 1) { - npc->rect.bottom = npc->rect.top + npc->act_wait / 4; + npc->rect.bottom = npc->rect.top + (npc->act_wait / 4); if (npc->act_wait / 2 % 2) ++npc->rect.left; @@ -993,9 +999,9 @@ void ActNpc113(NPCHAR *npc) npc->ani_no = 2; if (npc->direct == 0) - npc->x -= 0x200; + npc->x -= 1 * 0x200; else - npc->x += 0x200; + npc->x += 1 * 0x200; break; @@ -1007,9 +1013,9 @@ void ActNpc113(NPCHAR *npc) npc->act_no = 31; npc->ani_no = 0; npc->ani_wait = 0; - npc->hit.bottom = 0x2000; - npc->x -= 0x2000; - npc->y += 0x1000; + npc->hit.bottom = 16 * 0x200; + npc->x -= 16 * 0x200; + npc->y += 8 * 0x200; PlaySoundObject(29, 1); // Fallthrough case 31: @@ -1026,7 +1032,7 @@ void ActNpc113(NPCHAR *npc) { npc->act_no = 33; npc->ani_no = 1; - npc->hit.bottom = 0x1000; + npc->hit.bottom = 8 * 0x200; } break; @@ -1052,7 +1058,7 @@ void ActNpc113(NPCHAR *npc) if (npc->act_no == 31) { - npc->rect.bottom = npc->rect.top + npc->act_wait / 4; + npc->rect.bottom = npc->rect.top + (npc->act_wait / 4); if (npc->act_wait / 2 % 2) ++npc->rect.left; @@ -1062,6 +1068,8 @@ void ActNpc113(NPCHAR *npc) // Press void ActNpc114(NPCHAR *npc) { + int i; + RECT rcLeft[3] = { {144, 112, 160, 136}, {160, 112, 176, 136}, @@ -1072,15 +1080,19 @@ void ActNpc114(NPCHAR *npc) { case 0: npc->act_no = 1; - npc->y -= 0x800; + npc->y -= 4 * 0x200; // Fallthrough case 1: if (npc->flag & 8) - break; - - npc->act_no = 10; - npc->ani_wait = 0; - npc->ani_no = 1; + { + // Chances are there used to be commented-out code here + } + else + { + npc->act_no = 10; + npc->ani_wait = 0; + npc->ani_no = 1; + } break; @@ -1109,8 +1121,8 @@ void ActNpc114(NPCHAR *npc) { if (npc->ani_no > 1) { - for (int i = 0; i < 4; ++i) - SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + for (i = 0; i < 4; ++i) + SetNpChar(4, npc->x, npc->y, Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); PlaySoundObject(26, 1); SetQuake(10); @@ -1166,7 +1178,7 @@ void ActNpc115(NPCHAR *npc) npc->count1 = 0; // Fallthrough case 1: - if (gMC.x < npc->x + 0xC000 && gMC.x > npc->x - 0xC000 && gMC.y < npc->y + 0x4000 && gMC.y > npc->y - 0xC000) + if (gMC.x < npc->x + (96 * 0x200) && gMC.x > npc->x - (96 * 0x200) && gMC.y < npc->y + (32 * 0x200) && gMC.y > npc->y - (96 * 0x200)) npc->act_no = 10; if (npc->shock) @@ -1241,7 +1253,7 @@ void ActNpc115(NPCHAR *npc) npc->ani_wait = 0; npc->damage = 0; - if (gMC.x > npc->x + 0x12000 || gMC.x < npc->x - 0x12000 || gMC.y > npc->y + 0x6000 || gMC.y < npc->y - 0x12000) + if (gMC.x > npc->x + (144 * 0x200) || gMC.x < npc->x - (144 * 0x200) || gMC.y > npc->y + (48 * 0x200) || gMC.y < npc->y - (144 * 0x200)) npc->act_no = 0; } @@ -1249,7 +1261,7 @@ void ActNpc115(NPCHAR *npc) case 30: for (i = 0; i < 8; ++i) - SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, 0, 0x100); + SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); npc->ani_no = 0; npc->act_no = 0; @@ -1353,14 +1365,14 @@ void ActNpc117(NPCHAR *npc) case 3: if (0) { - // There used to be an if here that didn't do anything, but the compiler optimised it out. - // We only know this was here because empty ifs mess with the register usage. + // There used to be an if-statement here that didn't do anything, but the compiler optimised it out. + // We only know this was here because empty if-statements affect the assembly's register usage. // Since there's no code, we have no idea what the original condition actually was. } if (0) { - // Another empty if + // Another empty if-statement } npc->act_no = 4; @@ -1395,8 +1407,8 @@ void ActNpc117(NPCHAR *npc) case 6: if (0) { - // There used to be an if here that didn't do anything, but the compiler optimised it out. - // We only know this was here because empty ifs mess with the register usage. + // There used to be an if-statement here that didn't do anything, but the compiler optimised it out. + // We only know this was here because empty if-statements affect the assembly's register usage. // Since there's no code, we have no idea what the original condition actually was. } @@ -1425,11 +1437,11 @@ void ActNpc117(NPCHAR *npc) npc->ani_no = 1; if (npc->direct == 0) - npc->x -= 0x200; + npc->x -= 1 * 0x200; else - npc->x += 0x200; + npc->x += 1 * 0x200; - if (gMC.x < npc->x + 0x2800 && gMC.x > npc->x - 0x2800) + if (gMC.x < npc->x + (20 * 0x200) && gMC.x > npc->x - (20 * 0x200)) npc->act_no = 0; break; @@ -1459,7 +1471,7 @@ void ActNpc117(NPCHAR *npc) npc->ym += 0x40; - if (npc->act_wait++ && npc->flag & 8) + if (npc->act_wait++ != 0 && npc->flag & 8) npc->act_no = 32; break; @@ -1562,7 +1574,7 @@ void ActNpc118(NPCHAR *npc) npc->bits &= ~NPC_INVULNERABLE; // Fallthrough case 11: - if (npc->act_wait) + if (npc->act_wait != 0) --npc->act_wait; else npc->act_no = 13; @@ -1594,7 +1606,7 @@ void ActNpc118(NPCHAR *npc) else npc->xm += 0x40; - if (npc->act_wait) + if (npc->act_wait != 0) { --npc->act_wait; } @@ -1614,7 +1626,7 @@ void ActNpc118(NPCHAR *npc) else npc->direct = 2; - npc->xm = 8 * npc->xm / 9; + npc->xm = (npc->xm * 8) / 9; if (++npc->ani_no > 1) npc->ani_no = 0; @@ -1635,13 +1647,13 @@ void ActNpc118(NPCHAR *npc) if (bUpper) { npc->ani_no = 2; - SetNpChar(123, npc->x, npc->y - 0x1000, 0, 0, 1, 0, 0x100); + SetNpChar(123, npc->x, npc->y - (8 * 0x200), 0, 0, 1, NULL, 0x100); } else { npc->ani_no = 0; - SetNpChar(123, npc->x - 0x1000, npc->y + 0x800, 0, 0, 0, 0, 0x100); - npc->x += 0x200; + SetNpChar(123, npc->x - (8 * 0x200), npc->y + (4 * 0x200), 0, 0, 0, NULL, 0x100); + npc->x += 1 * 0x200; } } else @@ -1649,13 +1661,13 @@ void ActNpc118(NPCHAR *npc) if (bUpper) { npc->ani_no = 2; - SetNpChar(123, npc->x, npc->y - 0x1000, 0, 0, 1, 0, 0x100); + SetNpChar(123, npc->x, npc->y - (8 * 0x200), 0, 0, 1, NULL, 0x100); } else { npc->ani_no = 0; - SetNpChar(123, npc->x + 0x1000, npc->y + 0x800, 0, 0, 2, 0, 0x100); - npc->x -= 0x200; + SetNpChar(123, npc->x + (8 * 0x200), npc->y + (4 * 0x200), 0, 0, 2, NULL, 0x100); + npc->x -= 1 * 0x200; } } }