Merge pull request #248 from DizzyEggg/rgb

bg_palette_buffer clean-up
This commit is contained in:
AnonymousRandomPerson
2024-11-01 17:37:56 -04:00
committed by GitHub
23 changed files with 184 additions and 175 deletions

View File

@@ -1,10 +1,12 @@
#ifndef GUARD_BG_PALETTE_BUFFER_H
#define GUARD_BG_PALETTE_BUFFER_H
#include "structs/rgb.h"
void InitBGPaletteBuffer(void);
void nullsub_4(s32 index, const u8 *colorArray, s32, u8 *);
void nullsub_5(s32 index, const u8 *colorArray);
void SetBGPaletteBufferColorArray(s32 index, const u8 *colorArray);
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 TransferBGPaletteBuffer(void);

View File

@@ -10,10 +10,10 @@ typedef struct unkStruct_202EE8C
u32 unk0;
u16 unk4;
s16 unk6;
RGB *unk8;
RGB *unkC;
RGB *unk10;
RGB unk14;
Rgb32 *unk8;
Rgb32 *unkC;
Rgb32 *unk10;
Rgb32 unk14;
} unkStruct_202EE8C;
extern unkStruct_202EE8C gUnknown_202EE8C[32];
@@ -37,7 +37,7 @@ typedef struct unkDataFor8004AA4
{
/* 0x0 */ s16 colorCount;
s16 unk2;
/* 0x4 */ RGB colors[0];
/* 0x4 */ Rgb32 colors[0];
} unkDataFor8004AA4;
void nullsub_6(void);

View File

@@ -1,6 +1,8 @@
#ifndef GUARD_CODE_8009804_H
#define GUARD_CODE_8009804_H
#include "structs/rgb.h"
// size: 0xC
struct unkStruct_202D240
{
@@ -9,12 +11,6 @@ struct unkStruct_202D240
u32 size;
};
// size: 0x40
struct unkStruct_202D038
{
u32 unk0[0x10];
};
void vram_related_8009804(void);
void InitFontPalette(void);
@@ -23,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(u32);
void sub_80099F0(Rgb32);
#endif // GUARD_CODE_8009804_H

View File

@@ -4,6 +4,7 @@
#include "structs/menu.h"
#include "pokemon.h"
#include "structs/str_text.h"
#include "structs/rgb.h"
// size: 0x118
struct unk_203B250
@@ -27,7 +28,7 @@ struct unk_203B250
struct TeamBadgeData
{
/* 0x0 */ u8 *pics; // probably a pointer to an arrays of pixels?
/* 0x4 */ u8 *pallete; // Pics share common pallete
/* 0x4 */ Rgb32 *pallete; // Pics share common pallete
};
bool8 sub_801D014(PokemonStruct1 *);
@@ -36,4 +37,4 @@ u32 sub_801D178(void);
u8 sub_801D1D4(void);
void sub_801D1E0(void);
#endif // GUARD_CODE_801D014_H
#endif // GUARD_CODE_801D014_H

View File

@@ -2,21 +2,21 @@
#define GUARD_CONSTANTS_EMOTIONS_H
#define EMOTION_NORMAL 0
#define EMOTION_HAPPY 2
#define EMOTION_PAINED 4
#define EMOTION_ANGRY 6
#define EMOTION_WORRIED 8
#define EMOTION_SAD 10
#define EMOTION_CRYING 12
#define EMOTION_SHOUTING 14
#define EMOTION_TEARY_EYE 16
#define EMOTION_DETERMINED 18
#define EMOTION_JOYOUS 20
#define EMOTION_INSPIRED 22
#define EMOTION_SUPRISED 24
#define EMOTION_DIZZY 26
#define EMOTION_SIGH 32
#define EMOTION_STUNNED 34
#define MAX_EMOTIONS 40
#define EMOTION_HAPPY 1
#define EMOTION_PAINED 2
#define EMOTION_ANGRY 3
#define EMOTION_WORRIED 4
#define EMOTION_SAD 5
#define EMOTION_CRYING 6
#define EMOTION_SHOUTING 7
#define EMOTION_TEARY_EYE 8
#define EMOTION_DETERMINED 9
#define EMOTION_JOYOUS 10
#define EMOTION_INSPIRED 11
#define EMOTION_SUPRISED 12
#define EMOTION_DIZZY 13
#define EMOTION_SIGH 16
#define EMOTION_STUNNED 17
#define MAX_EMOTIONS 20
#endif // GUARD_CONSTANTS_EMOTIONS_H

