Made NpcAct300.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-02-25 17:02:21 +00:00
parent d921729820
commit 2d0607df32
3 changed files with 103 additions and 94 deletions

View file

@ -2,6 +2,8 @@
#include <string.h> #include <string.h>
#include "WindowsWrapper.h"
#include "Draw.h" #include "Draw.h"
#include "Caret.h" #include "Caret.h"
#include "Game.h" #include "Game.h"
@ -2397,7 +2399,7 @@ void ActBullet()
} }
} }
bool IsActiveSomeBullet(void) BOOL IsActiveSomeBullet(void)
{ {
for (int i = 0; i < 0x40; ++i) for (int i = 0; i < 0x40; ++i)
{ {
@ -2421,10 +2423,10 @@ bool IsActiveSomeBullet(void)
case 0x1F: case 0x1F:
case 0x20: case 0x20:
case 0x21: case 0x21:
return true; return TRUE;
} }
} }
} }
return false; return FALSE;
} }

View file

@ -58,4 +58,4 @@ void ClearBullet();
void PutBullet(int fx, int fy); void PutBullet(int fx, int fy);
void SetBullet(int no, int x, int y, int dir); void SetBullet(int no, int x, int y, int dir);
void ActBullet(); void ActBullet();
bool IsActiveSomeBullet(void); BOOL IsActiveSomeBullet(void);

View file

