mirror of
https://github.com/zeldaret/tmc
synced 2026-08-04 09:09:32 -04:00
Decompile graphics group loading function
This commit is contained in:
+6
-6
@@ -3,7 +3,7 @@
|
||||
extern void LoadPalettes(const u8*, int, int);
|
||||
|
||||
extern u32 gUsedPalettes;
|
||||
extern u16 gPaletteBuffer[][16];
|
||||
extern u16 gPaletteBuffer[];
|
||||
|
||||
typedef struct {
|
||||
u16 paletteId;
|
||||
@@ -12,17 +12,17 @@ typedef struct {
|
||||
} PaletteGroup;
|
||||
|
||||
extern const PaletteGroup* gPaletteGroups[];
|
||||
extern const u8 gGlobalPalettes[][32];
|
||||
extern const u8 gGlobalGfxAndPalettes[];
|
||||
|
||||
void LoadPaletteGroup(u32 arg0) {
|
||||
const PaletteGroup* paletteGroup = gPaletteGroups[arg0];
|
||||
void LoadPaletteGroup(u32 group) {
|
||||
const PaletteGroup* paletteGroup = gPaletteGroups[group];
|
||||
while (1) {
|
||||
u32 destPaletteNum = paletteGroup->destPaletteNum;
|
||||
u32 numPalettes = paletteGroup->numPalettes & 0xF;
|
||||
if (numPalettes == 0) {
|
||||
numPalettes = 16;
|
||||
}
|
||||
LoadPalettes(gGlobalPalettes[paletteGroup->paletteId], destPaletteNum, numPalettes);
|
||||
LoadPalettes(&gGlobalGfxAndPalettes[paletteGroup->paletteId * 32], destPaletteNum, numPalettes);
|
||||
if ((paletteGroup->numPalettes & 0x80) == 0) {
|
||||
break;
|
||||
}
|
||||
@@ -38,6 +38,6 @@ void LoadPalettes(const u8* src, int destPaletteNum, int numPalettes) {
|
||||
usedPalettesMask |= (usedPalettesMask << 1);
|
||||
}
|
||||
gUsedPalettes |= usedPalettesMask;
|
||||
dest = gPaletteBuffer[destPaletteNum];
|
||||
dest = &gPaletteBuffer[destPaletteNum * 16];
|
||||
DmaCopy32(3, src, dest, size);
|
||||
}
|
||||
|
||||
Executable
+96
@@ -0,0 +1,96 @@
|
||||
#include "global.h"
|
||||
#include "screen.h"
|
||||
#include "structures.h"
|
||||
|
||||
extern u16 gPaletteBuffer[];
|
||||
extern u32 gUsedPalettes;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
int raw;
|
||||
struct {
|
||||
u8 filler0[0x3];
|
||||
u8 unk3;
|
||||
} bytes;
|
||||
} unk0;
|
||||
u32 dest;
|
||||
u32 unk8;
|
||||
} GfxItem;
|
||||
|
||||
extern const GfxItem* gUnk_08100AA8[];
|
||||
extern const u8 gGlobalGfxAndPalettes[];
|
||||
|
||||
void sub_0801D79C(u32 colorIndex, u32 color) {
|
||||
gPaletteBuffer[colorIndex] = color;
|
||||
gUsedPalettes |= 1 << (colorIndex / 16);
|
||||
}
|
||||
|
||||
void sub_0801D7BC(u32 color, u32 arg1) {
|
||||
if (arg1) {
|
||||
gScreen.lcd.unk6 = 0xE0FF;
|
||||
} else {
|
||||
gScreen.lcd.unk6 = 0xFFFF;
|
||||
}
|
||||
sub_0801D79C(0, color);
|
||||
}
|
||||
|
||||
void LoadGfxGroup(u32 group) {
|
||||
u32 terminator;
|
||||
u32 dmaCtrl;
|
||||
int gfxOffset;
|
||||
const u8* src;
|
||||
u32 dest;
|
||||
int size;
|
||||
const GfxItem* gfxItem = gUnk_08100AA8[group];
|
||||
while (1) {
|
||||
u32 loadGfx = FALSE;
|
||||
u32 ctrl = gfxItem->unk0.bytes.unk3;
|
||||
ctrl &= 0xF;
|
||||
switch (ctrl) {
|
||||
case 0x7:
|
||||
loadGfx = TRUE;
|
||||
break;
|
||||
case 0xD:
|
||||
return;
|
||||
case 0xE:
|
||||
if (((struct_02000000 *)0x2000000)->gameLanguage > 1) {
|
||||
loadGfx = TRUE;
|
||||
}
|
||||
break;
|
||||
case 0xF:
|
||||
if (((struct_02000000 *)0x2000000)->gameLanguage != 0) {
|
||||
loadGfx = TRUE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (ctrl == ((struct_02000000 *)0x2000000)->gameLanguage) {
|
||||
loadGfx = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (loadGfx) {
|
||||
gfxOffset = gfxItem->unk0.raw & 0xFFFFFF;
|
||||
src = &gGlobalGfxAndPalettes[gfxOffset];
|
||||
dest = gfxItem->dest;
|
||||
size = gfxItem->unk8;
|
||||
dmaCtrl = 0x80000000;
|
||||
if (size < 0) {
|
||||
if (dest >= VRAM) {
|
||||
LZ77UnCompVram(src, (void*)dest);
|
||||
} else {
|
||||
LZ77UnCompWram(src, (void*)dest);
|
||||
}
|
||||
} else {
|
||||
DmaSet(3, src, dest, dmaCtrl | ((u32)size >> 1));
|
||||
}
|
||||
}
|
||||
|
||||
terminator = gfxItem->unk0.bytes.unk3;
|
||||
terminator &= 0x80;
|
||||
gfxItem++;
|
||||
if (!terminator) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -64,22 +64,22 @@ void HandleIntroScreen(void)
|
||||
static void sub_080AD3F4(void)
|
||||
{
|
||||
u32 iVar1;
|
||||
u32 uVar2;
|
||||
u32 paletteGroup;
|
||||
|
||||
iVar1 = sub_080AD84C();
|
||||
if (gMenu.menuType == 0) {
|
||||
sub_0801DA90(1);
|
||||
gMenu.menuType = 1;
|
||||
gMenu.transitionTimer = 120;
|
||||
sub_0801D7EC(0x10);
|
||||
sub_0801D7EC(1);
|
||||
LoadGfxGroup(16);
|
||||
LoadGfxGroup(1);
|
||||
if (((struct_02000000 *)0x2000000)->gameLanguage == 0) {
|
||||
uVar2 = 1;
|
||||
paletteGroup = 1;
|
||||
}
|
||||
else {
|
||||
uVar2 = 2;
|
||||
paletteGroup = 2;
|
||||
}
|
||||
LoadPaletteGroup(uVar2);
|
||||
LoadPaletteGroup(paletteGroup);
|
||||
gScreen.lcd.lcdControl2 |= 0x400;
|
||||
gScreen.bg2.bg0xOffset = 1;
|
||||
DoFade(6, 8);
|
||||
@@ -107,7 +107,7 @@ extern u8 gUnk_02024490;
|
||||
static void sub_080AD474(void)
|
||||
{
|
||||
int iVar2;
|
||||
u32 uVar3;
|
||||
u32 paletteGroup;
|
||||
|
||||
gMenu.field_0x12++;
|
||||
switch (gMenu.menuType) {
|
||||
@@ -120,14 +120,14 @@ static void sub_080AD474(void)
|
||||
sub_0801CFA8(0);
|
||||
sub_080ADD30();
|
||||
gUnk_02024490 = 1;
|
||||
sub_0801D7EC(2);
|
||||
LoadGfxGroup(2);
|
||||
if (((struct_02000000*)0x2000000)->gameLanguage == 0) {
|
||||
uVar3 = 3;
|
||||
paletteGroup = 3;
|
||||
}
|
||||
else {
|
||||
uVar3 = 4;
|
||||
paletteGroup = 4;
|
||||
}
|
||||
LoadPaletteGroup(uVar3);
|
||||
LoadPaletteGroup(paletteGroup);
|
||||
if (((struct_02000000*)0x2000000)->gameLanguage == 0) {
|
||||
gScreen.controls.windowOutsideControl = 0x844;
|
||||
gScreen.controls.mosaicSize = 0x909;
|
||||
@@ -192,7 +192,7 @@ static void sub_080AD474(void)
|
||||
}
|
||||
if (gMenu.field_0x4 != ((struct_02000000*)0x2000000)->gameLanguage) {
|
||||
gMenu.field_0x4 = ((struct_02000000*)0x2000000)->gameLanguage;
|
||||
sub_0801D7EC(3);
|
||||
LoadGfxGroup(3);
|
||||
}
|
||||
sub_080AD89C();
|
||||
sub_0805E5C0();
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
#include "readKeyInput.h"
|
||||
|
||||
extern void sub_0804FF84(u32);
|
||||
extern u32 gPaletteBuffer;
|
||||
extern u16 gPaletteBuffer[];
|
||||
extern void VBlankInterruptWait(void);
|
||||
extern void DisableInterruptsAndDMA(void);
|
||||
extern void sub_0801D66C(void*, u8*, int);
|
||||
@@ -34,7 +34,7 @@ void MainLoop(void) {
|
||||
sub_08056208();
|
||||
gUnk_02000010.field_0x4 = 193;
|
||||
sub_0804FFE4();
|
||||
DmaSet(3, 0x5000000U, &gPaletteBuffer, 0x84000080U);
|
||||
DmaSet(3, 0x5000000U, gPaletteBuffer, 0x84000080U);
|
||||
sub_0804FF84(1);
|
||||
sub_08056418();
|
||||
sub_080ADD30();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "entity.h"
|
||||
#include "screen.h"
|
||||
|
||||
extern void sub_0801D7EC(u32);
|
||||
extern void LoadGfxGroup(u32);
|
||||
extern void sub_08056250(void);
|
||||
extern void sub_080570B8(Entity*);
|
||||
void sub_080570F8(void);
|
||||
@@ -23,7 +23,7 @@ void Manager1(Entity *this)
|
||||
bVar1 = gUnk_08107C40[((u8*)&this->field_0x20)[1]];
|
||||
if ((bVar1 != 0) && (*(u8 *)&this->field_0x20 != bVar1)) {
|
||||
((u8*)&this->field_0x20)[0] = bVar1;
|
||||
sub_0801D7EC(bVar1);
|
||||
LoadGfxGroup(bVar1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void sub_080570B8(Entity *this)
|
||||
{
|
||||
u8 *pbVar1;
|
||||
|
||||
sub_0801D7EC(((u8 *)&this->field_0x20)[0]);
|
||||
LoadGfxGroup(((u8 *)&this->field_0x20)[0]);
|
||||
this->height.WORD = 0;
|
||||
pbVar1 = ((u8 *)&this->field_0x20 + 1);
|
||||
if (*pbVar1 == 3) {
|
||||
|
||||
@@ -39,7 +39,7 @@ typedef struct {
|
||||
extern void (*const gUnk_08121C64[])(Entity*);
|
||||
extern void (*const gUnk_08121CCC[])(Entity*);
|
||||
extern const int gUnk_08133368[];
|
||||
extern const u8 gGlobalPalettes[];
|
||||
extern const u8 gGlobalGfxAndPalettes[];
|
||||
extern const struct_08121CD4 gUnk_08121CD4[][4];
|
||||
extern const u8 gUnk_08121D10[];
|
||||
extern const u8 gUnk_08121D38[][8];
|
||||
@@ -88,7 +88,7 @@ void sub_0808E818(Entity* this) {
|
||||
this->field_0x70.BYTES.byte0 = 4;
|
||||
this->animationState = 2;
|
||||
var1 = gUnk_08133368[sub_0807A094(1) - 22] & 0xFFFFFF;
|
||||
LoadPalettes(&gGlobalPalettes[var1], 31, 1);
|
||||
LoadPalettes(&gGlobalGfxAndPalettes[var1], 31, 1);
|
||||
}
|
||||
|
||||
if (gUnk_02032EC0.transitionType == 0) {
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ void sub_080A3BD0(void)
|
||||
gMenu.unk2a = 0;
|
||||
sub_080A4D34();
|
||||
LoadPaletteGroup(0xcb);
|
||||
sub_0801D7EC(0x75);
|
||||
LoadGfxGroup(0x75);
|
||||
|
||||
iVar1 = sub_080A4494();
|
||||
iVar2 = iVar1 + 7;
|
||||
@@ -44,7 +44,7 @@ void sub_080A3BD0(void)
|
||||
iVar1 = max(iVar1, 0);
|
||||
iVar1 = min(iVar1, 6);
|
||||
|
||||
sub_0801D7EC(iVar1 + 0x76);
|
||||
LoadGfxGroup(iVar1 + 0x76);
|
||||
gScreen.lcd.lcdControl2 |= 0x1e00;
|
||||
gScreen.bg1.unk = 0x1c01;
|
||||
gScreen.bg2.unk = 0x1d02;
|
||||
|
||||
Reference in New Issue
Block a user