Made Boss.cpp ASM-accurate

This commit is contained in:
Clownacy 2019-05-05 19:16:09 +01:00
parent 626dcdf34e
commit dea995ffe6
2 changed files with 247 additions and 195 deletions

View file

@ -1794,6 +1794,34 @@ addr = 0x46E9E0
name = "ActNpc360" name = "ActNpc360"
addr = 0x46EA90 addr = 0x46EA90
[[func]]
name = "InitBossChar"
addr = 0x472740
[[func]]
name = "PutBossChar"
addr = 0x472770
[[func]]
name = "SetBossCharActNo"
addr = 0x472940
[[func]]
name = "HitBossBullet"
addr = 0x472950
[[func]]
name = "ActBossChar_0"
addr = 0x472FF0
[[func]]
name = "ActBossChar"
addr = 0x473000
[[func]]
name = "HitBossMap"
addr = 0x473080
[[func]] [[func]]
name = "ActBossChar_Core_Face" name = "ActBossChar_Core_Face"
addr = 0x4739B0 addr = 0x4739B0

View file

@ -36,14 +36,14 @@ void InitBossChar(int code)
void PutBossChar(int fx, int fy) void PutBossChar(int fx, int fy)
{ {
char a = 0;
for (int b = BOSS_MAX - 1; b >= 0; b--) for (int b = BOSS_MAX - 1; b >= 0; b--)
{ {
if (gBoss[b].cond & 0x80) if (gBoss[b].cond & 0x80)
{ {
int a;
if (gBoss[b].shock) if (gBoss[b].shock)
{ {
a = 2 * ((gBoss[b].shock >> 1) & 1) - 1; a = 2 * (gBoss[b].shock / 2 % 2) - 1;
} }
else else
{ {
@ -57,10 +57,10 @@ void PutBossChar(int fx, int fy)
} }
int side; int side;
if (gBoss[b].direct) if (gBoss[b].direct == 0)
side = gBoss[b].view.back;
else
side = gBoss[b].view.front; side = gBoss[b].view.front;
else
side = gBoss[b].view.back;
PutBitmap3( PutBitmap3(
&grcGame, &grcGame,
@ -79,35 +79,44 @@ void SetBossCharActNo(int a)
void HitBossBullet() void HitBossBullet()
{ {
for (int bos = 0; bos < BOSS_MAX; bos++) int bos;
int bul;
int bos_;
BOOL bHit;
for (bos = 0; bos < BOSS_MAX; bos++)
{ {
if (gBoss[bos].cond & 0x80) if ((gBoss[bos].cond & 0x80) == 0)
{ continue;
for (int bul = 0; bul < BULLET_MAX; bul++)
{ for (bul = 0; bul < BULLET_MAX; bul++)
if (gBul[bul].cond & 0x80 && gBul[bul].damage != -1)
{ {
if ((gBul[bul].cond & 0x80) == 0)
continue;
if (gBul[bul].damage == -1)
continue;
//Check if bullet touches boss //Check if bullet touches boss
bool bHit = false; bHit = FALSE;
if (gBoss[bos].bits & npc_shootable if (gBoss[bos].bits & npc_shootable
&& gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].enemyXL && gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].enemyXL
&& gBoss[bos].x + gBoss[bos].hit.back > gBul[bul].x - gBul[bul].enemyXL && gBoss[bos].x + gBoss[bos].hit.back > gBul[bul].x - gBul[bul].enemyXL
&& gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].enemyYL && gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].enemyYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].enemyYL) && gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].enemyYL)
bHit = true; bHit = TRUE;
else if (gBoss[bos].bits & npc_invulnerable else if (gBoss[bos].bits & npc_invulnerable
&& gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].blockXL && gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].blockXL
&& gBoss[bos].x + gBoss[bos].hit.back > gBul[bul].x - gBul[bul].blockXL && gBoss[bos].x + gBoss[bos].hit.back > gBul[bul].x - gBul[bul].blockXL
&& gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL && gBoss[bos].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL) && gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL)
bHit = true; bHit = TRUE;
if (bHit) if (bHit)
{ {
//Damage boss //Damage boss
if (gBoss[bos].bits & npc_shootable) if (gBoss[bos].bits & npc_shootable)
{ {
int bos_;
if (gBoss[bos].cond & 0x10) if (gBoss[bos].cond & 0x10)
bos_ = 0; bos_ = 0;
else else
@ -115,21 +124,7 @@ void HitBossBullet()
gBoss[bos_].life -= gBul[bul].damage; gBoss[bos_].life -= gBul[bul].damage;
if (gBoss[bos_].life > 0) if (gBoss[bos_].life < 1)
{
if (gBoss[bos].shock < 14)
{
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
PlaySoundObject(gBoss[bos_].hit_voice, 1);
}
gBoss[bos].shock = 8;
gBoss[bos_].shock = 8;
gBoss[bos_].damage_view -= gBul[bul].damage;
}
else
{ {
gBoss[bos_].life = bos_; gBoss[bos_].life = bos_;
@ -157,28 +152,41 @@ void HitBossBullet()
gBoss[bos_].cond = 0; gBoss[bos_].cond = 0;
} }
} }
else
{
if (gBoss[bos].shock < 14)
{
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
SetCaret(gBul[bul].x, gBul[bul].y, 11, 0);
PlaySoundObject(gBoss[bos_].hit_voice, 1);
}
if (--gBul[bul].life <= 0) gBoss[bos].shock = 8;
gBoss[bos_].shock = 8;
gBoss[bos_].damage_view -= gBul[bul].damage;
}
if (--gBul[bul].life < 1)
gBul[bul].cond = 0; gBul[bul].cond = 0;
} }
else if (gBul[bul].code_bullet != 13 else if (gBul[bul].code_bullet == 13
&& gBul[bul].code_bullet != 14 || gBul[bul].code_bullet == 14
&& gBul[bul].code_bullet != 15 || gBul[bul].code_bullet == 15
&& gBul[bul].code_bullet != 28 || gBul[bul].code_bullet == 28
&& gBul[bul].code_bullet != 29 || gBul[bul].code_bullet == 29
&& gBul[bul].code_bullet != 30) || gBul[bul].code_bullet == 30)
{
--gBul[bul].life;
}
else
{ {
if (!(gBul[bul].bbits & 0x10)) if (!(gBul[bul].bbits & 0x10))
{ {
SetCaret(gBul[bul].x, gBul[bul].y, 2, 2); SetCaret(gBul[bul].x, gBul[bul].y, 2, 2);
PlaySoundObject(31, 1); PlaySoundObject(31, 1);
gBul[bul].cond = 0; gBul[bul].cond = 0;
} continue;
}
else
{
gBul[bul].life--;
}
} }
} }
} }
@ -207,23 +215,32 @@ BOSSFUNCTION gpBossFuncTbl[10] =
void ActBossChar() void ActBossChar()
{ {
if (gBoss[0].cond & 0x80) int bos;
{ int code_char;
gpBossFuncTbl[gBoss[0].code_char]();
for (int bos = 0; bos < BOSS_MAX; bos++) if ((gBoss[0].cond & 0x80) == 0)
return;
code_char = gBoss[0].code_char;
gpBossFuncTbl[code_char]();
for (bos = 0; bos < BOSS_MAX; bos++)
{ {
if (gBoss[bos].shock) if (gBoss[bos].shock)
gBoss[bos].shock--; gBoss[bos].shock--;
} }
}
} }
void HitBossMap() void HitBossMap()
{ {
int offx[16]; int offx[16];
int offy[16]; int offy[16];
uint8_t atrb[16]; unsigned char atrb[16];
int b;
int j;
int x;
int y;
offx[0] = 0; offx[0] = 0;
offx[1] = 1; offx[1] = 1;
@ -259,42 +276,45 @@ void HitBossMap()
offy[14] = -1; offy[14] = -1;
offy[15] = -1; offy[15] = -1;
for (int b = 0; b < BOSS_MAX; b++) for (b = 0; b < BOSS_MAX; b++)
{
if ((gBoss[b].cond & 0x80) && !(gBoss[b].bits & npc_ignoreSolid))
{ {
int judg; int judg;
if (gBoss[b].size < 3)
judg = 4;
else
judg = 16;
int x = gBoss[b].x / 0x2000; if ((gBoss[b].cond & 0x80) == 0)
int y = gBoss[b].y / 0x2000; continue;
if (gBoss[b].bits & npc_ignoreSolid)
continue;
if (gBoss[b].size >= 3)
{
judg = 16;
x = gBoss[b].x / 0x10 / 0x200;
y = gBoss[b].y / 0x10 / 0x200;
}
else
{
judg = 4;
x = gBoss[b].x / 0x10 / 0x200;
y = gBoss[b].y / 0x10 / 0x200;
}
gBoss[b].flag = 0; gBoss[b].flag = 0;
for (int j = 0; j < judg; j++) for (j = 0; j < judg; j++)
{ {
atrb[j] = GetAttribute(x + offx[j], y + offy[j]); atrb[j] = GetAttribute(x + offx[j], y + offy[j]);
switch (atrb[j]) switch (atrb[j])
{ {
case 0x02: case 0x44:
case 0x60: if (gBoss[b].bits & npc_ignore44)
case 0x61:
case 0x64:
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
// Fallthrough
case 0x05: case 0x05:
case 0x41: case 0x41:
case 0x43: case 0x43:
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]); JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x44:
if (!(gBoss[b].bits & npc_ignore44))
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]);
break;
case 0x50: case 0x50:
JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
@ -319,6 +339,13 @@ void HitBossMap()
case 0x57: case 0x57:
JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x02:
case 0x60:
case 0x61:
case 0x64:
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]);
break;
case 0x70: case 0x70:
JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]);
@ -351,9 +378,6 @@ void HitBossMap()
JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]);
JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
default:
continue;
}
} }
} }
} }