ST WRP re-organise C files (#1181)

A massive PR, I know. It's the smallest change I could do to make this
happen.

After comparing the function order from both ST/WRP PSX and ST/WRP PSP,
I was able to come up with a file split much different from the one
suggested from Splat. It still returns an 🆗 and it follows the same
group functions order from the two game builds.

As soon as we are on board with the C names, next PR will be to do the
same with the PSX overlay. Then in another PR we will be able to start
merging the C files between the two builds. Ideally the same approach
can be used for sharing C files across the different overlays instead of
relying to floating header files in `src/st`
This commit is contained in:
Luciano Ciccariello 2024-05-26 20:59:07 +01:00 committed by GitHub
parent 2073f27ed0
commit 92812cc6c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
27 changed files with 220 additions and 214 deletions

View File

@ -41,19 +41,20 @@ segments:
align: 128
subalign: 8
subsegments:
- [0x80, c, wrp_psp/80]
- [0x4D0, c, wrp_psp/4D0]
- [0x31F0, c, wrp_psp/31F0]
- [0x3C70, c, wrp_psp/3C70]
- [0x4100, c, wrp_psp/4100]
- [0x5600, c, wrp_psp/5600]
- [0x5AB0, c, wrp_psp/5AB0]
- [0x6BF0, c, wrp_psp/6BF0]
- [0x8580, c, wrp_psp/8580]
- [0x95D0, c, wrp_psp/95D0]
- [0xBDA0, c, wrp_psp/BDA0]
- [0xBFD8, c, wrp_psp/BFD8]
- [0xC3F0, c, wrp_psp/C3F0]
- [0x80, c, wrp_psp/create_entity]
- [0x1028, c, wrp_psp/e_stage_name]
- [0x1EA8, c, wrp_psp/e_red_door]
- [0x31F0, c, wrp_psp/st_update]
- [0x36E8, c, wrp_psp/e_particles]
- [0x4C78, c, wrp_psp/blit_char]
- [0x5308, c, wrp_psp/e_collect]
- [0x7448, c, wrp_psp/e_misc]
- [0x95D0, c, wrp_psp/collision]
- [0xB7A8, c, wrp_psp/popup]
- [0xBDA0, c, wrp_psp/e_room_fg]
- [0xBEB8, c, wrp_psp/st_common]
- [0xC9A0, c, wrp_psp/stage_name_new]
- [0xCEA0, c, wrp_psp/prim_helpers]
- [0xD0E0, c, wrp_psp/st_init_wrp]
- [0xD1B8, c, wrp/e_breakable]
- [0xD338, c, wrp/st_debug]

View File

@ -17,4 +17,4 @@ g_pads = 0x091FC4A8;
g_randomNext = 0x091CE6B0;
g_CurrentEntity = 0x091E1678;
PfnEntityUpdates = 0x08C6BC30;
g_PlayableCharacter = 0x091CF020;
g_PlayableCharacter = 0x091CF020;

View File

@ -1,7 +0,0 @@
#include "common.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/31F0", Update);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/31F0", UpdateStageEntities);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/31F0", func_psp_0923AD68);

View File

@ -1,3 +0,0 @@
#include "common.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/3C70", func_psp_0923B2F0);

View File

@ -1,50 +0,0 @@
#include "common.h"
#include "game.h"
#include "sfx.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4100", EntitySoulStealOrb);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4100", EntityEnemyBlood);
// psp unique?
u8 func_psp_0923C2F8(u8 arg0) {
if (arg0 & 0x100) {
return func_psp_0923C2F8(arg0 & 0xFF);
}
if (arg0 & 0x80) {
return func_psp_0923C2F8((arg0 & 0x7F) + 3);
}
return (arg0 * 0x10);
}
extern s32 D_91ED5F8;
extern s32 D_psp_0924BC68;
extern s32 D_psp_0924BC70;
extern s32* D_psp_0924BC78;
// PSP unique?
void func_psp_0923C390(s32 arg0, s32 arg1) {
D_psp_0924BC78 = &D_91ED5F8;
D_psp_0924BC70 = arg0;
D_psp_0924BC68 = arg1;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4100", BlitChar);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4100", func_8018CAB0);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4100", func_8018CB34);
extern s8 c_HeartPrizes[];
void CollectHeart(u16 arg0) {
s32* hearts;
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_Status.hearts += c_HeartPrizes[arg0];
if (g_Status.hearts > g_Status.heartsMax) {
g_Status.hearts = g_Status.heartsMax;
}
DestroyEntity(g_CurrentEntity);
}

View File

@ -1,28 +0,0 @@
#include "common.h"
#include "game.h"
#include "sfx.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5600", CollectGold);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5600", CollectSubweapon);
void CollectHeartVessel(void) {
if (g_PlayableCharacter != PLAYER_ALUCARD) {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_Status.hearts += HEART_VESSEL_RICHTER;
if (g_Status.hearts > g_Status.heartsMax) {
g_Status.hearts = g_Status.heartsMax;
}
} else {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_api.func_800FE044(HEART_VESSEL_INCREASE, 0x4000);
}
DestroyEntity(g_CurrentEntity);
}
void CollectLifeVessel(void) {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_api.func_800FE044(5, 0x8000);
DestroyEntity(g_CurrentEntity);
}

View File

@ -1,9 +0,0 @@
#include "common.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5AB0", DestroyCurrentEntity);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5AB0", EntityPrizeDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5AB0", EntityExplosion);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/5AB0", BlinkItem);

View File

@ -1,5 +0,0 @@
#include "common.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/6BF0", EntityEquipItemDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/6BF0", EntityRelicOrb);

View File

@ -1,5 +0,0 @@
#include "../wrp/wrp.h"
#include "../create_entity_from_layout.h"
#include "../create_entity_in_range.h"

View File

@ -1,15 +0,0 @@
#include "common.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", EntityHeartDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", EntityMessageBox);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", func_8018F510);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", func_8018F838);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", EntityUnkId15);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", EntityIntenseExplosion);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/8580", func_801916C4);

View File

@ -1,7 +0,0 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/95D0", TestCollisions);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/95D0", EntityNumericDamage);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/95D0", BottomCornerText);

