Lots of code cleanup (#32)
### Description <!-- What is the purpose of this PR and what it adds? --> ### Will this Pull Request break anything? <!-- Will it break the compiling? --> ### Suggested Testing Steps <!-- See if the compiling fails/break anything in the game. -->
This commit is contained in:
135
src/sm_8d.c
135
src/sm_8d.c
@@ -4,15 +4,16 @@
|
||||
#include "funcs.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void CallPalfxFunc(uint32 ea, uint16 k, uint16 j);
|
||||
PairU16 CallPalInstr(uint32 ea, uint16 k, uint16 j);
|
||||
void CallPalFxPreInstr(uint32 ea, uint16 k);
|
||||
|
||||
void EnablePaletteFx(void) { // 0x8DC4C2
|
||||
flag_for_palette_fx_objects |= 0x8000u;
|
||||
flag_for_palette_fx_objects |= 0x8000;
|
||||
}
|
||||
|
||||
void DisablePaletteFx(void) { // 0x8DC4CD
|
||||
flag_for_palette_fx_objects &= ~0x8000u;
|
||||
flag_for_palette_fx_objects &= ~0x8000;
|
||||
}
|
||||
|
||||
void ClearPaletteFXObjects(void) { // 0x8DC4D8
|
||||
@@ -20,23 +21,13 @@ void ClearPaletteFXObjects(void) { // 0x8DC4D8
|
||||
palettefx_ids[i >> 1] = 0;
|
||||
}
|
||||
|
||||
void CallPalfxFunc(uint32 ea, uint16 k, uint16 j) {
|
||||
switch (ea) {
|
||||
case fnnullsub_131: return;
|
||||
case fnPalInit_E1BC: PalInit_E1BC(k, j); return;
|
||||
case fnPalInit_F761_Norfair1: PalInit_F761_Norfair1(k, j); return;
|
||||
case fnPalInit_F779_Brinstar8: PalInit_F779_Brinstar8(k, j); return;
|
||||
default: Unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void SpawnPalfxObject(uint16 j) { // 0x8DC4E9
|
||||
PalFxDef *PalFxDef;
|
||||
|
||||
uint16 v1 = 14;
|
||||
while (palettefx_ids[v1 >> 1]) {
|
||||
v1 -= 2;
|
||||
if ((v1 & 0x8000u) != 0)
|
||||
if ((v1 & 0x8000) != 0)
|
||||
return;
|
||||
}
|
||||
int v2 = v1 >> 1;
|
||||
@@ -54,7 +45,7 @@ void PalPreInstr_nullsub_129(uint16 k) { // 0x8DC526
|
||||
}
|
||||
|
||||
void PaletteFxHandler(void) { // 0x8DC527
|
||||
if ((flag_for_palette_fx_objects & 0x8000u) != 0) {
|
||||
if ((flag_for_palette_fx_objects & 0x8000) != 0) {
|
||||
for (int i = 14; i >= 0; i -= 2) {
|
||||
palettefx_index = i;
|
||||
if (palettefx_ids[i >> 1]) {
|
||||
@@ -65,48 +56,6 @@ void PaletteFxHandler(void) { // 0x8DC527
|
||||
}
|
||||
}
|
||||
|
||||
void CallPalFxPreInstr(uint32 ea, uint16 k) {
|
||||
switch (ea) {
|
||||
case fnPalPreInstr_nullsub_129: PalPreInstr_nullsub_129(k); return;
|
||||
case fnPalPreInstr_E1BC: PalPreInstr_E1BC(k); return;
|
||||
case fnPalPreInstr_CheckEnemy0Health: PalPreInstr_CheckEnemy0Health(k); return;
|
||||
case fnPalPreInstr_SamusInHeat: PalPreInstr_SamusInHeat(k); return;
|
||||
case fnPalPreInstr_DeletePalfxIfMinibossDead: PalPreInstr_DeletePalfxIfMinibossDead(k); return;
|
||||
case fnPalPreInstr_SwitchIfYpos: PalPreInstr_SwitchIfYpos(k); return;
|
||||
case fnPalPreInstr_SwitchIfYpos2: PalPreInstr_SwitchIfYpos2(k); return;
|
||||
case fnPalPreInstr_F621: PalPreInstr_F621(k); return;
|
||||
default: Unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
PairU16 CallPalInstr(uint32 ea, uint16 k, uint16 j) {
|
||||
switch (ea) {
|
||||
case fnPalInstr_Finish: return PalInstr_Finish(k, j);
|
||||
case fnPalInstr_ColorPlus2: return PalInstr_ColorPlus2(k, j);
|
||||
case fnPalInstr_ColorPlus3: return PalInstr_ColorPlus3(k, j);
|
||||
case fnPalInstr_ColorPlus4: return PalInstr_ColorPlus4(k, j);
|
||||
case fnPalInstr_ColorPlus8: return PalInstr_ColorPlus8(k, j);
|
||||
case fnPalInstr_ColorPlus9: return PalInstr_ColorPlus9(k, j);
|
||||
case fnPalInstr_ColorPlus15: return PalInstr_ColorPlus15(k, j);
|
||||
case fnPalInstr_Delete: return PalInstr_Delete(k, j);
|
||||
case fnPalInstr_SetPreInstr: return PalInstr_SetPreInstr(k, j);
|
||||
case fnPalInstr_ClearPreInstr: return PalInstr_ClearPreInstr(k, j);
|
||||
case fnPalInstr_Goto: return PalInstr_Goto(k, j);
|
||||
case fnPalInstr_GotoRel: return PalInstr_GotoRel(k, j);
|
||||
case fnPalInstr_DecTimerGoto: return PalInstr_DecTimerGoto(k, j);
|
||||
case fnPalInstr_DecTimerGotoRel: return PalInstr_DecTimerGotoRel(k, j);
|
||||
case fnPalInstr_SetTimer: return PalInstr_SetTimer(k, j);
|
||||
case fnPalInstr_SetColorIndex: return PalInstr_SetColorIndex(k, j);
|
||||
case fnPalInstr_QueueMusic: return PalInstr_QueueMusic(k, j);
|
||||
case fnPalInstr_QueueSfx1: return PalInstr_QueueSfx1(k, j);
|
||||
case fnPalInstr_QueueSfx2: return PalInstr_QueueSfx2(k, j);
|
||||
case fnPalInstr_QueueSfx3: return PalInstr_QueueSfx3(k, j);
|
||||
case fnPalInstr_SetTimerIfBossBit: return PalInstr_SetTimerIfBossBit(k, j);
|
||||
case fnPalInstr_SetPalfxIndex: return PalInstr_SetPalfxIndex(k, j);
|
||||
default: Unreachable(); return (PairU16){0, 0};
|
||||
}
|
||||
}
|
||||
|
||||
void PalFx_ProcessOne(uint16 k) { // 0x8DC54A
|
||||
PairU16 v7;
|
||||
int16 v11;
|
||||
@@ -120,9 +69,8 @@ void PalFx_ProcessOne(uint16 k) { // 0x8DC54A
|
||||
while (1) {
|
||||
const uint16 *v5 = (const uint16 *)RomPtr_8D(j);
|
||||
v6 = *v5;
|
||||
if ((*v5 & 0x8000u) == 0)
|
||||
if ((*v5 & 0x8000) == 0)
|
||||
break;
|
||||
R18_ = *v5;
|
||||
v7 = CallPalInstr(v6 | 0x8D0000, v1, j + 2);
|
||||
v1 = v7.k;
|
||||
j = v7.j;
|
||||
@@ -143,7 +91,6 @@ void PalFx_ProcessOne(uint16 k) { // 0x8DC54A
|
||||
v9 += 2;
|
||||
j += 2;
|
||||
}
|
||||
R18_ = GET_WORD(v10 + 2);
|
||||
v12 = CallPalInstr((uint16)v11 | 0x8D0000, v9, j);
|
||||
v9 = v12.k;
|
||||
j = v12.j;
|
||||
@@ -201,7 +148,6 @@ PairU16 PalInstr_Goto(uint16 k, uint16 j) { // 0x8DC61E
|
||||
}
|
||||
|
||||
PairU16 PalInstr_GotoRel(uint16 k, uint16 j) { // 0x8DC623
|
||||
R18_ = j;
|
||||
return MakePairU16(k, j + (int8)*RomPtr_8D(j));
|
||||
}
|
||||
|
||||
@@ -281,8 +227,8 @@ void PalPreInstr_SamusInHeat(uint16 k) { // 0x8DE379
|
||||
uint16 v1 = (__PAIR32__(samus_periodic_damage, samus_periodic_subdamage) + 0x4000) >> 16;
|
||||
samus_periodic_subdamage += 0x4000;
|
||||
samus_periodic_damage = v1;
|
||||
if ((nmi_frame_counter_word & 7) == 0 && samus_health > 0x46u)
|
||||
QueueSfx3_Max6(0x2Du);
|
||||
if ((nmi_frame_counter_word & 7) == 0 && samus_health > 0x46)
|
||||
QueueSfx3_Max6(0x2D);
|
||||
}
|
||||
if (samus_in_heat_palfx_index != samus_in_heat_palettefx_prev_index) {
|
||||
samus_in_heat_palettefx_prev_index = samus_in_heat_palfx_index;
|
||||
@@ -296,7 +242,6 @@ void PalPreInstr_SamusInHeat(uint16 k) { // 0x8DE379
|
||||
} else {
|
||||
v4 = addr_off_8DE420;
|
||||
}
|
||||
R18_ = v4;
|
||||
palettefx_instr_list_ptrs[v3] = *(uint16 *)&RomPtr_8D(v4)[v2];
|
||||
}
|
||||
}
|
||||
@@ -314,7 +259,7 @@ void PalInit_F761_Norfair1(uint16 k, uint16 j) { // 0x8DE440
|
||||
}
|
||||
|
||||
PairU16 PalInstr_SetTimerIfBossBit(uint16 k, uint16 j) { // 0x8DEB2A
|
||||
if (!(CheckBossBitForCurArea(1u) & 1)) {
|
||||
if (!(CheckBossBitForCurArea(1) & 1)) {
|
||||
palettefx_instr_timers[k >> 1] = 1;
|
||||
return MakePairU16(k, 0);
|
||||
}
|
||||
@@ -322,7 +267,7 @@ PairU16 PalInstr_SetTimerIfBossBit(uint16 k, uint16 j) { // 0x8DEB2A
|
||||
}
|
||||
|
||||
void PalPreInstr_SwitchIfYpos(uint16 k) { // 0x8DEC59
|
||||
if (samus_y_pos < 0x380u) {
|
||||
if (samus_y_pos < 0x380) {
|
||||
int v2 = k >> 1;
|
||||
palettefx_instr_timers[v2] = 1;
|
||||
palettefx_instr_list_ptrs[v2] = addr_word_8DEB43;
|
||||
@@ -330,7 +275,7 @@ void PalPreInstr_SwitchIfYpos(uint16 k) { // 0x8DEC59
|
||||
}
|
||||
|
||||
void PalPreInstr_SwitchIfYpos2(uint16 k) { // 0x8DED84
|
||||
if (samus_y_pos < 0x380u) {
|
||||
if (samus_y_pos < 0x380) {
|
||||
int v2 = k >> 1;
|
||||
palettefx_instr_timers[v2] = 1;
|
||||
palettefx_instr_list_ptrs[v2] = addr_word_8DEC76;
|
||||
@@ -355,4 +300,56 @@ void PalPreInstr_F621(uint16 k) { // 0x8DF621
|
||||
void PalInit_F779_Brinstar8(uint16 k, uint16 j) { // 0x8DF730
|
||||
if ((*(uint16 *)&boss_bits_for_area[area_index] & 2) != 0)
|
||||
palettefx_ids[j >> 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void CallPalFxPreInstr(uint32 ea, uint16 k) {
|
||||
switch (ea) {
|
||||
case fnPalPreInstr_nullsub_129: PalPreInstr_nullsub_129(k); return;
|
||||
case fnPalPreInstr_E1BC: PalPreInstr_E1BC(k); return;
|
||||
case fnPalPreInstr_CheckEnemy0Health: PalPreInstr_CheckEnemy0Health(k); return;
|
||||
case fnPalPreInstr_SamusInHeat: PalPreInstr_SamusInHeat(k); return;
|
||||
case fnPalPreInstr_DeletePalfxIfMinibossDead: PalPreInstr_DeletePalfxIfMinibossDead(k); return;
|
||||
case fnPalPreInstr_SwitchIfYpos: PalPreInstr_SwitchIfYpos(k); return;
|
||||
case fnPalPreInstr_SwitchIfYpos2: PalPreInstr_SwitchIfYpos2(k); return;
|
||||
case fnPalPreInstr_F621: PalPreInstr_F621(k); return;
|
||||
default: Unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
PairU16 CallPalInstr(uint32 ea, uint16 k, uint16 j) {
|
||||
switch (ea) {
|
||||
case fnPalInstr_Finish: return PalInstr_Finish(k, j);
|
||||
case fnPalInstr_ColorPlus2: return PalInstr_ColorPlus2(k, j);
|
||||
case fnPalInstr_ColorPlus3: return PalInstr_ColorPlus3(k, j);
|
||||
case fnPalInstr_ColorPlus4: return PalInstr_ColorPlus4(k, j);
|
||||
case fnPalInstr_ColorPlus8: return PalInstr_ColorPlus8(k, j);
|
||||
case fnPalInstr_ColorPlus9: return PalInstr_ColorPlus9(k, j);
|
||||
case fnPalInstr_ColorPlus15: return PalInstr_ColorPlus15(k, j);
|
||||
case fnPalInstr_Delete: return PalInstr_Delete(k, j);
|
||||
case fnPalInstr_SetPreInstr: return PalInstr_SetPreInstr(k, j);
|
||||
case fnPalInstr_ClearPreInstr: return PalInstr_ClearPreInstr(k, j);
|
||||
case fnPalInstr_Goto: return PalInstr_Goto(k, j);
|
||||
case fnPalInstr_GotoRel: return PalInstr_GotoRel(k, j);
|
||||
case fnPalInstr_DecTimerGoto: return PalInstr_DecTimerGoto(k, j);
|
||||
case fnPalInstr_DecTimerGotoRel: return PalInstr_DecTimerGotoRel(k, j);
|
||||
case fnPalInstr_SetTimer: return PalInstr_SetTimer(k, j);
|
||||
case fnPalInstr_SetColorIndex: return PalInstr_SetColorIndex(k, j);
|
||||
case fnPalInstr_QueueMusic: return PalInstr_QueueMusic(k, j);
|
||||
case fnPalInstr_QueueSfx1: return PalInstr_QueueSfx1(k, j);
|
||||
case fnPalInstr_QueueSfx2: return PalInstr_QueueSfx2(k, j);
|
||||
case fnPalInstr_QueueSfx3: return PalInstr_QueueSfx3(k, j);
|
||||
case fnPalInstr_SetTimerIfBossBit: return PalInstr_SetTimerIfBossBit(k, j);
|
||||
case fnPalInstr_SetPalfxIndex: return PalInstr_SetPalfxIndex(k, j);
|
||||
default: Unreachable(); return (PairU16) { 0, 0 };
|
||||
}
|
||||
}
|
||||
|
||||
void CallPalfxFunc(uint32 ea, uint16 k, uint16 j) {
|
||||
switch (ea) {
|
||||
case fnnullsub_131: return;
|
||||
case fnPalInit_E1BC: PalInit_E1BC(k, j); return;
|
||||
case fnPalInit_F761_Norfair1: PalInit_F761_Norfair1(k, j); return;
|
||||
case fnPalInit_F779_Brinstar8: PalInit_F779_Brinstar8(k, j); return;
|
||||
default: Unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user