View File

@@ -59,6 +59,7 @@
#define RGB_U32(r, g, b) ((r) | ((g) << 8) | ((b) << 16)) // 32 bit RGB color
#define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10))
#define RGB2(r, g, b) (((b) << 10) | ((g) << 5) | (r))
#define RGB_BLACK RGB(0, 0, 0)
#define RGB_WHITE RGB(31, 31, 31)

View File

@@ -4,6 +4,7 @@
#include "file_system.h"
#include "structs/menu.h"
#include "structs/str_text.h"
#include "structs/rgb.h"
// TODO: once the files close to string_format.c are decompiled, check if these should be included here. Most likely, they should be declared elsewhere.
// code_80130A8.s
@@ -19,7 +20,7 @@ void sub_80155F0(void);
struct PortraitGfxSub
{
const u8 *pal;
const Rgb32 *pal;
const u8 *gfx;
};

View File

@@ -1,12 +1,16 @@
#ifndef GUARD_RGB_H
#define GUARD_RGB_H
typedef struct RGB
typedef struct Rgb32
{
// IDK which is R G B
u8 unk0;
u8 unk1;
u8 unk2;
} RGB;
u8 r;
u8 g;
u8 b;
} Rgb32;
typedef struct Palette32
{
Rgb32 pal[16];
} Palette32;
#endif // GUARD_RGB_H

View File

@@ -73,7 +73,7 @@ const u8 *xxx_handle_format_global(const u8 *str, struct UnkDrawStringStruct *un
// text.s
extern const struct unkChar *GetCharacter(s32);
extern void InitGraphics(void);
void sub_800836C(s32 a0, const u8 *compressedData, s32 a1);
void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1);
extern void sub_800898C(void);
extern void sub_80089AC(const UnkTextStruct2 *, UnkTextStruct2_sub *);
extern void CallPrepareTextbox_8008C54(u32);

View File

@@ -43,10 +43,10 @@ void SetBGPaletteBufferColorRGB(s32 index, const u8 *colorArray, s32 a1, u8 *a2)
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);
}
void SetBGPaletteBufferColorArray(s32 index, const u8 *colorArray)
void SetBGPaletteBufferColorArray(s32 index, const Rgb32 *color32)
{
sBGPaletteUsed[index / BG_PALETTE_BUFFER_CHUNK_SIZE] = TRUE;
sBGPaletteBuffer[index] = (colorArray[2] >> 3) << 10 | (colorArray[1] >> 3) << 5 | colorArray[0] >> 3;
sBGPaletteBuffer[index] = RGB2(color32->r >> 3, color32->g >> 3, color32->b >> 3);
}
void SetBGPaletteBufferColor(s32 index, u16 *color)
@@ -59,7 +59,7 @@ void nullsub_4(s32 index, const u8 *colorArray, s32 a1, u8 *a2)
{
}
void nullsub_5(s32 index, const u8 *colorArray)
void nullsub_5(s32 index, const Rgb32 *colorArray)
{
}

View File

@@ -124,9 +124,9 @@ bool8 sub_8004C00(unkStruct_202EE8C *a0, s32 a1, s32 a2, s32 a3, u8 *a4, s16 *a5
ret = TRUE;
}
r1 = a5[0] + a0->unk14.unk0;
r3 = a5[1] + a0->unk14.unk1;
r5 = a5[2] + a0->unk14.unk2;
r1 = a5[0] + a0->unk14.r;
r3 = a5[1] + a0->unk14.g;
r5 = a5[2] + a0->unk14.b;
if (r1 > 0xFF)
r1 = 0xFF;
@@ -192,4 +192,4 @@ bool8 sub_8004D40(unkStruct_202EE8C *a0, s32 a1)
}
}
return TRUE;
}
}

View File

