cleanup graphics code

a bit
This commit is contained in:
Henny022p 2025-03-05 14:00:09 +00:00
parent 22c5e38729
commit 96a3e64280
13 changed files with 290 additions and 244 deletions

View File

@ -11,7 +11,7 @@ extern void SetTile(u32 tileIndex, u32 tilePos, u32 layer);
extern void UpdateScrollVram(void);
extern u32 sub_080B1BA4(u32, u32, u32);
extern void LoadResourceAsync(const void* src, u32 dest, u32 size);
extern void LoadResourceAsync(const void* src, void* dest, u32 size);
extern void GenericConfused(struct Entity_*);
extern void sub_08001290(struct Entity_*, u32);
extern void GenericKnockback(struct Entity_*);

View File

@ -560,7 +560,7 @@ extern u8 gManagerCount;
#define TILE(x, y) (((((x)-gRoomControls.origin_x) >> 4) & 0x3F) | ((((y)-gRoomControls.origin_y) >> 4) & 0x3F) << 6)
// Calculate tilePos from x and y coordinates where x and y are already relative to the current room.
#define TILE_LOCAL(x, y) ((((x) >> 4) & 0x3F) | (((y) >> 4) & 0x3F) << 6)
#define TILE_POS(x, y) (x + (y << 6))
#define TILE_POS(x, y) ((x) + ((y) << 6))
#define TILE_POS_X_COMPONENT 0x3f
#define TILE_POS_Y_COMPONENT 0xfc0
#define COORD_TO_TILE(entity) TILE((entity)->x.HALF.HI, (entity)->y.HALF.HI)

View File

@ -5,9 +5,9 @@
typedef struct {
Manager base;
u8 field_0x20;
u8 field_0x21;
u8 field_0x22;
u8 gfxGroup0;
u8 gfxGroup1;
u8 gfxGroup2;
} HyruleTownTileSetManager;
#endif // HYRULETOWNTILESETMANAGER_H

View File

