mirror of
https://github.com/pret/pmd-red.git
synced 2026-09-12 19:16:02 -05:00
Merge pull request #428 from DizzyEggg/some_funcs
Some checks failed
GithubCI / build (push) Has been cancelled
Some checks failed
GithubCI / build (push) Has been cancelled
Decompile code_80035F0 and GroundMap_Select and GroundMap_SelectDungeon
This commit is contained in:
@@ -1,338 +0,0 @@
|
||||
#include "global.h"
|
||||
#include "globaldata.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
#include "gba_color_util.h"
|
||||
|
||||
IWRAM_INIT bool8 gUnknown_3001B58 = FALSE;
|
||||
IWRAM_INIT u16 gUnknown_3001B5A = 0;
|
||||
|
||||
typedef struct unkStruct_3000C00
|
||||
{
|
||||
bool8 unk0;
|
||||
u8 unk1;
|
||||
s16 unk2;
|
||||
RGB_Array unk4;
|
||||
s32 unk8;
|
||||
void (*unkC)(u16, u16);
|
||||
void (*unk10)(u32);
|
||||
} unkStruct_3000C00;
|
||||
|
||||
// TODO: make static once whole file is decompiled
|
||||
#define UNK_3000400_ARR_COUNT 0x200
|
||||
#define UNK_3000C00_ARR_COUNT 0x21
|
||||
IWRAM_DATA RGB_Union gUnknown_3000400[UNK_3000400_ARR_COUNT] = {0};
|
||||
IWRAM_DATA unkStruct_3000C00 gUnknown_3000C00[UNK_3000C00_ARR_COUNT] = {0};
|
||||
|
||||
void sub_8003A34(u16 param_1, u16 idx);
|
||||
void sub_8003AC0(u16, u16);
|
||||
void sub_8003C18(u16, u16);
|
||||
void sub_8003E2C(u16, u16);
|
||||
void sub_8003F60(u16, u16);
|
||||
void sub_8004170(u16, u16);
|
||||
void sub_8004388(u16, u16);
|
||||
void sub_8003B50(u32);
|
||||
void sub_8003D00(u32);
|
||||
void sub_8003EC0(u32);
|
||||
void sub_8004034(u32);
|
||||
void sub_8004264(u32);
|
||||
void sub_8004434(u32);
|
||||
void sub_8003A74(u32);
|
||||
|
||||
NAKED
|
||||
UNUSED static void sub_80035F8(void)
|
||||
{
|
||||
asm_unified(" .text\n"
|
||||
" push {lr}\n"
|
||||
" pop {r0}\n"
|
||||
" bx r0\n");
|
||||
}
|
||||
|
||||
void sub_8003600(void)
|
||||
{
|
||||
unkStruct_3000C00 *it1;
|
||||
RGB_Union *it2;
|
||||
bool8 *r6;
|
||||
s32 i;
|
||||
s32 zero;
|
||||
|
||||
it1 = &gUnknown_3000C00[0];
|
||||
r6 = &gUnknown_3001B58;
|
||||
zero = 0;
|
||||
it2 = &gUnknown_3000400[0];
|
||||
|
||||
for (i = 0; i < UNK_3000400_ARR_COUNT; it2++, i++)
|
||||
{
|
||||
it2->asArr.c[0] = zero;
|
||||
it2->asArr.c[1] = zero;
|
||||
it2->asArr.c[2] = zero;
|
||||
it2->asArr.c[3] = zero;
|
||||
}
|
||||
|
||||
for (i = 0; i < UNK_3000C00_ARR_COUNT; i++, it1++)
|
||||
{
|
||||
it1->unk0 = FALSE;
|
||||
it1->unk2 = 0x100;
|
||||
it1->unk4.c[0] = 0;
|
||||
it1->unk4.c[1] = 0;
|
||||
it1->unk4.c[2] = 0;
|
||||
it1->unk4.c[3] = 0;
|
||||
it1->unk8 = 0;
|
||||
it1->unkC = &sub_8003A34;
|
||||
it1->unk10 = &sub_8003A74;
|
||||
}
|
||||
|
||||
*r6 = TRUE;
|
||||
}
|
||||
|
||||
void sub_8003664(u16 idx, s32 param_2)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4.c[0] = 0;
|
||||
ptr->unk4.c[1] = 0;
|
||||
ptr->unk4.c[2] = 0;
|
||||
ptr->unk4.c[3] = 0;
|
||||
ptr->unk8 = 0;
|
||||
ptr->unkC = &sub_8003AC0;
|
||||
ptr->unk10 = &sub_8003B50;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_80036AC(u16 idx, s32 param_2, RGB_Array param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4 = param_3;
|
||||
ptr->unk8 = 0;
|
||||
ptr->unkC = &sub_8003C18;
|
||||
ptr->unk10 = &sub_8003D00;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_80036F4(u16 idx, s32 param_2, RGB_Array param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4 = param_3;
|
||||
ptr->unk8 = 0;
|
||||
ptr->unkC = &sub_8003E2C;
|
||||
ptr->unk10 = &sub_8003EC0;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void sub_800373C(u16 idx, s32 param_2, s32 param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4.c[0] = 0;
|
||||
ptr->unk4.c[1] = 0;
|
||||
ptr->unk4.c[2] = 0;
|
||||
ptr->unk4.c[3] = 0;
|
||||
ptr->unk8 = param_3;
|
||||
ptr->unkC = &sub_8003F60;
|
||||
ptr->unk10 = &sub_8004034;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_8003780(u16 idx, s32 param_2, RGB_Array param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4 = param_3;
|
||||
ptr->unk8 = 0;
|
||||
ptr->unkC = &sub_8004170;
|
||||
ptr->unk10 = &sub_8004264;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_80037C8(u16 idx, s32 param_2, RGB_Array param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr = &gUnknown_3000C00[idx];
|
||||
|
||||
ptr->unk0 = TRUE;
|
||||
ptr->unk2 = param_2;
|
||||
ptr->unk4 = param_3;
|
||||
ptr->unk8 = 0;
|
||||
ptr->unkC = &sub_8004388;
|
||||
ptr->unk10 = &sub_8004434;
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_8003810(u16 idx, RGB_Union param_2)
|
||||
{
|
||||
unkStruct_3000C00 *a = &gUnknown_3000C00[idx / 16];
|
||||
a->unk0 = TRUE;
|
||||
|
||||
gUnknown_3000400[idx] = param_2;
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void sub_8003844(u16 idx1, u16 idx2)
|
||||
{
|
||||
unkStruct_3000C00 *a = &gUnknown_3000C00[idx1 / 16];
|
||||
a->unk0 = TRUE;
|
||||
|
||||
gUnknown_3000400[idx1].asArr = GbaColorToRGB(idx2);
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
void sub_800388C(u16 idx1, RGB_Union *param_2, s32 param_3)
|
||||
{
|
||||
unkStruct_3000C00 *ptr3;
|
||||
s32 i;
|
||||
u16 idx2 = idx1 / 16;
|
||||
u16 sVar2 = (idx1 + param_3 - 1) / 16;
|
||||
RGB_Union *ptr1 = &gUnknown_3000400[idx1];
|
||||
|
||||
for (i = 0; i < param_3; param_2++, ptr1++, i++)
|
||||
{
|
||||
*ptr1 = *param_2;
|
||||
}
|
||||
|
||||
ptr3 = &gUnknown_3000C00[idx2];
|
||||
|
||||
for (i = idx2; i <= sVar2; i++, ptr3++)
|
||||
{
|
||||
ptr3->unk0 = TRUE;
|
||||
}
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void sub_80038F0(u32 param_1, s16 *param_2, s32 param_3)
|
||||
{
|
||||
u16 idx1;
|
||||
u16 idx2;
|
||||
u16 uVar;
|
||||
RGB_Union *ptr1;
|
||||
unkStruct_3000C00 *ptr2;
|
||||
s32 i;
|
||||
|
||||
idx1 = param_1;
|
||||
idx2 = idx1 / 16;
|
||||
uVar = (idx1 + param_3 - 1) / 16;
|
||||
ptr1 = &gUnknown_3000400[idx1];
|
||||
|
||||
for (i = 0; i < param_3; i++)
|
||||
{
|
||||
ptr1->asArr = GbaColorToRGB(*param_2++);
|
||||
ptr1++;
|
||||
}
|
||||
|
||||
ptr2 = &gUnknown_3000C00[idx2];
|
||||
|
||||
for (i = idx2; i <= uVar; i++, ptr2++)
|
||||
{
|
||||
ptr2->unk0 = TRUE;
|
||||
}
|
||||
|
||||
gUnknown_3001B58 = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED RGB_Array sub_8003978(u16 idx)
|
||||
{
|
||||
return gUnknown_3000400[idx].asArr;
|
||||
}
|
||||
|
||||
static UNUSED u16 sub_8003988(u16 idx)
|
||||
{
|
||||
return RGBToGbaColor(gUnknown_3000400[idx].asArr);
|
||||
}
|
||||
|
||||
static UNUSED void sub_80039A4(u16 idx)
|
||||
{
|
||||
gUnknown_3001B5A |= idx;
|
||||
}
|
||||
|
||||
void sub_80039B8(void)
|
||||
{
|
||||
s32 i;
|
||||
unkStruct_3000C00* ptr1;
|
||||
unkStruct_3000C00* ptr2;
|
||||
|
||||
if (gUnknown_3001B58)
|
||||
{
|
||||
ptr1 = gUnknown_3000C00;
|
||||
if (gUnknown_3000C00[0xf].unk0)
|
||||
{
|
||||
gUnknown_3000C00[0x20].unk0 = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < 0x20; i++, ptr1++)
|
||||
{
|
||||
if (ptr1->unk0)
|
||||
{
|
||||
ptr1->unk10((u16) i);
|
||||
ptr1->unk0 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (gUnknown_3000C00[0x20].unk0)
|
||||
{
|
||||
ptr2 = &gUnknown_3000C00[0x20];
|
||||
// here ptr2 == ptr1
|
||||
ptr1->unkC(0x20, 0xf0);
|
||||
ptr2->unk0 = FALSE;
|
||||
}
|
||||
|
||||
gUnknown_3001B5A = 3;
|
||||
gUnknown_3001B58 = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_8003A34(u16 param_1, u16 idx)
|
||||
{
|
||||
RGB_Union *ptr1;
|
||||
u32 blue;
|
||||
u32 green;
|
||||
u32 red;
|
||||
u16 color;
|
||||
|
||||
ptr1 = &gUnknown_3000400[idx];
|
||||
blue = (ptr1->asArr.c[2] & 0xf8) << 7;
|
||||
green = (ptr1->asArr.c[1] & 0xf8) << 2;
|
||||
blue |= green;
|
||||
red = (ptr1->asArr.c[0] & 0xf8) >> 3;
|
||||
color = red | blue;
|
||||
SetBGPaletteBufferColor(idx, &color);
|
||||
}
|
||||
|
||||
void sub_8003A74(u32 param_1)
|
||||
{
|
||||
u16 idx;
|
||||
RGB_Union *ptr1;
|
||||
u32 red;
|
||||
u32 green;
|
||||
u32 blue;
|
||||
s32 i;
|
||||
u16 color;
|
||||
|
||||
idx = param_1 * 16;
|
||||
ptr1 = &gUnknown_3000400[idx];
|
||||
|
||||
for (i = 0; i < 16; ptr1++, i++)
|
||||
{
|
||||
blue = (ptr1->asArr.c[2] & 0xf8) << 7;
|
||||
green = (ptr1->asArr.c[1] & 0xf8) << 2;
|
||||
blue |= green;
|
||||
red = (ptr1->asArr.c[0] & 0xf8) >> 3;
|
||||
color = red | blue;
|
||||
SetBGPaletteBufferColor(idx + i, &color);
|
||||
}
|
||||
}
|
||||
@@ -7,16 +7,13 @@
|
||||
#include "def_filearchives.h"
|
||||
#include "event_flag.h"
|
||||
#include "file_system.h"
|
||||
#include "palette_fade_util.h"
|
||||
|
||||
extern u8 gUnknown_20398B8;
|
||||
|
||||
extern void sub_8003600(void);
|
||||
extern s32 sub_800388C(u16, const u8 *, u8);
|
||||
extern void sub_8003810(u16 idx, RGB_Array param_2);
|
||||
|
||||
void sub_8099648(void)
|
||||
{
|
||||
sub_8003600();
|
||||
InitPaletteFadeTable();
|
||||
sub_809965C();
|
||||
}
|
||||
|
||||
@@ -31,7 +28,7 @@ void sub_809965C(void)
|
||||
|
||||
file = OpenFileAndGetFileDataPtr("fontsppa", &gSystemFileArchive);
|
||||
|
||||
sub_800388C(0x1f0, file->data, 0x10);
|
||||
sub_800388C(0x1f0, (const RGB_Union *) file->data, 0x10);
|
||||
CloseFile(file);
|
||||
}
|
||||
|
||||
@@ -62,7 +59,7 @@ void sub_8099690(u32 param_1)
|
||||
break;
|
||||
}
|
||||
|
||||
sub_800388C(0xF0, (u8 *)pal, 0x10);
|
||||
sub_800388C(0xF0, (const RGB_Union *)pal, 0x10);
|
||||
var2 = pal;
|
||||
for(index = 0; index < 0x10; index++)
|
||||
{
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
#include "gba_color_util.h"
|
||||
|
||||
// Note: All of these functions are unused, because RGBToGbaColor and GbaColorToRGB are only called by unused functions. Could've been used for testing only?
|
||||
|
||||
u16 RGBToGbaColor(RGB_Array s)
|
||||
{
|
||||
return ((s.c[RGB_B] & 0xF8) << 7) | ((s.c[RGB_G] & 0xF8) << 2) | ((s.c[RGB_R] & 0xF8) >> 3);
|
||||
return RGB_TO_GBA2(s.c[RGB_R], s.c[RGB_G], s.c[RGB_B]);
|
||||
}
|
||||
|
||||
RGB_Array GbaColorToRGB(u16 color)
|
||||
|
||||
@@ -20,7 +20,6 @@ extern const FileArchive gGroundFileArchive;
|
||||
|
||||
void sub_80A456C(GroundBg *groundBg, s32 id, const PixelPos *srcPos);
|
||||
static void CloseOpenedFiles(GroundBg *groundBg);
|
||||
void sub_80A3BB0(GroundBg *groundBg, s32 a0);
|
||||
static void sub_80A3EB0(SubStruct_488 *map488);
|
||||
static const u8 *sub_80A3908(u16 **dstArray, const void *src_, SubStruct_52C *a2, SubStruct_448 *a3);
|
||||
static void sub_80A37C4(void *vramDst, const u16 *src_, SubStruct_52C *a2, SubStruct_545 *a3);
|
||||
@@ -402,7 +401,7 @@ void sub_80A2FBC(GroundBg *groundBg, s32 mapFileId_)
|
||||
groundBg->unk52A = 1;
|
||||
}
|
||||
|
||||
void sub_80A3440(GroundBg *groundBg, s32 mapFileId_, DungeonLocation *dungLoc, s32 a3)
|
||||
void sub_80A3440(GroundBg *groundBg, s32 mapFileId_, const DungeonLocation *dungLoc, s32 a3)
|
||||
{
|
||||
SubStruct_0 *sub0Ptr;
|
||||
s32 i;
|
||||
|
||||
186
src/ground_map.c
186
src/ground_map.c
@@ -8,12 +8,19 @@
|
||||
#include "ground_script.h"
|
||||
#include "memory.h"
|
||||
#include "ground_map_conversion_table.h"
|
||||
#include "code_800558C.h"
|
||||
#include "constants/dungeon.h"
|
||||
|
||||
IWRAM_INIT GroundMapAction *gGroundMapAction = {NULL};
|
||||
IWRAM_INIT GroundBg *gGroundMapDungeon_3001B70 = {NULL};
|
||||
|
||||
extern GroundMapAction *gGroundMapAction;
|
||||
|
||||
extern const SubStruct_52C gUnknown_8117324;
|
||||
extern const SubStruct_52C gUnknown_8117354;
|
||||
extern const SubStruct_52C gUnknown_811733C;
|
||||
extern const u8 gUnknown_81176A4[];
|
||||
extern const u8 gUnknown_8117700[];
|
||||
extern const u8 gUnknown_8117594[];
|
||||
extern const u8 gUnknown_81175EC[];
|
||||
extern const DebugLocation gUnknown_81175E0;
|
||||
@@ -49,9 +56,8 @@ void FreeGroundMapAction(void)
|
||||
{
|
||||
GroundMap_Reset();
|
||||
sub_80A5EBC();
|
||||
InitAction2((Action *)gGroundMapAction);
|
||||
MemoryFree(gGroundMapAction);
|
||||
gGroundMapAction = NULL;
|
||||
InitAction2(&gGroundMapAction->action);
|
||||
FREE_AND_SET_NULL(gGroundMapAction);
|
||||
}
|
||||
|
||||
void GroundMap_Reset(void)
|
||||
@@ -62,8 +68,7 @@ void GroundMap_Reset(void)
|
||||
|
||||
if (gGroundMapDungeon_3001B70 != NULL) {
|
||||
GroundBg_FreeAll(gGroundMapDungeon_3001B70);
|
||||
MemoryFree(gGroundMapDungeon_3001B70);
|
||||
gGroundMapDungeon_3001B70 = NULL;
|
||||
FREE_AND_SET_NULL(gGroundMapDungeon_3001B70);
|
||||
}
|
||||
|
||||
sub_80A5EDC(0);
|
||||
@@ -202,3 +207,174 @@ s16 GetAdjustedGroundMap(s32 mapId)
|
||||
|
||||
return retMapId;
|
||||
}
|
||||
|
||||
struct MapToDungeonStruct
|
||||
{
|
||||
s16 id;
|
||||
DungeonLocation loc;
|
||||
u32 unk8;
|
||||
};
|
||||
|
||||
extern const struct MapToDungeonStruct gUnknown_81173C0[];
|
||||
extern const u8 gUnknown_81176DC[];
|
||||
extern const u8 gUnknown_8117740[];
|
||||
extern const DebugLocation gUnknown_81176D0;
|
||||
extern const DebugLocation gUnknown_8117734;
|
||||
extern const u32 gUnknown_81176F8[];
|
||||
extern const u32 gUnknown_8117754[];
|
||||
|
||||
void GroundMap_SelectDungeon(s32 mapId, const DungeonLocation *loc, u32 param_2);
|
||||
void sub_80A56D8(const void *);
|
||||
|
||||
void GroundMap_Select(s32 mapId_)
|
||||
{
|
||||
const GroundConversionStruct *ptr;
|
||||
s32 mapId = (s16) mapId_;
|
||||
|
||||
Log(0, gUnknown_81176A4,mapId);
|
||||
ClearScriptVarArray(NULL, MAP_LOCAL);
|
||||
ClearScriptVarArray(NULL, MAP_LOCAL_DOOR);
|
||||
sub_80A5EDC(0);
|
||||
if (gGroundMapDungeon_3001B70 != NULL) {
|
||||
GroundBg_FreeAll(gGroundMapDungeon_3001B70);
|
||||
FREE_AND_SET_NULL(gGroundMapDungeon_3001B70);
|
||||
}
|
||||
gGroundMapDungeon_3001B70 = MemoryAlloc(sizeof(*gGroundMapDungeon_3001B70),6);
|
||||
gGroundMapAction->groundMapId = mapId;
|
||||
if (mapId == -1) {
|
||||
GroundBg_Init(gGroundMapDungeon_3001B70, &gUnknown_8117324);
|
||||
sub_80A2FBC(gGroundMapDungeon_3001B70, mapId);
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = &gGroundMapConversionTable[mapId];
|
||||
switch (ptr->unk0) {
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
GroundBg_Init(gGroundMapDungeon_3001B70, &gUnknown_811733C);
|
||||
gUnknown_2026E4E = 0x1000;
|
||||
break;
|
||||
case 0xA:
|
||||
case 0xB: {
|
||||
const struct MapToDungeonStruct *mapToDungPtr = &gUnknown_81173C0[0];
|
||||
while (mapToDungPtr->id != -1 && mapToDungPtr->id != mapId) {
|
||||
mapToDungPtr++;
|
||||
}
|
||||
FREE_AND_SET_NULL(gGroundMapDungeon_3001B70);
|
||||
GroundMap_SelectDungeon(mapId, &mapToDungPtr->loc, mapToDungPtr->unk8);
|
||||
return;
|
||||
}
|
||||
case -1:
|
||||
FatalError(&gUnknown_81176D0,gUnknown_81176DC,mapId,ptr->unk0);
|
||||
break;
|
||||
default:
|
||||
GroundBg_Init(gGroundMapDungeon_3001B70, &gUnknown_8117324);
|
||||
sub_80A5EDC(1);
|
||||
break;
|
||||
}
|
||||
|
||||
sub_80A2FBC(gGroundMapDungeon_3001B70, ptr->mapFileTableId);
|
||||
gGroundMapAction->unkE8 = 0;
|
||||
gGroundMapAction->unkEC = 0;
|
||||
gGroundMapAction->unkF0 = 0;
|
||||
gGroundMapAction->unkF4 = 0;
|
||||
gGroundMapAction->unkF8.x = 0;
|
||||
gGroundMapAction->unkF8.y = 0;
|
||||
gGroundMapAction->unk100 = gGroundMapAction->unk104 = gGroundMapAction->unk108 = gGroundMapAction->unk10C = 0;
|
||||
|
||||
switch (gGroundMapAction->groundMapId) {
|
||||
case MAP_PERSONALITY_TEST_CYAN:
|
||||
case MAP_PERSONALITY_TEST_PURPLE:
|
||||
case MAP_PERSONALITY_TEST_MULTICOLOR:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,4);
|
||||
gUnknown_2026E4E = 0x808;
|
||||
break;
|
||||
case MAP_FUGITIVES_BLIZZARD_ROAD:
|
||||
case MAP_FUGITIVES_SNOW_ROAD:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,1);
|
||||
break;
|
||||
case MAP_SUMMIT_SUNSET:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,1);
|
||||
case MAP_HILL_OF_THE_ANCIENTS:
|
||||
sub_80A3B80(gGroundMapDungeon_3001B70,0,0);
|
||||
break;
|
||||
case MAP_COMET:
|
||||
gUnknown_2026E4E = 0x1010;
|
||||
break;
|
||||
case MAP_NIGHTMARE:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,4);
|
||||
gUnknown_2026E4E = 0x80C;
|
||||
break;
|
||||
case MAP_NIGHT_SKY_2:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,1);
|
||||
break;
|
||||
case MAP_SILENT_CHASM_ENTRY:
|
||||
gUnknown_2026E4E = 0x1010;
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,4);
|
||||
break;
|
||||
case MAP_NIGHT_SKY_1:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,4);
|
||||
break;
|
||||
case MAP_PELIPPER_POST_OFFICE:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,3);
|
||||
break;
|
||||
case MAP_FRIEND_AREA_FINAL_ISLAND:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,3);
|
||||
break;
|
||||
case MAP_TITLE_SCREEN:
|
||||
sub_80A3BB0(gGroundMapDungeon_3001B70,3);
|
||||
case MAP_INTRO:
|
||||
sub_80A3B80(gGroundMapDungeon_3001B70,0,0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ptr->unk6 != -1) {
|
||||
GroundWeather_Select(ptr->unk6);
|
||||
}
|
||||
|
||||
sub_80A56D8(&gUnknown_81176F8);
|
||||
}
|
||||
|
||||
void GroundMap_SelectDungeon(s32 mapId_, const DungeonLocation *loc, u32 param_2)
|
||||
{
|
||||
const GroundConversionStruct *ptr;
|
||||
s32 mapId = (s16) mapId_;
|
||||
|
||||
Log('\0', gUnknown_8117700, mapId);
|
||||
ClearScriptVarArray(NULL, MAP_LOCAL);
|
||||
ClearScriptVarArray(NULL, MAP_LOCAL_DOOR);
|
||||
sub_80A5EDC('\0');
|
||||
if (gGroundMapDungeon_3001B70 != NULL) {
|
||||
GroundBg_FreeAll(gGroundMapDungeon_3001B70);
|
||||
FREE_AND_SET_NULL(gGroundMapDungeon_3001B70);
|
||||
}
|
||||
|
||||
gGroundMapDungeon_3001B70 = MemoryAlloc(sizeof(*gGroundMapDungeon_3001B70),6);
|
||||
gGroundMapAction->groundMapId = mapId;
|
||||
if (mapId == -1 || loc->id == DUNGEON_INVALID) {
|
||||
GroundBg_Init(gGroundMapDungeon_3001B70, &gUnknown_8117324);
|
||||
sub_80A2FBC(gGroundMapDungeon_3001B70,-1);
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = &gGroundMapConversionTable[mapId];
|
||||
if (ptr->unk0 != 0xA && ptr->unk0 != 0xB) {
|
||||
FatalError(&gUnknown_8117734, gUnknown_8117740, mapId);
|
||||
}
|
||||
|
||||
GroundBg_Init(gGroundMapDungeon_3001B70, &gUnknown_8117354);
|
||||
sub_80A5EDC(1);
|
||||
sub_80A3440(gGroundMapDungeon_3001B70, ptr->mapFileTableId, loc, param_2);
|
||||
gGroundMapAction->unkE8 = 0;
|
||||
gGroundMapAction->unkEC = 0;
|
||||
gGroundMapAction->unkF0 = 0;
|
||||
gGroundMapAction->unkF4 = 0;
|
||||
gGroundMapAction->unkF8.x = 0;
|
||||
gGroundMapAction->unkF8.y = 0;
|
||||
gGroundMapAction->unk100 = gGroundMapAction->unk104 = gGroundMapAction->unk108 = gGroundMapAction->unk10C = 0;
|
||||
|
||||
sub_80A56D8(&gUnknown_8117754);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ extern const s16 gUnknown_811E5F4[][2];
|
||||
extern const u8 gGroundWeatherSelect[];
|
||||
extern const s32 gUnknown_81177BC[];
|
||||
|
||||
extern void sub_80A3BB0(GroundBg *, u32);
|
||||
extern void sub_80A2FBC(GroundBg *, u32);
|
||||
extern void sub_80A49E8(GroundBg *);
|
||||
extern void sub_80A456C(GroundBg *, u32, const s32 *);
|
||||
extern void sub_80A4580(GroundBg *, u32, s32 *);
|
||||
|
||||
646
src/palette_fade_util.c
Normal file
646
src/palette_fade_util.c
Normal file
@@ -0,0 +1,646 @@
|
||||
#include "global.h"
|
||||
#include "globaldata.h"
|
||||
#include "palette_fade_util.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
#include "gba_color_util.h"
|
||||
|
||||
static IWRAM_INIT bool8 sUpdatePaletteFade = FALSE;
|
||||
static IWRAM_INIT u16 sUnusedPaletteUpdateFlags = 0;
|
||||
|
||||
typedef struct PaletteFadeEntry
|
||||
{
|
||||
bool8 active;
|
||||
s16 fadeAmount;
|
||||
RGB_Array fadeColor;
|
||||
RGB_Array *fadeColorArray;
|
||||
void (*applyFadeToSingle)(u16, u16);
|
||||
void (*applyFadeToRow)(u16);
|
||||
} PaletteFadeEntry;
|
||||
|
||||
#define MAX_FADE_AMOUNT 256
|
||||
|
||||
#define PALETTE_COLOR_COUNT 0x200
|
||||
#define PALETTE_FADE_ENTRY_COUNT 0x21
|
||||
|
||||
static IWRAM_DATA RGB_Union sRGBPaletteBuffer[PALETTE_COLOR_COUNT] = {0};
|
||||
static IWRAM_DATA PaletteFadeEntry sPaletteFadeTable[PALETTE_FADE_ENTRY_COUNT] = {0};
|
||||
|
||||
static void ApplySinglePalette(u16 param_1, u16 idx);
|
||||
static void ApplySinglePaletteBrightness(u16, u16);
|
||||
static void BlendSinglePalette(u16, u16);
|
||||
static void FadeToBlackSingle(u16, u16);
|
||||
static void PerEntryBlendSingle(u16, u16);
|
||||
static void DesaturateSingle(u16 fadeIndex, u16);
|
||||
static void ModulatePaletteSingle(u16, u16);
|
||||
static void ApplyRowPaletteBrightness(u16);
|
||||
static void BlendRowPalette(u16);
|
||||
static void FadeToBlackRow(u16);
|
||||
static void PerEntryBlendRow(u16);
|
||||
static void DesaturateRow(u16);
|
||||
static void ModulatePaletteRow(u16);
|
||||
static void ApplyRowPalette(u16);
|
||||
|
||||
NAKED
|
||||
UNUSED static void sub_80035F8(void)
|
||||
{
|
||||
asm_unified(" .text\n"
|
||||
" push {lr}\n"
|
||||
" pop {r0}\n"
|
||||
" bx r0\n");
|
||||
}
|
||||
|
||||
void InitPaletteFadeTable(void)
|
||||
{
|
||||
PaletteFadeEntry *it1;
|
||||
RGB_Union *it2;
|
||||
bool8 *r6;
|
||||
s32 i;
|
||||
s32 zero;
|
||||
|
||||
it1 = &sPaletteFadeTable[0];
|
||||
r6 = &sUpdatePaletteFade;
|
||||
zero = 0;
|
||||
it2 = &sRGBPaletteBuffer[0];
|
||||
|
||||
for (i = 0; i < PALETTE_COLOR_COUNT; it2++, i++)
|
||||
{
|
||||
it2->asArr.c[0] = zero;
|
||||
it2->asArr.c[1] = zero;
|
||||
it2->asArr.c[2] = zero;
|
||||
it2->asArr.c[3] = zero;
|
||||
}
|
||||
|
||||
for (i = 0; i < PALETTE_FADE_ENTRY_COUNT; i++, it1++)
|
||||
{
|
||||
it1->active = FALSE;
|
||||
it1->fadeAmount = 256;
|
||||
it1->fadeColor.c[0] = 0;
|
||||
it1->fadeColor.c[1] = 0;
|
||||
it1->fadeColor.c[2] = 0;
|
||||
it1->fadeColor.c[3] = 0;
|
||||
it1->fadeColorArray = 0;
|
||||
it1->applyFadeToSingle = &ApplySinglePalette;
|
||||
it1->applyFadeToRow = &ApplyRowPalette;
|
||||
}
|
||||
|
||||
*r6 = TRUE;
|
||||
}
|
||||
|
||||
void SetPaletteFade_Brightness(u16 idx, s32 fadeAmount)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor.c[0] = 0;
|
||||
ptr->fadeColor.c[1] = 0;
|
||||
ptr->fadeColor.c[2] = 0;
|
||||
ptr->fadeColor.c[3] = 0;
|
||||
ptr->fadeColorArray = 0;
|
||||
ptr->applyFadeToSingle = &ApplySinglePaletteBrightness;
|
||||
ptr->applyFadeToRow = &ApplyRowPaletteBrightness;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void SetPaletteFade_Blend(u16 idx, s32 fadeAmount, RGB_Array param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor = param_3;
|
||||
ptr->fadeColorArray = 0;
|
||||
ptr->applyFadeToSingle = &BlendSinglePalette;
|
||||
ptr->applyFadeToRow = &BlendRowPalette;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void SetPaletteFade_FadeToBlack(u16 idx, s32 fadeAmount, RGB_Array param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor = param_3;
|
||||
ptr->fadeColorArray = 0;
|
||||
ptr->applyFadeToSingle = &FadeToBlackSingle;
|
||||
ptr->applyFadeToRow = &FadeToBlackRow;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void SetPaletteFade_PerEntryBlend(u16 idx, s32 fadeAmount, RGB_Array *param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor.c[0] = 0;
|
||||
ptr->fadeColor.c[1] = 0;
|
||||
ptr->fadeColor.c[2] = 0;
|
||||
ptr->fadeColor.c[3] = 0;
|
||||
ptr->fadeColorArray = param_3;
|
||||
ptr->applyFadeToSingle = &PerEntryBlendSingle;
|
||||
ptr->applyFadeToRow = &PerEntryBlendRow;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void SetPaletteFade_Desaturate(u16 idx, s32 fadeAmount, RGB_Array param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor = param_3;
|
||||
ptr->fadeColorArray = 0;
|
||||
ptr->applyFadeToSingle = &DesaturateSingle;
|
||||
ptr->applyFadeToRow = &DesaturateRow;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void SetPaletteFade_Modulate(u16 idx, s32 fadeAmount, RGB_Array param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr = &sPaletteFadeTable[idx];
|
||||
|
||||
ptr->active = TRUE;
|
||||
ptr->fadeAmount = fadeAmount;
|
||||
ptr->fadeColor = param_3;
|
||||
ptr->fadeColorArray = 0;
|
||||
ptr->applyFadeToSingle = &ModulatePaletteSingle;
|
||||
ptr->applyFadeToRow = &ModulatePaletteRow;
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void sub_8003810(u16 idx, RGB_Array param_2)
|
||||
{
|
||||
PaletteFadeEntry *a = &sPaletteFadeTable[idx / 16];
|
||||
a->active = TRUE;
|
||||
|
||||
sRGBPaletteBuffer[idx].asArr = param_2;
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void sub_8003844(u16 idx1, u16 idx2)
|
||||
{
|
||||
PaletteFadeEntry *a = &sPaletteFadeTable[idx1 / 16];
|
||||
a->active = TRUE;
|
||||
|
||||
sRGBPaletteBuffer[idx1].asArr = GbaColorToRGB(idx2);
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
void sub_800388C(u16 idx1, const RGB_Union *param_2, s32 param_3)
|
||||
{
|
||||
PaletteFadeEntry *ptr3;
|
||||
s32 i;
|
||||
u16 idx2 = idx1 / 16;
|
||||
u16 sVar2 = (idx1 + param_3 - 1) / 16;
|
||||
RGB_Union *ptr1 = &sRGBPaletteBuffer[idx1];
|
||||
|
||||
for (i = 0; i < param_3; param_2++, ptr1++, i++)
|
||||
{
|
||||
*ptr1 = *param_2;
|
||||
}
|
||||
|
||||
ptr3 = &sPaletteFadeTable[idx2];
|
||||
|
||||
for (i = idx2; i <= sVar2; i++, ptr3++)
|
||||
{
|
||||
ptr3->active = TRUE;
|
||||
}
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED void sub_80038F0(u32 param_1, s16 *param_2, s32 param_3)
|
||||
{
|
||||
u16 idx1;
|
||||
u16 idx2;
|
||||
u16 uVar;
|
||||
RGB_Union *ptr1;
|
||||
PaletteFadeEntry *ptr2;
|
||||
s32 i;
|
||||
|
||||
idx1 = param_1;
|
||||
idx2 = idx1 / 16;
|
||||
uVar = (idx1 + param_3 - 1) / 16;
|
||||
ptr1 = &sRGBPaletteBuffer[idx1];
|
||||
|
||||
for (i = 0; i < param_3; i++)
|
||||
{
|
||||
ptr1->asArr = GbaColorToRGB(*param_2++);
|
||||
ptr1++;
|
||||
}
|
||||
|
||||
ptr2 = &sPaletteFadeTable[idx2];
|
||||
|
||||
for (i = idx2; i <= uVar; i++, ptr2++)
|
||||
{
|
||||
ptr2->active = TRUE;
|
||||
}
|
||||
|
||||
sUpdatePaletteFade = TRUE;
|
||||
}
|
||||
|
||||
static UNUSED RGB_Array sub_8003978(u16 idx)
|
||||
{
|
||||
return sRGBPaletteBuffer[idx].asArr;
|
||||
}
|
||||
|
||||
static UNUSED u16 sub_8003988(u16 idx)
|
||||
{
|
||||
return RGBToGbaColor(sRGBPaletteBuffer[idx].asArr);
|
||||
}
|
||||
|
||||
static UNUSED void sub_80039A4(u16 idx)
|
||||
{
|
||||
sUnusedPaletteUpdateFlags |= idx;
|
||||
}
|
||||
|
||||
void RunPaletteFadeFunctions(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
if (sUpdatePaletteFade) {
|
||||
PaletteFadeEntry* ptr1 = sPaletteFadeTable;
|
||||
if (sPaletteFadeTable[0xf].active) {
|
||||
sPaletteFadeTable[PALETTE_FADE_ENTRY_COUNT - 1].active = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < PALETTE_FADE_ENTRY_COUNT - 1; i++, ptr1++) {
|
||||
if (ptr1->active) {
|
||||
ptr1->applyFadeToRow(i);
|
||||
ptr1->active = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (sPaletteFadeTable[PALETTE_FADE_ENTRY_COUNT - 1].active) {
|
||||
PaletteFadeEntry *ptr2 = &sPaletteFadeTable[PALETTE_FADE_ENTRY_COUNT - 1];
|
||||
// here ptr2 == ptr1
|
||||
ptr1->applyFadeToSingle(0x20, 0xf0);
|
||||
ptr2->active = FALSE;
|
||||
}
|
||||
|
||||
sUnusedPaletteUpdateFlags = 1 | 2;
|
||||
sUpdatePaletteFade = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void ApplySinglePalette(u16 param_1, u16 idx)
|
||||
{
|
||||
RGB_Array *rgb = &sRGBPaletteBuffer[idx].asArr;
|
||||
u16 color = RGB_TO_GBA2(rgb->c[RGB_R], rgb->c[RGB_G], rgb->c[RGB_B]);
|
||||
|
||||
SetBGPaletteBufferColor(idx, &color);
|
||||
}
|
||||
|
||||
static void ApplyRowPalette(u16 param_1)
|
||||
{
|
||||
s32 i;
|
||||
u16 color;
|
||||
u16 idx = param_1 * 16;
|
||||
RGB_Array *rgb = &sRGBPaletteBuffer[idx].asArr;
|
||||
|
||||
for (i = 0; i < 16; rgb++, i++) {
|
||||
color = RGB_TO_GBA(rgb->c[RGB_R], rgb->c[RGB_G], rgb->c[RGB_B]);
|
||||
SetBGPaletteBufferColor(idx + i, &color);
|
||||
}
|
||||
}
|
||||
|
||||
static void ApplySinglePaletteBrightness(u16 idx1, u16 idx2)
|
||||
{
|
||||
u16 color;
|
||||
PaletteFadeEntry *ptr2 = &sPaletteFadeTable[idx1];
|
||||
u16 fadeAmount = ptr2->fadeAmount;
|
||||
RGB_Array *rgb = &sRGBPaletteBuffer[idx2].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
color = RGB_TO_GBA2(rgb->c[RGB_R], rgb->c[RGB_G], rgb->c[RGB_B]);
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
color = RGB_BLACK;
|
||||
}
|
||||
else {
|
||||
color = RGB_TO_GBA((rgb->c[RGB_R] * fadeAmount) / 256,
|
||||
(rgb->c[RGB_G] * fadeAmount) / 256,
|
||||
(rgb->c[RGB_B] * fadeAmount) / 256);
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColor(idx2, &color);
|
||||
}
|
||||
|
||||
static void ApplyRowPaletteBrightness(u16 param1)
|
||||
{
|
||||
u16 color;
|
||||
s32 i;
|
||||
PaletteFadeEntry *ptr1 = &sPaletteFadeTable[param1];
|
||||
u16 fadeAmount = ptr1->fadeAmount;
|
||||
u16 id = param1 * 16;
|
||||
RGB_Array *rgb = &sRGBPaletteBuffer[id].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
for (i = 0; i < 16; rgb++, i++) {
|
||||
color = RGB_TO_GBA(rgb->c[RGB_R], rgb->c[RGB_G], rgb->c[RGB_B]);
|
||||
SetBGPaletteBufferColor(id + i, &color);
|
||||
}
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
color = RGB_BLACK;
|
||||
for (i = 0; i < 16; rgb++, i++) {
|
||||
SetBGPaletteBufferColor(id + i, &color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < 16; rgb++, i++) {
|
||||
color = RGB_TO_GBA((rgb->c[RGB_R] * fadeAmount) / 256,
|
||||
(rgb->c[RGB_G] * fadeAmount) / 256,
|
||||
(rgb->c[RGB_B] * fadeAmount) / 256);
|
||||
SetBGPaletteBufferColor(id + i, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void BlendSinglePalette(u16 fadeIdx, u16 paletteIdx)
|
||||
{
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeRGB = fade->fadeColor;
|
||||
RGB_Array *paletteRGB = &sRGBPaletteBuffer[paletteIdx].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
// Just use the palette color directly
|
||||
color = RGB_TO_GBA2(paletteRGB->c[RGB_R], paletteRGB->c[RGB_G], paletteRGB->c[RGB_B]);
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
// Fully faded to target color
|
||||
color = RGB_TO_GBA2(fadeRGB.c[RGB_R], fadeRGB.c[RGB_G], fadeRGB.c[RGB_B]);
|
||||
}
|
||||
else {
|
||||
// Blend
|
||||
u16 invFade = 256 - fadeAmount;
|
||||
s32 invFadeR = fadeRGB.c[RGB_R] * invFade;
|
||||
s32 invFadeG = fadeRGB.c[RGB_G] * invFade;
|
||||
s32 invFadeB = fadeRGB.c[RGB_B] * invFade;
|
||||
color = RGB_TO_GBA2((paletteRGB->c[RGB_R] * fadeAmount + invFadeR) / 256,
|
||||
(paletteRGB->c[RGB_G] * fadeAmount + invFadeG) / 256,
|
||||
(paletteRGB->c[RGB_B] * fadeAmount + invFadeB) / 256);
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColor(paletteIdx, &color);
|
||||
}
|
||||
|
||||
static void BlendRowPalette(u16 fadeIdx)
|
||||
{
|
||||
s32 i;
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeRGB = fade->fadeColor;
|
||||
u16 basePaletteIdx = fadeIdx * 16;
|
||||
RGB_Array *paletteRGB = &sRGBPaletteBuffer[basePaletteIdx].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
// Just use the palette color directly
|
||||
for (i = 0; i < 16; paletteRGB++, i++) {
|
||||
color = RGB_TO_GBA(paletteRGB->c[RGB_R], paletteRGB->c[RGB_G], paletteRGB->c[RGB_B]);
|
||||
SetBGPaletteBufferColor(basePaletteIdx + i, &color);
|
||||
}
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
// Fully faded to target color
|
||||
color = RGB_TO_GBA2(fadeRGB.c[RGB_R], fadeRGB.c[RGB_G], fadeRGB.c[RGB_B]);
|
||||
for (i = 0; i < 16; paletteRGB++, i++) {
|
||||
SetBGPaletteBufferColor(basePaletteIdx + i, &color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Blend
|
||||
u16 invFade = 256 - fadeAmount;
|
||||
s32 invFadeR = fadeRGB.c[RGB_R] * invFade;
|
||||
s32 invFadeG = fadeRGB.c[RGB_G] * invFade;
|
||||
s32 invFadeB = fadeRGB.c[RGB_B] * invFade;
|
||||
for (i = 0; i < 16; paletteRGB++, i++) {
|
||||
color = RGB_TO_GBA((paletteRGB->c[RGB_R] * fadeAmount + invFadeR) / 256,
|
||||
(paletteRGB->c[RGB_G] * fadeAmount + invFadeG) / 256,
|
||||
(paletteRGB->c[RGB_B] * fadeAmount + invFadeB) / 256);
|
||||
SetBGPaletteBufferColor(basePaletteIdx + i, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void FadeToBlackSingle(u16 fadeIdx, u16 targetIdx)
|
||||
{
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeRGB = fade->fadeColor;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
color = RGB_TO_GBA2(fadeRGB.c[RGB_R], fadeRGB.c[RGB_G], fadeRGB.c[RGB_B]);
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
color = RGB_BLACK;
|
||||
}
|
||||
else {
|
||||
color = RGB_TO_GBA((fadeRGB.c[RGB_R] * fadeAmount) / 256,
|
||||
(fadeRGB.c[RGB_G] * fadeAmount) / 256,
|
||||
(fadeRGB.c[RGB_B] * fadeAmount) / 256);
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColor(targetIdx, &color);
|
||||
}
|
||||
|
||||
static void FadeToBlackRow(u16 fadeIdx)
|
||||
{
|
||||
u16 color;
|
||||
s32 i;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeColor = fade->fadeColor;
|
||||
u16 targetStartIdx = fadeIdx * 16;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
color = RGB_TO_GBA2(fadeColor.c[RGB_R], fadeColor.c[RGB_G], fadeColor.c[RGB_B]);
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
color = RGB_BLACK;
|
||||
}
|
||||
else {
|
||||
color = RGB_TO_GBA((fadeColor.c[RGB_R] * fadeAmount) / 256,
|
||||
(fadeColor.c[RGB_G] * fadeAmount) / 256,
|
||||
(fadeColor.c[RGB_B] * fadeAmount) / 256);
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
SetBGPaletteBufferColor(targetStartIdx + i, &color);
|
||||
}
|
||||
}
|
||||
|
||||
static void PerEntryBlendSingle(u16 fadeIdx, u16 targetIdx)
|
||||
{
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array *fadeSubColor = &fade->fadeColorArray[targetIdx % 16];
|
||||
RGB_Array *baseColor = &sRGBPaletteBuffer[targetIdx].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
color = RGB_TO_GBA2(baseColor->c[RGB_R], baseColor->c[RGB_G], baseColor->c[RGB_B]);
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
color = RGB_TO_GBA2(fadeSubColor->c[RGB_R], fadeSubColor->c[RGB_G], fadeSubColor->c[RGB_B]);
|
||||
}
|
||||
else {
|
||||
u16 invFade = 256 - fadeAmount;
|
||||
s32 r = fadeSubColor->c[RGB_R] * invFade + baseColor->c[RGB_R] * fadeAmount;
|
||||
s32 g = fadeSubColor->c[RGB_G] * invFade + baseColor->c[RGB_G] * fadeAmount;
|
||||
s32 b = fadeSubColor->c[RGB_B] * invFade + baseColor->c[RGB_B] * fadeAmount;
|
||||
color = RGB_TO_GBA2(r / 256, g / 256, b / 256);
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColor(targetIdx, &color);
|
||||
}
|
||||
|
||||
static void PerEntryBlendRow(u16 fadeIdx)
|
||||
{
|
||||
u16 color;
|
||||
s32 i;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIdx];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array *fadeColors = fade->fadeColorArray;
|
||||
u16 targetStartIdx = fadeIdx * 16;
|
||||
RGB_Array *baseColors = &sRGBPaletteBuffer[targetStartIdx].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
// Fully use base palette
|
||||
for (i = 0; i < 16; baseColors++, i++) {
|
||||
color = RGB_TO_GBA(baseColors->c[RGB_R], baseColors->c[RGB_G], baseColors->c[RGB_B]);
|
||||
ASM_MATCH_TRICK(i);
|
||||
SetBGPaletteBufferColor(targetStartIdx + i, &color);
|
||||
}
|
||||
}
|
||||
else if (fadeAmount == 0) {
|
||||
// Fully use fade palette
|
||||
for (i = 0; i < 16; fadeColors++, i++) {
|
||||
color = RGB_TO_GBA(fadeColors->c[RGB_R], fadeColors->c[RGB_G], fadeColors->c[RGB_B]);
|
||||
SetBGPaletteBufferColor(targetStartIdx + i, &color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Blend fade and base
|
||||
u16 invFade = 256 - fadeAmount;
|
||||
|
||||
for (i = 0; i < 16; baseColors++, fadeColors++, i++) {
|
||||
s32 r = fadeColors->c[RGB_R] * invFade + baseColors->c[RGB_R] * fadeAmount;
|
||||
s32 g = fadeColors->c[RGB_G] * invFade + baseColors->c[RGB_G] * fadeAmount;
|
||||
s32 b = fadeColors->c[RGB_B] * invFade + baseColors->c[RGB_B] * fadeAmount;
|
||||
color = RGB_TO_GBA(r / 256, g / 256, b / 256);
|
||||
SetBGPaletteBufferColor(targetStartIdx + i, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void DesaturateSingle(u16 fadeIndex, u16 targetIndex)
|
||||
{
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIndex];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeColor = fade->fadeColor;
|
||||
RGB_Array *baseColor = &sRGBPaletteBuffer[targetIndex].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
// No fade, just use base color
|
||||
color = RGB_TO_GBA2(baseColor->c[RGB_R], baseColor->c[RGB_G], baseColor->c[RGB_B] );
|
||||
}
|
||||
else {
|
||||
u16 r, g, b;
|
||||
// Fading to black per channel
|
||||
|
||||
r = fadeColor.c[RGB_R] + ((255 - fadeColor.c[RGB_R]) * fadeAmount) / 256;
|
||||
g = fadeColor.c[RGB_G] + ((255 - fadeColor.c[RGB_G]) * fadeAmount) / 256;
|
||||
b = fadeColor.c[RGB_B] + ((255 - fadeColor.c[RGB_B]) * fadeAmount) / 256;
|
||||
|
||||
color = RGB_TO_GBA2((r * baseColor->c[RGB_R]) / 255, (g * baseColor->c[RGB_G]) / 255, (b * baseColor->c[RGB_B]) / 255);
|
||||
}
|
||||
|
||||
SetBGPaletteBufferColor(targetIndex, &color);
|
||||
}
|
||||
|
||||
static void DesaturateRow(u16 fadeIndex)
|
||||
{
|
||||
s32 i;
|
||||
u16 color;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIndex];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeColor = fade->fadeColor;
|
||||
u16 targetIndex = fadeIndex * 16;
|
||||
RGB_Array *baseColor = &sRGBPaletteBuffer[targetIndex].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT) {
|
||||
for (i = 0; i < 16; baseColor++, i++) {
|
||||
// No fade, just use base color
|
||||
color = RGB_TO_GBA(baseColor->c[RGB_R], baseColor->c[RGB_G], baseColor->c[RGB_B]);
|
||||
SetBGPaletteBufferColor(targetIndex + i, &color);
|
||||
}
|
||||
}
|
||||
else {
|
||||
u16 r, g, b;
|
||||
// Fading to black per channel
|
||||
|
||||
r = fadeColor.c[RGB_R] + ((255 - fadeColor.c[RGB_R]) * fadeAmount) / 256;
|
||||
g = fadeColor.c[RGB_G] + ((255 - fadeColor.c[RGB_G]) * fadeAmount) / 256;
|
||||
b = fadeColor.c[RGB_B] + ((255 - fadeColor.c[RGB_B]) * fadeAmount) / 256;
|
||||
for (i = 0; i < 16; baseColor++, i++) {
|
||||
color = RGB_TO_GBA((r * baseColor->c[RGB_R]) / 255, (g * baseColor->c[RGB_G]) / 255, (b * baseColor->c[RGB_B]) / 255);
|
||||
SetBGPaletteBufferColor(targetIndex + i, &color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ModulatePaletteSingle(u16 fadeIndex, u16 paletteIndex)
|
||||
{
|
||||
u16 color;
|
||||
u16 r, g, b;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIndex];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeColor = fade->fadeColor;
|
||||
RGB_Array *baseColor = &sRGBPaletteBuffer[paletteIndex].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT)
|
||||
fadeAmount = MAX_FADE_AMOUNT;
|
||||
|
||||
r = fadeColor.c[RGB_R] * fadeAmount / 256;
|
||||
g = fadeColor.c[RGB_G] * fadeAmount / 256;
|
||||
b = fadeColor.c[RGB_B] * fadeAmount / 256;
|
||||
color = RGB_TO_GBA2((r * baseColor->c[RGB_R]) / 255, (g * baseColor->c[RGB_G]) / 255, (b * baseColor->c[RGB_B]) / 255);
|
||||
SetBGPaletteBufferColor(paletteIndex, &color);
|
||||
}
|
||||
|
||||
static void ModulatePaletteRow(u16 fadeIndex)
|
||||
{
|
||||
s32 i;
|
||||
u16 color;
|
||||
u16 r, g, b;
|
||||
PaletteFadeEntry *fade = &sPaletteFadeTable[fadeIndex];
|
||||
u16 fadeAmount = fade->fadeAmount;
|
||||
RGB_Array fadeColor = fade->fadeColor;
|
||||
u16 paletteIndex = fadeIndex * 16;
|
||||
RGB_Array *baseColors = &sRGBPaletteBuffer[paletteIndex].asArr;
|
||||
|
||||
if (fadeAmount >= MAX_FADE_AMOUNT)
|
||||
fadeAmount = MAX_FADE_AMOUNT;
|
||||
|
||||
r = fadeColor.c[RGB_R] * fadeAmount / 256;
|
||||
g = fadeColor.c[RGB_G] * fadeAmount / 256;
|
||||
b = fadeColor.c[RGB_B] * fadeAmount / 256;
|
||||
for (i = 0; i < 16; baseColors++, i++) {
|
||||
color = RGB_TO_GBA2((r * baseColors->c[RGB_R]) / 255, (g * baseColors->c[RGB_G]) / 255, (b * baseColors->c[RGB_B]) / 255);
|
||||
SetBGPaletteBufferColor(paletteIndex + i, &color);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,9 @@
|
||||
#include "globaldata.h"
|
||||
#include "palette_util.h"
|
||||
#include "bg_palette_buffer.h"
|
||||
#include "palette_fade_util.h"
|
||||
|
||||
extern void sub_80039B8(void);
|
||||
extern void TransferBGPaletteBuffer(void);
|
||||
extern void sub_80037C8(u16, u32, RGB_Array);
|
||||
extern void sub_8003664(u16 param_1, u16 param_2);
|
||||
extern void sub_80036AC(u16, u32, RGB_Array);
|
||||
extern void sub_80036F4(u16, u32, RGB_Array);
|
||||
extern void sub_8003780(u16, u32, RGB_Array);
|
||||
|
||||
struct UnkStruct_2039958
|
||||
{
|
||||
@@ -45,7 +40,7 @@ static void sub_8099E80(u16 a0, RGB_Array a1);
|
||||
|
||||
void sub_8099744(void)
|
||||
{
|
||||
sub_80039B8();
|
||||
RunPaletteFadeFunctions();
|
||||
}
|
||||
|
||||
void sub_8099750(void)
|
||||
@@ -419,30 +414,30 @@ static void sub_8099DD0(u16 a0)
|
||||
|
||||
for (i = 0; i < 14; i++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i, 0x100);
|
||||
SetPaletteFade_Brightness(i, 0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003664(i, a0);
|
||||
SetPaletteFade_Brightness(i, a0);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 31; i++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i, 0x100);
|
||||
SetPaletteFade_Brightness(i, 0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003664(i, a0);
|
||||
SetPaletteFade_Brightness(i, a0);
|
||||
}
|
||||
}
|
||||
|
||||
sub_8003664(32, a0);
|
||||
SetPaletteFade_Brightness(32, a0);
|
||||
}
|
||||
|
||||
static void sub_8099E58(u16 a0)
|
||||
{
|
||||
sub_8003664(15, a0);
|
||||
sub_8003664(14, a0);
|
||||
sub_8003664(31, a0);
|
||||
SetPaletteFade_Brightness(15, a0);
|
||||
SetPaletteFade_Brightness(14, a0);
|
||||
SetPaletteFade_Brightness(31, a0);
|
||||
}
|
||||
|
||||
static void sub_8099E80(u16 param_1,RGB_Array param_2)
|
||||
@@ -455,221 +450,221 @@ static void sub_8099E80(u16 param_1,RGB_Array param_2)
|
||||
case 1:
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
for (i = 14; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 31; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
for (i = 0; i < 14; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 31; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036AC(i,param_1,param_2);
|
||||
SetPaletteFade_Blend(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
for (i = 14; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 31; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for (i = 0; i < 14; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 31; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_80036F4(i,param_1,param_2);
|
||||
SetPaletteFade_FadeToBlack(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
for (i = 14; i < 16; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 31; i < 32; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
for (i = 0; i < 14; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 31; i++) {
|
||||
if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else {
|
||||
sub_8003780(i,param_1,param_2);
|
||||
SetPaletteFade_Desaturate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < 16; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 32; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
for (i = 14; i < 16; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 31; i < 32; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -693,25 +688,25 @@ static void sub_8099E80(u16 param_1,RGB_Array param_2)
|
||||
case 8:
|
||||
for (i = 0; i < 14; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 16; i < 31; i ++) {
|
||||
if (gUnknown_2039998[i] & 1) {
|
||||
sub_8003664(i,0x100);
|
||||
SetPaletteFade_Brightness(i,0x100);
|
||||
}
|
||||
else if (gUnknown_2039998[i] & 2) {
|
||||
sub_8003664(i,param_1);
|
||||
SetPaletteFade_Brightness(i,param_1);
|
||||
}
|
||||
else {
|
||||
sub_80037C8(i,param_1,param_2);
|
||||
SetPaletteFade_Modulate(i,param_1,param_2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@ extern bool8 IsWaterDungeon(u32 r0);
|
||||
static s32 sub_80ADFB8(s32 a0, s32 a1, s32 a2, s32 a3, u16 *a4, s32 a5, u8 *a6, s32 a7);
|
||||
|
||||
// This function is called when loading a transition between a dungeon and its summit, where the player can continue, save, or go back.
|
||||
void sub_80ADD9C(OpenedFile **a0, OpenedFile **a1, u32 *a2, void *a3, u16 *a4, DungeonLocation *a5, s32 a6, s32 a7, s32 a8, u16 *a9, s32 unused)
|
||||
void sub_80ADD9C(OpenedFile **a0, OpenedFile **a1, u32 *a2, void *a3, u16 *a4, const DungeonLocation *a5, s32 a6, s32 a7, s32 a8, u16 *a9, s32 unused)
|
||||
{
|
||||
OpenedFile *file;
|
||||
s32 r8;
|
||||
|
||||
Reference in New Issue
Block a user