@@ -8,7 +8,7 @@
extern const u8 gUnknown_80B88CC[];
extern const struct FileArchive gSystemFileArchive; // 8300500
extern struct unkStruct_202D038 gFontPalette[8];
extern Palette32 gFontPalette[8];
extern u8 gUnknown_202D238[4];
extern s32 gUnknown_202D23C;
extern struct unkStruct_202D240 gUnknown_202D240[8];
@@ -20,18 +20,18 @@ void InitFontPalette(void)
{
OpenedFile *fontpalFile;
s32 i;
u32 *ptr;
Rgb32 *ptr;
fontpalFile = OpenFileAndGetFileDataPtr(gUnknown_80B88CC, &gSystemFileArchive); // fontpal
CpuCopy(gFontPalette, fontpalFile->data, sizeof(gFontPalette));
if (sub_80063B0() == 1)
ptr = &gFontPalette[0].unk0[0];
ptr = gFontPalette[0].pal;
else
ptr = &gFontPalette[1].unk0[0];
ptr = gFontPalette[1].pal;
for (i = 0; i < 16; ptr++, i++)
SetBGPaletteBufferColorArray(i + 240, (u8 *)ptr);
SetBGPaletteBufferColorArray(i + 240, ptr);
CloseFile(fontpalFile);
}
@@ -126,12 +126,12 @@ void sub_80099C0(void)
CpuCopy(BG_SCREEN_ADDR(13), gUnknown_202B038[1], BG_SCREEN_SIZE);
}
void sub_80099F0(u32 a0)
void sub_80099F0(Rgb32 a0)
{
s32 i;
for (i = 0; i < 8; i++)
gFontPalette[i].unk0[1] = a0;
gFontPalette[i].pal[1] = a0;
}
UNUSED static void sub_8009A10(u32 *a0)

View File

