From fa6dabde3c078ebf589964b18eeb0589f26998b9 Mon Sep 17 00:00:00 2001 From: Alejandro Asenjo Nitti <96613413+sonicdcer@users.noreply.github.com> Date: Tue, 21 Feb 2023 19:27:41 -0300 Subject: [PATCH] DRA&RIC move a0, s0 carnage (#113) --- src/dra/75F54.c | 133 ++++++++++++++++++++++-------------------------- src/dra/dra.h | 2 +- src/ric/20920.c | 11 ++-- 3 files changed, 64 insertions(+), 82 deletions(-) diff --git a/src/dra/75F54.c b/src/dra/75F54.c index e0ffed26b..60e145d10 100644 --- a/src/dra/75F54.c +++ b/src/dra/75F54.c @@ -615,46 +615,40 @@ INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_80123788); INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_801238CC); -// move a0,s0 thing -// https://decomp.me/scratch/rJCCX -#ifndef NON_MATCHING -INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_80123A60); -#else void func_80123A60(Entity* entity) { - if (D_80072F2C & 0x01000000) { + Entity* player = &PLAYER; -#if 1 - entity->posX.i.hi = PLAYER.posX.i.hi; //(u16) D_800733DA; - entity->posY.i.hi = PLAYER.posY.i.hi; //(u16) D_800733DE; -#else // This one generates the first missing move a0, s0 for some reason? - entity->posX.i.hi = (u16)D_800733DA; - entity->posY.i.hi = (u16)D_800733DE; -#endif - if (entity->step == 0) { - func_8011A328(entity, 0xB); - entity->unk34 = 0x04060000; - entity->step++; - } - if (PLAYER.animCurFrame == 5) { - entity->hitboxWidth = 12; - entity->hitboxHeight = 32; - entity->unk10 = 0x1C; - entity->unk12 = -0xC; - return; - } - if (PLAYER.animCurFrame == 6) { - entity->hitboxWidth = 10; - entity->hitboxHeight = 10; - entity->unk10 = 0x1C; - entity->unk12 = 0x10; - return; - } - goto block_7; + if (!(D_80072F2C & 0x01000000)) { + DestroyEntity(entity); + return; } -block_7: + + entity->posX.i.hi = player->posX.i.hi; + entity->posY.i.hi = player->posY.i.hi; + if (entity->step == 0) { + func_8011A328(entity, 0xB); + entity->unk34 = 0x04060000; + entity->step++; + } + + if (player->animCurFrame == 5) { + entity->hitboxWidth = 12; + entity->hitboxHeight = 32; + entity->unk10 = 0x1C; + entity->unk12 = -0xC; + return; + } + + if (player->animCurFrame == 6) { + entity->hitboxWidth = 10; + entity->hitboxHeight = 10; + entity->unk10 = 0x1C; + entity->unk12 = 0x10; + return; + } + DestroyEntity(entity); } -#endif INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_80123B40); @@ -828,47 +822,40 @@ void func_80124164(POLY_GT4* poly, s32 colorIntensity, s32 y, s32 radius, // teleport effect like when using library card (ID 0x42) INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", EntityTeleport); -// move a0,s0 thing -#ifndef NON_MATCHING -INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_80124A8C); -#else void func_80124A8C(Entity* entity) { - u32* playerStep = &PLAYER.step; - - if (*playerStep == 4) { - s32 playerStep_temp = *playerStep; // might be !FAKE: - - switch (entity->step) { - case 0: - entity->animSet = 0x11; - entity->accelerationY = -0x6000; - AccelerateX(0x4000); - entity->unk5A = 0x50; - entity->palette = 0x819F; - entity->unk4C = &D_800AE294; - entity->unk34 = 0x100000; - entity->facing = 0; - entity->posY.i.hi -= 16; - playerStep_temp = entity->step; - playerStep_temp++; - entity->posX.val += entity->accelerationX << 5; - entity->step = playerStep_temp; - break; - - case 1: - entity->posX.val += entity->accelerationX; - entity->posY.val += entity->accelerationY; - - if (entity->animFrameDuration < 0) { - DestroyEntity(entity); - } - break; - } - } else { +#ifdef PSY_Q_3_5 + if (PLAYER.step != 0 || PLAYER.unk2E != 4) { // REAL: Matches with PSY-Q 3.5 +#else + if (*(s32*)&PLAYER.step != 0x40000) { // !FAKE: Probably ASPSX +#endif DestroyEntity(entity); + return; + } + + switch (entity->step) { + case 0: + entity->animSet = 0x11; + entity->accelerationY = -0x6000; + AccelerateX(0x4000); + entity->unk5A = 0x50; + entity->palette = 0x819F; + entity->unk4C = &D_800AE294; + entity->unk34 = 0x100000; + entity->facing = 0; + entity->posY.i.hi -= 16; + entity->posX.val += entity->accelerationX << 5; + entity->step++; + break; + + case 1: + entity->posX.val += entity->accelerationX; + entity->posY.val += entity->accelerationY; + if (entity->animFrameDuration < 0) { + DestroyEntity(entity); + } + break; } } -#endif // dagger thrown when using subweapon INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", EntitySubwpnThrownDagger); @@ -1516,7 +1503,7 @@ INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_80130E94); #ifndef NON_EQUIVALENT INCLUDE_ASM("asm/us/dra/nonmatchings/75F54", func_8013136C); #else -void func_8012C600(void); /* extern */ +void func_8012C600(void); extern u16 D_8007412E; extern s32 D_800741CC; extern s32 D_800741D0; diff --git a/src/dra/dra.h b/src/dra/dra.h index e66e5e819..43a93aa0b 100644 --- a/src/dra/dra.h +++ b/src/dra/dra.h @@ -144,7 +144,7 @@ extern s16 D_800ACF60[]; // collection of sounds? extern s32 D_800ACFB4[]; extern s32 D_800ADC44; extern s32 D_800AE270[]; -extern s32* D_800AE294; // might not really be a pointer +extern AnimationFrame* D_800AE294; extern s16 D_800AFDA6; extern const char* c_strEquip; extern const char* c_strSpells; diff --git a/src/ric/20920.c b/src/ric/20920.c index 3ab14ba73..81f35b660 100644 --- a/src/ric/20920.c +++ b/src/ric/20920.c @@ -514,12 +514,10 @@ Entity* func_801606BC(Entity* srcEntity, u32 arg1, s32 arg2) { INCLUDE_ASM("asm/us/ric/nonmatchings/20920", func_80160788); -// move a0,s0 -#ifndef NON_MATCHING -INCLUDE_ASM("asm/us/ric/nonmatchings/20920", func_80160C38); -#else void func_80160C38(Entity* entity) { - if (PLAYER.step == 17) { + if (PLAYER.step != 23) { + func_80156C60(entity); + } else { entity->posX.i.hi = PLAYER.posX.i.hi; entity->posY.i.hi = PLAYER.posY.i.hi; entity->facing = PLAYER.facing; @@ -541,11 +539,8 @@ void func_80160C38(Entity* entity) { if (PLAYER.animFrameIdx >= 8) { func_80156C60(entity); } - } else { - func_80156C60(entity); } } -#endif // aspatch jumps to the wrong instruction // Matches with PSY-Q 3.5 + aspsx 2.3.4