Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Macro for __FILE__ & __LINE__ when possible #559

Merged
merged 23 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c20c4ee
First batch some overlay
Baoulettes Jun 26, 2022
2e793f0
Almost all overlay
Baoulettes Jun 26, 2022
e6c3c71
effect & gamestate
Baoulettes Jun 26, 2022
a9b1695
kaleido stuffs
Baoulettes Jun 26, 2022
9ea4e24
more overlay
Baoulettes Jun 26, 2022
ac48cae
more left over from code folder
Baoulettes Jun 26, 2022
4a3905b
remaining hardcoded line and file
Baoulettes Jun 27, 2022
146fbb0
Open & Close _DISP __FILE__ & __LINE__ clean up
Baoulettes Jun 27, 2022
9e06677
Some if (1) {} remove
Baoulettes Jun 27, 2022
1cdaf45
LOG_xxxx __FILE__ , __LINE__ cleaned
Baoulettes Jun 27, 2022
73d9baf
ASSERT macro __FILE__ __LINE__
Baoulettes Jun 27, 2022
d627ec3
mtx without line/file in functions
Baoulettes Jun 27, 2022
cd0cea2
" if (1) {} " & "if (0) {}" and tab/white place
Baoulettes Jun 27, 2022
0ef8463
Merge branch 'HarbourMasters:develop' into openclose_disp_macro
Baoulettes Jun 28, 2022
4606929
LogUtils as macro
Baoulettes Jun 28, 2022
0d85caa
GameState_, GameAlloc_, SystemArena_ & ZeldaArena_
Baoulettes Jun 28, 2022
6b4ceef
Revert "GameState_, GameAlloc_, SystemArena_ & ZeldaArena_"
Baoulettes Jun 28, 2022
ceae019
Like last commit but as macro
Baoulettes Jun 28, 2022
c319631
Fix matrix not using macros
Baoulettes Jul 4, 2022
b038ba5
Merge branch 'HarbourMasters:develop' into openclose_disp_macro
Baoulettes Jul 4, 2022
6d298cb
use function not macro
Baoulettes Jul 4, 2022
193b634
DebugArena_* functions
Baoulettes Jul 4, 2022
98e3f7a
Merge branch 'HarbourMasters:develop' into openclose_disp_macro
Baoulettes Jul 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions soh/include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1763,8 +1763,8 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode);
void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation);
void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot);
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest);
Mtx* Matrix_ToMtx(Mtx* dest);
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx);
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line);
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line);
Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx);
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);
void Matrix_MtxFCopy(MtxF* dest, MtxF* src);
Expand All @@ -1775,7 +1775,7 @@ void Matrix_ReplaceRotation(MtxF* mf);
void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode);
MtxF* Matrix_CheckFloats(MtxF* mf);
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line);
void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY,
f32 translateZ);
uintptr_t SysUcode_GetUCodeBoot(void);
Expand Down
4 changes: 4 additions & 0 deletions soh/include/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@
#define LOG_HUNGUP_THREAD() ((void)0)
#endif

#define MATRIX_TOMTX(dest) Matrix_ToMtx(dest, __FILE__, __LINE__)
#define MATRIX_NEWMTX(gfxCtx) Matrix_NewMtx(gfxCtx, __FILE__, __LINE__)
#define MATRIX_CHECKFLOATS(mf) Matrix_CheckFloats(mf, __FILE__, __LINE__)

#define ZELDA_ARENA_MALLOC_DEBUG(size) ZeldaArena_MallocDebug(size, __FILE__, __LINE__)
#define ZELDA_ARENA_MALLOC_RDEBUG(size) ZeldaArena_MallocRDebug(size, __FILE__, __LINE__)
#define ZELDA_ARENA_REALLOC_DEBUG(ptr, newSize) ZeldaArena_ReallocDebug(ptr, newSize, __FILE__, __LINE__)
Expand Down
6 changes: 3 additions & 3 deletions soh/soh/frame_interpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void Matrix_RotateZYX(s16 x, s16 y, s16 z, u8 mode);
void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation);
void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot);
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest);
Mtx* Matrix_ToMtx(Mtx* dest);
Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx);
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line);
Mtx* Matrix_NewMtx(struct GraphicsContext* gfxCtx, char* file, s32 line);
Mtx* Matrix_MtxFToNewMtx(MtxF* src, struct GraphicsContext* gfxCtx);
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);
void Matrix_MtxFCopy(MtxF* dest, MtxF* src);
Expand All @@ -68,7 +68,7 @@ void Matrix_ReplaceRotation(MtxF* mf);
void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode);
MtxF* Matrix_CheckFloats(MtxF* mf);
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line);
void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY,
f32 translateZ);

