From 14a51f514b14c93256fbb51ed9ddb13b63c0be57 Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 12:35:04 +0100 Subject: [PATCH 1/7] Palette cleanup --- include/bg_palette_buffer.h | 8 ++-- include/code_8004AA0.h | 2 +- include/code_800558C.h | 18 +++++---- include/structs/str_dungeon.h | 12 +----- src/bg_palette_buffer.c | 55 +++++++++++++------------- src/code_2.c | 16 ++++---- src/code_8004AA0.c | 12 +++--- src/code_800558C.c | 38 +++++++++--------- src/code_803E46C.c | 2 +- src/code_803E724.c | 72 +++++++++++++++++------------------ src/weather.c | 6 +-- sym_ewram.txt | 2 +- tmp/rgb.cocci | 23 +++++++++++ 13 files changed, 142 insertions(+), 124 deletions(-) create mode 100644 tmp/rgb.cocci diff --git a/include/bg_palette_buffer.h b/include/bg_palette_buffer.h index d6218aa0b..2b10e90b6 100644 --- a/include/bg_palette_buffer.h +++ b/include/bg_palette_buffer.h @@ -4,10 +4,10 @@ #include "structs/rgb.h" void InitBGPaletteBuffer(void); -void nullsub_4(s32 index, const u8 *colorArray, s32, u8 *); -void nullsub_5(s32 index, const Rgb32 *colorArray); -void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color32); -void SetBGPaletteBufferColorRGB(s32 index, const u8 *colorArray, s32, u8 *); +void nullsub_4(s32 index, const Rgb32 *color, s32 brightness, const Rgb32 *ramp); +void nullsub_5(s32 index, const Rgb32 *color); +void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color); +void SetBGPaletteBufferColorRGB(s32 index, const Rgb32 *color, s32 brightness, const Rgb32 *ramp); void TransferBGPaletteBuffer(void); #endif // GUARD_BG_PALETTE_BUFFER_H diff --git a/include/code_8004AA0.h b/include/code_8004AA0.h index d1027e5a6..5d2b18dd4 100644 --- a/include/code_8004AA0.h +++ b/include/code_8004AA0.h @@ -42,7 +42,7 @@ typedef struct unkDataFor8004AA4 void nullsub_6(void); void sub_8004AA4(unkStruct_202EE8C *, OpenedFile *, s32); -bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, u8 *); +bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, const Rgb32 *); bool8 sub_8004D14(unkStruct_202EE8C *, s32); bool8 sub_8004D40(unkStruct_202EE8C *, s32); diff --git a/include/code_800558C.h b/include/code_800558C.h index abb8d2bd9..ec1b4b577 100644 --- a/include/code_800558C.h +++ b/include/code_800558C.h @@ -1,15 +1,17 @@ #ifndef GUARD_CODE_800558C_H #define GUARD_CODE_800558C_H +#include "structs/rgb.h" +#include "structs/axdata.h" #include "file_system.h" // size: ? 0x20 for now -struct unkStructFor800561C +struct axMapSprite { - u8 fill0[0x14 - 0x0]; - void *unk14; - s32 *unk18; - s32 unk1C; + axmain axmain; + const u32 *tiles; + const Rgb32 *pal; + s32 tileCount; }; extern s16 *gUnknown_203B078; @@ -21,10 +23,10 @@ void nullsub_10(bool8); void nullsub_12(void); void nullsub_13(void); void nullsub_14(void); -void sub_8005610(OpenedFile *, s32, s32, u8 *); -void sub_8005770(s32, u8 *colorArray, s32, u8 *); +void sub_8005610(OpenedFile *, s32, s32, const Rgb32 *); +void sub_8005770(s32, const Rgb32 *color, s32, const Rgb32 *ramp); void sub_80057E8(void); void sub_8005838(s32 *, u8 kind); void sub_80060EC(void); -#endif // GUARD_CODE_800558C_H \ No newline at end of file +#endif // GUARD_CODE_800558C_H diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index 5f6cec483..c84fc992e 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -5,6 +5,7 @@ #include "structs/dungeon_entity.h" #include "file_system.h" #include "structs/map.h" +#include "structs/rgb.h" #include "structs/str_position.h" #include "sprite.h" @@ -23,15 +24,6 @@ typedef struct DungeonLocation /* 0x1 */ u8 floor; } DungeonLocation; -// size: 0x4 -// This might be "RGB"... see `SetDungeonBGColorRGB()` -typedef struct Dungeon_sub -{ - u8 unk0; - u8 unk1; - u8 unk2; -} Dungeon_sub; - typedef struct Weather { /* 0xE264 */ u8 weather; // Uses the weather constants in weather.h. @@ -267,7 +259,7 @@ typedef struct Dungeon Entity *unkBC; u8 fillC0[0x134 - 0xC0]; struct unkStruct_Dungeon134_sub unk134; - Dungeon_sub unk17C[0x100]; + Rgb32 colorRamp[0x100]; /* 0x57C */ u8 fill57C[0x5C0 - 0x57c]; /* 0x5C0 */ s32 unk5C0; /* 0x5C4 */ struct unkStruct_Dungeon5C4_sub unk5C4[3]; diff --git a/src/bg_palette_buffer.c b/src/bg_palette_buffer.c index f2b71cb2c..bb2c6c798 100644 --- a/src/bg_palette_buffer.c +++ b/src/bg_palette_buffer.c @@ -3,9 +3,9 @@ #include "cpu.h" #define BG_PALETTE_BUFFER_SIZE 512 -#define BG_PALETTE_BUFFER_CHUNK_SIZE 16 +#define BG_PALETTE_ROW_SIZE 16 -static EWRAM_DATA bool8 sBGPaletteUsed[BG_PALETTE_BUFFER_SIZE / BG_PALETTE_BUFFER_CHUNK_SIZE] = {0}; +static EWRAM_DATA bool8 sBGPaletteRowDirty[BG_PALETTE_BUFFER_SIZE / BG_PALETTE_ROW_SIZE] = {0}; static EWRAM_DATA u16 sBGPaletteBuffer[BG_PALETTE_BUFFER_SIZE] = {0}; void InitBGPaletteBuffer(void) @@ -16,46 +16,47 @@ void InitBGPaletteBuffer(void) sBGPaletteBuffer[i] = 0; } - for (i = 0; i < BG_PALETTE_BUFFER_SIZE / BG_PALETTE_BUFFER_CHUNK_SIZE; i++) { - sBGPaletteUsed[i] = TRUE; + for (i = 0; i < BG_PALETTE_BUFFER_SIZE / BG_PALETTE_ROW_SIZE; i++) { + sBGPaletteRowDirty[i] = TRUE; } } -// 99.48% (r3/r4 regswap) https://decomp.me/scratch/7Yc8i -void SetBGPaletteBufferColorRGB(s32 index, const u8 *colorArray, s32 a1, u8 *a2) +void SetBGPaletteBufferColorRGB(s32 index, const Rgb32 *color, s32 brightnessRaw, const Rgb32 *ramp) { - #ifdef NONMATCHING - s32 var; - #else - register s32 var asm("r1"); - #endif // NONMATCHING + s32 brightness = brightnessRaw; - if (a1 < 0) - a1 = 0; - if (a1 > 31) - a1 = 31; + if (brightness < 0) + brightness = 0; + if (brightness > 31) + brightness = 31; - sBGPaletteUsed[index / 16] = 1; + sBGPaletteRowDirty[index / BG_PALETTE_ROW_SIZE] = TRUE; - if (a2 == NULL) - sBGPaletteBuffer[index] = var = ((colorArray[2] * a1 / 256 & 0x1F) << 10) | ((colorArray[1] * a1 / 256 & 0x1F) << 5) | (colorArray[0] * a1 / 256 & 0x1F); + if (ramp == NULL) + sBGPaletteBuffer[index] = RGB2( + color->r * brightness / 256 & 0x1F, + color->g * brightness / 256 & 0x1F, + color->b * brightness / 256 & 0x1F); else - sBGPaletteBuffer[index] = var = ((a2[4 * colorArray[2] + 2] * a1 / 256 & 0x1F) << 10) | ((a2[4 * colorArray[1] + 1] * a1 / 256 & 0x1F) << 5) | (a2[4 * colorArray[0]] * a1 / 256 & 0x1F); + sBGPaletteBuffer[index] = RGB2( + ramp[color->r].r * brightness / 256 & 0x1F, + ramp[color->g].g * brightness / 256 & 0x1F, + ramp[color->b].b * brightness / 256 & 0x1F); } void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color32) { - sBGPaletteUsed[index / BG_PALETTE_BUFFER_CHUNK_SIZE] = TRUE; + sBGPaletteRowDirty[index / BG_PALETTE_ROW_SIZE] = TRUE; sBGPaletteBuffer[index] = RGB2(color32->r >> 3, color32->g >> 3, color32->b >> 3); } void SetBGPaletteBufferColor(s32 index, u16 *color) { - sBGPaletteUsed[index / BG_PALETTE_BUFFER_CHUNK_SIZE] = TRUE; + sBGPaletteRowDirty[index / BG_PALETTE_ROW_SIZE] = TRUE; sBGPaletteBuffer[index] = *color; } -void nullsub_4(s32 index, const u8 *colorArray, s32 a1, u8 *a2) +void nullsub_4(s32 index, const Rgb32 *colorArray, s32 brightness, const Rgb32 *ramp) { } @@ -78,14 +79,14 @@ void TransferBGPaletteBuffer(void) dest = (u16 *)PLTT; do { - if (sBGPaletteUsed[i]) + if (sBGPaletteRowDirty[i]) { - sBGPaletteUsed[i] = 0; - CpuCopy(dest, &sBGPaletteBuffer[paletteBufferIndex], sizeof(u16) * 16); + sBGPaletteRowDirty[i] = 0; + CpuCopy(dest, &sBGPaletteBuffer[paletteBufferIndex], sizeof(u16) * BG_PALETTE_ROW_SIZE); } ++i; - dest += 16; - paletteBufferIndex += 16; + dest += BG_PALETTE_ROW_SIZE; + paletteBufferIndex += BG_PALETTE_ROW_SIZE; } while (paletteBufferIndex < BG_PALETTE_BUFFER_SIZE); } diff --git a/src/code_2.c b/src/code_2.c index 08b9f8871..6fc5effa5 100644 --- a/src/code_2.c +++ b/src/code_2.c @@ -44,7 +44,7 @@ extern void xxx_call_update_bg_vram(void); extern u32 gUnknown_203B03C; extern u16 gUnknown_2026E4E; -extern s32 gUnknown_2000A80; +extern s32 gTitleBrightness; extern OpenedFile *gTitlePaletteFile; extern char gPMDBuildVersion[]; @@ -103,12 +103,12 @@ void GameLoop(void) LoadTitleScreen(); SetBG2RegOffsets(0, 0); SetBG3RegOffsets(0, 0); - gUnknown_2000A80 = 0; - while (gUnknown_2000A80 < 32) { + gTitleBrightness = 0; + while (gTitleBrightness < 32) { s32 i; - gUnknown_2000A80++; + gTitleBrightness++; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &gTitlePaletteFile->data[i * 4], gUnknown_2000A80, 0); + SetBGPaletteBufferColorRGB(i, &((Rgb32*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); xxx_update_stuff(0); } if (tmp3) { @@ -145,11 +145,11 @@ void GameLoop(void) if (nextMenu == MENU_NEW_GAME) break; } DeleteMainMenu(); - while (gUnknown_2000A80 > 0) { + while (gTitleBrightness > 0) { s32 i; - gUnknown_2000A80--; + gTitleBrightness--; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &gTitlePaletteFile->data[i * 4], gUnknown_2000A80, 0); + SetBGPaletteBufferColorRGB(i, &((Rgb32*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); xxx_update_stuff(0); } CloseFile(gTitlePaletteFile); diff --git a/src/code_8004AA0.c b/src/code_8004AA0.c index 9438e07dd..9bc2cefa0 100644 --- a/src/code_8004AA0.c +++ b/src/code_8004AA0.c @@ -31,7 +31,7 @@ void sub_8004AA4(unkStruct_202EE8C *a0, OpenedFile *a1, s32 a2) } } -bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, u8 *a5) +bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const Rgb32 *a5) { bool8 bVar3; bool8 ret; @@ -57,13 +57,13 @@ bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, u8 *a } if (bVar3) - SetBGPaletteBufferColorRGB(a2, (u8 *)&a1->unk14, a4, a5); + SetBGPaletteBufferColorRGB(a2, &a1->unk14, a4, a5); } return ret; } -UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, u8 *a5) +UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const Rgb32 *a5) { bool8 bVar3; bool8 ret; @@ -89,13 +89,13 @@ UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, } if (bVar3) - nullsub_4(a2, (u8 *)&a1->unk14, a4, a5); + nullsub_4(a2, &a1->unk14, a4, a5); } return ret; } -bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, u8 *a4, s16 *a5) +bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, const Rgb32 *a4, s16 *a5) { bool8 ret; s32 i; @@ -153,7 +153,7 @@ bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, u8 *a4, s16 *a5 color32 &= 0xFF00FFFF; color32 |= val3; - SetBGPaletteBufferColorRGB(a1, (u8 *)&color32, a3, a4); + SetBGPaletteBufferColorRGB(a1, (Rgb32 *)&color32, a3, a4); } return ret; diff --git a/src/code_800558C.c b/src/code_800558C.c index 498c53041..8aaf3ad24 100644 --- a/src/code_800558C.c +++ b/src/code_800558C.c @@ -31,8 +31,8 @@ extern const s16 gUnknown_80B83EA[16 * 10]; extern s32 sin_abs_4096(s32); extern s32 cos_4096(s32); -static void sub_800561C(struct unkStructFor800561C *, s32, s32, u8 *); -s32 *sub_8005674(struct unkStructFor800561C *, s32); +static void sub_800561C(struct axMapSprite *, s32, s32, const Rgb32 *); +const Rgb32 *sub_8005674(struct axMapSprite *, s32); void DoAxFrame_800558C(struct axObject *a0, s32 spriteX, s32 spriteY, u32 a3, u32 paletteNum, u16 *spriteMasks) { @@ -56,35 +56,35 @@ void DoAxFrame_800558C(struct axObject *a0, s32 spriteX, s32 spriteY, u32 a3, u3 a0->axdata.flags &= 0xF7FF; } -void sub_8005610(OpenedFile *a0, s32 a1, s32 a2, u8 *a3) +void sub_8005610(OpenedFile *a0, s32 vramIdx, s32 brightness, const Rgb32 *ramp) { - sub_800561C((struct unkStructFor800561C *)a0->data, a1, a2, a3); + sub_800561C((struct axMapSprite *)a0->data, vramIdx, brightness, ramp); } -static void sub_800561C(struct unkStructFor800561C *a0, s32 a1, s32 a2, u8 *a3) +static void sub_800561C(struct axMapSprite *a0, s32 vramIdx, s32 brightness, const Rgb32 *ramp) { s32 i; - if (a0->unk14 != NULL) - CpuCopy(OBJ_VRAM0 + a1 * 0x20, a0->unk14, a0->unk1C << 5); + if (a0->tiles != NULL) + CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); - if (a0->unk18 != NULL) { + if (a0->pal != NULL) { for (i = 0; i < 16; i++) - SetBGPaletteBufferColorRGB(i + 480, (u8 *)&a0->unk18[i], a2, a3); + SetBGPaletteBufferColorRGB(i + 480, &a0->pal[i], brightness, ramp); } } -UNUSED static s32 *sub_8005668(OpenedFile *a0, s32 a1) +UNUSED static const Rgb32 *sub_8005668(OpenedFile *a0, s32 vramIdx) { - return sub_8005674((struct unkStructFor800561C *)a0->data, a1); + return sub_8005674((struct axMapSprite *)a0->data, vramIdx); } -s32 *sub_8005674(struct unkStructFor800561C *a0, s32 a1) +const Rgb32 *sub_8005674(struct axMapSprite *a0, s32 vramIdx) { - if (a0->unk14 != NULL) - CpuCopy(OBJ_VRAM0 + a1 * 0x20, a0->unk14, a0->unk1C << 5); + if (a0->tiles != NULL) + CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); - return a0->unk18; + return a0->pal; } void sub_800569C(Position *a0, struct axObject *a1, u8 a2) @@ -149,17 +149,17 @@ void sub_8005700(Position *a0, struct axObject *a1) } } -UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, u8 *a3) +UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, const Rgb32 *a3) { - sub_8005770(a0, file->data, a2, a3); + sub_8005770(a0, (const Rgb32*)file->data, a2, a3); } -void sub_8005770(s32 param_1, u8 *colorArray, s32 a1, u8 *a2) +void sub_8005770(s32 param_1, const Rgb32 *color, s32 brightness, const Rgb32 *ramp) { s32 i; for (i = 0; i < 16; i++) - SetBGPaletteBufferColorRGB((param_1 + 0x10) * 0x10 + i, &colorArray[i * 4], a1, a2); + SetBGPaletteBufferColorRGB((param_1 + 0x10) * 0x10 + i, &color[i], brightness, ramp); } // Maybe Position diff --git a/src/code_803E46C.c b/src/code_803E46C.c index d086befff..e65ab6b13 100644 --- a/src/code_803E46C.c +++ b/src/code_803E46C.c @@ -87,7 +87,7 @@ void sub_803E490(u32 unused) if(gDungeon->unk181e8.unk18215 != 0 && gDungeon->unk1BDD4.unk1C06C != 3) - sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, (u8 *)gDungeon->unk17C); + sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); nullsub_8(gGameOptionsRef->unkA); sub_8005180(); diff --git a/src/code_803E724.c b/src/code_803E724.c index 7f5d1527d..f881827b2 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -37,13 +37,13 @@ struct DungeonPalFile extern struct DungeonPalFile *gDungeonPaletteFile; extern struct DungeonPalFile *gDungeonNameBannerPalette; extern struct DungeonPalFile *gUnknown_202EC94; -extern u8 gUnknown_202ECA4[]; -extern u8 gUnknown_202D058[]; +extern Rgb32 gUnknown_202ECA4[]; +extern Rgb32 gUnknown_202D058; extern u8 gUnknown_203B40C; extern MenuInputStruct gUnknown_202EE10; extern SpriteOAM gUnknown_202EDDC; -extern const u8 gUnknown_80F62AC[]; +extern const Rgb32 gUnknown_80F62AC; extern const struct UnkTextStruct2 gUnknown_80F62B0[]; extern const struct UnkTextStruct2 gUnknown_80F6310[]; extern const struct UnkTextStruct2 gUnknown_80F6370[]; @@ -85,52 +85,52 @@ void sub_803FF18(s32 a0, u16 *a1, bool8 a2); void sub_803E874(bool8 r10, s32 r9) { s32 i, index, count; - const u8 *colorArray; + const Rgb32 *color; - colorArray = gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, gUnknown_80F62AC, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + color = gDungeonPaletteFile->unk4; + SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index = 1; count = 159; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index++; } if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, (void *) &gDungeon->unk17C); + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); } index += 32; - colorArray = gUnknown_202ECA4; + color = gUnknown_202ECA4; count = 32; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index++; } if (r10) { index = 224; - colorArray = gDungeonNameBannerPalette->unk4; + color = gDungeonNameBannerPalette->unk4; count = 16; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, r9, NULL); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, r9, NULL); + color++; index++; } } - SetBGPaletteBufferColorRGB(248, gUnknown_202D058, gUnknown_202EDC8, NULL); + SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gUnknown_202EDC8, NULL); - colorArray = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; + color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; index = 256; count = 208; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - nullsub_4(index, colorArray, gUnknown_202EDC8, NULL); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + nullsub_4(index, color, gUnknown_202EDC8, NULL); + color++; index++; } } @@ -138,14 +138,14 @@ void sub_803E874(bool8 r10, s32 r9) void BgColorCallNullsub4(void) { s32 i, index, count; - const u8 *colorArray; + const Rgb32 *color; - colorArray = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; + color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; index = 256; count = 208; for (i = 0; i < count; i++) { - nullsub_4(index, colorArray, gUnknown_202EDC8, NULL); - colorArray += 4; + nullsub_4(index, color, gUnknown_202EDC8, NULL); + color++; index++; } } @@ -153,33 +153,33 @@ void BgColorCallNullsub4(void) void sub_803EA10(void) { s32 i, index, count; - const u8 *colorArray; + const Rgb32 *color; - colorArray = gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, gUnknown_80F62AC, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + color= gDungeonPaletteFile->unk4; + SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index = 1; count = 159; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index++; } if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, (void *) &gDungeon->unk17C); + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); } index += 32; - colorArray = gUnknown_202ECA4; + color = gUnknown_202ECA4; count = 32; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, colorArray, gUnknown_202EDC8, (void *) &gDungeon->unk17C); - colorArray += 4; + SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + color++; index++; } - SetBGPaletteBufferColorRGB(248, gUnknown_202D058, gUnknown_202EDC8, NULL); + SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gUnknown_202EDC8, NULL); } void sub_803EAF0(u32 a0, u8 *a1) diff --git a/src/weather.c b/src/weather.c index d90d326ab..3293f369f 100644 --- a/src/weather.c +++ b/src/weather.c @@ -51,8 +51,8 @@ void sub_807E5E4(u8 weather) gDungeon->weather.waterSportTurns = 0; for(index = 0; index < 0x100; index++) { - gDungeon->unk17C[index].unk0 = index; - gDungeon->unk17C[index].unk1 = index; - gDungeon->unk17C[index].unk2 = index; + gDungeon->colorRamp[index].r = index; + gDungeon->colorRamp[index].g = index; + gDungeon->colorRamp[index].b = index; } } diff --git a/sym_ewram.txt b/sym_ewram.txt index 1a5b5655e..348af6354 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1,7 +1,7 @@ .include "src/m4a.o" -gUnknown_2000A80: /* 2000A80 (GameLoop) */ +gTitleBrightness: /* 2000A80 (GameLoop) */ .space 0x8 gScriptVarBuffer: /* 2000A88 (ThoroughlyResetScriptVars - RestoreGlobalScriptVars) */ diff --git a/tmp/rgb.cocci b/tmp/rgb.cocci new file mode 100644 index 000000000..632700fc7 --- /dev/null +++ b/tmp/rgb.cocci @@ -0,0 +1,23 @@ +@@ +RGB e; +RGB *ep; +@@ +( +- e.unk0 ++ e.r +| +- e.unk1 ++ e.g +| +- e.unk2 ++ e.b +| +- ep->unk0 ++ ep->r +| +- ep->unk1 ++ ep->g +| +- ep->unk2 ++ ep->b +) From db96148da7b67fbae891182c0ea548344b1c4c1c Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:01:13 +0100 Subject: [PATCH 2/7] Cleanup sub_8004C00 --- src/code_8004AA0.c | 59 +++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/src/code_8004AA0.c b/src/code_8004AA0.c index 9bc2cefa0..43339e8dc 100644 --- a/src/code_8004AA0.c +++ b/src/code_8004AA0.c @@ -95,17 +95,14 @@ UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, return ret; } -bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, const Rgb32 *a4, s16 *a5) +bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const Rgb32 *ramp, s16 *a5) { bool8 ret; s32 i; - s32 r1; - s32 r3; - s32 r5; - u32 color32; - u32 val; - u32 val2; - u32 val3; + s32 r; + s32 g; + s32 b; + Rgb32 color; ret = FALSE; @@ -124,36 +121,28 @@ bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, const Rgb32 *a4 ret = TRUE; } - r1 = a5[0] + a0->unk14.r; - r3 = a5[1] + a0->unk14.g; - r5 = a5[2] + a0->unk14.b; + r = a5[0] + a0->unk14.r; + g = a5[1] + a0->unk14.g; + b = a5[2] + a0->unk14.b; - if (r1 > 0xFF) - r1 = 0xFF; - if (r3 > 0xFF) - r3 = 0xFF; - if (r5 > 0xFF) - r5 = 0xFF; - if (r1 < 0) - r1 = 0; - if (r3 < 0) - r3 = 0; - if (r5 < 0) - r5 = 0; + if (r > 0xFF) + r = 0xFF; + if (g > 0xFF) + g = 0xFF; + if (b > 0xFF) + b = 0xFF; + if (r < 0) + r = 0; + if (g < 0) + g = 0; + if (b < 0) + b = 0; - val = (u8)r1; - color32 &= 0xFFFFFF00; - color32 |= val; + color.r = r; + color.g = g; + color.b = b; - val2 = (u8)r3 << 8; - color32 &= 0xFFFF00FF; - color32 |= val2; - - val3 = (u8)r5 << 16; - color32 &= 0xFF00FFFF; - color32 |= val3; - - SetBGPaletteBufferColorRGB(a1, (Rgb32 *)&color32, a3, a4); + SetBGPaletteBufferColorRGB(a1, &color, brightness, ramp); } return ret; From 97048546c5cb0b66b8becb5f7f62c4e0009d2257 Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:04:11 +0100 Subject: [PATCH 3/7] pallete -> palette --- include/code_801D014.h | 2 +- src/code_801D014.c | 8 ++++---- src/load_screen.c | 6 +++--- src/personality_test1.c | 6 +++--- src/personality_test2.c | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/code_801D014.h b/include/code_801D014.h index 1c04c8a2c..1f7549319 100644 --- a/include/code_801D014.h +++ b/include/code_801D014.h @@ -28,7 +28,7 @@ struct unk_203B250 struct TeamBadgeData { /* 0x0 */ u8 *pics; // probably a pointer to an arrays of pixels? - /* 0x4 */ Rgb32 *pallete; // Pics share common pallete + /* 0x4 */ Rgb32 *palette; // Pics share common palette }; bool8 sub_801D014(PokemonStruct1 *); diff --git a/src/code_801D014.c b/src/code_801D014.c index 3e67b7096..6eb954e40 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -595,17 +595,17 @@ static void sub_801D894(void) static void LoadTeamRankBadge(u32 a0, u32 a1, u32 a2) { OpenedFile *teamBadgeFile; - s32 palleteIndex; + s32 paletteIndex; u8 rank; Rgb32 *colorArray; u8 *teamBadgePic; teamBadgeFile = OpenFileAndGetFileDataPtr(sTeamRankBadgeFileName, &gTitleMenuFileArchive); teamBadgePic = ((struct TeamBadgeData *)(teamBadgeFile->data))->pics; - colorArray = ((struct TeamBadgeData *)(teamBadgeFile->data))->pallete; + colorArray = ((struct TeamBadgeData *)(teamBadgeFile->data))->palette; - for (palleteIndex = 0; palleteIndex < 16; palleteIndex++) { - SetBGPaletteBufferColorArray(palleteIndex + 224, colorArray); + for (paletteIndex = 0; paletteIndex < 16; paletteIndex++) { + SetBGPaletteBufferColorArray(paletteIndex + 224, colorArray); colorArray++; } diff --git a/src/load_screen.c b/src/load_screen.c index 8a5f57dd4..c8c73ea1f 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -365,11 +365,11 @@ void DrawLoadScreenText(void) sub_80073E0(0); } -// Think structure of clmkFile is like Team Rank Badges except each pic has a diff pallete +// Think structure of clmkFile is like Team Rank Badges except each pic has a diff palette struct ClmkFileData { /* 0x0 */ u32 *pics; - /* 0x4 */ Rgb32 *pallete; + /* 0x4 */ Rgb32 *palette; }; void sub_80397B4(void) @@ -383,7 +383,7 @@ void sub_80397B4(void) for(index = 0; index < 64; index++) { - SetBGPaletteBufferColorArray(index + 176, &((struct ClmkFileData *)(clmkFile->data))->pallete[index]); + SetBGPaletteBufferColorArray(index + 176, &((struct ClmkFileData *)(clmkFile->data))->palette[index]); } x = 8; diff --git a/src/personality_test1.c b/src/personality_test1.c index 481acb4d1..499895066 100644 --- a/src/personality_test1.c +++ b/src/personality_test1.c @@ -384,7 +384,7 @@ static void PersonalityTest_DisplayStarterSprite(void) { s32 starterID; struct OpenedFile *faceFile; - s32 palleteIndex; + s32 paletteIndex; s32 emotionId; const u8 *gfx; UnkTextStruct2 stackArray[4]; @@ -400,8 +400,8 @@ static void PersonalityTest_DisplayStarterSprite(void) faceFile = GetDialogueSpriteDataPtr(starterID); gfx = ((struct PortraitGfx *)(faceFile->data))->sprites[EMOTION_HAPPY].gfx; emotionId = EMOTION_HAPPY; - for (palleteIndex = 0; palleteIndex < 0x10; palleteIndex++) { - SetBGPaletteBufferColorArray(palleteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[palleteIndex]); + for (paletteIndex = 0; paletteIndex < 0x10; paletteIndex++) { + SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); } DisplayMonPortraitSpriteFlipped(1, gfx, 14); diff --git a/src/personality_test2.c b/src/personality_test2.c index 0c2334dc8..b6d030376 100644 --- a/src/personality_test2.c +++ b/src/personality_test2.c @@ -245,7 +245,7 @@ static void PersonalityTest_DisplayPartnerSprite(void) { s32 partnerID; struct OpenedFile *faceFile; - s32 palleteIndex; + s32 paletteIndex; const u8 *gfx; s32 emotionId; @@ -255,8 +255,8 @@ static void PersonalityTest_DisplayPartnerSprite(void) faceFile = GetDialogueSpriteDataPtr(partnerID); gfx = ((struct PortraitGfx *)(faceFile->data))->sprites[EMOTION_NORMAL].gfx; emotionId = EMOTION_NORMAL; - for (palleteIndex = 0; palleteIndex < 0x10; palleteIndex++) { - SetBGPaletteBufferColorArray(palleteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[palleteIndex]); + for (paletteIndex = 0; paletteIndex < 0x10; paletteIndex++) { + SetBGPaletteBufferColorArray(paletteIndex + 0xE0, &((struct PortraitGfx *)(faceFile->data))->sprites[emotionId].pal[paletteIndex]); } DisplayMonPortraitSpriteFlipped(1, gfx, 14); From d94422641d6b9a53901fc6cfef819dc326af49f8 Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:22:15 +0100 Subject: [PATCH 4/7] Clean tmp files --- tmp/rgb.cocci | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 tmp/rgb.cocci diff --git a/tmp/rgb.cocci b/tmp/rgb.cocci deleted file mode 100644 index 632700fc7..000000000 --- a/tmp/rgb.cocci +++ /dev/null @@ -1,23 +0,0 @@ -@@ -RGB e; -RGB *ep; -@@ -( -- e.unk0 -+ e.r -| -- e.unk1 -+ e.g -| -- e.unk2 -+ e.b -| -- ep->unk0 -+ ep->r -| -- ep->unk1 -+ ep->g -| -- ep->unk2 -+ ep->b -) From 021809df3f567641e99baf5dc1aafd8cbf33f064 Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:24:19 +0100 Subject: [PATCH 5/7] Improve comments --- include/code_800558C.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/code_800558C.h b/include/code_800558C.h index ec1b4b577..e16e166d0 100644 --- a/include/code_800558C.h +++ b/include/code_800558C.h @@ -5,7 +5,7 @@ #include "structs/axdata.h" #include "file_system.h" -// size: ? 0x20 for now +// size: 0x20 struct axMapSprite { axmain axmain; From d950923709f5c2301c2a8cbfe908ca2b1fb31368 Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:26:55 +0100 Subject: [PATCH 6/7] Rgb32 back to RGB --- include/bg_palette_buffer.h | 8 ++++---- include/code_8004AA0.h | 12 ++++++------ include/code_800558C.h | 6 +++--- include/code_8009804.h | 2 +- include/code_801D014.h | 2 +- include/string_format.h | 2 +- include/structs/rgb.h | 6 +++--- include/structs/str_dungeon.h | 2 +- src/bg_palette_buffer.c | 8 ++++---- src/code_2.c | 4 ++-- src/code_8004AA0.c | 8 ++++---- src/code_800558C.c | 18 +++++++++--------- src/code_8009804.c | 4 ++-- src/code_801D014.c | 2 +- src/code_803D110.c | 4 ++-- src/code_803E724.c | 12 ++++++------ src/code_8042B34.c | 2 +- src/game_options.c | 2 +- src/load_screen.c | 2 +- 19 files changed, 53 insertions(+), 53 deletions(-) diff --git a/include/bg_palette_buffer.h b/include/bg_palette_buffer.h index 2b10e90b6..ab3593aec 100644 --- a/include/bg_palette_buffer.h +++ b/include/bg_palette_buffer.h @@ -4,10 +4,10 @@ #include "structs/rgb.h" void InitBGPaletteBuffer(void); -void nullsub_4(s32 index, const Rgb32 *color, s32 brightness, const Rgb32 *ramp); -void nullsub_5(s32 index, const Rgb32 *color); -void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color); -void SetBGPaletteBufferColorRGB(s32 index, const Rgb32 *color, s32 brightness, const Rgb32 *ramp); +void nullsub_4(s32 index, const RGB *color, s32 brightness, const RGB *ramp); +void nullsub_5(s32 index, const RGB *color); +void SetBGPaletteBufferColorArray(s32 index, const RGB *color); +void SetBGPaletteBufferColorRGB(s32 index, const RGB *color, s32 brightness, const RGB *ramp); void TransferBGPaletteBuffer(void); #endif // GUARD_BG_PALETTE_BUFFER_H diff --git a/include/code_8004AA0.h b/include/code_8004AA0.h index 5d2b18dd4..8c6d517b7 100644 --- a/include/code_8004AA0.h +++ b/include/code_8004AA0.h @@ -10,10 +10,10 @@ typedef struct unkStruct_202EE8C u32 unk0; u16 unk4; s16 unk6; - Rgb32 *unk8; - Rgb32 *unkC; - Rgb32 *unk10; - Rgb32 unk14; + RGB *unk8; + RGB *unkC; + RGB *unk10; + RGB unk14; } unkStruct_202EE8C; extern unkStruct_202EE8C gUnknown_202EE8C[32]; @@ -37,12 +37,12 @@ typedef struct unkDataFor8004AA4 { /* 0x0 */ s16 colorCount; s16 unk2; - /* 0x4 */ Rgb32 colors[0]; + /* 0x4 */ RGB colors[0]; } unkDataFor8004AA4; void nullsub_6(void); void sub_8004AA4(unkStruct_202EE8C *, OpenedFile *, s32); -bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, const Rgb32 *); +bool8 sub_8004AF0(bool8, unkStruct_202EE8C *, s32, s32, s32, const RGB *); bool8 sub_8004D14(unkStruct_202EE8C *, s32); bool8 sub_8004D40(unkStruct_202EE8C *, s32); diff --git a/include/code_800558C.h b/include/code_800558C.h index e16e166d0..463e0e2b1 100644 --- a/include/code_800558C.h +++ b/include/code_800558C.h @@ -10,7 +10,7 @@ struct axMapSprite { axmain axmain; const u32 *tiles; - const Rgb32 *pal; + const RGB *pal; s32 tileCount; }; @@ -23,8 +23,8 @@ void nullsub_10(bool8); void nullsub_12(void); void nullsub_13(void); void nullsub_14(void); -void sub_8005610(OpenedFile *, s32, s32, const Rgb32 *); -void sub_8005770(s32, const Rgb32 *color, s32, const Rgb32 *ramp); +void sub_8005610(OpenedFile *, s32, s32, const RGB *); +void sub_8005770(s32, const RGB *color, s32, const RGB *ramp); void sub_80057E8(void); void sub_8005838(s32 *, u8 kind); void sub_80060EC(void); diff --git a/include/code_8009804.h b/include/code_8009804.h index b161ef8b4..d8509046a 100644 --- a/include/code_8009804.h +++ b/include/code_8009804.h @@ -19,6 +19,6 @@ void sub_80098BC(u32 *, const u32 *, u32); void sub_80098F8(u32); void sub_8009908(void); void sub_80099C0(void); -void sub_80099F0(Rgb32); +void sub_80099F0(RGB); #endif // GUARD_CODE_8009804_H diff --git a/include/code_801D014.h b/include/code_801D014.h index 1f7549319..63168f5b7 100644 --- a/include/code_801D014.h +++ b/include/code_801D014.h @@ -28,7 +28,7 @@ struct unk_203B250 struct TeamBadgeData { /* 0x0 */ u8 *pics; // probably a pointer to an arrays of pixels? - /* 0x4 */ Rgb32 *palette; // Pics share common palette + /* 0x4 */ RGB *palette; // Pics share common palette }; bool8 sub_801D014(PokemonStruct1 *); diff --git a/include/string_format.h b/include/string_format.h index 185897ed6..0dd5e875a 100644 --- a/include/string_format.h +++ b/include/string_format.h @@ -20,7 +20,7 @@ void sub_80155F0(void); struct PortraitGfxSub { - const Rgb32 *pal; + const RGB *pal; const u8 *gfx; }; diff --git a/include/structs/rgb.h b/include/structs/rgb.h index b76eb7d61..8bdd6058f 100644 --- a/include/structs/rgb.h +++ b/include/structs/rgb.h @@ -1,16 +1,16 @@ #ifndef GUARD_RGB_H #define GUARD_RGB_H -typedef struct Rgb32 +typedef struct RGB { u8 r; u8 g; u8 b; -} Rgb32; +} RGB; typedef struct Palette32 { - Rgb32 pal[16]; + RGB pal[16]; } Palette32; #endif // GUARD_RGB_H diff --git a/include/structs/str_dungeon.h b/include/structs/str_dungeon.h index c84fc992e..c7daddb1b 100644 --- a/include/structs/str_dungeon.h +++ b/include/structs/str_dungeon.h @@ -259,7 +259,7 @@ typedef struct Dungeon Entity *unkBC; u8 fillC0[0x134 - 0xC0]; struct unkStruct_Dungeon134_sub unk134; - Rgb32 colorRamp[0x100]; + RGB colorRamp[0x100]; /* 0x57C */ u8 fill57C[0x5C0 - 0x57c]; /* 0x5C0 */ s32 unk5C0; /* 0x5C4 */ struct unkStruct_Dungeon5C4_sub unk5C4[3]; diff --git a/src/bg_palette_buffer.c b/src/bg_palette_buffer.c index bb2c6c798..c47699ca6 100644 --- a/src/bg_palette_buffer.c +++ b/src/bg_palette_buffer.c @@ -21,7 +21,7 @@ void InitBGPaletteBuffer(void) } } -void SetBGPaletteBufferColorRGB(s32 index, const Rgb32 *color, s32 brightnessRaw, const Rgb32 *ramp) +void SetBGPaletteBufferColorRGB(s32 index, const RGB *color, s32 brightnessRaw, const RGB *ramp) { s32 brightness = brightnessRaw; @@ -44,7 +44,7 @@ void SetBGPaletteBufferColorRGB(s32 index, const Rgb32 *color, s32 brightnessRaw ramp[color->b].b * brightness / 256 & 0x1F); } -void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color32) +void SetBGPaletteBufferColorArray(s32 index, const RGB *color32) { sBGPaletteRowDirty[index / BG_PALETTE_ROW_SIZE] = TRUE; sBGPaletteBuffer[index] = RGB2(color32->r >> 3, color32->g >> 3, color32->b >> 3); @@ -56,11 +56,11 @@ void SetBGPaletteBufferColor(s32 index, u16 *color) sBGPaletteBuffer[index] = *color; } -void nullsub_4(s32 index, const Rgb32 *colorArray, s32 brightness, const Rgb32 *ramp) +void nullsub_4(s32 index, const RGB *colorArray, s32 brightness, const RGB *ramp) { } -void nullsub_5(s32 index, const Rgb32 *colorArray) +void nullsub_5(s32 index, const RGB *colorArray) { } diff --git a/src/code_2.c b/src/code_2.c index 6fc5effa5..15f81e89a 100644 --- a/src/code_2.c +++ b/src/code_2.c @@ -108,7 +108,7 @@ void GameLoop(void) s32 i; gTitleBrightness++; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &((Rgb32*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); + SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); xxx_update_stuff(0); } if (tmp3) { @@ -149,7 +149,7 @@ void GameLoop(void) s32 i; gTitleBrightness--; for (i = 0; i < 240; i++) - SetBGPaletteBufferColorRGB(i, &((Rgb32*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); + SetBGPaletteBufferColorRGB(i, &((RGB*)gTitlePaletteFile->data)[i], gTitleBrightness, NULL); xxx_update_stuff(0); } CloseFile(gTitlePaletteFile); diff --git a/src/code_8004AA0.c b/src/code_8004AA0.c index 43339e8dc..cac7766cd 100644 --- a/src/code_8004AA0.c +++ b/src/code_8004AA0.c @@ -31,7 +31,7 @@ void sub_8004AA4(unkStruct_202EE8C *a0, OpenedFile *a1, s32 a2) } } -bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const Rgb32 *a5) +bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const RGB *a5) { bool8 bVar3; bool8 ret; @@ -63,7 +63,7 @@ bool8 sub_8004AF0(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const return ret; } -UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const Rgb32 *a5) +UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, s32 a4, const RGB *a5) { bool8 bVar3; bool8 ret; @@ -95,14 +95,14 @@ UNUSED static bool8 sub_8004B78(bool8 a0, unkStruct_202EE8C *a1, s32 a2, s32 a3, return ret; } -bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const Rgb32 *ramp, s16 *a5) +bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 brightness, const RGB *ramp, s16 *a5) { bool8 ret; s32 i; s32 r; s32 g; s32 b; - Rgb32 color; + RGB color; ret = FALSE; diff --git a/src/code_800558C.c b/src/code_800558C.c index 8aaf3ad24..b62d47d72 100644 --- a/src/code_800558C.c +++ b/src/code_800558C.c @@ -31,8 +31,8 @@ extern const s16 gUnknown_80B83EA[16 * 10]; extern s32 sin_abs_4096(s32); extern s32 cos_4096(s32); -static void sub_800561C(struct axMapSprite *, s32, s32, const Rgb32 *); -const Rgb32 *sub_8005674(struct axMapSprite *, s32); +static void sub_800561C(struct axMapSprite *, s32, s32, const RGB *); +const RGB *sub_8005674(struct axMapSprite *, s32); void DoAxFrame_800558C(struct axObject *a0, s32 spriteX, s32 spriteY, u32 a3, u32 paletteNum, u16 *spriteMasks) { @@ -56,12 +56,12 @@ void DoAxFrame_800558C(struct axObject *a0, s32 spriteX, s32 spriteY, u32 a3, u3 a0->axdata.flags &= 0xF7FF; } -void sub_8005610(OpenedFile *a0, s32 vramIdx, s32 brightness, const Rgb32 *ramp) +void sub_8005610(OpenedFile *a0, s32 vramIdx, s32 brightness, const RGB *ramp) { sub_800561C((struct axMapSprite *)a0->data, vramIdx, brightness, ramp); } -static void sub_800561C(struct axMapSprite *a0, s32 vramIdx, s32 brightness, const Rgb32 *ramp) +static void sub_800561C(struct axMapSprite *a0, s32 vramIdx, s32 brightness, const RGB *ramp) { s32 i; @@ -74,12 +74,12 @@ static void sub_800561C(struct axMapSprite *a0, s32 vramIdx, s32 brightness, con } } -UNUSED static const Rgb32 *sub_8005668(OpenedFile *a0, s32 vramIdx) +UNUSED static const RGB *sub_8005668(OpenedFile *a0, s32 vramIdx) { return sub_8005674((struct axMapSprite *)a0->data, vramIdx); } -const Rgb32 *sub_8005674(struct axMapSprite *a0, s32 vramIdx) +const RGB *sub_8005674(struct axMapSprite *a0, s32 vramIdx) { if (a0->tiles != NULL) CpuCopy(OBJ_VRAM0 + vramIdx * 0x20, a0->tiles, a0->tileCount * 0x20); @@ -149,12 +149,12 @@ void sub_8005700(Position *a0, struct axObject *a1) } } -UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, const Rgb32 *a3) +UNUSED static void sub_8005764(s32 a0, OpenedFile *file, s32 a2, const RGB *a3) { - sub_8005770(a0, (const Rgb32*)file->data, a2, a3); + sub_8005770(a0, (const RGB*)file->data, a2, a3); } -void sub_8005770(s32 param_1, const Rgb32 *color, s32 brightness, const Rgb32 *ramp) +void sub_8005770(s32 param_1, const RGB *color, s32 brightness, const RGB *ramp) { s32 i; diff --git a/src/code_8009804.c b/src/code_8009804.c index dcc39f0bd..60061638e 100644 --- a/src/code_8009804.c +++ b/src/code_8009804.c @@ -20,7 +20,7 @@ void InitFontPalette(void) { OpenedFile *fontpalFile; s32 i; - Rgb32 *ptr; + RGB *ptr; fontpalFile = OpenFileAndGetFileDataPtr(gUnknown_80B88CC, &gSystemFileArchive); // fontpal CpuCopy(gFontPalette, fontpalFile->data, sizeof(gFontPalette)); @@ -126,7 +126,7 @@ void sub_80099C0(void) CpuCopy(BG_SCREEN_ADDR(13), gUnknown_202B038[1], BG_SCREEN_SIZE); } -void sub_80099F0(Rgb32 a0) +void sub_80099F0(RGB a0) { s32 i; diff --git a/src/code_801D014.c b/src/code_801D014.c index 6eb954e40..3a524e986 100644 --- a/src/code_801D014.c +++ b/src/code_801D014.c @@ -597,7 +597,7 @@ static void LoadTeamRankBadge(u32 a0, u32 a1, u32 a2) OpenedFile *teamBadgeFile; s32 paletteIndex; u8 rank; - Rgb32 *colorArray; + RGB *colorArray; u8 *teamBadgePic; teamBadgeFile = OpenFileAndGetFileDataPtr(sTeamRankBadgeFileName, &gTitleMenuFileArchive); diff --git a/src/code_803D110.c b/src/code_803D110.c index dabddea5e..937591752 100644 --- a/src/code_803D110.c +++ b/src/code_803D110.c @@ -546,7 +546,7 @@ struct DungeonNameFontFileData struct DungeonNamePaletteFileData { - Rgb32 pal[16]; + RGB pal[16]; }; void ShowDungeonNameBanner(void) @@ -1050,7 +1050,7 @@ NAKED void sub_803E02C(void) void sub_803E13C(void) { s32 i; - Rgb32 *pal; + RGB *pal; SetWindowBGColor(); if (gGameOptionsRef->playerGender != 0) diff --git a/src/code_803E724.c b/src/code_803E724.c index f881827b2..c48260830 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -37,13 +37,13 @@ struct DungeonPalFile extern struct DungeonPalFile *gDungeonPaletteFile; extern struct DungeonPalFile *gDungeonNameBannerPalette; extern struct DungeonPalFile *gUnknown_202EC94; -extern Rgb32 gUnknown_202ECA4[]; -extern Rgb32 gUnknown_202D058; +extern RGB gUnknown_202ECA4[]; +extern RGB gUnknown_202D058; extern u8 gUnknown_203B40C; extern MenuInputStruct gUnknown_202EE10; extern SpriteOAM gUnknown_202EDDC; -extern const Rgb32 gUnknown_80F62AC; +extern const RGB gUnknown_80F62AC; extern const struct UnkTextStruct2 gUnknown_80F62B0[]; extern const struct UnkTextStruct2 gUnknown_80F6310[]; extern const struct UnkTextStruct2 gUnknown_80F6370[]; @@ -85,7 +85,7 @@ void sub_803FF18(s32 a0, u16 *a1, bool8 a2); void sub_803E874(bool8 r10, s32 r9) { s32 i, index, count; - const Rgb32 *color; + const RGB *color; color = gDungeonPaletteFile->unk4; SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); @@ -138,7 +138,7 @@ void sub_803E874(bool8 r10, s32 r9) void BgColorCallNullsub4(void) { s32 i, index, count; - const Rgb32 *color; + const RGB *color; color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; index = 256; @@ -153,7 +153,7 @@ void BgColorCallNullsub4(void) void sub_803EA10(void) { s32 i, index, count; - const Rgb32 *color; + const RGB *color; color= gDungeonPaletteFile->unk4; SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); diff --git a/src/code_8042B34.c b/src/code_8042B34.c index b4019b80c..e2fe1701c 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -416,7 +416,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) bool8 r9; bool8 r10; u8 sp; - Rgb32 colorArray; + RGB colorArray; gUnknown_203B40C = 0; r6 = r8->unk8; diff --git a/src/game_options.c b/src/game_options.c index aeb8f349c..9158f5231 100644 --- a/src/game_options.c +++ b/src/game_options.c @@ -191,7 +191,7 @@ void ReadGameOptions(struct unkStruct_8094924 *param_1) void SetWindowBGColor(void) { - struct Rgb32 winColors[] = { + struct RGB winColors[] = { {0x20, 0x48, 0x68}, // Blue {0x80, 0x38, 0x20}, // Red {0x28, 0x80, 0x48}, // Green diff --git a/src/load_screen.c b/src/load_screen.c index c8c73ea1f..cd2094511 100644 --- a/src/load_screen.c +++ b/src/load_screen.c @@ -369,7 +369,7 @@ void DrawLoadScreenText(void) struct ClmkFileData { /* 0x0 */ u32 *pics; - /* 0x4 */ Rgb32 *palette; + /* 0x4 */ RGB *palette; }; void sub_80397B4(void) From 6b87f66106e0ce23de23e4b30799184ab2d2b62e Mon Sep 17 00:00:00 2001 From: Mateon1 Date: Fri, 1 Nov 2024 15:36:25 +0100 Subject: [PATCH 7/7] Clean up void casts --- asm/code_803D110.s | 2 +- asm/code_8040094.s | 2 +- asm/code_8085B80.s | 2 +- src/code_802DB28.c | 2 +- src/code_803E46C.c | 20 ++++++++++---------- src/code_803E724.c | 28 ++++++++++++++-------------- src/code_8041AD0.c | 12 ++++++------ src/code_8042B34.c | 14 +++++++------- src/code_80869E4.c | 8 ++++---- src/dungeon_cutscenes.c | 12 ++++++------ src/dungeon_message.c | 12 ++++++------ src/felicity_bank.c | 2 +- src/gulpin_shop.c | 2 +- src/gulpin_shop_801FB50.c | 2 +- src/kangaskhan_storage1.c | 2 +- src/kecleon_bros1.c | 2 +- src/makuhita_dojo1.c | 2 +- src/mission_reward.c | 2 +- src/post_office_guide1.c | 2 +- src/save_write.c | 2 +- src/thank_you_wonder_mail.c | 2 +- src/wigglytuff_shop3.c | 2 +- src/wonder_mail.c | 2 +- src/wonder_mail_2.c | 2 +- src/wonder_mail_6.c | 2 +- sym_ewram.txt | 2 +- 26 files changed, 72 insertions(+), 72 deletions(-) diff --git a/asm/code_803D110.s b/asm/code_803D110.s index e7f0bdf5d..e081c6be1 100644 --- a/asm/code_803D110.s +++ b/asm/code_803D110.s @@ -249,6 +249,6 @@ _0803E454: .4byte gUnknown_80F61EC _0803E458: .4byte gDungeon _0803E45C: .4byte 0x00018217 _0803E460: .4byte 0x00018218 -_0803E464: .4byte gUnknown_202EDC8 +_0803E464: .4byte gDungeonBrightness _0803E468: .4byte gUnknown_202D058 thumb_func_end sub_803E250 diff --git a/asm/code_8040094.s b/asm/code_8040094.s index 901f1929a..50633499f 100644 --- a/asm/code_8040094.s +++ b/asm/code_8040094.s @@ -1566,7 +1566,7 @@ _08040D48: _08040D58: .4byte gUnknown_203B40D _08040D5C: .4byte gUnknown_2026E4E _08040D60: .4byte 0x00000101 -_08040D64: .4byte gUnknown_202EDC8 +_08040D64: .4byte gDungeonBrightness _08040D68: movs r0, 0 str r0, [r1] diff --git a/asm/code_8085B80.s b/asm/code_8085B80.s index b79af6f97..f9f27fd90 100644 --- a/asm/code_8085B80.s +++ b/asm/code_8085B80.s @@ -411,7 +411,7 @@ _08085E70: .4byte gDungeonPaletteFile _08085E74: .4byte 0xffffff00 _08085E78: .4byte 0xffff00ff _08085E7C: .4byte 0xff00ffff -_08085E80: .4byte gUnknown_202EDC8 +_08085E80: .4byte gDungeonBrightness _08085E84: .4byte gDungeon _08085E88: .4byte 0xffff0000 _08085E8C: .4byte gUnknown_202EE8C diff --git a/src/code_802DB28.c b/src/code_802DB28.c index 0197d58ca..d50cf01ed 100644 --- a/src/code_802DB28.c +++ b/src/code_802DB28.c @@ -52,7 +52,7 @@ bool8 sub_802DB28(u8 jobSlotIndex, u8 dungeon) sUnknown_203B2FC->monPortrait.pos.y = 8; if (sUnknown_203B2FC->monPortrait.faceFile != NULL) - sUnknown_203B2FC->monPortrait.faceData = (void *) sUnknown_203B2FC->monPortrait.faceFile->data; + sUnknown_203B2FC->monPortrait.faceData = (struct PortraitGfx *) sUnknown_203B2FC->monPortrait.faceFile->data; sub_802DC28(0); return TRUE; diff --git a/src/code_803E46C.c b/src/code_803E46C.c index e65ab6b13..cf05240e0 100644 --- a/src/code_803E46C.c +++ b/src/code_803E46C.c @@ -18,7 +18,7 @@ extern u8 gUnknown_203B40C; extern u8 gUnknown_203B40D; -extern s32 gUnknown_202EDC8; +extern s32 gDungeonBrightness; extern s32 gUnknown_202EDCC; extern u32 gUnknown_202EDD0; extern s32 gUnknown_202EDD4; @@ -87,7 +87,7 @@ void sub_803E490(u32 unused) if(gDungeon->unk181e8.unk18215 != 0 && gDungeon->unk1BDD4.unk1C06C != 3) - sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); + sub_8004AF0(gUnknown_203B40D, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); nullsub_8(gGameOptionsRef->unkA); sub_8005180(); @@ -169,7 +169,7 @@ void sub_803E748(void) { index2 = 0x1F; gUnknown_203B40D = 1; - gUnknown_202EDC8 = 0; + gDungeonBrightness = 0; sub_803E874(1, 0x1F); @@ -186,13 +186,13 @@ void sub_803E748(void) { } } if(index1 > 0xB) - if(gUnknown_202EDC8 <= 0x1E) - gUnknown_202EDC8++; + if(gDungeonBrightness <= 0x1E) + gDungeonBrightness++; sub_803E874(1, index2); sub_803E46C(5); } gUnknown_203B40D = 0; - gUnknown_202EDC8 = 0x1F; + gDungeonBrightness = 0x1F; } void sub_803E7C8(void) @@ -203,7 +203,7 @@ void sub_803E7C8(void) index2 = 0x1F; gUnknown_203B40D = 1; - gUnknown_202EDC8 = 0; + gDungeonBrightness = 0; sub_803E46C(5); @@ -234,9 +234,9 @@ void sub_803E830(void) { sub_803E874(0, 0); sub_803E46C(5); - if(gUnknown_202EDC8 > 0) - gUnknown_202EDC8--; + if(gDungeonBrightness > 0) + gDungeonBrightness--; } - gUnknown_202EDC8 = 0; + gDungeonBrightness = 0; gUnknown_203B40D = 0; } diff --git a/src/code_803E724.c b/src/code_803E724.c index c48260830..0a5f9dfab 100644 --- a/src/code_803E724.c +++ b/src/code_803E724.c @@ -23,7 +23,7 @@ #include "constants/item.h" #include "constants/status.h" -extern s32 gUnknown_202EDC8; +extern s32 gDungeonBrightness; extern u32 gUnknown_202EDD0; extern s32 gUnknown_202EDD8; extern u32 gUnknown_202EDFC; @@ -88,25 +88,25 @@ void sub_803E874(bool8 r10, s32 r9) const RGB *color; color = gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gDungeonBrightness, gDungeon->colorRamp); color++; index = 1; count = 159; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); color++; index++; } if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); } index += 32; color = gUnknown_202ECA4; count = 32; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); color++; index++; } @@ -122,14 +122,14 @@ void sub_803E874(bool8 r10, s32 r9) } } - SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gUnknown_202EDC8, NULL); + SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gDungeonBrightness, NULL); color = ((struct DungeonPalFile*) gDungeon->paletFile)->unk4; index = 256; count = 208; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); - nullsub_4(index, color, gUnknown_202EDC8, NULL); + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); + nullsub_4(index, color, gDungeonBrightness, NULL); color++; index++; } @@ -144,7 +144,7 @@ void BgColorCallNullsub4(void) index = 256; count = 208; for (i = 0; i < count; i++) { - nullsub_4(index, color, gUnknown_202EDC8, NULL); + nullsub_4(index, color, gDungeonBrightness, NULL); color++; index++; } @@ -156,30 +156,30 @@ void sub_803EA10(void) const RGB *color; color= gDungeonPaletteFile->unk4; - SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(0, &gUnknown_80F62AC, gDungeonBrightness, gDungeon->colorRamp); color++; index = 1; count = 159; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); color++; index++; } if (gDungeon->unk181e8.unk18215 == 0 || gDungeon->unk1BDD4.unk1C06C == 3) { - sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gUnknown_202EDC8, gDungeon->colorRamp); + sub_8004AF0(TRUE, gUnknown_202EE8C, 0xA0, 0x20, gDungeonBrightness, gDungeon->colorRamp); } index += 32; color = gUnknown_202ECA4; count = 32; for (i = 0; i < count; i++) { - SetBGPaletteBufferColorRGB(index, color, gUnknown_202EDC8, gDungeon->colorRamp); + SetBGPaletteBufferColorRGB(index, color, gDungeonBrightness, gDungeon->colorRamp); color++; index++; } - SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gUnknown_202EDC8, NULL); + SetBGPaletteBufferColorRGB(248, &gUnknown_202D058, gDungeonBrightness, NULL); } void sub_803EAF0(u32 a0, u8 *a1) diff --git a/src/code_8041AD0.c b/src/code_8041AD0.c index 1166e99a9..ad6964532 100644 --- a/src/code_8041AD0.c +++ b/src/code_8041AD0.c @@ -40,7 +40,7 @@ extern void sub_8041550(Entity *pokemon, u32, u32, u32, u32, u32); void sub_80421C0(Entity *pokemon, u16 r1); void EntityUpdateStatusSprites(Entity *entity); -extern s32 gUnknown_202EDC8; +extern s32 gDungeonBrightness; extern u8 gUnknown_203B40D; extern s16 gUnknown_2026E4E; @@ -119,23 +119,23 @@ void sub_804178C(u8 param_1) if ((counter == 1000) || (param_1 != 0)) { sub_800DBBC(); } - if (gUnknown_202EDC8 < 0x1f) { + if (gDungeonBrightness < 0x1f) { temp = gUnknown_203B40D; gUnknown_203B40D = 1; for(counter = 0; counter < 1000; counter++) { - if (gUnknown_202EDC8 < 0x1f) { - gUnknown_202EDC8 += 4; + if (gDungeonBrightness < 0x1f) { + gDungeonBrightness += 4; if (gUnknown_2026E4E != 0x808) { gUnknown_2026E4E -= 0x101; } } else { - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; } sub_803EA10(); sub_803E46C(0x4a); - if(gUnknown_202EDC8 == 0x1f) break; + if(gDungeonBrightness == 0x1f) break; }; gUnknown_2026E4E = 0x808; gUnknown_203B40D = temp; diff --git a/src/code_8042B34.c b/src/code_8042B34.c index e2fe1701c..5fdc960d7 100644 --- a/src/code_8042B34.c +++ b/src/code_8042B34.c @@ -384,7 +384,7 @@ extern void sub_8042B0C(Entity *); extern s16 gUnknown_2026E4E; extern u8 gUnknown_202F32C; extern u8 gUnknown_202F1A8; -extern s32 gUnknown_202EDC8; +extern s32 gDungeonBrightness; extern Entity *gLeaderPointer; void sub_8044124(void); @@ -416,7 +416,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) bool8 r9; bool8 r10; u8 sp; - RGB colorArray; + RGB color; gUnknown_203B40C = 0; r6 = r8->unk8; @@ -631,7 +631,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) } sub_8049840(); sub_803E178(); - gUnknown_202EDC8 = 0; + gDungeonBrightness = 0; sub_8040124(); sub_803EAF0(4, 0); sub_8052210(0); @@ -806,10 +806,10 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8) } SetBGOBJEnableFlags(0); - colorArray.r = 0x60; - colorArray.g = 0x80; - colorArray.b = 0xF8; - SetBGPaletteBufferColorRGB(253, (void*) &colorArray, gUnknown_202EDC8, 0); // Todo: Fix SetBGPaletteBufferColorRGB to take RGB* + color.r = 0x60; + color.g = 0x80; + color.b = 0xF8; + SetBGPaletteBufferColorRGB(253, &color, gDungeonBrightness, NULL); sub_8040094(1); gDungeon->unk181e8.unk18218 = 1; if ((gDungeon->unk10 == 2 || gDungeon->unk10 == 3) && gDungeon->unk6 != 0) { diff --git a/src/code_80869E4.c b/src/code_80869E4.c index b7fcf7c7e..b11838214 100644 --- a/src/code_80869E4.c +++ b/src/code_80869E4.c @@ -12,7 +12,7 @@ // This file may originally be merged with code_8086A3C.c and code_8057824_1.c // ??? -extern u32 gUnknown_202EDC8; +extern u32 gDungeonBrightness; EWRAM_DATA unkStruct_202F3D0 gUnknown_202F3D0 = {0}; @@ -342,7 +342,7 @@ void sub_8086794(void) { s32 i; - gUnknown_202EDC8 = 0; + gDungeonBrightness = 0; for (i = 0; i < 200; i++) { SetDungeonBGColorRGB(0, 0, 0, 1, 0); @@ -350,8 +350,8 @@ void sub_8086794(void) sub_803E46C(70); if ((i & 3) == 0) { - gUnknown_202EDC8++; - if (gUnknown_202EDC8 == 31) + gDungeonBrightness++; + if (gDungeonBrightness == 31) break; } } diff --git a/src/dungeon_cutscenes.c b/src/dungeon_cutscenes.c index 66fa03047..84e3eb41a 100644 --- a/src/dungeon_cutscenes.c +++ b/src/dungeon_cutscenes.c @@ -30,7 +30,7 @@ #include "exclusive_pokemon.h" #include "trap.h" -extern u32 gUnknown_202EDC8; +extern u32 gDungeonBrightness; extern const s16 gUnknown_80F57CA; extern const s16 gUnknown_80F57CC; @@ -3554,7 +3554,7 @@ void LatiosScreenFlash(void) s32 iVar1; PlaySoundEffect(0x1ee); - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; for(iVar1 = 250; iVar1 > 149; iVar1 -= 10) { SetDungeonBGColorRGB(iVar1,iVar1,iVar1,1,1); @@ -4195,7 +4195,7 @@ void JirachiWishGrantFlash(void) s32 iVar1; PlaySoundEffect(0x2c1); - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; for(iVar1 = 0xFA; iVar1 > 0x95; iVar1 -= 10) { @@ -4493,7 +4493,7 @@ void LugiaScreenFlash2(void) void sub_808C0CC(void) { - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; SetDungeonBGColorRGB(0,0,0,1,1); BgColorCallNullsub4(); sub_803E46C(0x46); @@ -4614,7 +4614,7 @@ void KyogreScreenFlash(void) void sub_808C360(void) { - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; SetDungeonBGColorRGB(0,0,0,1,1); BgColorCallNullsub4(); sub_803E46C(0x46); @@ -4701,7 +4701,7 @@ void DeoxysScreenFlash(void) void sub_808C550(void) { - gUnknown_202EDC8 = 0x1f; + gDungeonBrightness = 0x1f; SetDungeonBGColorRGB(0,0,0,1,1); BgColorCallNullsub4(); sub_803E46C(0x46); diff --git a/src/dungeon_message.c b/src/dungeon_message.c index a8eb7a6b2..3d331311b 100644 --- a/src/dungeon_message.c +++ b/src/dungeon_message.c @@ -376,7 +376,7 @@ void DisplayDungeonMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (void *) monPortrait.faceFile->data; + monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -501,7 +501,7 @@ void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo) monPortraitPtr = &monPortrait; monPortraitPtr->faceFile = GetDialogueSpriteDataPtr(dialogueMonId); if (monPortraitPtr->faceFile != NULL) { - monPortraitPtr->faceData = (void *) monPortraitPtr->faceFile->data; + monPortraitPtr->faceData = (struct PortraitGfx *) monPortraitPtr->faceFile->data; monPortraitPtr->unkE = 0; monPortraitPtr->spriteId = dialogueInfo->unk2; monPortraitPtr->flip = strPtr->flip; @@ -551,7 +551,7 @@ bool32 DisplayDungeonYesNoMessage(struct MonDialogueSpriteInfo *monSpriteInfo, c && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (void *) monPortrait.faceFile->data; + monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -600,7 +600,7 @@ s32 DisplayDungeonMenuMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const && IsPokemonDialogueSpriteAvail(monSpriteInfo->species, monSpriteInfo->spriteId)) { monPortrait.faceFile = GetDialogueSpriteDataPtr(monSpriteInfo->species); - monPortrait.faceData = (void *) monPortrait.faceFile->data; + monPortrait.faceData = (struct PortraitGfx *) monPortrait.faceFile->data; monPortrait.pos.x = 2; monPortrait.pos.y = 9; monPortrait.spriteId = monSpriteInfo->spriteId; @@ -763,7 +763,7 @@ void sub_8052FB8(const u8 *str) if (r8 < 62) { r8++; for (j = 0; j < 8; j++) { - SetBGPaletteBufferColorRGB(240 + j, (void*) &gFontPalette[0].pal[j], r8 / 2, NULL); + SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[0].pal[j], r8 / 2, NULL); } } else { @@ -816,7 +816,7 @@ void sub_8052FB8(const u8 *str) while (r8 >= 0) { for (j = 0; j < 8; j++) { - SetBGPaletteBufferColorRGB(240 + j, (void*) &gFontPalette[0].pal[j], r8 / 2, NULL); + SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[0].pal[j], r8 / 2, NULL); } DrawDialogueBoxString(); sub_803E46C(9); diff --git a/src/felicity_bank.c b/src/felicity_bank.c index cbefb67d0..fcfbbe66b 100644 --- a/src/felicity_bank.c +++ b/src/felicity_bank.c @@ -71,7 +71,7 @@ bool8 CreateFelicityBank(s32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_PERSIAN); sFelicityBankWork->monPortrait.faceFile = faceFile; - sFelicityBankWork->monPortrait.faceData = (void *) faceFile->data; + sFelicityBankWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sFelicityBankWork->monPortrait.spriteId = 0; sFelicityBankWork->monPortrait.flip = FALSE; sFelicityBankWork->monPortrait.unkE = 0; diff --git a/src/gulpin_shop.c b/src/gulpin_shop.c index 5153212a4..8c036ee9d 100644 --- a/src/gulpin_shop.c +++ b/src/gulpin_shop.c @@ -49,7 +49,7 @@ bool8 CreateGulpinShop(u32 mode, s16 pokeSpecies, Move *moves) faceFile = GetDialogueSpriteDataPtr(MONSTER_GULPIN); sGulpinShopWork->monPortrait.faceFile = faceFile; - sGulpinShopWork->monPortrait.faceData = (void *) faceFile->data; + sGulpinShopWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sGulpinShopWork->monPortrait.spriteId = 0; sGulpinShopWork->monPortrait.flip = FALSE; diff --git a/src/gulpin_shop_801FB50.c b/src/gulpin_shop_801FB50.c index a565bdeda..88fa01c0a 100644 --- a/src/gulpin_shop_801FB50.c +++ b/src/gulpin_shop_801FB50.c @@ -101,7 +101,7 @@ bool8 sub_801FB50(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_GULPIN); gUnknown_203B27C->monPortrait.faceFile = faceFile; - gUnknown_203B27C->monPortrait.faceData = (void *) faceFile->data; + gUnknown_203B27C->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; gUnknown_203B27C->monPortrait.spriteId = 0; gUnknown_203B27C->monPortrait.flip = FALSE; gUnknown_203B27C->monPortrait.unkE = 0; diff --git a/src/kangaskhan_storage1.c b/src/kangaskhan_storage1.c index 092b348a1..9bd044f20 100644 --- a/src/kangaskhan_storage1.c +++ b/src/kangaskhan_storage1.c @@ -67,7 +67,7 @@ bool8 CreateKangaskhanStorage(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_KANGASKHAN); gKangaskhanStorageWork->monPortrait.faceFile = faceFile; - gKangaskhanStorageWork->monPortrait.faceData = (void *) faceFile->data; + gKangaskhanStorageWork->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; gKangaskhanStorageWork->monPortrait.spriteId = FALSE; gKangaskhanStorageWork->monPortrait.flip = FALSE; gKangaskhanStorageWork->monPortrait.unkE = 0; diff --git a/src/kecleon_bros1.c b/src/kecleon_bros1.c index 261a120ea..093f976b0 100644 --- a/src/kecleon_bros1.c +++ b/src/kecleon_bros1.c @@ -107,7 +107,7 @@ bool8 CreateKecleonBros(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_KECLEON); sKecleonBrosWork1->monPortrait.faceFile = faceFile; - sKecleonBrosWork1->monPortrait.faceData = (void *) faceFile->data; + sKecleonBrosWork1->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sKecleonBrosWork1->monPortrait.spriteId = 0; sKecleonBrosWork1->monPortrait.flip = FALSE; sKecleonBrosWork1->monPortrait.unkE = 0; diff --git a/src/makuhita_dojo1.c b/src/makuhita_dojo1.c index bf193124f..906e80ea7 100644 --- a/src/makuhita_dojo1.c +++ b/src/makuhita_dojo1.c @@ -98,7 +98,7 @@ bool8 MakuhitaDojo_New(u32 mode) faceFile = GetDialogueSpriteDataPtr(MONSTER_MAKUHITA); sMakuhitaDojoWork1->monPortrait.faceFile = faceFile; - sMakuhitaDojoWork1->monPortrait.faceData = (void *) faceFile->data; + sMakuhitaDojoWork1->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sMakuhitaDojoWork1->monPortrait.spriteId = 0; sMakuhitaDojoWork1->monPortrait.flip = FALSE; sMakuhitaDojoWork1->monPortrait.unkE = 0; diff --git a/src/mission_reward.c b/src/mission_reward.c index 684e156aa..381fac5e6 100644 --- a/src/mission_reward.c +++ b/src/mission_reward.c @@ -139,7 +139,7 @@ u32 sub_802F204(unkStruct_802F204 *r0, bool8 displayClientSprite) if(gUnknown_203B310->monPortrait.faceFile != NULL) { - gUnknown_203B310->monPortrait.faceData = (void *) gUnknown_203B310->monPortrait.faceFile->data; + gUnknown_203B310->monPortrait.faceData = (struct PortraitGfx *) gUnknown_203B310->monPortrait.faceFile->data; } SetRewardSceneState(PREP_MONEY_REWARD); diff --git a/src/post_office_guide1.c b/src/post_office_guide1.c index 41d4ea0cd..e998ed33e 100644 --- a/src/post_office_guide1.c +++ b/src/post_office_guide1.c @@ -65,7 +65,7 @@ bool8 CreateHelperPelipperMenu(s16 speciesID) sPostOfficeHelper->monPortrait.pos.y = 8; if (sPostOfficeHelper->monPortrait.faceFile != NULL) - sPostOfficeHelper->monPortrait.faceData = (void *) sPostOfficeHelper->monPortrait.faceFile->data; + sPostOfficeHelper->monPortrait.faceData = (struct PortraitGfx *) sPostOfficeHelper->monPortrait.faceFile->data; } sPostOfficeHelper->currMenuChoice = 0; diff --git a/src/save_write.c b/src/save_write.c index 156d8f3cd..b295510cb 100644 --- a/src/save_write.c +++ b/src/save_write.c @@ -26,7 +26,7 @@ void PrepareSavePakWrite(s16 pokemonID) if (pokemonID != MONSTER_NONE) { file = GetDialogueSpriteDataPtr(pokemonID); sSavePakWrite->monPortrait.faceFile = file; - sSavePakWrite->monPortrait.faceData = (void *) file->data; + sSavePakWrite->monPortrait.faceData = (struct PortraitGfx *) file->data; sSavePakWrite->monPortrait.spriteId = 0; sSavePakWrite->monPortrait.flip = FALSE; sSavePakWrite->monPortrait.unkE = 0; diff --git a/src/thank_you_wonder_mail.c b/src/thank_you_wonder_mail.c index 610df0dea..8d32621aa 100644 --- a/src/thank_you_wonder_mail.c +++ b/src/thank_you_wonder_mail.c @@ -249,7 +249,7 @@ u32 CreateThankYouMailPelipper(void) faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C4->monPortrait.faceFile = faceFile; - sUnknown_203B2C4->monPortrait.faceData = (void *) faceFile->data; + sUnknown_203B2C4->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sUnknown_203B2C4->monPortrait.spriteId = 0; sUnknown_203B2C4->monPortrait.flip = FALSE; sUnknown_203B2C4->monPortrait.unkE = 0; diff --git a/src/wigglytuff_shop3.c b/src/wigglytuff_shop3.c index f8a107f0a..81dffd8ad 100644 --- a/src/wigglytuff_shop3.c +++ b/src/wigglytuff_shop3.c @@ -75,7 +75,7 @@ bool8 CreateWigglytuffShop(u32 mode) file = GetDialogueSpriteDataPtr(MONSTER_WIGGLYTUFF); sWigglytuffShop3Work->monPortrait.faceFile = file; - sWigglytuffShop3Work->monPortrait.faceData = (void *) file->data; + sWigglytuffShop3Work->monPortrait.faceData = (struct PortraitGfx *) file->data; sWigglytuffShop3Work->monPortrait.spriteId = 0; sWigglytuffShop3Work->monPortrait.flip = FALSE; sWigglytuffShop3Work->monPortrait.unkE = 0; diff --git a/src/wonder_mail.c b/src/wonder_mail.c index 106dcb875..760e60656 100644 --- a/src/wonder_mail.c +++ b/src/wonder_mail.c @@ -200,7 +200,7 @@ u32 sub_8027F88(void) strcpy(gFormatBuffer_Monsters[0], monName); faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C0->monPortrait.faceFile = faceFile; - sUnknown_203B2C0->monPortrait.faceData = (void *) faceFile->data; + sUnknown_203B2C0->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sUnknown_203B2C0->monPortrait.spriteId = 0; sUnknown_203B2C0->monPortrait.flip = FALSE; sUnknown_203B2C0->monPortrait.unkE = 0; diff --git a/src/wonder_mail_2.c b/src/wonder_mail_2.c index 0697ac6da..7cf6654df 100644 --- a/src/wonder_mail_2.c +++ b/src/wonder_mail_2.c @@ -86,7 +86,7 @@ s32 sub_802B2D4(void) CopyYellowMonsterNametoBuffer(gSpeakerNameBuffer, MONSTER_PELIPPER); faceFile = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); sUnknown_203B2C8->monPortrait.faceFile = faceFile; - sUnknown_203B2C8->monPortrait.faceData = (void *) faceFile->data; + sUnknown_203B2C8->monPortrait.faceData = (struct PortraitGfx *) faceFile->data; sUnknown_203B2C8->monPortrait.spriteId = 0; sUnknown_203B2C8->monPortrait.flip = FALSE; sUnknown_203B2C8->monPortrait.unkE = 0; diff --git a/src/wonder_mail_6.c b/src/wonder_mail_6.c index 0111b82ae..beaa90e3c 100644 --- a/src/wonder_mail_6.c +++ b/src/wonder_mail_6.c @@ -110,7 +110,7 @@ bool8 sub_8030F58(u32 wonderMailType) gUnknown_203B328->wonderMailType = wonderMailType; file = GetDialogueSpriteDataPtr(MONSTER_PELIPPER); gUnknown_203B328->monPortrait.faceFile = file; - gUnknown_203B328->monPortrait.faceData = (void *) file->data; + gUnknown_203B328->monPortrait.faceData = (struct PortraitGfx *) file->data; gUnknown_203B328->monPortrait.spriteId = 0; gUnknown_203B328->monPortrait.flip = FALSE; gUnknown_203B328->monPortrait.unkE = 0; diff --git a/sym_ewram.txt b/sym_ewram.txt index 348af6354..f4a5c0262 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -221,7 +221,7 @@ gUnknown_202EDB8: /* 202EDB8 (sub_803E250) */ .space 0x8 gUnknown_202EDC0: /* 202EDC0 (sub_803E250 - sub_80462AC) */ .space 0x8 -gUnknown_202EDC8: /* 202EDC8 (sub_803E250 - sub_8086794) */ +gDungeonBrightness: /* 202EDC8 (sub_803E250 - sub_8086794) */ .space 0x4 gUnknown_202EDCC: /* 202EDCC (sub_803E490 - sub_807D148) */ .space 0x4