Move Some cen Data to Logical Compile Unit (#1492)

This change moves BSS variables into their most appropriate compile
unit, "decompiles" several data files, and splits out some existing data
into its logical unit.

BSS data has all been removed from `bss.c` and moved to a file where the
data is either first used or where it can be made static.

Several data files have been converted to appropriate types and added
to the most appropriate file. This converts the header related
references and some of the other early data.

Finally, some data like has been rearranged and moved into logical
compile units like data from `entity.c` into `holyglassescutscene.c`.
Logical boundaries were chosen based on where data could be made static.
This commit is contained in:
Jonathan Hohle 2024-08-09 02:30:12 -07:00 committed by GitHub
parent 8fe46d2b87
commit 2e181ea9f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 199 additions and 136 deletions

View File

@ -35,12 +35,16 @@ segments:
subsegments:
- [0x0, .data, header]
- [0xDC, .data, header] # layers
- [0x134, data] # gfxbanks
- [0x134, .data, header] # gfxbanks
- [0x1EC, .data, e_laydef] # layout entries header
- [0x394, .data, entity]
- [0x5D8, .data, holyglassescutscene]
- [0x68C, .data, F890]
- [0x7B8, .data, update]
- [0x7E4, .data, collision]
- [0xBA4, .data, e_red_door]
- [0xBBC, data]
- [0xBBC, .data, 14264]
- [0xDBC, data]
- [0x10AC, .data, entity_relic_orb]
- [0x1110, data]
- [0x12D4, .data, rooms]
@ -49,7 +53,7 @@ segments:
- [0x69EC, .data, tile_data] # tile data
- [0x81EC, .data, tile_data] # tile definitions
- [0xC60C, .data, sprites]
- [0xD414, rodata]
- [0xD414, .rodata, entity]
- [0xD42C, .rodata, holyglassescutscene]
- [0xD4B0, .rodata, F890]
- [0xD4D8, .rodata, e_red_door] # EntityRedDoor
@ -77,5 +81,8 @@ segments:
- [0x18084, c]
- [0x1B274, c]
- [0x1BED4, c, prim_helpers]
- [0x1C704, .bss, bss]
- [0x1C704, .bss, header]
- [0x1C718, .bss, create_entity]
- [0x1C71C, .bss, holyglassescutscene]
- [0x1C7C0, .bss, 15C84]
- [0x1D46C]

View File

@ -1,5 +1,3 @@
D_80180134 = 0x80180134;
gfxBanks = 0x8018019C;
g_goldCollectTexts = 0x80180F30;
c_GoldPrizes = 0x80180F58;
D_80180FE0 = 0x80180FE0;

View File

@ -49,7 +49,7 @@ extern PfnEntityUpdate* PfnEntityUpdates;
extern PfnEntityUpdate PfnEntityUpdates[];
#endif
extern u16 g_ItemIconSlots[0x20];
extern u16 g_ItemIconSlots[32];
/*
* Sets up layout arrays and initializes stage state to

View File

@ -188,6 +188,38 @@ Entity* AllocEntity(Entity* start, Entity* end) {
return NULL;
}
static s16 D_80180BBC[] = {
0x0000, 0x0065, 0x00C9, 0x012D, 0x0191, 0x01F5, 0x0259, 0x02BC, 0x031F,
0x0381, 0x03E3, 0x0444, 0x04A5, 0x0505, 0x0564, 0x05C2, 0x061F, 0x067C,
0x06D7, 0x0732, 0x078B, 0x07E3, 0x083A, 0x088F, 0x08E4, 0x0937, 0x0988,
0x09D8, 0x0A26, 0x0A73, 0x0ABF, 0x0B08, 0x0B50, 0x0B97, 0x0BDB, 0x0C1E,
0x0C5E, 0x0C9D, 0x0CDA, 0x0D15, 0x0D4E, 0x0D85, 0x0DB9, 0x0DEC, 0x0E1C,
0x0E4B, 0x0E77, 0x0EA1, 0x0EC8, 0x0EEE, 0x0F11, 0x0F31, 0x0F50, 0x0F6C,
0x0F85, 0x0F9C, 0x0FB1, 0x0FC4, 0x0FD4, 0x0FE1, 0x0FEC, 0x0FF5, 0x0FFB,
0x0FFF, 0x1000, 0x0FFF, 0x0FFB, 0x0FF5, 0x0FEC, 0x0FE1, 0x0FD4, 0x0FC4,
0x0FB1, 0x0F9C, 0x0F85, 0x0F6C, 0x0F50, 0x0F31, 0x0F11, 0x0EEE, 0x0EC8,
0x0EA1, 0x0E77, 0x0E4B, 0x0E1C, 0x0DEC, 0x0DB9, 0x0D85, 0x0D4E, 0x0D15,
0x0CDA, 0x0C9D, 0x0C5E, 0x0C1E, 0x0BDB, 0x0B97, 0x0B50, 0x0B08, 0x0ABF,
0x0A73, 0x0A26, 0x09D8, 0x0988, 0x0937, 0x08E4, 0x088F, 0x083A, 0x07E3,
0x078B, 0x0732, 0x06D7, 0x067C, 0x061F, 0x05C2, 0x0564, 0x0505, 0x04A5,
0x0444, 0x03E3, 0x0381, 0x031F, 0x02BC, 0x0259, 0x01F5, 0x0191, 0x012D,
0x00C9, 0x0065, 0x0000, 0xFF9B, 0xFF37, 0xFED3, 0xFE6F, 0xFE0B, 0xFDA7,
0xFD44, 0xFCE1, 0xFC7F, 0xFC1D, 0xFBBC, 0xFB5B, 0xFAFB, 0xFA9C, 0xFA3E,
0xF9E1, 0xF984, 0xF929, 0xF8CE, 0xF875, 0xF81D, 0xF7C6, 0xF771, 0xF71C,
0xF6C9, 0xF678, 0xF628, 0xF5DA, 0xF58D, 0xF541, 0xF4F8, 0xF4B0, 0xF469,
0xF425, 0xF3E2, 0xF3A2, 0xF363, 0xF326, 0xF2EB, 0xF2B2, 0xF27B, 0xF247,
0xF214, 0xF1E4, 0xF1B5, 0xF189, 0xF15F, 0xF138, 0xF112, 0xF0EF, 0xF0CF,
0xF0B0, 0xF094, 0xF07B, 0xF064, 0xF04F, 0xF03C, 0xF02C, 0xF01F, 0xF014,
0xF00B, 0xF005, 0xF001, 0xF000, 0xF001, 0xF005, 0xF00B, 0xF014, 0xF01F,
0xF02C, 0xF03C, 0xF04F, 0xF064, 0xF07B, 0xF094, 0xF0B0, 0xF0CF, 0xF0EF,
0xF112, 0xF138, 0xF15F, 0xF189, 0xF1B5, 0xF1E4, 0xF214, 0xF247, 0xF27B,
0xF2B2, 0xF2EB, 0xF326, 0xF363, 0xF3A2, 0xF3E2, 0xF425, 0xF469, 0xF4B0,
0xF4F8, 0xF541, 0xF58D, 0xF5DA, 0xF628, 0xF678, 0xF6C9, 0xF71C, 0xF771,
0xF7C6, 0xF81D, 0xF875, 0xF8CE, 0xF929, 0xF984, 0xF9E1, 0xFA3E, 0xFA9C,
0xFAFB, 0xFB5B, 0xFBBC, 0xFC1D, 0xFC7F, 0xFCE1, 0xFD44, 0xFDA7, 0xFE0B,
0xFE6F, 0xFED3, 0xFF37, 0xFF9B,
};
s32 func_80194B34(u8 arg0, s16 arg1) { return D_80180BBC[arg0] * arg1; }
s16 func_80194B60(u8 arg0) { return D_80180BBC[arg0]; }

View File

@ -228,6 +228,8 @@ void EntityPrizeDrop(Entity* self) {
#include "../blink_item.h"
u16 g_ItemIconSlots[32];
extern s32 D_80097410;
extern s32 D_80097414;
void EntityEquipItemDrop(Entity* self) {

View File

@ -2,6 +2,39 @@
#include "game.h"
#include "sfx.h"
extern u32 D_8019D424;
extern s32 D_8019D428;
// tile layout
static s16 D_8018068C[] = {
0x014A, 0x014B, 0x014E, 0x014F, 0x014C, 0x014D, 0x0150, 0x0151, 0x00F5,
0x00F6, 0x012B, 0x012C, 0x00FC, 0x00FD, 0x012F, 0x0130, 0x0101, 0x00FF,
0x0201, 0x00FF, 0x0201, 0x0307, 0x0407, 0x0507, 0x0607, 0x0707, 0x0807,
0x0907, 0x0A10, 0x00FF, 0x0A01, 0x0B06, 0x0C06, 0x0D06, 0x0E10, 0x0F0A,
0x0E0A, 0x0F0A, 0x0E20, 0x00FF, 0x0E01, 0x1004, 0x1104, 0x120B, 0x00FF,
0x0000, 0x1301, 0x00FF, 0x1201, 0x00FF, 0x1220, 0x1103, 0x1003, 0x1403,
0x1503, 0x1640, 0x1506, 0x0D05, 0x0C05, 0x0B05, 0x0A20, 0x00FF, 0x0A10,
0x1710, 0x0A08, 0x00FF, 0x0A01, 0x0B02, 0x0C02, 0x1806, 0x1906, 0x1850,
0x0C03, 0x0B03, 0x0A08, 0x00FF, 0x0A01, 0x0B03, 0x0C03, 0x0D03, 0x0E03,
0x1B06, 0x1A10, 0x1B20, 0x0E03, 0x0D03, 0x0C03, 0x00FF, 0x1C04, 0x1D04,
0x1E04, 0x1F04, 0x00FF, 0x0000, 0x2002, 0x2104, 0x2204, 0x2304, 0x2404,
0x2504, 0x2604, 0x2704, 0x2002, 0x0000, 0x2808, 0x2908, 0x2A60, 0x00FF,
0x0C01, 0x00FF,
};
static u8 D_80180768[] = {
0x08, 0x03, 0x04, 0x04, 0x04, 0x05, 0x04, 0x06, 0x04, 0x07, 0x04, 0x08,
0x04, 0x09, 0x02, 0x0A, 0x01, 0x0B, 0x10, 0x0A, 0xFF, 0x00, 0x00, 0x00,
};
static u8 D_80180780[] = {
0x04, 0x0A, 0x04, 0x09, 0x04, 0x08, 0x04, 0x07, 0x04, 0x06, 0x04, 0x05,
0x04, 0x04, 0x04, 0x03, 0x02, 0x0C, 0x04, 0x03, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01,
};
void func_8018F890(s16 arg0) {
s16 temp_v0 = arg0 - g_Tilemap.height;

View File

@ -1,35 +0,0 @@
#include <game.h>
u32 D_8019C704[24];
u32 g_LayoutObjHorizontal;
u32 g_LayoutObjVertical;
u8 g_LayoutObjPosHorizontal[4];
u8 g_LayoutObjPosVertical[3076];
u32 D_8019D374;
u32 g_Dialogue;
u16 D_8019D37C;
u16 D_8019D37E;
u16 D_8019D380;
u16 D_8019D382;
u16 D_8019D384;
u16 D_8019D386;
u16 D_8019D388;
u16 D_8019D38A;
u16 D_8019D38C;
u8 D_8019D38E;
u8 D_8019D38F;
u32 D_8019D390;
u32 D_8019D394;
u32 D_8019D398;
u32 D_8019D39C;
u32 D_8019D3A0;
u32 D_8019D3A4;
u32 D_8019D3A8;
u32 D_8019D3AC;
u32 D_8019D3B0;
u16 D_8019D3B4;
u16 D_8019D3B6;
u32 D_8019D3B8[27];
u32 D_8019D424;
u32 D_8019D428;
u16 g_ItemIconSlots[ICON_SLOT_NUM];

View File

@ -46,7 +46,7 @@ typedef enum {
void CreateEntityFromCurrentEntity(u16 entityId, Entity* entity);
void CreateEntityFromLayout(Entity*, LayoutEntity*);
extern u16 GetNormalizedAngle(u16 arg0, u16 arg1, u16 arg2);
u16 GetNormalizedAngle(u16 arg0, u16 arg1, u16 arg2);
void EntityUnkId14(Entity* entity);
void EntityUnkId15(Entity* entity);
@ -67,11 +67,6 @@ extern u8 D_8018059C[];
extern s16 D_801805A4[];
extern s8 D_801805B4[];
extern u16 D_801805BC;
extern const char* D_80180684[];
extern s16 D_8018068C[];
extern u8 D_80180768[]; // Animation
extern u8 D_80180780[]; // Animation
extern s16 D_80180BBC[];
extern u16 D_80180EEC[];
extern u16 D_80180F1C[];
extern s8 c_HeartPrizes[];
@ -80,21 +75,9 @@ extern s16 g_ESoulStealOrbSprt[];
extern u8 g_ESoulStealOrbAnim[];
extern ObjInit2 D_8018125C[];
extern u32 D_8019D424;
extern u16 g_InitializeEntityData0[];
extern Dialogue g_Dialogue;
// For EntityHolyGlassesCutscene
extern u8 D_801805DC[];
extern u16 D_801805E0[];
extern u16 D_801805E8[];
extern u16 D_801805EC[];
extern s16 D_801805F4[];
extern const char D_801813F0[];
extern u32 D_8019D424;
extern s32 D_8019D428;
extern s32 D_8019D374;
#endif

View File

@ -1 +1,10 @@
#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 "../create_entity.h"

View File

@ -235,77 +235,3 @@ u8 D_801805B4[] = {
s16 D_801805BC[] = {
-4, -4, 3, -6, 2, 9, -4, 12, 0, 2, 0, 15, 0, 31,
};
u8 D_801805D8[] = {0, 64, 0, 0};
u8 D_801805DC[] = {0, 0, 0, 0};
// clut
u16 D_801805E0[] = {
LAYER_CLUT_ALT | 0,
LAYER_CLUT_ALT | 8,
LAYER_CLUT_ALT | 16,
LAYER_CLUT_ALT | 24,
};
u16 D_801805E8[] = {0, 32};
u16 D_801805EC[] = {
0x01A1,
0x01A1,
0x01A1,
0x01A1,
};
// x-coords
u16 D_801805F4[] = {
0x08, 0x13, 0x11, 0x31, 0x4F, 0x26, 0x36, 0x1D, 0x1B, 0x33, 0x2C, 0x21,
0x19, 0x0A, 0x33, 0x1F, 0x48, 0x2F, 0x13, 0x19, 0x4D, 0x4B, 0x17, 0x1D,
0x12, 0x02, 0x1B, 0x2A, 0x50, 0x45, 0x32, 0x0D, 0x2A, 0x4D, 0x06, 0x27,
0x07, 0x48, 0x2F, 0x1B, 0x36, 0x22, 0x39, 0x14, 0x39, 0x1D, 0x0A, 0x35,
0x10, 0x1B, 0x3D, 0x17, 0x2E, 0x0B, 0x49, 0x42, 0x3D, 0x2A, 0x01, 0x0C,
0x1B, 0x34, 0x41, 0x35, 0x08, 0x0E, 0x4D, 0x11, 0x34, 0x41, 0x29, 0x48,
};
extern char D_8018D41C[];
extern char D_8018D414[];
char* D_80180684[] = {
&D_8018D41C,
&D_8018D414,
};
// tile layout
u16 D_8018068C[] = {
0x014A, 0x014B, 0x014E, 0x014F, 0x014C, 0x014D, 0x0150, 0x0151, 0x00F5,
0x00F6, 0x012B, 0x012C, 0x00FC, 0x00FD, 0x012F, 0x0130, 0x0101, 0x00FF,
0x0201, 0x00FF, 0x0201, 0x0307, 0x0407, 0x0507, 0x0607, 0x0707, 0x0807,
0x0907, 0x0A10, 0x00FF, 0x0A01, 0x0B06, 0x0C06, 0x0D06, 0x0E10, 0x0F0A,
0x0E0A, 0x0F0A, 0x0E20, 0x00FF, 0x0E01, 0x1004, 0x1104, 0x120B, 0x00FF,
0x0000, 0x1301, 0x00FF, 0x1201, 0x00FF, 0x1220, 0x1103, 0x1003, 0x1403,
0x1503, 0x1640, 0x1506, 0x0D05, 0x0C05, 0x0B05, 0x0A20, 0x00FF, 0x0A10,
0x1710, 0x0A08, 0x00FF, 0x0A01, 0x0B02, 0x0C02, 0x1806, 0x1906, 0x1850,
0x0C03, 0x0B03, 0x0A08, 0x00FF, 0x0A01, 0x0B03, 0x0C03, 0x0D03, 0x0E03,
0x1B06, 0x1A10, 0x1B20, 0x0E03, 0x0D03, 0x0C03, 0x00FF, 0x1C04, 0x1D04,
0x1E04, 0x1F04, 0x00FF, 0x0000, 0x2002, 0x2104, 0x2204, 0x2304, 0x2404,
0x2504, 0x2604, 0x2704, 0x2002, 0x0000, 0x2808, 0x2908, 0x2A60, 0x00FF,
0x0C01, 0x00FF,
};
u32 D_80180768[] = {
0x04040308, 0x06040504, 0x08040704, 0x0A020904, 0x0A100B01, 0x000000FF,
};
u32 D_80180780[] = {
0x09040A04, 0x07040804, 0x05040604, 0x03040404, 0x03040C02,
0x000000FF, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
0x00010001, 0x00010001, 0x00010001, 0x01010001,
};
// palette
u16 UNK_Invincibility0[] = {
PAL_OVL(0x163), PAL_OVL(0x164), PAL_OVL(0x166), PAL_OVL(0x164),
PAL_OVL(0x160), PAL_OVL(0x166), PAL_OVL(0x162), PAL_OVL(0x164),
PAL_OVL(0x167), PAL_OVL(0x164), PAL_OVL(0x167), PAL_OVL(0x168),
PAL_OVL(0x168), PAL_OVL(0x164), PAL_OVL(0x161), PAL_OVL(0x164),
PAL_OVL(0x165), PAL_OVL(0x165), PAL_OVL(0x163), PAL_OVL(0x163),
PAL_OVL(0x165), PAL_OVL(0x165),
};

View File

@ -4,7 +4,7 @@ extern RoomHeader OVL_EXPORT(rooms)[];
extern signed short* spriteBanks[];
extern void* Cluts[];
extern MyRoomDef rooms_layers[];
extern GfxBank gfxBanks[];
static GfxBank* gfxBanks[];
void UpdateStageEntities();
Overlay OVL_EXPORT(Overlay) = {
@ -39,3 +39,58 @@ static void* Cluts[] = {
};
#include "layers.h"
static u32 D_8019C704[24];
static GfxBank D_80180134 = {
.kind = GFX_BANK_NONE,
.entries =
{
GFX_ENTRY(0, 0, 0, 0, NULL),
},
};
static u_long D_80180134_TERM = GFX_TERMINATE();
extern u_long* D_80183A40;
extern u_long* D_80184B70;
static GfxBank D_80180148 = {
.kind = GFX_BANK_COMPRESSED,
.entries =
{
GFX_ENTRY(0x100, 0x80, 0x80, 0x80, &D_80183A40),
GFX_ENTRY(0x100, 0xA0, 0x80, 0x80, &D_80184B70),
},
};
static u_long D_80180148_TERM = GFX_TERMINATE();
extern u_long* D_80181658;
extern u_long* D_8018199C;
static GfxBank D_80180168 = {
.kind = GFX_BANK_COMPRESSED,
.entries =
{
GFX_ENTRY(0x100, 0x0040, 0x0080, 0x0080, &D_80181658),
GFX_ENTRY(0x100, 0x60, 0x80, 0x80, &D_8018199C),
},
};
static u_long D_80180168_TERM = GFX_TERMINATE();
extern u_long* D_80185830;
static GfxBank D_80180188 = {
.kind = GFX_BANK_COMPRESSED,
.entries =
{
GFX_ENTRY(0x100, 0x80, 0x80, 0x80, &D_80185830),
},
};
static u_long D_80180188_TERM = GFX_TERMINATE();
static GfxBank* gfxBanks[] = {
&D_80180134, &D_80180148, &D_80180188, &D_80180134, &D_80180134,
&D_80180168, &D_80180134, &D_80180134, &D_80180134, &D_80180134,
&D_80180134, &D_80180134, &D_80180134, &D_80180134, &D_80180134,
&D_80180134, &D_80180134, &D_80180134, &D_80180134, &D_80180134,
};

View File

@ -1,8 +1,49 @@
#include "cen.h"
#include "game.h"
static u8 __unused[0xC00];
static s32 D_8019D374;
static Dialogue g_Dialogue;
static u32 __unused0[26];
u32 D_8019D424;
u32 D_8019D428;
// Bizarre variable - u8 here, but u16 in EntityHeartDrop
extern u8 D_801805D8[];
u8 D_801805D8[] = {0, 64, 0, 0};
static u8 D_801805DC[] = {0, 0, 0, 0};
// clut
static u16 D_801805E0[] = {
LAYER_CLUT_ALT | 0,
LAYER_CLUT_ALT | 8,
LAYER_CLUT_ALT | 16,
LAYER_CLUT_ALT | 24,
};
static u16 D_801805E8[] = {0, 32};
static u16 D_801805EC[] = {
0x01A1,
0x01A1,
0x01A1,
0x01A1,
};
// x-coords
static s16 D_801805F4[] = {
0x08, 0x13, 0x11, 0x31, 0x4F, 0x26, 0x36, 0x1D, 0x1B, 0x33, 0x2C, 0x21,
0x19, 0x0A, 0x33, 0x1F, 0x48, 0x2F, 0x13, 0x19, 0x4D, 0x4B, 0x17, 0x1D,
0x12, 0x02, 0x1B, 0x2A, 0x50, 0x45, 0x32, 0x0D, 0x2A, 0x4D, 0x06, 0x27,
0x07, 0x48, 0x2F, 0x1B, 0x36, 0x22, 0x39, 0x14, 0x39, 0x1D, 0x0A, 0x35,
0x10, 0x1B, 0x3D, 0x17, 0x2E, 0x0B, 0x49, 0x42, 0x3D, 0x2A, 0x01, 0x0C,
0x1B, 0x34, 0x41, 0x35, 0x08, 0x0E, 0x4D, 0x11, 0x34, 0x41, 0x29, 0x48,
};
static char* D_80180684[] = {
_S("Alucard"),
_S("Maria"),
};
static const char _pad[4] = "";
void func_8018DF0C(void) {
g_Dialogue.nextLineX = 2;

View File

@ -1 +1,13 @@
#include <game.h>
// palette
u16 UNK_Invincibility0[] = {
PAL_OVL(0x163), PAL_OVL(0x164), PAL_OVL(0x166), PAL_OVL(0x164),
PAL_OVL(0x160), PAL_OVL(0x166), PAL_OVL(0x162), PAL_OVL(0x164),
PAL_OVL(0x167), PAL_OVL(0x164), PAL_OVL(0x167), PAL_OVL(0x168),
PAL_OVL(0x168), PAL_OVL(0x164), PAL_OVL(0x161), PAL_OVL(0x164),
PAL_OVL(0x165), PAL_OVL(0x165), PAL_OVL(0x163), PAL_OVL(0x163),
PAL_OVL(0x165), PAL_OVL(0x165),
};
#include "../update.h"