@@ -563,23 +563,17 @@ static void sub_801D878(void)
static void sub_801D894(void)
{
u8 rank;
const u8 *location;
s32 location_length;
s32 x_coord;
// Stored on stack
u32 *preload_string;
const u8 *r5; // R5
u8 buffer[96]; // sp +4
u8 buffer[100]; // sp +4
if (sUnknown_203B250->currFriendAreaLocation == FRIEND_AREA_NONE)
location = sub_8098FB4();
else
location = GetFriendAreaName(sUnknown_203B250->currFriendAreaLocation);
// TODO this is def a hack
FormatString(location, buffer, (u8 *)(&preload_string + 1), 0);
FormatString(location, buffer, buffer + sizeof(buffer), 0);
location_length = sub_8008ED0(buffer);
x_coord = (128 - location_length) / 2; // Centers the location name
CallPrepareTextbox_8008C54(1);
@@ -590,10 +584,8 @@ static void sub_801D894(void)
sub_80073B8(2);
LoadTeamRankBadge(2, 8, 6);
// Have to load before TeamRank funcs
r5 = sFmtPointsCyan; // %s {COLOR CYAN}%d{RESET} Pts.
rank = GetRescueTeamRank();
sprintfStatic(buffer, r5, GetTeamRankString(rank), GetTeamRankPts());
// %s {COLOR CYAN}%d{RESET} Pts.
sprintfStatic(buffer, sFmtPointsCyan, GetTeamRankString(GetRescueTeamRank()), GetTeamRankPts());
PrintStringOnWindow(32, 4, buffer, 2, 0);
sprintfStatic(buffer, sFmtMoneyCyan, gTeamInventoryRef->teamMoney);
PrintStringOnWindow(32, 18, buffer, 2, 0);
@@ -605,7 +597,7 @@ static void LoadTeamRankBadge(u32 a0, u32 a1, u32 a2)
OpenedFile *teamBadgeFile;
s32 palleteIndex;
u8 rank;
u8 *colorArray;
Rgb32 *colorArray;
u8 *teamBadgePic;
teamBadgeFile = OpenFileAndGetFileDataPtr(sTeamRankBadgeFileName, &gTitleMenuFileArchive);
@@ -614,7 +606,7 @@ static void LoadTeamRankBadge(u32 a0, u32 a1, u32 a2)
for (palleteIndex = 0; palleteIndex < 16; palleteIndex++) {
SetBGPaletteBufferColorArray(palleteIndex + 224, colorArray);
colorArray = colorArray + 4;
colorArray++;
}
rank = GetRescueTeamRank();

View File

@@ -3,6 +3,7 @@
#include "pokemon.h"
#include "file_system.h"
#include "code_803E46C.h"
#include "code_8009804.h"
#include "cpu.h"
#include "dungeon_random.h"
#include "bg_palette_buffer.h"
@@ -40,7 +41,7 @@ extern OpenedFile *gUnknown_202EC98;
extern OpenedFile *gUnknown_202EC94;
extern s32 gDungeonNameBannerFont;
extern u8 gUnknown_20274A5;
extern u8 gFontPalette[];
extern Palette32 gFontPalette[8];
struct UnkDungeonFileData
{
@@ -537,6 +538,17 @@ s32 sub_803DA20(s32 species)
return 1;
}
struct DungeonNameFontFileData
{
/* 0x0 */ u8 unk0;
/* 0x4 */ s32 font;
};
struct DungeonNamePaletteFileData
{
Rgb32 pal[16];
};
void ShowDungeonNameBanner(void)
{
u8 text[100];
@@ -546,9 +558,9 @@ void ShowDungeonNameBanner(void)
gDungeonNameBannerPalette = OpenFileAndGetFileDataPtr(gUnknown_80F60F8, &gDungeonFileArchive);
gDungeonNameBannerFontFile = OpenFileAndGetFileDataPtr(gUnknown_80F6100, &gDungeonFileArchive);
gDungeonNameBannerFont = (s32)(((u8**) gDungeonNameBannerFontFile->data)[1]);
gDungeonNameBannerFont = ((struct DungeonNameFontFileData *)(gDungeonNameBannerFontFile->data))->font;
for (i = 0; i < 16; i++) {
SetBGPaletteBufferColorArray(i + 224, (void*) &((u8**) gDungeonNameBannerPalette->data)[i]); // Todo: Fix when there is a better idea what to do with structs from opened files
SetBGPaletteBufferColorArray(i + 224, &((struct DungeonNamePaletteFileData *)(gDungeonNameBannerPalette->data))->pal[i]);
}
CpuClear((void *)(VRAM + 0x140), 0x1C00);
if (sub_80848EC()) {
@@ -1038,17 +1050,17 @@ NAKED void sub_803E02C(void)
void sub_803E13C(void)
{
s32 i;
u8 *pal;
Rgb32 *pal;
SetWindowBGColor();
if (gGameOptionsRef->playerGender != 0)
pal = gFontPalette + 256;
pal = gFontPalette[4].pal;
else
pal = gFontPalette;
pal = gFontPalette[0].pal;
for (i = 0; i < 16; i++) {
SetBGPaletteBufferColorArray(240 + i, pal);
pal += 4;
pal++;
}
}

View File

@@ -57,9 +57,7 @@ extern const u16 gUnknown_80F6544[][9];
extern u8 gUnknown_20274A5;
extern u8 gUnknown_202D06C[];
// 2d array? possibly the same as gUnknown_202D06C TODO: merge the variables
extern u8 gUnknown_202D068[];
extern Palette32 gFontPalette[8];
extern s32 gUnknown_202EDCC;
extern u32 gUnknown_3001018[];
@@ -880,7 +878,7 @@ void sub_803F27C(bool8 a0)
void sub_803F38C(void)
{
s32 palAdd;
s32 palId;
UnkDungeonGlobal_unk181E8_sub *strPtr = &gDungeon->unk181e8;
strPtr->unk3A = -1;
@@ -890,15 +888,15 @@ void sub_803F38C(void)
strPtr->unk36 = -1;
strPtr->unk38 = -1;
palAdd = (gGameOptionsRef->playerGender != MALE) ? 256 : 0;
palId = (gGameOptionsRef->playerGender != MALE) ? 4 : 0;
SetBGPaletteBufferColorArray(0xFD, &gUnknown_202D06C[0 + palAdd]);
SetBGPaletteBufferColorArray(0xFE, &gUnknown_202D06C[4 + palAdd]);
SetBGPaletteBufferColorArray(0xFF, &gUnknown_202D06C[8 + palAdd]);
SetBGPaletteBufferColorArray(0xFD, &gFontPalette[palId].pal[13]);
SetBGPaletteBufferColorArray(0xFE, &gFontPalette[palId].pal[14]);
SetBGPaletteBufferColorArray(0xFF, &gFontPalette[palId].pal[15]);
nullsub_5(0xFD, &gUnknown_202D06C[0 + palAdd]);
nullsub_5(0xFE, &gUnknown_202D06C[4 + palAdd]);
nullsub_5(0xFF, &gUnknown_202D06C[8 + palAdd]);
nullsub_5(0xFD, &gFontPalette[palId].pal[13]);
nullsub_5(0xFE, &gFontPalette[palId].pal[14]);
nullsub_5(0xFF, &gFontPalette[palId].pal[15]);
}
bool8 sub_803F428(Position *pos)
@@ -1300,18 +1298,18 @@ void sub_803FB74(void)
if (strPtr->unk36 != r5) {
strPtr->unk36 = r5;
SetBGPaletteBufferColorArray(0xFC, &gUnknown_202D068[0 + r5 * 4]);
SetBGPaletteBufferColorArray(0xFD, &gUnknown_202D068[4 + r5 * 4]);
SetBGPaletteBufferColorArray(0xFE, &gUnknown_202D068[8 + r5 * 4]);
SetBGPaletteBufferColorArray(0xFF, &gUnknown_202D068[12 + r5 * 4]);
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]);
}
if (strPtr->unk38 != r6) {
strPtr->unk38 = r6;
nullsub_5(0xFC, &gUnknown_202D068[0 + r6 * 4]);
nullsub_5(0xFD, &gUnknown_202D068[4 + r6 * 4]);
nullsub_5(0xFE, &gUnknown_202D068[8 + r6 * 4]);
nullsub_5(0xFF, &gUnknown_202D068[12 + r6 * 4]);
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]);
}
arrPtr = gUnknown_202B038[0][0];

