Made NpcAct100.cpp almost ASM-accurate

One bit compiles identically, but with the wrong registers. I'm hoping
this will go away once the memory layout's accurate enough.
This commit is contained in:
Clownacy 2019-02-25 01:19:54 +00:00
parent a65bf3bb60
commit 27bfd3914c

View file

@ -20,10 +20,12 @@ void ActNpc100(NPCHAR *npc)
{272, 48, 288, 64}, {272, 48, 288, 64},
}; };
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
npc->y += 0x2000; npc->y += 0x2000;
npc->act_no = 1; npc->act_no = 1;
break;
} }
if (npc->direct == 0) if (npc->direct == 0)
@ -182,6 +184,7 @@ void ActNpc104(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 0; npc->ani_no = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
break;
} }
break; break;
@ -225,13 +228,13 @@ void ActNpc104(NPCHAR *npc)
case 11: case 11:
if (npc->flag & 1 && npc->xm < 0) if (npc->flag & 1 && npc->xm < 0)
{ {
npc->xm = -npc->xm; npc->xm *= -1;
npc->direct = 2; npc->direct = 2;
} }
if (npc->flag & 4 && npc->xm > 0) if (npc->flag & 4 && npc->xm > 0)
{ {
npc->xm = -npc->xm; npc->xm *= -1;
npc->direct = 0; npc->direct = 0;
} }
@ -245,23 +248,27 @@ void ActNpc104(NPCHAR *npc)
break; break;
} }
bool bJump = false; BOOL bJump = FALSE;
if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10) if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10)
{ {
if (npc->shock) if (npc->shock)
bJump = true; 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 - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000)
{
// For some reason this blank space is needed for the function to compile accurately
}
else
{ {
if (Random(0, 50) == 2) if (Random(0, 50) == 2)
bJump = true; bJump = TRUE;
} }
} }
if (bJump) if (bJump)
{ {
if (gMC.x > npc->x) if (npc->x < gMC.x)
npc->direct = 2; npc->direct = 2;
else else
npc->direct = 0; npc->direct = 0;
@ -303,7 +310,7 @@ void ActNpc105(NPCHAR *npc)
if (++npc->act_wait > 30) if (++npc->act_wait > 30)
npc->cond = 0; npc->cond = 0;
if (npc->act_wait <= 4) if (npc->act_wait < 5)
npc->y -= 0x200; npc->y -= 0x200;
npc->rect = rect[npc->ani_no]; npc->rect = rect[npc->ani_no];
@ -312,16 +319,20 @@ void ActNpc105(NPCHAR *npc)
//'HEY!' speech bubble (high) //'HEY!' speech bubble (high)
void ActNpc106(NPCHAR *npc) void ActNpc106(NPCHAR *npc)
{ {
if (npc->act_no == 0) switch (npc->act_no)
{ {
case 0:
SetNpChar(105, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x180); SetNpChar(105, npc->x, npc->y - 0x1000, 0, 0, 0, 0, 0x180);
npc->act_no = 1; npc->act_no = 1;
break;
} }
} }
//Malco //Malco
void ActNpc107(NPCHAR *npc) void ActNpc107(NPCHAR *npc)
{ {
int i;
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0:
@ -337,7 +348,7 @@ void ActNpc107(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
for (int i = 0; i < 4; ++i) 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, 0, 0x100);
// Fallthrough // Fallthrough
@ -394,7 +405,7 @@ void ActNpc107(NPCHAR *npc)
npc->ani_no = 2; npc->ani_no = 2;
PlaySoundObject(12, 1); PlaySoundObject(12, 1);
for (int i = 0; i < 8; ++i) 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, 0, 0x100);
// Fallthrough // Fallthrough
@ -428,7 +439,7 @@ void ActNpc107(NPCHAR *npc)
npc->act_no = 20; npc->act_no = 20;
PlaySoundObject(12, 1); PlaySoundObject(12, 1);
for (int i = 0; i < 4; ++i) 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, 0, 0x100);
} }
@ -522,6 +533,8 @@ void ActNpc108(NPCHAR *npc)
//Malco (broken) //Malco (broken)
void ActNpc109(NPCHAR *npc) void ActNpc109(NPCHAR *npc)
{ {
int i;
RECT rcLeft[2] = { RECT rcLeft[2] = {
{240, 0, 256, 24}, {240, 0, 256, 24},
{256, 0, 272, 24}, {256, 0, 272, 24},
@ -549,9 +562,9 @@ void ActNpc109(NPCHAR *npc)
npc->ani_no = 1; npc->ani_no = 1;
} }
if (gMC.x > npc->x - 0x4000 && gMC.x < npc->x + 0x4000 && gMC.y > npc->y - 0x4000 && gMC.y < npc->y + 0x2000) if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x && npc->y - 0x4000 < gMC.y && npc->y + 0x2000 > gMC.y)
{ {
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -572,7 +585,7 @@ void ActNpc109(NPCHAR *npc)
npc->act_no = 0; npc->act_no = 0;
PlaySoundObject(12, 1); PlaySoundObject(12, 1);
for (int i = 0; i < 8; ++i) 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, 0, 0x100);
break; break;
@ -640,6 +653,7 @@ void ActNpc110(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 0; npc->ani_no = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
break;
} }
break; break;
@ -683,13 +697,13 @@ void ActNpc110(NPCHAR *npc)
case 11: case 11:
if (npc->flag & 1 && npc->xm < 0) if (npc->flag & 1 && npc->xm < 0)
{ {
npc->xm = -npc->xm; npc->xm *= -1;
npc->direct = 2; npc->direct = 2;
} }
if (npc->flag & 4 && npc->xm > 0) if (npc->flag & 4 && npc->xm > 0)
{ {
npc->xm = -npc->xm; npc->xm *= -1;
npc->direct = 0; npc->direct = 0;
} }
@ -703,23 +717,27 @@ void ActNpc110(NPCHAR *npc)
break; break;
} }
bool bJump = false; BOOL bJump = FALSE;
if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10) if (npc->act_no < 10 && npc->act_no != 3 && npc->act_wait > 10)
{ {
if (npc->shock) if (npc->shock)
bJump = true; 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 - 0x14000 || npc->x > gMC.x + 0x14000 || npc->y < gMC.y - 0x8000 || npc->y > gMC.y + 0x8000)
{
// For some reason this blank space is needed for the function to compile accurately
}
else
{ {
if (Random(0, 50) == 2) if (Random(0, 50) == 2)
bJump = true; bJump = TRUE;
} }
} }
if (bJump) if (bJump)
{ {
if (gMC.x > npc->x) if (npc->x < gMC.x)
npc->direct = 2; npc->direct = 2;
else else
npc->direct = 0; npc->direct = 0;
@ -1059,12 +1077,12 @@ void ActNpc114(NPCHAR *npc)
npc->y -= 0x800; npc->y -= 0x800;
// Fallthrough // Fallthrough
case 1: case 1:
if (!(npc->flag & 8)) if (npc->flag & 8)
{ break;
npc->act_no = 10; npc->act_no = 10;
npc->ani_wait = 0; npc->ani_wait = 0;
npc->ani_no = 1; npc->ani_no = 1;
}
break; break;
case 10: case 10:
@ -1104,6 +1122,8 @@ void ActNpc114(NPCHAR *npc)
npc->damage = 0; npc->damage = 0;
npc->bits |= 0x40; npc->bits |= 0x40;
} }
break;
} }
npc->ym += 0x20; npc->ym += 0x20;
@ -1118,6 +1138,8 @@ void ActNpc114(NPCHAR *npc)
//Ravil //Ravil
void ActNpc115(NPCHAR *npc) void ActNpc115(NPCHAR *npc)
{ {
int i;
RECT rcLeft[6] = { RECT rcLeft[6] = {
{0, 120, 24, 144}, {0, 120, 24, 144},
{24, 120, 48, 144}, {24, 120, 48, 144},
@ -1181,7 +1203,7 @@ void ActNpc115(NPCHAR *npc)
if (npc->ani_no > 2) if (npc->ani_no > 2)
{ {
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1227,7 +1249,7 @@ void ActNpc115(NPCHAR *npc)
break; break;
case 30: case 30:
for (int i = 0; i < 8; ++i) 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, 0, 0x100);
npc->ani_no = 0; npc->ani_no = 0;
@ -1314,7 +1336,7 @@ void ActNpc117(NPCHAR *npc)
case 0: case 0:
if (npc->direct == 4) if (npc->direct == 4)
{ {
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1330,6 +1352,8 @@ void ActNpc117(NPCHAR *npc)
break; break;
case 3: case 3:
// TODO: This code is being problematic, and
// assembling with the wrong registers.
npc->act_no = 4; npc->act_no = 4;
npc->ani_no = 1; npc->ani_no = 1;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -1368,7 +1392,7 @@ void ActNpc117(NPCHAR *npc)
npc->ani_no = 1; npc->ani_no = 1;
npc->ani_wait = 0; npc->ani_wait = 0;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1493,12 +1517,12 @@ void ActNpc118(NPCHAR *npc)
{160, 56, 192, 80}, {160, 56, 192, 80},
}; };
bool bUpper = false; BOOL bUpper = FALSE;
if (npc->direct == 0 && gMC.x > npc->x) if (npc->direct == 0 && npc->x < gMC.x)
bUpper = true; bUpper = TRUE;
if ( npc->direct == 2 && gMC.x < npc->x) if ( npc->direct == 2 && npc->x > gMC.x)
bUpper = true; bUpper = TRUE;
switch (npc->act_no) switch (npc->act_no)
{ {
@ -1513,7 +1537,7 @@ void ActNpc118(NPCHAR *npc)
npc->act_wait = Random(50, 100); npc->act_wait = Random(50, 100);
npc->ani_no = 0; npc->ani_no = 0;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1534,7 +1558,7 @@ void ActNpc118(NPCHAR *npc)
npc->ani_no = 3; npc->ani_no = 3;
npc->act_wait = Random(50, 100); npc->act_wait = Random(50, 100);
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1569,7 +1593,7 @@ void ActNpc118(NPCHAR *npc)
break; break;
case 20: case 20:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;