improve data file names, move sprite tables definition into C, improve sprite table type

This commit is contained in:
Oliver Bell committed 2024-04-19 13:19:33 +01:00
1 parent 09b467f0bf
commit 86d632cf01
25 files changed
+102 -135

No files matched your search

+8 -8
View File
@@ -288,27 +288,27 @@ $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s
europe: ; @$(MAKE) GAME_REGION=EUROPE
chao_garden/mb_chao_garden.gba:
$(MAKE) -C chao_garden
@$(MAKE) -C chao_garden
chao_garden: tools
$(MAKE) -C chao_garden
@$(MAKE) -C chao_garden
# Dependency here is already explicit, but we sometimes get a race condition if this
# is not specified
multi_boot/subgame_bootstrap/subgame_bootstrap.gba: multi_boot/programs/subgame_loader/subgame_loader.bin
$(MAKE) -C multi_boot/subgame_bootstrap
@$(MAKE) -C multi_boot/subgame_bootstrap
multi_boot/programs/subgame_loader/subgame_loader.bin:
$(MAKE) -C multi_boot/programs/subgame_loader
@$(MAKE) -C multi_boot/programs/subgame_loader
multi_boot/collect_rings/mb_signed_collect_rings.gba:
$(MAKE) -C multi_boot/collect_rings
@$(MAKE) -C multi_boot/collect_rings
subgame_bootstrap: tools
$(MAKE) -C multi_boot/subgame_bootstrap
@$(MAKE) -C multi_boot/subgame_bootstrap
subgame_loader: tools
$(MAKE) -C multi_boot/programs/subgame_loader
@$(MAKE) -C multi_boot/programs/subgame_loader
collect_rings: tools
$(MAKE) -C multi_boot/collect_rings
@$(MAKE) -C multi_boot/collect_rings
-56
View File
@@ -1,56 +0,0 @@
.include "constants/constants.inc"
.include "asm/macros.inc"
.section .rodata
@ TODO: Include as much data in C files as possible
@ NOTE: Sometimes in the codebase, there is pointers to inside the tileset data.
@ Set these pointers to:
@ (<Beginning_of_Tileset> + (tile_count * TILE_SIZE_4BPP))
@ NOTE: For some reason each level (except for the dummies) has a different tileset, even those that are visually identical.
@ Palettes are also stored as copies of each level.
@ We will just include the same file in those instances, unless there is actually a difference of course.
@ It is something to keep in mind in case one wants to port the game to other platforms down the line.
@ MapHeaders, not part of the file itself (starting @ 0x080D5CE4)
@ 0x08714530 0x08714554 0x08935224 @ Leaf Forest Act 1
@ 0x0873A3CC 0x0873A3F0 0x08935224 @ Leaf Forest Act 2
@ 0x0873C0B4 0x0873C0D8 0x08935224 @ Leaf Forest Boss
@ 0x0873CC44 0x0873CC68 0x0894E04C @ Dummy
@ 0x08763A34 0x08763A58 0x0894158C @ Hot Crater Act 1
@ 0x0878FE50 0x0878FE74 0x0894158C @ Hot Crater Act 2
@ 0x08792730 0x08792754 0x0894158C @ Hot Crater Boss
@ 0x0873CC44 0x0873CC68 0x08935224 @ Dummy
@ 0x087B8E14 0x087B8E38 0x0893805C @ Music Plant Act 1
@ 0x087DB730 0x087DB754 0x0893805C @ Music Plant Act 2
@ 0x087DCB1C 0x087DCB40 0x0893805C @ Music Plant Boss
@ 0x0873CC44 0x0873CC68 0x0893805C @ Dummy
@ 0x0880C528 0x0880C54C 0x0893BBF4 @ Ice Paradise Act 1
@ 0x088343E4 0x08834408 0x0893BBF4 @ Ice Paradise Act 2
@ 0x08835D70 0x08835D94 0x0893BBF4 @ Ice Paradise Boss
@ 0x0873CC44 0x0873CC68 0x0893BBF4 @ Dummy
@ 0x0885DB08 0x0885DB2C 0x08944B84 @ Sky Canyon Act 1
@ 0x08885A48 0x08885A6C 0x08944B84 @ Sky Canyon Act 2
@ 0x0888768C 0x088876B0 0x08944B84 @ Sky Canyon Boss
@ 0x0873CC44 0x0873CC68 0x08944B84 @ Dummy
@ 0x088A9128 0x088A914C 0x08949418 @ Techno Base Act 1
@ 0x088C2630 0x088C2654 0x08949418 @ Techno Base Act 2
@ 0x088C56B8 0x088C56DC 0x08949418 @ Techno Base Boss
@ 0x0873CC44 0x0873CC68 0x08949418 @ Dummy
@ 0x088F7D64 0x088F7D88 0x08947EFC @ Egg Utopia Act 1
@ 0x08924E14 0x08924E38 0x08947EFC @ Egg Utopia Act 2
@ 0x08925C84 0x08925CA8 0x08947EFC @ Egg Utopia Boss
@ 0x0873CC44 0x0873CC68 0x08947EFC @ Dummy
@ 0x0892ECE0 0x0892ED04 0x0894E04C @ Final Zone - XX
@ 0x0892F4D4 0x0892F4F8 0x08950508 @ True Area 53
@ 0x08933538 0x0893355C 0x089520C4 @ Leftover - w/out tileset
@.incbin "baserom.gba", 0x0073C120, (0x00958E00-0x0073C120)
@ >> 0x08958E00
@@ -1,10 +1,6 @@
.section .rodata
.align 2
.global gUnknown_08C882C8
gUnknown_08C882C8:
.incbin "baserom.gba", 0x00C882C8, 0x140 ;@ Unused but no idea what this is
;@ collect_rings tilemaps
.global gCollectRingsTilemaps
gCollectRingsTilemaps:
@@ -14,7 +10,7 @@ gCollectRingsTilemaps:
;@ obj_vram
.global gCollectRingsTextTiles
gCollectRingsTextTiles:
.incbin "multi_boot/collect_rings/graphics/obj_tiles/4bpp/text.4bpp" ;@ This is potentially 0x1B10 instead of 0x1E00
.incbin "multi_boot/roms/collect_rings/graphics/obj_tiles/4bpp/text.4bpp" ;@ This is potentially 0x1B10 instead of 0x1E00
;@ if the above is 0x1B10 then the below would be:
;@ 0x8C91f18 -> 0x8C92208 = 0x2f0 potentially some pointers/rodata, not sure
@@ -22,12 +18,14 @@ gCollectRingsTextTiles:
;@ bg map tileset
.global gCollectRingsBgStageTileset
gCollectRingsBgStageTileset:
.incbin "multi_boot/collect_rings/data/tilemaps/stage_tiles.4bpp"
.incbin "multi_boot/roms/collect_rings/data/tilemaps/stage_tiles.4bpp"
;@ these might all include the animation scripts
;@ compressed obj tiles
.global gCollectRingsAnimationTiles_Compressed
gCollectRingsAnimationTiles_Compressed:
.incbin "multi_boot/collect_rings/graphics/obj_tiles/4bpp/animations.4bpp.lz"
.incbin "multi_boot/roms/collect_rings/graphics/obj_tiles/4bpp/animations.4bpp.lz"
;@ compressed obj tiles
.global gCollectRings_ObjTiles_1
@@ -1,5 +1,6 @@
.section .rodata
@ TODO: move these into C files in src/data?
.global gSpritePalettes @ 0x0816ADC8
gSpritePalettes:
.include "graphics/obj_palettes.inc"
+7
View File
@@ -0,0 +1,7 @@
.section .rodata
@ TODO: How can we represent these in C files?
.include "data/animations/animations.inc"
.include "data/animations/animations_table.inc"
-13
View File
@@ -1,13 +0,0 @@
.section .rodata
.global gSpriteTables
gSpriteTables: @ 0x080F40D4
.4byte gAnimations
.4byte gSpriteDimensions
.4byte gSpriteOamData
.4byte gSpritePalettes
.4byte gObjTiles_4bpp
.4byte gObjTiles_8bpp @ 8bpp UNUSED - Read comment below at gObjTiles_8bpp
.include "data/animations/animations.inc"
.include "data/animations/animations_table.inc"
+8 -8
View File
@@ -7,19 +7,19 @@
#define NUM_SPRITE_ANIMATIONS 1133
extern s32 **const gAnimations[NUM_SPRITE_ANIMATIONS];
extern const ACmd **const gAnimations[NUM_SPRITE_ANIMATIONS];
extern const SpriteOffset *const gSpriteDimensions[NUM_SPRITE_ANIMATIONS];
extern const OamDataShort *const gSpriteOamData[NUM_SPRITE_ANIMATIONS];
extern const u16 gSpritePalettes[];
struct SpriteTables {
/* 0x00 */ ACmd ***animations;
/* 0x04 */ SpriteOffset **dimensions;
/* 0x08 */ u16 **oamData;
/* 0x0C */ u16 *palettes;
/* 0x10 */ u8 *tiles_4bpp;
/* 0x14 */ u8 *tiles_8bpp;
/* 0x00 */ const ACmd **const *animations;
/* 0x04 */ const SpriteOffset *const *dimensions;
/* 0x08 */ const u16 **const oamData;
/* 0x0C */ const u16 *const palettes;
/* 0x10 */ const u8 *const tiles_4bpp;
/* 0x14 */ const u8 *const tiles_8bpp;
};
extern const struct SpriteTables *gUnknown_03002794;
#endif
#endif
+1 -1
View File
@@ -130,7 +130,7 @@ typedef struct {
typedef struct {
/* 0x00 */ struct GraphicsData graphics;
/* 0x0C */ SpriteOffset *dimensions;
/* 0x0C */ const SpriteOffset *dimensions;
// Bitfield description from KATAM decomp
/* 0x10 */ u32 unk10; // bit 0-4: affine-index / rotscale param selection
+7 -5
View File
@@ -524,12 +524,14 @@ SECTIONS
build/sa2/src/game/cutscenes/missing_emeralds.o(.rodata);
build/sa2/src/data/tilemap_data_old_logos.o(.rodata);
build/sa2/data/sprite_data.o(.rodata);
build/sa2/src/data/sprite_tables.o(.rodata);
build/sa2/data/sprite_animation_scripts.o(.rodata);
build/sa2/src/data/sprite_dimensions.o(.rodata);
build/sa2/src/data/oam_data.o(.rodata);
build/sa2/data/sprite_data_2.o(.rodata);
build/sa2/src/data/sprite_oam_data.o(.rodata);
build/sa2/data/sprite_animation_data.o(.rodata);
build/sa2/src/data/tileset_language.o(.rodata);
build/sa2/data/map_data.o(.rodata);
build/sa2/src/data/tilemap_data.o(.rodata);
build/sa2/src/lib/m4a_tables.o(.rodata);
@@ -808,7 +810,7 @@ SECTIONS
build/sa2/data/handlers_ia_pipe_horn_sequences.o(.rodata);
build/sa2/src/data/palettes.o(.rodata);
build/sa2/src/data/recordings.o(.rodata);
build/sa2/data/data4.o(.rodata);
build/sa2/data/multiboot_collect_rings.o(.rodata);
build/sa2/data/multiboot_subgame_loader.o(.rodata);
build/sa2/asm/rom_footer.o(.rodata);
+2 -2
View File
@@ -36,8 +36,8 @@ with open('baserom.gba', 'rb') as rom:
# print(f"{read_s16(rom)}, ")
for i in range(length // 32):
print("{ ", end="")
for j in range(16):
print(f"{hex(read_u16(rom))}" + ", ", end="")
for j in range(32):
print(f"{(read_u8(rom))}" + ", ", end="")
print("},")
# print("{ ", end="")
+9 -8
View File
@@ -96,19 +96,20 @@ s32 sub_80036E0(Sprite *s)
s->timeUntilNextFrame -= s->animSpeed * 16;
else {
s32 ret;
ACmd *cmd;
ACmd *script;
ACmd **variants;
const ACmd *cmd;
const ACmd *script;
const ACmd **variants;
// Handle all the "regular" Animation commands with an ID < 0
variants = gUnknown_03002794->animations[s->graphics.anim];
script = variants[s->variant];
cmd = ReadInstruction(script, s->animCursor);
while (cmd->id < 0) {
ret = animCmdTable_BG[~cmd->id](cmd, s);
// TODO: Fix types to make these const
ret = animCmdTable_BG[~cmd->id]((void *)cmd, s);
if (ret != 1) {
#ifndef NON_MATCHING
register ACmd *newScript asm("r1");
register const ACmd *newScript asm("r1");
#else
ACmd *newScript;
#endif
@@ -201,7 +202,7 @@ s32 animCmd_AddHitbox_BG(void *cursor, Sprite *s)
void sub_8003914(Sprite *s)
{
SpriteOffset *dims;
const SpriteOffset *dims;
gUnknown_03004D10[gUnknown_03005390] = s;
gUnknown_03005390++;
@@ -259,9 +260,9 @@ NONMATCH("asm/non_matching/engine/sub_80039E4.inc", bool32 sub_80039E4(void))
s32 sp08;
u16 shapeAndSize;
Sprite *s; // = sp0C
SpriteOffset *dims;
const SpriteOffset *dims;
u32 sp10; // bg_affine_pixelcount
u16 **oamSub;
const u16 *const *oamSub;
OamDataShort *sp1C;
u32 tilesX; // =sp20
u32 tilesY; // =ip
+15
View File
@@ -17,3 +17,18 @@ static const u8 demo1[] = INCBIN_U8("data/recordings/demo_1.bin.lz");
static const u8 demo2[] = INCBIN_U8("data/recordings/demo_2.bin.lz");
static const u8 demo3[] = INCBIN_U8("data/recordings/demo_3.bin.lz");
static const u8 demo4[] = INCBIN_U8("data/recordings/demo_4.bin.lz");
// Unused - not sure what this data represent
static const u8 gUnknown_08C882C8[][32] = {
{ 120, 120, 132, 108, 120, 120, 132, 108, 120, 120, 132, 108, 120, 120, 132, 108, 120, 120, 131, 109, 120, 120, 131, 109, 120, 120, 131, 109, 120, 120, 131, 109 },
{ 120, 120, 131, 109, 135, 105, 139, 101, 142, 98, 144, 96, 147, 93, 149, 91, 150, 90, 152, 88, 154, 86, 155, 85, 157, 83, 158, 82, 159, 81, 161, 79 },
{ 162, 78, 163, 77, 164, 76, 165, 75, 166, 74, 167, 73, 168, 72, 169, 71, 169, 71, 170, 70, 171, 69, 172, 68, 172, 68, 173, 67, 174, 66, 174, 66 },
{ 175, 65, 175, 65, 176, 64, 177, 63, 177, 63, 178, 62, 178, 62, 178, 62, 179, 61, 179, 61, 180, 60, 180, 60, 180, 60, 181, 59, 181, 59, 181, 59 },
{ 181, 59, 182, 58, 182, 58, 182, 58, 182, 58, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57 },
{ 184, 56, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 183, 57, 182, 58, 182, 58, 182, 58, 182, 58 },
{ 181, 59, 181, 59, 181, 59, 181, 59, 180, 60, 180, 60, 180, 60, 179, 61, 179, 61, 178, 62, 178, 62, 178, 62, 177, 63, 177, 63, 176, 64, 175, 65 },
{ 175, 65, 174, 66, 174, 66, 173, 67, 172, 68, 172, 68, 171, 69, 170, 70, 169, 71, 169, 71, 168, 72, 167, 73, 166, 74, 165, 75, 164, 76, 163, 77 },
{ 162, 78, 161, 79, 159, 81, 158, 82, 157, 83, 155, 85, 154, 86, 152, 88, 150, 90, 149, 91, 147, 93, 144, 96, 142, 98, 139, 101, 135, 105, 131, 109 },
{ 136, 104, 131, 109, 136, 104, 131, 109, 136, 104, 131, 109, 136, 104, 131, 109, 137, 103, 132, 108, 137, 103, 132, 108, 137, 103, 132, 108, 137, 103, 132, 108 },
};
File renamed without changes.
+13
View File
@@ -0,0 +1,13 @@
#include "data/sprite_data.h"
extern const u8 gObjTiles_4bpp[];
extern const u8 gObjTiles_8bpp[];
const struct SpriteTables gSpriteTables = {
gAnimations,
gSpriteDimensions,
(const u16**const)gSpriteOamData,
gSpritePalettes,
gObjTiles_4bpp,
gObjTiles_8bpp
};
+1 -1
View File
@@ -162,7 +162,7 @@ void TaskDestructor_8015B50(struct Task *);
static inline void sub_8015B64_inline(AnimId anim, u16 palId)
{
s32 *pAnim = *gAnimations[anim];
const s32 *pAnim = (const s32 *)*gAnimations[anim];
if (*pAnim++ == ANIM_CMD__GET_PALETTE) {
u32 animPalId;
+2 -4
View File
@@ -44,8 +44,6 @@ extern u32 gCheckpointTime;
extern const struct SpriteTables *gUnknown_03002794;
extern const u32 gUnknown_080D63FC[34][2];
extern s32 **const gAnimations[];
#define CHECKPOINT_BALL_TILE_COUNT 4
/* [0] = animId
@@ -205,8 +203,8 @@ void Task_8063228(struct Task *unused)
{
u8 zone = LEVEL_TO_ZONE(gCurrentLevel);
s32 animId = sAnimIdsCheckpoint[zone][0];
s32 **anim = gAnimations[animId];
s32 *cmd = anim[0];
const ACmd **anim = gAnimations[animId];
const s32 *cmd = (const s32 *)anim[0];
u32 palId;
u32 numColors;
u32 offset;
@@ -171,8 +171,8 @@ void Task_805E480(void)
s16 screenX, screenY;
s16 otherPos;
u8 r6, x, y;
u16 *oam_ptr;
u16 *oam;
const u16 *oam_ptr;
const u16 *oam;
screenX = TO_WORLD_POS(platform->base.spriteX, platform->base.regionX);
screenY = TO_WORLD_POS(me->y, platform->base.regionY);
@@ -259,8 +259,8 @@ void Task_805E6A4(void)
s16 screenX, screenY;
s16 otherPos;
u8 r6, x, y;
u16 *oam_ptr;
u16 *oam;
const u16 *oam_ptr;
const u16 *oam;
screenX = TO_WORLD_POS(platform->base.spriteX, platform->base.regionX);
screenY = TO_WORLD_POS(me->y, platform->base.regionY);
+2 -2
View File
@@ -136,7 +136,7 @@ bool16 sub_806CB84(struct UNK_806CB84 *a,
void sub_806CD68(Sprite *s)
{
u16 *reference;
const u16 *reference;
OamData *oam;
u32 unk16, unk18;
u16 sprHeight;
@@ -144,7 +144,7 @@ void sub_806CD68(Sprite *s)
s16 numSubframes;
s16 i;
SpriteOffset *sprDims = (void *)s->dimensions;
const SpriteOffset *sprDims = s->dimensions;
s->numSubFrames = sprDims->numSubframes;
sprWidth = sprDims->width;
+8 -8
View File
@@ -73,7 +73,7 @@ NONMATCH("asm/non_matching/game/sub_8011328.inc", void sub_8011328(void))
{
s32 k;
u16 animId;
s32 **animation;
const ACmd **animation;
s32 pal;
u32 *dst, *src;
u32 waterMask;
@@ -97,7 +97,7 @@ NONMATCH("asm/non_matching/game/sub_8011328.inc", void sub_8011328(void))
u16 mpChar = gMultiplayerCharacters[j];
animId = gUnknown_080D550C[mpChar];
animation = gAnimations[animId];
pal = (animation[0])[1];
pal = animation[0]->pal.palId;
src = (u32 *)&gSpritePalettes[pal * 16];
dst = (u32 *)&wd->pal[j * 16];
sub_8011B54_inline(dst, src, 1, 0);
@@ -106,23 +106,23 @@ NONMATCH("asm/non_matching/game/sub_8011328.inc", void sub_8011328(void))
u16 playerChar = gPlayer.character;
animId = gUnknown_080D550C[playerChar];
animation = (s32 **)gAnimations[animId];
pal = ((animation[0])[1]);
animation = gAnimations[animId];
pal = animation[0]->pal.palId;
sub_8011B54_inline((u32 *)&wd->pal[0 * 16], (u32 *)&gSpritePalettes[pal * 16], 1,
0);
playerChar = gPlayer.character;
animId = sCharacterPalettesBoostEffect[playerChar];
animation = (s32 **)gAnimations[animId];
pal = ((animation[0])[1] + 0) * 16;
animation = gAnimations[animId];
pal = (animation[0]->pal.palId + 0) * 16;
dst = (u32 *)&wd->pal[1 * 16];
src = (u32 *)&gSpritePalettes[pal];
sub_8011B54_inline(dst, src, 1, 0);
}
animId = SA2_ANIM_PALETTE_554;
animation = (s32 **)gAnimations[animId];
pal = ((animation[0])[1] + 4) * 16;
animation = gAnimations[animId];
pal = (animation[0]->pal.palId + 4) * 16;
dst = (u32 *)&wd->pal[4 * 16];
src = (u32 *)&gSpritePalettes[(pal)];
sub_8011B54_inline(dst, src, 12, 0);
+1 -1
View File
@@ -146,7 +146,7 @@ NONMATCH("asm/non_matching/game/stage/Task_RingsMgrMain.inc",
void *rings = rm->rings; // sp14
s32 *rings_header;
Sprite *s; // sp18
SpriteOffset *dimensions; // sp20
const SpriteOffset *dimensions; // sp20
u16 sl; // sl / sp40
u16 sb;
+7 -6
View File
@@ -126,19 +126,20 @@ s32 UpdateSpriteAnimation(Sprite *s)
else {
/* Call all commands for the new frame */
s32 ret;
ACmd *cmd;
ACmd *script;
ACmd **variants;
const ACmd *cmd;
const ACmd *script;
const ACmd **variants;
// Handle all the "regular" Animation commands with an ID < 0
variants = gUnknown_03002794->animations[s->graphics.anim];
script = variants[s->variant];
cmd = ReadInstruction(script, s->animCursor);
while (cmd->id < 0) {
ret = animCmdTable[~cmd->id](cmd, s);
// TODO: make this const void*
ret = animCmdTable[~cmd->id]((void *)cmd, s);
if (ret != 1) {
#ifndef NON_MATCHING
register ACmd *newScript asm("r2");
register const ACmd *newScript asm("r2");
#else
ACmd *newScript;
#endif
@@ -251,7 +252,7 @@ NONMATCH("asm/non_matching/engine/sub_8004860.inc",
void sub_8004860(Sprite *s, SpriteTransform *transform))
{
// sp24 = s
SpriteOffset *dimensions = s->dimensions;
const SpriteOffset *dimensions = s->dimensions;
u16 sp00[8];
+1 -1
View File
@@ -34,7 +34,7 @@ void DisplaySprite(Sprite *sprite)
const u16 *oamData;
if ((u32)sprite->dimensions != -1) {
SpriteOffset *sprDims = sprite->dimensions;
const SpriteOffset *sprDims = sprite->dimensions;
sprite->numSubFrames = sprDims->numSubframes;
x = sprite->x;