Decompiles z_vr_box (from zel) (#73)

This commit is contained in:
Kenix3 2021-03-16 21:27:14 -04:00 committed by GitHub
parent 3a91922e89
commit a53626049f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 221 additions and 17 deletions

View File

@ -173,6 +173,7 @@ asm/%.asm: disasm ;
disasm: tables/files.txt tables/functions.txt tables/objects.txt tables/variables.txt tables/vrom_variables.txt tables/pre_boot_variables.txt
./tools/disasm.py -d ./asm -u . -l ./tables/files.txt -f ./tables/functions.txt -o ./tables/objects.txt -v ./tables/variables.txt -v ./tables/vrom_variables.txt -v ./tables/pre_boot_variables.txt
@echo "done with disasm"
clean:
rm -f $(ROM) $(UNCOMPRESSED_ROM) -r build asm

View File

@ -18,6 +18,8 @@ else
code_bucket=$3
fi
echo "split_asm : $code_file : $code_path : $code_bucket"
# Split asm file and create base c file
tools/split_asm.py -c "./src/$code_path/$code_file.c" "./asm/$code_bucket/$code_file.asm" "./asm/non_matchings/$code_bucket/$code_file"

View File

@ -2794,11 +2794,11 @@ void VisMono_Draw(void* arg0, Gfx** gfx, u32 arg2); // VisMono_Draw
void func_801420C0(void* arg0);
void func_801420F4(void* arg0);
void func_80142100(void* arg0, Gfx** gfx, u32 arg2);
// void func_80142440(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7, UNK_TYPE1 param_8, UNK_TYPE4 param_9);
// void func_80143148(void);
// void func_801431E8(void);
// void func_80143324(void);
void func_801434E4(GameState* ctxt, s32 iParm2, s16 sParm3);
s32 func_80142440(SkyboxContext* skyboxCtx, Vtx* vtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, s32 arg8); // func_80142440
void func_80143148(SkyboxContext* skyboxCtx, s32 arg1); // func_80143148
void func_801431E8(GameState* state, SkyboxContext* skyboxCtx, s16 skyType); // func_801431E8
void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType); // func_80143324
void func_801434E4(GameState* state, SkyboxContext* skyboxCtx, s16 skyType); // func_801434E4
// void func_801435A0(void);
// void func_80143624(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE1 param_5, UNK_TYPE1 param_6, UNK_TYPE1 param_7);
// void func_80143668(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5, UNK_TYPE4 param_6, UNK_TYPE4 param_7);

View File

@ -39,6 +39,9 @@ extern GraphicsContext* oGfxCtx;
#define GRAPH_ALLOC(gfxCtx, size) \
((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - (size)))
#define ALIGN8(val) (((val) + 7) & ~7)
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))

View File

@ -2082,13 +2082,13 @@ extern z_Matrix identityMatrix;
// extern UNK_TYPE1 D_801C5DE0;
// extern UNK_TYPE1 D_801C5DF0;
// extern UNK_TYPE1 D_801C5E00;
// extern UNK_TYPE1 D_801C5E30;
// extern UNK_TYPE2 D_801C5E48;
// extern UNK_TYPE4 D_801C5E88;
// extern UNK_TYPE4 D_801C5E9C;
// extern UNK_TYPE4 D_801C5EB0;
// extern UNK_TYPE2 D_801C5EC4;
// extern UNK_TYPE4 D_801C5F44;
extern s32 D_801C5E30[]; // D_801C5E30
extern u16 D_801C5E48[]; // D_801C5E48
extern s32 D_801C5E88[]; // D_801C5E88
extern s32 D_801C5E9C[]; // D_801C5E9C
extern s32 D_801C5EB0[]; // D_801C5EB0
extern s16 D_801C5EC4[]; // D_801C5EC4
extern struct_801C5F44 D_801C5F44[]; // D_801C5F44
// extern UNK_TYPE4 D_801C5FC0;
// extern UNK_TYPE4 D_801C5FC4;
// extern UNK_TYPE4 D_801C5FC8;

View File

