fix bg structs

This commit is contained in:
theo3 2021-02-28 18:48:00 -08:00
parent 082b0c03a3
commit 721c7ede10
13 changed files with 68 additions and 70 deletions

View File

@ -12,30 +12,28 @@ typedef struct {
typedef struct {
u16 bg0Control;
u16 bg1Control;
u16 bg2Control;
u16 bg3Control;
u16 bg0xOffset;
u16 bg0yOffset;
u16 bg0Updated;
void* bg0Tilemap;
u16 bg1Control;
u16 bg1xOffset;
u16 bg1yOffset;
u16 bg2xOffset;
u16 bg2yOffset;
void* unk_14;
u16 bg1Updated;
void* bg1Tilemap;
} BgSettings;
typedef struct {
u16 bg2Control;
u16 bg2xOffset;
u16 bg2yOffset;
u16 unk;
u16 unk2;
u16 unk3;
u16 bg2Updated;
void* bg2Tilemap;
u16 bg3Control;
s16 bg3xOffset;
s16 bg3yOffset;
u16 unk4;
void* unk5;
u16 bg3Updated;
void* bg3Tilemap;
} BgAffSettings;
typedef struct {

View File

@ -61,8 +61,8 @@ void sub_0802A2FC(Entity* this) {
}
void sub_0802A334(Entity* this) {
u32 x = (this->x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1yOffset) >> 3;
u32 y = (this->y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg2xOffset) >> 3;
u32 x = (this->x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1xOffset) >> 3;
u32 y = (this->y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg1yOffset) >> 3;
if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
this->collisionLayer = 2;
} else {
@ -72,8 +72,8 @@ void sub_0802A334(Entity* this) {
}
void sub_0802A39C(Entity* this) {
u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1yOffset) >> 3;
u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg2xOffset - 10) >> 3;
u32 x = (gPlayerEntity.x.HALF.HI - gRoomControls.roomScrollX + gScreen.bg.bg1xOffset) >> 3;
u32 y = (gPlayerEntity.y.HALF.HI - gRoomControls.roomScrollY + gScreen.bg.bg1yOffset - 10) >> 3;
if (gBG3Buffer[(x & 0x1fU) + (y & 0x1fU) * 0x20 + 0x400]) {
this->flags &= ~0x80;
} else {

View File

@ -100,19 +100,19 @@ void CreateDialogBox(u32 arg0, u32 arg1) {
if (sfx) {
SoundReq(sfx);
}
gScreen.bg.bg3Control = BGCNT_PRIORITY(1);
gScreen.bg.bg0Updated = 1;
}
void sub_08050384(void) {
sub_0801C4A0(0, 0);
MemClear32(&gBG0Buffer, sizeof(gBG0Buffer));
gScreen.bg.bg3Control = BGCNT_PRIORITY(1);
gScreen.bg.bg0Updated = 1;
}
void sub_080503A8(u32 gfxGroup) {
LoadGfxGroup(gfxGroup);
gScreen.bg.bg2yOffset = 1;
gScreen.affine.unk = 1;
gScreen.bg.bg1Updated = 1;
gScreen.affine.bg2Updated = 1;
}
void SetFileSelectState(FileSelectState mode) {
@ -153,10 +153,10 @@ void HandleChooseFileScreen(void) {
sScreenHandlers[gMain.funcIndex]();
if (gUnk_02032EC0.lastState != gUnk_02032EC0.state) {
gUnk_02032EC0.lastState = gUnk_02032EC0.state;
gScreen.bg.bg1Control = 0;
gScreen.bg.bg2Control = 0;
gScreen.bg.bg0xOffset = 0;
gScreen.bg.bg0yOffset = 0;
gScreen.bg.bg1xOffset = 0;
gScreen.bg.bg1yOffset = 0;
gScreen.bg.bg2xOffset = 0;
gScreen.affine.bg2xOffset = 0;
gScreen.affine.bg2yOffset = 0;
MemClear32(&gChooseFileState, sizeof(gChooseFileState));
@ -493,7 +493,7 @@ void sub_08050AFC(u32 idx) {
if (gUnk_02019EE0.saveStatus[idx] == SAVE_VALID) {
sub_08050B3C(&gBG1Buffer.unk29C);
}
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1Updated = 1;
}
typedef struct {
@ -827,7 +827,7 @@ void sub_08051090(void) {
sub_08050790();
sub_0805070C();
sub_08051458();
gScreen.bg.bg2xOffset = 0xff;
gScreen.bg.bg1yOffset = 0xff;
gScreen.affine.bg2yOffset = 0xff;
sub_080A7114(1);
}

View File

@ -99,7 +99,7 @@ static void HandleNintendoCapcomLogos(void) {
}
LoadPaletteGroup(paletteGroup);
gScreen.lcd.displayControl |= DISPCNT_BG2_ON;
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1Updated = 1;
DoFade(6, 8);
advance = ADVANCE_NONE;
} else {
@ -140,16 +140,16 @@ static void HandleTitlescreen(void) {
// Blend first and second layer
gScreen.controls.layerFXControl = BLDCNT_TGT1_BG2 | BLDCNT_TGT2_BG3 | BLDCNT_EFFECT_BLEND;
gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9);
gScreen.bg.bg1xOffset = 0x1c09;
gScreen.bg.bg1Control = 0x1c09;
gScreen.affine.bg2Control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.affine.bg3Control = BGCNT_SCREENBASE(30) | BGCNT_PRIORITY(3);
gScreen.lcd.displayControl |= DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON;
gScreen.bg.bg2xOffset = 0xff60;
gScreen.bg.bg1yOffset = 0xff60;
} else {
gScreen.controls.layerFXControl = BLDCNT_TGT1_BG0 | BLDCNT_TGT2_BG1 | BLDCNT_EFFECT_BLEND;
gScreen.controls.alphaBlend = BLDALPHA_BLEND(9, 9);
gScreen.bg.bg0Control = BGCNT_SCREENBASE(29) | BGCNT_PRIORITY(2);
gScreen.bg.bg1xOffset = 0x1E03;
gScreen.bg.bg1Control = 0x1E03;
gScreen.affine.bg2Control = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(2) | BGCNT_256COLOR |
BGCNT_SCREENBASE(28) | BGCNT_WRAP | BGCNT_TXT512x256;
gScreen.lcd.displayControl |= DISPCNT_MODE_1;
@ -233,13 +233,13 @@ static void HandleJapaneseTitlescreenAnimationIntro(void) {
case 0:
if (!gFadeControl.active) {
if ((gIntroState.counter & 1) == 0) {
gScreen.bg.bg2xOffset++;
gScreen.bg.bg1yOffset++;
}
if (GetAdvanceState() == ADVANCE_KEY_PRESSED || gScreen.bg.bg2xOffset == 0) {
if (GetAdvanceState() == ADVANCE_KEY_PRESSED || gScreen.bg.bg1yOffset == 0) {
gIntroState.subState++;
gScreen.bg.bg2xOffset = 0;
gScreen.bg.bg1xOffset = 0xc09;
gScreen.bg.bg1yOffset = 0;
gScreen.bg.bg1Control = 0xc09;
gFadeControl.field_0x4 = 0x40;
DoFade(6, 0x10);
SoundReq(0xf8);

View File

@ -33,7 +33,7 @@ void sub_080570B8(Entity* this) {
this->height.WORD = 0;
pbVar1 = ((u8*)&this->field_0x20 + 1);
if (*pbVar1 == 3) {
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Updated = 1;
} else {
gUnk_08107C48[*pbVar1](this);
}

View File

@ -499,10 +499,10 @@ void sub_0805AAF0(u32 unk0) {
gScreen.controls.layerFXControl = 0x3E48;
gScreen.controls.alphaBlend = 0x1008;
gScreen.affine.bg3Control = 0x1E04;
gScreen.affine.unk5 = &gBG3Buffer;
gScreen.affine.bg3Tilemap = &gBG3Buffer;
gScreen.affine.bg3xOffset = 0;
gScreen.affine.bg3yOffset = 0;
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Updated = 1;
gScreen.controls.windowInsideControl = 0x3F3F;
gScreen.controls.windowOutsideControl = 0x37;
gScreen.controls.window1HorizontalDimensions = 0xF0;

View File

@ -9,8 +9,8 @@ extern void sub_0805754C(Entity*);
void Manager2(Entity* this) {
if (this->action == 0) {
this->action = 1;
gScreen.affine.unk4 = 0;
gScreen.bg.bg2yOffset = 0;
gScreen.affine.bg3Updated = 0;
gScreen.bg.bg1Updated = 0;
sub_08052D74(this, sub_080576A0, 0);
}
sub_0805754C(this);

View File

@ -69,7 +69,7 @@ void sub_0805E18C(Manager39* this) {
void sub_0805E1D8(Manager39* this) {
MemClear32(&gUnk_02034DF0, 0x80);
gScreen.bg.bg3Control = 1;
gScreen.bg.bg0Updated = 1;
DeleteThisEntity();
}
@ -89,5 +89,5 @@ void sub_0805E1F8(u32 unk0, u32 unk1) {
if (!unk1)
tmp2 = gUnk_08108E30;
sub_0805F46C(&tmp, tmp2);
gScreen.bg.bg3Control = 1;
gScreen.bg.bg0Updated = 1;
}

View File

@ -25,8 +25,8 @@ void sub_08057ED0(Manager8* this) {
sub_08057F20(this);
if (!this->manager.action) {
this->manager.action = 1;
gScreen.bg.bg2yOffset = 0;
gScreen.affine.unk4 = 0;
gScreen.bg.bg1Updated = 0;
gScreen.affine.bg3Updated = 0;
sub_08052D74(this, sub_08057EFC, 0);
}
}
@ -50,23 +50,23 @@ void sub_08057F20(Manager8* this) {
tmp = tmp + (tmp >> 3) + ((0x400 - gRoomControls.width) / 2);
gScreen.affine.bg3xOffset = tmp & 0xF;
gScreen.affine.bg3yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 2);
gScreen.affine.unk5 = gBG3Buffer;
gScreen.affine.bg3Tilemap = gBG3Buffer;
sub_08058004(tmp, gUnk_02006F00, gBG3Buffer);
tmp = ((tmp >> 4) << 1);
if (this->unk_38 != tmp) {
this->unk_38 = tmp;
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Updated = 1;
}
tmp = (gRoomControls.roomScrollX - gRoomControls.roomOriginX);
tmp = tmp + (tmp >> 2) + ((0x400 - gRoomControls.width) / 2);
gScreen.bg.bg1yOffset = tmp & 0xF;
gScreen.bg.bg2xOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1);
gScreen.bg.unk_14 = gBG3Buffer + 0x800;
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1);
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x800;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x800);
tmp = ((tmp >> 4) << 1);
if (this->unk_3c != tmp) {
this->unk_3c = tmp;
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1Updated = 1;
}
}
@ -121,16 +121,16 @@ void sub_080580B0(u32 unk1) {
gScreen.affine.bg3xOffset = tmp & 0xF;
gScreen.affine.bg3yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.affine.bg3Control = 0x1D09;
gScreen.affine.unk5 = gBG3Buffer;
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Tilemap = gBG3Buffer;
gScreen.affine.bg3Updated = 1;
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX; // r7
tmp = tmp + (tmp >> 2) + (0x400 - gRoomControls.width) / 2;
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gBG3Buffer + 0x800);
gScreen.bg.bg1yOffset = tmp & 0xF;
gScreen.bg.bg2xOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg.bg1xOffset = 0x1E09;
gScreen.bg.unk_14 = gBG3Buffer + 0x800;
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1xOffset = tmp & 0xF;
gScreen.bg.bg1yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY)) >> 1); //?
gScreen.bg.bg1Control = 0x1E09;
gScreen.bg.bg1Tilemap = gBG3Buffer + 0x800;
gScreen.bg.bg1Updated = 1;
gScreen.controls.layerFXControl = 0x3C48;
gScreen.controls.alphaBlend = 0x609;
gScreen.lcd.displayControl |= 0xa00;

View File

@ -26,7 +26,7 @@ void sub_080581D8(Manager9* this) {
sub_08058210(this);
if (!this->manager.action) {
this->manager.action = 1;
gScreen.bg.bg2yOffset = 0;
gScreen.bg.bg1Updated = 0;
sub_08052D74(this, sub_08058204, NULL);
}
}
@ -41,7 +41,7 @@ void sub_08058210(Manager9* this) {
return;
this->unk_3c = tmp;
sub_080582A0(tmp, gUnk_02006F00, gBG3Buffer);
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1Updated = 1;
}
u32 sub_08058244(int i) {
@ -50,9 +50,9 @@ u32 sub_08058244(int i) {
u32 tmp3;
s32 tmp4;
tmp = ((gRoomControls.roomScrollY - gRoomControls.roomOriginY) * 0x20) / (gRoomControls.height - 0xa0);
gScreen.bg.bg2xOffset = gRoomControls.roomOriginY + tmp;
gScreen.bg.bg1yOffset = gRoomControls.roomOriginY + tmp;
tmp = (((gRoomControls.roomScrollX - gRoomControls.roomOriginX) * gUnk_081081EC[i]) / (gRoomControls.width - 0xf0));
gScreen.bg.bg1yOffset = tmp & 0xf;
gScreen.bg.bg1xOffset = tmp & 0xf;
return tmp;
}
@ -92,8 +92,8 @@ void sub_08058324(u32 unk) {
LoadGfxGroup(unk + 0x36);
sub_080582D0();
sub_080582A0(sub_08058244(unk), gUnk_02006F00, gBG3Buffer);
gScreen.bg.bg1xOffset = 0x1D47;
gScreen.bg.unk_14 = gBG3Buffer;
gScreen.bg.bg2yOffset = 1;
gScreen.bg.bg1Control = 0x1D47;
gScreen.bg.bg1Tilemap = gBG3Buffer;
gScreen.bg.bg1Updated = 1;
gScreen.lcd.displayControl |= 0x200;
}

View File

@ -26,12 +26,12 @@ void sub_0805FA04(void) {
MemClear32((void*)&gBG0Buffer, sizeof(BGBuffer));
MemClear32((void*)&gBG3Buffer, 0x1000);
gScreen.lcd.displayControl = 0x940;
gScreen.bg.bg1Control = 0;
gScreen.bg.bg2Control = 0;
gScreen.bg.bg0xOffset = 0;
gScreen.bg.bg0yOffset = 0;
gScreen.affine.bg3xOffset = 0;
gScreen.affine.bg3yOffset = 0;
gScreen.affine.bg3Control = 0x1e0f;
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Updated = 1;
MessageInitialize();
MemClear32((void*)&gUnk_02032EC0, sizeof(UI));
MemClear32((void*)&gMenu, sizeof(Menu));
@ -95,7 +95,7 @@ void sub_0805FA98(void) {
}
}
gMenu.focusCoords[1] = (gMenu.focusCoords[1] + 3) % 3;
gScreen.affine.unk4 = 1;
gScreen.affine.bg3Updated = 1;
}
void sub_0805FBC4() {

View File

@ -42,7 +42,7 @@ void DoFade(u32 fadeType, u32 fadeSpeed) {
}
if ((fadeType & 8) != 0) {
gUnk_03000000.spritesOffset = 1;
gScreen.bg.bg1xOffset |= 0x40;
gScreen.bg.bg1Control |= 0x40;
gScreen.affine.bg2Control |= 0x40;
gScreen.affine.bg3Control |= 0x40;
}

View File

@ -44,12 +44,12 @@ void sub_080A3BD0(void) {
LoadGfxGroup(iVar1 + 0x76);
gScreen.lcd.displayControl |= 0x1e00;
gScreen.bg.bg1xOffset = 0x1c01;
gScreen.bg.bg1Control = 0x1c01;
gScreen.affine.bg2Control = 0x1d02;
gScreen.affine.bg3Control = 0x1e0b;
gScreen.bg.bg2yOffset = 1;
gScreen.affine.unk = 1;
gScreen.affine.unk4 = 1;
gScreen.bg.bg1Updated = 1;
gScreen.affine.bg2Updated = 1;
gScreen.affine.bg3Updated = 1;
sub_080A4528();
sub_080A4398();
sub_0801E738(0);