View File

@@ -416,7 +416,7 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
bool8 r9;
bool8 r10;
u8 sp;
RGB colorArray;
Rgb32 colorArray;
gUnknown_203B40C = 0;
r6 = r8->unk8;
@@ -806,9 +806,9 @@ void xxx_dungeon_8042F6C(struct UnkStruct_xxx_dungeon_8042F6C *r8)
}
SetBGOBJEnableFlags(0);
colorArray.unk0 = 0x60;
colorArray.unk1 = 0x80;
colorArray.unk2 = 0xF8;
colorArray.r = 0x60;
colorArray.g = 0x80;
colorArray.b = 0xF8;
SetBGPaletteBufferColorRGB(253, (void*) &colorArray, gUnknown_202EDC8, 0); // Todo: Fix SetBGPaletteBufferColorRGB to take RGB*
sub_8040094(1);
gDungeon->unk181e8.unk18218 = 1;

View File

@@ -53,7 +53,7 @@ extern void (*gUnknown_203B080)(s32 a0);
extern u8 gSpeakerNameBuffer[];
extern UnkTextStruct1 gUnknown_2027370[4];
extern s32 gUnknown_202EDCC;
extern u8 gFontPalette[];
extern Palette32 gFontPalette[];
extern const u8 gUnknown_80F7AE8[];
extern const u8 gUnknown_80F7AF8[];
@@ -763,7 +763,7 @@ void sub_8052FB8(const u8 *str)
if (r8 < 62) {
r8++;
for (j = 0; j < 8; j++) {
SetBGPaletteBufferColorRGB(240 + j, &gFontPalette[j * 4], r8 / 2, NULL);
SetBGPaletteBufferColorRGB(240 + j, (void*) &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, &gFontPalette[j * 4], r8 / 2, NULL);
SetBGPaletteBufferColorRGB(240 + j, (void*) &gFontPalette[0].pal[j], r8 / 2, NULL);
}
DrawDialogueBoxString();
sub_803E46C(9);
@@ -827,7 +827,7 @@ void sub_8052FB8(const u8 *str)
sub_803E46C(9);
sub_8040238();
for (j = 0; j < 8; j++) {
SetBGPaletteBufferColorArray(240 + j, &gFontPalette[j * 4]);
SetBGPaletteBufferColorArray(240 + j, &gFontPalette[0].pal[j]);
}
sub_803E708(8, 9);
}

View File

