diff --git a/asm/code_803D110.s b/asm/code_803D110.s index e081c6be1..c89b8b4ae 100644 --- a/asm/code_803D110.s +++ b/asm/code_803D110.s @@ -250,5 +250,5 @@ _0803E458: .4byte gDungeon _0803E45C: .4byte 0x00018217 _0803E460: .4byte 0x00018218 _0803E464: .4byte gDungeonBrightness -_0803E468: .4byte gUnknown_202D058 +_0803E468: .4byte gFontPalette + 0x20 thumb_func_end sub_803E250 diff --git a/asm/code_8040094.s b/asm/code_8040094.s index b728bf652..48176725e 100644 --- a/asm/code_8040094.s +++ b/asm/code_8040094.s @@ -150,7 +150,7 @@ _08040256: .align 2, 0 _0804026C: .4byte gUnknown_202EE04 _08040270: .4byte gUnknown_202EE01 -_08040274: .4byte gUnknown_202D03C +_08040274: .4byte gFontPalette + 0x4 _08040278: adds r5, r6, 0 adds r5, 0xE0 diff --git a/asm/code_8099360.s b/asm/code_8099360.s index 3b4fdac75..5acfafb4a 100644 --- a/asm/code_8099360.s +++ b/asm/code_8099360.s @@ -31,12 +31,12 @@ sub_8099690: _080996BC: .4byte gUnknown_8116028 _080996C0: .4byte gSystemFileArchive _080996C4: .4byte gGameOptionsRef -_080996C8: .4byte gFontPaletteAlt +_080996C8: .4byte gFontPalette + 0x40 _080996CC: ldr r4, _080996D0 b _080996D6 .align 2, 0 -_080996D0: .4byte gUnknown_202D1B8 +_080996D0: .4byte gFontPalette + 0x180 _080996D4: ldr r4, _08099704 _080996D6: @@ -61,7 +61,7 @@ _080996E4: pop {r0} bx r0 .align 2, 0 -_08099704: .4byte gUnknown_202D1F8 +_08099704: .4byte gFontPalette + 0x1C0 thumb_func_end sub_8099690 thumb_func_start sub_8099708 diff --git a/include/code_8009804.h b/include/code_8009804.h index 4441c6abb..b388eb0ee 100644 --- a/include/code_8009804.h +++ b/include/code_8009804.h @@ -3,6 +3,8 @@ #include "structs/rgb.h" +extern RGB gFontPalette[128]; + // size: 0xC struct unkStruct_202D240 { diff --git a/include/structs/rgb.h b/include/structs/rgb.h index 8bdd6058f..b4c9ad9f3 100644 --- a/include/structs/rgb.h +++ b/include/structs/rgb.h @@ -8,9 +8,4 @@ typedef struct RGB u8 b; } RGB; -typedef struct Palette32 -{ - RGB pal[16]; -} Palette32; - #endif // GUARD_RGB_H diff --git a/src/code_2.c b/src/code_2.c index 487eb5262..a8f6ee9b7 100644 --- a/src/code_2.c +++ b/src/code_2.c @@ -39,7 +39,7 @@ extern void nullsub_33(void); extern u32 sub_80009D0(u32); extern u16 gUnknown_2026E4E; -extern s32 gTitleBrightness; +EWRAM_DATA s32 sTitleBrightness = 0; // TODO: figure out the struct struct UnkStruct203B040 @@ -106,12 +106,12 @@ void GameLoop(void) LoadTitleScreen(); SetBG2RegOffsets(0, 0); SetBG3RegOffsets(0, 0); - gTitleBrightness = 0; - while (gTitleBrightness < 32) { + sTitleBrightness = 0; + while (sTitleBrightness < 32) { s32 i; - gTitleBrightness++; + sTitleBrightness++; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); + SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], sTitleBrightness, NULL); xxx_update_stuff(0); } if (tmp3) { @@ -148,11 +148,11 @@ void GameLoop(void) if (nextMenu == MENU_NEW_GAME) break; } DeleteMainMenu(); - while (gTitleBrightness > 0) { + while (sTitleBrightness > 0) { s32 i; - gTitleBrightness--; + sTitleBrightness--; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); + SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], sTitleBrightness, NULL); xxx_update_stuff(0); } CloseFile(gTitlePaletteFile); diff --git a/src/code_800558C.c b/src/code_800558C.c index c7935f7cf..8d4a3262c 100644 --- a/src/code_800558C.c +++ b/src/code_800558C.c @@ -6,18 +6,19 @@ #include "math.h" #include "sprite.h" -extern u8 gUnknown_2026E38; -extern u32 *gUnknown_2026E3C; -extern s32 gUnknown_2026E40; -extern s32 gUnknown_2026E44; -extern s32 gUnknown_2026E48; -extern bool8 gUnknown_2026E4C; -extern u16 gUnknown_2026E4E; -extern bool32 gUnknown_2026E50; -extern bool32 gUnknown_2026E54; -extern u32 *gUnknown_2026E58; -extern s16 gUnknown_2026E60[]; -extern s16 gUnknown_20270E8[]; +EWRAM_DATA u8 gUnknown_2026E38 = 0; +EWRAM_DATA u32 *gUnknown_2026E3C = 0; +EWRAM_DATA s32 gUnknown_2026E40 = 0; +EWRAM_DATA s32 gUnknown_2026E44 = 0; +EWRAM_DATA s32 gUnknown_2026E48 = 0; +EWRAM_DATA bool8 gUnknown_2026E4C = 0; +EWRAM_DATA u16 gUnknown_2026E4E = 0; +EWRAM_DATA bool32 gUnknown_2026E50 = 0; +EWRAM_DATA bool32 gUnknown_2026E54 = 0; +EWRAM_DATA u32 *gUnknown_2026E58 = NULL; +UNUSED EWRAM_DATA static u32 sUnused0 = 0; +EWRAM_DATA static s16 gUnknown_2026E60[324] = {0}; +EWRAM_DATA static s16 gUnknown_20270E8[324] = {0}; EWRAM_INIT s16 *gUnknown_203B078 = NULL; @@ -239,7 +240,7 @@ void sub_8005838(s32 *a0, u8 kind) if (!gUnknown_2026E4C) kind = 0; - r3 = !gUnknown_2026E54 ? (s16 *) &gUnknown_2026E60 : (s16*) &gUnknown_20270E8; + r3 = !gUnknown_2026E54 ? gUnknown_2026E60 : gUnknown_20270E8; r2 = gUnknown_203B078; if (r2 == NULL) diff --git a/src/code_8009804.c b/src/code_8009804.c index 92fb68549..0ba651473 100644 --- a/src/code_8009804.c +++ b/src/code_8009804.c @@ -8,11 +8,11 @@ extern const u8 gUnknown_80B88CC[]; extern const struct FileArchive gSystemFileArchive; // 8300500 -extern Palette32 gFontPalette[8]; -extern u8 gUnknown_202D238[4]; -extern s32 gUnknown_202D23C; -extern u32 gUnknown_202D2A0; -extern struct unkStruct_202D240 gUnknown_202D240[8]; +EWRAM_DATA RGB gFontPalette[128] = {0}; +EWRAM_DATA static u8 gUnknown_202D238[4] = {0}; +EWRAM_DATA static s32 gUnknown_202D23C = 0; +EWRAM_DATA static struct unkStruct_202D240 gUnknown_202D240[8] = {0}; +EWRAM_DATA u32 gUnknown_202D2A0 = 0; typedef struct Palette256 { @@ -45,9 +45,9 @@ void InitFontPalette(void) CpuCopy(gFontPalette, fontpalFile->data, sizeof(gFontPalette)); if (sub_80063B0() == 1) - ptr = gFontPalette[0].pal; + ptr = &gFontPalette[0]; else - ptr = gFontPalette[1].pal; + ptr = &gFontPalette[16]; for (i = 0; i < 16; ptr++, i++) SetBGPaletteBufferColorArray(i + 240, ptr); @@ -64,11 +64,11 @@ void vram_related_8009804(void) for (i = 0; i < 0x13C0; i++) *dest++ = 0; - dest = (u32 *)0x06007000; + dest = (u32 *)(VRAM + 0x7000); for (i = 0; i < 0x400; i++) *dest++ = 0; - dest = (u32 *)0x06008000; + dest = (u32 *)(VRAM + 0x8000); for (i = 0; i < 0x2000; i++) *dest++ = 0; @@ -85,7 +85,7 @@ void vram_related_8009804(void) *dest++ = 0; dest = (u32 *)OAM; - for (i = 0; i < 256; i++) + for (i = 0; i < OAM_SIZE / 4; i++) *dest++ = 0xA000A0; // TODO: Macro or explanation } @@ -150,7 +150,7 @@ void SetFontsBaseColor(RGB a0) s32 i; for (i = 0; i < 8; i++) - gFontPalette[i].pal[1] = a0; + gFontPalette[16 * i + 1] = a0; } UNUSED static void sub_8009A10(struct unkStruct_8009A1C_ptr *a0, u32 palId, u32 vramDstOffset, u32 r3) diff --git a/src/code_800E9A8.c b/src/code_800E9A8.c index 329e485fc..c02a9fed8 100644 --- a/src/code_800E9A8.c +++ b/src/code_800E9A8.c @@ -7,7 +7,7 @@ s32 sub_800E2C0(u32); -struct unkStruct_203B0CC *gUnknown_203B0CC; +extern struct unkStruct_203B0CC *gUnknown_203B0CC; void sub_800DE38(struct unkStruct_203B0CC_sub *); void sub_800DE8C(struct unkStruct_203B0CC_sub *, DungeonPos *); @@ -48,7 +48,7 @@ bool8 sub_800E838(u16 *param_1, s32 param_2) } // TODO: look at this later -// https://decomp.me/scratch/luz2f +// https://decomp.me/scratch/luz2f u32 sub_800E890(unkStruct_80416E0 *param_1) { param_1->unk14 = sub_800E900(param_1->unk0); @@ -101,7 +101,7 @@ bool8 sub_800E90C(DungeonPos *param_1) } } - if(ptr->unk10 > 0) + if(ptr->unk10 > 0) ptr->unk10--; sub_800DCD0(ptr); if(ptr->unk54 == 0) diff --git a/src/code_800E9E4.c b/src/code_800E9E4.c index b5120a88d..2235958dc 100644 --- a/src/code_800E9E4.c +++ b/src/code_800E9E4.c @@ -8,14 +8,14 @@ u32 sub_800F19C(s32); s32 sub_800EBBC(s32); s32 sub_800EC68(s32); -struct unkStruct_203B0CC *gUnknown_203B0CC; +extern struct unkStruct_203B0CC *gUnknown_203B0CC; extern unkStruct_80B9C60 gUnknown_80B9C60; extern s32 gUnknown_80B9C9C[8]; extern s16 gUnknown_80CE73C[20]; -unkStruct_80CE37C gUnknown_80CE37C[1]; +extern unkStruct_80CE37C gUnknown_80CE37C[1]; extern unkStruct_80BDBC4 gUnknown_80BDBC4[430]; extern unkStruct_80B9CC4 gUnknown_80B9CC4[448]; @@ -56,13 +56,13 @@ s32 sub_800EA84(s32 *param_1) unkStruct_80BDBC4 *ret1; u32 size; ret1 = sub_800ECB8(param_1[0]); - + stack[1].unk00[0] = ret1->unk0; stack[1].unk00[1] = param_1[4]; stack[1].unk00[2] = param_1[3]; stack[1].unk00[3] = param_1[1]; stack[1].unk00[4] = param_1[2]; - + ret1 = sub_800ECB8(param_1[0]); stack[1].unk00[5] = sub_800EBBC(ret1->unk0); stack[1].unk00[6] = 0x0000ffff; @@ -137,13 +137,13 @@ s32 sub_800EBC8(s32 *param_1) unkStruct_80BDBC4 *ret1; u32 size; ret1 = sub_800ECB8(param_1[0]); - + stack[1].unk00[0] = ret1->unk4; stack[1].unk00[1] = param_1[4]; stack[1].unk00[2] = param_1[3]; stack[1].unk00[3] = param_1[1]; stack[1].unk00[4] = param_1[2]; - + ret1 = sub_800ECB8(param_1[0]); stack[1].unk00[5] = sub_800EC68(ret1->unk4); stack[1].unk00[6] = 0x0000ffff; diff --git a/src/code_800F034.c b/src/code_800F034.c index ef2398231..6f08b8b99 100644 --- a/src/code_800F034.c +++ b/src/code_800F034.c @@ -16,7 +16,7 @@ struct unkStruct_203B0D4 struct unkStruct_800F18C unk0[2]; }; -struct unkStruct_203B0D4 *gUnknown_203B0D4; +extern struct unkStruct_203B0D4 *gUnknown_203B0D4; ALIGNED(4) static const u8 gUnknown_80CE77C[] = "efob%03d"; ALIGNED(4) static const u8 gUnknown_80CE788[] = "efbg%03d"; @@ -53,7 +53,7 @@ void sub_800F094(void) { gUnknown_203B0D4->unk0[index].effectID = -1; gUnknown_203B0D4->unk0[index].counter = 0; - } + } } s32 sub_800F0C0(s32 animType, s32 effectID) @@ -81,7 +81,7 @@ s32 sub_800F0F4(s32 animType, s32 effectID) return -1; } -void sub_800F13C(s32 index, OpenedFile *file, unkStruct_80B9CC4 * r2) +void sub_800F13C(s32 index, OpenedFile *file, unkStruct_80B9CC4 * r2) { if(gUnknown_203B0D4->unk0[index].counter == 0) gUnknown_203B0D4->unk0[index].effectID = r2->effectId; @@ -101,9 +101,9 @@ void sub_800F15C(s32 effectID) } } -struct unkStruct_800F18C *sub_800F18C(s32 index) +struct unkStruct_800F18C *sub_800F18C(s32 index) { - return &gUnknown_203B0D4->unk0[index]; + return &gUnknown_203B0D4->unk0[index]; } s32 sub_800F19C(s32 index) @@ -135,6 +135,6 @@ OpenedFile * sub_800F1C0(u32 animType, s32 effectID) void sub_800F204(OpenedFile *file) { - CloseFile(file); + CloseFile(file); } diff --git a/src/code_803D110.c b/src/code_803D110.c index bc5150e71..6f40c9e93 100644 --- a/src/code_803D110.c +++ b/src/code_803D110.c @@ -41,7 +41,6 @@ extern OpenedFile *gUnknown_202EC98; extern OpenedFile *gUnknown_202EC94; extern s32 gDungeonNameBannerFont; extern u8 gUnknown_20274A5; -extern Palette32 gFontPalette[8]; struct UnkDungeonFileData { @@ -623,9 +622,9 @@ void sub_803E13C(void) SetWindowBGColor(); if (gGameOptionsRef->playerGender != 0) - pal = gFontPalette[4].pal; + pal = &gFontPalette[16 * 4]; else - pal = gFontPalette[0].pal; + pal = &gFontPalette[0]; for (i = 0; i < 16; i++) { SetBGPaletteBufferColorArray(240 + i, pal); diff --git a/src/code_803E724.c b/src/code_803E724.c index c640b874d..ff2d84e7f 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -39,7 +39,6 @@ extern struct DungeonPalFile *gDungeonPaletteFile; extern struct DungeonPalFile *gDungeonNameBannerPalette; extern struct DungeonPalFile *gUnknown_202EC94; extern RGB gUnknown_202ECA4[]; -extern RGB gUnknown_202D058; extern u8 gUnknown_203B40C; extern MenuInputStruct gUnknown_202EE10; extern SpriteOAM gUnknown_202EDDC; @@ -58,10 +57,7 @@ extern const u16 gUnknown_80F6544[][9]; extern u8 gUnknown_20274A5; -extern Palette32 gFontPalette[8]; - extern s32 gUnknown_202EDCC; -extern u32 gUnknown_3001018[]; extern void sub_8040A84(); extern void sub_8083D44(void); @@ -120,7 +116,7 @@ void sub_803E874(bool8 r10, s32 r9) } } - SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gDungeonBrightness, NULL); + SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; index = 256; @@ -177,7 +173,7 @@ void sub_803EA10(void) index++; } - SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gDungeonBrightness, NULL); + SetBGPaletteBufferColorRGB(248, &gFontPalette[8], gDungeonBrightness, NULL); } void sub_803EAF0(u32 a0, u8 *a1) @@ -859,13 +855,13 @@ void sub_803F38C(void) palId = (gGameOptionsRef->playerGender != MALE) ? 4 : 0; - SetBGPaletteBufferColorArray(0xFD, &gFontPalette[palId].pal[13]); - SetBGPaletteBufferColorArray(0xFE, &gFontPalette[palId].pal[14]); - SetBGPaletteBufferColorArray(0xFF, &gFontPalette[palId].pal[15]); + SetBGPaletteBufferColorArray(0xFD, &gFontPalette[16 * palId + 13]); + SetBGPaletteBufferColorArray(0xFE, &gFontPalette[16 * palId + 14]); + SetBGPaletteBufferColorArray(0xFF, &gFontPalette[16 * palId + 15]); - nullsub_5(0xFD, &gFontPalette[palId].pal[13]); - nullsub_5(0xFE, &gFontPalette[palId].pal[14]); - nullsub_5(0xFF, &gFontPalette[palId].pal[15]); + nullsub_5(0xFD, &gFontPalette[16 * palId + 13]); + nullsub_5(0xFE, &gFontPalette[16 * palId + 14]); + nullsub_5(0xFF, &gFontPalette[16 * palId + 15]); } bool8 sub_803F428(DungeonPos *pos) @@ -1153,6 +1149,8 @@ void sub_803F9CC(void) gUnknown_20274A5 = TRUE; } +IWRAM_DATA static u32 gUnknown_3001018[96] = {0}; + void sub_803FA4C(s32 a0, s32 a1, bool8 a2) { s32 i; @@ -1214,7 +1212,7 @@ void sub_803FA4C(s32 a0, s32 a1, bool8 a2) r5 = 0; } } - sub_80098BC((void *) VRAM + 0x5980, gUnknown_3001018, 0x180); + sub_80098BC((void *) VRAM + 0x5980, gUnknown_3001018, sizeof(gUnknown_3001018)); } void sub_803FB74(void) @@ -1267,18 +1265,18 @@ void sub_803FB74(void) if (strPtr->unk36 != r5) { strPtr->unk36 = r5; - SetBGPaletteBufferColorArray(0xFC, &gFontPalette[0].pal[12 + r5]); - SetBGPaletteBufferColorArray(0xFD, &gFontPalette[0].pal[13 + r5]); - SetBGPaletteBufferColorArray(0xFE, &gFontPalette[0].pal[14 + r5]); - SetBGPaletteBufferColorArray(0xFF, &gFontPalette[0].pal[15 + r5]); + SetBGPaletteBufferColorArray(0xFC, &gFontPalette[12 + r5]); + SetBGPaletteBufferColorArray(0xFD, &gFontPalette[13 + r5]); + SetBGPaletteBufferColorArray(0xFE, &gFontPalette[14 + r5]); + SetBGPaletteBufferColorArray(0xFF, &gFontPalette[15 + r5]); } if (strPtr->unk38 != r6) { strPtr->unk38 = r6; - nullsub_5(0xFC, &gFontPalette[0].pal[12 + r6]); - nullsub_5(0xFD, &gFontPalette[0].pal[13 + r6]); - nullsub_5(0xFE, &gFontPalette[0].pal[14 + r6]); - nullsub_5(0xFF, &gFontPalette[0].pal[15 + r6]); + nullsub_5(0xFC, &gFontPalette[12 + r6]); + nullsub_5(0xFD, &gFontPalette[13 + r6]); + nullsub_5(0xFE, &gFontPalette[14 + r6]); + nullsub_5(0xFF, &gFontPalette[15 + r6]); } arrPtr = gUnknown_202B038[0][0]; diff --git a/src/code_8073CF0.c b/src/code_8073CF0.c index c425bc7a1..f2ad85430 100644 --- a/src/code_8073CF0.c +++ b/src/code_8073CF0.c @@ -64,7 +64,6 @@ extern void sub_8075900(Entity *pokemon, u8 r1); extern void sub_806A5B8(Entity *); extern void sub_807EC28(bool8); -extern s32 gUnknown_202F378; extern u8 gUnknown_202F32D; extern const u8 *gMonTerrifiedCouldntPickUpItem; @@ -91,6 +90,8 @@ extern const DungeonPos gUnknown_80F4D44[]; bool8 UseAttack(Entity *a0); void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr); +static EWRAM_DATA s32 gUnknown_202F378 = 0; + void HandleEatAIAction(Entity *pokemon) { sub_8067110(pokemon); diff --git a/src/code_80869E4.c b/src/code_80869E4.c index 33f398c27..80578f4d5 100644 --- a/src/code_80869E4.c +++ b/src/code_80869E4.c @@ -15,7 +15,7 @@ // ??? extern u32 gDungeonBrightness; -EWRAM_DATA unkStruct_202F3D0 gUnknown_202F3D0 = {0}; +EWRAM_DATA static unkStruct_202F3D0 gUnknown_202F3D0 = {0}; // data_8107010.s extern u32 gUnknown_8107314[]; diff --git a/src/dungeon_map_access.c b/src/dungeon_map_access.c index 1130825ff..858fd80a5 100644 --- a/src/dungeon_map_access.c +++ b/src/dungeon_map_access.c @@ -157,7 +157,7 @@ void sub_8049884(void) } } -void sub_80498A8(int x,int y) +void sub_80498A8(s32 x,s32 y) { volatile u32 sp_0x0; volatile u32 sp_0x4; diff --git a/src/dungeon_message.c b/src/dungeon_message.c index a6e0362ff..0571134ee 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -4,6 +4,7 @@ #include "structs/dungeon_entity.h" #include "code_803E46C.h" #include "code_803E724.h" +#include "code_8009804.h" #include "string_format.h" #include "code_800E9E4.h" #include "menu_input.h" @@ -45,7 +46,6 @@ extern u32 gUnknown_202EDD0; extern u8 gUnknown_203B40C; extern u8 gUnknown_202EE01; extern s32 gUnknown_202EDCC; -extern Palette32 gFontPalette[]; extern const u8 gUnknown_80F7AE8[]; extern const u8 gUnknown_80F7AF8[]; @@ -746,7 +746,7 @@ void sub_8052FB8(const u8 *str) if (r8 < 62) { r8++; for (j = 0; j < 8; j++) { - SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[0].pal[j], r8 / 2, NULL); + SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[j], r8 / 2, NULL); } } else { @@ -777,7 +777,7 @@ void sub_8052FB8(const u8 *str) while (r8 >= 0) { for (j = 0; j < 8; j++) { - SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[0].pal[j], r8 / 2, NULL); + SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[j], r8 / 2, NULL); } DrawDialogueBoxString(); sub_803E46C(9); @@ -788,7 +788,7 @@ void sub_8052FB8(const u8 *str) sub_803E46C(9); sub_8040238(); for (j = 0; j < 8; j++) { - SetBGPaletteBufferColorArray(240 + j, &gFontPalette[0].pal[j]); + SetBGPaletteBufferColorArray(240 + j, &gFontPalette[j]); } sub_803E708(8, 9); } diff --git a/src/event_flag.c b/src/event_flag.c index 572a97f5f..9f32181fa 100644 --- a/src/event_flag.c +++ b/src/event_flag.c @@ -14,7 +14,7 @@ #include "pokemon.h" #include "pokemon_3.h" -extern u8 gScriptVarBuffer[0x400]; +EWRAM_DATA u8 gScriptVarBuffer[0x400] = {0}; struct GroundEventTableEntry { diff --git a/src/ground_main.c b/src/ground_main.c index 5c22c7a5d..f05411939 100644 --- a/src/ground_main.c +++ b/src/ground_main.c @@ -44,8 +44,8 @@ EWRAM_DATA u16 gUnknown_20398BC = {0}; EWRAM_DATA u16 gUnknown_20398BE = {0}; EWRAM_DATA u32 gUnknown_20398C0 = {0}; EWRAM_DATA s16 gUnknown_20398C4 = {0}; -struct unkStruct_20398C8 gUnknown_20398C8; -extern u8 gUnknown_2039950; +EWRAM_DATA struct unkStruct_20398C8 gUnknown_20398C8 = {0}; +EWRAM_DATA u8 gUnknown_2039950 = 0; EWRAM_INIT bool8 gUnknown_203B49C = {0}; EWRAM_INIT u8 gUnknown_203B49D = {0}; @@ -395,7 +395,7 @@ u8 sub_80990EC(struct unkStruct_20398C8 *param_1, s16 param_2) sub_80A8EC0(auStack_98, 0x5b); BoundedCopyStringtoBuffer(nameBuffer, auStack_98, POKEMON_NAME_LENGTH); { - struct unkStruct_808D144 stack = + struct unkStruct_808D144 stack = { .name = nameBuffer, .speciesNum = MONSTER_GENGAR, @@ -413,7 +413,7 @@ u8 sub_80990EC(struct unkStruct_20398C8 *param_1, s16 param_2) sub_808D144(¶m_1->unk18, &stack); } } - break; + break; case 4: param_1->unkB = 0; break; @@ -431,7 +431,7 @@ u8 sub_80991E0(struct unkStruct_20398C8 *param_1,short *param_2) *param_2 = gUnknown_20398C4; if (gUnknown_203B49C) { memcpy(param_1, &gUnknown_20398C8, sizeof(struct unkStruct_20398C8)); - return TRUE; + return TRUE; } else { return sub_80990EC(param_1,gUnknown_20398C4); @@ -441,7 +441,7 @@ u8 sub_80991E0(struct unkStruct_20398C8 *param_1,short *param_2) void sub_8099220(struct unkStruct_20398C8 *param_1, s16 param_2) { s32 param_2_s32 = (s16)param_2; - if (param_1 != NULL) + if (param_1 != NULL) { gUnknown_203B49C = TRUE; gUnknown_203B49D = 0; diff --git a/src/other_menus2.c b/src/other_menus2.c index c8e9717bd..2c5c17b30 100644 --- a/src/other_menus2.c +++ b/src/other_menus2.c @@ -20,9 +20,10 @@ typedef struct unkStruct_800D670 // rescue_password_menu.c extern s32 gCommsTimeout; // Counts to 100 and then errors if other player hasn't connected -extern s32 gUnknown_202EC40[2]; -extern s32 gUnknown_202EC48; -extern s32 gUnknown_202EC38; +EWRAM_DATA static s32 gUnknown_202EC38 = 0; +UNUSED EWRAM_DATA static u8 sUnused = 0; +EWRAM_DATA static s32 gUnknown_202EC40[2] = {0}; +EWRAM_DATA static s32 gUnknown_202EC48 = 0; extern struct UnkStruct_203B184 *gUnknown_203B184; @@ -190,7 +191,7 @@ s32 sub_8037C10(bool8 a0) if (sub_800D588()) ret = gUnknown_202EC40[1]; else - ret = gUnknown_202EC40[0]; + ret = gUnknown_202EC40[0]; } return ret; diff --git a/src/sound_names.c b/src/sound_names.c index 75cf95255..8fbca344e 100644 --- a/src/sound_names.c +++ b/src/sound_names.c @@ -16,8 +16,6 @@ struct SoundNamesStruct }; // Forward declarations -static const char sText_Table[]; -static const char sText_Header[]; static const char sText_PKDSoundData[]; const struct SoundNamesStruct gSoundNamesStruct; @@ -33,14 +31,12 @@ ALIGNED(4) UNUSED static const char sPksDir1[] = "pksdir0"; const struct SoundNamesStruct gSoundNamesStruct = { - .headerText = sText_Header, + .headerText = "HEADER", .soundDataBankText = sText_PKDSoundData, - .tableText = sText_Table, + .tableText = "TABLE", .sfxNames = gSfxNames, }; -ALIGNED(4) static const char sText_Table[] = "TABLE"; -ALIGNED(4) static const char sText_Header[] = "HEADER"; ALIGNED(4) UNUSED static const char sPksDir2[] = "pksdir0"; ALIGNED(4) static const char sText_PKDSoundData[] = "PKD Sound Data Bank"; diff --git a/src/text.c b/src/text.c index c5d72ce51..d5c4014f4 100644 --- a/src/text.c +++ b/src/text.c @@ -15,8 +15,6 @@ struct CharMapStruct struct unkChar *unk4; }; -// data.s - // data2.s extern const char gUnknown_80B88B0[]; // "font" extern const char gUnknown_80B88B8[]; // "fontsp" @@ -25,9 +23,6 @@ extern const char gUnknown_80B88C0[]; // "fontsppa" // system_sbin.s extern const struct FileArchive gSystemFileArchive; -// Todo fix gUnknown_3000E94 being accessed as s16/u8 -extern s16 gUnknown_3000E94[]; - EWRAM_DATA UnkTextStruct1 gUnknown_2027370[4] = {0}; EWRAM_DATA static struct CharMapStruct *sCharmaps[2] = {NULL}; EWRAM_DATA static s16 sCharacterSpacing = 0; @@ -46,6 +41,8 @@ EWRAM_DATA static u32 sTextShadowMask = 0; // Some text color info is stored; re EWRAM_DATA static u8 sDrawTextShadow = 0; EWRAM_DATA ALIGNED(4) u16 gUnknown_202B038[4][32][32] = {0}; +IWRAM_DATA static s16 gUnknown_3000E94[161] = {0}; + // These text-related functions were deemed important as they're copied and run from IWRAM for improved performance. static void sub_8272774(UnkTextStruct1 *txtStructs, s32 id); static void sub_8272884(UnkTextStruct1 *txtStructs, s32 id); @@ -2861,7 +2858,7 @@ static void sub_800898C(void) { s32 i; - for (i = 0; i < 161; i++) { + for (i = 0; i < ARRAY_COUNT_INT(gUnknown_3000E94); i++) { gUnknown_3000E94[i] = 0xF0F0; } } @@ -2873,7 +2870,7 @@ static void sub_80089AC(const UnkTextStruct2 *r4, DungeonPos *r5_Str) if (r4->unk0 & 0x40) return; - r6 = (void*) &gUnknown_3000E94; + r6 = (u8*) gUnknown_3000E94; if (r4->unk4 == 1) { s32 r12 = (r4->pos.x + r5_Str->x) * 8; s32 r5 = (r4->pos.y + r5_Str->y) * 8; diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index 9870dc165..d2b8dfe3f 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -95,9 +95,6 @@ const UnkTextStruct2 gUnknown_80DED60 = NULL }; -extern const u8 SendItem_Text[]; -extern const u8 DontSendItem_Text[]; - const MenuItem gUnknown_80DED78[] = { {"Confirm", CONFIRM_ACTION}, @@ -149,15 +146,12 @@ const MenuItem gUnknown_80DEE60[] = const MenuItem gUnknown_80DEE7C[] = { - {SendItem_Text, SEND_ITEM_ACTION}, - {DontSendItem_Text, NO_SEND_ITEM_ACTION}, + {"Send Item", SEND_ITEM_ACTION}, + {_("Don't Send Item"), NO_SEND_ITEM_ACTION}, {"Cancel", CANCEL_ACTION}, {}, }; -ALIGNED(4) static const u8 DontSendItem_Text[] = _("Don't Send Item"); -ALIGNED(4) static const u8 SendItem_Text[] = "Send Item"; - const MenuItem gUnknown_80DEEBC[] = { {"Send w/o Item", NO_SEND_ITEM_ACTION}, diff --git a/sym_ewram.txt b/sym_ewram.txt index 7e5738f9f..0622cfebf 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,77 +1,16 @@ .include "src/m4a.o" + .include "src/code_2.o" + .space 0x4 -gTitleBrightness: /* 2000A80 (GameLoop) */ - .space 0x8 - -gScriptVarBuffer: /* 2000A88 (ThoroughlyResetScriptVars - RestoreGlobalScriptVars) */ - .space 0x400 - + .include "src/event_flag.o" .include "src/memory.o" .include "src/bg_palette_buffer.o" .include "src/input.o" .include "src/sprite.o" - -gUnknown_2026E38: /* 2026E38 (sub_80057E8 - VBlank_CB) */ - .space 0x4 -gUnknown_2026E3C: /* 2026E3C (sub_80057E8 - VBlank_CB) */ - .space 0x4 -gUnknown_2026E40: /* 2026E40 (sub_8005838) */ - .space 0x4 -gUnknown_2026E44: /* 2026E44 (sub_8005838) */ - .space 0x4 -gUnknown_2026E48: /* 2026E48 (sub_8005838) */ - .space 0x4 -gUnknown_2026E4C: /* 2026E4C (sub_80057E8 - sub_8005838) */ - .space 0x2 -gUnknown_2026E4E: /* 2026E4E (GameLoop - GroundWeather_Select) */ - .space 0x2 -gUnknown_2026E50: /* 2026E50 (sub_80057E8 - sub_80060EC) */ - .space 0x4 -gUnknown_2026E54: /* 2026E54 (sub_80057E8 - sub_80060EC) */ - .space 0x4 -gUnknown_2026E58: /* 2026E58 (sub_80057E8 - sub_80060EC) */ - .space 0x8 -gUnknown_2026E60: /* 2026E60 (sub_8005838) */ - .space 0x288 -gUnknown_20270E8: /* 20270E8 (sub_8005838) */ - .space 0x288 - + .include "src/code_800558C.o" .include "src/text.o" - - -gFontPalette: /* 202D038 (sub_80097B0 - sub_8052FB8) */ - .space 0x4 - -gUnknown_202D03C: /* 202D03C (sub_8040238) */ - .space 0x1C -gUnknown_202D058: /* 202D058 (sub_803E250 - sub_803EA10) */ - .space 0x10 -gUnknown_202D068: /* 202D068 (sub_803FB74) */ - .space 0x4 -gUnknown_202D06C: /* 202D06C (sub_803F38C) */ - .space 0xC - -gFontPaletteAlt: /* 202D078 (sub_8099690) */ - .space 0x20 - -gUnknown_202D098: /* 202D098 (xxx_format_string) */ - .space 0x120 - -gUnknown_202D1B8: /* 202D1B8 (sub_8099690) */ - .space 0x40 -gUnknown_202D1F8: /* 202D1F8 (sub_8099690) */ - .space 0x40 - -gUnknown_202D238: /* 202D238 (sub_80098A0 - sub_8009908) */ - .space 0x4 -gUnknown_202D23C: /* 202D23C (sub_80098A0 - sub_8009908) */ - .space 0x4 -gUnknown_202D240: /* 202D240 (sub_80098BC - sub_8009908) */ - .space 0x60 -gUnknown_202D2A0: /* 202D2A0 (sub_8009A1C - sub_8009BE4) */ - .space 0x4 - + .include "src/code_8009804.o" .include "src/file_system.o" .include "src/decompress.o" .include "src/main.o" @@ -128,15 +67,7 @@ gUnknown_202DE19: /* 202DE19 (sub_800F990 - sub_8010014) */ .space 4 .include "src/string_format.o" .space 4 - - -gUnknown_202EC38: /* 202EC38 (sub_8037B28) */ - .space 0x8 -gUnknown_202EC40: /* 202EC40 (sub_8037A48 - sub_8037C10) */ - .space 0x8 -gUnknown_202EC48: /* 202EC48 (sub_8037D64) */ - .space 0x4 - + .include "src/other_menus2.o" .include "src/rescue_password_menu.o" .space 0x2 @@ -258,14 +189,10 @@ gUnknown_202F32D: /* 202F32D (sub_8072CF4 - UseAttack) */ .space 0x3 .include "src/dungeon_ai_items.o" - -gUnknown_202F378: /* 202F378 (sub_8074FB0 - UseAttack) */ - .space 0x8 - + .include "src/code_8073CF0.o" + .space 0x4 .include "src/dungeon_ai_attack.o" - -gUnknown_202F3D0: /* 202F3D0 (sub_80867F4 - sub_8086854) */ - .space 0x8 + .include "src/code_80869E4.o" gUnknown_202F3D8: /* 202F3D8 (sub_8085B4C - sub_8085B80) */ .space 0x8 @@ -289,12 +216,8 @@ gUnknown_202F3D8: /* 202F3D8 (sub_8085B4C - sub_8085B80) */ .include "src/exclusive_pokemon.o" .space 0x4 .include "src/ground_main.o" - .space 0x2 -gUnknown_20398C8: /* 20398C8 (sub_80991E0 - sub_809927C) */ - .space 0x88 /* This should be a "struct WonderMailStruct_203B2C0_sub", at least I think so due to its size. Kermalis */ -gUnknown_2039950: /* 2039950 (xxx_script_related_8098468 - sub_809927C) */ - .space 0x8 + .space 0x7 gUnknown_2039958: /* 2039958 (sub_809977C - sub_8099BE4) */ .space 0x10 diff --git a/sym_iwram.txt b/sym_iwram.txt index 5c61b39d2..908f47ef4 100644 --- a/sym_iwram.txt +++ b/sym_iwram.txt @@ -6,13 +6,7 @@ gUnknown_3000400: /* 3000400 */ gUnknown_3000C00: /* 3000C00 */ .space 0x294 -gUnknown_3000E94: /* 3000E94 */ - .space 0x144 - +.include "src/text.o" .include "src/music.o" - -gUnknown_3001018: /* 3001018 */ - .space 0x180 - +.include "src/code_803E724.o" .include "src/code_8094D28.o" -