merge master

This commit is contained in:
Henny022p
2022-01-31 17:30:51 +01:00
545 changed files with 17306 additions and 89017 deletions
+213 -19
View File
@@ -3,23 +3,39 @@
#include "screen.h"
#include "functions.h"
#include "common.h"
#include "main.h"
extern void sub_08056250(void);
extern void (*const gUnk_08107C5C[])(Entity*);
extern void (*const gUnk_08107C48[])(Entity*);
void (*const gUnk_08107C5C[])(Entity*);
void (*const gUnk_08107C48[])(Entity*);
const u16 gUnk_08107C1C[];
const u16 gUnk_08107C30[];
const u8 gManager1GfxGroups[];
extern u8 gUnk_08107C40[];
extern u16 gUnk_02017AA0[];
extern u16 gUnk_085B4180[];
typedef struct {
u8 unk0;
u8 unk1;
u8 unk2;
u8 unk3;
u8 unk4;
} PACKED Manager1Prop;
#define ZV(this) ((u8*)&this->zVelocity)
#define ZS(this) ((u8*)&this->speed)
void Manager1_Main(Entity* this) {
u8 bVar1;
u8* pbVar2;
gUnk_08107C5C[this->action](this);
gUnk_08107C48[((u8*)&this->zVelocity)[1]](this);
bVar1 = gUnk_08107C40[((u8*)&this->zVelocity)[1]];
if ((bVar1 != 0) && (*(u8*)&this->zVelocity != bVar1)) {
((u8*)&this->zVelocity)[0] = bVar1;
gUnk_08107C48[ZV(this)[1]](this);
bVar1 = gManager1GfxGroups[ZV(this)[1]];
if ((bVar1 != 0) && (ZV(this)[0] != bVar1)) {
ZV(this)[0] = bVar1;
LoadGfxGroup(bVar1);
}
}
@@ -27,9 +43,9 @@ void Manager1_Main(Entity* this) {
static void sub_080570B8(Entity* this) {
u8* pbVar1;
LoadGfxGroup(((u8*)&this->zVelocity)[0]);
LoadGfxGroup(ZV(this)[0]);
this->z.WORD = 0;
pbVar1 = ((u8*)&this->zVelocity + 1);
pbVar1 = &ZV(this)[1];
if (*pbVar1 == 3) {
gScreen.bg3.updated = 1;
} else {
@@ -45,9 +61,9 @@ static void sub_080570F8(void) {
void sub_08057118(Entity* this) {
this->actionDelay = 0;
*(u8*)&this->zVelocity = 0;
((u8*)&this->zVelocity)[1] = 0;
((u8*)&this->zVelocity)[2] = 0;
ZV(this)[0] = 0;
ZV(this)[1] = 0;
ZV(this)[2] = 0;
this->action = 1;
gScreen.bg3.control = 0x1e04;
gScreen.lcd.displayControl |= DISPCNT_BG3_ON;
@@ -56,16 +72,194 @@ void sub_08057118(Entity* this) {
RegisterTransitionManager(this, sub_080570B8, sub_080570F8);
}
ASM_FUNC("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174())
// regalloc
NONMATCH("asm/non_matching/manager1/sub_08057174.inc", void sub_08057174(Entity* this)) {
Manager1Prop* prop = GetCurrentRoomProperty(this->type);
s32 temp;
s32 x;
s32 y;
ASM_FUNC("asm/non_matching/manager1/sub_0805728C.inc", void sub_0805728C())
if (prop->unk0 == 0xff)
return;
temp = gPlayerEntity.x.HALF.HI;
if (temp < 0) {
temp += 0xf;
}
ASM_FUNC("asm/non_matching/manager1/sub_080572D4.inc", void sub_080572D4())
x = temp >> 4;
temp = gPlayerEntity.y.HALF.HI;
if (temp < 0) {
temp += 0xf;
}
ASM_FUNC("asm/non_matching/manager1/sub_0805732C.inc", void sub_0805732C())
y = temp >> 4;
ASM_FUNC("asm/non_matching/manager1/nullsub_494.inc", void nullsub_494())
for (; prop->unk0 != 0xff; prop++) {
if (prop->unk0 != ZV(this)[1]) {
u32 x2 = (gRoomControls.origin_x >> 4) + prop->unk1;
u32 y2 = (gRoomControls.origin_y >> 4) + prop->unk2;
ASM_FUNC("asm/non_matching/manager1/sub_080573AC.inc", void sub_080573AC())
if (y - y2 < prop->unk4 && x - x2 < prop->unk3) {
switch (prop->unk0) {
case 1:
if (ZV(this)[1] == 2) {
this->action = 3;
this->actionDelay = 9;
}
break;
case 5:
if (ZV(this)[1] == 6) {
this->action = 3;
this->actionDelay = 9;
}
break;
case 2:
if (ZV(this)[1] == 0) {
this->action = 2;
this->actionDelay = 0;
ZV(this)[0] = 0;
}
break;
case 6:
if (ZV(this)[1] == 0) {
this->action = 2;
this->actionDelay = 0;
}
break;
case 4:
if (ZV(this)[1] == 0) {
this->action = 2;
this->actionDelay = 0;
this->z.WORD = 0;
}
break;
case 3:
if (ZV(this)[1] == 4) {
this->action = 3;
this->actionDelay = 9;
}
break;
}
ASM_FUNC("asm/non_matching/manager1/sub_08057450.inc", void sub_08057450())
if (this->action != 1) {
this->field_0xf = 8;
ZV(this)[1] = prop->unk0;
ZV(this)[2] = 1;
return;
}
}
}
}
}
END_NONMATCH
void sub_0805728C(Entity* this) {
if (--this->field_0xf == 0) {
this->field_0xf = 8;
gScreen.controls.alphaBlend = gUnk_08107C1C[this->actionDelay++];
if (this->actionDelay == 10) {
this->action = 1;
ZV(this)[2] = 0;
}
}
}
void sub_080572D4(Entity* this) {
if (--this->field_0xf == 0) {
this->field_0xf = 8;
gScreen.controls.alphaBlend = gUnk_08107C1C[this->actionDelay--];
if (this->actionDelay == 0xff) {
this->action = 1;
ZV(this)[2] = 0;
ZV(this)[1] = 0;
gScreen._6c = 0;
}
}
}
void sub_0805732C(u32 param_1, u32 param_2) {
u32 index;
u16* ptr = &gUnk_02017AA0[gUnk_03003DE4 * 0x500];
for (index = 0; index < 0xa0; ptr++, index++) {
*ptr = gSineTable[(param_2 + index) & 0xff] * param_1 / 0x100 + gScreen.bg3.xOffset;
}
sub_0805622C(&gUnk_02017AA0[gUnk_03003DE4 * 0x500], REG_ADDR_BG3HOFS, 0xa2600001UL);
}
void nullsub_494() {
}
void sub_080573AC(Entity* this) {
s32 sin, frameCount;
gRoomControls.bg3OffsetX.WORD -= 0x2000;
gRoomControls.bg3OffsetY.WORD -= 0x1000;
gScreen.bg3.xOffset = ((gRoomControls.scroll_x - gRoomControls.origin_x) >> 1) + gRoomControls.bg3OffsetX.HALF.HI;
gScreen.bg3.yOffset = ((gRoomControls.scroll_y - gRoomControls.origin_y) >> 1) + gRoomControls.bg3OffsetY.HALF.HI;
sin = gSineTable[(gRoomTransition.frameCount & 0xff) + 0x40];
sub_0805732C((sin >> 5) + 0x10, gRoomTransition.frameCount);
if (ZV(this)[2] == 0) {
if ((gRoomTransition.frameCount & 0x1f) == 0) {
ZS(this)[0] = (ZS(this)[0] + 1) & 7;
gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]];
}
}
}
void sub_08057450(Entity* this) {
s32 y;
gScreen.bg3.xOffset = 0x10;
y = gRoomControls.scroll_y;
y -= gRoomControls.origin_y;
y >>= 2;
gScreen.bg3.yOffset = y & 0x3f;
gScreen.bg3.tilemap = &gBG3Buffer[(y / 0x40) << 8];
if ((void*)this->z.WORD != gScreen.bg3.tilemap) {
this->z.WORD = (u32)gScreen.bg3.tilemap;
gScreen.bg3.updated = 1;
}
if (ZV(this)[2] == 0 && (gRoomTransition.frameCount & 0x1f) == 0) {
ZS(this)[0] = (ZS(this)[0] + 1) & 7;
gScreen.controls.alphaBlend = gUnk_08107C30[ZS(this)[0]];
}
if ((gRoomTransition.frameCount & 0x7) == 0) {
u32 index;
u16* ptr = &gUnk_085B4180[(ZV(this)[3] << 4)];
for (index = 0, ptr = ptr + 7; index <= 3; index++) {
SetColor(index + 0x87, *(ptr + index));
SetColor(index + 0x8c, *(ptr + index + 5));
}
ZV(this)[3] = (ZV(this)[3] + 1) & 3;
}
}
const u16 gUnk_08107C1C[] = {
0x1000, 0xF01, 0xE02, 0xD03, 0xC04, 0xB05, 0xA06, 0x907, 0x908, 0x909,
};
const u16 gUnk_08107C30[] = {
0x909, 0xA08, 0xB07, 0xC06, 0xD05, 0xC06, 0xB07, 0xA08,
};
const u8 gManager1GfxGroups[] = {
0x25, 0x00, 0x24, 0x00, 0x25, 0x00, 0x00, 0x00,
};
void (*const gUnk_08107C48[])(Entity*) = {
nullsub_494, nullsub_494, sub_080573AC, nullsub_494, sub_08057450,
};
void (*const gUnk_08107C5C[])(Entity*) = {
sub_08057118,
sub_08057174,
sub_0805728C,
sub_080572D4,
};
+3 -3
View File
@@ -155,9 +155,9 @@ void sub_0805B210(Manager1A* this) {
gRoomTransition.player_status.room_next = tmp->unk_02;
gRoomTransition.player_status.layer = tmp->unk_03;
if (gPlayerState.flags & PL_MINISH) {
gRoomTransition.player_status.spawn_type = 6;
gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP_MINISH;
} else {
gRoomTransition.player_status.spawn_type = 2;
gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP;
}
switch (tmp->unk_00) {
case 0:
@@ -171,7 +171,7 @@ void sub_0805B210(Manager1A* this) {
case 2:
gRoomTransition.player_status.start_pos_x = tmp->unk_04;
gRoomTransition.player_status.start_pos_y = tmp->unk_06;
gRoomTransition.player_status.spawn_type = 6;
gRoomTransition.player_status.spawn_type = PL_SPAWN_DROP_MINISH;
break;
}
}
+1 -1
View File
@@ -11,7 +11,7 @@ ASM_FUNC("asm/non_matching/manager22/sub_0805BB00.inc", void sub_0805BB00())
ASM_FUNC("asm/non_matching/manager22/sub_0805BB74.inc", void sub_0805BB74())
ASM_FUNC("asm/non_matching/manager22/sub_0805BBBC.inc", void UpdateLightLevel())
ASM_FUNC("asm/non_matching/manager22/UpdateLightLevel.inc", void UpdateLightLevel())
ASM_FUNC("asm/non_matching/manager22/sub_0805BC04.inc", void sub_0805BC04())
+1 -1
View File
@@ -113,7 +113,7 @@ Entity* Manager28_FindMatchingEntity(EntityData* unk1) {
y = unk1->yPos + gRoomControls.origin_y;
tmp = &gEntityLists[4];
for (i = tmp->first; (u32)i != (u32)tmp; i = i->next) {
if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && 3 == i->kind && unk1->type == i->type) {
if (x == i->x.HALF.HI && y == i->y.HALF.HI && unk1->id == i->id && ENEMY == i->kind && unk1->type == i->type) {
return i;
}
}
+1 -1
View File
@@ -25,7 +25,7 @@ void Manager2C_Main(Manager2C* manager) {
MemClear(&gRoomTransition.player_status, 0x20);
gRoomTransition.transitioningOut = 1;
gRoomTransition.type = TRANSITION_DEFAULT;
gRoomTransition.player_status.spawn_type = 0xb;
gRoomTransition.player_status.spawn_type = PL_SPAWN_PARACHUTE_UP;
gRoomTransition.player_status.area_next = manager->manager.unk_0b;
gRoomTransition.player_status.room_next = manager->manager.unk_0e;
gRoomTransition.player_status.start_anim = manager->field_0x37;
+4 -4
View File
@@ -91,9 +91,6 @@ u32 sub_0805795C(Manager* this, DiggingCaveEntrance* entr) {
extern void sub_08080930(u32);
#ifdef EU
ASM_FUNC("asm/non_matching/eu/sub_08057A18.inc", void sub_08057A18(Manager* this, DiggingCaveEntrance* entr))
#else
void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
u16 tmp;
SetInitializationPriority();
@@ -106,6 +103,8 @@ void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
gUnk_03004030.unk_00 = entr;
gUnk_03004030.unk_04 = gPlayerEntity.x.HALF.HI - gRoomControls.origin_x - ((entr->unk_00 & 0x3F) * 16);
gUnk_03004030.unk_06 = gPlayerEntity.y.HALF.HI - gRoomControls.origin_y - ((entr->unk_00 & 0xFC0) >> 2);
#ifndef EU
tmp = gUnk_03004030.unk_08;
if (!tmp) {
if ((entr->target_room | 0x80) != gUnk_03004030.unk_0b) {
@@ -113,10 +112,11 @@ void sub_08057A18(Manager* this, DiggingCaveEntrance* entr) {
}
gUnk_03004030.unk_0b = entr->target_room | 0x80;
}
#endif
sub_08080930(entr->unk_03);
DeleteManager(this);
}
#endif
DiggingCaveEntrance* sub_08057AA8(DiggingCaveEntrance* entr, int room) {
for (; entr->unk_00 != 0xFFFF; entr++) {
+52 -5
View File
@@ -55,7 +55,54 @@ const u32 gUnk_081080A4[0x50] = {
const u8 gUnk_081081E4[] = { 0x16, 0x17, 0x17, 0x18, 0x18 };
#ifdef EU
ASM_FUNC("asm/non_matching/eu/Manager7_Main.inc", void Manager7_Main(Manager7* this))
void Manager7_Main(Manager7* this) {
u32 tmp;
const u32* tmp2;
s32 tmp3;
if (!this->manager.action) {
this->manager.action = 1;
this->manager.unk_0e = 8;
this->unk_20 = 0xFF;
RegisterTransitionManager(this, sub_08057E30, 0);
}
if (gRoomControls.reload_flags)
return;
if (sub_08057E40(this)) {
tmp = (u32)gRoomVars.unk_10[0];
if (this->unk_20 != tmp) {
this->unk_20 = tmp;
this->manager.unk_0e = 0;
}
}
tmp2 = &gUnk_081080A4[tmp << 4];
tmp3 = this->manager.unk_0e;
if (tmp3 == 0) {
gUnk_02034490.unk0 = 1;
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[0]], tmp2[1], 0x1000);
LoadPaletteGroup(gUnk_081081E4[tmp]);
this->manager.unk_0e++;
} else {
switch (tmp3) {
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
LoadResourceAsync(&gGlobalGfxAndPalettes[tmp2[(this->manager.unk_0e << 1)]],
tmp2[(this->manager.unk_0e << 1) + 1], 0x1000);
this->manager.unk_0e++;
gUnk_02034490.unk0 = 0;
case 8:
break;
}
}
}
#else
void Manager7_Main(Manager7* this) {
u32 tmp;
@@ -129,14 +176,15 @@ void sub_08057E64(void) {
}
}
#ifdef EU
ASM_FUNC("asm/non_matching/eu/sub_08057E7C.inc", void sub_08057E7C(u32 unk1))
#else
void sub_08057E7C(u32 unk1) {
u32 tmp;
const u32* tmp2;
#ifndef EU
if (unk1 > 4)
return;
#endif
LoadPaletteGroup(gUnk_081081E4[unk1]);
tmp2 = &gUnk_081080A4[unk1 << 4];
for (tmp = 0; tmp < 8; tmp++, tmp2 += 2) {
@@ -144,4 +192,3 @@ void sub_08057E7C(u32 unk1) {
}
gRoomVars.unk_10[0] = unk1;
}
#endif
+1 -1
View File
@@ -98,7 +98,7 @@ void ManagerB_LoadFight(Manager* this) {
if (prop) {
while (*((u8*)prop) != 0xFF) {
ent = LoadRoomEntity(prop++);
if (ent && (ent->kind == 3)) {
if (ent && (ent->kind == ENEMY)) {
ent->field_0x6c.HALF.HI |= 0x40;
ManagerBHelper_Monitor(monitor, ent, counter++);
}
+1 -2
View File
@@ -46,7 +46,6 @@ u32 sub_08058B08(ManagerC*, u32, u32, const struct_08108228*);
void sub_08058B5C(ManagerC*, u32);
extern void sub_0805622C(struct BgAffineDstData*, u32, u32);
extern void sub_080044AE(Entity*, u32, u32);
extern u8 gUnk_03003DE4[0xC];
@@ -207,7 +206,7 @@ const u16 gUnk_081082E8[0xC] = { 0xB8, 0x80, 0x0, 0xB8, 0x110, 0x2, 0x118, 0x80,
void sub_08058B5C(ManagerC* this, u32 unk1) {
gRoomTransition.transitioningOut = 1;
gRoomTransition.type = TRANSITION_DEFAULT;
gRoomTransition.player_status.spawn_type = 4;
gRoomTransition.player_status.spawn_type = PL_SPAWN_STEP_IN;
gRoomTransition.player_status.area_next = gRoomControls.area;
gRoomTransition.player_status.room_next = 6;
gRoomTransition.player_status.start_anim = unk1 & 1 ? 4 : 0;
+3 -3
View File
@@ -361,7 +361,7 @@ void sub_0805938C(ManagerF* this) {
u32 sub_080593CC(ManagerF* this) {
if (!(gPlayerState.flags & PL_MINISH) && gPlayerState.swim_state != 0 && gPlayerEntity.animationState == 0 &&
(gPlayerState.field_0x90 & 0xF00) == 0x400) {
return sub_0806FCB8(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
return EntityWithinDistance(&gPlayerEntity, this->unk_38, this->unk_3a + 0xC, 6);
}
return 0;
}
@@ -379,7 +379,7 @@ void sub_08059424(ManagerF* this) {
tmp->collisionLayer = 2;
tmp->x.HALF.HI = this->unk_38 + gRoomControls.origin_x;
tmp->y.HALF.HI = this->unk_3a + gRoomControls.origin_y;
EnqueueSFX(0x1B0);
EnqueueSFX(SFX_1B0);
DeleteThisEntity();
}
@@ -427,7 +427,7 @@ void sub_080594DC(ManagerF* this) {
#if defined(USA) || defined(DEMO_USA) || defined(DEMO_JP)
void sub_08059548(ManagerF* this) {
SetDefaultPriority((Entity*)this, PRIO_PLAYER_EVENT);
if (gPlayerEntity.action == 0x16) {
if (gPlayerEntity.action == PLAYER_TALKEZLO) {
DeleteThisEntity();
}
gInput.heldKeys |= 0x4;