@ -801,8 +801,8 @@ typedef struct {
/* 0x04 */ f32 unk4;
/* 0x08 */ f32 unk8;
/* 0x0C */ f32 unkC;
/* 0x10 */ UNK_TYPE1 unk10;
/* 0x11 */ UNK_TYPE1 unk11;
/* 0x10 */ u8 unk10;
/* 0x11 */ u8 unk11;
/* 0x12 */ UNK_TYPE1 unk12;
/* 0x13 */ UNK_TYPE1 unk13;
/* 0x14 */ UNK_TYPE1 unk14;
@ -958,6 +958,34 @@ typedef struct {
/* 0xF2 */ u8 unkF2[0xC];
} KankyoContext; // size = 0xFE
typedef struct {
/* 0x00000 */ View view;
/* 0x00168 */ void* skyboxStaticSegment[2];
/* 0x00170 */ char unk170[8]; // more static segments?
/* 0x00178 */ void* skyboxPaletteStaticSegment;
/* 0x0017C */ Gfx* unk17C;
/* 0x00180 */ Gfx* unk180;
/* 0x00184 */ Vtx* roomVtx;
/* 0x00188 */ DmaRequest unk188;
/* 0x001A8 */ DmaRequest unk1A8;
/* 0x001C8 */ DmaRequest unk1C8;
/* 0x001E8 */ OSMesgQueue loadQueue;
/* 0x00200 */ OSMesg loadMsg;
/* 0x00204 */ s16 skyboxShouldDraw;
/* 0x00208 */ f32 rotX;
/* 0x0020C */ f32 rotY;
/* 0x00210 */ f32 rotZ;
/* 0x00214 */ Vec3f eye;
/* 0x00220 */ s16 angle;
/* 0x00222 */ u8 primR;
/* 0x00223 */ u8 primG;
/* 0x00224 */ u8 primB;
/* 0x00225 */ u8 envR;
/* 0x00226 */ u8 envG;
/* 0x00227 */ u8 envB;
} SkyboxContext; // size = 0x228
typedef struct {
/* 0x00000 */ View view;
/* 0x00168 */ Font font;
@ -1611,7 +1639,8 @@ struct GlobalContext {
/* 0x01F78 */ GlobalContext1F78 unk1F78[16];
/* 0x02138 */ EffFootmark footmarks[100];
/* 0x046B8 */ SramContext sram;
/* 0x046D8 */ UNK_TYPE1 pad46D8[0x230];
/* 0x046D8 */ UNK_TYPE1 pad46D8[0x8];
/* 0x046E0 */ SkyboxContext skyboxCtx;
/* 0x04908 */ MessageContext msgCtx;
/* 0x169E0 */ UNK_TYPE1 pad169E0[0x8];
/* 0x169E8 */ InterfaceContext interfaceCtx;
@ -1664,6 +1693,14 @@ struct GlobalContext {
/* 0x18E58 */ UNK_TYPE1 pad18E58[0x400];
}; // size = 0x19258
typedef struct {
/* 0x00 */ s32 unk0;
/* 0x04 */ s32 unk4;
/* 0x08 */ s32 unk8;
/* 0x0C */ s32 unkC;
/* 0x10 */ s32 unk10;
} struct_801C5F44; // size = 0x14
typedef struct {
/* 0x000 */ Actor base;
/* 0x144 */ ColQuad unk144;

View File

@ -396,7 +396,7 @@ SECTIONS
build/asm/code/code_0x80140E80.o(.text)
build/asm/code/z_vismono.o(.text)
build/asm/code/code_0x801420C0.o(.text)
build/asm/code/z_vr_box.o(.text)
build/src/code/z_vr_box.o(.text)
build/asm/code/z_vr_box_draw.o(.text)
build/asm/code/z_sram_NES.o(.text)
build/asm/code/z_message.o(.text)
@ -507,7 +507,7 @@ SECTIONS
build/asm/code/code_data_0x80138BA0.o(.data)
build/asm/code/code_data_z_sub_s.o(.data)
build/asm/code/code_data_z_vimode.o(.data)
build/asm/code/code_data_z_vr_box.o(.data)
build/src/code/z_vr_box.o(.data)
build/asm/code/code_data_z_vr_box_draw.o(.data)
build/asm/code/code_data_z_sram_NES.o(.data)
build/asm/code/code_data_z_message_nes.o(.data)

161
src/code/z_vr_box.c Normal file
View File

@ -0,0 +1,161 @@
#include <ultra64.h>
#include <global.h>
s32 D_801C5E30[] = { 0, 0x2000, 0x4000, 0x6000, 0x8000, 0xC000 };
u16 D_801C5E48[] = {
0, 2, 10, 12, 2, 4, 12, 14, 10, 12, 20, 22, 12, 14, 22, 24, 1, 3, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 21, 23,
};
s32 D_801C5E88[] = { 0, 0x7C0, 0xF80, 0x1740, 0x1F00 };
s32 D_801C5E9C[] = { 0, 0x7C0, 0xF80, 0x1740, 0x1F00 };
s32 D_801C5EB0[] = { 0, 0x7C0, 0xF80, 0x7C0, 0 };
s16 D_801C5EC4[] = {
0, 16, 19, 18, 16, 1, 20, 19, 1, 17, 21, 20, 17, 5, 22, 21, 18, 19, 23, 2, 19, 20,
3, 23, 20, 21, 24, 3, 21, 22, 7, 24, 2, 23, 26, 25, 23, 3, 27, 26, 3, 24, 28, 27,
24, 7, 29, 28, 25, 26, 30, 10, 26, 27, 11, 30, 27, 28, 31, 11, 28, 29, 15, 31,
};
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_vr_box/func_80142440.asm")
void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) {
static struct_801C5F44 D_801C5F44[] = {
{ -64, 64, -64, 32, -32 }, { 64, 64, 64, -32, -32 }, { -64, 64, 64, -32, -32 },
{ 64, 64, -64, 32, -32 }, { -64, 64, 64, 32, -32 }, { -64, -64, -64, 32, 32 },
};
s32 ret = 0;
struct_801C5F44* unkStruct;
s32 face;
for (face = 0; face < arg1; face++) {
unkStruct = &D_801C5F44[face];
ret = func_80142440(skyboxCtx, skyboxCtx->roomVtx, ret, unkStruct->unk0, unkStruct->unk4, unkStruct->unk8,
unkStruct->unkC, unkStruct->unk10, face);
}
}
#ifdef NON_MATCHING
// Matches besides rodata, since rodata is not merged into the asm in code files yet.
void func_801431E8(GameState* state, SkyboxContext* skyboxCtx, s16 skyType) {
GlobalContext* globalCtx = (GlobalContext*)state;
u32 size;
void* offset;
s32 pad;
skyboxCtx->rotZ = 0.0f;
if (skyType != 1) {
if (skyType != 2) {
return;
}
} else {
// Send a DMA request for the cloudy sky texture
skyboxCtx->skyboxStaticSegment[0] = &D_80025D00;
size = (u32)_vr_cloud_staticSegmentRomEnd - (u32)_vr_cloud_staticSegmentRomStart;
offset = (void*)ALIGN8((u32)skyboxCtx->skyboxStaticSegment[0] + size);
DmaMgr_SendRequest0(skyboxCtx->skyboxStaticSegment[0], (u32)_vr_cloud_staticSegmentRomStart, size);
// Send a DMA request for the clear sky texture
skyboxCtx->skyboxStaticSegment[1] = offset;
size = (u32)_vr_fine_staticSegmentRomEnd - (u32)_vr_fine_staticSegmentRomStart;
offset = (void*)ALIGN8((u32)offset + size);
DmaMgr_SendRequest0(skyboxCtx->skyboxStaticSegment[1], (u32)_vr_fine_staticSegmentRomStart, size);
// Send a DMA request for the skybox palette
skyboxCtx->skyboxPaletteStaticSegment = offset;
size = (u32)_vr_pal_staticSegmentRomEnd - (u32)_vr_pal_staticSegmentRomStart;
offset = (void*)ALIGN8((u32)offset + size);
DmaMgr_SendRequest0(skyboxCtx->skyboxPaletteStaticSegment, (u32)_vr_pal_staticSegmentRomStart, size);
skyboxCtx->primR = 145;
skyboxCtx->primG = 120;
skyboxCtx->primB = 155;
skyboxCtx->envR = 40;
skyboxCtx->envG = 0;
skyboxCtx->envB = 40;
// Inverted Stone Tower Temple and Inverted Stone Tower
if ((globalCtx->sceneNum == SCENE_F41) || (globalCtx->sceneNum == SCENE_INISIE_R)) {
skyboxCtx->rotZ = 3.15000009537f;
}
}
}
#else
#pragma GLOBAL_ASM("./asm/non_matchings/code/z_vr_box/func_801431E8.asm")
#endif
void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) {
u32 size;
if (1) {}
if (skyType == 1) {
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
if (globalCtx->kankyoContext.unk10 == 0) {
// Send a DMA request for the clear sky texture
size = (u32)_vr_fine_staticSegmentRomEnd - (u32)_vr_fine_staticSegmentRomStart;
DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->skyboxStaticSegment[0],
(u32)_vr_fine_staticSegmentRomStart, size, 0, &skyboxCtx->loadQueue, NULL);
} else {
// Send a DMA request for the cloudy sky texture
size = (u32)_vr_cloud_staticSegmentRomEnd - (u32)_vr_cloud_staticSegmentRomStart;
DmaMgr_SendRequestImpl(&skyboxCtx->unk188, skyboxCtx->skyboxStaticSegment[0],
(u32)_vr_cloud_staticSegmentRomStart, size, 0, &skyboxCtx->loadQueue, NULL);
}
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
if (globalCtx->kankyoContext.unk11 == 0) {
// Send a DMA request for the clear sky texture
size = (u32)_vr_fine_staticSegmentRomEnd - (u32)_vr_fine_staticSegmentRomStart;
DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->skyboxStaticSegment[1],
(u32)_vr_fine_staticSegmentRomStart, size, 0, &skyboxCtx->loadQueue, NULL);
} else {
// Send a DMA request for the cloudy sky texture
size = (u32)_vr_cloud_staticSegmentRomEnd - (u32)_vr_cloud_staticSegmentRomStart;
DmaMgr_SendRequestImpl(&skyboxCtx->unk1A8, skyboxCtx->skyboxStaticSegment[1],
(u32)_vr_cloud_staticSegmentRomStart, size, 0, &skyboxCtx->loadQueue, NULL);
}
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
size = (u32)_vr_pal_staticSegmentRomEnd - (u32)_vr_pal_staticSegmentRomStart;
// Send a DMA request for the skybox palette
DmaMgr_SendRequestImpl(&skyboxCtx->unk1C8, skyboxCtx->skyboxPaletteStaticSegment,
(u32)_vr_pal_staticSegmentRomStart, size, 0, &skyboxCtx->loadQueue, NULL);
osRecvMesg(&skyboxCtx->loadQueue, NULL, 1);
}
}
void func_801434E4(GameState* state, SkyboxContext* skyboxCtx, s16 skyType) {
skyboxCtx->skyboxShouldDraw = 0;
skyboxCtx->rotX = skyboxCtx->rotY = skyboxCtx->rotZ = 0.0f;
func_801431E8(state, skyboxCtx, skyType);
if (skyType != 0) {
skyboxCtx->unk17C = GameStateHeap_AllocFromEnd(&state->heap, 0x3840);
if (skyType == 5) {
// Allocate enough space for the vertices for a 6 sided skybox (cube)
skyboxCtx->roomVtx = GameStateHeap_AllocFromEnd(&state->heap, sizeof(Vtx) * 32 * 6);
func_80143148(skyboxCtx, 6);
} else {
// Allocate enough space for the vertices for a 5 sided skybox (bottom is missing)
skyboxCtx->roomVtx = GameStateHeap_AllocFromEnd(&state->heap, sizeof(Vtx) * 32 * 5);
func_80143148(skyboxCtx, 5);
}
}
}