Clean-up Bullet.cpp

This commit is contained in:
Clownacy 2019-11-15 21:55:48 +00:00
parent 9c32a5dd05
commit 16c03115c9
2 changed files with 1189 additions and 1191 deletions

View file

@ -64,33 +64,35 @@ BULLET_TABLE gBulTbl[46] =
BULLET gBul[BULLET_MAX];
void InitBullet()
void InitBullet(void)
{
// Identical to ClearBullet
for (int i = 0; i < BULLET_MAX; i++)
int i;
for (i = 0; i < BULLET_MAX; ++i)
gBul[i].cond = 0;
}
int CountArmsBullet(int arms_code)
{
int i;
int count = 0;
for (int i = 0; i < BULLET_MAX; i++)
{
for (i = 0; i < BULLET_MAX; ++i)
if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == arms_code)
++count;
}
return count;
}
int CountBulletNum(int bullet_code)
{
int i;
int count = 0;
for (int i = 0; i < BULLET_MAX; i++)
{
for (i = 0; i < BULLET_MAX; ++i)
if (gBul[i].cond & 0x80 && gBul[i].code_bullet == bullet_code)
++count;
}
return count;
}
@ -98,21 +100,19 @@ int CountBulletNum(int bullet_code)
void DeleteBullet(int code)
{
int i;
int unknown = 0; // Not the original name
for (i = 0; i < BULLET_MAX; i++)
{
if (gBul[i].cond & 0x80)
{
if ((gBul[i].code_bullet + 2) / 3 == code)
int count = 0; // Guessed name. This is unused, and was optimised out of the Linux port.
for (i = 0; i < BULLET_MAX; ++i)
if (gBul[i].cond & 0x80 && (gBul[i].code_bullet + 2) / 3 == code)
gBul[i].cond = 0;
}
}
}
void ClearBullet()
void ClearBullet(void)
{
// Identical to InitBullet
for (int i = 0; i < BULLET_MAX; i++)
int i;
for (i = 0; i < BULLET_MAX; ++i)
gBul[i].cond = 0;
}
@ -121,7 +121,7 @@ void PutBullet(int fx, int fy)
int i;
int x, y;
for (i = 0; i < BULLET_MAX; i++)
for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
@ -145,7 +145,7 @@ void PutBullet(int fx, int fy)
break;
}
PutBitmap3(&grcGame, x / 0x200 - fx / 0x200, y / 0x200 - fy / 0x200, &gBul[i].rect, SURFACE_ID_BULLET);
PutBitmap3(&grcGame, (x / 0x200) - (fx / 0x200), (y / 0x200) - (fy / 0x200), &gBul[i].rect, SURFACE_ID_BULLET);
}
}
}
@ -167,14 +167,14 @@ void SetBullet(int no, int x, int y, int dir)
gBul[i].life = gBulTbl[no].life;
gBul[i].life_count = gBulTbl[no].life_count;
gBul[i].bbits = gBulTbl[no].bbits;
gBul[i].enemyXL = gBulTbl[no].enemyXL << 9;
gBul[i].enemyYL = gBulTbl[no].enemyYL << 9;
gBul[i].blockXL = gBulTbl[no].blockXL << 9;
gBul[i].blockYL = gBulTbl[no].blockYL << 9;
gBul[i].view.back = gBulTbl[no].view.back << 9;
gBul[i].view.front = gBulTbl[no].view.front << 9;
gBul[i].view.top = gBulTbl[no].view.top << 9;
gBul[i].view.bottom = gBulTbl[no].view.bottom << 9;
gBul[i].enemyXL = gBulTbl[no].enemyXL * 0x200;
gBul[i].enemyYL = gBulTbl[no].enemyYL * 0x200;
gBul[i].blockXL = gBulTbl[no].blockXL * 0x200;
gBul[i].blockYL = gBulTbl[no].blockYL * 0x200;
gBul[i].view.back = gBulTbl[no].view.back * 0x200;
gBul[i].view.front = gBulTbl[no].view.front * 0x200;
gBul[i].view.top = gBulTbl[no].view.top * 0x200;
gBul[i].view.bottom = gBulTbl[no].view.bottom * 0x200;
gBul[i].x = x;
gBul[i].y = y;
}
@ -185,9 +185,9 @@ void ActBullet_Frontia1(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
bul->ani_no = Random(0, 2);
@ -242,7 +242,6 @@ void ActBullet_Frontia1(BULLET *bul)
bul->rect = rcLeft[bul->ani_no];
else
bul->rect = rcRight[bul->ani_no];
}
}
void ActBullet_Frontia2(BULLET *bul, int level)
@ -251,9 +250,9 @@ void ActBullet_Frontia2(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
bul->ani_no = Random(0, 2);
@ -366,10 +365,9 @@ void ActBullet_Frontia2(BULLET *bul, int level)
bul->rect = rect[bul->ani_no];
if (level == 2)
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100);
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, NULL, 0x100);
else
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, 0, 0x100);
}
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, NULL, 0x100);
}
void ActBullet_PoleStar(BULLET *bul, int level)
@ -382,9 +380,9 @@ void ActBullet_PoleStar(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
bul->act_no = 1;
@ -471,6 +469,7 @@ void ActBullet_PoleStar(BULLET *bul, int level)
bul->rect = rect1[0];
break;
case 2:
if (bul->direct == 1 || bul->direct == 3)
bul->rect = rect2[1];
@ -478,6 +477,7 @@ void ActBullet_PoleStar(BULLET *bul, int level)
bul->rect = rect2[0];
break;
case 3:
if (bul->direct == 1 || bul->direct == 3)
bul->rect = rect3[1];
@ -486,7 +486,6 @@ void ActBullet_PoleStar(BULLET *bul, int level)
break;
}
}
}
void ActBullet_FireBall(BULLET *bul, int level)
@ -501,16 +500,16 @@ void ActBullet_FireBall(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
bBreak = FALSE;
if (bul->flag & 2 && bul->flag & 8)
bBreak = TRUE;
if (bul->flag & 1 && bul->flag & 4)
bBreak = TRUE;
if (!bul->direct && bul->flag & 1)
if (bul->direct == 0 && bul->flag & 1)
bul->direct = 2;
if (bul->direct == 2 && bul->flag & 4)
bul->direct = 0;
@ -520,9 +519,9 @@ void ActBullet_FireBall(BULLET *bul, int level)
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 0);
PlaySoundObject(28, 1);
return;
}
else
{
if (bul->act_no == 0)
{
bul->act_no = 1;
@ -532,6 +531,7 @@ void ActBullet_FireBall(BULLET *bul, int level)
case 0:
bul->xm = -0x400;
break;
case 1:
bul->xm = gMC.xm;
@ -547,9 +547,11 @@ void ActBullet_FireBall(BULLET *bul, int level)
bul->ym = -0x5FF;
break;
case 2:
bul->xm = 0x400;
break;
case 3:
bul->xm = gMC.xm;
@ -601,7 +603,7 @@ void ActBullet_FireBall(BULLET *bul, int level)
SET_RECT(rect_right2[1], 208, 16, 224, 32)
SET_RECT(rect_right2[2], 192, 16, 208, 32)
bul->ani_no++;
++bul->ani_no;
if (level == 1)
{
@ -624,11 +626,9 @@ void ActBullet_FireBall(BULLET *bul, int level)
bul->rect = rect_right2[bul->ani_no];
if (level == 2)
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, 0, 0x100);
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no, NULL, 0x100);
else
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, 0, 0x100);
}
}
SetNpChar(129, bul->x, bul->y, 0, -0x200, bul->ani_no + 3, NULL, 0x100);
}
}
@ -661,9 +661,9 @@ void ActBullet_MachineGun(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
switch (level)
@ -711,22 +711,23 @@ void ActBullet_MachineGun(BULLET *bul, int level)
case 1:
bul->rect = rect1[bul->direct];
break;
case 2:
bul->rect = rect2[bul->direct];
if (bul->direct == 1 || bul->direct == 3)
SetNpChar(127, bul->x, bul->y, 0, 0, 1, 0, 256);
SetNpChar(127, bul->x, bul->y, 0, 0, 1, NULL, 0x100);
else
SetNpChar(127, bul->x, bul->y, 0, 0, 0, 0, 256);
SetNpChar(127, bul->x, bul->y, 0, 0, 0, NULL, 0x100);
break;
case 3:
bul->rect = rect3[bul->direct];
SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, 0, 256);
SetNpChar(128, bul->x, bul->y, 0, 0, bul->direct, NULL, 0x100);
break;
}
}
}
}
void ActBullet_Missile(BULLET *bul, int level)
@ -892,16 +893,16 @@ void ActBullet_Missile(BULLET *bul, int level)
switch (bul->direct)
{
case 0:
SetCaret(bul->x + 0x1000, bul->y, 7, 2);
SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2);
break;
case 1:
SetCaret(bul->x, bul->y + 0x1000, 7, 3);
SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3);
break;
case 2:
SetCaret(bul->x - 0x1000, bul->y, 7, 0);
SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0);
break;
case 3:
SetCaret(bul->x, bul->y - 0x1000, 7, 1);
SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1);
break;
}
}
@ -968,22 +969,23 @@ void ActBullet_Bom(BULLET *bul, int level)
{
case 1:
if (bul->act_wait % 3 == 0)
SetDestroyNpCharUp(bul->x + (Random(-16, 16) << 9), bul->y + (Random(-16, 16) << 9), bul->enemyXL, 2);
SetDestroyNpCharUp(bul->x + (Random(-16, 16) * 0x200), bul->y + (Random(-16, 16) * 0x200), bul->enemyXL, 2);
break;
case 2:
if (bul->act_wait % 3 == 0)
SetDestroyNpCharUp(bul->x + (Random(-32, 32) << 9), bul->y + (Random(-32, 32) << 9), bul->enemyXL, 2);
SetDestroyNpCharUp(bul->x + (Random(-32, 32) * 0x200), bul->y + (Random(-32, 32) * 0x200), bul->enemyXL, 2);
break;
case 3:
if (bul->act_wait % 3 == 0)
SetDestroyNpCharUp(bul->x + (Random(-40, 40) << 9), bul->y + (Random(-40, 40) << 9), bul->enemyXL, 2);
SetDestroyNpCharUp(bul->x + (Random(-40, 40) * 0x200), bul->y + (Random(-40, 40) * 0x200), bul->enemyXL, 2);
break;
}
if (--bul->act_wait < 0)
bul->cond = 0;
break;
}
}
@ -996,9 +998,9 @@ void ActBullet_Bubblin1(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 0);
return;
}
else
{
switch (bul->act_no)
{
case 0:
@ -1026,16 +1028,16 @@ void ActBullet_Bubblin1(BULLET *bul)
switch (bul->direct)
{
case 0:
bul->xm += 42;
bul->xm += 0x2A;
break;
case 2:
bul->xm -= 42;
bul->xm -= 0x2A;
break;
case 1:
bul->ym += 42;
bul->ym += 0x2A;
break;
case 3:
bul->ym -= 42;
bul->ym -= 0x2A;
break;
}
@ -1063,7 +1065,6 @@ void ActBullet_Bubblin1(BULLET *bul)
bul->ani_no = 3;
bul->rect = rect[bul->ani_no];
}
}
void ActBullet_Bubblin2(BULLET *bul)
@ -1086,9 +1087,9 @@ void ActBullet_Bubblin2(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 2, 0);
return;
}
else
{
switch (bul->act_no)
{
case 0:
@ -1157,7 +1158,6 @@ void ActBullet_Bubblin2(BULLET *bul)
bul->ani_no = 3;
bul->rect = rect[bul->ani_no];
}
}
void ActBullet_Bubblin3(BULLET *bul)
@ -1174,9 +1174,10 @@ void ActBullet_Bubblin3(BULLET *bul)
SetBullet(22, bul->x, bul->y, 3);
else
SetBullet(22, bul->x, bul->y, gMC.direct);
return;
}
else
{
switch (bul->act_no)
{
case 0:
@ -1245,7 +1246,6 @@ void ActBullet_Bubblin3(BULLET *bul)
bul->ani_no = 3;
bul->rect = rect[bul->ani_no];
}
}
void ActBullet_Spine(BULLET *bul)
@ -1254,9 +1254,9 @@ void ActBullet_Spine(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
bul->act_no = 1;
@ -1322,7 +1322,6 @@ void ActBullet_Spine(BULLET *bul)
bul->rect = rcDown[bul->ani_no];
break;
}
}
}
void ActBullet_Sword1(BULLET *bul)
@ -1331,9 +1330,9 @@ void ActBullet_Sword1(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->count1 == 3)
bul->bbits &= ~4;
@ -1393,7 +1392,6 @@ void ActBullet_Sword1(BULLET *bul)
bul->rect = rcLeft[bul->ani_no];
else
bul->rect = rcRight[bul->ani_no];
}
}
void ActBullet_Sword2(BULLET *bul)
@ -1402,9 +1400,9 @@ void ActBullet_Sword2(BULLET *bul)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->count1 == 3)
bul->bbits &= ~4;
@ -1464,7 +1462,6 @@ void ActBullet_Sword2(BULLET *bul)
bul->rect = rcLeft[bul->ani_no];
else
bul->rect = rcRight[bul->ani_no];
}
}
void ActBullet_Sword3(BULLET *bul)
@ -1591,12 +1588,12 @@ void ActBullet_Edge(BULLET *bul)
{
case 0:
bul->act_no = 1;
bul->y -= 0x1800;
bul->y -= 12 * 0x200;
if (bul->direct == 0)
bul->x += 0x2000;
bul->x += 16 * 0x200;
else
bul->x -= 0x2000;
bul->x -= 16 * 0x200;
// Fallthrough
case 1:
if (++bul->ani_wait > 2)
@ -1606,11 +1603,11 @@ void ActBullet_Edge(BULLET *bul)
}
if (bul->direct == 0)
bul->x -= 0x400;
bul->x -= 2 * 0x200;
else
bul->x += 0x400;
bul->x += 2 * 0x200;
bul->y += 0x400;
bul->y += 2 * 0x200;
if (bul->ani_no == 1)
bul->damage = 2;
@ -1823,16 +1820,16 @@ void ActBullet_SuperMissile(BULLET *bul, int level)
switch (bul->direct)
{
case 0:
SetCaret(bul->x + 0x1000, bul->y, 7, 2);
SetCaret(bul->x + (8 * 0x200), bul->y, 7, 2);
break;
case 1:
SetCaret(bul->x, bul->y + 0x1000, 7, 3);
SetCaret(bul->x, bul->y + (8 * 0x200), 7, 3);
break;
case 2:
SetCaret(bul->x - 0x1000, bul->y, 7, 0);
SetCaret(bul->x - (8 * 0x200), bul->y, 7, 0);
break;
case 3:
SetCaret(bul->x, bul->y - 0x1000, 7, 1);
SetCaret(bul->x, bul->y - (8 * 0x200), 7, 1);
break;
}
}
@ -1917,9 +1914,9 @@ void ActBullet_Nemesis(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->act_no == 0)
{
bul->act_no = 1;
@ -1956,16 +1953,16 @@ void ActBullet_Nemesis(BULLET *bul, int level)
switch (bul->direct)
{
case 0:
SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, 0, 0x100);
SetNpChar(4, bul->x, bul->y, -0x200, Random(-0x200, 0x200), 2, NULL, 0x100);
break;
case 1:
SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, 0, 0x100);
SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), -0x200, 2, NULL, 0x100);
break;
case 2:
SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, 0, 0x100);
SetNpChar(4, bul->x, bul->y, 0x200, Random(-0x200, 0x200), 2, NULL, 0x100);
break;
case 3:
SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, 0, 0x100);
SetNpChar(4, bul->x, bul->y, Random(-0x200, 0x200), 0x200, 2, NULL, 0x100);
break;
}
}
@ -2013,11 +2010,10 @@ void ActBullet_Nemesis(BULLET *bul, int level)
break;
}
bul->rect.top += 32 * ((level - 1) / 2);
bul->rect.bottom += 32 * ((level - 1) / 2);
bul->rect.left += (level - 1) % 2 << 7;
bul->rect.right += (level - 1) % 2 << 7;
}
bul->rect.top += ((level - 1) / 2) * 32;
bul->rect.bottom += ((level - 1) / 2) * 32;
bul->rect.left += ((level - 1) % 2) * 128;
bul->rect.right += ((level - 1) % 2) * 128;
}
void ActBullet_Spur(BULLET *bul, int level)
@ -2026,9 +2022,9 @@ void ActBullet_Spur(BULLET *bul, int level)
{
bul->cond = 0;
SetCaret(bul->x, bul->y, 3, 0);
return;
}
else
{
if (bul->damage && bul->life != 100)
bul->damage = 0;
@ -2143,16 +2139,17 @@ void ActBullet_Spur(BULLET *bul, int level)
break;
}
SetBullet(level + 39, bul->x, bul->y, bul->direct);
}
SetBullet(39 + level, bul->x, bul->y, bul->direct);
}
void ActBullet_SpurTail(BULLET *bul, int level)
{
if (++bul->count1 > 20)
bul->ani_no = bul->count1 - 20;
if (bul->ani_no > 2)
bul->cond = 0;
if (bul->damage && bul->life != 100)
bul->damage = 0;
@ -2225,13 +2222,12 @@ void ActBullet_EnemyClear(BULLET *bul)
if (++bul->count1 > bul->life_count)
{
bul->cond = 0;
return;
}
else
{
bul->damage = 10000;
bul->enemyXL = 0xC8000;
bul->enemyYL = 0xC8000;
}
}
void ActBullet_Star(BULLET *bul)
@ -2240,9 +2236,11 @@ void ActBullet_Star(BULLET *bul)
bul->cond = 0;
}
void ActBullet()
void ActBullet(void)
{
for (int i = 0; i < BULLET_MAX; i++)
int i;
for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
@ -2251,8 +2249,7 @@ void ActBullet()
gBul[i].cond = 0;
continue;
}
else
{
switch (gBul[i].code_bullet)
{
case 1:
@ -2393,33 +2390,34 @@ void ActBullet()
}
}
}
}
}
BOOL IsActiveSomeBullet(void)
{
for (int i = 0; i < 0x40; ++i)
int i;
for (i = 0; i < BULLET_MAX; ++i)
{
if (gBul[i].cond & 0x80)
{
switch (gBul[i].code_bullet)
{
case 0xD:
case 0xE:
case 0xF:
case 0x10:
case 0x11:
case 0x12:
case 0x17:
case 0x19:
case 0x1A:
case 0x1B:
case 0x1C:
case 0x1D:
case 0x1E:
case 0x1F:
case 0x20:
case 0x21:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 23:
case 25:
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
case 32:
case 33:
return TRUE;
}
}

View file

@ -60,12 +60,12 @@ struct BULLET_TABLE
#define BULLET_MAX 0x40
extern BULLET gBul[BULLET_MAX];
void InitBullet();
void InitBullet(void);
int CountArmsBullet(int arms_code);
int CountBulletNum(int bullet_code);
void DeleteBullet(int code);
void ClearBullet();
void ClearBullet(void);
void PutBullet(int fx, int fy);
void SetBullet(int no, int x, int y, int dir);
void ActBullet();
void ActBullet(void);
BOOL IsActiveSomeBullet(void);