Add two new functions from MAD

This commit is contained in:
Luciano Ciccariello 2022-01-24 00:19:58 +00:00
parent 2f95e7de07
commit 4ecb1f5370
7 changed files with 232 additions and 17 deletions

View File

@ -22,6 +22,30 @@ segments:
subalign: 4
subsegments:
- [0x0, data]
# - [0x11D4, data, objlayout]
# # - [0x11D4, bin, assets/st/mad/0.objlayout]
# # - [0x11E8, bin, assets/st/mad/1.objlayout]
# # - [0x1206, bin, assets/st/mad/2.objlayout]
# # - [0x12B0, bin, assets/st/mad/3.objlayout]
# # - [0x135A, bin, assets/st/mad/4.objlayout]
# # - [0x1404, bin, assets/st/mad/5.objlayout]
# # - [0x14AE, bin, assets/st/mad/6.objlayout]
# # - [0x1558, bin, assets/st/mad/7.objlayout]
# # - [0x1602, bin, assets/st/mad/8.objlayout]
# # - [0x16AC, bin, assets/st/mad/9.objlayout]
# # - [0x1756, bin, assets/st/mad/10.objlayout]
# # - [0x1774, bin, assets/st/mad/11.objlayout]
# # - [0x1788, bin, assets/st/mad/12.objlayout]
# # - [0x17A6, bin, assets/st/mad/13.objlayout]
# # - [0x1850, bin, assets/st/mad/14.objlayout]
# # - [0x18FA, bin, assets/st/mad/15.objlayout]
# # - [0x19A4, bin, assets/st/mad/16.objlayout]
# # - [0x1A4E, bin, assets/st/mad/17.objlayout]
# # - [0x1AF8, bin, assets/st/mad/18.objlayout]
# # - [0x1BA2, bin, assets/st/mad/19.objlayout]
# # - [0x1C4C, bin, assets/st/mad/20.objlayout]
# # - [0x1CF6, bin, assets/st/mad/21.objlayout]
# - [0x1D14, data]
- [0xD8C8, c]
- [0x197D8, data]
- [0x19E94]

View File

@ -0,0 +1,35 @@
func_8018E994 = 0x8018E994;
func_8018EDB8 = 0x8018EDB8;
func_80190F04 = 0x80190F04;
func_80190D8C = 0x80190D8C;
g_stRooms = 0x80181130;
D_80180040 = 0x80180040;
D_801800B4 = 0x801800B4;
D_801801F8 = 0x801801F8;
g_pStTileset = 0x801802A4;
func_8018EC90 = 0x8018EC90;
func_8018E1D4 = 0x8018E1D4;
g_pStTilesetDebug = 0x80180290;
g_pStObjLayout = 0x801802F4;
g_pStrObjLayout0 = 0x801811D4;
g_pStrObjLayout1 = 0x801811E8;
g_pStrObjLayout2 = 0x80181206;
g_pStrObjLayout3 = 0x801812B0;
g_pStrObjLayout4 = 0x8018135A;
g_pStrObjLayout5 = 0x80181404;
g_pStrObjLayout6 = 0x801814AE;
g_pStrObjLayout7 = 0x80181558;
g_pStrObjLayout8 = 0x80181602;
g_pStrObjLayout9 = 0x801816AC;
g_pStrObjLayout10 = 0x80181756;
g_pStrObjLayout11 = 0x80181774;
g_pStrObjLayout12 = 0x80181788;
g_pStrObjLayout13 = 0x801817A6;
g_pStrObjLayout14 = 0x80181850;
g_pStrObjLayout15 = 0x801818FA;
g_pStrObjLayout16 = 0x801819A4;
g_pStrObjLayout17 = 0x80181A4E;
g_pStrObjLayout18 = 0x80181AF8;
g_pStrObjLayout19 = 0x80181BA2;
g_pStrObjLayout20 = 0x80181C4C;
g_pStrObjLayout21 = 0x80181CF6;

View File

