mirror of https://github.com/zeldaret/mm.git
Debug display mostly OK (#399)
* WIP * done? * remove something from variables.h * missed a warning * PR fixes (AngheloAlf) * fix lights * restore ZAPD makefile * format * format again * fix a graph alloc * Missed one in skin
This commit is contained in:
parent
11487db1ca
commit
fcbd524b5d
|
@ -0,0 +1,29 @@
|
|||
<Root>
|
||||
<File Name="code" BaseAddress="0x800A5AC0" RangeStart="0x114A90" RangeEnd="0x115550" OutName="debug_display">
|
||||
<Array Name="sDebugDisplay1Vtx" Count="36" Offset="0x114A90">
|
||||
<Vtx/>
|
||||
</Array>
|
||||
<DList Name="sDebugDisplay1DL" Offset="0x114CD0"/>
|
||||
|
||||
<Array Name="sDebugDisplay2Vtx" Count="8" Offset="0x114D30">
|
||||
<Vtx/>
|
||||
</Array>
|
||||
<DList Name="sDebugDisplay2DL" Offset="0x114DB0"/>
|
||||
|
||||
<Array Name="sDebugDisplay3Vtx" Count="40" Offset="0x114E00">
|
||||
<Vtx/>
|
||||
</Array>
|
||||
<DList Name="sDebugDisplay3DL" Offset="0x115080"/>
|
||||
|
||||
<Texture Name="sDebugDisplayCircleTex" OutName="debug_circle" Format="i8" Width="16" Height="16" Offset="0x1150F8"/>
|
||||
<Texture Name="sDebugDisplayBallTex" OutName="debug_ball" Format="i8" Width="16" Height="16" Offset="0x1151F8"/>
|
||||
<Texture Name="sDebugDisplayCursorTex" OutName="debug_cursor" Format="i8" Width="16" Height="16" Offset="0x1152F8"/>
|
||||
<Texture Name="sDebugDisplayCrossTex" OutName="debug_cross" Format="i8" Width="16" Height="16" Offset="0x1153F8"/>
|
||||
|
||||
<Array Name="sDebugDisplaySpriteVtx" Count="4" Offset="0x1154F8">
|
||||
<Vtx/>
|
||||
</Array>
|
||||
<DList Name="sDebugDisplaySpriteDL" Offset="0x115538"/>
|
||||
|
||||
</File>
|
||||
</Root>
|
|
@ -1545,12 +1545,7 @@ s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s*
|
|||
void SaveContext_Init(void);
|
||||
void GameInfo_Init(void);
|
||||
// void func_800E9470(void);
|
||||
void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx);
|
||||
void DebugDisplay_DrawObjects(GlobalContext* globalCtx);
|
||||
// void func_800E95F4(void);
|
||||
// void func_800E97D8(void);
|
||||
// void func_800E992C(void);
|
||||
// void func_800E99B0(void);
|
||||
DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx);
|
||||
// void func_800E9C90(void);
|
||||
// void func_800E9CA0(s32 param_1, UNK_TYPE1 param_2, s8* param_3);
|
||||
// void func_800E9CFC(void);
|
||||
|
|
|
@ -882,26 +882,6 @@ extern ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX];
|
|||
extern ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX];
|
||||
extern EffShieldParticleInit shieldParticleInitMetal;
|
||||
extern EffShieldParticleInit shieldParticleInitWood;
|
||||
extern UNK_TYPE1 D_801BA550;
|
||||
// extern UNK_TYPE1 D_801BA750;
|
||||
// extern UNK_TYPE1 D_801BA790;
|
||||
// extern UNK_TYPE1 D_801BA7F0;
|
||||
// extern UNK_TYPE1 D_801BA870;
|
||||
// extern UNK_TYPE1 D_801BA8C0;
|
||||
// extern UNK_TYPE1 D_801BAAC0;
|
||||
// extern UNK_TYPE1 D_801BAB40;
|
||||
// extern UNK_TYPE1 D_801BABB8;
|
||||
// extern UNK_TYPE1 D_801BACB8;
|
||||
// extern UNK_TYPE1 D_801BADB8;
|
||||
// extern UNK_TYPE1 D_801BAEB8;
|
||||
// extern UNK_TYPE1 D_801BAFB8;
|
||||
// extern UNK_TYPE1 D_801BAFF8;
|
||||
// extern UNK_TYPE1 D_801BB010;
|
||||
// extern UNK_TYPE1 D_801BB018;
|
||||
// extern UNK_TYPE1 D_801BB050;
|
||||
// extern UNK_TYPE1 D_801BB058;
|
||||
// extern UNK_TYPE2 D_801BB068;
|
||||
// extern UNK_TYPE1 D_801BB08C;
|
||||
// extern UNK_TYPE4 D_801BB090;
|
||||
// extern UNK_TYPE1 D_801BB094;
|
||||
// extern UNK_TYPE1 D_801BB0DC;
|
||||
|
@ -3264,7 +3244,6 @@ extern SaveContext gSaveContext;
|
|||
// extern UNK_TYPE1 D_801F3F4A;
|
||||
// extern UNK_TYPE1 D_801F3F5A;
|
||||
extern GameInfo* gGameInfo;
|
||||
// extern UNK_TYPE1 D_801F3F70;
|
||||
// extern UNK_TYPE1 D_801F3F80;
|
||||
// extern UNK_TYPE1 D_801F3F83;
|
||||
// extern UNK_TYPE1 D_801F48C8;
|
||||
|
|
|
@ -1684,6 +1684,16 @@ typedef struct {
|
|||
/* 0x20 */ u16 fracPart[4][4];
|
||||
} MatrixInternal; // size = 0x40
|
||||
|
||||
typedef struct DebugDispObject {
|
||||
/* 0x00 */ Vec3f pos;
|
||||
/* 0x0C */ Vec3s rot;
|
||||
/* 0x14 */ Vec3f scale;
|
||||
/* 0x20 */ Color_RGBA8 color;
|
||||
/* 0x24 */ s16 type;
|
||||
/* 0x28 */ struct DebugDispObject* next;
|
||||
/* 0x2C */ s32 pad; //Padding not in the OOT version
|
||||
} DebugDispObject; // size = 0x30
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8* value;
|
||||
/* 0x04 */ const char* name;
|
||||
|
|
2
spec
2
spec
|
@ -470,8 +470,6 @@ beginseg
|
|||
include "build/src/code/z_common_data.o"
|
||||
include "build/src/code/z_debug.o"
|
||||
include "build/src/code/z_debug_display.o"
|
||||
include "build/data/code/z_debug_display.data.o"
|
||||
include "build/data/code/z_debug_display.bss.o"
|
||||
include "build/src/code/z_debug_mode.o"
|
||||
include "build/data/code/z_debug_mode.data.o"
|
||||
include "build/data/code/z_debug_mode.bss.o"
|
||||
|
|
|
@ -1,15 +1,125 @@
|
|||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E9470.s")
|
||||
DebugDispObject* sDebugObjectListHead;
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s")
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 drawType; // indicates which draw function to use when displaying the object
|
||||
/* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called
|
||||
} DebugDispObjectInfo; // size = 0x8
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s")
|
||||
typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E95F4.s")
|
||||
void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, GlobalContext*);
|
||||
void DebugDisplay_DrawPolygon(DebugDispObject*, void*, GlobalContext*);
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E97D8.s")
|
||||
DebugDispObject* DebugDisplay_Init(void) {
|
||||
sDebugObjectListHead = NULL;
|
||||
return sDebugObjectListHead;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E992C.s")
|
||||
DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX,
|
||||
f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type,
|
||||
GraphicsContext* gfxCtx) {
|
||||
DebugDispObject* oldHead = sDebugObjectListHead;
|
||||
|
||||
sDebugObjectListHead = GRAPH_ALLOC(gfxCtx, sizeof(DebugDispObject));
|
||||
sDebugObjectListHead->pos.x = posX;
|
||||
sDebugObjectListHead->pos.y = posY;
|
||||
sDebugObjectListHead->pos.z = posZ;
|
||||
sDebugObjectListHead->rot.x = rotX;
|
||||
sDebugObjectListHead->rot.y = rotY;
|
||||
sDebugObjectListHead->rot.z = rotZ;
|
||||
sDebugObjectListHead->scale.x = scaleX;
|
||||
sDebugObjectListHead->scale.y = scaleY;
|
||||
sDebugObjectListHead->scale.z = scaleZ;
|
||||
sDebugObjectListHead->color.r = red;
|
||||
sDebugObjectListHead->color.g = green;
|
||||
sDebugObjectListHead->color.b = blue;
|
||||
sDebugObjectListHead->color.a = alpha;
|
||||
sDebugObjectListHead->type = type;
|
||||
sDebugObjectListHead->next = oldHead;
|
||||
return sDebugObjectListHead;
|
||||
}
|
||||
|
||||
#include "code/debug_display/debug_display.c"
|
||||
|
||||
DebugDispObject_DrawFunc sDebugObjectDrawFuncTable[] = { DebugDisplay_DrawSpriteI8, DebugDisplay_DrawPolygon };
|
||||
|
||||
DebugDispObjectInfo sDebugObjectInfoTable[] = {
|
||||
{ 0, sDebugDisplayCircleTex }, { 0, sDebugDisplayCrossTex }, { 0, sDebugDisplayBallTex },
|
||||
{ 0, sDebugDisplayCursorTex }, { 1, &sDebugDisplay1DL }, { 1, &sDebugDisplay3DL },
|
||||
{ 1, &sDebugDisplay2DL },
|
||||
};
|
||||
|
||||
void DebugDisplay_DrawObjects(GlobalContext* globalCtx) {
|
||||
DebugDispObject* dispObj = sDebugObjectListHead;
|
||||
DebugDispObjectInfo* objInfo;
|
||||
|
||||
while (dispObj != NULL) {
|
||||
objInfo = &sDebugObjectInfoTable[dispObj->type];
|
||||
sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx);
|
||||
dispObj = dispObj->next;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) {
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
func_8012C6FC(globalCtx->state.gfxCtx);
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
|
||||
Matrix_InsertTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, 0);
|
||||
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1);
|
||||
Matrix_InsertMatrix(&globalCtx->mf_187FC, 1);
|
||||
Matrix_InsertRotation(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, 1);
|
||||
|
||||
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
|
||||
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL);
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
||||
Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73);
|
||||
|
||||
void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContext* globalCtx) {
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
func_8012C588(globalCtx->state.gfxCtx);
|
||||
|
||||
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
|
||||
|
||||
gSPSetLights1(POLY_XLU_DISP++, sDebugDisplayLight1);
|
||||
|
||||
Matrix_SetStateRotationAndTranslation(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
|
||||
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, 1);
|
||||
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
|
||||
gSPDisplayList(POLY_XLU_DISP++, arg1);
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
||||
s32 D_801BB068[] = {
|
||||
0x00140000, 0x0000FFEC, 0x00000000, 0x00000014, 0x00000000, 0xFFEC0000, 0x00000000, 0x00140000, 0x0000FFEC,
|
||||
};
|
||||
|
||||
s32 D_801BB08C = 0;
|
||||
|
||||
Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1);
|
||||
|
||||
void func_800E992C(GlobalContext* globalCtx, s32 arg1) {
|
||||
s32 pad;
|
||||
|
||||
OPEN_DISPS(globalCtx->state.gfxCtx);
|
||||
|
||||
func_8012C560(globalCtx->state.gfxCtx);
|
||||
gSPMatrix(POLY_XLU_DISP++, &D_801D1DE0, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1));
|
||||
|
||||
CLOSE_DISPS(globalCtx->state.gfxCtx);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s")
|
||||
|
|
|
@ -329,9 +329,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8
|
|||
Lights* lights;
|
||||
s32 i;
|
||||
|
||||
// TODO allocation should be a macro
|
||||
lights = (Lights*)((int)gfxCtx->polyOpa.d - sizeof(Lights));
|
||||
gfxCtx->polyOpa.d = (void*)lights;
|
||||
lights = GRAPH_ALLOC(gfxCtx, sizeof(Lights));
|
||||
|
||||
lights->l.a.l.col[0] = lights->l.a.l.colc[0] = ambientR;
|
||||
lights->l.a.l.col[1] = lights->l.a.l.colc[1] = ambientG;
|
||||
|
@ -356,9 +354,7 @@ Lights* Lights_NewAndDraw(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8
|
|||
Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambientB) {
|
||||
Lights* lights;
|
||||
|
||||
// TODO allocation should be a macro
|
||||
lights = (Lights*)((int)gfxCtx->polyOpa.d - sizeof(Lights));
|
||||
gfxCtx->polyOpa.d = (void*)lights;
|
||||
lights = GRAPH_ALLOC(gfxCtx, sizeof(Lights));
|
||||
|
||||
lights->l.a.l.col[0] = ambientR;
|
||||
lights->l.a.l.colc[0] = ambientR;
|
||||
|
|
|
@ -577,12 +577,7 @@ void SkinMatrix_MtxFToMtx(MtxF* src, Mtx* dest) {
|
|||
}
|
||||
|
||||
Mtx* SkinMatrix_MtxFToNewMtx(GraphicsContext* gfxCtx, MtxF* src) {
|
||||
s32 pad;
|
||||
Mtx* mtx;
|
||||
|
||||
// TODO allocation should be a macro
|
||||
mtx = (Mtx*)((int)gfxCtx->polyOpa.d - sizeof(Mtx));
|
||||
gfxCtx->polyOpa.d = (void*)mtx;
|
||||
Mtx* mtx = GRAPH_ALLOC(gfxCtx, sizeof(Mtx));
|
||||
|
||||
if (mtx == NULL) {
|
||||
return NULL;
|
||||
|
|
|
@ -1520,11 +1520,11 @@
|
|||
0x800E9250:("func_800E9250",),
|
||||
0x800E9360:("SaveContext_Init",),
|
||||
0x800E93E0:("GameInfo_Init",),
|
||||
0x800E9470:("func_800E9470",),
|
||||
0x800E9470:("DebugDisplay_Init",),
|
||||
0x800E9488:("DebugDisplay_AddObject",),
|
||||
0x800E9564:("DebugDisplay_DrawObjects",),
|
||||
0x800E95F4:("func_800E95F4",),
|
||||
0x800E97D8:("func_800E97D8",),
|
||||
0x800E95F4:("DebugDisplay_DrawSpriteI8",),
|
||||
0x800E97D8:("DebugDisplay_DrawPolygon",),
|
||||
0x800E992C:("func_800E992C",),
|
||||
0x800E99B0:("func_800E99B0",),
|
||||
0x800E9C90:("func_800E9C90",),
|
||||
|
|
|
@ -892,22 +892,21 @@
|
|||
0x801BA508:("shieldParticleInitWood","EffShieldParticleInit","",0x40),
|
||||
0x801BA550:("D_801BA550","UNK_TYPE1","",0x1),
|
||||
0x801BA750:("D_801BA750","UNK_TYPE1","",0x1),
|
||||
0x801BA790:("D_801BA790","UNK_TYPE1","",0x1),
|
||||
0x801BA790:("sDebugDisplay1DL","UNK_TYPE1","",0x1),
|
||||
0x801BA7F0:("D_801BA7F0","UNK_TYPE1","",0x1),
|
||||
0x801BA870:("D_801BA870","UNK_TYPE1","",0x1),
|
||||
0x801BA870:("sDebugDisplay2DL","UNK_TYPE1","",0x1),
|
||||
0x801BA8C0:("D_801BA8C0","UNK_TYPE1","",0x1),
|
||||
0x801BAAC0:("D_801BAAC0","UNK_TYPE1","",0x1),
|
||||
0x801BAB40:("D_801BAB40","UNK_TYPE1","",0x1),
|
||||
0x801BAB40:("sDebugDisplay3DL","UNK_TYPE1","",0x1),
|
||||
0x801BABB8:("D_801BABB8","UNK_TYPE1","",0x1),
|
||||
0x801BACB8:("D_801BACB8","UNK_TYPE1","",0x1),
|
||||
0x801BADB8:("D_801BADB8","UNK_TYPE1","",0x1),
|
||||
0x801BAEB8:("D_801BAEB8","UNK_TYPE1","",0x1),
|
||||
0x801BAFB8:("D_801BAFB8","UNK_TYPE1","",0x1),
|
||||
0x801BAFF8:("D_801BAFF8","UNK_TYPE1","",0x1),
|
||||
0x801BB010:("D_801BB010","UNK_TYPE1","",0x1),
|
||||
0x801BB018:("D_801BB018","UNK_TYPE1","",0x1),
|
||||
0x801BB050:("D_801BB050","UNK_TYPE1","",0x1),
|
||||
0x801BB058:("D_801BB058","UNK_TYPE1","",0x1),
|
||||
0x801BAFF8:("gDebugSpriteDL","UNK_TYPE1","",0x1),
|
||||
0x801BB010:("sDebugObjectDrawFuncTable","UNK_TYPE1","",0x1),
|
||||
0x801BB018:("sDebugObjectInfoTable","UNK_TYPE1","",0x1),
|
||||
0x801BB050:("sDebugDisplayLight1","Lights1","",0x24),
|
||||
0x801BB068:("D_801BB068","UNK_TYPE2","",0x2),
|
||||
0x801BB08C:("D_801BB08C","UNK_TYPE1","",0x1),
|
||||
0x801BB090:("D_801BB090","UNK_TYPE4","",0x4),
|
||||
|
@ -4022,7 +4021,7 @@
|
|||
0x801F3F58:("D_801F3F58","UNK_TYPE1","",0x1),
|
||||
0x801F3F5A:("D_801F3F5A","UNK_TYPE1","",0x1),
|
||||
0x801F3F60:("gGameInfo","GameInfo*","",0x4),
|
||||
0x801F3F70:("D_801F3F70","UNK_TYPE1","",0x1),
|
||||
0x801F3F70:("sDebugObjectListHead","UNK_TYPE1","",0x1),
|
||||
0x801F3F80:("D_801F3F80","UNK_TYPE1","",0x1),
|
||||
0x801F3F83:("D_801F3F83","UNK_TYPE1","",0x1),
|
||||
0x801F48C8:("D_801F48C8","UNK_TYPE1","",0x1),
|
||||
|
|
Loading…
Reference in New Issue