mirror of
https://github.com/Xeeynamo/sotn-decomp.git
synced 2024-11-27 15:00:36 +00:00
Decompile DRA func_800F14CC (#682)
This one is pretty ugly and requires a lot of fake things like unrealistic casts and single-element structs to make it work. Thanks to @sozud for finishing off the last cast. The main purpose of this PR is to get a version of the function into the repo, which may be useful, along with other functions, for determining the true layout of the data we're dealing with.
This commit is contained in:
parent
1816ac9192
commit
c6feebd92a
@ -482,17 +482,44 @@ typedef struct {
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
u8 unk3;
|
||||
} ET_Entity1;
|
||||
} ET_EntitySlot1;
|
||||
|
||||
typedef struct {
|
||||
char pad[0x32];
|
||||
s16 unkAE;
|
||||
} ET_Entity16;
|
||||
|
||||
typedef struct {
|
||||
s32 unk7C;
|
||||
s32 unk80;
|
||||
s32 unk84;
|
||||
s32 unk88;
|
||||
s32 entityPtr;
|
||||
s16 unk90;
|
||||
s16 unk92;
|
||||
s16 unk94;
|
||||
s16 unk96;
|
||||
s16 unk98;
|
||||
s16 unk9A;
|
||||
s16 unk9C;
|
||||
s16 unk9E;
|
||||
s16 unkA0;
|
||||
s16 unkA2;
|
||||
s16 unkA4;
|
||||
s16 unkA6;
|
||||
s16 unkA8;
|
||||
s16 unkAA;
|
||||
s16 unkAC;
|
||||
s16 unkAE;
|
||||
s16 unkB0;
|
||||
} ET_Entity1;
|
||||
|
||||
typedef union {
|
||||
/* 0x7C */ struct Primitive* prim;
|
||||
/* 0x7C */ ET_Generic generic;
|
||||
/* 0x7C */ ET_Entity1 ent1;
|
||||
ET_Entity16 ent16;
|
||||
/* 0x7C */ ET_EntitySlot1 entSlot1;
|
||||
/* 0x7C */ ET_Entity16 ent16;
|
||||
/* 0x7C */ ET_EquipItemDrop equipItemDrop;
|
||||
/* 0x7C */ ET_RelicOrb relicOrb;
|
||||
/* 0x7C */ ET_MessageBox messageBox;
|
||||
|
@ -490,6 +490,11 @@ typedef struct {
|
||||
/* 0x3 */ u8 objLayoutId;
|
||||
} RoomLoadDef; // size = 0x4
|
||||
|
||||
// fake struct for D_801375BC
|
||||
typedef struct {
|
||||
RoomLoadDef* def;
|
||||
} RoomLoadDefHolder;
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ u8 left;
|
||||
/* 0x1 */ u8 top;
|
||||
|
@ -96,7 +96,7 @@ s32 SetNextRoomToLoad(u32 x, u32 y) {
|
||||
D_800A245C[room->load.tileLayoutId].stageId == STAGE_ST0) {
|
||||
return 0;
|
||||
}
|
||||
D_801375BC = &room->load;
|
||||
D_801375BC.def = &room->load;
|
||||
return 1;
|
||||
}
|
||||
room++;
|
||||
@ -272,7 +272,66 @@ void func_800F1424(void) {
|
||||
}
|
||||
}
|
||||
|
||||
INCLUDE_ASM("dra/nonmatchings/5087C", func_800F14CC);
|
||||
void func_800F14CC(void) {
|
||||
RoomTeleport* temp_a2;
|
||||
s32 temp_a1;
|
||||
s32 newY;
|
||||
|
||||
if (D_8003C730 == 1) {
|
||||
PLAYER.posX.i.hi = 0x80;
|
||||
PLAYER.posY.i.hi = 0xA4;
|
||||
if (g_StageId & 0x20) {
|
||||
PLAYER.posY.i.hi = 0xB4;
|
||||
}
|
||||
SetNextRoomToLoad(g_CurrentRoom.left, g_CurrentRoom.top);
|
||||
return;
|
||||
}
|
||||
if (D_8003C730 == 2) {
|
||||
PLAYER.posX.i.hi = 0x74;
|
||||
PLAYER.posY.i.hi = 0xA4;
|
||||
SetNextRoomToLoad(g_CurrentRoom.left, g_CurrentRoom.top);
|
||||
return;
|
||||
}
|
||||
temp_a2 = &D_800A245C[D_8006C374];
|
||||
do {
|
||||
} while (0);
|
||||
// TODO: !FAKE Ugly casts, need to work this out.
|
||||
D_801375BC.def =
|
||||
&((RoomHeader*)((u8*)g_api.o.rooms + temp_a2->roomId))->load;
|
||||
PLAYER.posX.i.hi = temp_a2->x;
|
||||
PLAYER.posY.i.hi = temp_a2->y;
|
||||
|
||||
if (g_StageId & STAGE_INVERTEDCASTLE_FLAG) {
|
||||
temp_a1 =
|
||||
(D_801375BC.def - 1)->objLayoutId - (D_801375BC.def - 1)->tilesetId;
|
||||
PLAYER.posX.i.hi =
|
||||
(((D_801375BC.def - 1)->objGfxId -
|
||||
(D_801375BC.def - 1)->tileLayoutId + 1)
|
||||
<< 8) -
|
||||
temp_a2->x;
|
||||
newY = (temp_a1 << 8) - (temp_a2->y & 0xFF00);
|
||||
if (D_80097C98 == 4) {
|
||||
newY |= 0x47;
|
||||
} else if (g_StageId == STAGE_RCEN) {
|
||||
newY |= 0xD0;
|
||||
} else if ((g_StageId == STAGE_RNO0) && (D_8006C374 == 7)) {
|
||||
newY |= 0x30;
|
||||
} else if (D_8006C374 == 8) {
|
||||
newY = 0xB3;
|
||||
} else if (newY == 0) {
|
||||
if (temp_a1 != 0) {
|
||||
newY = 0x88;
|
||||
} else {
|
||||
newY = 0x84;
|
||||
}
|
||||
} else if (newY == temp_a1) {
|
||||
newY |= 0x84;
|
||||
} else {
|
||||
newY |= 0x88;
|
||||
}
|
||||
PLAYER.posY.i.hi = newY;
|
||||
}
|
||||
}
|
||||
|
||||
s32 func_800F16D0(void) {
|
||||
if (D_8003C730 != 0)
|
||||
|
@ -47,7 +47,7 @@ void func_800F298C(void) {
|
||||
g_backbufferX = 0;
|
||||
g_backbufferY = 0;
|
||||
func_800F14CC();
|
||||
LoadRoomLayer(D_801375BC->tileLayoutId);
|
||||
LoadRoomLayer(D_801375BC.def->tileLayoutId);
|
||||
if (D_8003C708.flags & 0x20) {
|
||||
func_800EAF28(3);
|
||||
}
|
||||
@ -67,12 +67,12 @@ void func_800F298C(void) {
|
||||
}
|
||||
D_80097928 = 0;
|
||||
func_800EA538(2);
|
||||
if (D_801375BC->tilesetId != 0) {
|
||||
func_800EA5E4(D_801375BC->tilesetId + 0x7fff | 0x4000);
|
||||
if (D_801375BC.def->tilesetId != 0) {
|
||||
func_800EA5E4(D_801375BC.def->tilesetId + 0x7fff | 0x4000);
|
||||
}
|
||||
if (D_801375BC->objGfxId != 0) {
|
||||
func_800EAF28(D_801375BC->objGfxId + 0x7fff);
|
||||
D_80097904 = D_801375BC->objGfxId + 0x7fff;
|
||||
if (D_801375BC.def->objGfxId != 0) {
|
||||
func_800EAF28(D_801375BC.def->objGfxId + 0x7fff);
|
||||
D_80097904 = D_801375BC.def->objGfxId + 0x7fff;
|
||||
} else {
|
||||
D_80097904 = 0;
|
||||
}
|
||||
@ -89,13 +89,13 @@ void func_800F298C(void) {
|
||||
}
|
||||
ptr_791c = &D_8009791C;
|
||||
g_CurrentRoom.x =
|
||||
((D_801375BC - 1)->tileLayoutId - g_CurrentRoom.left) << 8;
|
||||
((D_801375BC.def - 1)->tileLayoutId - g_CurrentRoom.left) << 8;
|
||||
g_CurrentRoom.y =
|
||||
((D_801375BC - 1)->tilesetId - g_CurrentRoom.top) << 8;
|
||||
((D_801375BC.def - 1)->tilesetId - g_CurrentRoom.top) << 8;
|
||||
g_CurrentRoom.width =
|
||||
(((D_801375BC - 1)->objGfxId - g_CurrentRoom.left) + 1) << 8;
|
||||
(((D_801375BC.def - 1)->objGfxId - g_CurrentRoom.left) + 1) << 8;
|
||||
g_CurrentRoom.height =
|
||||
(((D_801375BC - 1)->objLayoutId - g_CurrentRoom.top) + 1) << 8;
|
||||
(((D_801375BC.def - 1)->objLayoutId - g_CurrentRoom.top) + 1) << 8;
|
||||
|
||||
*ptr_791c = (playerX >> 8) + g_CurrentRoom.left;
|
||||
D_80097920 = (playerY >> 8) + g_CurrentRoom.top;
|
||||
@ -123,7 +123,7 @@ void func_800F298C(void) {
|
||||
func_800F0CD8(0);
|
||||
D_80073074 = (s32)g_Camera.posX.i.hi;
|
||||
D_8007307C = (s32)g_Camera.posY.i.hi;
|
||||
g_api.o.InitRoomEntities(D_801375BC->objLayoutId);
|
||||
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
|
||||
g_api.o.Update();
|
||||
g_api.o.Update();
|
||||
func_800F0940();
|
||||
@ -256,8 +256,8 @@ void func_800F298C(void) {
|
||||
g_GameStep = Play_PrepareNextStage;
|
||||
return;
|
||||
}
|
||||
if (D_801375BC->tilesetId == 0xFF) {
|
||||
D_8006C374 = D_801375BC->tileLayoutId;
|
||||
if (D_801375BC.def->tilesetId == 0xFF) {
|
||||
D_8006C374 = D_801375BC.def->tileLayoutId;
|
||||
g_GameStep = Play_PrepareNextStage;
|
||||
return;
|
||||
}
|
||||
@ -480,9 +480,9 @@ void func_800F298C(void) {
|
||||
func_8010427C();
|
||||
D_80137598 = 0;
|
||||
}
|
||||
layer = g_api.o.tileLayers[D_801375BC->tileLayoutId].fg;
|
||||
layer = g_api.o.tileLayers[D_801375BC.def->tileLayoutId].fg;
|
||||
if (layer->bottom & 0x80) {
|
||||
D_801375BC = &g_api.o.rooms[layer->bottom & 0x7F].load;
|
||||
D_801375BC.def = &g_api.o.rooms[layer->bottom & 0x7F].load;
|
||||
// TODO: !FAKE
|
||||
// D_8009791C is probably part of a struct. see also
|
||||
// (&g_Camera.posX)->i.hi seen elsewhere in this function.
|
||||
@ -503,19 +503,20 @@ void func_800F298C(void) {
|
||||
func_800EAF28(1);
|
||||
}
|
||||
func_800EA538(2);
|
||||
if (D_801375BC->tilesetId != 0) {
|
||||
func_800EA5E4((D_801375BC->tilesetId + 0x7FFF) | 0x4000);
|
||||
if (D_801375BC.def->tilesetId != 0) {
|
||||
func_800EA5E4(
|
||||
(D_801375BC.def->tilesetId + 0x7FFF) | 0x4000);
|
||||
}
|
||||
if (D_801375BC->objGfxId != 0) {
|
||||
func_800EAF28(D_801375BC->objGfxId + 0x7FFF);
|
||||
D_80097904 = D_801375BC->objGfxId + 0x7FFF;
|
||||
if (D_801375BC.def->objGfxId != 0) {
|
||||
func_800EAF28(D_801375BC.def->objGfxId + 0x7FFF);
|
||||
D_80097904 = D_801375BC.def->objGfxId + 0x7FFF;
|
||||
} else {
|
||||
D_80097904 = 0;
|
||||
}
|
||||
func_800F2404(1);
|
||||
PLAYER.posY.i.hi = (u8)PLAYER.posY.i.hi;
|
||||
PLAYER.posX.i.hi = (u8)PLAYER.posX.i.hi;
|
||||
LoadRoomLayer(D_801375BC->tileLayoutId);
|
||||
LoadRoomLayer(D_801375BC.def->tileLayoutId);
|
||||
if (D_8003C708.flags & 0x20) {
|
||||
func_800EAF28(3);
|
||||
}
|
||||
@ -523,14 +524,16 @@ void func_800F298C(void) {
|
||||
func_800EAF28(4);
|
||||
}
|
||||
g_CurrentRoom.x =
|
||||
((D_801375BC - 1)->tileLayoutId - g_CurrentRoom.left) << 8;
|
||||
((D_801375BC.def - 1)->tileLayoutId - g_CurrentRoom.left)
|
||||
<< 8;
|
||||
g_CurrentRoom.y =
|
||||
((D_801375BC - 1)->tilesetId - g_CurrentRoom.top) << 8;
|
||||
((D_801375BC.def - 1)->tilesetId - g_CurrentRoom.top) << 8;
|
||||
g_CurrentRoom.width =
|
||||
(((D_801375BC - 1)->objGfxId - g_CurrentRoom.left) + 1)
|
||||
(((D_801375BC.def - 1)->objGfxId - g_CurrentRoom.left) + 1)
|
||||
<< 8;
|
||||
g_CurrentRoom.height =
|
||||
(((D_801375BC - 1)->objLayoutId - g_CurrentRoom.top) + 1)
|
||||
(((D_801375BC.def - 1)->objLayoutId - g_CurrentRoom.top) +
|
||||
1)
|
||||
<< 8;
|
||||
// permuter found this weird & -> thing, I don't know man
|
||||
(&g_Camera.posX)->i.hi = (D_8009791C - g_CurrentRoom.left) << 8;
|
||||
@ -551,7 +554,7 @@ void func_800F298C(void) {
|
||||
}
|
||||
D_80073074 = (s32)g_Camera.posX.i.hi;
|
||||
D_8007307C = (s32)g_Camera.posY.i.hi;
|
||||
g_api.o.InitRoomEntities(D_801375BC->objLayoutId);
|
||||
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
|
||||
g_api.o.Update();
|
||||
func_800F0CD8(0);
|
||||
func_800F0CD8(0);
|
||||
@ -604,7 +607,7 @@ void func_800F298C(void) {
|
||||
}
|
||||
D_80073074 = g_Camera.posX.i.hi;
|
||||
D_8007307C = g_Camera.posY.i.hi;
|
||||
g_api.o.InitRoomEntities(D_801375BC->objLayoutId);
|
||||
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
|
||||
g_api.o.Update();
|
||||
func_800F0CD8(0);
|
||||
func_800F0CD8(0);
|
||||
@ -621,7 +624,7 @@ void func_800F298C(void) {
|
||||
} else {
|
||||
D_80097C98 = 0;
|
||||
}
|
||||
g_api.o.InitRoomEntities(D_801375BC->objLayoutId);
|
||||
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
|
||||
g_api.o.Update();
|
||||
g_api.o.Update();
|
||||
func_800F0940();
|
||||
|
@ -14,7 +14,7 @@ void func_8010D59C(void) {
|
||||
Primitive* prim;
|
||||
s32 i;
|
||||
|
||||
if (g_Entities[1].ext.ent1.unk0 != 0) {
|
||||
if (g_Entities[1].ext.entSlot1.unk0 != 0) {
|
||||
return;
|
||||
}
|
||||
switch (PLAYER.ext.player.unkAC) {
|
||||
@ -23,27 +23,27 @@ void func_8010D59C(void) {
|
||||
case 0x60:
|
||||
case 0x61:
|
||||
case 0x62:
|
||||
g_Entities[1].ext.ent1.unk2 = 10;
|
||||
g_Entities[1].ext.entSlot1.unk2 = 10;
|
||||
return;
|
||||
}
|
||||
if ((g_Player.padTapped & GAMEBUTTONS) ||
|
||||
((g_Player.padHeld ^ g_Player.padPressed) & g_Player.padHeld &
|
||||
GAMEBUTTONS) ||
|
||||
(PLAYER.velocityY > FIX(0.5))) {
|
||||
g_Entities[1].ext.ent1.unk2 = 0;
|
||||
g_Entities[1].ext.ent1.unk3 = 0;
|
||||
g_Entities[1].ext.entSlot1.unk2 = 0;
|
||||
g_Entities[1].ext.entSlot1.unk3 = 0;
|
||||
} else {
|
||||
if (g_Entities[1].ext.ent1.unk2 >= 10) {
|
||||
if (g_Entities[1].ext.entSlot1.unk2 >= 10) {
|
||||
return;
|
||||
}
|
||||
if (g_Entities[1].ext.ent1.unk3 == 0) {
|
||||
g_Entities[1].ext.ent1.unk3 =
|
||||
g_D_800ACF18[g_Entities[1].ext.ent1.unk2];
|
||||
if (g_Entities[1].ext.entSlot1.unk3 == 0) {
|
||||
g_Entities[1].ext.entSlot1.unk3 =
|
||||
g_D_800ACF18[g_Entities[1].ext.entSlot1.unk2];
|
||||
}
|
||||
if (!(--g_Entities[1].ext.ent1.unk3 & 0xFF)) {
|
||||
g_Entities[1].ext.ent1.unk2++;
|
||||
g_Entities[1].ext.ent1.unk3 =
|
||||
g_D_800ACF18[g_Entities[1].ext.ent1.unk2];
|
||||
if (!(--g_Entities[1].ext.entSlot1.unk3 & 0xFF)) {
|
||||
g_Entities[1].ext.entSlot1.unk2++;
|
||||
g_Entities[1].ext.entSlot1.unk3 =
|
||||
g_D_800ACF18[g_Entities[1].ext.entSlot1.unk2];
|
||||
}
|
||||
}
|
||||
if (g_Entities[1].animFrameIdx != 0) {
|
||||
@ -87,9 +87,9 @@ void func_8010D800(void) {
|
||||
|
||||
i = 0;
|
||||
prim = &g_PrimBuf[g_Entities[1].primIndex];
|
||||
temp_t2 = g_Entities[1].ext.ent1.unk1;
|
||||
temp_t1 = g_shadowOpacityReductionTable[g_Entities[1].ext.ent1.unk2];
|
||||
temp_t0 = g_D_800ACF3C[g_Entities[1].ext.ent1.unk2];
|
||||
temp_t2 = g_Entities[1].ext.entSlot1.unk1;
|
||||
temp_t1 = g_shadowOpacityReductionTable[g_Entities[1].ext.entSlot1.unk2];
|
||||
temp_t0 = g_D_800ACF3C[g_Entities[1].ext.entSlot1.unk2];
|
||||
|
||||
plDraw = &g_PlayerDraw[1];
|
||||
for (i = 0; i < 6; prim = prim->next, i++) {
|
||||
|
@ -540,7 +540,8 @@ extern s32 D_801375AC;
|
||||
extern s32 D_801375B0;
|
||||
extern s32 D_801375B4;
|
||||
extern s32 D_801375B8;
|
||||
extern RoomLoadDef* D_801375BC;
|
||||
// clues indicate being in a struct, unclear what else is with it though.
|
||||
extern RoomLoadDefHolder D_801375BC;
|
||||
extern s32 D_801375C0;
|
||||
extern s32 D_801375C4;
|
||||
extern s32 D_801375C8;
|
||||
|
Loading…
Reference in New Issue
Block a user