Skip to content

Commit

Permalink
Add size hints for PSP globals and fix some references (#2247)
Browse files Browse the repository at this point in the history
Should help with decomp because when doing this, splat can provide
offsets from the base address in the ASM, for example
```
    /* 23C8C 0910060C 1D09023C */  lui        $v0, %hi(g_Status + 0x240)
    /* 23C90 09100610 40F6428C */  lw         $v0, %lo(g_Status + 0x240)($v0)
```

```
    /* 1A29C 090F6C1C 2309023C */  lui        $v0, %hi(g_CastleFlags + 0x96)
    /* 1A2A0 090F6C20 C64743A0 */  sb         $v1, %lo(g_CastleFlags + 0x96)($v0)
```

This should stop accidentally mapping these addresses as extern symbols
when decompiling [like
this](#2243 (comment)).

While I was here I fixed a few of the existing cases where that had
happened, using the splat hints as a guide.

I think the same should be possible on the PSX side but I need to verify
a few things.
  • Loading branch information
JoshSchreuder authored Feb 23, 2025
1 parent df8ff7c commit f17d42e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 51 deletions.
16 changes: 4 additions & 12 deletions config/symbols.pspeu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,11 @@ g_CdStep = 0x91CE5E0;
g_unkGraphicsStruct = 0x091CE5F8;
D_80097488 = 0x091CE688;
g_randomNext = 0x091CE6B0;
g_Settings = 0x091CEEBC;
g_Settings = 0x091CEEBC; // size:0x110
g_PlayableCharacter = 0x091CF020;
g_Servant = 0x091CF028;
g_Player = 0x091CF030;
g_Player_pl_vram_flag = 0x091CF380;
D_psp_091CF3A0 = 0x091CF3A0;
D_psp_091CF3A4 = 0x091CF3A4;
D_psp_091CF3A8 = 0x091CF3A8;
D_psp_091CF3AC = 0x091CF3AC;
g_Player_unk50 = 0x091CF3D0;
g_Player_unk52 = 0x091CF3D2;
D_psp_091CF3DC = 0x091CF3DC;
g_Status = 0x091CF400;
g_Player = 0x091CF030; // size:0x3CE
g_Status = 0x091CF400; // size:0x334
g_api = 0x91CF738;
g_api_FreePrimitives = 0x091cf778;
g_api_AllocPrimitives = 0x091cf77c;
Expand Down Expand Up @@ -121,5 +113,5 @@ g_Timer = 0x091FC468;
g_UseDisk = 0x091FC470;
g_CurrentBuffer = 0x091FC4E0;
g_GpuBuffers = 0x091FC4E8;
g_CastleFlags = 0x09234730;
g_CastleFlags = 0x09234730; // size:0x300
DestroyEntity = 0x092EE938;
8 changes: 0 additions & 8 deletions config/undefined_syms.pspeu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ g_ScrollDeltaX = 0x091CE698;
g_ScrollDeltaY = 0x091CE690;
g_Servant = 0x091CF028;
g_Player = 0x091CF030;
D_psp_091CF3A0 = 0x091CF3A0;
D_psp_091CF3A4 = 0x091CF3A4;
D_psp_091CF3A8 = 0x091CF3A8;
D_psp_091CF3AC = 0x091CF3AC;
D_psp_091CF3DC = 0x091CF3DC;
g_Status = 0x091CF400;
g_api = 0x091CF738;
g_PrimBuf = 0x091CFAF8;
Expand All @@ -31,8 +26,5 @@ g_CurrentEntity = 0x091E1678;
PfnEntityUpdates = 0x08C6BC30;
g_PlayableCharacter = 0x091CF020;
g_Status = 0x091CF400;
D_091CF6DC = 0x091CF6DC;
D_091CF698 = 0x091CF698;
g_PauseAllowed = 0x091CE580;
D_8003BEBC = 0x09234800;
D_80097C98 = 0x091ed280;
8 changes: 1 addition & 7 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ typedef struct {
/* 80072F3C */ s32 unk1C;
/* 80072F40 */ s32 unk20;
/* 80072F44 */ s32 unk24;
/* 80072F48 */ s32 unk28;
/* 80072F48 */ PfnEntityUpdate unk28;
/* 80072F4C */ s32 unk2C;
/* 80072F50 */ s32 unk30;
/* 80072F54 */ s32 unk34;
Expand Down Expand Up @@ -1939,12 +1939,6 @@ extern s16 D_800705CC[]; // part of g_Clut
extern u32 D_80070BCC; // part of g_Clut

extern PlayerState g_Player;
// the following are most likely part of g_Player
extern Entity* D_psp_091CF3A0;
extern s32 D_psp_091CF3A4; // maybe not s32 but a pointer?
extern void (*D_psp_091CF3A8)(Entity*);
extern s32 D_psp_091CF3AC; // maybe not s32 but a pointer?
extern u16 D_psp_091CF3DC;

extern GfxLoad g_GfxLoad[0x10];
extern u32 g_GameStep;
Expand Down
18 changes: 9 additions & 9 deletions src/dra_psp/67F0.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ extern s32 D_psp_09147418[];
Primitive* func_psp_090E4828(Primitive* prim) {
s32* ptr;

if (D_psp_091CF698 == 0) {
if (g_Status.subWeapon == 0) {
prim->drawMode = DRAW_HIDE;
} else {
if (g_PlayableCharacter == PLAYER_MARIA) {
ptr = &D_psp_09147418[D_psp_091CF698 * 8];
ptr = &D_psp_09147418[g_Status.subWeapon * 8];
} else {
ptr = &D_psp_091472F8[(D_psp_091CF698 - 1) * 8];
ptr = &D_psp_091472F8[(g_Status.subWeapon - 1) * 8];
}
SetTexturedPrimRect(
prim, ptr[0] + 2, ptr[1] + 22, ptr[2], ptr[3], ptr[4], ptr[5]);
Expand Down Expand Up @@ -191,23 +191,23 @@ void func_psp_090E4968(Primitive* prim, s32 idx, s32 xOffset, s32 yOffset,
void func_psp_090E4C18(void) {
if (D_psp_091474B8 < 0) {
D_psp_091474B8 = 0;
D_psp_091CDC80 = D_psp_091CF698;
D_psp_091CDC88 = D_psp_091CF6DC;
D_psp_091CDC80 = g_Status.subWeapon;
D_psp_091CDC88 = g_Status.D_80097C40;
}
}

s32 func_psp_090E4C58(void) { return D_psp_091474B8; }

void func_psp_090E4C68(void) {
D_psp_091CDC80 = D_psp_091CF698;
D_psp_091CDC88 = D_psp_091CF6DC;
D_psp_091CDC80 = g_Status.subWeapon;
D_psp_091CDC88 = g_Status.D_80097C40;
}

void func_psp_090E4C90(void) {
if (D_psp_091474B8 < 0) {
D_psp_091CDC88 = D_psp_091CF6DC;
D_psp_091CDC88 = g_Status.D_80097C40;
} else {
D_psp_091CDC80 = D_psp_091CF6DC;
D_psp_091CDC80 = g_Status.D_80097C40;
}
}

Expand Down
2 changes: 0 additions & 2 deletions src/dra_psp/dra_psp.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ extern s32 D_psp_091474B8;
extern s32 D_psp_091893B8[];
extern s32 D_psp_091CDC80;
extern s32 D_psp_091CDC88;
extern s32 D_psp_091CF698;
extern s32 D_psp_091CF6DC;
extern unsigned char D_psp_09236780[][0x20];

s32 func_89192EC(s32, s32);
Expand Down
16 changes: 8 additions & 8 deletions src/st/collect_subweapon_psp.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
extern u16 D_80180DC4[];
extern u32 D_091CF6DC;
extern u32 D_091CF698;
static void CollectSubweapon(u16 subWeaponIdx) {
Entity* player = &PLAYER;
u16 subWeapon;

g_api.PlaySfx(SFX_ITEM_PICKUP);
if (g_PlayableCharacter == PLAYER_MARIA) {
subWeapon = D_091CF6DC;
subWeapon = g_Status.D_80097C40;
} else {
subWeapon = D_091CF698;
subWeapon = g_Status.subWeapon;
}

if (g_PlayableCharacter == PLAYER_MARIA) {
D_091CF6DC = maria_subweapons_idx[subWeaponIdx - 14];
g_Status.D_80097C40 = maria_subweapons_idx[subWeaponIdx - 14];
func_90E4C90();
} else {
D_091CF698 = aluric_subweapons_idx[subWeaponIdx - 14];
g_Status.subWeapon = aluric_subweapons_idx[subWeaponIdx - 14];
}

if (g_PlayableCharacter != PLAYER_MARIA && subWeapon == D_091CF698 ||
g_PlayableCharacter == PLAYER_MARIA && subWeapon == D_091CF6DC) {
if (g_PlayableCharacter != PLAYER_MARIA &&
subWeapon == g_Status.subWeapon ||
g_PlayableCharacter == PLAYER_MARIA &&
subWeapon == g_Status.D_80097C40) {
subWeapon = 1;
g_CurrentEntity->unk6D[0] = 0x10;
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/st/e_particles_maria1.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ void func_psp_0923AD68(Entity* self) {
u16 direction;
Entity* pl;

if (D_psp_091CF3DC && D_psp_091CF3A0) {
pl = D_psp_091CF3A0;
if (g_Player.unk5C && g_Player.unk20) {
pl = (Entity*)g_Player.unk20;
} else {
pl = &PLAYER;
}
Expand Down Expand Up @@ -54,7 +54,7 @@ void func_psp_0923AD68(Entity* self) {
}
if (abs(pl->posX.i.hi - self->posX.i.hi) < 8 &&
abs(pl->posY.i.hi - self->posY.i.hi) < 8) {
D_psp_091CF3A4 += 4;
g_Player.unk24 += 4;
DestroyEntity(self);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/st/e_particles_maria2.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ void func_psp_0923B2F0(Entity* self) {
}
break;
}
D_psp_091CF3AC = 0;
g_Player.unk2C = 0;
DestroyEntity(self);
}
2 changes: 1 addition & 1 deletion src/st/entity_soul_steal_orb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void EntitySoulStealOrb(Entity* self) {

#ifdef VERSION_PSP
if (g_PlayableCharacter == PLAYER_MARIA) {
D_psp_091CF3A8 = &func_psp_0923B2F0;
g_Player.unk28 = &func_psp_0923B2F0;
func_psp_0923AD68(self);
return;
}
Expand Down

0 comments on commit f17d42e

Please sign in to comment.