diff options
Diffstat (limited to 'src/pokedex.c')
-rw-r--r-- | src/pokedex.c | 72 |
1 files changed, 41 insertions, 31 deletions
diff --git a/src/pokedex.c b/src/pokedex.c index f99a8226a..cceb50ba1 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -30,8 +30,6 @@ #include "constants/songs.h" #include "constants/species.h" -extern u8 gDexCryScreenState; - // EWRAM static EWRAM_DATA struct PokedexView *sPokedexView = NULL; static EWRAM_DATA u16 gUnknown_02039B50 = 0; @@ -39,7 +37,8 @@ static EWRAM_DATA u8 gUnknown_02039B52 = 0; static EWRAM_DATA struct PokedexListItem *sPokedexListItem = NULL; // IWRAM common -u8 gUnknown_030060B0; +// This is written to, but never read. +u8 gUnusedPokedexU8; void (*gUnknown_030060B4)(void); struct PokedexOption @@ -249,10 +248,10 @@ static const struct OamData sOamData_855CFE4 = .objMode = 0, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_SQUARE, + .shape = SPRITE_SHAPE(8x8), .x = 0, .matrixNum = 0, - .size = 0, + .size = SPRITE_SIZE(8x8), .tileNum = 0, .priority = 1, .paletteNum = 0, @@ -266,10 +265,10 @@ static const struct OamData sOamData_855CFEC = .objMode = 0, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_H_RECTANGLE, + .shape = SPRITE_SHAPE(16x8), .x = 0, .matrixNum = 0, - .size = 0, + .size = SPRITE_SIZE(16x8), .tileNum = 0, .priority = 0, .paletteNum = 0, @@ -283,10 +282,10 @@ static const struct OamData sOamData_855CFF4 = .objMode = 0, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_H_RECTANGLE, + .shape = SPRITE_SHAPE(32x16), .x = 0, .matrixNum = 0, - .size = 2, + .size = SPRITE_SIZE(32x16), .tileNum = 0, .priority = 0, .paletteNum = 0, @@ -300,10 +299,10 @@ static const struct OamData sOamData_855CFFC = .objMode = 2, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_SQUARE, + .shape = SPRITE_SHAPE(32x32), .x = 0, .matrixNum = 0, - .size = 2, + .size = SPRITE_SIZE(32x32), .tileNum = 0, .priority = 1, .paletteNum = 0, @@ -317,10 +316,10 @@ static const struct OamData sOamData_855D004 = .objMode = 0, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_H_RECTANGLE, + .shape = SPRITE_SHAPE(64x32), .x = 0, .matrixNum = 0, - .size = 3, + .size = SPRITE_SIZE(64x32), .tileNum = 0, .priority = 0, .paletteNum = 0, @@ -334,10 +333,10 @@ static const struct OamData sOamData_855D00C = .objMode = 0, .mosaic = 0, .bpp = 0, - .shape = ST_OAM_V_RECTANGLE, + .shape = SPRITE_SHAPE(8x16), .x = 0, .matrixNum = 0, - .size = 0, + .size = SPRITE_SIZE(8x16), .tileNum = 0, .priority = 0, .paletteNum = 0, @@ -1227,7 +1226,7 @@ void ResetPokedex(void) gUnknown_02039B50 = 0; gUnknown_02039B52 = 64; - gUnknown_030060B0 = 0; + gUnusedPokedexU8 = 0; gSaveBlock2Ptr->pokedex.mode = DEX_MODE_HOENN; gSaveBlock2Ptr->pokedex.order = 0; gSaveBlock2Ptr->pokedex.nationalMagic = 0; @@ -1245,7 +1244,7 @@ void ResetPokedex(void) } } -void sub_80BB358(void) +void ResetPokedexScrollPositions(void) { gUnknown_02039B50 = 0; gUnknown_02039B52 = 64; @@ -2153,7 +2152,7 @@ static void CreateCaughtBall(u16 a, u8 x, u8 y, u16 unused) if (a) BlitBitmapToWindow(0, gUnknown_0855D2BE, x * 8, y * 8, 8, 16); else - FillWindowPixelRect(0, 0, x * 8, y * 8, 8, 16); + FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 8, 16); } static u8 CreateMonName(u16 num, u8 left, u8 top) @@ -2171,7 +2170,7 @@ static u8 CreateMonName(u16 num, u8 left, u8 top) void sub_80BD28C(u8 x, u8 y, u16 unused) { - FillWindowPixelRect(0, 0, x * 8, y * 8, 0x60, 16); + FillWindowPixelRect(0, PIXEL_FILL(0), x * 8, y * 8, 0x60, 16); } static void CreateInitialPokemonSprites(u16 selectedMon, u16 b) @@ -2928,7 +2927,7 @@ void sub_80BEA24(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(0, 0); + FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); PutWindowTilemap(1); sub_80C0D30(1, sPokedexListItem->dexNum); @@ -3223,7 +3222,7 @@ void sub_80BF250(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, &gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, &gPokedexTilemap_CryScreen, 0, 0); - FillWindowPixelBuffer(0, 0); + FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); PutWindowTilemap(3); PutWindowTilemap(2); @@ -3417,7 +3416,7 @@ void sub_80BF82C(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_SizeScreen, 0, 0); - FillWindowPixelBuffer(0, 0); + FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); gMain.state++; break; @@ -3541,8 +3540,9 @@ void sub_80BFCF4(u16 a) { CopyToBgTilemapBuffer(1, gPokedexTilemap_ScreenSelectBar2, 0, 0); } - #ifdef NONMATCHING +// This doesn't match because gcc flips the naming of the r3 and r4 +// registers. void sub_80BFD0C(u8 a, u16 unused) { u8 i; @@ -3631,6 +3631,8 @@ _080BFD3E:\n\ #endif #ifdef NONMATCHING +// This doesn't match because gcc flips the naming of the r3 and r4 +// registers. void sub_80BFD7C(u8 a, u16 b) { u8 i; @@ -3764,7 +3766,7 @@ void sub_80BFE38(u8 taskId) case 1: DecompressAndLoadBgGfxUsingHeap(3, gPokedexMenu_Gfx, 0x2000, 0, 0); CopyToBgTilemapBuffer(3, gPokedexTilemap_DescriptionScreen, 0, 0); - FillWindowPixelBuffer(0, 0); + FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); PutWindowTilemap(1); sub_80C0D30(1, gTasks[taskId].data[1]); @@ -3961,6 +3963,8 @@ void sub_80C0354(u16 height, u8 left, u8 top) } #ifdef NONMATCHING +// This doesn't match because gcc manages to avoid using the stack +// to store local variables. void sub_80C0460(u16 weight, u8 left, u8 top) { u8 buffer[16]; @@ -4038,7 +4042,7 @@ void sub_80C0460(u16 weight, u8 left, u8 top) lsls r2, 24\n\ lsrs r2, 24\n\ str r2, [sp, 0x10]\n\ - ldr r5, =0x000186a0\n\ + ldr r5, =0x000186a0 @ Note to decompiler: See UNKNOWN_OFFSET\n\ muls r0, r5\n\ ldr r1, =0x000011b8\n\ bl __divsi3\n\ @@ -4072,7 +4076,7 @@ _080C04C0:\n\ mov r8, r1\n\ movs r6, 0x1\n\ _080C04C6:\n\ - ldr r1, =0x000186a0\n\ + ldr r1, =0x000186a0 @ Note to decompiler: See UNKNOWN_OFFSET\n\ adds r0, r7, 0\n\ bl __umodsi3\n\ adds r7, r0, 0\n\ @@ -4780,7 +4784,7 @@ void sub_80C1270(const u8 *str, u32 left, u32 top) void sub_80C12B0(u32 x, u32 y, u32 width, u32 height) { - FillWindowPixelRect(0, 0, x, y, width, height); + FillWindowPixelRect(0, PIXEL_FILL(0), x, y, width, height); } void sub_80C12E0(u8 taskId) @@ -5207,18 +5211,24 @@ void sub_80C1D70(u8 taskId) } #ifdef NONMATCHING +// This doesn't match because gcc flips the naming of the r7 and r6 +// registers. It also does one of the additions backwards. void sub_80C1D98(u8 a, u8 b, u8 c, u8 d) { u16 i; u16* ptr = GetBgTilemapBuffer(3); + u16* temp; for (i = 0; i < d; i++) { - ptr[b + i + (c << 6)] %= 0x1000; - ptr[b + i + (c << 6)] |= a * 4096; + // This addition is supposed to be done in this order; however, + // gcc will always do it in ptr + (c << 5) order. + temp = (c << 5) + ptr; + temp[b + i] %= 0x1000; + temp[b + i] |= a * 4096; - ptr[b + i + (c << 6) + 32] %= 0x1000; - ptr[b + i + (c << 6) + 32] |= a * 4096; + temp[b + i + 32] %= 0x1000; + temp[b + i + 32] |= a * 4096; } } #else |