mirror of
https://github.com/zeldaret/tmc
synced 2026-05-31 09:22:08 -04:00
Merge branch 'master' of https://github.com/zeldaret/tmc
This commit is contained in:
@@ -0,0 +1,495 @@
|
||||
#include "global.h"
|
||||
#include "flags.h"
|
||||
#include "screen.h"
|
||||
#include "manager.h"
|
||||
#include "functions.h"
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
u8 unk_20;
|
||||
u8 unk_21;
|
||||
u8 unk_22;
|
||||
u8 unk_23;//used
|
||||
u16 unk_24;
|
||||
u16 unk_26;
|
||||
void* unk_28;
|
||||
u16 unk_2c;
|
||||
u8 unk_2e[0x6];
|
||||
s16 unk_34;
|
||||
s16 unk_36;
|
||||
s16 unk_38;
|
||||
s16 unk_3a;
|
||||
u16 unk_3c;
|
||||
u16 unk_3e;//used
|
||||
} Manager15;
|
||||
|
||||
extern void (*const gUnk_081085D8[])(Manager*);
|
||||
|
||||
void sub_0805A280(Manager* this) {
|
||||
gUnk_081085D8[this->unk_0a](this);
|
||||
}
|
||||
|
||||
|
||||
void sub_0805A89C(Manager15*);
|
||||
void sub_0805A8EC(Manager15*);
|
||||
void sub_0805AAF0(u32);
|
||||
|
||||
void sub_0805A298(Manager15* this) {
|
||||
if (this->manager.action == 0) {
|
||||
sub_0805A89C(this);
|
||||
if (!CheckLocalFlag(this->unk_3e)) {
|
||||
this->unk_23 = 1;
|
||||
} else {
|
||||
this->unk_23 = 2;
|
||||
}
|
||||
sub_0805AAF0(this->unk_23);
|
||||
gScreen.lcd.displayControl |= 0x4800;
|
||||
}
|
||||
sub_0805A8EC(this);
|
||||
}
|
||||
|
||||
extern void (*const gUnk_081085F8[])(Manager15*);
|
||||
|
||||
void sub_0805A2E4(Manager15* this) {
|
||||
if (this->manager.action == 0) {
|
||||
sub_0805A89C(this);
|
||||
this->unk_23 = 1;
|
||||
sub_0805AAF0(1);
|
||||
if (!CheckLocalFlag(this->unk_3e)) {
|
||||
this->manager.action = 1;
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
} else {
|
||||
if (CheckLocalFlag(0x48)) {
|
||||
this->manager.action = 4;
|
||||
} else {
|
||||
this->manager.action = 3;
|
||||
}
|
||||
gScreen.lcd.displayControl |= 0x4800;
|
||||
}
|
||||
} else {
|
||||
gUnk_081085F8[this->manager.action](this);
|
||||
}
|
||||
if (this->manager.next) {
|
||||
sub_0805A8EC(this);
|
||||
}
|
||||
}
|
||||
|
||||
extern Entity gUnk_080E4C08;
|
||||
|
||||
void sub_0805A370(Manager15* this) {
|
||||
if (this->manager.unk_0d) {
|
||||
LoadRoomEntityList(&gUnk_080E4C08);
|
||||
this->manager.action = 3;
|
||||
PlaySFX(0x80100000);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A394(Manager15* this) {
|
||||
Entity* ent;
|
||||
if ((ent = FindEntityInListBySubtype(0x3,0x13,0x4))) {
|
||||
if (ent->entityType.form != 4) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
SetLocalFlag(0x48);
|
||||
ClearRoomFlag(0);
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
void nullsub_496(Manager15* this) {
|
||||
}
|
||||
|
||||
extern void (*const gUnk_0810860C[])(Manager15*);
|
||||
|
||||
void sub_0805A3D4(Manager15* this) {
|
||||
if (this->manager.action == 0) {
|
||||
sub_0805A89C(this);
|
||||
if (this->manager.unk_0a == 3) {
|
||||
this->unk_23 = 2;
|
||||
} else {
|
||||
this->unk_23 = 1;
|
||||
}
|
||||
sub_0805AAF0(this->unk_23);
|
||||
if (!CheckLocalFlag(this->unk_3e)) {
|
||||
ClearFlag(this->unk_3c);
|
||||
this->manager.action = 1;
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
} else {
|
||||
SetFlag(this->unk_3c);
|
||||
this->manager.action = 3;
|
||||
gScreen.lcd.displayControl |= 0x4800;
|
||||
}
|
||||
} else {
|
||||
gUnk_0810860C[this->manager.action](this);
|
||||
}
|
||||
sub_0805A8EC(this);
|
||||
}
|
||||
|
||||
void sub_0805A4CC(Manager15*, u32);
|
||||
|
||||
void sub_0805A464(Manager15* this) {
|
||||
if (CheckLocalFlag(this->unk_3e)) {
|
||||
this->manager.action = 2;
|
||||
sub_0805A4CC(this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A480(Manager15* this) {
|
||||
if (this->manager.unk_0d != 0) {
|
||||
this->manager.action = 3;
|
||||
SetFlag(this->unk_3c);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A498(Manager15* this) {
|
||||
if (!CheckLocalFlag(this->unk_3e)) {
|
||||
this->manager.action = 4;
|
||||
sub_0805A4CC(this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A4B4(Manager15* this) {
|
||||
if (this->manager.unk_0d != 0) {
|
||||
this->manager.action = 1;
|
||||
ClearFlag(this->unk_3c);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A4CC(Manager15* this, u32 unk_0) {
|
||||
Entity* tmp;
|
||||
tmp = CreateObject(0x8e, unk_0, 0);
|
||||
if (tmp) {
|
||||
tmp->x.HALF.HI = this->unk_38 + gRoomControls.roomOriginX;
|
||||
tmp->y.HALF.HI = this->unk_3a + gRoomControls.roomOriginY - 0x30;
|
||||
tmp->parent = (Entity*) this;
|
||||
this->manager.unk_0d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
extern void (*const gUnk_08108620[])(Manager15*);
|
||||
void sub_0805AA58(Manager15*);
|
||||
void sub_0805A9CC(Manager15*);
|
||||
|
||||
void sub_0805A500(Manager15* this) {
|
||||
if (this->manager.action == 0) {
|
||||
sub_0805A89C(this);
|
||||
this->unk_28 = 0;
|
||||
if (CheckLocalFlag(0x36)) {
|
||||
this->unk_23 = 3;
|
||||
this->manager.action = 5;
|
||||
gScreen.lcd.displayControl |= 0x4800;
|
||||
} else {
|
||||
if (CheckLocalFlag(0x34)) {
|
||||
this->unk_23 = 4;
|
||||
this->manager.action = 3;
|
||||
gScreen.lcd.displayControl |= 0x4800;
|
||||
} else {
|
||||
this->unk_23 = 4;
|
||||
this->manager.action = 1;
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
}
|
||||
}
|
||||
sub_0805AAF0(this->unk_23);
|
||||
} else {
|
||||
gUnk_08108620[this->manager.action](this);
|
||||
}
|
||||
sub_0805AA58(this);
|
||||
sub_0805A9CC(this);
|
||||
if (gRoomControls.unk2 == 1) {
|
||||
gScreen.lcd.displayControl |= 0x80<<7;
|
||||
this->manager.unk_0d = 1;
|
||||
return;
|
||||
}
|
||||
if (!this->manager.unk_0d) return;
|
||||
this->manager.unk_0d = 0;
|
||||
if (this->unk_20 == gRoomControls.roomID) return;
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
void sub_0805A5FC(Manager15* this) {
|
||||
if (CheckLocalFlag(0x34)) {
|
||||
this->manager.action = 2;
|
||||
sub_0805A4CC(this,2);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A618(Manager15* this) {
|
||||
if (this->manager.unk_0d) {
|
||||
this->manager.action = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A628(Manager15* this) {
|
||||
if (CheckLocalFlag(0x36)) {
|
||||
this->manager.action = 4;
|
||||
this->unk_23 = 3;
|
||||
sub_0805A4CC(this,3);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A64C(Manager15* this) {
|
||||
if (this->manager.unk_0d) {
|
||||
this->manager.action = 5;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A65C(Manager15* this) {}
|
||||
void sub_0805A660(Manager15* this) {}
|
||||
|
||||
extern void (*const gUnk_08108638[])(Manager15*);
|
||||
void sub_0805A68C(Manager15*);
|
||||
|
||||
void sub_0805A664(Manager15* this) {
|
||||
gUnk_08108638[this->manager.action](this);
|
||||
sub_0805A8EC(this);
|
||||
sub_0805A68C(this);
|
||||
}
|
||||
|
||||
extern u32 sub_0806FBFC(u32, u32, u32, u32);
|
||||
|
||||
void sub_0805A68C(Manager15* this) {
|
||||
if (sub_0806FBFC(this->unk_38 - 0x18, this->unk_3a - 0x18, 0x30, 0x30)) {
|
||||
if (this->unk_2c <= 0x1007) {
|
||||
gScreen.controls.alphaBlend = ++this->unk_2c;
|
||||
this->unk_22 = 0;
|
||||
}
|
||||
} else {
|
||||
if (this->unk_2c > 0x1000) {
|
||||
this->unk_2c--;
|
||||
}
|
||||
gScreen.controls.alphaBlend=this->unk_2c;
|
||||
}
|
||||
}
|
||||
|
||||
u32 sub_0805A73C(Manager15*);
|
||||
|
||||
void sub_0805A6E8(Manager15* this) {
|
||||
u16 tmp;
|
||||
sub_0805A89C(this);
|
||||
this->unk_23 = 0;
|
||||
sub_0805AAF0(0);
|
||||
this->unk_38 += gRoomControls.roomOriginX;
|
||||
this->unk_3a += gRoomControls.roomOriginY;
|
||||
if (!sub_0805A73C(this)) {
|
||||
this->manager.action++;
|
||||
}
|
||||
this->unk_2c = 0x1000;
|
||||
tmp = gScreen.lcd.displayControl | 0x4800;
|
||||
gScreen.lcd.displayControl = tmp;
|
||||
}
|
||||
|
||||
u32 sub_0805A73C(Manager15* this) {
|
||||
return sub_0806FBFC(this->unk_38 - 0x6, this->unk_3a - 0x6, 0xC, 0xC);
|
||||
}
|
||||
|
||||
void sub_0805A758(Manager15* this) {
|
||||
if (!sub_0805A73C(this)) {
|
||||
this->manager.action++;
|
||||
}
|
||||
}
|
||||
|
||||
extern u8 gUnk_02034490;
|
||||
extern void sub_0805E4E0(Manager*, u32);
|
||||
extern void sub_08077B20(void);
|
||||
|
||||
void sub_0805A76C(Manager15* this) {
|
||||
if ((gPlayerEntity.currentHealth != 0)
|
||||
&& (gPlayerEntity.height.HALF.HI == 0)
|
||||
&& (!gPlayerState.field_0x2c)
|
||||
) {
|
||||
switch (gPlayerState.field_0xa9) {
|
||||
case 1:
|
||||
case 0:
|
||||
if (sub_0805A73C(this)) {
|
||||
this->manager.action++;
|
||||
sub_08004168(&gPlayerEntity);
|
||||
gPlayerEntity.animationState = 4;
|
||||
sub_0805E4E0(&this->manager, 0x258);
|
||||
sub_08078A90(0xFF);
|
||||
gUnk_02034490 = 1;
|
||||
gRoomControls.cameraTarget = 0;
|
||||
sub_08077B20();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A7E4(Manager15* this) {
|
||||
if (gPlayerState.playerAction != 0x12) {
|
||||
gPlayerState.playerAction = 0x12;
|
||||
gPlayerState.field_0x38 = 0;
|
||||
gPlayerState.field_0x39 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A804(Manager15* this) {
|
||||
switch (this->manager.action) {
|
||||
case 0:
|
||||
if (CheckLocalFlag(this->unk_3e)) {
|
||||
this->manager.action = 1;
|
||||
} else {
|
||||
this->manager.action = 2;
|
||||
}
|
||||
this->manager.unk_0d = 1;
|
||||
this->manager.unk_10 |= 0x20;
|
||||
sub_0805E3A0(this, 6);
|
||||
break;
|
||||
case 1:
|
||||
if (CheckLocalFlag(this->unk_3e)) break;
|
||||
this->manager.action = 2;
|
||||
sub_0805A4CC(this,4);
|
||||
break;
|
||||
case 2:
|
||||
if (this->manager.unk_0d) {
|
||||
this->manager.action = 3;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!CheckLocalFlag(this->unk_3e)) break;
|
||||
this->manager.action = 4;
|
||||
sub_0805A4CC(this,4);
|
||||
break;
|
||||
case 4:
|
||||
if (this->manager.unk_0d) {
|
||||
this->manager.action = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DeleteThisEntity();
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805AAC8(Manager15*);
|
||||
extern void sub_08052D74(void*, void*, void*);
|
||||
|
||||
void sub_0805A89C(Manager15* this) {
|
||||
sub_0805E3A0(this, 6);
|
||||
this->manager.action = 1;
|
||||
this->manager.unk_10 |= 0x20;
|
||||
this->manager.unk_0e = 8;
|
||||
this->manager.unk_0f = 0x10;
|
||||
this->unk_21 = 0;
|
||||
this->unk_22 = 0;
|
||||
this->unk_20 = gRoomControls.roomID;
|
||||
this->unk_24 = gRoomControls.roomOriginX;
|
||||
this->unk_26 = gRoomControls.roomOriginY;
|
||||
sub_08052D74(this, sub_0805AAC8, 0);
|
||||
}
|
||||
|
||||
void sub_0805A94C(Manager15* this);
|
||||
|
||||
void sub_0805A8EC(Manager15* this) {
|
||||
sub_0805AA58(this);
|
||||
sub_0805A94C(this);
|
||||
if (gRoomControls.unk2 == 1) {
|
||||
gScreen.lcd.displayControl |= 0x4000;
|
||||
this->manager.unk_0d = 1;
|
||||
} else {
|
||||
if (!this->manager.unk_0d) return;
|
||||
this->manager.unk_0d = 0;
|
||||
if (this->unk_20 == gRoomControls.roomID) return;
|
||||
gScreen.lcd.displayControl &= 0xB7FF;
|
||||
DeleteThisEntity();
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805A94C(Manager15* this) {
|
||||
int tmp1, tmp2;
|
||||
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
|
||||
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY - this->unk_26 + this->unk_36;
|
||||
tmp1 = -gScreen.affine.bg3xOffset;
|
||||
tmp2 = tmp1 + 0x100;
|
||||
if (tmp1 < 0) tmp1 = 0;
|
||||
if (tmp1 > 0xF0) tmp1 = 0xF0;
|
||||
if (tmp2 < 0) tmp2 = 0;
|
||||
if (tmp2 > 0xF0) tmp2 = 0xF0;
|
||||
gScreen.controls.window1HorizontalDimensions = (tmp1 << 8 | tmp2);
|
||||
tmp1 = -gScreen.affine.bg3yOffset;
|
||||
tmp2 = tmp1 + 0x100;
|
||||
if (tmp1 < 0) tmp1 = 0;
|
||||
if (tmp1 > 0xA0) tmp1 = 0xA0;
|
||||
if (tmp2 < 0) tmp2 = 0;
|
||||
if (tmp2 > 0xA0) tmp2 = 0xA0;
|
||||
gScreen.controls.window1VerticalDimensions = (tmp1 << 8 | tmp2);
|
||||
}
|
||||
|
||||
extern u8 gUnk_02001A40[];
|
||||
|
||||
#ifdef NON_MATCHING
|
||||
void sub_0805A9CC(Manager15* this) {
|
||||
int tmp1, tmp2;
|
||||
void* tmp3;
|
||||
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX - this->unk_24 + this->unk_34;
|
||||
tmp1 = -gScreen.affine.bg3xOffset;
|
||||
tmp2 = tmp1 + 0x100;
|
||||
if (tmp1 < 0) tmp1 = 0;
|
||||
if (tmp1 > 0xF0) tmp1 = 0xF0;
|
||||
if (tmp2 < 0) tmp2 = 0;
|
||||
if (tmp2 > 0xF0) tmp2 = 0xF0;
|
||||
gScreen.controls.window1HorizontalDimensions = tmp1 << 8 | tmp2;
|
||||
tmp1 = gRoomControls.roomScrollY - this->unk_26 + this->unk_36;
|
||||
gScreen.affine.bg3yOffset = tmp1 & 0x3F;
|
||||
if (tmp1 < 0) tmp1 += 0x3F;
|
||||
tmp3 = (&gUnk_02001A40[(tmp1 >> 6 << 9)]);
|
||||
gScreen.affine.unk5 = (u32) tmp3;
|
||||
gScreen.controls.window1VerticalDimensions = 0xa0;
|
||||
if (this->unk_28 == tmp3) return;
|
||||
this->unk_28 = tmp3;
|
||||
gScreen.affine.unk4 = 1;
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
void sub_0805A9CC(Manager15* this) {
|
||||
asm(".include \"asm/non_matching/manager15/sub_0805A9CC.inc\"");
|
||||
}
|
||||
#endif
|
||||
|
||||
extern struct {
|
||||
u8 unk_00[0x20];
|
||||
} gUnk_085A97A0[];
|
||||
extern u16 gUnk_081085B8[];
|
||||
extern void LoadPalettes(const u8*, u32, u32);
|
||||
|
||||
void sub_0805AA58(Manager15* this) {
|
||||
if (--this->manager.unk_0e == 0) {
|
||||
this->manager.unk_0e = 8;
|
||||
this->unk_21 += 1;
|
||||
this->unk_21 &= 3;
|
||||
LoadPalettes(gUnk_085A97A0[this->unk_21].unk_00,5,1);
|
||||
}
|
||||
if (--this->manager.unk_0f == 0) {
|
||||
this->manager.unk_0f = 0x10;
|
||||
this->unk_22 += 1;
|
||||
this->unk_22 &= 0xF;
|
||||
gScreen.controls.alphaBlend = gUnk_081085B8[this->unk_22];
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805AAC8(Manager15* this) {
|
||||
sub_0805AAF0(this->unk_23);
|
||||
sub_0805A280(&this->manager);
|
||||
}
|
||||
|
||||
|
||||
extern u16 gUnk_08108648[];
|
||||
|
||||
void sub_0805AADC(u32 unk0) {
|
||||
LoadGfxGroup(gUnk_08108648[unk0]);
|
||||
}
|
||||
|
||||
void sub_0805AAF0(u32 unk0) {
|
||||
sub_0805AADC(unk0);
|
||||
gScreen.controls.layerFXControl = 0x3E48;
|
||||
gScreen.controls.alphaBlend = 0x1008;
|
||||
gScreen.affine.bg3Control = 0x1E04;
|
||||
gScreen.affine.unk5 = &gUnk_02001A40;
|
||||
gScreen.affine.bg3xOffset = 0;
|
||||
gScreen.affine.bg3yOffset = 0;
|
||||
gScreen.affine.unk4 = 1;
|
||||
gScreen.controls.windowInsideControl = 0x3F3F;
|
||||
gScreen.controls.windowOutsideControl = 0x37;
|
||||
gScreen.controls.window1HorizontalDimensions = 0xF0;
|
||||
gScreen.controls.window1VerticalDimensions = 0xA0;
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "flags.h"
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
#include "screen.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
s16 unk_20;
|
||||
s16 unk_22;
|
||||
u16 unk_24;
|
||||
u16 unk_26;
|
||||
u8 unk_28[8];
|
||||
u16 unk_30;
|
||||
u16 unk_32;
|
||||
u16 unk_34;
|
||||
u16 unk_36;
|
||||
u8 unk_38[7];
|
||||
u8 unk_3f;
|
||||
} Manager1A;
|
||||
|
||||
extern void (*const gUnk_08108668[])(Manager1A*);
|
||||
|
||||
extern u8 gGlobalGfxAndPalettes[];
|
||||
|
||||
void sub_0805B030(Manager1A* this) {
|
||||
gUnk_08108668[this->manager.action](this);
|
||||
}
|
||||
|
||||
extern void sub_08052D74(void*, void*, void*);
|
||||
extern u32 sub_0806FBFC(u32, u32, u32, u32);
|
||||
|
||||
typedef struct struct_08108764 {
|
||||
u8 unk_00;
|
||||
u8 unk_01;//area ID?
|
||||
u8 unk_02;//room ID?
|
||||
u8 unk_03;//layer?
|
||||
u16 unk_04;
|
||||
u16 unk_06;
|
||||
u8 unk_08;
|
||||
u8 unk_09;
|
||||
u8 unk_0a;
|
||||
u8 unk_0b;
|
||||
struct {
|
||||
u32 unk_00;
|
||||
u16 unk_04;
|
||||
u16 unk_06;
|
||||
u16 unk_08;
|
||||
u16 unk_0a;
|
||||
}* unk_0c;
|
||||
struct {
|
||||
u8 unk_00;
|
||||
u8 unk_01;
|
||||
u8 unk_02[2];
|
||||
u16 unk_04;
|
||||
u16 unk_06;
|
||||
}* unk_10;
|
||||
} struct_08108764;
|
||||
|
||||
extern struct_08108764 gUnk_08108764[];
|
||||
|
||||
u32 sub_0805B1CC(Manager1A*);
|
||||
void sub_0805B210(Manager1A*);
|
||||
void sub_0805B2B0(Manager1A*);
|
||||
void sub_0805B328(Manager1A*);
|
||||
void sub_0805BC4C(void);
|
||||
|
||||
void sub_0805B048(Manager1A* this) {
|
||||
struct_08108764* tmp;
|
||||
Entity* obj;
|
||||
sub_0805E3A0(&this->manager, 6);
|
||||
_DmaZero(&this->unk_20, 0x20);
|
||||
this->manager.action = 1;
|
||||
this->unk_3f = gRoomControls.roomID;
|
||||
tmp = &gUnk_08108764[this->manager.unk_0a];
|
||||
if (!tmp->unk_0a) {
|
||||
this->unk_20 = gRoomControls.roomOriginX;
|
||||
this->unk_22 = gRoomControls.roomOriginY;
|
||||
this->unk_24 = gRoomControls.width;
|
||||
this->unk_26 = gRoomControls.height;
|
||||
} else {
|
||||
this->unk_20 = (tmp->unk_08 << 4) + gRoomControls.roomOriginX;
|
||||
this->unk_22 = (tmp->unk_09 << 4) + gRoomControls.roomOriginY;
|
||||
this->unk_24 = (tmp->unk_0a << 4);
|
||||
this->unk_26 = (tmp->unk_0b << 4);
|
||||
}
|
||||
this->manager.unk_0b = tmp->unk_0c != 0;
|
||||
if (this->manager.unk_0b) {
|
||||
this->manager.unk_10 |= 0x20;
|
||||
this->unk_34 = tmp->unk_0c->unk_04;
|
||||
this->unk_36 = tmp->unk_0c->unk_06;
|
||||
this->unk_30 = tmp->unk_0c->unk_08;
|
||||
this->unk_32 = tmp->unk_0c->unk_0a;
|
||||
sub_0805BC4C();
|
||||
sub_0805B2B0(this);
|
||||
sub_0805B328(this);
|
||||
sub_08052D74(this, sub_0805B328, 0);
|
||||
}
|
||||
if (!tmp->unk_10) return;
|
||||
obj = CreateObject(0x28, tmp->unk_10->unk_00, tmp->unk_10->unk_01);
|
||||
if (obj) {
|
||||
obj->x.HALF.HI = tmp->unk_10->unk_04 + gRoomControls.roomOriginX;
|
||||
obj->y.HALF.HI = tmp->unk_10->unk_06 + gRoomControls.roomOriginY;
|
||||
}
|
||||
if (this->manager.unk_0a != 0xa
|
||||
|| CheckLocalFlag(0x4B)) return;
|
||||
obj = CreateObject(0x28, 3, 3);
|
||||
if (obj) {
|
||||
obj->x.HALF.HI = tmp->unk_10->unk_04 + gRoomControls.roomOriginX;
|
||||
obj->y.HALF.HI = tmp->unk_10->unk_06 + gRoomControls.roomOriginY;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805B168(Manager1A* this) {
|
||||
if (sub_0805B1CC(this)) {
|
||||
sub_0805B210(this);
|
||||
DeleteThisEntity();
|
||||
return;
|
||||
}
|
||||
sub_0805B2B0(this);
|
||||
if (gRoomControls.unk2 == 1) {
|
||||
this->manager.unk_0d = 1;
|
||||
return;
|
||||
}
|
||||
if (!this->manager.unk_0d) return;
|
||||
this->manager.unk_0d = 0;
|
||||
if (this->unk_3f == gRoomControls.roomID) return;
|
||||
if (this->manager.unk_0b) {
|
||||
gScreen.lcd.displayControl &= ~0x800;
|
||||
}
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
u32 sub_0805B1CC(Manager1A* this) {
|
||||
u32 re = 0;
|
||||
if (sub_0806FBFC(this->unk_20, this->unk_22, this->unk_24, this->unk_26)) {
|
||||
if ((gPlayerState.flags.all & 0x4) && (gPlayerState.flags.all & 0x1)) {
|
||||
gPlayerState.flags.all |= 0x8000;
|
||||
} else if (gPlayerState.flags.all & 0x8000) {
|
||||
re = 1;
|
||||
}
|
||||
}
|
||||
return re;
|
||||
}
|
||||
|
||||
void sub_0805B210(Manager1A* this) {
|
||||
struct_08108764 *tmp;
|
||||
gScreenTransition.transitioningOut = 1;
|
||||
gScreenTransition.transitionType = 1;
|
||||
gScreenTransition.playerState = 4;
|
||||
tmp = &gUnk_08108764[this->manager.unk_0a];
|
||||
gScreenTransition.areaID = tmp->unk_01;
|
||||
gScreenTransition.roomID = tmp->unk_02;
|
||||
gScreenTransition.playerLayer = tmp->unk_03;
|
||||
if (gPlayerState.flags.all & 0x80) {
|
||||
gScreenTransition.field_0xf = 6;
|
||||
} else {
|
||||
gScreenTransition.field_0xf = 2;
|
||||
}
|
||||
switch (tmp->unk_00) {
|
||||
case 0:
|
||||
gScreenTransition.playerStartPos.HALF.x = tmp->unk_04;
|
||||
gScreenTransition.playerStartPos.HALF.y = tmp->unk_06;
|
||||
break;
|
||||
case 1:
|
||||
gScreenTransition.playerStartPos.HALF.x = gPlayerEntity.x.HALF.HI - gRoomControls.roomOriginX + tmp->unk_04;
|
||||
gScreenTransition.playerStartPos.HALF.y = gPlayerEntity.y.HALF.HI - gRoomControls.roomOriginY + tmp->unk_06;
|
||||
break;
|
||||
case 2:
|
||||
gScreenTransition.playerStartPos.HALF.x = tmp->unk_04;
|
||||
gScreenTransition.playerStartPos.HALF.y = tmp->unk_06;
|
||||
gScreenTransition.field_0xf = 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_0805B2B0(Manager1A* this) {
|
||||
s32 tmp, tmp2;
|
||||
if (!this->manager.unk_0b) return;
|
||||
tmp = (this->unk_30 - gRoomControls.roomScrollX) / 4;
|
||||
tmp2 = (this->unk_32 - gRoomControls.roomScrollY) / 4;
|
||||
if (tmp < -12) {
|
||||
tmp = -12;
|
||||
}
|
||||
if (tmp > 12) {
|
||||
tmp = 12;
|
||||
}
|
||||
if (tmp2 < -12) {
|
||||
tmp2 = -12;
|
||||
}
|
||||
if (tmp2 > 12) {
|
||||
tmp2 = 12;
|
||||
}
|
||||
gScreen.lcd.displayControl |= 0x800;
|
||||
gRoomControls.bg3OffsetX.HALF.HI = gRoomControls.roomScrollX + this->unk_34 + tmp;
|
||||
gScreen.affine.bg3xOffset = gRoomControls.roomScrollX + this->unk_34 + tmp;
|
||||
gRoomControls.bg3OffsetY.HALF.HI = gRoomControls.roomScrollY + this->unk_36 + tmp2;
|
||||
gScreen.affine.bg3yOffset = gRoomControls.roomScrollY + this->unk_36 + tmp2;
|
||||
}
|
||||
|
||||
void sub_0805B328(Manager1A* this) {
|
||||
struct_08108764 *tmp;
|
||||
if (!this->manager.unk_0b) return;
|
||||
tmp = &gUnk_08108764[this->manager.unk_0a];
|
||||
LoadAssetAsync(&gGlobalGfxAndPalettes[tmp->unk_0c->unk_00], 0x0600F000, 0x800);
|
||||
gScreen.affine.bg3Control = 0x1E07;
|
||||
gScreen.lcd.displayControl |= 0x800;
|
||||
gScreen.affine.bg3xOffset = gRoomControls.bg3OffsetX.HALF.HI;
|
||||
gScreen.affine.bg3yOffset = gRoomControls.bg3OffsetY.HALF.HI;
|
||||
gScreen.controls.layerFXControl &= ~0x8;
|
||||
}
|
||||
|
||||
void sub_0805B390(u32 unk1) {
|
||||
Manager* tmp = GetEmptyManager();
|
||||
if (!tmp) return;
|
||||
tmp->type = 0x9;
|
||||
tmp->subtype = 0x1A;
|
||||
tmp->unk_0a = unk1;
|
||||
AppendEntityToList(tmp, 6);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "flags.h"
|
||||
#include "entity.h"
|
||||
#include "room.h"
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
u8 unk_20[0x12];
|
||||
u16 unk_32;
|
||||
u8 unk_34[2];
|
||||
u8 unk_36;
|
||||
u8 unk_37;
|
||||
u16 unk_38;
|
||||
u16 unk_3a;
|
||||
u16 unk_3c;
|
||||
u16 unk_3e;
|
||||
} Manager20;
|
||||
|
||||
extern void DeleteManager(Manager20*);
|
||||
|
||||
void sub_0805B7A0(Manager20* this) {
|
||||
Entity* tmp = CreateObject(this->manager.unk_0e, this->manager.unk_0a, this->manager.unk_0b);
|
||||
if (!tmp) return;
|
||||
tmp->field_0x86.HWORD = this->unk_3e;
|
||||
if (CheckFlags(this->unk_3e)) {
|
||||
tmp->x.HALF.HI = this->unk_36 | (this->unk_37&0xF)<<8;//r1
|
||||
tmp->y.HALF.HI = this->unk_3c & 0xFFF;
|
||||
tmp->collisionLayer = this->unk_3c >> 0xC;
|
||||
} else {
|
||||
tmp->x.HALF.HI = this->unk_38;
|
||||
tmp->y.HALF.HI = this->unk_3a;
|
||||
tmp->collisionLayer = this->unk_37>>4;
|
||||
}
|
||||
tmp->x.HALF.HI += gRoomControls.roomOriginX;
|
||||
tmp->y.HALF.HI += gRoomControls.roomOriginY;
|
||||
DeleteManager(this);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "flags.h"
|
||||
#include "functions.h"
|
||||
|
||||
typedef struct Manager30 {
|
||||
Manager manager;
|
||||
u8 unk_20[8];//unused
|
||||
u16 own_tile;
|
||||
u8 unk_2a[0x2];//unused
|
||||
u16 player_previous_tile;
|
||||
u16 player_current_tile;
|
||||
u8 unk_30[0x6];//unused
|
||||
u8 width;
|
||||
u8 height;
|
||||
s16 x;
|
||||
s16 y;
|
||||
u16 flag_succeeded;
|
||||
u16 flag_reset;
|
||||
} Manager30;
|
||||
|
||||
extern void sub_0807B7D8(u32, u32, u32);
|
||||
|
||||
enum {
|
||||
INIT,
|
||||
IN_PROGRESS,
|
||||
FAILED,
|
||||
SUCCEEDED
|
||||
};
|
||||
|
||||
/*
|
||||
* Tile puzzles (step on all blue tiles exactly once).
|
||||
*
|
||||
* The Manager's field 0xe is used for the remaining number of tiles to be changed.
|
||||
* field 0xf is used for the total number of tiles to be changed.
|
||||
*/
|
||||
void Manager30_Main(Manager30* this) {
|
||||
u32 i, j, tmp, tmp2;
|
||||
switch (this->manager.action) {
|
||||
default:
|
||||
break;
|
||||
case INIT:
|
||||
this->manager.action = IN_PROGRESS;
|
||||
this->manager.unk_0f = this->manager.unk_0e;
|
||||
this->own_tile = (((this->x >> 4) & 0x3fU) |
|
||||
((this->y >> 4) & 0x3fU) << 6);
|
||||
this->player_previous_tile = this->player_current_tile = COORD_TO_TILE((&gPlayerEntity));
|
||||
break;
|
||||
case 1:
|
||||
this->player_current_tile = COORD_TO_TILE((&gPlayerEntity));
|
||||
if (this->player_current_tile != this->player_previous_tile) {
|
||||
this->player_previous_tile = this->player_current_tile;
|
||||
switch (GetTileType(this->player_current_tile, this->manager.unk_0b)) {
|
||||
case 0x317:
|
||||
//stepped on a red tile again
|
||||
this->manager.action = FAILED;
|
||||
PlaySFX(0x6d);
|
||||
break;
|
||||
case 0x318:
|
||||
//stepped on a blue tile
|
||||
//turn the tile into a red tile
|
||||
sub_0807B7D8(0x317, this->player_current_tile, this->manager.unk_0b);
|
||||
PlaySFX(0x6b);
|
||||
//decrease the number of remaining tiles and check if we're done
|
||||
if (--this->manager.unk_0e == 0) {
|
||||
this->manager.action = SUCCEEDED;
|
||||
//set up delay for setting the flag/playing the success sfx
|
||||
this->manager.unk_0e = 0x40;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
//fall through, can be reset in-progress
|
||||
case FAILED:
|
||||
if (!this->flag_reset) return;//can't be reset
|
||||
if (!CheckFlags(this->flag_reset)) return;//wait for the flag telling it to reset
|
||||
ClearFlag(this->flag_reset);//make sure the puzzle can be reset again later
|
||||
this->manager.action = IN_PROGRESS;
|
||||
this->manager.unk_0e = this->manager.unk_0f;
|
||||
for (i = 0; i < this->height; i++) {
|
||||
tmp = this->own_tile + (i << 6);
|
||||
for (j = 0; j < this->width; j++) {
|
||||
sub_0807BA8C(tmp + j, this->manager.unk_0b);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SUCCEEDED:
|
||||
if (this->manager.unk_0e == 0) return;
|
||||
tmp2 = --this->manager.unk_0e;
|
||||
if (tmp2) {
|
||||
if (tmp2 == 0x20) {
|
||||
SetFlag(this->flag_succeeded);
|
||||
}
|
||||
} else {
|
||||
PlaySFX(0x72);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "flags.h"
|
||||
#include "functions.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
u8 unk_20[0x08];
|
||||
u16 unk_28;
|
||||
u16 unk_2a;
|
||||
u16 unk_2c;
|
||||
u16 unk_2e;
|
||||
u16 unk_30;
|
||||
u16 unk_32;
|
||||
u8 unk_34[0x04];
|
||||
s16 unk_38;
|
||||
s16 unk_3a;
|
||||
u16 unk_3c;
|
||||
u16 unk_3e;
|
||||
} Manager5;
|
||||
|
||||
void sub_08057AE8(Manager5*);
|
||||
void sub_08057BA4(Manager5*);
|
||||
void sub_08057C28(Manager5*);
|
||||
|
||||
const u16 gUnk_08108024[] = {
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
-1,
|
||||
0
|
||||
};
|
||||
const u16 gUnk_08108034[] = {
|
||||
0,
|
||||
1,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
1,
|
||||
0
|
||||
};
|
||||
|
||||
void (*const gUnk_08108044[])(Manager5*) = {
|
||||
sub_08057AE8,
|
||||
sub_08057BA4,
|
||||
sub_08057C28
|
||||
};
|
||||
|
||||
void sub_08057AD0(Manager5* this) {
|
||||
gUnk_08108044[this->manager.action](this);
|
||||
}
|
||||
|
||||
void sub_08057CA4(Manager5*, u32, u32);
|
||||
|
||||
extern void DeleteManager(Manager*);
|
||||
|
||||
void sub_08057AE8(Manager5* this) {
|
||||
u32 tmp;
|
||||
tmp = (this->manager.unk_0b & 0x3)<<1;
|
||||
if (this->manager.unk_0e == 1) {
|
||||
this->unk_30 = 0x323;
|
||||
} else {
|
||||
this->unk_30 = tmp & 2 ? 0x37 : 0x36;
|
||||
}
|
||||
this->unk_28 = gUnk_08108024[tmp];
|
||||
this->unk_2a = gUnk_08108024[tmp+1];
|
||||
this->unk_2c = gUnk_08108034[tmp];
|
||||
this->unk_2e = gUnk_08108034[tmp+1];
|
||||
this->unk_32 = ((this->manager.unk_0b>>2)&0xF)+1;
|
||||
this->manager.unk_0e = 0x1C;
|
||||
this->manager.unk_0f = 0;
|
||||
this->manager.action = (this->manager.unk_0b & 0x80)?2:1;
|
||||
if (this->manager.action != 2
|
||||
|| !CheckFlags(this->unk_3e)) return;
|
||||
for (;this->unk_32;this->unk_32--) {
|
||||
sub_08057CA4(this, this->unk_28, this->unk_2a);
|
||||
sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6),this->unk_3c);
|
||||
}
|
||||
DeleteManager(&this->manager);
|
||||
}
|
||||
|
||||
void sub_08057BA4(Manager5* this) {
|
||||
if (--this->manager.unk_0e) return;
|
||||
this->manager.unk_0e = 8;
|
||||
if (CheckFlags(this->unk_3e)) {
|
||||
if (this->unk_32 == this->manager.unk_0f) return;
|
||||
sub_08057CA4(this, this->unk_28, this->unk_2a);
|
||||
sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6), this->unk_3c);
|
||||
this->manager.unk_0f++;
|
||||
PlaySFX(0x71);
|
||||
} else {
|
||||
if (!this->manager.unk_0f) return;
|
||||
sub_0807BA8C(this->unk_38 | (this->unk_3a << 6), this->unk_3c);
|
||||
sub_08057CA4(this, this->unk_2c, this->unk_2e);
|
||||
this->manager.unk_0f--;
|
||||
PlaySFX(0x71);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057C28(Manager5* this) {
|
||||
if (!this->manager.unk_0d) {
|
||||
if (!CheckFlags(this->unk_3e)) return;
|
||||
this->manager.unk_0d++;
|
||||
} else {
|
||||
if (--this->manager.unk_0e) return;
|
||||
this->manager.unk_0e = 8;
|
||||
if (this->unk_32 != this->manager.unk_0f) {
|
||||
sub_08057CA4(this, this->unk_28, this->unk_2a);
|
||||
sub_0807B7D8(this->unk_30, this->unk_38 | (this->unk_3a << 6), this->unk_3c);
|
||||
this->manager.unk_0f++;
|
||||
PlaySFX(0x71);
|
||||
} else {
|
||||
if (this->unk_30 != 0x323) {
|
||||
PlaySFX(0x72);
|
||||
}
|
||||
DeleteManager(&this->manager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057CA4(Manager5* this, u32 unk1, u32 unk2) {
|
||||
this->unk_38 += unk1;
|
||||
this->unk_3a += unk2;
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "functions.h"
|
||||
#include "gba/gba.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
u8 unk_20;
|
||||
u8 unk_21[0x1F];
|
||||
} Manager7;
|
||||
|
||||
void sub_08057E30();
|
||||
u32 sub_08057E40();
|
||||
void sub_08057E64();
|
||||
void sub_08057E7C(u32);
|
||||
|
||||
extern void sub_08052D74();
|
||||
extern u32 sub_08056300(const u16*);
|
||||
extern void sub_0805E3A0();
|
||||
|
||||
extern u8 gUnk_02034490;
|
||||
extern const u8 gGlobalGfxAndPalettes[];
|
||||
|
||||
const u16 gUnk_08108050[0x2A] = {
|
||||
0, 0, 0x20, 0xE0,
|
||||
0xE0, 1, 0, 0x1D0,
|
||||
0x80, 0x60, 2, 0x170,
|
||||
0x278, 0xF8, 0xA0, 3,
|
||||
0x310, 0x178, 0xC0, 0x150,
|
||||
3, 0x340, 0x2C8, 0x60,
|
||||
0x90, 4, 0x1D0, 0,
|
||||
0x200, 0xE0, 1, 0x108,
|
||||
0x188, 0xD0, 0x80, 2,
|
||||
0x1E8, 0x338, 0x50, 0xC0,
|
||||
0xFF, 0
|
||||
};
|
||||
|
||||
const u32 gUnk_081080A4[0x50] = {
|
||||
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
|
||||
};
|
||||
|
||||
const u8 gUnk_081081E4[] = {
|
||||
0x16,
|
||||
0x17,
|
||||
0x17,
|
||||
0x18,
|
||||
0x18
|
||||
};
|
||||
|
||||
void Manager7_Main(Manager7* this) {
|
||||
u32 tmp;
|
||||
const u32 * tmp2;
|
||||
if (!this->manager.action) {
|
||||
this->manager.action = 1;
|
||||
this->manager.unk_0e = 8;
|
||||
this->unk_20 = 0xFF;
|
||||
sub_0805E3A0(this, 6);
|
||||
sub_08052D74(this, sub_08057E30, 0);
|
||||
}
|
||||
if (sub_08057E40(this)) {
|
||||
tmp = gRoomVars.unk_10;
|
||||
if (this->unk_20 != tmp) {
|
||||
this->unk_20 = tmp;
|
||||
this->manager.unk_0e = 0;
|
||||
}
|
||||
}
|
||||
if (gRoomControls.unk2) return;
|
||||
tmp = this->unk_20;
|
||||
tmp2 = &gUnk_081080A4[tmp<<4];
|
||||
switch (this->manager.unk_0e) {
|
||||
case 0:
|
||||
gUnk_02034490 = 1;
|
||||
LoadAssetAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
|
||||
LoadPaletteGroup(gUnk_081081E4[tmp]);
|
||||
this->manager.unk_0e++;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
LoadAssetAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]], tmp2[(this->manager.unk_0e << 1)+1], 0x1000);
|
||||
this->manager.unk_0e++;
|
||||
break;
|
||||
case 8:
|
||||
gUnk_02034490 = 0;
|
||||
this->manager.unk_0e++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057E30(Manager7* this) {
|
||||
sub_08057E7C(gRoomVars.unk_10);
|
||||
}
|
||||
|
||||
u32 sub_08057E40(Manager7* this) {
|
||||
u32 tmp = sub_08056300(gUnk_08108050);
|
||||
if (tmp != 0xFF) {
|
||||
gRoomVars.unk_10 = tmp;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057E64() {
|
||||
u32 tmp;
|
||||
tmp = sub_08056300(gUnk_08108050);
|
||||
if (tmp != 0xFF) {
|
||||
sub_08057E7C(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057E7C(u32 unk1) {
|
||||
u32 tmp;
|
||||
const u32* tmp2;
|
||||
if (unk1 > 4) return;
|
||||
LoadPaletteGroup(gUnk_081081E4[unk1]);
|
||||
tmp2 = &gUnk_081080A4[unk1<<4];
|
||||
for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) {
|
||||
DmaSet(3,&gGlobalGfxAndPalettes[tmp2[0]],tmp2[1],0x84000400);
|
||||
}
|
||||
gRoomVars.unk_10 = unk1;
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
#include "global.h"
|
||||
#include "manager.h"
|
||||
#include "screen.h"
|
||||
#include "functions.h"
|
||||
#include "gba/gba.h"
|
||||
|
||||
typedef struct {
|
||||
Manager manager;
|
||||
u8 unk_20;
|
||||
u8 unk_21[0x17];
|
||||
u32 unk_38;
|
||||
u32 unk_3c;
|
||||
} Manager8;
|
||||
|
||||
void sub_08057F20(Manager8*);
|
||||
void sub_08057EFC();
|
||||
void sub_08058034(void);
|
||||
void sub_08058084(u16*, u16*);
|
||||
|
||||
extern void sub_08052D74(void*, void*, void*);
|
||||
|
||||
extern u16 gMapDataTopSpecial[];
|
||||
|
||||
void sub_08057ED0(Manager8* this) {
|
||||
sub_08057F20(this);
|
||||
if (!this->manager.action) {
|
||||
this->manager.action = 1;
|
||||
gScreen.bg.bg2yOffset = 0;
|
||||
gScreen.affine.unk4 = 0;
|
||||
sub_08052D74(this, sub_08057EFC, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08057EFC(Manager8* this) {
|
||||
LoadGfxGroup(gRoomVars.unk_10);
|
||||
sub_08058034();
|
||||
this->unk_3c = 0;
|
||||
this->unk_38 = 0;
|
||||
sub_08057F20(this);
|
||||
}
|
||||
|
||||
void sub_08058004(u32, void*, void*);
|
||||
|
||||
extern u8 gUnk_02001A40[];
|
||||
extern u8 gUnk_02006F00[];
|
||||
|
||||
void sub_08057F20(Manager8* this) {
|
||||
u32 tmp;
|
||||
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX;
|
||||
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 = gUnk_02001A40;
|
||||
sub_08058004(tmp, gUnk_02006F00, gUnk_02001A40);
|
||||
tmp = ((tmp>>4)<<1);
|
||||
if (this->unk_38 != tmp) {
|
||||
this->unk_38 = tmp;
|
||||
gScreen.affine.unk4 = 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 = gUnk_02001A40 + 0x800;
|
||||
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gUnk_02001A40 + 0x800);
|
||||
tmp = ((tmp>>4)<<1);
|
||||
if (this->unk_3c != tmp) {
|
||||
this->unk_3c = tmp;
|
||||
gScreen.bg.bg2yOffset = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08058004(u32 unk1, void* unk2, void* unk3) {
|
||||
u32 tmp = 0x20;
|
||||
unk2 += (unk1 >> 4) << 2;
|
||||
for (tmp; tmp != 0; tmp--) {
|
||||
DmaSet(3, unk2, unk3, 0x80000020);
|
||||
unk2 += 0x100;
|
||||
unk3 += 0x40;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08058034() {
|
||||
u32 tmp;
|
||||
u16 *tmp2, *tmp3;
|
||||
tmp2 = gMapDataTopSpecial;
|
||||
tmp3 = gMapDataTopSpecial + 0x2000;
|
||||
for (tmp = 0; tmp < 4; tmp++) {
|
||||
sub_08058084(tmp2, tmp3);
|
||||
tmp2 += 0x400;
|
||||
tmp3 += 0x20;
|
||||
}
|
||||
tmp2 = gMapDataTopSpecial + 0x1000;
|
||||
tmp3 = gMapDataTopSpecial + 0x3000;
|
||||
for (tmp = 0; tmp < 4; tmp++) {
|
||||
sub_08058084(tmp2, tmp3);
|
||||
tmp2 += 0x400;
|
||||
tmp3 += 0x20;
|
||||
}
|
||||
}
|
||||
|
||||
void sub_08058084(u16* unk1, u16* unk2) {
|
||||
u32 tmp;
|
||||
for (tmp = 0; tmp < 0x20; tmp++, unk1+=0x20, unk2+=0x80) {
|
||||
DmaSet(3,unk1,unk2,0x80000020);
|
||||
}
|
||||
}
|
||||
|
||||
extern u32 gUnk_0200B650;
|
||||
|
||||
void sub_080580B0(u32 unk1) {
|
||||
s32 tmp;
|
||||
gUnk_0200B650 = 0;
|
||||
REG_DISPCNT = 0;
|
||||
LoadGfxGroup(unk1);
|
||||
gRoomVars.unk_10 = unk1;
|
||||
sub_08058034();
|
||||
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX;//r7
|
||||
tmp = tmp + (tmp >> 3) + (0x400 - gRoomControls.width) / 2;
|
||||
sub_08058004(tmp, gUnk_02006F00, gUnk_02001A40);
|
||||
gScreen.affine.bg3xOffset = tmp & 0xF;
|
||||
gScreen.affine.bg3yOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY))>>1);//?
|
||||
gScreen.affine.bg3Control = 0x1D09;
|
||||
gScreen.affine.unk5 = gUnk_02001A40;
|
||||
gScreen.affine.unk4 = 1;
|
||||
tmp = gRoomControls.roomScrollX - gRoomControls.roomOriginX;//r7
|
||||
tmp = tmp + (tmp >> 2) + (0x400 - gRoomControls.width) / 2;
|
||||
sub_08058004(tmp, gUnk_02006F00 + 0x2000, gUnk_02001A40 + 0x800);
|
||||
gScreen.bg.bg1yOffset = tmp & 0xF;
|
||||
gScreen.bg.bg2xOffset = 0x30 - ((0x30 - (gRoomControls.roomScrollY - gRoomControls.roomOriginY))>>1);//?
|
||||
gScreen.bg.bg1xOffset = 0x1E09;
|
||||
gScreen.bg.unk_14 = gUnk_02001A40 + 0x800;
|
||||
gScreen.bg.bg2yOffset = 1;
|
||||
gScreen.controls.layerFXControl = 0x3C48;
|
||||
gScreen.controls.alphaBlend = 0x609;
|
||||
gScreen.lcd.displayControl |= 0xa00;
|
||||
}
|
||||
+80
-39
@@ -6,25 +6,42 @@
|
||||
#include "area.h"
|
||||
#include "functions.h"
|
||||
|
||||
extern void (*(gUnk_08108208[]))(Manager*);
|
||||
/*
|
||||
* Manager B is used to create fights:
|
||||
* It possibly waits for an inhibitor flag to be set, then spawns a bunch of entities (based on room data).
|
||||
* Once all enemies created this way are dead, it sets a flag.
|
||||
* (There is also a part about changing the music and setting it back when the fight is done, which is song 0x33 (a fight theme) by default but can be overridden through room data)
|
||||
*/
|
||||
|
||||
void (*const ManagerB_ActionFuncs[])(Manager*);
|
||||
|
||||
void sub_080585F0(Manager* this) {
|
||||
gUnk_08108208[this->unk_0a](this);
|
||||
//make a distincion if this is a controller (unk_0a = 0) or a helper (unk_0a = 1)
|
||||
ManagerB_ActionFuncs[this->unk_0a](this);
|
||||
}
|
||||
|
||||
extern void (*(gUnk_08108210[]))(Manager*);
|
||||
enum ManagerB_State {
|
||||
Init,
|
||||
WaitForFlag,
|
||||
WaitForDone
|
||||
};
|
||||
|
||||
void sub_08058608(Manager* this) {
|
||||
gUnk_08108210[this->action](this);
|
||||
void (*const ManagerB_StateFuncs[])(ManagerB*);
|
||||
|
||||
void ManagerB_Main(ManagerB* this) {
|
||||
//make a distinction based on the state of this controller
|
||||
ManagerB_StateFuncs[this->manager.action](this);
|
||||
}
|
||||
|
||||
void sub_080586EC(Manager*);
|
||||
void ManagerB_LoadFight(Manager*);
|
||||
|
||||
void sub_08058620(ManagerB* this) {
|
||||
void ManagerB_Init(ManagerB* this) {
|
||||
//check if the fight was already completed previously (checks the flag that gets set after the fight is done)
|
||||
if (!CheckFlags(this->unk_3e)) {
|
||||
this->manager.action = 1;
|
||||
this->manager.action = WaitForFlag;
|
||||
//if there is no flag that needs to be set before the fight is started, start it immediately
|
||||
if (!this->unk_3c) {
|
||||
sub_080586EC(&this->manager);
|
||||
ManagerB_LoadFight(&this->manager);
|
||||
}
|
||||
sub_0805E3A0(this, 3);
|
||||
} else {
|
||||
@@ -33,10 +50,10 @@ void sub_08058620(ManagerB* this) {
|
||||
}
|
||||
extern void sub_080186C0(u32);
|
||||
|
||||
void sub_08058650(ManagerB* this) {
|
||||
void ManagerB_WaitForFlag(ManagerB* this) {
|
||||
int tmp;
|
||||
if (CheckFlags(this->unk_3c)) {
|
||||
sub_080586EC(&this->manager);
|
||||
ManagerB_LoadFight(&this->manager);
|
||||
if (!this->unk_35) {
|
||||
tmp = gRoomVars.field_0x9 ? gRoomVars.field_0x9 : 0x33;
|
||||
this->unk_20 = gArea.musicIndex;
|
||||
@@ -49,9 +66,12 @@ void sub_08058650(ManagerB* this) {
|
||||
|
||||
extern void sub_0801855C(void);
|
||||
|
||||
void sub_080586A8(ManagerB* this) {
|
||||
void ManagerB_WaitForDone(ManagerB* this) {
|
||||
//check if all helpers are done
|
||||
if (this->manager.unk_0e) return;
|
||||
//set the completion flag for the fight
|
||||
SetFlag(this->unk_3e);
|
||||
//restore music (if it was set, which apparently is only possible if there's a flag the fight waited for)
|
||||
if (this->unk_3c) {
|
||||
if (!this->unk_35) {
|
||||
gArea.musicIndex = this->unk_20;
|
||||
@@ -62,40 +82,45 @@ void sub_080586A8(ManagerB* this) {
|
||||
DeleteThisEntity();
|
||||
}
|
||||
|
||||
ManagerBHelper* sub_08058760(Manager*);
|
||||
void sub_08058798(ManagerBHelper*, Entity*, u32);
|
||||
ManagerBHelper* CreateHelper(Manager*);
|
||||
void ManagerBHelper_Monitor(ManagerBHelper*, Entity*, u32);
|
||||
|
||||
extern EntityData* GetCurrentRoomProperty(u8);
|
||||
extern Entity* LoadRoomEntity(EntityData*);
|
||||
|
||||
void sub_080586EC(Manager* this) {
|
||||
ManagerBHelper* tmp;
|
||||
void ManagerB_LoadFight(Manager* this) {
|
||||
ManagerBHelper* monitor;
|
||||
EntityData* prop;
|
||||
Entity* ent;
|
||||
u32 counter;
|
||||
this->action = 2;
|
||||
this->unk_0e = 0;
|
||||
counter = 0;
|
||||
tmp = sub_08058760(this);
|
||||
if (!tmp) DeleteThisEntity();
|
||||
//Create a helper to keep track of the created entities.
|
||||
monitor = CreateHelper(this);
|
||||
if (!monitor) DeleteThisEntity();
|
||||
prop = (EntityData*) GetCurrentRoomProperty(this->unk_0b);
|
||||
if (prop) {
|
||||
while (*((u8*)prop) != 0xFF) {
|
||||
ent = LoadRoomEntity(prop++);
|
||||
if (ent && (ent->entityType.type == 3)) {
|
||||
ent->field_0x6c.HALF.HI |= 0x40;
|
||||
sub_08058798(tmp, ent, counter++);
|
||||
ManagerBHelper_Monitor(monitor, ent, counter++);
|
||||
}
|
||||
if (counter >= 7) {
|
||||
counter = 0;
|
||||
tmp = sub_08058760(this);
|
||||
if (!tmp) return;
|
||||
monitor = CreateHelper(this);
|
||||
if (!monitor) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ManagerBHelper* sub_08058760(Manager* this) {
|
||||
/*
|
||||
* Create a helper and increment the counter for the number of helpers (unk_0e).
|
||||
* The helper will decrease said counter when it deletes itself (when none of the enemies it monitors remain).
|
||||
*/
|
||||
ManagerBHelper* CreateHelper(Manager* this) {
|
||||
ManagerBHelper* extra;
|
||||
extra = (ManagerBHelper*) GetEmptyManager();
|
||||
if (extra) {
|
||||
@@ -110,51 +135,67 @@ ManagerBHelper* sub_08058760(Manager* this) {
|
||||
return extra;
|
||||
}
|
||||
|
||||
void sub_08058798(ManagerBHelper* this, Entity* value, u32 index) {
|
||||
this->enemies[index]=value;
|
||||
void ManagerBHelper_Monitor(ManagerBHelper* this, Entity* ent, u32 index) {
|
||||
this->enemies[index]=ent;
|
||||
this->manager.unk_0e++;
|
||||
}
|
||||
|
||||
void sub_080587AC(ManagerBHelper* this) {
|
||||
u8 i, tmp;
|
||||
//case unk_0a is 1: The manager is a helper
|
||||
|
||||
void ManagerBHelper_Main(Manager* this) {
|
||||
u8 i, anyRemaining;
|
||||
Entity* current;
|
||||
if (this->manager.action == 0) {
|
||||
this->manager.action = 1;
|
||||
if (this->action == 0) {
|
||||
this->action = 1;
|
||||
sub_0805E3A0(this,3);
|
||||
}
|
||||
tmp = 0;
|
||||
//go through and check all monitored enemies.
|
||||
anyRemaining = 0;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if ((current = this->enemies[i])) {
|
||||
if ((current = ((ManagerBHelper*)this)->enemies[i])) {
|
||||
if (!current->next) {
|
||||
this->enemies[i] = 0;
|
||||
((ManagerBHelper*) this)->enemies[i] = 0;
|
||||
} else {
|
||||
tmp = 1;
|
||||
anyRemaining = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!tmp) {
|
||||
if (((ManagerB*) this->manager.parent)->manager.unk_0e) {
|
||||
((ManagerB*) this->manager.parent)->manager.unk_0e--;
|
||||
if (!anyRemaining) {
|
||||
//inform the parent that we're done
|
||||
if (((ManagerB*) this->parent)->manager.unk_0e) {
|
||||
((ManagerB*) this->parent)->manager.unk_0e--;
|
||||
}
|
||||
DeleteThisEntity();
|
||||
DeleteThisEntity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern Manager gUnk_03003DB0;
|
||||
|
||||
void sub_08058800(Entity* this, Entity* unk1) {
|
||||
/*
|
||||
* Replace an entity that is currently being monitored with a new one
|
||||
*/
|
||||
void ReplaceMonitoredEntity(Entity* old, Entity* new) {
|
||||
ManagerBHelper* current;
|
||||
Manager* end = &gUnk_03003DB0;
|
||||
u32 i;
|
||||
for (current = (ManagerBHelper*) end->next; (Manager*)current != end; current=(ManagerBHelper*)current->manager.next) {
|
||||
if (current->manager.type != 0x9 || current->manager.subtype != 0xB) continue;
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (this == current->enemies[i]) {
|
||||
current->enemies[i] = unk1;
|
||||
if (old == current->enemies[i]) {
|
||||
current->enemies[i] = new;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void (*const ManagerB_ActionFuncs[])(Manager*) = {
|
||||
(void (*)(Manager*)) ManagerB_Main,
|
||||
(void (*)(Manager*)) ManagerBHelper_Main
|
||||
};
|
||||
void (*const ManagerB_StateFuncs[])(ManagerB*) = {
|
||||
ManagerB_Init,
|
||||
ManagerB_WaitForFlag,
|
||||
ManagerB_WaitForDone
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user