Skip to content

Commit

Permalink
Merge pull request #348 from DizzyEggg/monster_archieve
Browse files Browse the repository at this point in the history
Move main gMonsterFileArchive array to C
  • Loading branch information
SethBarberee authored Feb 27, 2025
2 parents e890892 + 23390ee commit 2e7ba57
Show file tree
Hide file tree
Showing 15 changed files with 2,459 additions and 3,937 deletions.
5,330 changes: 1,419 additions & 3,911 deletions data/monster_sbin.s

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions include/decompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
u32 DecompressAT(u8 *result, s32 resultLength, const u8 *compressedData);
u32 DecompressATFile(u8 *result, s32 resultLength, OpenedFile *file);
u32 DecompressATGlobalFile(u32 *result, s32 resultLength, OpenedFile *file);
u8 *GetSiroPtr(OpenedFile *openedFile);
const u8 *GetSiroPtr(OpenedFile *openedFile);
void nullsub_16(void);

bool8 sub_800B2D4(char *, char *, s32 length);

#endif // GUARD_DECOMPRESS_H
#endif // GUARD_DECOMPRESS_H
12 changes: 7 additions & 5 deletions include/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
typedef struct File
{
/* 0x0 */ char *name;
/* 0x4 */ u8 *data;
/* 0x4 */ const u8 *data;
} File;

// size: 0x8
typedef struct OpenedFile
{
/* 0x0 */ File *file;
/* 0x4 */ u8 *data;
/* 0x0 */ const File *file;
/* 0x4 */ const u8 *data;
} OpenedFile;

// size: 0x10
typedef struct FileArchive
{
/* 0x0 */ char magic[8];
/* 0x8 */ s32 count;
/* 0xC */ File *entries;
/* 0xC */ const File *entries;
} FileArchive;

// size: 0x8
Expand All @@ -39,11 +39,13 @@ typedef struct UnkFileStruct

OpenedFile *Call_OpenFileAndGetFileDataPtr(const u8 *filename, const FileArchive *arc);
void CloseFile(OpenedFile *openedFile);
u8 *GetFileDataPtr(OpenedFile *openedFile, s32 unused);
const u8 *GetFileDataPtr(OpenedFile *openedFile, s32 unused);
void InitFileSystem(void);
OpenedFile *OpenFile(const u8 *filename, const FileArchive *arc);
OpenedFile *OpenFileAndGetFileDataPtr(const u8 *filename, const FileArchive *arc);

u32 sub_800A8F8(u32 value);

extern const FileArchive gMonsterFileArchive; // monster_sbin.c

#endif //GUARD_FILE_SYSTEM_H
4 changes: 2 additions & 2 deletions include/luminous_cave.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ typedef struct LuminousCaveWork
MenuStruct unk84;
u8 fillD4[0x104 - 0xD4];
OpenedFile *unk104;
u8 *unk108;
const u8 *unk108;
u16 unk10C;
u16 unk10E;
u8 unk110;
Expand All @@ -42,4 +42,4 @@ bool8 HasEvolutionCompleted(void);
u32 sub_802465C(void);
u32 sub_80246F0(void);

#endif // GUARD_LUMINOUS_CAVE_H
#endif // GUARD_LUMINOUS_CAVE_H
3 changes: 2 additions & 1 deletion include/string_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ struct PortraitGfxSub

struct PortraitGfx
{
struct PortraitGfxSub sprites[10];
// NOTE: The actual number of sprites is different depending on pokemon. For example, starters have 12 sprites, while most legendaries only 1. [0] means that any number of sprites is valid.
struct PortraitGfxSub sprites[0];
};