Expand Down
14 changes: 7 additions & 7 deletions soh/src/code/sys_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,15 @@ Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) {
return dest;
}

Mtx* Matrix_ToMtx(Mtx* dest) {
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) {
FrameInterpolation_RecordMatrixToMtx(dest, __FILE__, __LINE__);
Baoulettes marked this conversation as resolved.
Show resolved Hide resolved
guMtxF2L(Matrix_CheckFloats(sCurrentMatrix), dest);
guMtxF2L(MATRIX_CHECKFLOATS(sCurrentMatrix), dest);
Baoulettes marked this conversation as resolved.
Show resolved Hide resolved
return dest;
//return Matrix_MtxFToMtx(Matrix_CheckFloats(sCurrentMatrix, file, line), dest);
//return Matrix_MtxFToMtx(MATRIX_CHECKFLOATS(sCurrentMatrix), dest);
}

Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx) {
return Matrix_ToMtx(Graph_Alloc(gfxCtx, sizeof(Mtx)));
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line) {
return Matrix_ToMtx(Graph_Alloc(gfxCtx, sizeof(Mtx)), file, line);
}

Mtx* Matrix_MtxFToNewMtx(MtxF* src, GraphicsContext* gfxCtx) {
Expand Down Expand Up @@ -889,7 +889,7 @@ void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode) {
}
}

MtxF* Matrix_CheckFloats(MtxF* mf) {
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line) {
s32 i, j;

for (i = 0; i < 4; i++) {
Expand All @@ -900,7 +900,7 @@ MtxF* Matrix_CheckFloats(MtxF* mf) {
"| %12.6f %12.6f %12.6f %12.6f |\n"
"| %12.6f %12.6f %12.6f %12.6f |\n"
"\\ %12.6f %12.6f %12.6f %12.6f /\n",
__FILE__, __LINE__, "mf", mf->xx, mf->xy, mf->xz, mf->xw, mf->yx, mf->yy, mf->yz, mf->yw, mf->zx,
file, line, "mf", mf->xx, mf->xy, mf->xz, mf->xw, mf->yx, mf->yy, mf->yz, mf->yw, mf->zx,
mf->zy, mf->zz, mf->zw, mf->wx, mf->wy, mf->wz, mf->ww);
//Fault_AddHungupAndCrash(file, line);
}
Expand Down
18 changes: 9 additions & 9 deletions soh/src/code/z_actor.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf
temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.shadowScale;
Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY);

gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dlist);

Expand Down Expand Up @@ -160,7 +160,7 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3
Matrix_RotateY(sp58, MTXMODE_APPLY);
Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY);

gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL);

Expand Down Expand Up @@ -496,7 +496,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) {
Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY);
Matrix_Push();
Matrix_Translate(entry->unk_0C, entry->unk_0C, 0.0f, MTXMODE_APPLY);
gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL);
Matrix_Pop();
Expand Down Expand Up @@ -525,7 +525,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) {
Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY);

gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, naviColor->inner.r, naviColor->inner.g, naviColor->inner.b, 255);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL);
FrameInterpolation_RecordCloseChild();
Expand Down Expand Up @@ -2277,14 +2277,14 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) {
gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255);

Matrix_RotateZ(((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL);

Matrix_Pop();
Matrix_RotateZ(~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY);

gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL);
}
Expand Down Expand Up @@ -3841,7 +3841,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx)

Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY);

gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL);

Expand Down Expand Up @@ -3931,7 +3931,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY);
}

gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);

Expand All @@ -3947,7 +3947,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
Matrix_Put(&baseMtxF);
Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY);

gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, entry->lockDL);

Expand Down
4 changes: 2 additions & 2 deletions soh/src/code/z_cheap_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) {
OPEN_DISPS(globalCtx->state.gfxCtx);

func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dlist);

Expand All @@ -15,7 +15,7 @@ void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) {
OPEN_DISPS(globalCtx->state.gfxCtx);

func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, dlist);

Expand Down
4 changes: 2 additions & 2 deletions soh/src/code/z_debug_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalCo
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),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gDebugSpriteDL);

Expand All @@ -100,7 +100,7 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, GlobalConte
Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot);
Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY);

gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx),
G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, dlist);

Expand Down
Loading