From 17694f1a505b97bccf56219486c0120cc1c9f0e7 Mon Sep 17 00:00:00 2001 From: bismurphy Date: Mon, 3 Mar 2025 09:17:53 -0500 Subject: [PATCH] Prepare file alignments for next PSP DRA codeshare (#2277) Same as usual, just changing file splits to make them the same between versions. Decompiled a couple on PSP to make sure I was in the right place. As usual, PSP file will end up deleted once code is shared between versions. Looks like this file is just a whole bunch of helper functions, possibly all for transformation-related code. --- CMakeLists.txt | 1 + config/splat.hd.dra.yaml | 1 + config/splat.pspeu.dra.yaml | 3 +- config/splat.us.dra.yaml | 1 + config/symbols.pspeu.dra.txt | 2 + src/dra/8BEF8.c | 393 ---------------------------------- src/dra/8C600.c | 395 +++++++++++++++++++++++++++++++++++ src/dra_psp/59E20.c | 121 ++++++++++- src/dra_psp/5A560.c | 4 - src/dra_psp/5A5B0.c | 22 -- src/dra_psp/5AF80.c | 5 + 11 files changed, 524 insertions(+), 424 deletions(-) create mode 100644 src/dra/8C600.c delete mode 100644 src/dra_psp/5A560.c delete mode 100644 src/dra_psp/5A5B0.c create mode 100644 src/dra_psp/5AF80.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f2d951e8d..dd58e20e19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -211,6 +211,7 @@ set(SOURCE_FILES_DRA src/dra/84B88.c src/dra/8A0A4.c src/dra/8BEF8.c + src/dra/8C600.c src/dra/8D3E8.c src/dra/91EBC.c src/dra/92F60.c diff --git a/config/splat.hd.dra.yaml b/config/splat.hd.dra.yaml index a17a9c5236..f09708f849 100644 --- a/config/splat.hd.dra.yaml +++ b/config/splat.hd.dra.yaml @@ -205,6 +205,7 @@ segments: - [0x84814, c, 84B88] - [0x8A528, c, 8A0A4] - [0x8BB50, c, 8BEF8] + - [0x8C28C, c, 8C600] - [0x8D050, c, 8D3E8] - [0x91A98, c, 91EBC] - [0x92B3C, c, 92F60] diff --git a/config/splat.pspeu.dra.yaml b/config/splat.pspeu.dra.yaml index a76a4a5d9b..3d2a3c86c1 100644 --- a/config/splat.pspeu.dra.yaml +++ b/config/splat.pspeu.dra.yaml @@ -113,8 +113,7 @@ segments: - [0x47EA8, c, dra/7879C] - [0x507F0, c, dra/7E4BC] - [0x59E20, c, dra_psp/59E20] - - [0x5A560, c, dra_psp/5A560] - - [0x5A5B0, c, dra_psp/5A5B0] + - [0x5AF80, c, dra_psp/5AF80] - [0x5B8C0, c, dra_psp/5B8C0] - [0x5BC80, c, dra_psp/5BC80] - [0x5C420, c, dra_psp/5C420] diff --git a/config/splat.us.dra.yaml b/config/splat.us.dra.yaml index 27ee652322..dc03987630 100644 --- a/config/splat.us.dra.yaml +++ b/config/splat.us.dra.yaml @@ -273,6 +273,7 @@ segments: - [0x84B88, c, 84B88] - [0x8A0A4, c, 8A0A4] - [0x8BEF8, c, 8BEF8] + - [0x8C600, c, 8C600] - [0x8D3E8, c, 8D3E8] - [0x91EBC, c, 91EBC] - [0x92F60, c, 92F60] diff --git a/config/symbols.pspeu.dra.txt b/config/symbols.pspeu.dra.txt index ed8470926d..5ce416d3bd 100644 --- a/config/symbols.pspeu.dra.txt +++ b/config/symbols.pspeu.dra.txt @@ -265,6 +265,8 @@ func_80123F78 = 0x091355A0; func_80124164 = 0x091357E0; EntityTeleport = 0x09135BE8; EntityPlayerSleepZ = 0x09136620; +func_8012C600 = 0x091367A0; +WolfFormFinished = 0x09136BF8; func_8012F894 = 0x0913A448; func_80130264 = 0x0913B0F8; func_80130618 = 0x0913B5D0; diff --git a/src/dra/8BEF8.c b/src/dra/8BEF8.c index 7fb4a63603..bbc354adee 100644 --- a/src/dra/8BEF8.c +++ b/src/dra/8BEF8.c @@ -1,7 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "dra.h" #include "dra_bss.h" -#include "sfx.h" // echo of bat effect void EntityBatEcho(Entity* self) { @@ -175,395 +174,3 @@ void EntityBatEcho(Entity* self) { prim = prim->next; } } - -void func_8012C600(void) { - s32 x, y; - s32 i; - s32 t0 = PLAYER.posX.i.hi; - s32 t1 = PLAYER.posY.i.hi; - - x = g_Entities[20].posX.i.hi + 8; - for (i = 0; i < 9; i++) { - if (x <= g_Entities[i + 21].posX.i.hi + 4) { - x = g_Entities[i + 21].posX.i.hi + 4; - } - } - D_8013AEBC[0] = x - t0; - - x = g_Entities[20].posX.i.hi - 8; - for (i = 0; i < 9; i++) { - if (x >= g_Entities[i + 21].posX.i.hi - 4) { - x = g_Entities[i + 21].posX.i.hi - 4; - } - } - D_8013AEBC[2] = x - t0; - - y = g_Entities[21].posY.i.hi; - for (i = 0; i < 9; i++) { - if (y >= g_Entities[i + 21].posY.i.hi) { - y = g_Entities[i + 21].posY.i.hi; - } - } - y = y - 4; - if (y >= g_Entities[30].posY.i.hi - 12) { - y = g_Entities[30].posY.i.hi - 12; - } - if (y >= g_Entities[20].posY.i.hi - 8) { - y = g_Entities[20].posY.i.hi - 8; - } - D_8013AEBC[3] = y - t1; - if (D_8013AEBC[3] < -24) { - D_8013AEBC[3] = -24; - } - - y = g_Entities[21].posY.i.hi; - for (i = 0; i < 9; i++) { - if (y <= g_Entities[i + 21].posY.i.hi) { - y = g_Entities[i + 21].posY.i.hi; - } - } - y = y + 4; - - if (y <= PLAYER.posY.i.hi + 28) { - y = PLAYER.posY.i.hi + 28; - } - if (y <= g_Entities[17].posY.i.hi + 28) { - y = g_Entities[17].posY.i.hi + 28; - } - D_8013AEBC[1] = y - t1; - if (D_8013AEBC[1] > 0x27) { - D_8013AEBC[1] = 0x27; - } - - if (!PLAYER.facingLeft) { - if (D_8013AEBC[2] < -0x2C) { - D_8013AEBC[2] = -0x2C; - } - if (D_8013AEBC[0] > 0x14) { - D_8013AEBC[0] = 0x14; - } - } else { - if (D_8013AEBC[2] < -0x14) { - D_8013AEBC[2] = -0x14; - } - if (D_8013AEBC[0] > 0x2C) { - D_8013AEBC[0] = 0x2C; - } - } -} - -bool WolfFormFinished(void) { - if (PLAYER.step_s == 0) { - return false; - } - if (PLAYER.step_s == 8) { - return false; - } - if (D_80097448[1] != 0 && !IsRelicActive(RELIC_HOLY_SYMBOL) || - g_Player.padTapped & PAD_R2 || - HandleTransformationMP(FORM_WOLF, REDUCE) < 0) { - SetPlayerStep(Player_UnmorphWolf); - SetPlayerAnim(0xCA); - D_800AFDA4[1] = 1; - PLAYER.palette = 0x810D; - g_Player.unk66 = 0; - g_Player.unk68 = 0; - // Create factory for EntityPlayerBlinkWhite - CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x24), 0); - PLAYER.velocityY >>= 1; - return true; - } - return false; -} - -void func_8012C97C(void) { - if (g_Entities[PLAYER_CHARACTER].step_s == 0) { - return; - } - if (g_Entities[PLAYER_CHARACTER].step_s >= 8 && - g_Entities[PLAYER_CHARACTER].step_s < 10) { - return; - } - if (D_80097448[1] < 13) { - return; - } - if (!IsRelicActive(RELIC_HOLY_SYMBOL)) { - return; - } - if (!IsRelicActive(RELIC_SKILL_OF_WOLF)) { - return; - } - if (g_Player.pl_vram_flag & 1) { - return; - } - if (!(g_Player.padPressed & PAD_TRIANGLE)) { - return; - } - if (D_80138440 != 0) { - return; - } - - PLAYER.step_s = 9; - D_800B0914 = 0; - SetPlayerAnim(0xEC); - PLAYER.velocityY = 0; -} - -void func_8012CA64(void) { - u8 anim; - - PLAYER.step_s = 1; - D_800B0914 = 0; - - anim = 0xDE; - if (g_Player.pl_vram_flag & 0x20) { - anim = 0xDF; - } - SetPlayerAnim(anim); - - PLAYER.velocityY = 0; - PLAYER.velocityX /= 2; - - D_800B0918 = 0x200; - if (g_Player.pl_vram_flag & 0x40) { - D_800B0914 = 1; - SetPlayerAnim(0xE9); - } -} - -void func_8012CB0C(void) { - PLAYER.ext.player.anim = 0xDE; - PLAYER.velocityY = 0; - D_800B0914 = 0; - PLAYER.animFrameIdx = 0; - PLAYER.animFrameDuration = 0; - PLAYER.step_s = 7; -} - -void func_8012CB4C(void) { - PLAYER.step_s = 2; - if ((PLAYER.facingLeft != 0 && g_Player.padPressed & PAD_RIGHT) || - (PLAYER.facingLeft == 0 && g_Player.padPressed & PAD_LEFT)) { - SetPlayerAnim(0xE1); - D_800B0914 = 0; - D_8013842C = 0; - return; - } else if (D_8013842C != 0) { - SetPlayerAnim(0xE2); - D_800B0914 = 2; - SetSpeedX(0x20000); - return; - } else { - SetPlayerAnim(0xE0); - D_800B0914 = 1; - D_8013842C = 0xC; - } -} - -void func_8012CC30(s32 arg0) { - if (arg0 == 0) { - D_80138444 = 1; - if (g_ButtonCombo[COMBO_QCF].buttonsCorrect == COMBO_COMPLETE && - IsRelicActive(RELIC_SKILL_OF_WOLF) && - CastSpell(SPELL_WOLF_CHARGE)) { - CheckMoveDirection(); - PLAYER.step_s = 2; - D_800B0914 = 4; - SetSpeedX(0x50000); - g_CurrentEntity->velocityY = 0; - SetPlayerAnim(0xED); - LearnSpell(4); - } - } else { - D_80138444 = 1; - } -} - -void func_8012CCE4(void) { - PLAYER.velocityY = FIX(-3.5); - if ((PLAYER.step_s == 2) & (D_800B0914 == 2)) { - SetPlayerAnim(0xE7); - // Might be possible to rewrite this block to reduce duplication with - // some clever && and || - if (PLAYER.facingLeft) { - if ((g_Player.pl_vram_flag & 0xF000) == 0xC000) { - PLAYER.velocityY = -(abs(PLAYER.velocityX) + FIX(3.5)); - } - if ((g_Player.pl_vram_flag & 0xF000) == 0x8000) { - PLAYER.velocityY = FIX(-0.5); - } - } else { - if ((g_Player.pl_vram_flag & 0xF000) == 0x8000) { - PLAYER.velocityY = -(abs(PLAYER.velocityX) + FIX(3.5)); - } - if ((g_Player.pl_vram_flag & 0xF000) == 0xC000) { - PLAYER.velocityY = FIX(-0.5); - } - } - D_800B0914 = 2; - } else if ( - (g_Player.padPressed & (PAD_RIGHT | PAD_LEFT)) && - ((PLAYER.step_s != 2) || (D_800B0914 != 0)) && (PLAYER.step_s != 9)) { - SetPlayerAnim(0xE7); - D_800B0914 = 1; - if (g_Player.padPressed & PAD_UP) { - PLAYER.velocityY = FIX(-4.875); - } - } else { - SetPlayerAnim(0xE6); - D_800B0914 = 0; - if (g_Player.padPressed & PAD_UP) { - PLAYER.velocityY = FIX(-4.875); - } - } - PLAYER.step_s = 4; - D_80138430 += 0x80; -} - -void func_8012CED4(void) { - if (PLAYER.step_s == 2 && D_800B0914 == PLAYER.step_s) { - SetPlayerAnim(0xE7); - D_800B0914 = 1; - } else { - SetPlayerAnim(0xE8); - SetSpeedX(0x10000); - D_800B0914 = 0; - if (D_80138438 & 0x40) { - PLAYER.animFrameIdx = 4; - PLAYER.velocityX = 0; - PLAYER.animFrameDuration = 1; - } - } - PLAYER.step_s = 5; - g_Player.timers[5] = 8; - PLAYER.velocityY = 0; - D_80138430 -= 0x100; -} - -void func_8012CFA8(void) { - SetPlayerAnim(0xEA); - PLAYER.step_s = 6; - D_800B0914 = 0; - PLAYER.velocityX = 0; - g_Player.timers[5] = 8; -} - -void func_8012CFF0(void) { - PLAYER.step_s = 3; - SetPlayerAnim(0xE3); - D_800B0914 = 0; -} - -void func_8012D024(void) { - DecelerateX(0x2000); - if (g_Player.padTapped & PAD_CROSS) { - func_8012CCE4(); - return; - } - if (!(g_Player.pl_vram_flag & 1)) { - func_8012CED4(); - return; - } - if (g_Player.padTapped & PAD_SQUARE) { - func_8012CC30(0); - return; - } - if (g_Player.padPressed & (PAD_RIGHT | PAD_LEFT)) { - func_8012CB4C(); - return; - } - if (g_Player.padPressed & PAD_DOWN) { - func_8012CFF0(); - return; - } - if (D_800B0914 != 0) { - return; - } - if (abs(PLAYER.posY.i.hi - g_Entities[17].posY.i.hi) < 4 && - --D_800B0918 == 0) { - D_800B0914 = 1; - SetPlayerAnim(0xE9); - return; - } - if (g_Player.pl_vram_flag & 0x40) { - D_800B0914 = 1; - SetPlayerAnim(0xE9); - } -} - -void func_8012D178(void) { - s32 var_v0; - - if (g_Player.padTapped & PAD_CROSS) { - func_8012CCE4(); - } else if (!(g_Player.pl_vram_flag & 1)) { - func_8012CFA8(); - } else { -#if defined(VERSION_US) - if (PLAYER.facingLeft != 0) { - var_v0 = g_Player.padPressed & PAD_LEFT; - } else { - var_v0 = g_Player.padPressed & PAD_RIGHT; - } -#elif defined(VERSION_HD) - var_v0 = g_Player.padPressed & (PAD_LEFT | PAD_RIGHT); -#endif - if (var_v0 != 0) { - func_8012CB4C(); - } else if (g_Player.unk04 & 0x40) { - func_8012CA64(); - } else if (g_GameTimer % 6 == 0) { - CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(69, 1), 0); - } - } -} - -void func_8012D28C(bool exitEarly) { - bool bitNotFound; - s32 i; - - func_80102CD8(2); - PlaySfx(SFX_WALL_DEBRIS_B); - PLAYER.velocityX = 0; - g_Player.D_80072EFC = 0x20; - g_Player.padSim = 0; - // Odd logic, if we exit early, we force an R2-tap. Strange! - if (exitEarly) { - g_Player.padTapped = PAD_R2; - WolfFormFinished(); - return; - } - // Start a routine where we look through this array for a value. - bitNotFound = 0; - for (i = 3; i < NUM_VERTICAL_SENSORS; i++) { - if (g_Player.colWall[i].effects & EFFECT_UNK_0002) { - break; - } - } - // If we made it through that loop without finding one, skip i=7,8,9 - // and keep searching. - if (i == 7) { - for (i = NUM_VERTICAL_SENSORS + 3; i < NUM_VERTICAL_SENSORS * 2; i++) { - if (g_Player.colWall[i].effects & EFFECT_UNK_0002) { - break; - } - } - } - // If we even made it through that one, then conclude the bit was not found. - if (i == 14) { - bitNotFound++; - } - - SetSpeedX(FIX(1)); - CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(4, 9), 0); - D_800B0914 = 0; - // Finally make use of that bit to control if X is positive or negative. - if (bitNotFound) { - func_8012CED4(); - SetSpeedX(FIX(1)); - } else { - func_8012CFA8(); - SetSpeedX(FIX(-1)); - } - PLAYER.velocityY = FIX(-3.5); -} diff --git a/src/dra/8C600.c b/src/dra/8C600.c new file mode 100644 index 0000000000..2ed5d3e7b3 --- /dev/null +++ b/src/dra/8C600.c @@ -0,0 +1,395 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#include "dra.h" +#include "dra_bss.h" + +void func_8012C600(void) { + s32 x, y; + s32 i; + s32 t0 = PLAYER.posX.i.hi; + s32 t1 = PLAYER.posY.i.hi; + + x = g_Entities[20].posX.i.hi + 8; + for (i = 0; i < 9; i++) { + if (x <= g_Entities[i + 21].posX.i.hi + 4) { + x = g_Entities[i + 21].posX.i.hi + 4; + } + } + D_8013AEBC[0] = x - t0; + + x = g_Entities[20].posX.i.hi - 8; + for (i = 0; i < 9; i++) { + if (x >= g_Entities[i + 21].posX.i.hi - 4) { + x = g_Entities[i + 21].posX.i.hi - 4; + } + } + D_8013AEBC[2] = x - t0; + + y = g_Entities[21].posY.i.hi; + for (i = 0; i < 9; i++) { + if (y >= g_Entities[i + 21].posY.i.hi) { + y = g_Entities[i + 21].posY.i.hi; + } + } + y = y - 4; + if (y >= g_Entities[30].posY.i.hi - 12) { + y = g_Entities[30].posY.i.hi - 12; + } + if (y >= g_Entities[20].posY.i.hi - 8) { + y = g_Entities[20].posY.i.hi - 8; + } + D_8013AEBC[3] = y - t1; + if (D_8013AEBC[3] < -24) { + D_8013AEBC[3] = -24; + } + + y = g_Entities[21].posY.i.hi; + for (i = 0; i < 9; i++) { + if (y <= g_Entities[i + 21].posY.i.hi) { + y = g_Entities[i + 21].posY.i.hi; + } + } + y = y + 4; + + if (y <= PLAYER.posY.i.hi + 28) { + y = PLAYER.posY.i.hi + 28; + } + if (y <= g_Entities[17].posY.i.hi + 28) { + y = g_Entities[17].posY.i.hi + 28; + } + D_8013AEBC[1] = y - t1; + if (D_8013AEBC[1] > 0x27) { + D_8013AEBC[1] = 0x27; + } + + if (!PLAYER.facingLeft) { + if (D_8013AEBC[2] < -0x2C) { + D_8013AEBC[2] = -0x2C; + } + if (D_8013AEBC[0] > 0x14) { + D_8013AEBC[0] = 0x14; + } + } else { + if (D_8013AEBC[2] < -0x14) { + D_8013AEBC[2] = -0x14; + } + if (D_8013AEBC[0] > 0x2C) { + D_8013AEBC[0] = 0x2C; + } + } +} + +bool WolfFormFinished(void) { + if (PLAYER.step_s == 0) { + return false; + } + if (PLAYER.step_s == 8) { + return false; + } + if (D_80097448[1] != 0 && !IsRelicActive(RELIC_HOLY_SYMBOL) || + g_Player.padTapped & PAD_R2 || + HandleTransformationMP(FORM_WOLF, REDUCE) < 0) { + SetPlayerStep(Player_UnmorphWolf); + SetPlayerAnim(0xCA); + D_800AFDA4[1] = 1; + PLAYER.palette = 0x810D; + g_Player.unk66 = 0; + g_Player.unk68 = 0; + // Create factory for EntityPlayerBlinkWhite + CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x24), 0); + PLAYER.velocityY >>= 1; + return true; + } + return false; +} + +void func_8012C97C(void) { + if (g_Entities[PLAYER_CHARACTER].step_s == 0) { + return; + } + if (g_Entities[PLAYER_CHARACTER].step_s >= 8 && + g_Entities[PLAYER_CHARACTER].step_s < 10) { + return; + } + if (D_80097448[1] < 13) { + return; + } + if (!IsRelicActive(RELIC_HOLY_SYMBOL)) { + return; + } + if (!IsRelicActive(RELIC_SKILL_OF_WOLF)) { + return; + } + if (g_Player.pl_vram_flag & 1) { + return; + } + if (!(g_Player.padPressed & PAD_TRIANGLE)) { + return; + } + if (D_80138440 != 0) { + return; + } + + PLAYER.step_s = 9; + D_800B0914 = 0; + SetPlayerAnim(0xEC); + PLAYER.velocityY = 0; +} + +void func_8012CA64(void) { + u8 anim; + + PLAYER.step_s = 1; + D_800B0914 = 0; + + anim = 0xDE; + if (g_Player.pl_vram_flag & 0x20) { + anim = 0xDF; + } + SetPlayerAnim(anim); + + PLAYER.velocityY = 0; + PLAYER.velocityX /= 2; + + D_800B0918 = 0x200; + if (g_Player.pl_vram_flag & 0x40) { + D_800B0914 = 1; + SetPlayerAnim(0xE9); + } +} + +void func_8012CB0C(void) { + PLAYER.ext.player.anim = 0xDE; + PLAYER.velocityY = 0; + D_800B0914 = 0; + PLAYER.animFrameIdx = 0; + PLAYER.animFrameDuration = 0; + PLAYER.step_s = 7; +} + +void func_8012CB4C(void) { + PLAYER.step_s = 2; + if ((PLAYER.facingLeft != 0 && g_Player.padPressed & PAD_RIGHT) || + (PLAYER.facingLeft == 0 && g_Player.padPressed & PAD_LEFT)) { + SetPlayerAnim(0xE1); + D_800B0914 = 0; + D_8013842C = 0; + return; + } else if (D_8013842C != 0) { + SetPlayerAnim(0xE2); + D_800B0914 = 2; + SetSpeedX(0x20000); + return; + } else { + SetPlayerAnim(0xE0); + D_800B0914 = 1; + D_8013842C = 0xC; + } +} + +void func_8012CC30(s32 arg0) { + if (arg0 == 0) { + D_80138444 = 1; + if (g_ButtonCombo[COMBO_QCF].buttonsCorrect == COMBO_COMPLETE && + IsRelicActive(RELIC_SKILL_OF_WOLF) && + CastSpell(SPELL_WOLF_CHARGE)) { + CheckMoveDirection(); + PLAYER.step_s = 2; + D_800B0914 = 4; + SetSpeedX(0x50000); + g_CurrentEntity->velocityY = 0; + SetPlayerAnim(0xED); + LearnSpell(4); + } + } else { + D_80138444 = 1; + } +} + +void func_8012CCE4(void) { + PLAYER.velocityY = FIX(-3.5); + if ((PLAYER.step_s == 2) & (D_800B0914 == 2)) { + SetPlayerAnim(0xE7); + // Might be possible to rewrite this block to reduce duplication with + // some clever && and || + if (PLAYER.facingLeft) { + if ((g_Player.pl_vram_flag & 0xF000) == 0xC000) { + PLAYER.velocityY = -(abs(PLAYER.velocityX) + FIX(3.5)); + } + if ((g_Player.pl_vram_flag & 0xF000) == 0x8000) { + PLAYER.velocityY = FIX(-0.5); + } + } else { + if ((g_Player.pl_vram_flag & 0xF000) == 0x8000) { + PLAYER.velocityY = -(abs(PLAYER.velocityX) + FIX(3.5)); + } + if ((g_Player.pl_vram_flag & 0xF000) == 0xC000) { + PLAYER.velocityY = FIX(-0.5); + } + } + D_800B0914 = 2; + } else if ( + (g_Player.padPressed & (PAD_RIGHT | PAD_LEFT)) && + ((PLAYER.step_s != 2) || (D_800B0914 != 0)) && (PLAYER.step_s != 9)) { + SetPlayerAnim(0xE7); + D_800B0914 = 1; + if (g_Player.padPressed & PAD_UP) { + PLAYER.velocityY = FIX(-4.875); + } + } else { + SetPlayerAnim(0xE6); + D_800B0914 = 0; + if (g_Player.padPressed & PAD_UP) { + PLAYER.velocityY = FIX(-4.875); + } + } + PLAYER.step_s = 4; + D_80138430 += 0x80; +} + +void func_8012CED4(void) { + if (PLAYER.step_s == 2 && D_800B0914 == PLAYER.step_s) { + SetPlayerAnim(0xE7); + D_800B0914 = 1; + } else { + SetPlayerAnim(0xE8); + SetSpeedX(0x10000); + D_800B0914 = 0; + if (D_80138438 & 0x40) { + PLAYER.animFrameIdx = 4; + PLAYER.velocityX = 0; + PLAYER.animFrameDuration = 1; + } + } + PLAYER.step_s = 5; + g_Player.timers[5] = 8; + PLAYER.velocityY = 0; + D_80138430 -= 0x100; +} + +void func_8012CFA8(void) { + SetPlayerAnim(0xEA); + PLAYER.step_s = 6; + D_800B0914 = 0; + PLAYER.velocityX = 0; + g_Player.timers[5] = 8; +} + +void func_8012CFF0(void) { + PLAYER.step_s = 3; + SetPlayerAnim(0xE3); + D_800B0914 = 0; +} + +void func_8012D024(void) { + DecelerateX(0x2000); + if (g_Player.padTapped & PAD_CROSS) { + func_8012CCE4(); + return; + } + if (!(g_Player.pl_vram_flag & 1)) { + func_8012CED4(); + return; + } + if (g_Player.padTapped & PAD_SQUARE) { + func_8012CC30(0); + return; + } + if (g_Player.padPressed & (PAD_RIGHT | PAD_LEFT)) { + func_8012CB4C(); + return; + } + if (g_Player.padPressed & PAD_DOWN) { + func_8012CFF0(); + return; + } + if (D_800B0914 != 0) { + return; + } + if (abs(PLAYER.posY.i.hi - g_Entities[17].posY.i.hi) < 4 && + --D_800B0918 == 0) { + D_800B0914 = 1; + SetPlayerAnim(0xE9); + return; + } + if (g_Player.pl_vram_flag & 0x40) { + D_800B0914 = 1; + SetPlayerAnim(0xE9); + } +} + +void func_8012D178(void) { + s32 var_v0; + + if (g_Player.padTapped & PAD_CROSS) { + func_8012CCE4(); + } else if (!(g_Player.pl_vram_flag & 1)) { + func_8012CFA8(); + } else { +#if defined(VERSION_US) + if (PLAYER.facingLeft != 0) { + var_v0 = g_Player.padPressed & PAD_LEFT; + } else { + var_v0 = g_Player.padPressed & PAD_RIGHT; + } +#elif defined(VERSION_HD) + var_v0 = g_Player.padPressed & (PAD_LEFT | PAD_RIGHT); +#endif + if (var_v0 != 0) { + func_8012CB4C(); + } else if (g_Player.unk04 & 0x40) { + func_8012CA64(); + } else if (g_GameTimer % 6 == 0) { + CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(69, 1), 0); + } + } +} + +void func_8012D28C(bool exitEarly) { + bool bitNotFound; + s32 i; + + func_80102CD8(2); + PlaySfx(SFX_WALL_DEBRIS_B); + PLAYER.velocityX = 0; + g_Player.D_80072EFC = 0x20; + g_Player.padSim = 0; + // Odd logic, if we exit early, we force an R2-tap. Strange! + if (exitEarly) { + g_Player.padTapped = PAD_R2; + WolfFormFinished(); + return; + } + // Start a routine where we look through this array for a value. + bitNotFound = 0; + for (i = 3; i < NUM_VERTICAL_SENSORS; i++) { + if (g_Player.colWall[i].effects & EFFECT_UNK_0002) { + break; + } + } + // If we made it through that loop without finding one, skip i=7,8,9 + // and keep searching. + if (i == 7) { + for (i = NUM_VERTICAL_SENSORS + 3; i < NUM_VERTICAL_SENSORS * 2; i++) { + if (g_Player.colWall[i].effects & EFFECT_UNK_0002) { + break; + } + } + } + // If we even made it through that one, then conclude the bit was not found. + if (i == 14) { + bitNotFound++; + } + + SetSpeedX(FIX(1)); + CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(4, 9), 0); + D_800B0914 = 0; + // Finally make use of that bit to control if X is positive or negative. + if (bitNotFound) { + func_8012CED4(); + SetSpeedX(FIX(1)); + } else { + func_8012CFA8(); + SetSpeedX(FIX(-1)); + } + PLAYER.velocityY = FIX(-3.5); +} diff --git a/src/dra_psp/59E20.c b/src/dra_psp/59E20.c index e950195e1c..c16fe5a1fc 100644 --- a/src/dra_psp/59E20.c +++ b/src/dra_psp/59E20.c @@ -1,10 +1,125 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "../dra/dra.h" +#include "../dra/dra_bss.h" -INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_091367A0); +void func_8012C600(void) { + s32 x, y; + s32 i; + s32 t0 = PLAYER.posX.i.hi; + s32 t1 = PLAYER.posY.i.hi; -INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136BF8); + x = g_Entities[20].posX.i.hi + 8; + for (i = 0; i < 9; i++) { + if (x <= g_Entities[i + 21].posX.i.hi + 4) { + x = g_Entities[i + 21].posX.i.hi + 4; + } + } + D_8013AEBC[0] = x - t0; -INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136D18); + x = g_Entities[20].posX.i.hi - 8; + for (i = 0; i < 9; i++) { + if (x >= g_Entities[i + 21].posX.i.hi - 4) { + x = g_Entities[i + 21].posX.i.hi - 4; + } + } + D_8013AEBC[2] = x - t0; + + y = g_Entities[21].posY.i.hi; + for (i = 0; i < 9; i++) { + if (y >= g_Entities[i + 21].posY.i.hi) { + y = g_Entities[i + 21].posY.i.hi; + } + } + y = y - 4; + if (y >= g_Entities[30].posY.i.hi - 12) { + y = g_Entities[30].posY.i.hi - 12; + } + if (y >= g_Entities[20].posY.i.hi - 8) { + y = g_Entities[20].posY.i.hi - 8; + } + D_8013AEBC[3] = y - t1; + if (D_8013AEBC[3] < -24) { + D_8013AEBC[3] = -24; + } + + y = g_Entities[21].posY.i.hi; + for (i = 0; i < 9; i++) { + if (y <= g_Entities[i + 21].posY.i.hi) { + y = g_Entities[i + 21].posY.i.hi; + } + } + y = y + 4; + + if (y <= PLAYER.posY.i.hi + 28) { + y = PLAYER.posY.i.hi + 28; + } + if (y <= g_Entities[17].posY.i.hi + 28) { + y = g_Entities[17].posY.i.hi + 28; + } + D_8013AEBC[1] = y - t1; + if (D_8013AEBC[1] > 0x27) { + D_8013AEBC[1] = 0x27; + } + if (!PLAYER.facingLeft) { + if (D_8013AEBC[2] < -0x2C) { + D_8013AEBC[2] = -0x2C; + } + if (D_8013AEBC[0] > 0x13) { + D_8013AEBC[0] = 0x13; + } + } else { + if (D_8013AEBC[2] < -0x13) { + D_8013AEBC[2] = -0x13; + } + if (D_8013AEBC[0] > 0x2C) { + D_8013AEBC[0] = 0x2C; + } + } +} + +bool WolfFormFinished(void) { + if (PLAYER.step_s == 0 || PLAYER.step_s == 8) { + return false; + } + if (D_80097448[1] != 0 && !IsRelicActive(RELIC_HOLY_SYMBOL) || + g_Player.padTapped & PAD_L1 || + HandleTransformationMP(FORM_WOLF, REDUCE) < 0) { + SetPlayerStep(Player_UnmorphWolf); + SetPlayerAnim(0xCA); + D_800AFDA4[1] = 1; + PLAYER.palette = 0x810D; + g_Player.unk66 = 0; + g_Player.unk68 = 0; + // Create factory for EntityPlayerBlinkWhite + CreateEntFactoryFromEntity(g_CurrentEntity, FACTORY(44, 0x24), 0); + PLAYER.velocityY >>= 1; + return true; + } + return false; +} + +// func_8012C97C +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136D18); +// func_8012CA64 INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136E18); +// func_8012CB0C +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136EE0); +// func_8012CB4C +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09136F30); +// func_8012CC30 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137038); +// func_8012CCE4 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137110); +// func_8012CED4 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137358); +// func_8012CFA8 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137448); +// func_8012CFF0 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137498); +// func_8012D024 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_091374D0); +// func_8012D178 +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137668); +// func_8012D28C (confirmed) +INCLUDE_ASM("dra_psp/psp/dra_psp/59E20", func_psp_09137748); diff --git a/src/dra_psp/5A560.c b/src/dra_psp/5A560.c deleted file mode 100644 index b872266b11..0000000000 --- a/src/dra_psp/5A560.c +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-or-later -#include "../dra/dra.h" - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A560", func_psp_09136EE0); diff --git a/src/dra_psp/5A5B0.c b/src/dra_psp/5A5B0.c deleted file mode 100644 index 67aff20d0d..0000000000 --- a/src/dra_psp/5A5B0.c +++ /dev/null @@ -1,22 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-or-later -#include "../dra/dra.h" - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09136F30); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137038); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137110); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137358); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137448); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137498); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_091374D0); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137668); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137748); - -INCLUDE_ASM("dra_psp/psp/dra_psp/5A5B0", func_psp_09137900); diff --git a/src/dra_psp/5AF80.c b/src/dra_psp/5AF80.c new file mode 100644 index 0000000000..972c88f68a --- /dev/null +++ b/src/dra_psp/5AF80.c @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#include "../dra/dra.h" +#include "../dra/dra_bss.h" + +INCLUDE_ASM("dra_psp/psp/dra_psp/5AF80", func_psp_09137900);