@@ -10,19 +10,6 @@ struct unkStruct_8094CB0
s16 unk2;
};
struct WindowBG
{
// size: 0x10
u32 hexBG[4];
};
const struct WindowBG gWindowBGColors = {
RGB_U32(0x20, 0x48, 0x68), // Blue
RGB_U32(0x80, 0x38, 0x20), // Red
RGB_U32(0x28, 0x80, 0x48), // Green
RGB_U32(0x28, 0x80, 0x48) // Green
};
EWRAM_DATA_2 GameOptions *gGameOptionsRef = {0};
EWRAM_DATA GameOptions gGameOptions = {0};
@@ -45,7 +32,7 @@ void InitializeGameOptions(bool8 initializeGender)
}
gGameOptionsRef->unk9 = 0;
gGameOptionsRef->unkA = 0;
gGameOptionsRef->dungeonSpeed = DUNGEON_SPEED_SLOW;
gGameOptionsRef->dungeonSpeed = DUNGEON_SPEED_SLOW;
gGameOptionsRef->FarOffPals = FAROFFPALS_LOCK;
gGameOptionsRef->damageTurn = TRUE;
gGameOptionsRef->gridEnable = TRUE;
@@ -56,23 +43,32 @@ void InitializeGameOptions(bool8 initializeGender)
bool8 GameOptionsNotChange(GameOptions *r0)
{
// NOTE: had to nest to match
if(gGameOptionsRef->windowColor == r0->windowColor)
if(gGameOptionsRef->unk9 == r0->unk9)
if(gGameOptionsRef->unkA == r0->unkA)
if(gGameOptionsRef->playerGender == r0->playerGender)
if(gGameOptionsRef->dungeonSpeed == r0->dungeonSpeed)
if(gGameOptionsRef->FarOffPals == r0->FarOffPals)
if(gGameOptionsRef->damageTurn == r0->damageTurn)
if(gGameOptionsRef->gridEnable == r0->gridEnable)
if(gGameOptionsRef->mapOption == r0->mapOption)
if(gGameOptionsRef->unkC == r0->unkC)
return TRUE;
return FALSE;
if (gGameOptionsRef->windowColor != r0->windowColor)
return FALSE;
if (gGameOptionsRef->unk9 != r0->unk9)
return FALSE;
if (gGameOptionsRef->unkA != r0->unkA)
return FALSE;
if (gGameOptionsRef->playerGender != r0->playerGender)
return FALSE;
if (gGameOptionsRef->dungeonSpeed != r0->dungeonSpeed)
return FALSE;
if (gGameOptionsRef->FarOffPals != r0->FarOffPals)
return FALSE;
if (gGameOptionsRef->damageTurn != r0->damageTurn)
return FALSE;
if (gGameOptionsRef->gridEnable != r0->gridEnable)
return FALSE;
if (gGameOptionsRef->mapOption != r0->mapOption)
return FALSE;
if (gGameOptionsRef->unkC != r0->unkC)
return FALSE;
return TRUE;
}
void WriteGameOptions(struct unkStruct_8094924 *param_1)
{
{
u8 zero;
u8 neg_1;
u8 *puVar2;
@@ -195,11 +191,14 @@ void ReadGameOptions(struct unkStruct_8094924 *param_1)
void SetWindowBGColor(void)
{
struct WindowBG temp;
struct Rgb32 winColors[] = {
{0x20, 0x48, 0x68}, // Blue
{0x80, 0x38, 0x20}, // Red
{0x28, 0x80, 0x48}, // Green
{0x28, 0x80, 0x48} // Green
};
temp = gWindowBGColors;
sub_80099F0(temp.hexBG[gGameOptionsRef->windowColor & NUM_WINDOW_COLORS]);
sub_80099F0(winColors[gGameOptionsRef->windowColor & NUM_WINDOW_COLORS]);
}
bool8 sub_8094C48(void)
@@ -228,15 +227,10 @@ bool8 DoesNotHaveShadedMap(void)
void sub_8094C88(void)
{
if(gGameOptionsRef->mapOption < 3)
if (gGameOptionsRef->mapOption == 0 || gGameOptionsRef->mapOption == 1 || gGameOptionsRef->mapOption == 2)
gGameOptionsRef->mapOption = 1;
else
{
if((u8)(gGameOptionsRef->mapOption - 3) > 2)
return;
else
gGameOptionsRef->mapOption = 4;
}
else if (gGameOptionsRef->mapOption == 3 || gGameOptionsRef->mapOption == 4 || gGameOptionsRef->mapOption == 5)
gGameOptionsRef->mapOption = 4;
}
void sub_8094CB0(struct unkStruct_8094CB0 *r0)

View File

@@ -366,7 +366,12 @@ void DrawLoadScreenText(void)
}
// Think structure of clmkFile is like Team Rank Badges except each pic has a diff pallete
// TODO clean up but it matches so yea
struct ClmkFileData
{
/* 0x0 */ u32 *pics;
/* 0x4 */ Rgb32 *pallete;
};
void sub_80397B4(void)
{
OpenedFile *clmkFile;
@@ -378,7 +383,7 @@ void sub_80397B4(void)
for(index = 0; index < 64; index++)
{
SetBGPaletteBufferColorArray(index + 176, (u8 *)(*(s32 *)((clmkFile->data) + 4) + index * 4));
SetBGPaletteBufferColorArray(index + 176, &((struct ClmkFileData *)(clmkFile->data))->pallete[index]);
}
x = 8;
@@ -388,7 +393,7 @@ void sub_80397B4(void)
for(index = 0; index < 12; index++)
{
if (sub_80023E4(gUnknown_203B3B8[index])) {
sub_8007E20(0,x,y,0x10,0x10,(u32 *)(*((s32*)clmkFile->data) + index * 0x80), gUnknown_203B388[index]);
sub_8007E20(0,x,y,0x10,0x10,(&((struct ClmkFileData *)(clmkFile->data))->pics[index * 32]), gUnknown_203B388[index]);
x += 16;
}
}

View File

@@ -18,6 +18,7 @@
#include "text_util.h"
#include "text1.h"
#include "text2.h"
#include "string_format.h"
enum
{
@@ -382,10 +383,10 @@ static void PrintPersonalityTypeDescription(void)
static void PersonalityTest_DisplayStarterSprite(void)
{
s32 starterID;
OpenedFile *faceFile;
struct OpenedFile *faceFile;
s32 palleteIndex;
u8 *r6;
u32 faceIndex;
s32 emotionId;
const u8 *gfx;
UnkTextStruct2 stackArray[4];
starterID = sPersonalityTestTracker->StarterID;
@@ -397,12 +398,13 @@ static void PersonalityTest_DisplayStarterSprite(void)
sub_80073B8(1);
faceFile = GetDialogueSpriteDataPtr(starterID);
r6 = ((struct FaceData *)faceFile->data)->unk0[1 + EMOTION_HAPPY];
faceIndex = EMOTION_HAPPY;
for (palleteIndex = 0; palleteIndex < 0x10; palleteIndex++)
SetBGPaletteBufferColorArray(palleteIndex + 0xE0, &((struct FaceData *)faceFile->data)->unk0[faceIndex][palleteIndex * 4]);
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]);
}
sub_800836C(1, r6, 14);
DisplayMonPortraitSpriteFlipped(1, gfx, 14);
CloseFile(faceFile);
sub_80073E0(1);
}