@ -668,7 +668,7 @@ D_80097494 = 0x80097494;
D_80097496 = 0x80097496;
D_80097498 = 0x80097498;
D_8009749C = 0x8009749C;
D_800974A0 = 0x800974A0;
g_mapProgramId = 0x800974A0;
D_800974A4 = 0x800974A4;
D_800974AC = 0x800974AC;
D_800978AC = 0x800978AC;
@ -682,7 +682,7 @@ D_80097908 = 0x80097908;
D_8009790C = 0x8009790C;
D_80097910 = 0x80097910;
D_80097914 = 0x80097914;
D_80097918 = 0x80097918;
g_mapTilesetId = 0x80097918;
D_8009791C = 0x8009791C;
D_80097920 = 0x80097920;
D_80097924 = 0x80097924;
@ -1129,4 +1129,10 @@ g_OverlayBlockCount = 0x80137F8C;
g_OverlayLastBlockSize = 0x80137F90;
g_imgUnk8013C200 = 0x8013C200;
g_imgUnk8013C270 = 0x8013C270;
g_pStOverlay = 0x80180000;
g_pStOverlay = 0x80180000;
g_pStUnkNum = 0x8018000C;
g_pStUnkRoomDef = 0x80180010;
g_pStUnkObjLayouts = 0x8018001C;
g_pStUnkTilesLayout = 0x80180020;
g_pStTilesets = 0x80180024;
D_801997DC = 0x801997DC;

View File

@ -37,6 +37,26 @@ typedef struct
int unk18;
} MenuContext;
typedef struct
{
u8 left, top, right, bottom;
u8 tileLayoutId;
u8 tilesetId;
u8 objGfxId;
u8 objLayoutId;
} RoomHeader;
typedef struct
{
u16 x, y;
u16 id : 10;
u16 unk04_10 : 3;
u16 unk04_13 : 3;
u8 unk06;
u8 unk07;
u16 unk08;
} ObjLayoutEntry;
typedef struct
{
s16 unk0;
@ -88,10 +108,20 @@ typedef struct
s16 unk52;
} Unkstruct3;
typedef struct
{
char unk0[0xA];
s16 unkA;
s16 unkC;
s16 unkE;
} Unkstruct4;
extern s32 D_8006BB00;
extern Unkstruct3* D_8006C26C;
extern s32 D_8006C39C;
extern s32 D_8006C3A0;
extern Unkstruct4 D_80072B34;
extern u16 D_80072B3E;
extern s32 D_80072F2C;
extern s32 D_80073060;
extern s32 D_80073080;
@ -113,6 +143,7 @@ extern s8 D_80073511;
extern s8 D_80073512;
extern Unkstruct2 D_80086FEC[];
extern u32 D_80097364;
extern s32 D_800973B4;
extern Unkstruct2 D_800973B8[];
extern s32 playerX;
extern s32 playerY;
@ -120,7 +151,7 @@ extern s32 D_800973FC;
extern Unkstruct1 D_80097490;
extern u16 D_80097494;
extern s16 D_80097496;
extern s32 D_800974A0;
extern s32 g_mapProgramId;
extern s32 D_800974AC;
extern u8 D_8009798A;
extern u8 D_80097A8D;

View File

@ -10,7 +10,7 @@
.if \num < 0x8000 && \num > 0
ori \reg, $0, \num & 0xFFFF
.elseif \num > 0
lui \reg, %hi(\num)
ori \reg, $0, \num & 0xFFFF
.elseif \num >= -0x8000
addiu \reg, $0, \num
.else

View File

@ -216,7 +216,7 @@ void func_800EAD0C(void) {
func_800EA5E4(6);
func_800EA5E4(7);
func_800EA5E4(8);
if (g_CurrentPlayableCharacter == 0 && D_800974A0 != 0x1F) {
if (g_CurrentPlayableCharacter == 0 && g_mapProgramId != 0x1F) {
func_800EA5E4(0x17);
}
}
@ -445,9 +445,9 @@ INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F2014);
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F2120);
void func_800F223C(void) {
D_800974A0 = D_800974A0 ^ 0x20;
g_mapProgramId = g_mapProgramId ^ 0x20;
func_800F2120();
D_800974A0 = D_800974A0 ^ 0x20;
g_mapProgramId = g_mapProgramId ^ 0x20;
}
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800F2288);
@ -1068,14 +1068,13 @@ INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800FD4C0);
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800FD5BC);
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800FD664);
// s32 func_800FD664(s32 context) {
// s32 phi_a0 = context;
// if ((D_800974A0 & 0x20) != 0) {
// phi_a0 <<= 1;
// }
// return phi_a0;
// }
s32 func_800FD664(s32 context) {
s32 phi_a0 = context;
if ((g_mapProgramId & 0x20) != 0) {
phi_a0 <<= 1;
}
return phi_a0;
}
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_800FD688);

