Made NpChar.cpp ASM-accurate

SetBulletObject has a commented-out if, it seems, and the leftover
braces affected the ASM.
This commit is contained in:
Clownacy 2019-06-30 00:57:19 +01:00
parent c162d06f96
commit 5167a341aa

View file

@ -238,52 +238,59 @@ void SetExpObjects(int x, int y, int exp)
BOOL SetBulletObject(int x, int y, int val) BOOL SetBulletObject(int x, int y, int val)
{ {
int t = 0;
int bullet_no;
int tamakazu_ari[10];
int n; int n;
int bullet_no; // The Linux debug data claims there's a 3-line gap between this and the next variable declaration. Just enough space for an 'if' statement.
memset(tamakazu_ari, 0, sizeof(tamakazu_ari)); // if (/* unknown */)
for (n = 0; n < 8; ++n) { // This is necessary for accurate ASM (stack frame layout)
{ int tamakazu_ari[10];
switch (gArmsData[n].code) int t = 0;
memset(tamakazu_ari, 0, sizeof(tamakazu_ari));
for (n = 0; n < 8; ++n)
{ {
case 5: switch (gArmsData[n].code)
tamakazu_ari[t++] = 0; {
break; case 5:
tamakazu_ari[t++] = 0;
break;
case 10: case 10:
tamakazu_ari[t++] = 1; tamakazu_ari[t++] = 1;
break; break;
default: default:
tamakazu_ari[t] = 0; tamakazu_ari[t] = 0;
break; break;
}
} }
if (t == 0)
return FALSE;
n = Random(1, 10 * t);
bullet_no = tamakazu_ari[n % t];
n = 0x100;
while (n < NPC_MAX && gNPC[n].cond)
++n;
if (n == NPC_MAX)
return FALSE;
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_event = bullet_no;
gNPC[n].code_char = 86;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = val;
SetUniqueParameter(&gNPC[n]);
} }
if (t == 0)
return FALSE;
n = Random(1, 10 * t);
bullet_no = tamakazu_ari[n % t];
n = 0x100;
while (n < NPC_MAX && gNPC[n].cond)
++n;
if (n == NPC_MAX)
return FALSE;
memset(&gNPC[n], 0, sizeof(NPCHAR));
gNPC[n].cond |= 0x80;
gNPC[n].direct = 0;
gNPC[n].code_event = bullet_no;
gNPC[n].code_char = 86;
gNPC[n].x = x;
gNPC[n].y = y;
gNPC[n].bits = gNpcTable[gNPC[n].code_char].bits;
gNPC[n].exp = val;
SetUniqueParameter(&gNPC[n]);
return TRUE; return TRUE;
} }