1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-02 15:55:59 +00:00
oot/src/code/z_debug_display.c

109 lines
4.4 KiB
C
Raw Normal View History

#include "global.h"
Decompile Gameplay_Keep and fix all existing decompiled objects (#595) * First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-01-25 00:36:40 +00:00
#include "objects/gameplay_keep/gameplay_keep.h"
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
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 function when called
} DebugDispObjectInfo; // size = 0x8
2020-03-17 04:31:30 +00:00
typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*);
2020-03-17 04:31:30 +00:00
void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play);
void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, PlayState* play);
2020-03-17 04:31:30 +00:00
2020-03-22 21:19:43 +00:00
static DebugDispObject_DrawFunc sDebugObjectDrawFuncTable[] = {
2020-03-17 04:31:30 +00:00
DebugDisplay_DrawSpriteI8,
DebugDisplay_DrawPolygon,
};
2020-03-22 21:19:43 +00:00
static DebugDispObjectInfo sDebugObjectInfoTable[] = {
Decompile Gameplay_Keep and fix all existing decompiled objects (#595) * First batch of files * Add missing folders back * Fix missing folders again * Finish fixing existing texture files * Gameplay_Keep XML finished * Most actor gameplay_keep undefined syms removed * Only ~200 gkeep symbols remain * All gkeep symbols that ZAP supports are fixed * Cleanup, and make gkeep names more accurate * Starting to figure out what some unknown blobs are, merge zeldaret in * fix a few more things * refactor gkeep * Change how gitkeep is handled * gkeep xml cleanup * Gkeep finished, now just waiting up ZAP updates * 100 link animations finished * 150 link animations finished * 200 link animations finished * 250 link animations finished * 350 link animations finished * 400 link animations finished * 450 link animations finished * 500 link animations finished * 550 link animations finished * All Link animations finished cannot build yet because ZAP doesn't have LinkAnimationHeader yet * xml changes for new zap stuff * finish gameplay_keep * fixing existing objects * ready for pr besides zap padding issue * mostly ready for pr * format all c files * all conflicts fixed * make changes that roman requested * fix thing i didn't mean to change * some animation symbols renamed * fixed roman's stuff * lifemeter hardcoded pointers removed * fix issue with incorrect data in gameplay_keep * removed unused asm * fixed most of fig's comments * fix all of fig's comments * reformat files * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * Update assets/xml/textures/icon_item_static.xml Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com> * fixed stuff * fixed most of roman's comments * remove leading zeroes * should build now * git subrepo pull --force tools/ZAPD subrepo: subdir: "tools/ZAPD" merged: "f84d8337b" upstream: origin: "https://github.com/zeldaret/ZAPD.git" branch: "master" commit: "f84d8337b" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * all of gkeep symbols fixed * compiler error fixed * format files * final changes Co-authored-by: Zelllll <elijah@DESKTOP-NMP1I89.localdomain> Co-authored-by: Roman971 <32455037+Roman971@users.noreply.github.com>
2021-01-25 00:36:40 +00:00
{ 0, gDebugCircleTex }, { 0, gDebugCrossTex }, { 0, gDebugBallTex },
{ 0, gDebugCursorTex }, { 1, gDebugArrowDL }, { 1, gDebugCameraDL },
2020-03-17 04:31:30 +00:00
};
static Lights1 sDebugObjectLights = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73);
2020-03-17 04:31:30 +00:00
static DebugDispObject* sDebugObjectListHead;
2020-03-22 21:19:43 +00:00
void DebugDisplay_Init(void) {
2020-03-17 04:31:30 +00:00
sDebugObjectListHead = NULL;
}
2020-03-22 21:19:43 +00:00
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) {
2020-03-17 04:31:30 +00:00
DebugDispObject* prevHead = 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 = prevHead;
return sDebugObjectListHead;
}
void DebugDisplay_DrawObjects(PlayState* play) {
2020-03-17 04:31:30 +00:00
DebugDispObject* dispObj = sDebugObjectListHead;
DebugDispObjectInfo* objInfo;
2020-03-22 21:19:43 +00:00
while (dispObj != NULL) {
2020-03-17 04:31:30 +00:00
objInfo = &sDebugObjectInfoTable[dispObj->type];
sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, play);
2020-03-17 04:31:30 +00:00
dispObj = dispObj->next;
}
}
void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx, "../z_debug_display.c", 169);
2020-03-17 04:31:30 +00:00
func_80094678(play->state.gfxCtx);
2020-03-17 04:31:30 +00:00
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
2020-03-17 04:31:30 +00:00
Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY);
Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY);
2020-03-17 04:31:30 +00:00
gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP,
2020-03-22 21:19:43 +00:00
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_debug_display.c", 189),
2020-03-22 21:19:43 +00:00
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gDebugSpriteDL);
2020-03-17 04:31:30 +00:00
CLOSE_DISPS(play->state.gfxCtx, "../z_debug_display.c", 192);
2020-03-17 04:31:30 +00:00
}
void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx, "../z_debug_display.c", 211);
2020-03-17 04:31:30 +00:00
func_8009435C(play->state.gfxCtx);
2020-03-17 04:31:30 +00:00
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
2020-03-17 04:31:30 +00:00
gSPSetLights1(POLY_XLU_DISP++, sDebugObjectLights);
2020-03-17 04:31:30 +00:00
Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
2020-03-17 04:31:30 +00:00
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_debug_display.c", 228),
2020-03-22 21:19:43 +00:00
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, dlist);
2020-03-17 04:31:30 +00:00
CLOSE_DISPS(play->state.gfxCtx, "../z_debug_display.c", 231);
2020-03-17 04:31:30 +00:00
}