@ -1,5 +1,7 @@
#include "NpcAct.h" #include "NpcAct.h"
#include <stddef.h>
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Back.h" #include "Back.h"
@ -19,12 +21,10 @@ void ActNpc300(NPCHAR *npc)
{ {
RECT rc = {192, 80, 208, 96}; RECT rc = {192, 80, 208, 96};
switch (npc->act_no) if (npc->act_no == 0)
{ {
case 0:
npc->act_no = 1; npc->act_no = 1;
npc->y += 0xC00; npc->y += 0xC00;
break;
} }
if (++npc->ani_wait % 8 == 1) if (++npc->ani_wait % 8 == 1)
@ -163,8 +163,8 @@ void ActNpc302(NPCHAR *npc)
} }
// Fallthrough // Fallthrough
case 101: case 101:
npc->x = (npc->pNpc->x + gMC.x) / 2; npc->x = (gMC.x + npc->pNpc->x) / 2;
npc->y = (npc->pNpc->y + gMC.y) / 2; npc->y = (gMC.y + npc->pNpc->y) / 2;
break; break;
} }
} }
@ -182,19 +182,21 @@ void ActNpc303(NPCHAR *npc)
{232, 168, 248, 184}, {232, 168, 248, 184},
}; };
if (npc->pNpc) if (npc->pNpc == NULL)
{ return;
//Set position //Set position
if (npc->pNpc->direct) if (npc->pNpc->direct == 0)
{
npc->direct = 2;
npc->x = npc->pNpc->x + 0x1000;
}
else
{ {
npc->direct = 0; npc->direct = 0;
npc->x = npc->pNpc->x - 0x1000; npc->x = npc->pNpc->x - 0x1000;
} }
else
{
npc->direct = 2;
npc->x = npc->pNpc->x + 0x1000;
}
npc->y = npc->pNpc->y; npc->y = npc->pNpc->y;
//Animation //Animation
@ -203,11 +205,10 @@ void ActNpc303(NPCHAR *npc)
npc->y -= 0x200; npc->y -= 0x200;
//Set framerect //Set framerect
if (npc->direct) if (npc->direct == 0)
npc->rect = rcRight[npc->ani_no];
else
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
} else
npc->rect = rcRight[npc->ani_no];
} }
//Gaudi in hospital //Gaudi in hospital
@ -286,10 +287,10 @@ void ActNpc305(NPCHAR *npc)
break; break;
} }
if (npc->direct) if (npc->direct == 0)
npc->rect = rcRight[npc->ani_no];
else
npc->rect = rcLeft[npc->ani_no]; npc->rect = rcLeft[npc->ani_no];
else
npc->rect = rcRight[npc->ani_no];
} }
//Balrog (nurse) //Balrog (nurse)
@ -418,7 +419,7 @@ void ActNpc308(NPCHAR *npc)
npc->xm2 = 0; npc->xm2 = 0;
npc->ym2 = 0; npc->ym2 = 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;
@ -446,7 +447,8 @@ void ActNpc308(NPCHAR *npc)
npc->act_no = 21; npc->act_no = 21;
npc->act_wait = 0; npc->act_wait = 0;
deg = GetArktan(npc->x - gMC.x, npc->y - gMC.y) + Random(-3, 3); deg = (unsigned char)GetArktan(npc->x - gMC.x, npc->y - gMC.y);
deg += (unsigned char)Random(-3, 3);
npc->ym2 = 2 * GetSin(deg); npc->ym2 = 2 * GetSin(deg);
npc->xm2 = 2 * GetCos(deg); npc->xm2 = 2 * GetCos(deg);
@ -459,19 +461,19 @@ void ActNpc308(NPCHAR *npc)
if (npc->xm2 < 0 && npc->flag & 1) if (npc->xm2 < 0 && npc->flag & 1)
{ {
npc->direct = 2; npc->direct = 2;
npc->xm2 = -npc->xm2; npc->xm2 *= -1;
} }
if (npc->xm2 > 0 && npc->flag & 4) if (npc->xm2 > 0 && npc->flag & 4)
{ {
npc->direct = 0; npc->direct = 0;
npc->xm2 = -npc->xm2; npc->xm2 *= -1;
} }
if (npc->ym2 < 0 && npc->flag & 2) if (npc->ym2 < 0 && npc->flag & 2)
npc->ym2 = -npc->ym2; npc->ym2 *= -1;
if (npc->ym2 > 0 && npc->flag & 8) if (npc->ym2 > 0 && npc->flag & 8)
npc->ym2 = -npc->ym2; npc->ym2 *= -1;
if (npc->flag & 0x100) if (npc->flag & 0x100)
npc->ym2 = -0x200; npc->ym2 = -0x200;
@ -515,20 +517,22 @@ void ActNpc309(NPCHAR *npc)
case 1: case 1:
if (npc->direct == 0) if (npc->direct == 0)
{ {
if (gMC.x <= npc->x - 0x24000 || gMC.x >= npc->x - 0x22000) if (gMC.x > npc->x - 0x24000 && gMC.x < npc->x - 0x22000)
return; {
npc->act_no = 10; npc->act_no = 10;
break;
}
} }
else else
{ {
if (gMC.x >= npc->x + 0x24000 || gMC.x <= npc->x + 0x22000) if (gMC.x < npc->x + 0x24000 && gMC.x > npc->x + 0x22000)
return; {
npc->act_no = 10; npc->act_no = 10;
break;
}
} }
break; return;
case 10: case 10:
npc->act_no = 11; npc->act_no = 11;
@ -536,7 +540,7 @@ void ActNpc309(NPCHAR *npc)
npc->damage = 5; npc->damage = 5;
// Fallthrough // Fallthrough
case 11: case 11:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -546,20 +550,20 @@ void ActNpc309(NPCHAR *npc)
else else
npc->xm2 += 0x10; npc->xm2 += 0x10;
if (gMC.y < npc->y) if (npc->y > gMC.y)
npc->ym2 -= 0x10; npc->ym2 -= 0x10;
else else
npc->ym2 += 0x10; npc->ym2 += 0x10;
if (npc->xm2 < 0 && npc->flag & 1) if (npc->xm2 < 0 && npc->flag & 1)
npc->xm2 = -npc->xm2; npc->xm2 *= -1;
if (npc->xm2 > 0 && npc->flag & 4) if (npc->xm2 > 0 && npc->flag & 4)
npc->xm2 = -npc->xm2; npc->xm2 *= -1;
if (npc->ym2 < 0 && npc->flag & 2) if (npc->ym2 < 0 && npc->flag & 2)
npc->ym2 = -npc->ym2; npc->ym2 *= -1;
if (npc->ym2 > 0 && npc->flag & 8) if (npc->ym2 > 0 && npc->flag & 8)
npc->ym2 = -npc->ym2; npc->ym2 *= -1;
if (npc->xm2 < -0x5FF) if (npc->xm2 < -0x5FF)
npc->xm2 = -0x5FF; npc->xm2 = -0x5FF;
@ -626,7 +630,7 @@ void ActNpc310(NPCHAR *npc)
npc->damage = 0; npc->damage = 0;
// Fallthrough // Fallthrough
case 1: case 1:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -660,7 +664,7 @@ void ActNpc310(NPCHAR *npc)
npc->bits |= 0x20; npc->bits |= 0x20;
npc->damage = 0; npc->damage = 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;
@ -795,7 +799,7 @@ void ActNpc311(NPCHAR *npc)
npc->act_no = 11; npc->act_no = 11;
// Fallthrough // Fallthrough
case 11: case 11:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -821,16 +825,16 @@ void ActNpc311(NPCHAR *npc)
npc->act_wait = 0; npc->act_wait = 0;
// Fallthrough // Fallthrough
case 21: case 21:
if (npc->count1) if (npc->count1 == 0)
{
if (++npc->ani_no > 5)
npc->ani_no = 4;
}
else
{ {
if (++npc->ani_no > 2) if (++npc->ani_no > 2)
npc->ani_no = 1; npc->ani_no = 1;
} }
else
{
if (++npc->ani_no > 5)
npc->ani_no = 4;
}
if (++npc->act_wait > 30) if (++npc->act_wait > 30)
npc->act_no = 30; npc->act_no = 30;
@ -841,16 +845,7 @@ void ActNpc311(NPCHAR *npc)
npc->act_no = 31; npc->act_no = 31;
npc->act_wait = 0; npc->act_wait = 0;
if (npc->count1) if (npc->count1 == 0)
{
if (npc->direct == 0)
SetNpChar(312, npc->x, npc->y, -0x600, -0x600, 0, 0, 0x100);
else
SetNpChar(312, npc->x, npc->y, 0x600, -0x600, 2, 0, 0x100);
npc->ani_no = 6;
}
else
{ {
if (npc->direct == 0) if (npc->direct == 0)
SetNpChar(312, npc->x, npc->y, -0x600, 0, 0, 0, 0x100); SetNpChar(312, npc->x, npc->y, -0x600, 0, 0, 0, 0x100);
@ -859,6 +854,15 @@ void ActNpc311(NPCHAR *npc)
npc->ani_no = 3; npc->ani_no = 3;
} }
else
{
if (npc->direct == 0)
SetNpChar(312, npc->x, npc->y, -0x600, -0x600, 0, 0, 0x100);
else
SetNpChar(312, npc->x, npc->y, 0x600, -0x600, 2, 0, 0x100);
npc->ani_no = 6;
}
// Fallthrough // Fallthrough
case 31: case 31:
if (++npc->act_wait > 30) if (++npc->act_wait > 30)
@ -984,7 +988,10 @@ void ActNpc312(NPCHAR *npc)
// Fallthrough // Fallthrough
case 31: case 31:
if (++npc->act_wait > 30) if (++npc->act_wait > 30)
{
npc->cond = 0; npc->cond = 0;
return;
}
break; break;
} }
@ -1002,7 +1009,7 @@ void ActNpc312(NPCHAR *npc)
if (npc->act_no == 31) if (npc->act_no == 31)
{ {
if (npc->act_wait / 2 & 1) if (npc->act_wait / 2 % 2)
{ {
npc->rect.left = 0; npc->rect.left = 0;
npc->rect.right = 0; npc->rect.right = 0;
@ -1065,9 +1072,9 @@ void ActNpc313(NPCHAR *npc)
npc->ani_no = 1; npc->ani_no = 1;
} }
if (gMC.x > npc->x - 0x4000 && gMC.x < npc->x + 0x4000) if (npc->x - 0x4000 < gMC.x && npc->x + 0x4000 > gMC.x)
{ {
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1093,7 +1100,7 @@ void ActNpc313(NPCHAR *npc)
case 110: case 110:
npc->damage = 1; npc->damage = 1;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1136,11 +1143,11 @@ void ActNpc313(NPCHAR *npc)
npc->bits &= ~8; npc->bits &= ~8;
if (npc->xm < 0 && npc->flag & 1) if (npc->xm < 0 && npc->flag & 1)
npc->xm = -npc->xm; npc->xm *= -1;
if (npc->xm > 0 && npc->flag & 4) if (npc->xm > 0 && npc->flag & 4)
npc->xm = -npc->xm; npc->xm *= -1;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1222,7 +1229,7 @@ void ActNpc313(NPCHAR *npc)
npc->ani_no = 6; npc->ani_no = 6;
if (++npc->act_wait % 6 == 0) if (++npc->act_wait % 6 == 0)
SetNpChar(314, Random(4, 16) * 0x2000, 0x2000, 0, 0, 0, 0, 0x100); SetNpChar(314, Random(4, 16) * 0x200 * 0x10, 0x200 * 0x10, 0, 0, 0, 0, 0x100);
if (npc->act_wait > 30) if (npc->act_wait > 30)
{ {
@ -1239,7 +1246,7 @@ void ActNpc313(NPCHAR *npc)
npc->act_no = 301; npc->act_no = 301;
npc->ani_no = 9; npc->ani_no = 9;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1301,7 +1308,7 @@ void ActNpc313(NPCHAR *npc)
npc->ani_no = 12; npc->ani_no = 12;
if (++npc->act_wait % 6 == 0) if (++npc->act_wait % 6 == 0)
SetNpChar(315, Random(4, 16) * 0x2000, 0, 0, 0, 0, 0, 0x100); SetNpChar(315, Random(4, 16) * 0x200 * 0x10, 0, 0, 0, 0, 0, 0x100);
if (npc->act_wait > 30) if (npc->act_wait > 30)
{ {
@ -1403,7 +1410,7 @@ void ActNpc314(NPCHAR *npc)
case 110: case 110:
npc->ym += 0x40; npc->ym += 0x40;
if (npc->y > (gMap.length * 0x2000) + 0x4000) if (npc->y > (gMap.length * 0x200 * 0x10) + (2 * 0x200 * 0x10))
{ {
npc->cond = 0; npc->cond = 0;
return; return;
@ -1469,7 +1476,7 @@ void ActNpc315(NPCHAR *npc)
npc->bits |= 0x20; npc->bits |= 0x20;
// Fallthrough // Fallthrough
case 110: case 110:
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1502,11 +1509,11 @@ void ActNpc315(NPCHAR *npc)
npc->ym += 0x80; npc->ym += 0x80;
if (npc->xm < 0 && npc->flag & 1) if (npc->xm < 0 && npc->flag & 1)
npc->xm = -npc->xm; npc->xm *= -1;
if (npc->xm > 0 && npc->flag & 4) if (npc->xm > 0 && npc->flag & 4)
npc->xm = -npc->xm; npc->xm *= -1;
if (gMC.x < npc->x) if (npc->x > gMC.x)
npc->direct = 0; npc->direct = 0;
else else
npc->direct = 2; npc->direct = 2;
@ -1683,7 +1690,7 @@ void ActNpc317(NPCHAR *npc)
npc->count1 = 0; npc->count1 = 0;
// Fallthrough // Fallthrough
case 2: case 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;