View File

@ -1,6 +1,22 @@
#include "common.h"
#include "dra.h"
typedef struct
{
u16 unk0;
u16 unk2;
s16 unk4;
s16 unk6;
s16 unk8;
} Unkstruct_mad_1;
extern RoomHeader g_rooms[];
extern Unkstruct_mad_1* D_801997DC;
void func_801908DC(s16);
void func_801909D8(s16);
void func_80190B7C(s16);
void func_80190C78(s16);
void func_80191D3C(Unkstruct3*);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_8018D8C8);
@ -50,15 +66,119 @@ INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_801909D8);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190AD8);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190B24);
void func_80190B24(s32 arg0) {
while (true)
{
if (D_801997DC->unk2 == 0xFFFF)
D_801997DC--;
else if ((s16)arg0 >= D_801997DC->unk2 || D_801997DC->unk2 == 0xFFFE)
break;
else
D_801997DC--;
}
}
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190B7C);
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190C78);
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190D8C);
#else
typedef struct
{
u16 unk0;
u16 unk2;
u16 unk4;
} Unkstruct_80190D8C_1;
void func_80190838(s16, s16);
void func_801908DC(s16);
void func_80190AD8(s16);
extern s32* D_801803C8;
extern Unkstruct_80190D8C_1* D_801997D8;
extern s8 D_801997E0;
extern s8 D_801997E4;
extern u16* g_pStObjLayout[];
void func_80190D8C(s32 arg0) {
s16 temp_s0;
s16 temp_v0_3;
s32 temp_a0;
u16 temp_a0_2;
u16* temp_a1;
Unkstruct_80190D8C_1* temp_v1;
Unkstruct_mad_1* temp_v0_2;
s32 phi_a0;
s32 phi_a1;
s16 phi_a1_2;
temp_a0 = arg0 * 4;
temp_a1 = g_pStObjLayout[arg0];
D_801997D8 = temp_a1;
D_801997DC = *(&D_801803C8 + temp_a0);
if (*temp_a1 != 0xFFFE) {
D_801997D8 = temp_a1 + 1;
phi_a0 = func_8018E964() & 0xFF;
phi_a1 = 0;
while (true)
{
s32 temp_v0 = phi_a0 - D_801997D8->unk0;
phi_a0 = temp_v0;
if ((temp_v0 << 0x10) < 0)
break;
D_801997D8++;
phi_a1++;
}
D_801997D8 = (temp_v1->unk4 << 0x10) + temp_v1->unk2;
temp_v0_2 = (s16)phi_a1 + 1 + D_801997DC;
D_801997DC = temp_v0_2;
D_801997DC = (temp_v0_2->unk2 << 0x10) + temp_v0_2->unk0;
}
temp_a0_2 = D_80072B34.unkA;
temp_v0_3 = temp_a0_2 - 0x40;
temp_s0 = temp_a0_2 + 0x140;
phi_a1_2 = temp_v0_3;
if (temp_v0_3 >> 15) {
phi_a1_2 = 0;
}
D_801997E0 = 0;
D_801997E4 = 0;
func_80190838(phi_a1_2, phi_a1_2);
func_801908DC(temp_s0);
func_80190AD8(D_80072B34.unkE + 0x120);
}
#endif
#ifndef NON_MATCHING
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190F04);
#else
void func_80190F04(void) {
Unkstruct4* s0 = &D_80072B34;
s32 temp_v0_2;
if (D_800973B4 != 0) {
u16 temp_a0 = D_80072B3E;
if (D_800973B4 > 0)
func_801908DC(temp_a0 + 0x140);
else
func_801909D8(temp_a0 - 0x40);
}
temp_v0_2 = D_800973B8[0].next;
if (temp_v0_2 != 0) {
u16 temp_a0_2 = s0->unkE;
if (temp_v0_2 > 0)
func_80190B7C(temp_a0_2 + 0x120);
else
func_80190C78(temp_a0_2 - 0x40);
}
}
#endif
INCLUDE_ASM("asm/st/mad/nonmatchings/D8C8", func_80190FB8);