@ -596,7 +596,7 @@ void sub_0801DD58(u32 area, u32 room) {
}
void LoadDungeonMap(void) {
LoadResourceAsync(gDungeonMap, 0x6006000, sizeof(gDungeonMap));
LoadResourceAsync(gDungeonMap, BG_SCREEN_ADDR(12), sizeof(gDungeonMap));
}
void DrawDungeonFeatures(u32 floor, void* data, u32 size) {

View File

@ -283,10 +283,9 @@ u32 CheckRegionOnScreen(u32 x0, u32 y0, u32 x1, u32 y1) {
* Iterate over array of AABBs and check if any fit on screen
*/
u32 CheckRegionsOnScreen(const u16* arr) {
const u16* i;
for (i = arr; *i != 0xff; i += 5) {
if (CheckRegionOnScreen(i[1], i[2], i[3], i[4]))
return *i;
for (; *arr != 0xff; arr += 5) {
if (CheckRegionOnScreen(arr[1], arr[2], arr[3], arr[4]))
return *arr;
}
return 0xff;
}

View File

@ -302,7 +302,7 @@ void HoleManager_InitParallaxBackground(HoleManager* this) {
if (!super->type2)
return;
transition = &gHoleTransitions[super->type];
LoadResourceAsync(&gGlobalGfxAndPalettes[transition->parallax_background->gfx], 0x0600F000, 0x800);
LoadResourceAsync(&gGlobalGfxAndPalettes[transition->parallax_background->gfx], BG_SCREEN_ADDR(30), BG_SCREEN_SIZE);
gScreen.bg3.control = 0x1E07;
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
gScreen.bg3.xOffset = gRoomControls.bg3OffsetX.HALF.HI;

View File

@ -8,106 +8,130 @@
#include "area.h"
#include "asm.h"
#include "flags.h"
#include "functions.h"
#include "main.h"
#include "room.h"
#include "tiles.h"
#include "assets/gfx_offsets.h"
#include "functions.h"
void sub_08059A58(HyruleTownTileSetManager*);
void sub_08059A2C(HyruleTownTileSetManager*);
void HyruleTownTileSetManager_UpdateLoadGfxGroups(HyruleTownTileSetManager*);
void HyruleTownTileSetManager_Reset(HyruleTownTileSetManager*);
static const u16 gUnk_08108398[] = { 0x0, 0x0, 0x0, 0x3f0, 0x200, 0x1, 0x0, 0x280, 0x3f0, 0x140, 0xff };
static const u16 gUnk_081083AE[] = { 0x2, 0x0, 0x0, 0x180, 0x3c0, 0x3, 0x280, 0x0, 0x170, 0x3c0, 0xff };
static const u16 gUnk_081083C4[] = { 0x5, 0x130, 0x1b0, 0x190, 0x140, 0x4, 0x0, 0x0, 0x3f0, 0x3c0, 0xff };
static const u16 gUnk_081083DA[] = { 0x0, 0x0, 0x0, 0x190, 0x1d0, 0x1, 0x0, 0x2a0, 0x190, 0x120, 0xff, 0xff };
static const u16 gUnk_081083F2[] = { 0x5, 0x0, 0x1b0, 0x190, 0x140, 0x4, 0x0, 0x0, 0x190, 0x3c0, 0xff };
// clang-format off
static const u16 gHyruleTownTileSetManager_regions0[] = {
0, 0x000, 0x000, 0x3f0, 0x200,
1, 0x000, 0x280, 0x3f0, 0x140,
0xff
};
static const u16 gHyruleTownTileSetManager_regions1[] = {
2, 0x000, 0x000, 0x180, 0x3c0,
3, 0x280, 0x000, 0x170, 0x3c0,
0xff
};
static const u16 gHyruleTownTileSetManager_regions2[] = {
5, 0x130, 0x1b0, 0x190, 0x140,
4, 0x000, 0x000, 0x3f0, 0x3c0,
0xff
};
static const u16 gHyruleTownTileSetManager_festivalRegions0[] = {
0, 0x000, 0x000, 0x190, 0x1d0,
1, 0x000, 0x2a0, 0x190, 0x120,
0xff
};
static const u16 gHyruleTownTileSetManager_festivalRegions1[] = {
0xff
};
static const u16 gHyruleTownTileSetManager_festivalRegions2[] = {
5, 0x000, 0x1b0, 0x190, 0x140,
4, 0x000, 0x000, 0x190, 0x3c0,
0xff
};
// clang-format on
void sub_08059CC0(u32, u32);
void sub_08059B18(void);
void HyruleTownTileSetManager_LoadGfxGroup(u32, u32);
void HyruleTownTileSetManager_BuildSecondOracleHouse(void);
bool32 sub_08059C8C(HyruleTownTileSetManager*, u32, u8*, const u16*);
bool32 HyruleTownTileSetManager_UpdateRoomGfxGroup(HyruleTownTileSetManager*, u32, u8*, const u16*);
extern u32 gUnk_086E8460;
typedef struct {
u32 field_0x0;
u32 field_0x4;
u32 field_0x8;
u32 field_0xc;
} Unknown;
u32 gfx1;
void* dest1;
u32 gfx2;
void* dest2;
} HyruleTownTileSetManagerGfxInfo;
static const Unknown gUnk_08108408[] = {
#ifdef EU
{ 0x139860, 0x6000000, 0x13f860, 0x6008000 }, { 0x13c860, 0x6000000, 0x142860, 0x6008000 },
{ 0x13a860, 0x6001000, 0x140860, 0x6009000 }, { 0x13d860, 0x6001000, 0x143860, 0x6009000 },
{ 0x13b860, 0x6002000, 0x141860, 0x600a000 }, { 0x13e860, 0x6002000, 0x144860, 0x600a000 }
#else
{ 0x1395e0, 0x6000000, 0x13f5e0, 0x6008000 }, { 0x13c5e0, 0x6000000, 0x1425e0, 0x6008000 },
{ 0x13a5e0, 0x6001000, 0x1405e0, 0x6009000 }, { 0x13d5e0, 0x6001000, 0x1435e0, 0x6009000 },
{ 0x13b5e0, 0x6002000, 0x1415e0, 0x600a000 }, { 0x13e5e0, 0x6002000, 0x1445e0, 0x600a000 }
#endif
static const HyruleTownTileSetManagerGfxInfo gHyruleTownTileSetManagerGfxInfos[] = {
{ offset_gUnk_086D4460 + 0x8000, BG_SCREEN_ADDR(0), offset_gUnk_086D4460 + 0xE000, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086D4460 + 0xB000, BG_SCREEN_ADDR(0), offset_gUnk_086D4460 + 0x11000, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086D4460 + 0x9000, BG_SCREEN_ADDR(2), offset_gUnk_086D4460 + 0xF000, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086D4460 + 0xC000, BG_SCREEN_ADDR(2), offset_gUnk_086D4460 + 0x12000, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086D4460 + 0xA000, BG_SCREEN_ADDR(4), offset_gUnk_086D4460 + 0x10000, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086D4460 + 0xD000, BG_SCREEN_ADDR(4), offset_gUnk_086D4460 + 0x13000, BG_SCREEN_ADDR(20) }
};
static const Unknown gUnk_08108468[] = {
#ifdef EU
{ 0x146060, 0x6000000, 0x14c060, 0x6008000 }, { 0x149060, 0x6000000, 0x14f060, 0x6008000 },
{ 0x147060, 0x6001000, 0x14d060, 0x6009000 }, { 0x14a060, 0x6001000, 0x150060, 0x6009000 },
{ 0x148060, 0x6002000, 0x14e060, 0x600a000 }, { 0x14b060, 0x6002000, 0x151060, 0x600a000 },
#else
{ 0x145de0, 0x6000000, 0x14bde0, 0x6008000 }, { 0x148de0, 0x6000000, 0x14ede0, 0x6008000 },
{ 0x146de0, 0x6001000, 0x14cde0, 0x6009000 }, { 0x149de0, 0x6001000, 0x14fde0, 0x6009000 },
{ 0x147de0, 0x6002000, 0x14dde0, 0x600a000 }, { 0x14ade0, 0x6002000, 0x150de0, 0x600a000 },
#endif
static const HyruleTownTileSetManagerGfxInfo gHyruleTownTileSetManagerGfxInfosFestival[] = {
{ offset_gUnk_086E8460 + 0x800, BG_SCREEN_ADDR(0), offset_gUnk_086E8460 + 0x6800, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086E8460 + 0x3800, BG_SCREEN_ADDR(0), offset_gUnk_086E8460 + 0x9800, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086E8460 + 0x1800, BG_SCREEN_ADDR(2), offset_gUnk_086E8460 + 0x7800, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086E8460 + 0x4800, BG_SCREEN_ADDR(2), offset_gUnk_086E8460 + 0xA800, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086E8460 + 0x2800, BG_SCREEN_ADDR(4), offset_gUnk_086E8460 + 0x8800, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086E8460 + 0x5800, BG_SCREEN_ADDR(4), offset_gUnk_086E8460 + 0xB800, BG_SCREEN_ADDR(20) },
};
extern const u8 gGlobalGfxAndPalettes[];
void HyruleTownTileSetManager_Main(HyruleTownTileSetManager* this) {
if (super->action == 0) {
super->action = 1;
this->field_0x22 = 0xff;
this->field_0x21 = 0xff;
this->field_0x20 = 0xff;
RegisterTransitionManager(this, sub_08059A2C, NULL);
this->gfxGroup2 = 0xff;
this->gfxGroup1 = 0xff;
this->gfxGroup0 = 0xff;
RegisterTransitionManager(this, HyruleTownTileSetManager_Reset, NULL);
SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT);
}
sub_08059A58(this);
HyruleTownTileSetManager_UpdateLoadGfxGroups(this);
}
void sub_08059A2C(HyruleTownTileSetManager* this) {
void HyruleTownTileSetManager_Reset(HyruleTownTileSetManager* this) {
gRoomVars.graphicsGroups[2] = 0xff;
gRoomVars.graphicsGroups[1] = 0xff;
gRoomVars.graphicsGroups[0] = 0xff;
this->field_0x22 = 0xff;
this->field_0x21 = 0xff;
this->field_0x20 = 0xff;
sub_08059A58(this);
this->gfxGroup2 = 0xff;
this->gfxGroup1 = 0xff;
this->gfxGroup0 = 0xff;
HyruleTownTileSetManager_UpdateLoadGfxGroups(this);
}
void sub_08059A58(HyruleTownTileSetManager* this) {
void HyruleTownTileSetManager_UpdateLoadGfxGroups(HyruleTownTileSetManager* this) {
if (gRoomControls.area != AREA_FESTIVAL_TOWN) {
if (sub_08059C8C(this, 0, &this->field_0x20, gUnk_08108398) != 0) {
sub_08059CC0(0, (u32)this->field_0x20);
if (HyruleTownTileSetManager_UpdateRoomGfxGroup(this, 0, &this->gfxGroup0,
gHyruleTownTileSetManager_regions0) != 0) {
HyruleTownTileSetManager_LoadGfxGroup(0, this->gfxGroup0);
}
if (sub_08059C8C(this, 1, &this->field_0x21, gUnk_081083AE) != 0) {
sub_08059CC0(1, this->field_0x21);
if (this->field_0x21 == 2) {
sub_08059B18();
if (HyruleTownTileSetManager_UpdateRoomGfxGroup(this, 1, &this->gfxGroup1,
gHyruleTownTileSetManager_regions1) != 0) {
HyruleTownTileSetManager_LoadGfxGroup(1, this->gfxGroup1);
if (this->gfxGroup1 == 2) {
HyruleTownTileSetManager_BuildSecondOracleHouse();
}
}
if (sub_08059C8C(this, 2, &this->field_0x22, gUnk_081083C4) != 0) {
sub_08059CC0(2, (u32)this->field_0x22);
if (HyruleTownTileSetManager_UpdateRoomGfxGroup(this, 2, &this->gfxGroup2,
gHyruleTownTileSetManager_regions2) != 0) {
HyruleTownTileSetManager_LoadGfxGroup(2, this->gfxGroup2);
}
} else {
if (sub_08059C8C(this, 0, &this->field_0x20, gUnk_081083DA) != 0) {
sub_08059CC0(0, (u32)this->field_0x20);
if (HyruleTownTileSetManager_UpdateRoomGfxGroup(this, 0, &this->gfxGroup0,
gHyruleTownTileSetManager_festivalRegions0) != 0) {
HyruleTownTileSetManager_LoadGfxGroup(0, this->gfxGroup0);
}
if (sub_08059C8C(this, 2, &this->field_0x22, gUnk_081083F2) != 0) {
sub_08059CC0(2, (u32)this->field_0x22);
if (HyruleTownTileSetManager_UpdateRoomGfxGroup(this, 2, &this->gfxGroup2,
gHyruleTownTileSetManager_festivalRegions2) != 0) {
HyruleTownTileSetManager_LoadGfxGroup(2, this->gfxGroup2);
}
}
}
#define COMMON(tmp2, tmp1) (((tmp2) >> 4 & 0x3f) | (((tmp1) + 0x188U) >> 4 & 0x3f) << 6)
void sub_08059B18(void) {
void HyruleTownTileSetManager_BuildSecondOracleHouse(void) {
u32 loopVar;
u32 innerLoopVar;
@ -115,25 +139,25 @@ void sub_08059B18(void) {
for (loopVar = 0; loopVar < 4; ++loopVar) {
for (innerLoopVar = 0; innerLoopVar < 4; ++innerLoopVar) {
SetTileByIndex(loopVar * 0x10 + TILE_TYPE_1195 + innerLoopVar,
COMMON(0x28 + 0x10 * innerLoopVar, loopVar * 0x10), 1);
TILE_LOCAL(0x28 + innerLoopVar * 0x10, 0x188 + loopVar * 0x10), 1);
}
}
for (loopVar = 0; loopVar < 3; ++loopVar) {
for (innerLoopVar = 0; innerLoopVar < 4; ++innerLoopVar) {
SetTileByIndex(loopVar * 0x10 + TILE_TYPE_1088 + innerLoopVar,
COMMON(0x28 + 0x10 * innerLoopVar, loopVar * 0x10), 2);
TILE_LOCAL(0x28 + innerLoopVar * 0x10, 0x188 + loopVar * 0x10), 2);
}
}
SetTileByIndex(TILE_TYPE_214, TILE_POS(2, 23), LAYER_TOP);
SetTileByIndex(TILE_TYPE_215, TILE_POS(3, 23), LAYER_TOP);
LoadResourceAsync(&gUnk_086E8460, 0x6001800, 0x800);
LoadResourceAsync(&gUnk_086E8460, BG_SCREEN_ADDR(3), BG_SCREEN_SIZE);
} else {
if (CheckGlobalFlag(TATEKAKE_TOCHU) != 0) {
for (loopVar = 0; loopVar < 5; ++loopVar) {
for (innerLoopVar = 0; innerLoopVar < 4; ++innerLoopVar) {
SetTileByIndex(loopVar * 0x10 + TILE_TYPE_1190 + innerLoopVar,
COMMON(0x28 + 0x10 * innerLoopVar, loopVar * 0x10), 1);
TILE_LOCAL(0x28 + innerLoopVar * 0x10, 0x188 + loopVar * 0x10), 1);
}
}
SetTileByIndex(TILE_TYPE_1092, TILE_POS(2, 24), LAYER_TOP);
@ -144,55 +168,56 @@ void sub_08059B18(void) {
}
}
bool32 sub_08059C8C(HyruleTownTileSetManager* this, u32 param_2, u8* param_3, const u16* param_4) {
bool32 bVar2;
*param_3 = CheckRegionsOnScreen(param_4);
if ((*param_3 != 0xff) && (gRoomVars.graphicsGroups[param_2] != *param_3)) {
gRoomVars.graphicsGroups[param_2] = *param_3;
bool32 HyruleTownTileSetManager_UpdateRoomGfxGroup(HyruleTownTileSetManager* this, u32 gfxIndex, u8* pGfxGroup,
const u16* regions) {
*pGfxGroup = CheckRegionsOnScreen(regions);
if ((*pGfxGroup != 0xff) && (gRoomVars.graphicsGroups[gfxIndex] != *pGfxGroup)) {
gRoomVars.graphicsGroups[gfxIndex] = *pGfxGroup;
return TRUE;
} else {
return FALSE;
}
return FALSE;
}
void sub_08059CC0(u32 param_1, u32 param_2) {
const Unknown* unknown;
void HyruleTownTileSetManager_LoadGfxGroup(u32 gfxIndex, u32 gfxGroup) {
const HyruleTownTileSetManagerGfxInfo* gfxInfo;
gRoomVars.graphicsGroups[param_1] = param_2;
gRoomVars.graphicsGroups[gfxIndex] = gfxGroup;
if (gRoomControls.area != AREA_FESTIVAL_TOWN) {
unknown = &gUnk_08108408[param_2];
gfxInfo = &gHyruleTownTileSetManagerGfxInfos[gfxGroup];
} else {
unknown = &gUnk_08108468[param_2];
gfxInfo = &gHyruleTownTileSetManagerGfxInfosFestival[gfxGroup];
}
LoadResourceAsync((void*)&gGlobalGfxAndPalettes + unknown->field_0x0, unknown->field_0x4, 0x1000);
LoadResourceAsync((void*)&gGlobalGfxAndPalettes + unknown->field_0x8, unknown->field_0xc, 0x1000);
LoadResourceAsync(&gGlobalGfxAndPalettes[gfxInfo->gfx1], gfxInfo->dest1, BG_SCREEN_SIZE * 2);
LoadResourceAsync(&gGlobalGfxAndPalettes[gfxInfo->gfx2], gfxInfo->dest2, BG_SCREEN_SIZE * 2);
}
void TryLoadPrologueHyruleTown(void) {
u32 tmp;
u32 gfxGroup;
if (gRoomControls.area != AREA_FESTIVAL_TOWN) {
tmp = CheckRegionsOnScreen(gUnk_08108398);
if (tmp != 0xff) {
sub_08059CC0(0, tmp);
gfxGroup = CheckRegionsOnScreen(gHyruleTownTileSetManager_regions0);
if (gfxGroup != 0xff) {
HyruleTownTileSetManager_LoadGfxGroup(0, gfxGroup);
}
tmp = CheckRegionsOnScreen(gUnk_081083AE);
if ((tmp != 0xff) && (sub_08059CC0(1, tmp), tmp == 2)) {
sub_08059B18();
gfxGroup = CheckRegionsOnScreen(gHyruleTownTileSetManager_regions1);
if (gfxGroup != 0xff) {
HyruleTownTileSetManager_LoadGfxGroup(1, gfxGroup);
if (gfxGroup == 2) {
HyruleTownTileSetManager_BuildSecondOracleHouse();
}
}
tmp = CheckRegionsOnScreen(gUnk_081083C4);
if (tmp != 0xff) {
sub_08059CC0(2, tmp);
gfxGroup = CheckRegionsOnScreen(gHyruleTownTileSetManager_regions2);
if (gfxGroup != 0xff) {
HyruleTownTileSetManager_LoadGfxGroup(2, gfxGroup);
}
} else {
tmp = CheckRegionsOnScreen(gUnk_081083DA);
if (tmp != 0xff) {
sub_08059CC0(0, tmp);
gfxGroup = CheckRegionsOnScreen(gHyruleTownTileSetManager_festivalRegions0);
if (gfxGroup != 0xff) {
HyruleTownTileSetManager_LoadGfxGroup(0, gfxGroup);
}
tmp = CheckRegionsOnScreen(gUnk_081083F2);
if (tmp != 0xff) {
sub_08059CC0(2, tmp);
gfxGroup = CheckRegionsOnScreen(gHyruleTownTileSetManager_festivalRegions2);
if (gfxGroup != 0xff) {
HyruleTownTileSetManager_LoadGfxGroup(2, gfxGroup);
}
}
}

View File

@ -7,85 +7,148 @@
#include "manager/minishVillageTileSetManager.h"
#include "asm.h"
#include "common.h"
#include "functions.h"
#include "main.h"
#include "assets/gfx_offsets.h"
#include "functions.h"
void sub_08057E30(void*);
bool32 sub_08057E40(MinishVillageTileSetManager*);
void sub_08057E7C(u32);
void MinishVillageTileSetManager_LoadRoomGfxGroup(void*);
bool32 MinishVillageTileSetManager_UpdateRoomGfxGroup(MinishVillageTileSetManager*);
void MinishVillageTileSetManager_LoadGfxGroup(u32);
extern const u8 gGlobalGfxAndPalettes[];
const u16 gUnk_08108050[0x2A] = {
// clang-format off
const u16 gMinishVillageTileSetManagerRegions[] = {
0, 0x000, 0x020, 0x0E0, 0x0E0,
#ifdef EU
0, 0, 0x20, 0xE0, 0xE0, 1, 0x28, 0x1C8, 0x60, 0x80, 2,
0x188, 0x278, 0xE0, 0xA0, 3, 0x310, 0x178, 0xC0, 0x150, 3, 0x340,
1, 0x028, 0x1C8, 0x060, 0x080,
2, 0x188, 0x278, 0x0E0, 0x0A0,
#else
0, 0, 0x20, 0xE0, 0xE0, 1, 0, 0x1D0, 0x80, 0x60, 2,
0x170, 0x278, 0xF8, 0xA0, 3, 0x310, 0x178, 0xC0, 0x150, 3, 0x340,
1, 0x000, 0x1D0, 0x080, 0x060,
2, 0x170, 0x278, 0x0F8, 0x0A0,
#endif
0x2C8, 0x60, 0x90, 4, 0x1D0, 0, 0x200, 0xE0, 1, 0x108, 0x188,
0xD0, 0x80, 2, 0x1E8, 0x338, 0x50, 0xC0, 0xFF, 0
3, 0x310, 0x178, 0x0C0, 0x150,
3, 0x340, 0x2C8, 0x060, 0x090,
4, 0x1D0, 0x000, 0x200, 0x0E0,
1, 0x108, 0x188, 0x0D0, 0x080,
2, 0x1E8, 0x338, 0x050, 0x0C0,
0xFF,
};
// clang-format on
typedef struct {
u32 gfx;
void* dest;
} MinishVillageTileSetManagerGfxInfo;
const MinishVillageTileSetManagerGfxInfo gMinishVillageTileSetManagerGfxInfos[][8] = {
{
{ offset_gUnk_086AAEE0 + 0x1580, BG_SCREEN_ADDR(0) },
{ offset_gUnk_086AAEE0 + 0x2580, BG_SCREEN_ADDR(2) },
{ offset_gUnk_086AAEE0 + 0x3580, BG_SCREEN_ADDR(4) },
{ offset_gUnk_086AAEE0 + 0x4580, BG_SCREEN_ADDR(6) },
{ offset_gUnk_086AAEE0 + 0x5580, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086AAEE0 + 0x6580, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086AAEE0 + 0x7580, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086AAEE0 + 0x8580, BG_SCREEN_ADDR(22) },
},
{
{ offset_gUnk_086AAEE0 + 0x9580, BG_SCREEN_ADDR(0) },
{ offset_gUnk_086AAEE0 + 0xA580, BG_SCREEN_ADDR(2) },
{ offset_gUnk_086AAEE0 + 0xB580, BG_SCREEN_ADDR(4) },
{ offset_gUnk_086AAEE0 + 0xC580, BG_SCREEN_ADDR(6) },
{ offset_gUnk_086AAEE0 + 0xD580, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086AAEE0 + 0xE580, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086AAEE0 + 0xF580, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086AAEE0 + 0x10580, BG_SCREEN_ADDR(22) },
},
{
{ offset_gUnk_086AAEE0 + 0x11580, BG_SCREEN_ADDR(0) },
{ offset_gUnk_086AAEE0 + 0x12580, BG_SCREEN_ADDR(2) },
{ offset_gUnk_086AAEE0 + 0x13580, BG_SCREEN_ADDR(4) },
{ offset_gUnk_086AAEE0 + 0x14580, BG_SCREEN_ADDR(6) },
{ offset_gUnk_086AAEE0 + 0x15580, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086AAEE0 + 0x16580, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086AAEE0 + 0x17580, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086AAEE0 + 0x18580, BG_SCREEN_ADDR(22) },
},
{
{ offset_gUnk_086AAEE0 + 0x19580, BG_SCREEN_ADDR(0) },
{ offset_gUnk_086AAEE0 + 0x1A580, BG_SCREEN_ADDR(2) },
{ offset_gUnk_086AAEE0 + 0x1B580, BG_SCREEN_ADDR(4) },
{ offset_gUnk_086AAEE0 + 0x1C580, BG_SCREEN_ADDR(6) },
{ offset_gUnk_086AAEE0 + 0x1D580, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086AAEE0 + 0x1E580, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086AAEE0 + 0x1F580, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086AAEE0 + 0x20580, BG_SCREEN_ADDR(22) },
},
{
{ offset_gUnk_086AAEE0 + 0x21580, BG_SCREEN_ADDR(0) },
{ offset_gUnk_086AAEE0 + 0x22580, BG_SCREEN_ADDR(2) },
{ offset_gUnk_086AAEE0 + 0x23580, BG_SCREEN_ADDR(4) },
{ offset_gUnk_086AAEE0 + 0x24580, BG_SCREEN_ADDR(6) },
{ offset_gUnk_086AAEE0 + 0x25580, BG_SCREEN_ADDR(16) },
{ offset_gUnk_086AAEE0 + 0x26580, BG_SCREEN_ADDR(18) },
{ offset_gUnk_086AAEE0 + 0x27580, BG_SCREEN_ADDR(20) },
{ offset_gUnk_086AAEE0 + 0x28580, BG_SCREEN_ADDR(22) },
},
};
const u32 gUnk_081080A4[0x50] = {
#ifdef EU
0x109860, 0x6000000, 0x10a860, 0x6001000, 0x10b860, 0x6002000, 0x10c860, 0x6003000, 0x10d860, 0x6008000,
0x10e860, 0x6009000, 0x10f860, 0x600a000, 0x110860, 0x600b000, 0x111860, 0x6000000, 0x112860, 0x6001000,
0x113860, 0x6002000, 0x114860, 0x6003000, 0x115860, 0x6008000, 0x116860, 0x6009000, 0x117860, 0x600a000,
0x118860, 0x600b000, 0x119860, 0x6000000, 0x11a860, 0x6001000, 0x11b860, 0x6002000, 0x11c860, 0x6003000,
0x11d860, 0x6008000, 0x11e860, 0x6009000, 0x11f860, 0x600a000, 0x120860, 0x600b000, 0x121860, 0x6000000,
0x122860, 0x6001000, 0x123860, 0x6002000, 0x124860, 0x6003000, 0x125860, 0x6008000, 0x126860, 0x6009000,
0x127860, 0x600a000, 0x128860, 0x600b000, 0x129860, 0x6000000, 0x12a860, 0x6001000, 0x12b860, 0x6002000,
0x12c860, 0x6003000, 0x12d860, 0x6008000, 0x12e860, 0x6009000, 0x12f860, 0x600a000, 0x130860, 0x600b000
#else
0x001095E0, 0x06000000, 0x0010A5E0, 0x06001000, 0x0010B5E0, 0x06002000, 0x0010C5E0, 0x06003000, 0x0010D5E0,
0x06008000, 0x0010E5E0, 0x06009000, 0x0010F5E0, 0x0600A000, 0x001105E0, 0x0600B000, 0x001115E0, 0x06000000,
0x001125E0, 0x06001000, 0x001135E0, 0x06002000, 0x001145E0, 0x06003000, 0x001155E0, 0x06008000, 0x001165E0,
0x06009000, 0x001175E0, 0x0600A000, 0x001185E0, 0x0600B000, 0x001195E0, 0x06000000, 0x0011A5E0, 0x06001000,
0x0011B5E0, 0x06002000, 0x0011C5E0, 0x06003000, 0x0011D5E0, 0x06008000, 0x0011E5E0, 0x06009000, 0x0011F5E0,
0x0600A000, 0x001205E0, 0x0600B000, 0x001215E0, 0x06000000, 0x001225E0, 0x06001000, 0x001235E0, 0x06002000,
0x001245E0, 0x06003000, 0x001255E0, 0x06008000, 0x001265E0, 0x06009000, 0x001275E0, 0x0600A000, 0x001285E0,
0x0600B000, 0x001295E0, 0x06000000, 0x0012A5E0, 0x06001000, 0x0012B5E0, 0x06002000, 0x0012C5E0, 0x06003000,
0x0012D5E0, 0x06008000, 0x0012E5E0, 0x06009000, 0x0012F5E0, 0x0600A000, 0x001305E0, 0x0600B000
#endif
};
const u8 gMinishVillateTileSetManagerPaletteGroups[] = { 0x16, 0x17, 0x17, 0x18, 0x18 };
const u8 gUnk_081081E4[] = { 0x16, 0x17, 0x17, 0x18, 0x18 };
#ifdef EU
void MinishVillageTileSetManager_Main(MinishVillageTileSetManager* this) {
u32 tmp;
const u32* tmp2;
s32 tmp3;
u32 gfxGroup;
const MinishVillageTileSetManagerGfxInfo* gfxInfo;
s32 super_timer;
if (super->action == 0) {
super->action = 1;
super->timer = 8;
this->unk_20 = 0xFF;
RegisterTransitionManager(this, sub_08057E30, 0);
#ifndef EU
SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT);
#endif
RegisterTransitionManager(this, MinishVillageTileSetManager_LoadRoomGfxGroup, 0);
}
#ifdef EU
if (gRoomControls.reload_flags)
return;
#endif
if (sub_08057E40(this)) {
tmp = (u32)gRoomVars.graphicsGroups[0];
if (this->unk_20 != tmp) {
this->unk_20 = tmp;
if (MinishVillageTileSetManager_UpdateRoomGfxGroup(this)) {
gfxGroup = (u32)gRoomVars.graphicsGroups[0];
if (this->unk_20 != gfxGroup) {
this->unk_20 = gfxGroup;
super->timer = 0;
}
}
#ifndef EU
if (gRoomControls.reload_flags)
return;
#endif
#ifndef JP
#ifndef EU
gfxGroup = this->unk_20;
#endif
#endif
tmp2 = &gUnk_081080A4[tmp << 4];
tmp3 = super->timer;
if (tmp3 == 0) {
gfxInfo = gMinishVillageTileSetManagerGfxInfos[gfxGroup];
#ifdef EU
super_timer = super->timer;
if (super_timer == 0) {
#else
switch (super->timer) {
case 0:
#endif
gPauseMenuOptions.disabled = 1;
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
LoadResourceAsync(&gGlobalGfxAndPalettes[gfxInfo->gfx], gfxInfo->dest, BG_SCREEN_SIZE * 2);
LoadPaletteGroup(gMinishVillateTileSetManagerPaletteGroups[gfxGroup]);
super->timer++;
#ifdef EU
} else {
switch (tmp3) {
switch (super_timer) {
case 0:
#else
break;
#endif
case 1:
case 2:
case 3:
@ -93,99 +156,58 @@ void MinishVillageTileSetManager_Main(MinishVillageTileSetManager* this) {
case 5:
case 6:
case 7:
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(super->timer << 1)]], tmp2[(super->timer << 1) + 1],
0x1000);
LoadResourceAsync(&gGlobalGfxAndPalettes[gfxInfo[super->timer].gfx], gfxInfo[super->timer].dest,
BG_SCREEN_SIZE * 2);
super->timer++;
#ifdef EU
gPauseMenuOptions.disabled = 0;
#endif
break;
case 8:
#ifndef EU
gPauseMenuOptions.disabled = 0;
super->timer++;
#endif
break;
}
#ifdef EU
}
}
#else
void MinishVillageTileSetManager_Main(MinishVillageTileSetManager* this) {
u32 tmp;
const u32* tmp2;
if (super->action == 0) {
super->action = 1;
super->timer = 8;
this->unk_20 = 0xFF;
SetEntityPriority((Entity*)this, PRIO_PLAYER_EVENT);
RegisterTransitionManager(this, sub_08057E30, 0);
}
if (sub_08057E40(this)) {
tmp = (u32)gRoomVars.graphicsGroups[0];
if (this->unk_20 != tmp) {
this->unk_20 = tmp;
super->timer = 0;
}
}
if (gRoomControls.reload_flags)
return;
#ifndef JP
tmp = this->unk_20;
#endif
tmp2 = &gUnk_081080A4[tmp << 4];
switch (super->timer) {
case 0:
gPauseMenuOptions.disabled = 1;
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
super->timer++;
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(super->timer << 1)]], tmp2[(super->timer << 1) + 1], 0x1000);
super->timer++;
break;
case 8:
gPauseMenuOptions.disabled = 0;
super->timer++;
break;
}
}
#endif
void sub_08057E30(void* this) {
sub_08057E7C(gRoomVars.graphicsGroups[0]);
}
bool32 sub_08057E40(MinishVillageTileSetManager* this) {
u32 tmp = CheckRegionsOnScreen(gUnk_08108050);
if (tmp != 0xFF) {
gRoomVars.graphicsGroups[0] = tmp;
void MinishVillageTileSetManager_LoadRoomGfxGroup(void* this) {
MinishVillageTileSetManager_LoadGfxGroup(gRoomVars.graphicsGroups[0]);
}
bool32 MinishVillageTileSetManager_UpdateRoomGfxGroup(MinishVillageTileSetManager* this) {
u32 gfxGroup = CheckRegionsOnScreen(gMinishVillageTileSetManagerRegions);
if (gfxGroup != 0xFF) {
gRoomVars.graphicsGroups[0] = gfxGroup;
return TRUE;
} else {
return FALSE;
}
return FALSE;
}
void MinishVillageTileSetManger_LoadInitialGfxGroup(void) {
u32 gfxGroup = CheckRegionsOnScreen(gMinishVillageTileSetManagerRegions);
if (gfxGroup != 0xFF) {
MinishVillageTileSetManager_LoadGfxGroup(gfxGroup);
}
}
void sub_08057E64(void) {
u32 tmp = CheckRegionsOnScreen(gUnk_08108050);
if (tmp != 0xFF) {
sub_08057E7C(tmp);
}
}
void sub_08057E7C(u32 unk1) {
u32 tmp;
const u32* tmp2;
void MinishVillageTileSetManager_LoadGfxGroup(u32 gfxGroup) {
u32 i;
const MinishVillageTileSetManagerGfxInfo* gfxInfo;
#ifndef EU
if (unk1 > 4)
if (gfxGroup >= ARRAY_COUNT(gMinishVillageTileSetManagerGfxInfos))
return;
#endif
LoadPaletteGroup(gUnk_081081E4[unk1]);
tmp2 = &gUnk_081080A4[unk1 << 4];
for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) {
DmaCopy32(3, &gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x400 * 4);
LoadPaletteGroup(gMinishVillateTileSetManagerPaletteGroups[gfxGroup]);
gfxInfo = gMinishVillageTileSetManagerGfxInfos[gfxGroup];
for (i = 0; i < ARRAY_COUNT(gMinishVillageTileSetManagerGfxInfos[0]); i++, gfxInfo++) {
DmaCopy32(3, &gGlobalGfxAndPalettes[gfxInfo->gfx], gfxInfo->dest, BG_SCREEN_SIZE * 2);
}
gRoomVars.graphicsGroups[0] = unk1;
gRoomVars.graphicsGroups[0] = gfxGroup;
}

View File

@ -140,7 +140,7 @@ void sub_080596E0(WeatherChangeManager* this) {
break;
case 4:
MemClear(gBG3Buffer, 0x800);
LoadResourceAsync(gBG3Buffer, 0x600e800, 0x800);
LoadResourceAsync(gBG3Buffer, BG_SCREEN_ADDR(29), BG_SCREEN_SIZE);
break;
case 5:
gMapTop.bgSettings = &gScreen.bg1;

View File

@ -380,9 +380,9 @@ void FigurineMenu_080A4978(void) {
LoadPalettes(fig->pal, 0x16, 9);
gfx = fig->gfx;
if (fig->size < 0) {
LZ77UnCompVram(gfx, (void*)0x6014000);
LZ77UnCompVram(gfx, OBJ_VRAM0 + 0x4000);
} else {
LoadResourceAsync(gfx, 0x6014000, fig->size);
LoadResourceAsync(gfx, OBJ_VRAM0 + 0x4000, fig->size);
}
}
}

View File

@ -813,7 +813,7 @@ static void DispCursor(void) {
}
static void DrawCanvasLine(void) {
LoadResourceAsync(gTextGfxBuffer, 0x0600D040, sizeof(gTextGfxBuffer));
LoadResourceAsync(gTextGfxBuffer, BG_SCREEN_ADDR(26) + 0x40, sizeof(gTextGfxBuffer));
}
void sub_08056F88(u32 unk_1, u32 unk_2) {

View File

@ -17,7 +17,7 @@
#include "functions.h"
extern u32 sub_08060354(void);
extern void sub_08057E64(void);
extern void MinishVillageTileSetManger_LoadInitialGfxGroup(void);
extern void sub_0809F814(u32);
extern void sub_080300E8(void);
extern void sub_08058D34(void);
@ -1796,7 +1796,7 @@ void sub_StateChange_MinishVillage_Main(void) {
if (!CheckLocalFlag(KOBITO_MORI_1ST)) {
LoadRoomEntityList(&gUnk_080DC4C0);
}
sub_08057E64();
MinishVillageTileSetManger_LoadInitialGfxGroup();
}
u32 sub_unk3_MinishVillage_SideHouse(void) {
@ -1814,8 +1814,8 @@ typedef struct {
extern struct_086D4460 gUnk_086D4460;
void sub_unk2_MinishVillage_SideHouse(void) {
LoadResourceAsync(&gUnk_086D4460.LO, 0x6000000, 0x4000);
LoadResourceAsync(&gUnk_086D4460.HI, 0x6008000, 0x4000);
LoadResourceAsync(&gUnk_086D4460.LO, BG_SCREEN_ADDR(0), BG_SCREEN_SIZE * 8);
LoadResourceAsync(&gUnk_086D4460.HI, BG_SCREEN_ADDR(16), BG_SCREEN_SIZE * 8);
LoadPaletteGroup(0x19);
}

View File

@ -741,7 +741,7 @@ void sub_0805F918(u32 idx, u32 idx2, void* dest) {
idx3++;
}
}
LoadResourceAsync((const void*)&gUnk_02036AD8, (u32)dest, 0xe0);
LoadResourceAsync(&gUnk_02036AD8, dest, 0xe0);
}
u32 sub_0805F9A0(u32 r0) {