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,107 +79,115 @@ 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 (bul = 0; bul < BULLET_MAX; bul++)
{ {
for (int bul = 0; bul < BULLET_MAX; bul++) if ((gBul[bul].cond & 0x80) == 0)
continue;
if (gBul[bul].damage == -1)
continue;
//Check if bullet touches boss
bHit = FALSE;
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].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].enemyYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].enemyYL)
bHit = TRUE;
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].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL)
bHit = TRUE;
if (bHit)
{ {
if (gBul[bul].cond & 0x80 && gBul[bul].damage != -1) //Damage boss
if (gBoss[bos].bits & npc_shootable)
{ {
//Check if bullet touches boss if (gBoss[bos].cond & 0x10)
bool bHit = false; bos_ = 0;
if (gBoss[bos].bits & npc_shootable else
&& gBoss[bos].x - gBoss[bos].hit.back < gBul[bul].x + gBul[bul].enemyXL bos_ = bos;
&& 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.bottom > gBul[bul].y - gBul[bul].enemyYL)
bHit = true;
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].y - gBoss[bos].hit.top < gBul[bul].y + gBul[bul].blockYL
&& gBoss[bos].y + gBoss[bos].hit.bottom > gBul[bul].y - gBul[bul].blockYL)
bHit = true;
if (bHit) gBoss[bos_].life -= gBul[bul].damage;
if (gBoss[bos_].life < 1)
{ {
//Damage boss gBoss[bos_].life = bos_;
if (gBoss[bos].bits & npc_shootable)
if ((gMC.cond & 0x80) && gBoss[bos_].bits & npc_eventDie)
{ {
int bos_; StartTextScript(gBoss[bos_].code_event);
if (gBoss[bos].cond & 0x10)
bos_ = 0;
else
bos_ = bos;
gBoss[bos_].life -= gBul[bul].damage;
if (gBoss[bos_].life > 0)
{
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_;
if ((gMC.cond & 0x80) && gBoss[bos_].bits & npc_eventDie)
{
StartTextScript(gBoss[bos_].code_event);
}
else
{
PlaySoundObject(gBoss[bos_].destroy_voice, 1);
switch (gBoss[bos_].size)
{
case 1:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 4);
break;
case 2:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 8);
break;
case 3:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 16);
break;
}
gBoss[bos_].cond = 0;
}
}
if (--gBul[bul].life <= 0)
gBul[bul].cond = 0;
}
else if (gBul[bul].code_bullet != 13
&& gBul[bul].code_bullet != 14
&& gBul[bul].code_bullet != 15
&& gBul[bul].code_bullet != 28
&& gBul[bul].code_bullet != 29
&& gBul[bul].code_bullet != 30)
{
if (!(gBul[bul].bbits & 0x10))
{
SetCaret(gBul[bul].x, gBul[bul].y, 2, 2);
PlaySoundObject(31, 1);
gBul[bul].cond = 0;
}
} }
else else
{ {
gBul[bul].life--; PlaySoundObject(gBoss[bos_].destroy_voice, 1);
switch (gBoss[bos_].size)
{
case 1:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 4);
break;
case 2:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 8);
break;
case 3:
SetDestroyNpChar(gBoss[bos_].x, gBoss[bos_].y, gBoss[bos_].view.back, 16);
break;
}
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);
}
gBoss[bos].shock = 8;
gBoss[bos_].shock = 8;
gBoss[bos_].damage_view -= gBul[bul].damage;
}
if (--gBul[bul].life < 1)
gBul[bul].cond = 0;
}
else if (gBul[bul].code_bullet == 13
|| gBul[bul].code_bullet == 14
|| gBul[bul].code_bullet == 15
|| gBul[bul].code_bullet == 28
|| gBul[bul].code_bullet == 29
|| gBul[bul].code_bullet == 30)
{
--gBul[bul].life;
}
else
{
if (!(gBul[bul].bbits & 0x10))
{
SetCaret(gBul[bul].x, gBul[bul].y, 2, 2);
PlaySoundObject(31, 1);
gBul[bul].cond = 0;
continue;
}
} }
} }
} }
@ -207,15 +215,20 @@ 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;
if (gBoss[bos].shock)
gBoss[bos].shock--; code_char = gBoss[0].code_char;
}
gpBossFuncTbl[code_char]();
for (bos = 0; bos < BOSS_MAX; bos++)
{
if (gBoss[bos].shock)
gBoss[bos].shock--;
} }
} }
@ -223,7 +236,11 @@ 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,101 +276,108 @@ 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;
if ((gBoss[b].cond & 0x80) == 0)
continue;
if (gBoss[b].bits & npc_ignoreSolid)
continue;
if (gBoss[b].size >= 3)
{ {
int judg; judg = 16;
if (gBoss[b].size < 3) x = gBoss[b].x / 0x10 / 0x200;
judg = 4; y = gBoss[b].y / 0x10 / 0x200;
else }
judg = 16; else
{
judg = 4;
x = gBoss[b].x / 0x10 / 0x200;
y = gBoss[b].y / 0x10 / 0x200;
}
int x = gBoss[b].x / 0x2000; gBoss[b].flag = 0;
int y = gBoss[b].y / 0x2000; for (j = 0; j < judg; j++)
{
atrb[j] = GetAttribute(x + offx[j], y + offy[j]);
gBoss[b].flag = 0; switch (atrb[j])
for (int j = 0; j < judg; j++)
{ {
atrb[j] = GetAttribute(x + offx[j], y + offy[j]); case 0x44:
if (gBoss[b].bits & npc_ignore44)
switch (atrb[j])
{
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; break;
case 0x05: // Fallthrough
case 0x41: case 0x05:
case 0x43: case 0x41:
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]); case 0x43:
break; JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]);
case 0x44: break;
if (!(gBoss[b].bits & npc_ignore44)) case 0x50:
JadgeHitNpCharBlock(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x50: case 0x51:
JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleB(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x51: case 0x52:
JudgeHitNpCharTriangleB(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleC(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x52: case 0x53:
JudgeHitNpCharTriangleC(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleD(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x53: case 0x54:
JudgeHitNpCharTriangleD(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleE(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x54: case 0x55:
JudgeHitNpCharTriangleE(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleF(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x55: case 0x56:
JudgeHitNpCharTriangleF(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleG(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x56: case 0x57:
JudgeHitNpCharTriangleG(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]);
break; break;
case 0x57: case 0x02:
JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]); case 0x60:
break; case 0x61:
case 0x70: case 0x64:
JudgeHitNpCharTriangleA(&gBoss[b], x + offx[j], y + offy[j]); JadgeHitNpCharBlock(&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;
case 0x71: case 0x70:
JudgeHitNpCharTriangleB(&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]);
break; break;
case 0x72: case 0x71:
JudgeHitNpCharTriangleC(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleB(&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;
case 0x73: case 0x72:
JudgeHitNpCharTriangleD(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleC(&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;
case 0x74: case 0x73:
JudgeHitNpCharTriangleE(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleD(&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;
case 0x75: case 0x74:
JudgeHitNpCharTriangleF(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleE(&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;
case 0x76: case 0x75:
JudgeHitNpCharTriangleG(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleF(&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;
case 0x77: case 0x76:
JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]); JudgeHitNpCharTriangleG(&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: case 0x77:
continue; JudgeHitNpCharTriangleH(&gBoss[b], x + offx[j], y + offy[j]);
} JudgeHitNpCharWater(&gBoss[b], x + offx[j], y + offy[j]);
break;
} }
} }
} }