View File

@ -1,37 +0,0 @@
#include "common.h"
#include "game.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", func_8018C1E0);
void SetStep(u8 step) {
g_CurrentEntity->step = step;
g_CurrentEntity->step_s = 0;
g_CurrentEntity->animFrameIdx = 0;
g_CurrentEntity->animFrameDuration = 0;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", InitializeEntity);
void EntityDummy(Entity* arg0) {
if (!arg0->step) {
arg0->step++;
}
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", func_8018C55C);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", ReplaceBreakableWithItemDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", func_psp_09244020);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", PrimResetNext);
void UnkPolyFunc2(Primitive* prim) {
PrimResetNext(prim);
prim->p3 = 8;
prim->next->p3 = 1;
prim->next->type = PRIM_LINE_G2;
prim->next->drawMode = 0xA;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/C3F0", PrimDecreaseBrightness);

View File

@ -0,0 +1,26 @@
#include "../wrp/wrp.h"
// psp unique?
u8 func_psp_0923C2F8(u8 arg0) {
if (arg0 & 0x100) {
return func_psp_0923C2F8(arg0 & 0xFF);
}
if (arg0 & 0x80) {
return func_psp_0923C2F8((arg0 & 0x7F) + 3);
}
return (arg0 * 0x10);
}
extern s32 D_91ED5F8;
extern s32 D_psp_0924BC68;
extern s32 D_psp_0924BC70;
extern s32* D_psp_0924BC78;
// PSP unique?
void func_psp_0923C390(s32 arg0, s32 arg1) {
D_psp_0924BC78 = &D_91ED5F8;
D_psp_0924BC70 = arg0;
D_psp_0924BC68 = arg1;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/blit_char", BlitChar);

View File

@ -0,0 +1,5 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/collision", TestCollisions);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/collision", EntityNumericDamage);

View File

@ -1,5 +1,13 @@
#include <game.h>
// *** TODO ***
// REMOVE THIS WHEN DOING #include <stage.h>
#if defined(VERSION_PSP)
extern PfnEntityUpdate* PfnEntityUpdates;
#else
extern PfnEntityUpdate PfnEntityUpdates[];
#endif
// redeclaring for the moment due to header conflict with Random() definition
typedef struct {
/* 0x0 */ u16 posX;
@ -9,6 +17,10 @@ typedef struct {
/* 0x8 */ u16 params;
} LayoutEntity; // size = 0xA
#include "../create_entity_from_layout.h"
#include "../create_entity_in_range.h"
extern LayoutEntity* g_LayoutObjHorizontal;
extern LayoutEntity* g_LayoutObjVertical;
@ -39,9 +51,11 @@ void FindFirstEntityToTheLeft(s16 posX) {
}
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", CreateEntitiesToTheRight);
void CreateEntitiesToTheRight(s16);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/create_entity", CreateEntitiesToTheRight);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", CreateEntitiesToTheLeft);
void CreateEntitiesToTheLeft(s16);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/create_entity", CreateEntitiesToTheLeft);
void FindFirstEntityAbove(s16 arg0) {
while (true) {
@ -64,16 +78,13 @@ void FindFirstEntityBelow(s16 arg0) {
}
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", CreateEntitiesAbove);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", CreateEntitiesBelow);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", InitRoomEntities);
void CreateEntitiesToTheRight(s16);
void CreateEntitiesToTheLeft(s16);
void CreateEntitiesAbove(s16);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/create_entity", CreateEntitiesAbove);
void CreateEntitiesBelow(s16);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/create_entity", CreateEntitiesBelow);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/create_entity", InitRoomEntities);
void UpdateRoomPosition() {
Tilemap* tilemap = &g_Tilemap;
@ -117,14 +128,3 @@ void CreateEntityFromEntity(u16 entityId, Entity* source, Entity* entity) {
entity->posX.i.hi = source->posX.i.hi;
entity->posY.i.hi = source->posY.i.hi;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", EntityStageNamePopup);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", EntityIsNearPlayer);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/4D0", EntityRedDoor);
u8 Random(void) {
g_randomNext = (g_randomNext * 0x01010101) + 1;
return g_randomNext >> 0x18;
}

View File

@ -0,0 +1,55 @@
#include "../wrp/wrp.h"
#include <sfx.h>
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", func_8018CAB0);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", func_8018CB34);
extern s8 c_HeartPrizes[];
void CollectHeart(u16 arg0) {
s32* hearts;
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_Status.hearts += c_HeartPrizes[arg0];
if (g_Status.hearts > g_Status.heartsMax) {
g_Status.hearts = g_Status.heartsMax;
}
DestroyEntity(g_CurrentEntity);
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", CollectGold);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", CollectSubweapon);
void CollectHeartVessel(void) {
if (g_PlayableCharacter != PLAYER_ALUCARD) {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_Status.hearts += HEART_VESSEL_RICHTER;
if (g_Status.hearts > g_Status.heartsMax) {
g_Status.hearts = g_Status.heartsMax;
}
} else {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_api.func_800FE044(HEART_VESSEL_INCREASE, 0x4000);
}
DestroyEntity(g_CurrentEntity);
}
void CollectLifeVessel(void) {
g_api.PlaySfx(NA_SE_PL_COLLECT_HEART);
g_api.func_800FE044(5, 0x8000);
DestroyEntity(g_CurrentEntity);
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", DestroyCurrentEntity);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", EntityPrizeDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", EntityExplosion);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", BlinkItem);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_collect", EntityEquipItemDrop);

17
src/st/wrp_psp/e_misc.c Normal file
View File

@ -0,0 +1,17 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", EntityRelicOrb);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", EntityHeartDrop);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", EntityMessageBox);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", func_8018F510);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", func_8018F838);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", EntityUnkId15);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", EntityIntenseExplosion);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_misc", func_801916C4);