View File

@@ -12,6 +12,7 @@
#include "pokemon.h"
#include "text1.h"
#include "text2.h"
#include "string_format.h"
EWRAM_DATA_2 struct PersonalityStruct_203B404 *gUnknown_203B404 = {0};
@@ -243,22 +244,22 @@ static void RedrawPartnerSelectionMenu(void)
static void PersonalityTest_DisplayPartnerSprite(void)
{
s32 partnerID;
OpenedFile *faceFile;
struct OpenedFile *faceFile;
s32 palleteIndex;
u8 *r6;
u32 faceIndex;
const u8 *gfx;
s32 emotionId;
partnerID = gUnknown_203B404->PartnerArray[gUnknown_203B404->s18.s0.input.menuIndex];
CallPrepareTextbox_8008C54(1);
sub_80073B8(1);
faceFile = GetDialogueSpriteDataPtr(partnerID);
r6 = ((struct FaceData *)faceFile->data)->unk0[1 + EMOTION_NORMAL];
faceIndex = EMOTION_NORMAL;
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 (palleteIndex = 0; palleteIndex < 0x10; palleteIndex++)
SetBGPaletteBufferColorArray(palleteIndex + 0xE0, &((struct FaceData *)faceFile->data)->unk0[faceIndex][palleteIndex * 4]);
sub_800836C(1, r6, 14);
DisplayMonPortraitSpriteFlipped(1, gfx, 14);
CloseFile(faceFile);
sub_80073E0(1);
gUnknown_203B404->unk16 = 1;

View File

@@ -117,7 +117,7 @@ extern const u8 gUnknown_80D4910[];
extern const u8 gSpeakerNameSeparator[];
extern void SetCharacterMask(int a0);
extern void sub_8008274(s32 a0, const u8 *compressedData, s32 a2);
extern void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2);
extern void sub_80073E0(s32 a0);
extern void sub_8011A04(void);
@@ -247,7 +247,7 @@ void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const Me
gUnknown_203B198.unk26 = 5;
gUnknown_203B198.unk28 = 5;
for (i = 0; i < 16; i++) {
SetBGPaletteBufferColorArray(224 + i, &monPortraitPtr->faceData->sprites[monPortraitPtr->spriteId].pal[i * 4]);
SetBGPaletteBufferColorArray(224 + i, &monPortraitPtr->faceData->sprites[monPortraitPtr->spriteId].pal[i]);
}
portraitOn = TRUE;
if (monPortraitPtr->unkE) {
@@ -292,10 +292,10 @@ void CreateMenuDialogueBoxAndPortrait(const u8 *text, void *a1, u32 r9, const Me
sub_80073B8(1);
if (!monPortraitPtr->flip) {
sub_8008274(1, data, 0xE);
DisplayMonPortraitSprite(1, data, 0xE);
}
else {
sub_800836C(1, data, 0xE);
DisplayMonPortraitSpriteFlipped(1, data, 0xE);
}
sub_80073E0(1);
}

View File

@@ -2569,16 +2569,16 @@ UNUSED void sub_80081A4(s32 a0, s32 a3, s32 a4, s32 a7Id)
}
}
void sub_800829C(UnkTextStruct1 *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4);
static void DisplayMonPortrait(UnkTextStruct1 *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4);
void sub_8008274(s32 a0, const u8 *compressedData, s32 a2)
void DisplayMonPortraitSprite(s32 a0, const u8 *compressedData, s32 a2)
{
sub_800829C(gUnknown_2027370, gUnknown_202B038[0], a0, compressedData, a2);
DisplayMonPortrait(gUnknown_2027370, gUnknown_202B038[0], a0, compressedData, a2);
}
UNUSED void nullsub_162() {}
void sub_800829C(UnkTextStruct1 *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4)
static void DisplayMonPortrait(UnkTextStruct1 *a0, u16 a1[32][32], s32 a2, const u8 *compressedData, u32 a4)
{
s32 i, j;
UnkTextStruct1 *strPtr = &a0[a2];
@@ -2621,21 +2621,21 @@ void sub_8008334(u32 *r7, u32 *r12)
*r12 = r2;
}
void sub_800838C(UnkTextStruct1 *a0, s32 a1, const u8 *compressedData, s32 a3);
static void DisplayMonPortraitFlipped(UnkTextStruct1 *a0, s32 a1, const u8 *compressedData, s32 a3);
void sub_800836C(s32 a0, const u8 *compressedData, s32 a1)
void DisplayMonPortraitSpriteFlipped(s32 a0, const u8 *compressedData, s32 a1)
{
sub_800838C(gUnknown_2027370, a0, compressedData, a1);
DisplayMonPortraitFlipped(gUnknown_2027370, a0, compressedData, a1);
}
UNUSED void nullsub_163(void) {}
void sub_800838C(UnkTextStruct1 *a0, s32 a1, const u8 *compressedData, s32 a3)
static void DisplayMonPortraitFlipped(UnkTextStruct1 *a0, s32 a1, const u8 *compressedData, s32 a3)
{
s32 i, j;
UnkTextStruct1 *strPtr = &a0[a1];
sub_8008274(a1, compressedData, a3);
DisplayMonPortraitSprite(a1, compressedData, a3);
for (i = 0; i < strPtr->unk8; i++) {
s32 r8 = strPtr->unk4 / 2;
if (strPtr->unk4 & 1)