Skip to content

Commit

Permalink
Stage BSS Organizing, Padding Macros (Xeeynamo#1497)
Browse files Browse the repository at this point in the history
Maps `create_entity` and `e_collect` data, text, and bss for all stages.

Adds macros for defining padding for various sections by size.

Tables for section sizes have been added to common includes to make
calculating offsets easier when segments.
  • Loading branch information
hohle authored Aug 11, 2024
1 parent 20a3936 commit a34dc9a
Show file tree
Hide file tree
Showing 47 changed files with 182 additions and 656 deletions.
4 changes: 3 additions & 1 deletion config/splat.hd.stwrp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ segments:
- [0x124C8, c, e_room_fg]
- [0x125B4, c, popup]
- [0x1298C, c, prim_helpers]
- [0x131BC, .bss, bss]
- [0x131BC, .bss, create_entity]
- [0x131CC, .bss, bss]
- [0x13E44, .bss, e_collect]
- [0x13E84]
4 changes: 3 additions & 1 deletion config/splat.pspeu.stwrp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ segments:
- [0x14498, .rodata, wrp_psp/e_collect]
- [0x144D0, .rodata, wrp_psp/e_misc]
- [0x144F8, .rodata, wrp/warp]
- [0x14580, .bss, wrp_psp/bss]
- [0x14500, .bss, wrp_psp/create_entity]
- [0x14520, .bss, wrp_psp/e_collect]
- [0x14560, .bss, wrp_psp/bss]
- [0x14580]
4 changes: 2 additions & 2 deletions config/splat.us.stcen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ segments:
- [0x1B274, c]
- [0x1BED4, c, prim_helpers]
- [0x1C704, .bss, header]
- [0x1C718, .bss, create_entity]
- [0x1C71C, .bss, holyglassescutscene]
- [0x1C764, .bss, create_entity]
- [0x1C774, .bss, holyglassescutscene]
- [0x1C7C0, .bss, 15C84]
- [0x1D46C]
4 changes: 3 additions & 1 deletion config/splat.us.stdre.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,7 @@ segments:
- [0x1E1C8, c]
- [0x22018, c, prim_helpers]
- [0x22848, c]
- [0x23264, .bss, bss]
- [0x23264, .bss, create_entity]
- [0x232CA, .bss, bss]
- [0x23FB6, .bss, 1C7DC]
- [0x23FCC]
4 changes: 3 additions & 1 deletion config/splat.us.stmad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,7 @@ segments:
- [0x149C0, c, entity_relic_orb]
- [0x15520, c]
- [0x18FA0, c, prim_helpers]
- [0x197D8, .bss, bss]
- [0x197D8, .bss, create_entity]
- [0x197ED, .bss, bss]
- [0x19E7E, .bss, 139E0]
- [0x19E94]
14 changes: 9 additions & 5 deletions config/splat.us.stno3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ segments:
- [0x1CEC, .data, collision]
- [0x20AC, .data, e_red_door]
- [0x20C4, data]
- [0x22C4, .data, e_collect]
- [0x25B4, .data, entity_relic_orb]
- [0x2618, data]
- [0x3180, data]
Expand All @@ -77,9 +78,9 @@ segments:
- [0x37514, .rodata, 3FF00] # EntityDeath
- [0x37564, .rodata, 3FF00] # EntityWargExplosionPuffOpaque
- [0x37578, .rodata, e_red_door] # EntityRedDoor
- [0x37590, rodata]
- [0x375E0, .rodata, 46684] # EntityPrizeDrop
- [0x37600, .rodata, 46684] # EntityEquipItemDrop
- [0x37590, .rodata, e_collect] # CollectGold text
- [0x375E0, .rodata, e_collect] # EntityPrizeDrop
- [0x37600, .rodata, e_collect] # EntityEquipItemDrop
- [0x37618, .rodata, entity_relic_orb]
- [0x37650, .rodata, entity_message_box]
- [0x37664, .rodata, 48A84] # EntityStageNamePopup
Expand All @@ -98,13 +99,16 @@ segments:
- [0x4343C, c, create_entity]
- [0x43FB4, c, e_red_door]
- [0x44C64, c]
- [0x46684, c]
- [0x45BC0, c, e_collect]
- [0x47680, c, blit_char]
- [0x47930, c, entity_relic_orb]
- [0x48400, c, entity_heart_drop]
- [0x48528, c, entity_message_box]
- [0x48A84, c]
- [0x56264, c]
- [0x564B0, c]
- [0x56880, c, prim_helpers]
- [0x570B0, .bss, bss]
- [0x570B0, .bss, create_entity]
- [0x57120, .bss, bss]
- [0x57DD8, .bss, e_collect]
- [0x57E18]
5 changes: 4 additions & 1 deletion config/splat.us.stnp3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,8 @@ segments:
- [0x4F5B8, c]
- [0x50A00, c, blade]
- [0x51F38, c, prim_helpers]
- [0x52768, .bss, bss]
- [0x52768, .bss, create_entity]
- [0x5277D, .bss, bss]
- [0x53378, .bss, 4D540]
- [0x533F4, .bss, e_collect]
- [0x53434]
4 changes: 3 additions & 1 deletion config/splat.us.stnz0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,7 @@ segments:
- [0x48ADC, c, e_stage_name]
- [0x49930, c, prim_helpers]
- [0x4A160, c, lifeupspawn]
- [0x4AA14, .bss, bss]
- [0x4AA14, .bss, create_entity]
- [0x4AA24, .bss, bss]
- [0x4B740, .bss, e_collect]
- [0x4B780]
4 changes: 3 additions & 1 deletion config/splat.us.strwrp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,7 @@ segments:
- [0x14DD4, c, wrp/e_room_fg]
- [0x14EC0, c, wrp/popup]
- [0x151F0, c, wrp/prim_helpers]
- [0x15A20, .bss, rwrp/bss]
- [0x15A20, .bss, wrp/create_entity]
- [0x15A36, .bss, rwrp/bss]
- [0x166A8, .bss, wrp/e_collect]
- [0x166E8]
4 changes: 3 additions & 1 deletion config/splat.us.stst0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,7 @@ segments:
- [0x36358, c]
- [0x3D0C0, c, prim_helpers]
- [0x3D8F0, c]
- [0x3EB00, .bss, bss]
- [0x3EB00, .bss, create_entity]
- [0x400B6, .bss, bss]
- [0x42584, .bss, 36358]
- [0x425C4]
4 changes: 3 additions & 1 deletion config/splat.us.stwrp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,7 @@ segments:
- [0x12E54, c, e_room_fg]
- [0x12F40, c, popup]
- [0x13270, c, prim_helpers]
- [0x13AB0, .bss, bss]
- [0x13AB0, .bss, create_entity]
- [0x13AC0, .bss, bss]
- [0x14728, .bss, e_collect]
- [0x14768]
2 changes: 0 additions & 2 deletions config/symbols.us.ric.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
g_RicFactoryBlueprints = 0x80154A6C;
UpdateEntityRichter = 0x80157BFC;
6 changes: 0 additions & 6 deletions config/symbols.us.stno3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ g_eBreakableExplosionTypes = 0x80180E78;
g_eBreakableanimSets = 0x80180E80;
g_eBreakableDrawModes = 0x80180E90;
g_TrapDoorFlag = 0x8018123C;
g_goldCollectTexts = 0x80182438;
c_GoldPrizes = 0x80182460;
c_HeartPrizes = 0x801824F0;
g_ExplosionYVelocities = 0x801824F4;
g_bigRedFireballAnim = 0x8018251C;
g_ExplosionAnimations = 0x801825A0;
g_eUnk14SpawnRots = 0x80182618;
unk15_rot = 0x80182628;
unk15_yVel = 0x80182638;
Expand Down
33 changes: 33 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,37 @@ int sprintf(char* dst, const char* fmt, ...);
#define CLAMP_MIN(v, min) ((v) < (min) ? (min) : (v))
#define CLAMP_MAX(v, max) ((v) > (max) ? (max) : (v))

// Creates padding between variables with a unique name and file
// visibility. On versions where this padding is unnecessary, these
// macros expand to nothing. "Critical" versions of these macros
// ensure that the padding is provided, regardless of version, useful
// for when locations are accessed using a variety of sizes so
// field offset needs to be maintained. The unknown critical versions
// expand identically to the critical versions but indicate that it
// is not known whether or not the padding is necessary outside of
// reproducing an original binary.
#define __INDIRECT_CRITICAL_PAD_TYPE_FIELD(type, size, line, counter) \
type __pad__##size##__##line##__##counter[size]
#define __CRITICAL_PAD_TYPE_FIELD(type, size, line, counter) \
__INDIRECT_CRITICAL_PAD_TYPE_FIELD(type, size, line, counter)
#define CRITICAL_PAD_TYPE_FIELD(type, size) \
__CRITICAL_PAD_TYPE_FIELD(type, size, __LINE__, __COUNTER__)
#define CRITICAL_PAD_FIELD(size) CRITICAL_PAD_TYPE_FIELD(uint8_t, size)

#define UNKNOWN_CRITICAL_PAD_TYPE(type, size) \
CRITICAL_PAD_TYPE_FIELD(type, size)
#define UNKNOWN_CRITICAL_PAD_FIELD(size) CRITICAL_PAD_FIELD(size)

#ifndef VERSION_PC
#define PAD_FIELD(size) const CRITICAL_PAD_FIELD(size)
#define STATIC_PAD_BSS(size) static CRITICAL_PAD_FIELD(size)
#define STATIC_PAD_DATA(size) STATIC_PAD_BSS(size) = {0}
#define STATIC_PAD_RODATA(size) static const STATIC_PAD_BSS(size) = {0}
#else
#define PAD_FIELD(size)
#define STATIC_PAD_BSS(size)
#define STATIC_PAD_DATA(size)
#define STATIC_PAD_RODATA(size)
#endif

#endif
7 changes: 7 additions & 0 deletions src/st/blit_char.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//
// Section Sizes:
//
// | Data | RO Data | Text | BSS |
// +-------+---------+--------+------+
// PSX US | - | - | 0x2B0 | - |
//
#include <stage.h>

char* BlitChar(char* str, u16* xOffset, u8* pix, u16 stride) {
Expand Down
2 changes: 1 addition & 1 deletion src/st/cen/15C84.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void EntityPrizeDrop(Entity* self) {

#include "../blink_item.h"

u16 g_ItemIconSlots[32];
static u16 g_ItemIconSlots[ICON_SLOT_NUM];

extern s32 D_80097410;
extern s32 D_80097414;
Expand Down
9 changes: 1 addition & 8 deletions src/st/cen/create_entity.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
#include <types.h>

static u16* g_LayoutObjHorizontal;
static u16* g_LayoutObjVertical;
static u8 g_LayoutObjPosHorizontal;
static u8 _unused0[3];
static u8 g_LayoutObjPosVertical;
static u8 _unused1[3];
#include <common.h>

#include "../create_entity.h"
19 changes: 18 additions & 1 deletion src/st/create_entity.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
#include "st_private.h"
//
// Section Sizes:
//
// | Data | RO Data | Text | BSS |
// --------+-------+---------+-------+------+
// PSX US | TBD | TBD | 0xB78 | 0x10 |
// PSX HD | TBD | TBD | 0xB78 | 0x10 |
//

#include <common.h>

static u16* g_LayoutObjHorizontal;
static u16* g_LayoutObjVertical;
static u8 g_LayoutObjPosHorizontal;
STATIC_PAD_BSS(3);
static u8 g_LayoutObjPosVertical;
STATIC_PAD_BSS(3);

#include "st_private.h"
#include "create_entity_from_layout.h"
#include "create_entity_in_range.h"
#include "find_entity_horizontal.h"
Expand Down
2 changes: 2 additions & 0 deletions src/st/dre/1C7DC.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "dre.h"
#include "sfx.h"

static u16 g_ItemIconSlots[ICON_SLOT_NUM];

void EntityEquipItemDrop(Entity* self) {
u16 itemId = self->params & 0x7FFF;
s32 primIndex;
Expand Down
9 changes: 2 additions & 7 deletions src/st/dre/bss.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include <game.h>
#include <common.h>

u32 D_801A3264[24];
u32 g_LayoutObjHorizontal;
u32 g_LayoutObjVertical;
u8 g_LayoutObjPosHorizontal[4];
u8 g_LayoutObjPosVertical[3076];
STATIC_PAD_BSS(3072);
u32 D_801A3ED4;
u32 g_Dialogue;
u16 D_801A3EDC;
Expand Down Expand Up @@ -32,4 +28,3 @@ u16 D_801A3F16;
u32 D_801A3F18[27];
u32 D_801A3F84;
u32 D_801A3F88;
u16 g_ItemIconSlots[ICON_SLOT_NUM];
4 changes: 4 additions & 0 deletions src/st/dre/create_entity.c
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#include <types.h>

u32 D_801A3264[24];

#include "../create_entity.h"
13 changes: 10 additions & 3 deletions src/st/e_collect.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
//
// Section Sizes:
//
// | Data | RO Data | Text | BSS |
// --------+-------+---------+--------+------+
// PSX US | 0x2F0 | 0x88 | 0x1AC0 | 0x40 |
// PSX HD | 0x200 | 0x88 | 0x1570 | 0x40 |
//
#include <stage.h>
#include "sfx.h"

Expand Down Expand Up @@ -91,9 +99,6 @@ static u8* g_ExplosionAnimations[] = {
D_80180ED8, g_bigRedFireballAnim, D_80180F08, D_80180F38, D_80180F6C,
};

// TODO BSS
extern u16 g_ItemIconSlots[];

// from another file
extern u16 g_InitializeData0[];

Expand Down Expand Up @@ -476,6 +481,8 @@ extern u16 g_InitializeEntityData0[];

#include "blink_item.h"

u16 g_ItemIconSlots[ICON_SLOT_NUM];

void EntityEquipItemDrop(Entity* self) {
Collider collider;
Primitive* prim;
Expand Down
2 changes: 2 additions & 0 deletions src/st/mad/139E0.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ extern u16 D_80180D4C[];
extern u8* D_80180DB0[];
extern u16 D_80180E10[];

static u16 g_ItemIconSlots[ICON_SLOT_NUM];

void EntityPrizeDrop(Entity* self) {
Collider collider;
Primitive* prim;
Expand Down
7 changes: 1 addition & 6 deletions src/st/mad/bss.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#include <game.h>
#include <types.h>

u32 g_LayoutObjHorizontal;
u32 g_LayoutObjVertical;
u8 g_LayoutObjPosHorizontal[4];
u8 g_LayoutObjPosVertical[4];
u16 D_801997E8[768];
u32 D_80199DE8[27];
u16 g_ItemIconSlots[ICON_SLOT_NUM];
9 changes: 9 additions & 0 deletions src/st/mad/create_entity.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#include "mad.h"

// BSS START size = 0x16
static u16* g_LayoutObjHorizontal;
static u16* g_LayoutObjVertical;
static u8 g_LayoutObjPosHorizontal;
STATIC_PAD_BSS(3);
static u8 g_LayoutObjPosVertical;
STATIC_PAD_BSS(3);
// END BSS

#include "../st_private.h"

#include "../create_entity_from_layout.h"
Expand Down
Loading

0 comments on commit a34dc9a

Please sign in to comment.