View File

@ -0,0 +1,9 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_particles", func_psp_0923AD68);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_particles", func_psp_0923B2F0);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_particles", EntitySoulStealOrb);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_particles", EntityEnemyBlood);

View File

@ -0,0 +1,12 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_red_door", EntityIsNearPlayer);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_red_door", EntityRedDoor);
// TODO move this function to the next file
// but only when the func Update is matching
s32 Random(void) {
g_randomNext = (g_randomNext * 0x01010101) + 1;
return (g_randomNext >> 0x18) & 0xFF;
}

View File

@ -22,13 +22,3 @@ void EntityRoomForeground(Entity* entity) {
}
AnimateEntity(objInit->unk10, entity);
}
#include "../../destroy_entity.h"
void PreventEntityFromRespawning(Entity* entity) {
if (entity->entityRoomIndex) {
u16 index = entity->entityRoomIndex - 1 >> 5;
g_unkGraphicsStruct.D_80097428[index] |=
1 << ((entity->entityRoomIndex - 1) & 0x1F);
}
}

View File

@ -0,0 +1,3 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/e_stage_name", EntityStageNamePopup);

3
src/st/wrp_psp/popup.c Normal file
View File

@ -0,0 +1,3 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/popup", BottomCornerText);

View File

@ -0,0 +1,13 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/prim_helpers", PrimResetNext);
void UnkPolyFunc2(Primitive* prim) {
PrimResetNext(prim);
prim->p3 = 8;
prim->next->p3 = 1;
prim->next->type = PRIM_LINE_G2;
prim->next->drawMode = 0xA;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/prim_helpers", PrimDecreaseBrightness);

View File

@ -1,5 +1,14 @@
#include "common.h"
#include "game.h"
#include "../wrp/wrp.h"
#include "../../destroy_entity.h"
void PreventEntityFromRespawning(Entity* entity) {
if (entity->entityRoomIndex) {
u16 index = entity->entityRoomIndex - 1 >> 5;
g_unkGraphicsStruct.D_80097428[index] |=
1 << ((entity->entityRoomIndex - 1) & 0x1F);
}
}
#include "../animate_entity.h"
@ -51,3 +60,24 @@ u16 func_8018C160(Entity* a, Entity* b) {
s32 diffY = b->posY.i.hi - a->posY.i.hi;
return ratan2(diffY, diffX);
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_common", func_8018C1E0);
void SetStep(u8 step) {
g_CurrentEntity->step = step;
g_CurrentEntity->step_s = 0;
g_CurrentEntity->animFrameIdx = 0;
g_CurrentEntity->animFrameDuration = 0;
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_common", InitializeEntity);
void EntityDummy(Entity* arg0) {
if (!arg0->step) {
arg0->step++;
}
}
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_common", func_8018C55C);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_common", ReplaceBreakableWithItemDrop);

View File

@ -1,4 +1,4 @@
#include <game.h>
#include "../wrp/wrp.h"
// entity table to allocate new entities
extern PfnEntityUpdate* D_08C6BC30;

View File

@ -0,0 +1,5 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_update", Update);
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/st_update", UpdateStageEntities);

View File

@ -0,0 +1,3 @@
#include "../wrp/wrp.h"
INCLUDE_ASM("st/wrp_psp/psp/wrp_psp/stage_name_new", func_psp_09244020);