struct MonPortraitMsg
Expand Down
1 change: 1 addition & 0 deletions ld_script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ SECTIONS {
monster_sbin_section 0x8510000 :
ALIGN(4)
{
src/monster_sbin.o(.rodata);
data/monster_sbin.o(.rodata);
} > ROM =0

Expand Down
1 change: 0 additions & 1 deletion src/code_805D8C8.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "text.h"

// monster_sbin.s
extern const struct FileArchive gMonsterFileArchive;
// data_8106A4C.s
extern const u8 gUnknown_8106EA0[]; // ax%03d
extern const u8 gUnknown_8106E98[]; // palet
Expand Down
2 changes: 1 addition & 1 deletion src/code_8099360.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern u8 gUnknown_20398B8;

extern void sub_8003600(void);

extern s32 sub_800388C(u16, u8 *, u8);
extern s32 sub_800388C(u16, const u8 *, u8);

extern void sub_80A4B38(void);
extern void sub_80A4B54(void);
Expand Down
6 changes: 3 additions & 3 deletions src/decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ static void DecompressAT_Finish(void);
static char DecompressAT_GetByte(s32);
static void DecompressAT_Init(u32 *);
static u32 DecompressATGlobal(u32 *, s32, const char *);
static void NDS_DecompressRLE(void *);
static void NDS_DecompressRLE(const void *);

u8 *GetSiroPtr(OpenedFile *openedFile)
const u8 *GetSiroPtr(OpenedFile *openedFile)
{
struct SiroArchive *siro = (struct SiroArchive *)openedFile->data;

Expand All @@ -42,7 +42,7 @@ UNUSED static void *UnusedGetSir0Ptr(struct SiroArchive *siro)
return siro->data;
}

static void NDS_DecompressRLE(void *unused)
static void NDS_DecompressRLE(const void *unused)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/file_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ OpenedFile *OpenFile(const u8 *filename, const FileArchive *arc)
s32 i;
u32 magic = 0;
bool32 magicFound;
File *entries;
File *file;
const File *entries;
const File *file;

magic = strcmp(arc->magic, gUnknown_80B9B94) != 0;

Expand Down Expand Up @@ -109,13 +109,13 @@ OpenedFile *OpenFile(const u8 *filename, const FileArchive *arc)
return NULL;
}

static u8 *_GetFileDataPtr(OpenedFile *openedFile)
static const u8 *_GetFileDataPtr(OpenedFile *openedFile)
{
openedFile->data = openedFile->file->data;
return openedFile->data;
}

u8 *GetFileDataPtr(OpenedFile *openedFile, s32 unused)
const u8 *GetFileDataPtr(OpenedFile *openedFile, s32 unused)
{
_GetFileDataPtr(openedFile);
return GetSiroPtr(openedFile);
Expand Down
1 change: 0 additions & 1 deletion src/friend_areas_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ EWRAM_DATA static u8 sCurrDirection = 0;
EWRAM_DATA static u8 sHeldDpadCounter = 0;

extern const FileArchive gTitleMenuFileArchive;
extern const FileArchive gMonsterFileArchive;

static void MoveToNewLocation(s32 destLocationId, s32 direction, s32 nFrames);
static u8 GetChosenDirection(void);
Expand Down
1 change: 0 additions & 1 deletion src/friend_areas_map_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ extern void xxx_call_update_bg_sound_input(void);
extern s32 sprintf(char *, const char *, ...);

extern const FileArchive gTitleMenuFileArchive;
extern const FileArchive gMonsterFileArchive;

static inline bool8 CheckAxFlag8000(axdata *ptr)
{
Expand Down
7 changes: 3 additions & 4 deletions src/ground_sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ EWRAM_INIT OpenedFile *gUnknown_203B4B4 = {NULL};
// dungeon_sbin.s
extern const struct FileArchive gDungeonFileArchive;
// monster_sbin.s
extern const struct FileArchive gMonsterFileArchive;
// ornament_sbin.s
extern const struct FileArchive gOrnamentFileArchive;
// data_8115F5C.s
Expand All @@ -35,7 +34,7 @@ extern const u8 gUnknown_81177EC[];
extern const u8 *gUnknown_81178F4[];

// code_8098BDC.s
extern void sub_809971C(u16, u8 *, s16);
extern void sub_809971C(u16, const u8 *, s16);
extern void sub_80997F4(u16, u16);
// pokemon_2.s
extern void InitShadowSprites(u32, u32);
Expand Down Expand Up @@ -119,7 +118,7 @@ void sub_80A6460(void)
{
OpenedFile *file;
s32 i;
u8 *data;
const u8 *data;
u16 something;

file = OpenFileAndGetFileDataPtr(gUnknown_81177EC, &gMonsterFileArchive);
Expand All @@ -138,7 +137,7 @@ void sub_80A6460(void)

void sub_80A64A4(void)
{
u8 *r2;
const u8 *r2;
u16 r4;
u32 r5;
OpenedFile *file;
Expand Down
Loading

0 comments on commit 2e7ba57

Please sign in to comment.