From 5d6aa01e6ece01d69fe66df17698affc56e9d4f6 Mon Sep 17 00:00:00 2001 From: Jeffrey Crowell Date: Fri, 16 Jan 2026 17:07:48 -0800 Subject: [PATCH] Fix linker errors. Stubbing out all OS* functions to stubs.cpp, these will likely have to be replaced with the operating system's primitives for locking/heaps/threads/etc. Moved some generic globals into globals.cpp, not sure where they're actually to be used. Stub DSP functions Stub JSUMemoryOutputStream, JORServer, Z2Audio mDoExt stubs add memcpy add some more stubs, add extras c++ mangled functions add extras.cpp AR/AQ stubbing stub DVD stub CARD more stubs, more extras add missing mtx functions to dusk file finish mtx stub GX KPAD and LC, also do pragma marks for better visualization finish mtx, add a few more stubs gf/wpad/vi translate some matrix math from ppc to C jorserver/debugpad/fap/dmsgobject add m_Do_ext functions from debug block to separate file make small janges to JSystem, does this need upstreaming reorg DVD stubs reorganize stubs by mark --- CMakeLists.txt | 7 +- include/JSystem/JAudio2/JASGadget.h | 5 + src/dusk/J3DTransforms_C.cpp | 25 + src/dusk/extras.c | 12 + src/dusk/extras.cpp | 18 + src/dusk/globals.cpp | 21 + src/dusk/m_Do_ext_dusk.cpp | 565 ++++++++ src/dusk/mtx.cpp | 730 ++++++++++ src/dusk/stubs.cpp | 2080 ++++++++++++++++----------- src/m_Do/m_Do_main.cpp | 9 +- 10 files changed, 2621 insertions(+), 851 deletions(-) create mode 100644 src/dusk/J3DTransforms_C.cpp create mode 100644 src/dusk/extras.cpp create mode 100644 src/dusk/globals.cpp create mode 100644 src/dusk/m_Do_ext_dusk.cpp create mode 100644 src/dusk/mtx.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 437f138699..4f7ff4995e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1347,6 +1347,11 @@ set(DUSK_FILES src/dusk/imgui.cpp src/dusk/stubs.cpp src/dusk/extras.c + src/dusk/extras.cpp + src/dusk/globals.cpp + src/dusk/mtx.cpp + src/dusk/J3DTransforms_C.cpp + src/dusk/m_Do_ext_dusk.cpp ) source_group("dolzel" FILES ${DOLZEL_FILES} ${Z2AUDIOLIB_FILES} ${SSYSTEM_FILES} ${JSYSTEM_FILES} ${REL_FILES}) @@ -1357,7 +1362,7 @@ target_compile_definitions(game PRIVATE TARGET_PC VERSION=0 NDEBUG=1 NDEBUG_DEFI # TODO: version handling for res includes set(DUSK_TP_VERSION GZ2E01) target_include_directories(game PRIVATE include src assets/${DUSK_TP_VERSION} ${CMAKE_BINARY_DIR}/../${DUSK_TP_VERSION}/include) -target_link_libraries(game PRIVATE aurora::core aurora::gx aurora::si aurora::vi aurora::pad) +target_link_libraries(game PRIVATE aurora::core aurora::gx aurora::si aurora::vi aurora::pad aurora::mtx) add_executable(dusk src/dusk/main.cpp) target_compile_definitions(dusk PRIVATE TARGET_PC VERSION=0) diff --git a/include/JSystem/JAudio2/JASGadget.h b/include/JSystem/JAudio2/JASGadget.h index 718ce02069..087e8028cd 100644 --- a/include/JSystem/JAudio2/JASGadget.h +++ b/include/JSystem/JAudio2/JASGadget.h @@ -33,6 +33,11 @@ public: static T* sInstance; }; +#ifndef __MWERKS__ +template +T* JASGlobalInstance::sInstance; +#endif + /** * @ingroup jsystem-jaudio * diff --git a/src/dusk/J3DTransforms_C.cpp b/src/dusk/J3DTransforms_C.cpp new file mode 100644 index 0000000000..efdd2793cd --- /dev/null +++ b/src/dusk/J3DTransforms_C.cpp @@ -0,0 +1,25 @@ +#include +#include + +// translated to C, should be correct, but not tested. + +void J3DPSMtxArrayConcat(Mtx mA, Mtx mB, Mtx mAB, u32 count) { + for (uint32_t i = 0; i < count; i++) { + const float* b = (const float*)mB[i]; + float* res = (float*)mAB[i]; + + for (int row = 0; row < 3; row++) { + float a0 = mA[row][0]; + float a1 = mA[row][1]; + float a2 = mA[row][2]; + float a3 = mA[row][3]; + + // Standard Matrix Multiply for 3x4 * 3x4 (with implicit 4th row [0,0,0,1]) + res[row * 4 + 0] = a0 * b[0] + a1 * b[4] + a2 * b[8]; + res[row * 4 + 1] = a0 * b[1] + a1 * b[5] + a2 * b[9]; + res[row * 4 + 2] = a0 * b[2] + a1 * b[6] + a2 * b[10]; + // The 4th column includes the translation + res[row * 4 + 3] = a0 * b[3] + a1 * b[7] + a2 * b[11] + a3; + } + } +} diff --git a/src/dusk/extras.c b/src/dusk/extras.c index 1dcb6ae49f..d4af760430 100644 --- a/src/dusk/extras.c +++ b/src/dusk/extras.c @@ -1,5 +1,8 @@ #include "dusk/extras.h" #include +#include +#include +#include int stricmp(const char* str1, const char* str2) { char a_var; @@ -43,3 +46,12 @@ int strnicmp(const char* str1, const char* str2, int n) { return 0; } + + +void *_memcpy(void* dest, void const* src, int n) { + return memcpy(dest, src, n); +} + +void DCZeroRange(void* addr, uint32_t nBytes) { + bzero(addr, nBytes); +} diff --git a/src/dusk/extras.cpp b/src/dusk/extras.cpp new file mode 100644 index 0000000000..f13d3e3440 --- /dev/null +++ b/src/dusk/extras.cpp @@ -0,0 +1,18 @@ +// C++ Mangled version of extras.c +#include +#include + +void *__memcpy(void* dest, void const* src, int n) { + return memcpy(dest, src, n); +} + +void __dcbz(void* addr, int offset) { + // Gekko cache lines are 32 bytes. + // dcbz usually requires addr to be 32-byte aligned. + memset((char*)addr + offset, 0, 32); +} + +int __cntlzw(unsigned int val) { + if (val == 0) return 32; // PowerPC returns 32 if the input is 0 + return __builtin_clz(val); +} diff --git a/src/dusk/globals.cpp b/src/dusk/globals.cpp new file mode 100644 index 0000000000..d82a680fcc --- /dev/null +++ b/src/dusk/globals.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +u8 g_printOtherHeapDebug; + +dKankyo_HIO_c g_kankyoHIO; + +dDebugPad_c dDebugPad; + +u32 __OSFpscrEnableBits; + +GDLObj* __GDCurrentDL; + +// DSP +#include +DSPTaskInfo* __DSP_first_task; +DSPTaskInfo* __DSP_curr_task; + +// mDo_dvd +#include +u8 mDoDvdThd::DVDLogoMode; diff --git a/src/dusk/m_Do_ext_dusk.cpp b/src/dusk/m_Do_ext_dusk.cpp new file mode 100644 index 0000000000..7d16d08439 --- /dev/null +++ b/src/dusk/m_Do_ext_dusk.cpp @@ -0,0 +1,565 @@ +// XXX Ripped these from a DEBUG block, rather than changing defines. +/** + * m_Do_ext.cpp + * Model, Animation, and Heap Functions + */ + +#include "d/dolzel.h" // IWYU pragma: keep + +#include +#include +#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h" +#include "JSystem/J3DGraphBase/J3DDrawBuffer.h" +#include "JSystem/J3DGraphBase/J3DMaterial.h" +#include "JSystem/J3DGraphLoader/J3DMaterialFactory.h" +#include "JSystem/JKernel/JKRAssertHeap.h" +#include "JSystem/JKernel/JKRExpHeap.h" +#include "JSystem/JKernel/JKRSolidHeap.h" +#include "JSystem/JUtility/JUTCacheFont.h" +#include "JSystem/JUtility/JUTResFont.h" +#include "Z2AudioLib/Z2Creature.h" +#include "d/d_com_inf_game.h" +#include "global.h" +#include "m_Do/m_Do_ext.h" +#include "m_Do/m_Do_main.h" +#include "m_Do/m_Do_mtx.h" +#include + +mDoExt_cube8pPacket::mDoExt_cube8pPacket(cXyz* i_points, const GXColor& i_color) { + cXyz* pnt_array = mPoints; + + for (int i = 0; i < 8; i++) { + *(pnt_array)++ = *(i_points)++; + } + + DCStoreRangeNoSync(mPoints, sizeof(cXyz) * 8); + mColor = i_color; +} + +void drawCube(MtxP mtx, cXyz* pos, const GXColor& color) { + GXSetArray(GX_VA_POS, pos, sizeof(cXyz)); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX8); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, + GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, color); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_BACK); + GXSetClipMode(GX_CLIP_ENABLE); + GXLoadPosMtxImm(mtx, 0); + GXSetCurrentMtx(0); + + GXBegin(GX_TRIANGLESTRIP, GX_VTXFMT0, 14); + GXPosition1x8(4); + GXPosition1x8(6); + GXPosition1x8(5); + GXPosition1x8(7); + GXPosition1x8(3); + GXPosition1x8(6); + GXPosition1x8(2); + GXPosition1x8(4); + GXPosition1x8(0); + GXPosition1x8(5); + GXPosition1x8(1); + GXPosition1x8(3); + GXPosition1x8(0); + GXPosition1x8(2); + GXEnd(); +} + +void mDoExt_cube8pPacket::draw() { + drawCube(j3dSys.getViewMtx(), mPoints, mColor); +} + +mDoExt_cubePacket::mDoExt_cubePacket(cXyz& i_position, cXyz& i_size, csXyz& i_angle, const GXColor& i_color) { + mPosition = i_position; + mSize = i_size; + mAngle = i_angle; + mColor = i_color; +} + +void mDoExt_cubePacket::draw() { + static cXyz l_pos[8] = { + cXyz(-1.0f, 1.0f, -1.0f), cXyz(1.0f, 1.0f, -1.0f), cXyz(-1.0f, 1.0f, 1.0f), + cXyz(1.0f, 1.0f, 1.0f), cXyz(-1.0f, -1.0f, -1.0f), cXyz(1.0f, -1.0f, -1.0f), + cXyz(-1.0f, -1.0f, 1.0f), cXyz(1.0f, -1.0f, 1.0f), + }; + + mDoMtx_stack_c::transS(mPosition.x, mPosition.y, mPosition.z); + mDoMtx_stack_c::XYZrotM(mAngle.x, mAngle.y, mAngle.z); + mDoMtx_stack_c::scaleM(mSize.x, mSize.y, mSize.z); + mDoMtx_stack_c::revConcat(j3dSys.getViewMtx()); + drawCube(mDoMtx_stack_c::get(), l_pos, mColor); +} + +mDoExt_quadPacket::mDoExt_quadPacket(cXyz* i_points, const GXColor& i_color, u8 i_clipZ) { + cXyz* pnt_array = mPoints; + + for (int i = 0; i < 4; i++) { + *(pnt_array)++ = *(i_points)++; + } + + DCStoreRangeNoSync(mPoints, sizeof(cXyz) * 4); + mColor = i_color; + mClipZ = i_clipZ; +} + +void mDoExt_quadPacket::draw() { + GXSetArray(GX_VA_POS, mPoints, sizeof(cXyz)); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX8); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, + GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_BACK); + GXSetClipMode(GX_CLIP_ENABLE); + GXLoadPosMtxImm(j3dSys.getViewMtx(), 0); + GXSetCurrentMtx(0); + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + GXPosition1x8(0); + GXPosition1x8(1); + GXPosition1x8(2); + GXPosition1x8(3); + GXEnd(); +} + +mDoExt_trianglePacket::mDoExt_trianglePacket(cXyz* i_points, const GXColor& i_color, u8 i_clipZ) { + cXyz* pnt_array = mPoints; + + for (int i = 0; i < 3; i++) { + *(pnt_array)++ = *(i_points)++; + } + + DCStoreRangeNoSync(mPoints, sizeof(cXyz) * 3); + mColor = i_color; + mClipZ = i_clipZ; +} + +void mDoExt_trianglePacket::draw() { + j3dSys.reinitGX(); + + GXSetArray(GX_VA_POS, mPoints, sizeof(cXyz)); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_INDEX8); + GXLoadPosMtxImm(j3dSys.getViewMtx(), 0); + GXSetCurrentMtx(0); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetZCompLoc(GX_ENABLE); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, g_clearColor); + GXSetFogRangeAdj(GX_DISABLE, 0, NULL); + GXSetCullMode(GX_CULL_NONE); + GXSetDither(GX_ENABLE); + GXSetClipMode(GX_CLIP_ENABLE); + GXSetNumIndStages(0); + + GXBegin(GX_TRIANGLES, GX_VTXFMT0, 3); + GXPosition1x8(0); + GXPosition1x8(1); + GXPosition1x8(2); + GXEnd(); + + J3DShape::resetVcdVatCache(); +} + +mDoExt_linePacket::mDoExt_linePacket(cXyz& i_start, cXyz& i_end, const GXColor& i_color, u8 i_clipZ, u8 i_width) { + mStart = i_start; + mEnd = i_end; + mColor = i_color; + mClipZ = i_clipZ; + mWidth = i_width; +} + +void mDoExt_linePacket::draw() { + j3dSys.reinitGX(); + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXLoadPosMtxImm(j3dSys.getViewMtx(), 0); + GXSetCurrentMtx(0); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetZCompLoc(GX_ENABLE); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, g_clearColor); + GXSetFogRangeAdj(GX_DISABLE, 0, NULL); + GXSetCullMode(GX_CULL_NONE); + GXSetDither(GX_ENABLE); + GXSetClipMode(GX_CLIP_ENABLE); + GXSetNumIndStages(0); + GXSetLineWidth(mWidth, GX_TO_ZERO); + + GXBegin(GX_LINES, GX_VTXFMT0, 2); + GXPosition3f32(mStart.x, mStart.y, mStart.z); + GXPosition3f32(mEnd.x, mEnd.y, mEnd.z); + GXEnd(); + + J3DShape::resetVcdVatCache(); +} + +mDoExt_ArrowPacket::mDoExt_ArrowPacket(cXyz& i_position, cXyz& param_1, const GXColor& i_color, u8 i_clipZ, u8 i_lineWidth) { + mStart = i_position; + mEnd = param_1; + mColor = i_color; + mClipZ = i_clipZ; + mLineWidth = i_lineWidth; +} + +void mDoExt_ArrowPacket::draw() { + Mtx sp28; + cXyz sp18; + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_NONE); + GXSetClipMode(GX_CLIP_ENABLE); + GXSetLineWidth(mLineWidth, GX_TO_ZERO); + + sp18 = mEnd - mStart; + MtxTrans(mStart.x, mStart.y, mStart.z, 0); + cMtx_YrotM(*calc_mtx, sp18.atan2sX_Z()); + cMtx_XrotM(*calc_mtx, cM_atan2s(JMAFastSqrt(SQUARE(sp18.x) + SQUARE(sp18.z)), sp18.y)); + cMtx_concat(j3dSys.getViewMtx(), *calc_mtx, sp28); + + GXLoadPosMtxImm(sp28, 0); + GXSetCurrentMtx(0); + + GXBegin(GX_LINES, GX_VTXFMT0, 2); + GXPosition3f32(0.0f, 0.0f, 0.0f); + GXPosition3f32(0.0f, sp18.abs(), 0.0f); + GXEnd(); + + f32 var_f29 = sp18.abs(); + f32 var_f31 = var_f29 * 0.1f; + f32 var_f30 = var_f29 * 0.8f; + + GXBegin(GX_TRIANGLEFAN, GX_VTXFMT0, 6); + GXPosition3f32(0.0f, var_f29, 0.0f); + GXPosition3f32(0.0f, var_f30, var_f31); + GXPosition3f32(var_f31, var_f30, 0.0f); + GXPosition3f32(0.0f, var_f30, -var_f31); + GXPosition3f32(-var_f31, var_f30, 0.0f); + GXPosition3f32(0.0f, var_f30, var_f31); + GXEnd(); +} + +mDoExt_pointPacket::mDoExt_pointPacket(cXyz& i_position, const GXColor& i_color, u8 i_clipZ, u8 i_lineWidth) { + mPosition = i_position; + mColor = i_color; + mClipZ = i_clipZ; + mLineWidth = i_lineWidth; +} + +void mDoExt_pointPacket::draw() { + j3dSys.reinitGX(); + + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_NONE); + GXSetClipMode(GX_CLIP_ENABLE); + GXSetPointSize(mLineWidth, GX_TO_ZERO); + + GXLoadPosMtxImm(j3dSys.getViewMtx(), 0); + GXSetCurrentMtx(0); + + GXBegin(GX_POINTS, GX_VTXFMT0, 1); + GXPosition3f32(mPosition.x, mPosition.y, mPosition.z); + GXEnd(); + + j3dSys.reinitGX(); + J3DShape::resetVcdVatCache(); +} + +mDoExt_circlePacket::mDoExt_circlePacket(cXyz& i_position, f32 i_radius, const GXColor& i_color, u8 i_clipZ, u8 i_lineWidth) { + mPosition = i_position; + mRadius = i_radius; + mColor = i_color; + mClipZ = i_clipZ; + mLineWidth = i_lineWidth; +} + +void mDoExt_circlePacket::draw() { + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_ZERO, GX_CC_ZERO, GX_CC_C0); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_NONE); + GXSetClipMode(GX_CLIP_ENABLE); + GXSetLineWidth(mLineWidth, GX_TO_ZERO); + GXLoadPosMtxImm(j3dSys.getViewMtx(), 0); + GXSetCurrentMtx(0); + + cXyz sp38; + cXyz sp44; + int numEdges = 36; + sp38.y = sp44.y = mPosition.y; + + GXBegin(GX_LINES, GX_VTXFMT0, numEdges * 2); + for (int i = 0; i < numEdges; i++) { + sp38.x = cM_fcos((i * 6.2831855f) / numEdges) * mRadius; + sp38.z = cM_fsin((i * 6.2831855f) / numEdges) * mRadius; + + sp44.x = cM_fcos(((i + 1) * 6.2831855f) / numEdges) * mRadius; + sp44.z = cM_fsin(((i + 1) * 6.2831855f) / numEdges) * mRadius; + + sp38.x += mPosition.x; + sp38.z += mPosition.z; + sp44.x += mPosition.x; + sp44.z += mPosition.z; + GXPosition3f32(sp38.x, sp38.y, sp38.z); + GXPosition3f32(sp44.x, sp44.y, sp44.z); + } + GXEnd(); +} + +mDoExt_spherePacket::mDoExt_spherePacket(cXyz& i_position, f32 i_size, const GXColor& i_color, u8 i_clipZ) { + mPosition = i_position; + mSize = i_size; + mColor = i_color; + mClipZ = i_clipZ; +} + +void mDoExt_spherePacket::draw() { + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_C0, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_BACK); + GXSetClipMode(GX_CLIP_ENABLE); + + mDoMtx_stack_c::copy(j3dSys.getViewMtx()); + mDoMtx_stack_c::transM(mPosition.x, mPosition.y, mPosition.z); + mDoMtx_stack_c::scaleM(mSize, mSize, mSize); + + GXLoadPosMtxImm(mDoMtx_stack_c::get(), 0); + mDoMtx_stack_c::inverseTranspose(); + + GXLoadNrmMtxImm(mDoMtx_stack_c::get(), 0); + GXSetCurrentMtx(0); + + GXDrawSphere(8, 8); +} + +mDoExt_cylinderPacket::mDoExt_cylinderPacket(cXyz& i_position, f32 i_radius, f32 i_height, const GXColor& i_color, u8 i_clipZ) { + mPosition = i_position; + mRadius = i_radius; + mHeight = i_height; + mColor = i_color; + mClipZ = i_clipZ; +} + +void mDoExt_cylinderPacket::draw() { + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, 1, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_C0, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_TRUE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_BACK); + GXSetClipMode(GX_CLIP_ENABLE); + + f32 var_f31 = mHeight * 0.5f; + + mDoMtx_stack_c::copy(j3dSys.getViewMtx()); + mDoMtx_stack_c::transM(mPosition.x, mPosition.y + var_f31, mPosition.z); + mDoMtx_stack_c::scaleM(mRadius, var_f31, mRadius); + mDoMtx_stack_c::XrotM(0x4000); + + GXLoadPosMtxImm(mDoMtx_stack_c::get(), 0); + mDoMtx_stack_c::inverseTranspose(); + + GXLoadNrmMtxImm(mDoMtx_stack_c::get(), 0); + GXSetCurrentMtx(0); + GXDrawCylinder(8); +} + +mDoExt_cylinderMPacket::mDoExt_cylinderMPacket(Mtx i_mtx, const GXColor& i_color, u8 i_clipZ) { + cMtx_copy(i_mtx, mMatrix); + mColor = i_color; + mClipZ = i_clipZ; +} + +void mDoExt_cylinderMPacket::draw() { + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0, GX_ENABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT0, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(0); + GXSetNumTevStages(1); + GXSetTevColor(GX_TEVREG0, mColor); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevColorIn(GX_TEVSTAGE0, GX_CC_ZERO, GX_CC_RASC, GX_CC_C0, GX_CC_ZERO); + GXSetTevColorOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_A0); + GXSetTevAlphaOp(GX_TEVSTAGE0, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, GX_ENABLE, GX_TEVPREV); + + if (mClipZ) { + GXSetZMode(GX_ENABLE, GX_LEQUAL, GX_ENABLE); + } else { + GXSetZMode(GX_DISABLE, GX_LEQUAL, GX_DISABLE); + } + + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_OR, GX_ALWAYS, 0); + GXSetCullMode(GX_CULL_BACK); + GXSetClipMode(GX_CLIP_ENABLE); + + cMtx_concat(j3dSys.getViewMtx(), mMatrix, mMatrix); + + GXLoadPosMtxImm(mMatrix, 0); + cMtx_inverseTranspose(mMatrix, mMatrix); + + GXLoadNrmMtxImm(mMatrix, 0); + GXSetCurrentMtx(0); + + GXDrawCylinder(8); +} diff --git a/src/dusk/mtx.cpp b/src/dusk/mtx.cpp new file mode 100644 index 0000000000..19016ec781 --- /dev/null +++ b/src/dusk/mtx.cpp @@ -0,0 +1,730 @@ +// This should go into aurora, but for now we'll place it here: +#include +#include +#include + +#define ASSERTLINE(line, cond) (void)0 +#define ASSERTMSGLINE(line, cond, msg) (void)0 +#define ASSERTMSG1LINE(line, cond, msg, arg1) (void)0 +#define ASSERTMSG2LINE(line, cond, msg, arg1, arg2) (void)0 +#define ASSERTMSGLINEV(line, cond, ...) (void)0 + +// SNIP : after here, place it into aurora + +void C_MTXLightOrtho(Mtx m, f32 t, f32 b, f32 l, f32 r, f32 scaleS, f32 scaleT, f32 transS, f32 transT) { + f32 tmp; + + ASSERTMSGLINE(2672, m, "MTXLightOrtho(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(2673, (t != b), "MTXLightOrtho(): 't' and 'b' clipping planes are equal "); + ASSERTMSGLINE(2674, (l != r), "MTXLightOrtho(): 'l' and 'r' clipping planes are equal "); + tmp = 1 / (r - l); + m[0][0] = (2 * tmp * scaleS); + m[0][1] = 0; + m[0][2] = 0; + m[0][3] = (transS + (scaleS * (tmp * -(r + l)))); + tmp = 1/ (t - b); + m[1][0] = 0; + m[1][1] = (2 * tmp * scaleT); + m[1][2] = 0; + m[1][3] = (transT + (scaleT * (tmp * -(t + b)))); + m[2][0] = 0; + m[2][1] = 0; + m[2][2] = 0; + m[2][3] = 1; +} + +void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, f32 scaleS, f32 scaleT, f32 transS, f32 transT) { + f32 angle; + f32 cot; + + ASSERTMSGLINE(2604, m, "MTXLightPerspective(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(2605, (fovY > 0.0) && (fovY < 180.0), "MTXLightPerspective(): 'fovY' out of range "); + ASSERTMSGLINE(2606, 0 != aspect, "MTXLightPerspective(): 'aspect' is 0 "); + + angle = (0.5f * fovY); + angle = MTXDegToRad(angle); + cot = 1 / tanf(angle); + m[0][0] = (scaleS * (cot / aspect)); + m[0][1] = 0; + m[0][2] = -transS; + m[0][3] = 0; + m[1][0] = 0; + m[1][1] = (cot * scaleT); + m[1][2] = -transT; + m[1][3] = 0; + m[2][0] = 0; + m[2][1] = 0; + m[2][2] = -1; + m[2][3] = 0; +} + +void C_MTXLookAt(Mtx m, const Point3d* camPos, const Vec* camUp, const Point3d* target) { + Vec vLook; + Vec vRight; + Vec vUp; + + ASSERTMSGLINE(2437, m, "MTXLookAt(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(2438, camPos, "MTXLookAt(): NULL VecPtr 'camPos' "); + ASSERTMSGLINE(2439, camUp, "MTXLookAt(): NULL VecPtr 'camUp' "); + ASSERTMSGLINE(2440, target, "MTXLookAt(): NULL Point3dPtr 'target' "); + + vLook.x = camPos->x - target->x; + vLook.y = camPos->y - target->y; + vLook.z = camPos->z - target->z; + VECNormalize(&vLook, &vLook); + VECCrossProduct(camUp, &vLook, &vRight); + VECNormalize(&vRight, &vRight); + VECCrossProduct(&vLook, &vRight, &vUp); + m[0][0] = vRight.x; + m[0][1] = vRight.y; + m[0][2] = vRight.z; + m[0][3] = -((camPos->z * vRight.z) + ((camPos->x * vRight.x) + (camPos->y * vRight.y))); + m[1][0] = vUp.x; + m[1][1] = vUp.y; + m[1][2] = vUp.z; + m[1][3] = -((camPos->z * vUp.z) + ((camPos->x * vUp.x) + (camPos->y * vUp.y))); + m[2][0] = vLook.x; + m[2][1] = vLook.y; + m[2][2] = vLook.z; + m[2][3] = -((camPos->z * vLook.z) + ((camPos->x * vLook.x) + (camPos->y * vLook.y))); +} + +void C_MTXPerspective(Mtx44 m, f32 fovY, f32 aspect, f32 n, f32 f) { + f32 angle; + f32 cot; + f32 tmp; + + ASSERTMSGLINE(179, m, "MTXPerspective(): NULL Mtx44Ptr 'm' "); + ASSERTMSGLINE(180, (fovY > 0.0) && (fovY < 180.0), "MTXPerspective(): 'fovY' out of range "); + ASSERTMSGLINE(181, 0.0f != aspect, "MTXPerspective(): 'aspect' is 0 "); + + angle = (0.5f * fovY); + angle = MTXDegToRad(angle); + cot = 1 / tanf(angle); + m[0][0] = (cot / aspect); + m[0][1] = 0; + m[0][2] = 0; + m[0][3] = 0; + m[1][0] = 0; + m[1][1] = (cot); + m[1][2] = 0; + m[1][3] = 0; + m[2][0] = 0; + m[2][1] = 0; + tmp = 1 / (f - n); + m[2][2] = (-n * tmp); + m[2][3] = (tmp * -(f * n)); + m[3][0] = 0; + m[3][1] = 0; + m[3][2] = -1; + m[3][3] = 0; +} + +void C_MTXRotRad(Mtx m, char axis, f32 rad) { + f32 sinA; + f32 cosA; + + ASSERTMSGLINE(1447, m, "MTXRotRad(): NULL MtxPtr 'm' "); + sinA = sinf(rad); + cosA = cosf(rad); + C_MTXRotTrig(m, axis, sinA, cosA); +} + +void C_MTXScale(Mtx m, f32 xS, f32 yS, f32 zS) { + ASSERTMSGLINE(2008, m, "MTXScale(): NULL MtxPtr 'm' "); + m[0][0] = xS; + m[0][1] = 0; + m[0][2] = 0; + m[0][3] = 0; + m[1][0] = 0; + m[1][1] = yS; + m[1][2] = 0; + m[1][3] = 0; + m[2][0] = 0; + m[2][1] = 0; + m[2][2] = zS; + m[2][3] = 0; +} + +void C_MTXScaleApply(const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS) { + ASSERTMSGLINE(2070, src, "MTXScaleApply(): NULL MtxPtr 'src' "); + ASSERTMSGLINE(2071, dst, "MTXScaleApply(): NULL MtxPtr 'dst' "); + dst[0][0] = (src[0][0] * xS); + dst[0][1] = (src[0][1] * xS); + dst[0][2] = (src[0][2] * xS); + dst[0][3] = (src[0][3] * xS); + dst[1][0] = (src[1][0] * yS); + dst[1][1] = (src[1][1] * yS); + dst[1][2] = (src[1][2] * yS); + dst[1][3] = (src[1][3] * yS); + dst[2][0] = (src[2][0] * zS); + dst[2][1] = (src[2][1] * zS); + dst[2][2] = (src[2][2] * zS); + dst[2][3] = (src[2][3] * zS); +} + +void C_MTXTransApply(const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT) { + ASSERTMSGLINE(1933, src, "MTXTransApply(): NULL MtxPtr 'src' "); + ASSERTMSGLINE(1934, dst, "MTXTransApply(): NULL MtxPtr 'src' "); //! wrong assert string + + if (src != dst) { + dst[0][0] = src[0][0]; + dst[0][1] = src[0][1]; + dst[0][2] = src[0][2]; + dst[1][0] = src[1][0]; + dst[1][1] = src[1][1]; + dst[1][2] = src[1][2]; + dst[2][0] = src[2][0]; + dst[2][1] = src[2][1]; + dst[2][2] = src[2][2]; + } + + dst[0][3] = (src[0][3] + xT); + dst[1][3] = (src[1][3] + yT); + dst[2][3] = (src[2][3] + zT); +} + +void C_MTXRotTrig(Mtx m, char axis, f32 sinA, f32 cosA) { + ASSERTMSGLINE(1502, m, "MTXRotTrig(): NULL MtxPtr 'm' "); + switch(axis) { + case 'x': + case 'X': + m[0][0] = 1; + m[0][1] = 0; + m[0][2] = 0; + m[0][3] = 0; + m[1][0] = 0; + m[1][1] = cosA; + m[1][2] = -sinA; + m[1][3] = 0; + m[2][0] = 0; + m[2][1] = sinA; + m[2][2] = cosA; + m[2][3] = 0; + break; + case 'y': + case 'Y': + m[0][0] = cosA; + m[0][1] = 0; + m[0][2] = sinA; + m[0][3] = 0; + m[1][0] = 0; + m[1][1] = 1; + m[1][2] = 0; + m[1][3] = 0; + m[2][0] = -sinA; + m[2][1] = 0; + m[2][2] = cosA; + m[2][3] = 0; + break; + case 'z': + case 'Z': + m[0][0] = cosA; + m[0][1] = -sinA; + m[0][2] = 0; + m[0][3] = 0; + m[1][0] = sinA; + m[1][1] = cosA; + m[1][2] = 0; + m[1][3] = 0; + m[2][0] = 0; + m[2][1] = 0; + m[2][2] = 1; + m[2][3] = 0; + break; + default: + ASSERTMSGLINE(1529, FALSE, "MTXRotTrig(): invalid 'axis' value "); + break; + } +} + +void C_VECAdd(const Vec* a, const Vec* b, Vec* ab) { + ASSERTMSGLINE(114, a, "VECAdd(): NULL VecPtr 'a' "); + ASSERTMSGLINE(115, b, "VECAdd(): NULL VecPtr 'b' "); + ASSERTMSGLINE(116, ab, "VECAdd(): NULL VecPtr 'ab' "); + ab->x = a->x + b->x; + ab->y = a->y + b->y; + ab->z = a->z + b->z; +} + +// MTX QUAT + +void C_QUATMultiply(const Quaternion* p, const Quaternion* q, Quaternion* pq) { + Quaternion* r; + Quaternion pqTmp; + + ASSERTMSGLINE(193, p, "QUATMultiply(): NULL QuaternionPtr 'p' "); + ASSERTMSGLINE(194, q, "QUATMultiply(): NULL QuaternionPtr 'q' "); + ASSERTMSGLINE(195, pq, "QUATMultiply(): NULL QuaternionPtr 'pq' "); + + if (p == pq || q == pq){ + r = &pqTmp; + } else { + r = pq; + } + + r->w = (p->w * q->w) - (p->x * q->x) - (p->y * q->y) - (p->z * q->z); + r->x = (p->w * q->x) + (p->x * q->w) + (p->y * q->z) - (p->z * q->y); + r->y = (p->w * q->y) + (p->y * q->w) + (p->z * q->x) - (p->x * q->z); + r->z = (p->w * q->z) + (p->z * q->w) + (p->x * q->y) - (p->y * q->x); + + if (r == &pqTmp) { + *pq = pqTmp; + } +} + +void C_QUATRotAxisRad(Quaternion* r, const Vec* axis, f32 rad) { + f32 half, sh, ch; + Vec nAxis; + + ASSERTMSGLINE(758, r, "QUATRotAxisRad(): NULL QuaternionPtr 'r' "); + ASSERTMSGLINE(759, axis, "QUATRotAxisRad(): NULL VecPtr 'axis' "); + + VECNormalize(axis, &nAxis); + + half = rad * 0.5f; + sh = sinf(half); + ch = cosf(half); + + r->x = sh * nAxis.x; + r->y = sh * nAxis.y; + r->z = sh * nAxis.z; + r->w = ch; +} + +void C_QUATSlerp(const Quaternion* p, const Quaternion* q, Quaternion* r, f32 t) { + f32 theta, sin_th, cos_th; + f32 tp, tq; + + ASSERTMSGLINE(869, p, "QUATSlerp(): NULL QuaternionPtr 'p' "); + ASSERTMSGLINE(870, q, "QUATSlerp(): NULL QuaternionPtr 'q' "); + ASSERTMSGLINE(871, r, "QUATSlerp(): NULL QuaternionPtr 'r' "); + + cos_th = p->x * q->x + p->y * q->y + p->z * q->z + p->w * q->w; + tq = 1.0f; + + if (cos_th < 0.0f) { + cos_th = -cos_th; + tq = -tq; + } + + if (cos_th <= 0.99999f) { + theta = acosf(cos_th); + sin_th = sinf(theta); + + tp = sinf((1.0f - t) * theta) / sin_th; + tq *= sinf(t * theta) / sin_th; + } else { + tp = 1.0f - t; + tq *= t; + } + + r->x = (tp * p->x) + (tq * q->x); + r->y = (tp * p->y) + (tq * q->y); + r->z = (tp * p->z) + (tq * q->z); + r->w = (tp * p->w) + (tq * q->w); +} + +void C_VECHalfAngle(const Vec* a, const Vec* b, Vec* half) { + Vec aTmp; + Vec bTmp; + Vec hTmp; + + ASSERTMSGLINE(713, a, "VECHalfAngle(): NULL VecPtr 'a' "); + ASSERTMSGLINE(714, b, "VECHalfAngle(): NULL VecPtr 'b' "); + ASSERTMSGLINE(715, half, "VECHalfAngle(): NULL VecPtr 'half' "); + + aTmp.x = -a->x; + aTmp.y = -a->y; + aTmp.z = -a->z; + bTmp.x = -b->x; + bTmp.y = -b->y; + bTmp.z = -b->z; + + VECNormalize(&aTmp, &aTmp); + VECNormalize(&bTmp, &bTmp); + VECAdd(&aTmp, &bTmp, &hTmp); + + if (VECDotProduct(&hTmp, &hTmp) > 0.0f) { + VECNormalize(&hTmp, half); + return; + } + *half = hTmp; +} + +void C_VECNormalize(const Vec* src, Vec* unit) { + f32 mag; + + ASSERTMSGLINE(321, src, "VECNormalize(): NULL VecPtr 'src' "); + ASSERTMSGLINE(322, unit, "VECNormalize(): NULL VecPtr 'unit' "); + + mag = (src->z * src->z) + ((src->x * src->x) + (src->y * src->y)); + ASSERTMSGLINE(327, 0.0f != mag, "VECNormalize(): zero magnitude vector "); + + mag = 1.0f/ sqrtf(mag); + unit->x = src->x * mag; + unit->y = src->y * mag; + unit->z = src->z * mag; +} + +void C_VECReflect(const Vec* src, const Vec* normal, Vec* dst) { + f32 cosA; + Vec uI; + Vec uN; + + ASSERTMSGLINE(769, src, "VECReflect(): NULL VecPtr 'src' "); + ASSERTMSGLINE(770, normal, "VECReflect(): NULL VecPtr 'normal' "); + ASSERTMSGLINE(771, dst, "VECReflect(): NULL VecPtr 'dst' "); + + uI.x = -src->x; + uI.y = -src->y; + uI.z = -src->z; + + VECNormalize(&uI, &uI); + VECNormalize(normal, &uN); + + cosA = VECDotProduct(&uI, &uN); + dst->x = (2.0f * uN.x * cosA) - uI.x; + dst->y = (2.0f * uN.y * cosA) - uI.y; + dst->z = (2.0f * uN.z * cosA) - uI.z; + VECNormalize(dst, dst); +} + +u32 C_MTXInverse(const Mtx src, Mtx inv) { + Mtx mTmp; + MtxPtr m; + f32 det; + + ASSERTMSGLINE(950, src, "MTXInverse(): NULL MtxPtr 'src' "); + ASSERTMSGLINE(951, inv, "MTXInverse(): NULL MtxPtr 'inv' "); + + if (src == inv) { + m = mTmp; + } else { + m = inv; + } + det = ((((src[2][1] * (src[0][2] * src[1][0])) + + ((src[2][2] * (src[0][0] * src[1][1])) + + (src[2][0] * (src[0][1] * src[1][2])))) + - (src[0][2] * (src[2][0] * src[1][1]))) + - (src[2][2] * (src[1][0] * src[0][1]))) + - (src[1][2] * (src[0][0] * src[2][1])); + if (0 == det) { + return 0; + } + det = 1 / det; + m[0][0] = (det * +((src[1][1] * src[2][2]) - (src[2][1] * src[1][2]))); + m[0][1] = (det * -((src[0][1] * src[2][2]) - (src[2][1] * src[0][2]))); + m[0][2] = (det * +((src[0][1] * src[1][2]) - (src[1][1] * src[0][2]))); + + m[1][0] = (det * -((src[1][0] * src[2][2]) - (src[2][0] * src[1][2]))); + m[1][1] = (det * +((src[0][0] * src[2][2]) - (src[2][0] * src[0][2]))); + m[1][2] = (det * -((src[0][0] * src[1][2]) - (src[1][0] * src[0][2]))); + + m[2][0] = (det * +((src[1][0] * src[2][1]) - (src[2][0] * src[1][1]))); + m[2][1] = (det * -((src[0][0] * src[2][1]) - (src[2][0] * src[0][1]))); + m[2][2] = (det * +((src[0][0] * src[1][1]) - (src[1][0] * src[0][1]))); + + m[0][3] = ((-m[0][0] * src[0][3]) - (m[0][1] * src[1][3])) - (m[0][2] * src[2][3]); + m[1][3] = ((-m[1][0] * src[0][3]) - (m[1][1] * src[1][3])) - (m[1][2] * src[2][3]); + m[2][3] = ((-m[2][0] * src[0][3]) - (m[2][1] * src[1][3])) - (m[2][2] * src[2][3]); + + if (m == mTmp) { + C_MTXCopy(mTmp, inv); + } + return 1; +} + +void C_MTXConcatArray(const Mtx a, const Mtx* srcBase, Mtx* dstBase, u32 count) { + u32 i; + + ASSERTMSGLINE(580, a != 0, "MTXConcatArray(): NULL MtxPtr 'a' "); + ASSERTMSGLINE(581, srcBase != 0, "MTXConcatArray(): NULL MtxPtr 'srcBase' "); + ASSERTMSGLINE(582, dstBase != 0, "MTXConcatArray(): NULL MtxPtr 'dstBase' "); + ASSERTMSGLINE(583, count > 1, "MTXConcatArray(): count must be greater than 1."); + + for (i = 0; i < count; i++) { + C_MTXConcat(a, *srcBase, *dstBase); + srcBase++; + dstBase++; + } +} + +void C_MTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) { + u32 i; + Vec vTmp; + + ASSERTMSGLINE(168, m, "MTXMultVecArray(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(169, srcBase, "MTXMultVecArray(): NULL VecPtr 'srcBase' "); + ASSERTMSGLINE(170, dstBase, "MTXMultVecArray(): NULL VecPtr 'dstBase' "); + ASSERTMSGLINE(171, count > 1, "MTXMultVecArray(): count must be greater than 1."); + + for(i = 0; i < count; i++) { + vTmp.x = m[0][3] + ((m[0][2] * srcBase->z) + ((m[0][0] * srcBase->x) + (m[0][1] * srcBase->y))); + vTmp.y = m[1][3] + ((m[1][2] * srcBase->z) + ((m[1][0] * srcBase->x) + (m[1][1] * srcBase->y))); + vTmp.z = m[2][3] + ((m[2][2] * srcBase->z) + ((m[2][0] * srcBase->x) + (m[2][1] * srcBase->y))); + dstBase->x = vTmp.x; + dstBase->y = vTmp.y; + dstBase->z = vTmp.z; + srcBase++; + dstBase++; + } +} + +void C_MTXMultVecArraySR(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) { + u32 i; + Vec vTmp; + + ASSERTMSGLINE(410, m, "MTXMultVecArraySR(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(411, srcBase, "MTXMultVecArraySR(): NULL VecPtr 'srcBase' "); + ASSERTMSGLINE(412, dstBase, "MTXMultVecArraySR(): NULL VecPtr 'dstBase' "); + ASSERTMSGLINE(413, count > 1, "MTXMultVecArraySR(): count must be greater than 1."); + + for(i = 0; i < count; i++) { + vTmp.x = (m[0][2] * srcBase->z) + ((m[0][0] * srcBase->x) + (m[0][1] * srcBase->y)); + vTmp.y = (m[1][2] * srcBase->z) + ((m[1][0] * srcBase->x) + (m[1][1] * srcBase->y)); + vTmp.z = (m[2][2] * srcBase->z) + ((m[2][0] * srcBase->x) + (m[2][1] * srcBase->y)); + dstBase->x = vTmp.x; + dstBase->y = vTmp.y; + dstBase->z = vTmp.z; + srcBase++; + dstBase++; + } +} + +void C_MTXQuat(Mtx m, const Quaternion* q) { + f32 s; + f32 xs; + f32 ys; + f32 zs; + f32 wx; + f32 wy; + f32 wz; + f32 xx; + f32 xy; + f32 xz; + f32 yy; + f32 yz; + f32 zz; + + ASSERTMSGLINE(2145, m, "MTXQuat(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(2146, q, "MTXQuat(): NULL QuaternionPtr 'q' "); + ASSERTMSGLINE(2147, q->x || q->y || q->z || q->w, "MTXQuat(): zero-value quaternion "); + s = 2 / ((q->w * q->w) + ((q->z * q->z) + ((q->x * q->x) + (q->y * q->y)))); + xs = q->x * s; + ys = q->y * s; + zs = q->z * s; + wx = q->w * xs; + wy = q->w * ys; + wz = q->w * zs; + xx = q->x * xs; + xy = q->x * ys; + xz = q->x * zs; + yy = q->y * ys; + yz = q->y * zs; + zz = q->z * zs; + m[0][0] = (1 - (yy + zz)); + m[0][1] = (xy - wz); + m[0][2] = (xz + wy); + m[0][3] = 0; + m[1][0] = (xy + wz); + m[1][1] = (1 - (xx + zz)); + m[1][2] = (yz - wx); + m[1][3] = 0; + m[2][0] = (xz - wy); + m[2][1] = (yz + wx); + m[2][2] = (1 - (xx + yy)); + m[2][3] = 0; +} +void C_MTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) { + Vec vN; + f32 s; + f32 c; + f32 t; + f32 x; + f32 y; + f32 z; + f32 xSq; + f32 ySq; + f32 zSq; + + ASSERTMSGLINE(1677, m, "MTXRotAxisRad(): NULL MtxPtr 'm' "); + ASSERTMSGLINE(1678, axis, "MTXRotAxisRad(): NULL VecPtr 'axis' "); + + s = sinf(rad); + c = cosf(rad); + t = 1 - c; + C_VECNormalize(axis, &vN); + x = vN.x; + y = vN.y; + z = vN.z; + xSq = (x * x); + ySq = (y * y); + zSq = (z * z); + m[0][0] = (c + (t * xSq)); + m[0][1] = (y * (t * x)) - (s * z); + m[0][2] = (z * (t * x)) + (s * y); + m[0][3] = 0; + m[1][0] = ((y * (t * x)) + (s * z)); + m[1][1] = (c + (t * ySq)); + m[1][2] = ((z * (t * y)) - (s * x)); + m[1][3] = 0; + m[2][0] = ((z * (t * x)) - (s * y)); + m[2][1] = ((z * (t * y)) + (s * x)); + m[2][2] = (c + (t * zSq)); + m[2][3] = 0; +} + +// VEC +void C_VECCrossProduct(const Vec* a, const Vec* b, Vec* axb) { + Vec vTmp; + + ASSERTMSGLINE(608, a, "VECCrossProduct(): NULL VecPtr 'a' "); + ASSERTMSGLINE(609, b, "VECCrossProduct(): NULL VecPtr 'b' "); + ASSERTMSGLINE(610, axb, "VECCrossProduct(): NULL VecPtr 'axb' "); + + vTmp.x = (a->y * b->z) - (a->z * b->y); + vTmp.y = (a->z * b->x) - (a->x * b->z); + vTmp.z = (a->x * b->y) - (a->y * b->x); + axb->x = vTmp.x; + axb->y = vTmp.y; + axb->z = vTmp.z; +} + +f32 C_VECDistance(const Vec* a, const Vec* b) { + return sqrtf(C_VECSquareDistance(a, b)); +} + +f32 C_VECDotProduct(const Vec* a, const Vec* b) { + f32 dot; + + ASSERTMSGLINE(546, a, "VECDotProduct(): NULL VecPtr 'a' "); + ASSERTMSGLINE(547, b, "VECDotProduct(): NULL VecPtr 'b' "); + dot = (a->z * b->z) + ((a->x * b->x) + (a->y * b->y)); + return dot; +} + +f32 C_VECMag(const Vec* v) { + return sqrtf(C_VECSquareMag(v)); +} + +void C_VECScale(const Vec* src, Vec* dst, f32 scale) { + ASSERTMSGLINE(253, src, "VECScale(): NULL VecPtr 'src' "); + ASSERTMSGLINE(254, dst, "VECScale(): NULL VecPtr 'dst' "); + dst->x = (src->x * scale); + dst->y = (src->y * scale); + dst->z = (src->z * scale); +} + +f32 C_VECSquareDistance(const Vec* a, const Vec* b) { + Vec diff; + + diff.x = a->x - b->x; + diff.y = a->y - b->y; + diff.z = a->z - b->z; + return (diff.z * diff.z) + ((diff.x * diff.x) + (diff.y * diff.y)); +} + +f32 C_VECSquareMag(const Vec* v) { + f32 sqmag; + + ASSERTMSGLINE(411, v, "VECMag(): NULL VecPtr 'v' "); + + sqmag = v->z * v->z + ((v->x * v->x) + (v->y * v->y)); + return sqmag; +} + +void C_VECSubtract(const Vec* a, const Vec* b, Vec* a_b) { + ASSERTMSGLINE(183, a, "VECSubtract(): NULL VecPtr 'a' "); + ASSERTMSGLINE(184, b, "VECSubtract(): NULL VecPtr 'b' "); + ASSERTMSGLINE(185, a_b, "VECSubtract(): NULL VecPtr 'a_b' "); + a_b->x = a->x - b->x; + a_b->y = a->y - b->y; + a_b->z = a->z - b->z; +} + +#pragma mark PSMTX +// I think these are PPC ASM implemntations? +// this can be done just with defining DEBUG, but that has some other +// implecations, so we'll just define them here for now. These are all just wrappers around the C versions, so we can just call those directly. +void PSMTXConcatArray(const __REGISTER Mtx a, const __REGISTER Mtx* srcBase, __REGISTER Mtx* dstBase, __REGISTER u32 count) { + C_MTXConcatArray(a, srcBase, dstBase, count); +} +void PSMTXCopy(const __REGISTER Mtx src, __REGISTER Mtx dst) { + C_MTXCopy(src, dst); +} +void PSMTXIdentity(__REGISTER Mtx m) { + C_MTXIdentity(m); +} +u32 PSMTXInverse(const __REGISTER Mtx src, __REGISTER Mtx inv) { + return C_MTXInverse(src, inv); +} +void PSMTXMultVec(const __REGISTER Mtx m, const __REGISTER Vec* src, __REGISTER Vec* dst) { + C_MTXMultVec(m, src, dst); +} +void PSMTXConcat(const __REGISTER Mtx a, const __REGISTER Mtx b, __REGISTER Mtx ab) { + C_MTXConcat(a, b, ab); +} +void PSMTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) { + C_MTXMultVecArray(m, srcBase, dstBase, count); +} +void PSMTXMultVecArraySR(const __REGISTER Mtx m, const __REGISTER Vec* srcBase, __REGISTER Vec* dstBase, __REGISTER u32 count) { + C_MTXMultVecArraySR(m, srcBase, dstBase, count); +} +void PSMTXMultVecSR(const __REGISTER Mtx m, const __REGISTER Vec* src, __REGISTER Vec* dst) { + C_MTXMultVecSR(m, src, dst); +} +void PSMTXQuat(__REGISTER Mtx m, const __REGISTER Quaternion* q) { + C_MTXQuat(m, q); +} +void PSMTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) { + C_MTXRotAxisRad(m, axis, rad); +} +void PSMTXRotRad(Mtx m, char axis, f32 rad) { + C_MTXRotRad(m, axis, rad); +} +void PSMTXScale(__REGISTER Mtx m, __REGISTER f32 xS, __REGISTER f32 yS, __REGISTER f32 zS) { + C_MTXScale(m, xS, yS, zS); +} +void PSMTXScaleApply(const __REGISTER Mtx src, __REGISTER Mtx dst, __REGISTER f32 xS, __REGISTER f32 yS, __REGISTER f32 zS) { + C_MTXScaleApply(src, dst, xS, yS, zS); +} +void PSMTXTrans(__REGISTER Mtx m, __REGISTER f32 xT, __REGISTER f32 yT, __REGISTER f32 zT) { + C_MTXTrans(m, xT, yT, zT); +} +void PSMTXTransApply(const __REGISTER Mtx src, __REGISTER Mtx dst, __REGISTER f32 xT, __REGISTER f32 yT, __REGISTER f32 zT) { + C_MTXTransApply(src, dst, xT, yT, zT); +} +void PSQUATMultiply(const __REGISTER Quaternion* p, const __REGISTER Quaternion* q, __REGISTER Quaternion* pq) { + C_QUATMultiply(p, q, pq); +} +void PSVECAdd(const __REGISTER Vec* a, const __REGISTER Vec* b, __REGISTER Vec* ab) { + C_VECAdd(a, b, ab); +} +void PSVECCrossProduct(const __REGISTER Vec* a, const __REGISTER Vec* b, __REGISTER Vec* axb) { + C_VECCrossProduct(a, b, axb); +} +f32 PSVECDistance(const __REGISTER Vec* a, const __REGISTER Vec* b) { + return C_VECDistance(a, b); +} +f32 PSVECDotProduct(const __REGISTER Vec* a, const __REGISTER Vec* b) { + return C_VECDotProduct(a, b); +} +f32 PSVECMag(const __REGISTER Vec* v) { + return C_VECMag(v); +} +void PSVECNormalize(const __REGISTER Vec* src, __REGISTER Vec* unit) { + C_VECNormalize(src, unit); +} +void PSVECScale(const __REGISTER Vec* src, __REGISTER Vec* dst, __REGISTER f32 scale) { + C_VECScale(src, dst, scale); +} +f32 PSVECSquareDistance(const __REGISTER Vec* a, const __REGISTER Vec* b) { + return C_VECSquareDistance(a, b); +} +f32 PSVECSquareMag(const __REGISTER Vec* v) { + return C_VECSquareMag(v); +} +void PSVECSubtract(const __REGISTER Vec* a, const __REGISTER Vec* b, __REGISTER Vec* a_b) { + C_VECSubtract(a, b, a_b); +} diff --git a/src/dusk/stubs.cpp b/src/dusk/stubs.cpp index ee466a699c..8590df30eb 100644 --- a/src/dusk/stubs.cpp +++ b/src/dusk/stubs.cpp @@ -1,52 +1,10 @@ -//#include -#include -#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include // Credits: Super Monkey Ball -static VIRetraceCallback sVIRetraceCallback = NULL; - void OSReport(const char *msg, ...) { va_list args; va_start(args, msg); @@ -58,6 +16,335 @@ u32 OSGetConsoleType() { return OS_CONSOLE_RETAIL1; } u32 OSGetSoundMode() { return 2; } +// Consolidated OS functions (moved from other sections) +void OSClearContext(OSContext *context) { puts("OSClearContext is a stub"); } + +void OSInit() { puts("OSInit is a stub"); } + +void OSInitMutex(OSMutex *mutex) { puts("OSInitMutex is a stub"); } + +void OSUnlockMutex(OSMutex *mutex) { puts("OSUnlockMutex is a stub"); } + +BOOL OSTryLockMutex(OSMutex *mutex) { + puts("OSTryLockMutex is a stub"); + return FALSE; +} + +void *OSAllocFromArenaLo(u32 size, u32 align) { + puts("OSAllocFromArenaLo is a stub"); + return NULL; +} + +BOOL OSDisableInterrupts() { + puts("OSDisableInterrupts is a stub"); + return FALSE; +} + +void OSSleepThread(OSThreadQueue *queue) { puts("OSSleepThread is a stub"); } + +void OSDumpContext(OSContext *context) { puts("OSDumpContext is a stub"); } + +void OSSignalCond(OSCond *cond) { puts("OSSignalCond is a stub"); } + +void OSCreateAlarm(OSAlarm *alarm) { puts("OSCreateAlarm is a stub"); } + +void OSCancelAlarm(OSAlarm *alarm) { puts("OSCancelAlarm is a stub"); } + +s32 OSCheckActiveThreads(void) { puts("OSCheckActiveThreads is a stub"); } + +int OSCreateThread(OSThread* thread, void* (*func)(void*), void* param, void* stack, u32 stackSize, OSPriority priority, u16 attr) { + puts("OSCreateThread is a stub"); + return 0; +} + +s32 OSDisableScheduler() { + puts("OSDisableScheduler is a stub"); + return 0; +} + +void OSDetachThread(OSThread* thread) { + puts("OSDetachThread is a stub"); +} + +OSThread *OSGetCurrentThread() { + puts("OSGetCurrentThread is a stub"); + return 0; +} + +u16 OSGetFontEncode() { + puts("OSGetFontEncode is a stub"); + return 0; +} + +char *OSGetFontTexture(char *string, void **image, s32 *x, s32 *y, s32 *width) { + puts("OSGetFontTexture is a stub"); + return 0; +} + +char *OSGetFontWidth(char *string, s32 *width) { + puts("OSGetFontWidth is a stub"); + return 0; +} + +BOOL OSGetResetButtonState() { + puts("OSGetResetButtonState is a stub"); + return FALSE; +} + +u32 OSGetStackPointer() { + puts("OSGetStackPointer is a stub"); + return 0; +} + +BOOL OSInitFont(OSFontHeader *fontData) { + puts("OSInitFont is a stub"); + return FALSE; +} + +BOOL OSLink(OSModuleInfo *newModule, void *bss) { + puts("OSLink is a stub"); + return TRUE; +} + +void OSLoadContext(OSContext *context) { puts("OSLoadContext is a stub"); } + +void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) { + puts("OSResetSystem is a stub"); +} + +BOOL OSRestoreInterrupts(BOOL level) { + puts("OSRestoreInterrupts is a stub"); + return FALSE; +} + +s32 OSResumeThread(OSThread *thread) { + puts("OSResumeThread is a stub"); + return 0; +} + +void OSSetCurrentContext(OSContext *context) { + puts("OSSetCurrentContext is a stub"); +} + +void OSSetStringTable(void* stringTable) { + puts("OSSetStringTable is a stub"); +} + +OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback) { + puts("OSSetSwitchThreadCallback is a stub"); + return NULL; +} + +int OSSetThreadPriority(OSThread* thread, s32 priority) { + puts("OSSetThreadPriority is a stub"); + return 0; +} + +void OSWaitCond(OSCond* cond, OSMutex* mutex) { + puts("OSWaitCond is a stub"); +} + +void OSYieldThread(void) { + puts("OSYieldThread is a stub"); +} + +s32 OSSuspendThread(OSThread *thread) { + puts("OSSuspendThread is a stub"); + return 0; +} + +void OSCancelThread(OSThread *thread) { + puts("OSCancelThread is a stub"); +} + +void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime *td) { + puts("OSTicksToCalendarTime is a stub"); +} + +BOOL OSUnlink(OSModuleInfo *oldModule) { + puts("OSUnlink is a stub"); + return FALSE; +} + +void OSSwitchFiberEx(__REGISTER u32 param_0, __REGISTER u32 param_1, __REGISTER u32 param_2, __REGISTER u32 param_3, __REGISTER u32 code, __REGISTER u32 stack) { + puts("OSSwitchFiberEx is a stub"); +} + +void OSWakeupThread(OSThreadQueue *queue) { puts("OSWakeupThread is a stub"); } + +u32 __OSGetDIConfig() { + puts("__OSGetDIConfig is a stub"); + return 0; +} + +__OSInterruptHandler __OSSetInterruptHandler(__OSInterrupt interrupt, + __OSInterruptHandler handler) { + puts("__OSSetInterruptHandler is a stub"); + return 0; +} + +OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask) { + puts("__OSUnmaskInterrupts is a stub"); + return 0; +} + +BOOL OSEnableInterrupts() { + puts("OSEnableInterrupts is a stub"); + return FALSE; +} + +s32 OSEnableScheduler() { + puts("OSEnableScheduler is a stub"); + return 0; +} + +void OSExitThread(void *val) { puts("OSExitThread is a stub"); } + +void* OSGetArenaHi(void) { + puts("OSGetArenaHi is a stub"); + return NULL; +} + +void* OSGetArenaLo(void) { + puts("OSGetArenaLo is a stub"); + return NULL; +} + +OSContext* OSGetCurrentContext(void) { + puts("OSGetCurrentContext is a stub"); + return NULL; +} + +u32 OSGetProgressiveMode(void) { + puts("OSGetProgressiveMode is a stub"); + return 0; +} + +u32 OSGetResetCode(void) { + puts("OSGetResetCode is a stub"); + return 0; +} + +BOOL OSGetResetSwitchState() { + puts("OSGetResetSwitchState is a stub"); + return FALSE; +} + +s32 OSGetThreadPriority(OSThread* thread) { + puts("OSGetThreadPriority is a stub"); + return 0; +} + +OSTick OSGetTick(void) { + puts("OSGetTick is a stub"); + return 0; +} + +OSTime OSGetTime(void) { + puts("OSGetTime is a stub"); + return 0; +} + +void OSInitCond(OSCond* cond) { + puts("OSInitCond is a stub"); +} + +void OSInitMessageQueue(OSMessageQueue* mq, void* msgArray, s32 msgCount) { + puts("OSInitMessageQueue is a stub"); +} + +void OSInitThreadQueue(OSThreadQueue* queue) { + puts("OSInitThreadQueue is a stub"); +} + +BOOL OSIsThreadTerminated(OSThread* thread) { + puts("OSIsThreadTerminated is a stub"); + return FALSE; +} + +int OSJamMessage(OSMessageQueue* mq, void* msg, s32 flags) { + puts("OSJamMessage is a stub"); + return 0; +} + +BOOL OSLinkFixed(OSModuleInfo* newModule, void* bss) { + puts("OSLinkFixed is a stub"); + return TRUE; +} + +void OSLockMutex(OSMutex* mutex) { + puts("OSLockMutex is a stub"); +} + +void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control) { + puts("OSProtectRange is a stub"); +} + +int OSReceiveMessage(OSMessageQueue* mq, void* msg, s32 flags) { + puts("OSReceiveMessage is a stub"); + return 0; +} + +int OSSendMessage(OSMessageQueue* mq, void* msg, s32 flags) { + puts("OSSendMessage is a stub"); + return 0; +} + +void OSSetArenaHi(void* newHi) { + puts("OSSetArenaHi is a stub"); +} + +void OSSetArenaLo(void* newLo) { + puts("OSSetArenaLo is a stub"); +} + +void OSSetPeriodicAlarm(OSAlarm* alarm, OSTime start, OSTime period, OSAlarmHandler handler) { + puts("OSSetPeriodicAlarm is a stub"); +} + +void OSSetProgressiveMode(u32 on) { + puts("OSSetProgressiveMode is a stub"); +} + +void OSSetSaveRegion(void* start, void* end) { + puts("OSSetSaveRegion is a stub"); +} + +OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler) { + puts("OSSetErrorHandler is a stub"); + return NULL; +} + +void OSSetAlarm(OSAlarm* alarm, OSTime tick, OSAlarmHandler handler) { + puts("OSSetAlarm is a stub"); +} + +void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps) { + puts("OSInitAlloc is a stub"); + return NULL; +} + +void OSFillFPUContext(__REGISTER OSContext* context) { + puts("OSFillFPUContext is a stub"); +} + +void OSSetSoundMode(u32 mode) {} + +# pragma mark SOUND +void SoundChoID(int a, int b) { puts("SoundChoID is a stub"); } +void SoundPan(int a, int b, int c) { puts("SoundPan is a stub"); } +void SoundPitch(u16 a, int b) { puts("SoundPitch is a stub"); } +void SoundRevID(int a, int b) { puts("SoundRevID is a stub"); } + +# pragma mark CARD + +#include + +extern "C" int CARDProbe(s32 chan) { + puts("CARDProbe is a stub"); + return 0; +} + s32 CARDCancel(CARDFileInfo *fileInfo) { puts("CARDCancel is a stub"); return 0; @@ -191,13 +478,13 @@ s32 CARDUnmount(s32 chan) { return 0; } -s32 CARDWrite(CARDFileInfo *fileInfo, void *addr, s32 length, +extern "C" s32 CARDWrite(CARDFileInfo *fileInfo, void *addr, s32 length, s32 offset) { puts("CARDWrite is a stub"); return 0; } -s32 CARDWriteAsync(CARDFileInfo *fileInfo, void *addr, s32 length, +s32 CARDWriteAsync(CARDFileInfo *fileInfo, const void *addr, s32 length, s32 offset, CARDCallback callback) { puts("CARDWriteAsync is a stub"); return 0; @@ -207,6 +494,13 @@ s32 CARDGetSerialNo(s32 chan, u64 *serialNo) { return 0; } s32 CARDSetStatus(s32 chan, s32 fileNo, CARDStat *stat) { return 0; } +s32 __CARDFormatRegionAsync(int a, int b) { + puts("__CARDFormatRegionAsync is a stub"); + return 0; +} + +# pragma mark DC + void DCFlushRange(void *addr, u32 nBytes) { // puts("DCFlushRange is a stub"); } @@ -227,23 +521,7 @@ void DCStoreRangeNoSync(void *addr, u32 nBytes) { // puts("DCStoreRangeNoSync is a stub"); } -s32 DVDCancel(volatile DVDCommandBlock *block) { - puts("DVDCancel is a stub"); - return 0; -} - -int DVDReadAbsAsyncForBS(DVDCommandBlock *block, void *addr, s32 length, s32 offset, - DVDCBCallback callback) { - puts("DVDReadAbsAsyncForBS is a stub"); - return 0; -} - -int DVDReadDiskID(DVDCommandBlock* block, DVDDiskID* diskID, DVDCBCallback callback) { - puts("DVDReadDiskID is a stub"); - return 0; -} - -void DVDReset() { puts("DVDReset is a stub"); } +# pragma mark EXI BOOL EXIDeselect(int chan) { puts("EXIDeselect is a stub"); @@ -280,106 +558,17 @@ BOOL EXIUnlock(int chan) { return FALSE; } +# pragma mark LC + void LCEnable() { puts("LCEnable is a stub"); } -void OSClearContext(OSContext *context) { puts("OSClearContext is a stub"); } +// OS-related functions consolidated under "# pragma mark OS" further up -BOOL OSDisableInterrupts() { - puts("OSDisableInterrupts is a stub"); - return FALSE; -} +# pragma mark VI -void OSDumpContext(OSContext *context) { puts("OSDumpContext is a stub"); } +static VIRetraceCallback sVIRetraceCallback = NULL; -OSThread *OSGetCurrentThread() { - puts("OSGetCurrentThread is a stub"); - return 0; -} - -u16 OSGetFontEncode() { - puts("OSGetFontEncode is a stub"); - return 0; -} - -char *OSGetFontTexture(const char* string, void** image, s32* x, s32* y, s32* width) { - puts("OSGetFontTexture is a stub"); - return 0; -} - -char *OSGetFontWidth(const char* string, s32* width) { - puts("OSGetFontWidth is a stub"); - return 0; -} - -BOOL OSGetResetButtonState() { - puts("OSGetResetButtonState is a stub"); - return FALSE; -} - -u32 OSGetStackPointer() { - puts("OSGetStackPointer is a stub"); - return 0; -} - -BOOL OSInitFont(OSFontHeader *fontData) { - puts("OSInitFont is a stub"); - return FALSE; -} - -BOOL OSLink(OSModuleInfo *newModule, void *bss) { - puts("OSLink is a stub"); - return TRUE; -} - -void OSLoadContext(OSContext *context) { puts("OSLoadContext is a stub"); } - -void OSResetSystem(int reset, u32 resetCode, BOOL forceMenu) { - puts("OSResetSystem is a stub"); -} - -BOOL OSRestoreInterrupts(BOOL level) { - puts("OSRestoreInterrupts is a stub"); - return FALSE; -} - -s32 OSResumeThread(OSThread *thread) { - puts("OSResumeThread is a stub"); - return 0; -} - -void OSSetCurrentContext(OSContext *context) { - puts("OSSetCurrentContext is a stub"); -} - -void OSSetStringTable(void* stringTable) { - puts("OSSetStringTable is a stub"); -} - -s32 OSSuspendThread(OSThread *thread) { - puts("OSSuspendThread is a stub"); - return 0; -} - -void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime *td) { - puts("OSTicksToCalendarTime is a stub"); -} - -BOOL OSUnlink(OSModuleInfo *oldModule) { - puts("OSUnlink is a stub"); - return FALSE; -} - -void OSWakeupThread(OSThreadQueue *queue) { puts("OSWakeupThread is a stub"); } - -void PPCHalt() { puts("PPCHalt is a stub"); } - -void SoundChoID(int a, int b) { puts("SoundChoID is a stub"); } - -void SoundPan(int a, int b, int c) { puts("SoundPan is a stub"); } - -void SoundPitch(u16 a, int b) { puts("SoundPitch is a stub"); } - -void SoundRevID(int a, int b) { puts("SoundRevID is a stub"); } +extern "C" { void VIConfigure(const GXRenderModeObj *rm) { puts("VIConfigure is a stub"); } @@ -409,38 +598,19 @@ void VIWaitForRetrace() { } } -s32 __CARDFormatRegionAsync(int a, int b) { - puts("__CARDFormatRegionAsync is a stub"); +void* VIGetCurrentFrameBuffer(void) { + puts("VIGetCurrentFrameBuffer is a stub"); + return NULL; +} + +u32 VIGetDTVStatus(void) { + puts("VIGetDTVStatus is a stub"); return 0; } -void __GXSetSUTexSize() { puts("__GXSetSUTexSize is a stub"); } - -void __GXSetVAT() { puts("__GXSetVAT is a stub"); } - -void __GXSetVCD() { puts("__GXSetVCD is a stub"); } - -void __GXUpdateBPMask() { puts("__GXUpdateBPMask is a stub"); } - -u32 __OSGetDIConfig() { - puts("__OSGetDIConfig is a stub"); - return 0; -} - -__OSInterruptHandler __OSSetInterruptHandler(__OSInterrupt interrupt, - __OSInterruptHandler handler) { - puts("__OSSetInterruptHandler is a stub"); - return 0; -} - -OSInterruptMask __OSUnmaskInterrupts(OSInterruptMask mask) { - puts("__OSUnmaskInterrupts is a stub"); - return 0; -} - -void SISetSamplingRate(u32 msec) { - // Maybe we could include SI later - puts("SISetSamplingRate is a stub"); +void* VIGetNextFrameBuffer(void) { + puts("VIGetNextFrameBuffer is a stub"); + return NULL; } VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback callback) { @@ -448,83 +618,835 @@ VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback callback) { return callback; } +VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback cb) { + puts("VISetPreRetraceCallback is a stub"); + return cb; +} + +} // extern "C" + +# pragma mark DSP +#include +extern "C" void __DSP_insert_task(DSPTaskInfo* task) { + puts("__DSP_insert_task is a stub"); +} + +extern "C" void __DSP_boot_task(DSPTaskInfo*) { + puts("__DSP_boot_task is a stub"); +} + +extern "C" void __DSP_exec_task(DSPTaskInfo*, DSPTaskInfo*) { + puts("__DSP_exec_task is a stub"); +} + +extern "C" void __DSP_remove_task(DSPTaskInfo* task) { + puts("__DSP_remove_task is a stub"); +} + +void DSPAssertInt(void) { + puts("DSPAssertInt is a stub"); +} +u32 DSPCheckMailFromDSP(void) { + puts("DSPCheckMailFromDSP is a stub"); + return 0; +} +u32 DSPCheckMailToDSP(void) { + puts("DSPCheckMailToDSP is a stub"); + return 0; +} +void DSPInit(void) { + puts("DSPInit is a stub"); +} +u32 DSPReadMailFromDSP(void) { + puts("DSPReadMailFromDSP is a stub"); + return 0; +} +void DSPSendMailToDSP(u32 mail) { + puts("DSPSendMailToDSP is a stub"); +} + +# pragma mark Z2Audio +#include +void Z2AudioCS::extensionProcess(s32, s32) { + puts("Z2AudioMgr::play is a stub"); +} + +# pragma mark JORServer +#include +void JORServer::releaseMCTX(JORMContext*) { + puts("releaseMCTX is a stub"); +} + +JORMContext* JORServer::attachMCTX(u32) { + puts("attachMCTX is a stub"); + return NULL; +} + +JORServer* JORServer::instance; + +void JORMContext::genCheckBoxSub(u32 kind, const char* label, u32 id, u32 style, u16 initValue, u16 mask, + JOREventListener* pListener, u16 posX, u16 posY, u16 width, + u16 height) { + puts("JORServer::genCheckBoxSub is a stub"); +} +void JORMContext::updateCheckBoxSub(u32 mode, u32 id, u16 value, u16 mask, u32 param_4) { + puts("JORServer::updateCheckBoxSub is a stub"); +} + +int JOREventCallbackListNode::JORAct(u32, const char*) { + return 0; +} + +# pragma mark JSUMemoryOutputStream +#include +s32 JSUMemoryOutputStream::getAvailable() const { + return mLength - mPosition; +} + +s32 JSUMemoryOutputStream::getPosition() const { + return mPosition; +} + +# pragma mark JSURandomOutputStream +#include +s32 JSUMemoryOutputStream::seek(s32 offset, JSUStreamSeekFrom origin) { + // XXX I think this is correct? could be broken. + return this->seekPos(offset, origin); +} + +# pragma mark JKRHeap +#include +JKRHeap* JKRHeap::sRootHeap2; // XXX this is defined for WII/SHIELD, should we just define it for dusk builds? + +# pragma mark mDoExt_onCupOnAupPacket +#include +mDoExt_offCupOnAupPacket::~mDoExt_offCupOnAupPacket() { + puts("mDoExt_onCupOffAupPacket_c destructor is a stub"); +} +# pragma mark mDoExt_onCupOffAupPacket +mDoExt_onCupOffAupPacket::~mDoExt_onCupOffAupPacket() { + puts("mDoExt_onCupOffAupPacket_c destructor is a stub"); +} + +# pragma mark mDoExt +namespace mDoExt { + u8 CurrentHeapAdjustVerbose; + u8 HeapAdjustVerbose; + u8 HeapAdjustQuiet; +}; + +# pragma mark dKankyo_vrboxHIO_c +#include +void dKankyo_vrboxHIO_c::dKankyo_vrboxHIOInfoUpDateF() { + puts("dKankyo_vrboxHIO_c::dKankyo_vrboxHIOInfoUpDateF is a stub"); +} + +void dKankyo_lightHIO_c::dKankyo_lightHIOInfoUpDateF() { + puts("dKankyo_lightHIO_c::dKankyo_lightHIOInfoUpDateF is a stub"); +} + +# pragma mark dKankyo_HIO_c +#include +dKankyo_HIO_c::dKankyo_HIO_c() { + light.m_displayTVColorSettings = FALSE; + vrbox.m_displayVrboxTVColorSettings = FALSE; +} + +dKankyo_ParticlelightHIO_c::dKankyo_ParticlelightHIO_c() { + field_0x5 = 0; + prim_col.r = 255; + prim_col.g = 255; + prim_col.b = 255; + prim_col.a = 255; + env_col.r = 255; + env_col.g = 255; + env_col.b = 255; + env_col.a = 255; + blend_ratio = 0.5f; + field_0x14 = 0; + type = 0; + field_0x19 = 1; + field_0x1a = 0; +} + +dKankyo_dungeonlightHIO_c::dKankyo_dungeonlightHIO_c() { + field_0x5 = 0; + usedLights = 0; + displayDebugSphere = 0; + field_0x8 = 0; + field_0x9 = 0; +} + +dKankyo_demolightHIO_c::dKankyo_demolightHIO_c() { + adjust_ON = 0; + light.mPosition.x = 0.0f; + light.mPosition.y = 0.0f; + light.mPosition.z = 0.0f; + light.mColor.r = 255; + light.mColor.g = 255; + light.mColor.b = 255; + light.mPow = 1000.0f; + light.mFluctuation = 0.0f; +} + +dKankyo_efflightHIO_c::dKankyo_efflightHIO_c() { + adjust_ON = 0; + power = 80.0f; + fluctuation = 100.0f; + + step1.start_frame = 1; + step1.r = 191; + step1.g = 150; + step1.b = 45; + + step2.start_frame = 4; + step2.r = 180; + step2.g = 60; + step2.b = 0; + + step3.start_frame = 8; + step3.r = 75; + step3.g = 15; + step3.b = 0; + + step4.start_frame = 15; + step4.r = 0; + step4.g = 0; + step4.b = 0; +} + +dKankyo_vrboxHIO_c::dKankyo_vrboxHIO_c() { + m_VrboxSetting = 0; + field_0x5 = 0; + field_0x7 = 0; + field_0x8 = 0; + field_0x9 = 0; + field_0xa = 0; + field_0xb = 0; + field_0xc = 0; + field_0xd = 0; + field_0xe = -1; + field_0xf = -1; + field_0x10 = -1; + field_0x11 = -1; + field_0x12 = -1; + field_0x13 = -1; + field_0x14 = 0; + m_horizonHeight = 0.0f; +} + +dKankyo_lightHIO_c::dKankyo_lightHIO_c() { + m_HOSTIO_setting = FALSE; + field_0x52 = 0; + m_forcedPalette = FALSE; + m_displayColorPaletteCheckInfo = TRUE; + + field_0x58 = 0.0f; + field_0x60 = 0; + field_0x61 = 0; + field_0x62 = 0; + field_0x63 = 0; + field_0x64 = 0; + field_0x65 = 0; + field_0x66 = 0; + field_0x67 = 0; + field_0x68 = 0; + field_0x69 = 0; + field_0x6a = 0; + field_0x6b = 0; + + m_BG_fakelight_R = 0; + m_BG_fakelight_G = 0; + m_BG_fakelight_B = 0; + m_BG_fakelight_power = 0.0f; + + field_0x80 = 0; +} + +dKankyo_bloomHIO_c::dKankyo_bloomHIO_c() { + field_0x4 = 0; + m_saturationPattern = 0; + field_0x5 = 0; + + for (int i = 0; i < 64; i++) { + dKydata_BloomInfo_c* bloominf = dKyd_BloomInf_tbl_getp(i); + bloom_info[i] = bloominf->info; + } +} + +dKankyo_windHIO_c::dKankyo_windHIO_c() { + display_wind_dir = 0; + use_HOSTIO_adjustment = 0; + field_0x8 = -1; + global_x_angle = 0; + global_y_angle = 0; + global_wind_power = 0.3f; + field_0x14 = 0.0; + field_0x18 = 35.0f; + field_0x1c = 6.0f; + display_wind_trajectory = 0; + lightsword_x_angle = 1800; + lightsword_init_scale = 500.0f; + lightsword_end_scale = 300.0f; + influence = 1.0f; + lightsword_move_speed = 150.0f; + influence_attenuation = 0.3f; + wind_change_speed = 0.05f; + minigame_no_wind_duration = 90; + minigame_low_wind_duration = 60; + minigame_high_wind_duration = 90; +} +dKankyo_navyHIO_c::dKankyo_navyHIO_c() { + field_0x5 = 0; + field_0x6 = 0; + field_0x8 = 12; + cloud_sunny_wind_influence_rate = 10.0f; + cloud_sunny_bottom_height = 2500.0f; + cloud_sunny_top_height = 2500.0f; + cloud_sunny_size = 0.6f; + cloud_sunny_height_shrink_rate = 0.9999f; + cloud_sunny_alpha = 1.0f; + cloud_cloudy_wind_influence_rate = 25.0f; + cloud_cloudy_bottom_height = 1200.0f; + cloud_cloudy_top_height = 1200.0f; + cloud_cloudy_size = 0.84f; + cloud_cloudy_height_shrink_rate = 0.96f; + cloud_cloudy_alpha = 1.0f; + field_0x3c = 4000.0f; + field_0x40 = 2000.0f; + field_0x44 = 2500.0f; + field_0x48 = 80.0f; + field_0x4c = 0.18f; + field_0x68 = 1; + field_0x69 = 3; + field_0x50 = 255.0f; + field_0x58 = 800.0f; + field_0x5c = 250.0f; + field_0x54 = 1.0f; + field_0x60 = 1000.0f; + field_0x64 = 0.2f; + housi_max_number = 300; + housi_max_alpha = 120.0f; + housi_max_scale = 9.0f; + field_0x74 = 45; + field_0x75 = 136; + field_0x76 = 170; + field_0x78 = 109; + field_0x79 = 60; + field_0x7a = 205; + field_0x7c = 120.0f; + field_0x80 = 100.0f; + field_0x84 = 0.2f; + field_0x8a = 0; + field_0x88 = 0; + field_0x80 = 0.0f; + moon_col.r = 0; + moon_col.g = 0; + moon_col.b = 0; + moon_col.a = 255; + moon_scale = 8000.0f; + field_0xb0.x = 16.5f; + field_0xb0.y = -2.0f; + field_0xb0.z = 30.0f; + field_0xbc = 160.0f; + field_0xc0 = 0.06f; + field_0xc4 = 200; + field_0xc8 = 3.0f; + field_0xcc = 60.0f; + field_0xd0 = 69; + field_0xd1 = 60; + field_0xd2 = 39; + field_0xd4 = 124; + field_0xd5 = 124; + field_0xd6 = 104; + field_0xd3 = 255; + field_0xd8 = 255; + field_0xd9 = 0; + field_0xda = 0; + field_0xdc = 255; + field_0xdd = 255; + field_0xde = 0; + field_0xe0 = 500; + field_0xe4 = 0.4f; + sun_col.r = 255; + sun_col.g = 255; + sun_col.b = 241; + sun_col2.r = 255; + sun_col2.g = 145; + sun_col2.b = 73; + sun_adjust_ON = 0; + smell_adjust_ON = 0; + smell_col.r = 255; + smell_col.g = 255; + smell_col.b = 115; + smell_col2.r = 80; + smell_col2.g = 50; + smell_col2.b = 0; + smell_alpha = 1.0f; + field_0xf0 = 190; + field_0xf1 = 120; + field_0xf2 = 120; + field_0x108 = 60; + field_0x109 = 0; + field_0x10a = 0; + field_0xf4 = 60; + field_0xf5 = 150; + field_0xf6 = 230; + field_0x10c = 50; + field_0x10d = 65; + field_0x10e = 80; + field_0xf8 = 80; + field_0xf9 = 80; + field_0xfa = 20; + field_0x110 = 30; + field_0x111 = 30; + field_0x112 = 10; + field_0xfc = 33; + field_0xfd = 255; + field_0xfe = 125; + field_0x114 = 33; + field_0x115 = 255; + field_0x116 = 125; + field_0x120 = 0.1f; + field_0x124 = 1.0f; + constellation_maker_ON = 0; + constellation_maker_pos[0].x = 5900.0f; + constellation_maker_pos[0].y = 14000.0f; + constellation_maker_pos[0].z = -16000.0f; + constellation_maker_pos[1].x = 7500.0f; + constellation_maker_pos[1].y = 14000.0f; + constellation_maker_pos[1].z = -14700.0f; + constellation_maker_pos[2].x = 8700.0f; + constellation_maker_pos[2].y = 13920.0f; + constellation_maker_pos[2].z = -14700.0f; + constellation_maker_pos[3].x = 10200.0f; + constellation_maker_pos[3].y = 14320.0f; + constellation_maker_pos[3].z = -15000.0f; + constellation_maker_pos[4].x = 12300.0f; + constellation_maker_pos[4].y = 15400.0f; + constellation_maker_pos[4].z = -18400.0f; + constellation_maker_pos[5].x = 13000.0f; + constellation_maker_pos[5].y = 13500.0f; + constellation_maker_pos[5].z = -15000.0f; + constellation_maker_pos[6].x = 13000.0f; + constellation_maker_pos[6].y = 15400.0f; + constellation_maker_pos[6].z = -14500.0f; + constellation_maker_pos[7].x = 13000.0f; + constellation_maker_pos[7].y = 15400.0f; + constellation_maker_pos[7].z = -14500.0f; + constellation_maker_pos[8].x = 13000.0f; + constellation_maker_pos[8].y = 15400.0f; + constellation_maker_pos[8].z = -14500.0f; + constellation_maker_pos[9].x = 13000.0f; + constellation_maker_pos[9].y = 15400.0f; + constellation_maker_pos[9].z = -14500.0f; + lightning_scale_x_min = 14.0f; + lightning_scale_x_max = 20.0f; + lightning_scale_y_min = 14.0f; + lightning_scale_y_max = 20.0f; + lightning_tilt_angle = 2000; + field_0x1b6 = 3; + lightning_debug_mode = 0; + collect_light_reflect_pos.x = 60000.0f; + collect_light_reflect_pos.y = -5000.0f; + collect_light_reflect_pos.z = 0.0f; + moya_alpha = 0.12f; + field_0x1c5 = 0; + thunder_col.r = 75; + thunder_col.g = 130; + thunder_col.b = 150; + thunder_height = 2000.0f; + thunder_blacken_rate = 0.75f; + water_in_col_ratio_R = 0.0f; + water_in_col_ratio_G = 0.4f; + water_in_col_ratio_B = 0.5f; + field_0x1e8 = -10.0f; + field_0x1ec = 40.0f; + field_0x1f0 = 50.0f; + field_0x1f4 = 200.0f; + field_0x1f8 = 0.0f; + field_0x1e4 = 80; + field_0x1e5 = 80; + field_0x1e6 = 80; + field_0x1fd = 2; + field_0x1fe = 3; + field_0x1ff = 0; + field_0x200 = 0; + mist_tag_fog_near = -2000.0f; + mist_tag_fog_far = 200.0f; + wipe_test_ON = 0xff; + field_0x210 = 0.0f; + fade_test_speed = 0; + field_0x215 = 1; + smell_railtag_space = 0.0f; + field_0x22a = 0; + field_0x22c = 0; + field_0x22d = 0; + light_adjust_ON = 0; + adjust_light_ambcol.r = 24; + adjust_light_ambcol.g = 24; + adjust_light_ambcol.b = 24; + adjust_light_dif0_col_R = 126; + adjust_light_dif0_col_G = 110; + adjust_light_dif0_col_B = 89; + adjust_light_dif1_col.r = 24; + adjust_light_dif1_col.g = 41; + adjust_light_dif1_col.b = 50; + adjust_light_main_pos.x = 500.0f; + adjust_light_main_pos.y = 500.0f; + adjust_light_main_pos.z = 500.0f; + mist_twilight_c1_col.r = 182; + mist_twilight_c1_col.g = 88; + mist_twilight_c1_col.b = 50; + mist_twilight_c1_col.a = 150; + mist_twilight_c2_col.r = 117; + mist_twilight_c2_col.g = 69; + mist_twilight_c2_col.b = 50; + mist_twilight_c2_col.a = 255; + field_0x264.r = 124; + field_0x264.g = 60; + field_0x264.b = 50; + field_0x267 = 255; + field_0x268 = 150; + adjust_custom_R = 70; + adjust_custom_G = 70; + adjust_custom_B = 70; + adjust_light_mode = 1; + adjust_height = 0.0f; + field_0x278 = 120.0f; + shadow_adjust_ON = 0; + shadow_normal_alpha = 0.4f; + shadow_max_alpha = 0.65f; + field_0x29c = 0; + field_0x27c = 70.0f; + field_0x280 = 0.05f; + field_0x284 = 1.5f; + field_0x288 = 0.00025f; + field_0x28c = 0.001f; + unk_color_1.r = 255; + unk_color_1.g = 255; + unk_color_1.b = 255; + unk_alpha_1 = 255; + unk_color_2.r = 0; + unk_color_2.g = 0; + unk_color_2.b = 0; + unk_alpha_2 = 255; + unk_color_3.r = 60; + unk_color_3.g = 30; + unk_color_3.b = 0; + unk_alpha_3 = 255; + field_0x29d = 1; + camera_light_col.r = 25; + camera_light_col.g = 90; + camera_light_col.b = 183; + camera_light_alpha = 255; + camera_light_y_shift = 1500.0f; + camera_light_power = 1.25f; + camera_light_cutoff = 90.0f; + camera_light_sp = 2; + camera_light_da = 3; + demo_adjust_SW = 0; + demo_focus_pos = 30; + demo_focus_offset_x = 0.0025f; + demo_focus_offset_y = 0.0025f; + grass_ambcol.r = 0; + grass_ambcol.g = 0; + grass_ambcol.b = 0; + grass_adjust_ON = 0; + grass_shine_value = 0.0f; + stars_max_number = 0xffff; + display_save_location = 0; + unk_light_influence_ratio = 100; + door_light_influence_ratio = 255; + fish_pond_colreg_adjust_ON = 0; + fish_pond_colreg_c0.r = 0; + fish_pond_colreg_c0.g = 0; + fish_pond_colreg_c0.b = 0; + water_mud_adjust_ON = 0; + field_0x2ea = 0; + field_0x2ec = 0; + fish_pond_tree_adjust_ON = 0; + fish_pond_tree_ambcol.r = 0; + fish_pond_tree_ambcol.g = 0; + fish_pond_tree_ambcol.b = 0; + fish_pond_tree_dif0_col.r = 0; + fish_pond_tree_dif0_col.g = 0; + fish_pond_tree_dif0_col.b = 0; + fish_pond_tree_dif1_col.r = 0; + fish_pond_tree_dif1_col.g = 0; + fish_pond_tree_dif1_col.b = 0; + rainbow_adjust_ON = 0; + rainbow_separation_dist = 4500; + rainbow_max_alpha = 175; + field_0x2ff = 0; + grass_light_influence_ratio = 100; + grass_light_debug = 0; + field_0x302 = 2000; + field_0x304 = 0.6f; + field_0x308 = 0; + moya_col.r = 255; + moya_col.g = 255; + moya_col.b = 255; + field_0x30d = 0; + twilight_sense_saturation_mode = 0; + twilight_sense_pat = 0; + twilight_sense_pat_tv_display_ON = 0; + camera_light_adjust_ON = 0; + possessed_zelda_light_col.r = 30; + possessed_zelda_light_col.g = 55; + possessed_zelda_light_col.b = 110; + possessed_zelda_light_alpha = 255; + possessed_zelda_light_height = -800.0f; + possessed_zelda_light_power = 250.0f; + beast_ganon_light_col.r = 60; + beast_ganon_light_col.g = 95; + beast_ganon_light_col.b = 100; + beast_ganon_light_alpha = 255; + beast_ganon_light_height = -800.0f; + beast_ganon_light_power = 150.0f; + water_in_light_col.r = 138; + water_in_light_col.g = 192; + water_in_light_col.b = 188; +} + +# pragma mark AI +#include +u32 AIGetDSPSampleRate(void) { + puts("AIGetDSPSampleRate is a stub"); + return 48000; // Default sample rate? +} + +void AIInit(u8* stack) { + puts("AIInit is a stub"); + // This function initializes the AI system, but we don't have any specific implementation here. + // In a real scenario, it would set up the audio interface and prepare it for use. +} + +void AIInitDMA(u32 start_addr, u32 length) { + puts("AIInitDMA is a stub"); +} + +AIDCallback AIRegisterDMACallback(AIDCallback callback) { + puts("AIRegisterDMACallback is a stub"); + return callback; +} + +void AISetDSPSampleRate(u32 rate) { + // Should this link with the getsamplerate? this is very TODO + puts("AISetDSPSampleRate is a stub"); +} + +void AIStartDMA(void) { + puts("AIStartDMA is a stub"); +} + +void AIStopDMA(void) { + puts("AIStopDMA is a stub"); +} + +# pragma mark AR +#include +// Auxilary RAM doesn't exist on PC platforms, do we need to call malloc/free for these instead? +// For now, we will just stub these functions. +u32 ARAlloc(u32 length) { + puts("ARAlloc is a stub"); + return 0; +} + +u32 ARGetSize(void) { + return 0x10000; // 64KB, this is the size of the AR memory region +} + +u32 ARInit(u32* stack_index_addr, u32 num_entries) { + puts("ARInit is a stub"); + return 0; +} + +# pragma mark ARQ +void ARQPostRequest(ARQRequest* request, u32 owner, u32 type, u32 priority, u32 source, u32 dest, u32 length, ARQCallback callback) { + puts("ARQPostRequest is a stub"); +} + +void ARQInit() { + puts("ARQInit is a stub"); +} + +# pragma mark DVD +#include +s32 DVDCancel(volatile DVDCommandBlock* block) { + puts("DVDCancel is a stub"); + return 0; +} +s32 DVDCancel(DVDCommandBlock* block) { + puts("DVDCancel is a stub"); + return 0; +} +BOOL DVDChangeDir(const char* dirName) { + puts("DVDChangeDir is a stub"); + return TRUE; +} +BOOL DVDCheckDisk(void) { + puts("DVDCheckDisk is a stub"); + return TRUE; +} +BOOL DVDClose(DVDFileInfo* fileInfo) { + puts("DVDClose is a stub"); + return TRUE; +} +int DVDCloseDir(DVDDir* dir) { + puts("DVDCloseDir is a stub"); + return 0; +} +s32 DVDConvertPathToEntrynum(const char* pathPtr) { + puts("DVDConvertPathToEntrynum is a stub"); + return 0; +} +BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo) { + puts("DVDFastOpen is a stub"); + return TRUE; +} +s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) { + puts("DVDGetCommandBlockStatus is a stub"); + return 0; +} +DVDDiskID* DVDGetCurrentDiskID(void) { + puts("DVDGetCurrentDiskID is a stub"); + return NULL; +} +s32 DVDGetDriveStatus(void) { + puts("DVDGetDriveStatus is a stub"); + return 0; +} +void DVDInit(void) { + puts("DVDInit is a stub"); +} +BOOL DVDOpen(const char* fileName, DVDFileInfo* fileInfo) { + puts("DVDOpen is a stub"); + return TRUE; +} +int DVDOpenDir(const char* dirName, DVDDir* dir) { + puts("DVDOpenDir is a stub"); + return 0; +} +BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, + DVDCallback callback, s32 prio) { + puts("DVDReadAsyncPrio is a stub"); + return TRUE; +} +int DVDReadDir(DVDDir* dir, DVDDirEntry* dirent) { + puts("DVDReadDir is a stub"); + return 0; +} +s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 prio) { + puts("DVDReadPrio is a stub"); + return 0; +} + +void DVDReadAbsAsyncForBS(void *a, struct bb2struct *b, int c, int d, + void (*e)()) { + puts("DVDReadAbsAsyncForBS is a stub"); +} + +void DVDReadDiskID(void *a, DVDDiskID *b, void (*c)()) { + puts("DVDReadDiskID is a stub"); +} + +void DVDReset() { + puts("DVDReset is a stub"); +} + +# pragma mark GD +#include +#include +void GDFlushCurrToMem(void) { + puts("GDFlushCurrToMem is a stub"); +} +void GDInitGDLObj(GDLObj* dl, void* start, u32 length) { + puts("GDInitGDLObj is a stub"); +} +void GDOverflowed(void) { + puts("GDOverflowed is a stub"); +} +void GDPadCurr32(void) { + puts("GDPadCurr32 is a stub"); +} +void GDSetArray(GXAttr attr, void* base_ptr, u8 stride) { + puts("GDSetArray is a stub"); +} +void GDSetArrayRaw(GXAttr attr, u32 base_ptr_raw, u8 stride) { + puts("GDSetArrayRaw is a stub"); +} +void GDSetVtxDescv(const GXVtxDescList* attrPtr) { + puts("GDSetVtxDescv is a stub"); +} + +# pragma mark GX +#include + +// Moved-in GX helpers and helpers for metrics/project +void __GXSetSUTexSize() { puts("__GXSetSUTexSize is a stub"); } +void __GXSetVAT() { puts("__GXSetVAT is a stub"); } +void __GXSetVCD() { puts("__GXSetVCD is a stub"); } +void __GXUpdateBPMask() { puts("__GXUpdateBPMask is a stub"); } + void GXSetGPMetric(GXPerf0 perf0, GXPerf1 perf1) { // puts("GXSetGPMetric is a stub"); } - void GXReadGPMetric(u32 *cnt0, u32 *cnt1) { // puts("GXReadGPMetric is a stub"); } - void GXClearGPMetric(void) { // puts("GXClearGPMetric is a stub"); } - void GXReadMemMetric(u32 *cp_req, u32 *tc_req, u32 *cpu_rd_req, u32 *cpu_wr_req, u32 *dsp_req, u32 *io_req, u32 *vi_req, u32 *pe_req, u32 *rf_req, u32 *fi_req) { // puts("GXReadMemMetric is a stub"); } - void GXClearMemMetric(void) { // puts("GXClearMemMetric is a stub"); } - void GXClearVCacheMetric(void) { // puts("GXClearVCacheMetric is a stub"); } - void GXReadPixMetric(u32 *top_pixels_in, u32 *top_pixels_out, u32 *bot_pixels_in, u32 *bot_pixels_out, u32 *clr_pixels_in, u32 *copy_clks) { // puts("GXReadPixMetric is a stub"); } - void GXClearPixMetric(void) { // puts("GXClearPixMetric is a stub"); } - void GXSetVCacheMetric(GXVCachePerf attr) { // puts("GXSetVCacheMetric is a stub"); } - void GXReadVCacheMetric(u32 *check, u32 *miss, u32 *stall) { // puts("GXReadVCacheMetric is a stub"); } - void GXSetDrawSync(u16 token) { // puts("GXSetDrawSync is a stub"); } - GXDrawSyncCallback GXSetDrawSyncCallback(GXDrawSyncCallback cb) { puts("GXSetDrawSyncCallback is a stub"); - // TODO return cb; } - -void PPCSync(void) { - // puts("PPCSync is a stub"); +void GXDrawCylinder(u8 numEdges) { + puts("GXDrawCylinder is a stub"); } - void GXWaitDrawDone(void) { // puts("GXWaitDrawDone is a stub"); } - void GXSetTevIndTile(GXTevStageID tev_stage, GXIndTexStageID ind_stage, u16 tilesize_s, u16 tilesize_t, u16 tilespacing_s, u16 tilespacing_t, GXIndTexFormat format, GXIndTexMtxID matrix_sel, GXIndTexBiasSel bias_sel, GXIndTexAlphaSel alpha_sel) { // TODO - // puts("GXSetTevIndTile is a stub"); } - void GXResetWriteGatherPipe(void) { // puts("GXResetWriteGatherPipe is a stub"); } -void ARQInit(void) { puts("ARQInit is a stub"); } - void GXProject(f32 x, f32 y, f32 z, const f32 mtx[3][4], const f32 *pm, const f32 *vp, f32 *sx, f32 *sy, f32 *sz) { Vec peye; @@ -551,575 +1473,116 @@ void GXProject(f32 x, f32 y, f32 z, const f32 mtx[3][4], const f32 *pm, *sy = (vp[3] / 2.0f) + (vp[1] + (wc * (-yc * vp[3] / 2.0f))); *sz = vp[5] + (wc * (zc * (vp[5] - vp[4]))); } - -void GXGetViewportv(f32 *vp) { - // TODO -} - -void OSSetSoundMode(u32 mode) {} - -u32 AIGetDSPSampleRate(void) { - puts("AIGetDSPSampleRate is a stub"); - return 0; -} - -void AIInit(u8* stack) { - puts("AIInit is a stub"); -} - -void AIInitDMA(u32 start_addr, u32 length) { - puts("AIInitDMA is a stub"); -} - -AIDCallback AIRegisterDMACallback(AIDCallback callback) { - puts("AIRegisterDMACallback is a stub"); - return NULL; -} - -void AISetDSPSampleRate(u32 rate) { - puts("AISetDSPSampleRate is a stub"); -} - -void AIStartDMA(void) { - puts("AIStartDMA is a stub"); -} - -void AIStopDMA(void) { - puts("AIStopDMA is a stub"); -} - -u32 ARAlloc(u32 length) { - puts("ARAlloc is a stub"); - return 0; -} - -u32 ARGetSize(void) { - puts("ARGetSize is a stub"); - return 0; -} - -u32 ARInit(u32* stack_index_addr, u32 num_entries) { - puts("ARInit is a stub"); - return 0; -} - -void ARQPostRequest(ARQRequest* request, u32 owner, u32 type, u32 priority, u32 source, u32 dest, u32 length, ARQCallback callback) { - puts("ARQPostRequest is a stub"); -} - -int CARDProbe(s32 chan) { - puts("CARDProbe is a stub"); - return 0; -} - -void C_MTXLightOrtho(Mtx m, f32 t, f32 b, f32 l, f32 r, f32 scaleS, f32 scaleT, f32 transS, - f32 transT) { - puts("C_MTXLightOrtho is a stub"); -} - -void C_MTXLightPerspective(Mtx m, f32 fovY, f32 aspect, f32 scaleS, f32 scaleT, f32 transS, - f32 transT) { - puts("C_MTXLightPerspective is a stub"); -} - -void C_MTXLookAt(Mtx m, const Point3d* camPos, const Vec* camUp, const Point3d* target) { - puts("C_MTXLookAt is a stub"); -} - -void C_MTXOrtho(Mtx44 m, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f) { - puts("C_MTXOrtho is a stub"); -} - -void C_MTXPerspective(Mtx44 m, f32 fovY, f32 aspect, f32 n, f32 f) { - puts("C_MTXPerspective is a stub"); -} - -void C_MTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) { - puts("C_MTXRotAxisRad is a stub"); -} - -void C_QUATRotAxisRad(Quaternion* r, const Vec* axis, f32 rad) { - puts("C_QUATRotAxisRad is a stub"); -} - -void C_QUATSlerp(const Quaternion* p, const Quaternion* q, Quaternion* r, f32 t) { - puts("C_QUATSlerp is a stub"); -} - -void C_VECHalfAngle(const Vec* a, const Vec* b, Vec* half) { - puts("C_VECHalfAngle is a stub"); -} - -void C_VECReflect(const Vec* src, const Vec* normal, Vec* dst) { - puts("C_VECReflect is a stub"); -} - -void DCZeroRange(void* addr, u32 nBytes) { - puts("C_VECReflect is a stub"); -} - -void DSPAssertInt(void) { - puts("DSPAssertInt is a stub"); -} - -u32 DSPCheckMailFromDSP(void) { - puts("DSPCheckMailFromDSP is a stub"); - return 0; -} - -u32 DSPCheckMailToDSP(void) { - puts("DSPCheckMailToDSP is a stub"); - return 0; -} - -void DSPInit(void) { - puts("DSPInit is a stub"); -} - -u32 DSPReadMailFromDSP(void) { - puts("DSPReadMailFromDSP is a stub"); - return 0; -} - -void DSPSendMailToDSP(u32 mail) { - puts("DSPSendMailToDSP is a stub"); -} - -BOOL DVDChangeDir(const char* dirName) { - puts("DVDChangeDir is a stub"); - return FALSE; -} - -BOOL DVDCheckDisk(void) { - puts("DVDCheckDisk is a stub"); - return FALSE; -} - -BOOL DVDClose(DVDFileInfo* fileInfo) { - puts("DVDClose is a stub"); - return FALSE; -} - -int DVDCloseDir(DVDDir* dir) { - puts("DVDCloseDir is a stub"); - return 0; -} - -s32 DVDConvertPathToEntrynum(const char* pathPtr) { - puts("DVDConvertPathToEntrynum is a stub"); - return 0; -} - -BOOL DVDFastOpen(s32 entrynum, DVDFileInfo* fileInfo) { - puts("DVDFastOpen is a stub"); - return FALSE; -} - -s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) { - puts("DVDGetCommandBlockStatus is a stub"); - return 0; -} - -DVDDiskID* DVDGetCurrentDiskID(void) { - puts("DVDGetCurrentDiskID is a stub"); - return NULL; -} - -s32 DVDGetDriveStatus(void) { - puts("DVDGetDriveStatus is a stub"); - return 0; -} - -void DVDInit(void) { - puts("DVDInit is a stub"); -} - -BOOL DVDOpen(const char* fileName, DVDFileInfo* fileInfo) { - puts("DVDOpen is a stub"); - return FALSE; -} - -int DVDOpenDir(const char* dirName, DVDDir* dir) { - puts("DVDOpenDir is a stub"); - return 0; -} - -BOOL DVDReadAsyncPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, - DVDCallback callback, s32 prio) { - puts("DVDReadAsyncPrio is a stub"); - return FALSE; -} - -int DVDReadDir(DVDDir* dir, DVDDirEntry* dirent) { - puts("DVDReadDir is a stub"); - return 0; -} - -s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 prio) { - puts("DVDReadPrio is a stub"); - return 0; -} - -void GDFlushCurrToMem(void) { - puts("GDFlushCurrToMem is a stub"); -} - -void GDInitGDLObj(GDLObj* dl, void* start, u32 length) { - puts("GDInitGDLObj is a stub"); -} - -void GDOverflowed(void) { - puts("GDOverflowed is a stub"); -} - -void GDPadCurr32(void) { - puts("GDPadCurr32 is a stub"); -} - -extern "C" { - -void GDSetArray(GXAttr attr, void* base_ptr, u8 stride) { - puts("GDSetArray is a stub"); -} - -void GDSetArrayRaw(GXAttr attr, u32 base_ptr_raw, u8 stride) { - puts("GDSetArrayRaw is a stub"); -} - -void GDSetVtxDescv(const GXVtxDescList* attrPtr) { - puts("GDSetVtxDescv is a stub"); -} - -} - void GXAbortFrame(void) { puts("GXAbortFrame is a stub"); } - -void GXEnableTexOffsets(GXTexCoordID coord, GXBool line_enable, GXBool point_enable) { +void GXEnableTexOffsets(GXTexCoordID coord, u8 line_enable, u8 point_enable) { puts("GXEnableTexOffsets is a stub"); } - OSThread* GXGetCurrentGXThread(void) { puts("GXGetCurrentGXThread is a stub"); return NULL; } - void* GXGetFifoBase(const GXFifoObj* fifo) { puts("GXGetFifoBase is a stub"); return NULL; } - u32 GXGetFifoSize(const GXFifoObj* fifo) { puts("GXGetFifoSize is a stub"); return 0; } - u16 GXGetNumXfbLines(u16 efbHeight, f32 yScale) { puts("GXGetNumXfbLines is a stub"); return 0; } - +void GXGetViewportv(f32* vp) { + puts("GXGetViewportv is a stub"); +} void GXGetScissor(u32* left, u32* top, u32* wd, u32* ht) { puts("GXGetScissor is a stub"); } - u32 GXGetTexObjTlut(const GXTexObj* tex_obj) { puts("GXGetTexObjTlut is a stub"); return 0; } - f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight) { puts("GXGetYScaleFactor is a stub"); - return 0.f; + return 0.0f; } - -void GXInitTexCacheRegion(GXTexRegion* region, GXBool is_32b_mipmap, u32 tmem_even, GXTexCacheSize size_even, - u32 tmem_odd, GXTexCacheSize size_odd) { +void GXInitTexCacheRegion(GXTexRegion* region, u8 is_32b_mipmap, u32 tmem_even, GXTexCacheSize size_even, u32 tmem_odd, GXTexCacheSize size_odd) { puts("GXInitTexCacheRegion is a stub"); } - -GXRenderModeObj GXNtsc480Int = { - (VITVMode)0, 640, 480, 480, 40, 0, 640, 480, (VIXFBMode)1, 0, 0, { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }, { 0, 0, 21, 22, 21, 0, 0 } -}; - +// XXX, this should be some struct? +GXRenderModeObj GXNtsc480IntDf; +GXRenderModeObj GXNtsc480Int; void GXPeekZ(u16 x, u16 y, u32* z) { puts("GXPeekZ is a stub"); + *z = 0; } - void GXReadXfRasMetric(u32* xf_wait_in, u32* xf_wait_out, u32* ras_busy, u32* clocks) { puts("GXReadXfRasMetric is a stub"); + *xf_wait_in = 0; + *xf_wait_out = 0; + *ras_busy = 0; + *clocks = 0; } - void GXSetClipMode(GXClipMode mode) { puts("GXSetClipMode is a stub"); } - void GXSetCoPlanar(GXBool enable) { puts("GXSetCoPlanar is a stub"); } - void GXSetCopyClamp(GXFBClamp clamp) { puts("GXSetCopyClamp is a stub"); } - OSThread* GXSetCurrentGXThread(void) { puts("GXSetCurrentGXThread is a stub"); return NULL; } - -void GXSetFogRangeAdj(GXBool enable, u16 center, const GXFogAdjTable* table) { +void GXSetFogRangeAdj(GXBool enable, u16 center, const GXFogAdjTable *table) { puts("GXSetFogRangeAdj is a stub"); } - void GXSetMisc(GXMiscToken token, u32 val) { puts("GXSetMisc is a stub"); } - void GXSetPointSize(u8 pointSize, GXTexOffset texOffsets) { puts("GXSetPointSize is a stub"); } - void GXSetProjectionv(const f32* ptr) { puts("GXSetProjectionv is a stub"); } - void GXSetVtxAttrFmtv(GXVtxFmt vtxfmt, const GXVtxAttrFmtList* list) { puts("GXSetVtxAttrFmtv is a stub"); } +# pragma mark KPAD +// is this actually used? +extern "C" void KPADDisableDPD(s32) { + puts("KPADDisableDPD is a stub"); + +} +extern "C" void KPADEnableDPD(s32) { + puts("KPADEnableDPD is a stub"); +} + +// LC (consolidated above) void LCDisable(void) { puts("LCDisable is a stub"); } - -void LCQueueWait(u32 len) { +void LCQueueWait(__REGISTER u32 len) { puts("LCQueueWait is a stub"); } - u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes) { puts("LCStoreData is a stub"); return 0; } -void* OSAllocFromArenaLo(u32 size, u32 align) { - puts("OSAllocFromArenaLo is a stub"); - return NULL; -} +# pragma mark PPC Arch +// MSR stuff? +void PPCHalt() { puts("PPCHalt is a stub"); } -void OSCancelAlarm(OSAlarm *alarm) { - puts("OSCancelAlarm is a stub"); -} - -void OSCancelThread(OSThread* thread) { - puts("OSCancelThread is a stub"); -} - -s32 OSCheckActiveThreads(void) { - puts("OSCheckActiveThreads is a stub"); - return 0; -} - -void OSCreateAlarm(OSAlarm* alarm) { - puts("OSCreateAlarm is a stub"); -} - -int OSCreateThread(OSThread* thread, void* (*func)(void*), void* param, void* stack, u32 stackSize, OSPriority priority, u16 attr) { - puts("OSCreateThread is a stub"); - return 0; -} - -void OSDetachThread(OSThread* thread) { - puts("OSDetachThread is a stub"); -} - -s32 OSDisableScheduler(void) { - puts("OSDisableScheduler is a stub"); - return 0; -} - -BOOL OSEnableInterrupts(void) { - puts("OSEnableInterrupts is a stub"); - return FALSE; -} - -s32 OSEnableScheduler(void) { - puts("OSEnableScheduler is a stub"); - return 0; -} - -void OSExitThread(void* val) { - puts("OSExitThread is a stub"); -} - -void OSFillFPUContext(OSContext* context) { - puts("OSFillFPUContext is a stub"); -} - -void* OSGetArenaHi(void) { - puts("OSGetArenaHi is a stub"); - return NULL; -} - -void* OSGetArenaLo(void) { - puts("OSGetArenaLo is a stub"); - return NULL; -} - -OSContext* OSGetCurrentContext(void) { - puts("OSGetCurrentContext is a stub"); - return NULL; -} - -u32 OSGetProgressiveMode(void) { - puts("OSGetProgressiveMode is a stub"); - return 0; -} - -u32 OSGetResetCode() { - puts("OSGetResetCode is a stub"); - return 0; -} - -BOOL OSGetResetSwitchState(void) { - puts("OSGetResetSwitchState is a stub"); - return FALSE; -} - -s32 OSGetThreadPriority(OSThread* thread) { - puts("OSGetThreadPriority is a stub"); - return 0; -} - -OSTick OSGetTick(void) { - puts("OSGetTick is a stub"); - return 0; -} - -OSTime OSGetTime(void) { - puts("OSGetTime is a stub"); - return 0; -} - -void OSInit(void) { - puts("OSInit is a stub"); -} - -void* OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps) { - puts("OSInitAlloc is a stub"); - return NULL; -} - -void OSInitCond(OSCond* cond) { - puts("OSInitCond is a stub"); -} - -void OSInitMessageQueue(OSMessageQueue* mq, void* msgArray, s32 msgCount) { - puts("OSInitMessageQueue is a stub"); -} - -void OSInitMutex(OSMutex* mutex) { - puts("OSInitMutex is a stub"); -} - -void OSInitThreadQueue(OSThreadQueue* queue) { - puts("OSInitThreadQueue is a stub"); -} - -BOOL OSIsThreadTerminated(OSThread* thread) { - puts("OSIsThreadTerminated is a stub"); - return FALSE; -} - -int OSJamMessage(OSMessageQueue* mq, void* msg, s32 flags) { - puts("OSJamMessage is a stub"); - return 0; -} - -BOOL OSLinkFixed(OSModuleInfo* newModule, void* bss) { - puts("OSLinkFixed is a stub"); - return FALSE; -} - -void OSLockMutex(OSMutex* mutex) { - puts("OSLockMutex is a stub"); -} - -void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control) { - puts("OSProtectRange is a stub"); -} - -int OSReceiveMessage(OSMessageQueue* mq, void* msg, s32 flags) { - puts("OSReceiveMessage is a stub"); - return 0; -} - -int OSSendMessage(OSMessageQueue* mq, void* msg, s32 flags) { - puts("OSSendMessage is a stub"); - return 0; -} - -void OSSetAlarm(OSAlarm* alarm, OSTime tick, OSAlarmHandler handler) { - puts("OSSetAlarm is a stub"); -} - -void OSSetArenaHi(void* newHi) { - puts("OSSetArenaHi is a stub"); -} - -void OSSetArenaLo(void* newLo) { - puts("OSSetArenaLo is a stub"); -} - -OSErrorHandler OSSetErrorHandler(OSError error, OSErrorHandler handler) { - puts("OSSetErrorHandler is a stub"); - return NULL; -} - -void OSSetPeriodicAlarm(OSAlarm* alarm, OSTime start, OSTime period, OSAlarmHandler handler) { - puts("OSSetPeriodicAlarm is a stub"); -} - -void OSSetProgressiveMode(u32 on) { - puts("OSSetProgressiveMode is a stub"); -} - -void OSSetSaveRegion(void* start, void* end) { - puts("OSSetSaveRegion is a stub"); -} - -OSSwitchThreadCallback OSSetSwitchThreadCallback(OSSwitchThreadCallback callback) { - puts("OSSetSwitchThreadCallback is a stub"); - return NULL; -} - -int OSSetThreadPriority(OSThread* thread, OSPriority priority) { - puts("OSSetThreadPriority is a stub"); - return 0; -} - -void OSSignalCond(OSCond* cond) { - puts("OSSignalCond is a stub"); -} - -void OSSleepThread(OSThreadQueue* queue) { - puts("OSSleepThread is a stub"); -} - -BOOL OSTryLockMutex(OSMutex* mutex) { - puts("OSTryLockMutex is a stub"); - return FALSE; -} - -void OSUnlockMutex(OSMutex* mutex) { - puts("OSUnlockMutex is a stub"); -} - -void OSWaitCond(OSCond* cond, OSMutex* mutex) { - puts("OSWaitCond is a stub"); -} - -void OSYieldThread(void) { - puts("OSYieldThread is a stub"); +extern "C" void PPCSync(void) { + // puts("PPCSync is a stub"); } u32 PPCMfhid2() { @@ -1136,185 +1599,63 @@ void PPCMtmsr(u32 newMSR) { puts("PPCMtmsr is a stub"); } -void PSMTXConcat(const Mtx a, const Mtx b, Mtx ab) { - puts("PSMTXConcat is a stub"); -} - -void PSMTXCopy(const Mtx src, Mtx dst) { - puts("PSMTXCopy is a stub"); -} - -void PSMTXIdentity(Mtx m) { - puts("PSMTXIdentity is a stub"); -} - -u32 PSMTXInverse(const Mtx src, Mtx inv) { - puts("PSMTXInverse is a stub"); - return 0; -} - -void PSMTXMultVec(const Mtx m, const Vec* src, Vec* dst) { - puts("PSMTXMultVec is a stub"); -} - -void PSMTXMultVecArray(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) { - puts("PSMTXMultVecArray is a stub"); -} - -void PSMTXMultVecArraySR(const Mtx m, const Vec* srcBase, Vec* dstBase, u32 count) { - puts("PSMTXMultVecArraySR is a stub"); -} - -void PSMTXMultVecSR(const Mtx m, const Vec* src, Vec* dst) { - puts("PSMTXMultVecSR is a stub"); -} - -void PSMTXQuat(Mtx m, const Quaternion* q) { - puts("PSMTXQuat is a stub"); -} - -void PSMTXRotAxisRad(Mtx m, const Vec* axis, f32 rad) { - puts("PSMTXRotAxisRad is a stub"); -} - -void PSMTXRotRad(Mtx m, char axis, f32 rad) { - puts("PSMTXRotRad is a stub"); -} - -void PSMTXScale(Mtx m, f32 xS, f32 yS, f32 zS) { - puts("PSMTXScale is a stub"); -} - -void PSMTXScaleApply(const Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS) { - puts("PSMTXScaleApply is a stub"); -} - -void PSMTXTrans(Mtx m, f32 xT, f32 yT, f32 zT) { - puts("PSMTXTrans is a stub"); -} - -void PSMTXTransApply(const Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT) { - puts("PSMTXTransApply is a stub"); -} - -void PSQUATMultiply(const Quaternion* p, const Quaternion* q, Quaternion* pq) { - puts("PSQUATMultiply is a stub"); -} - -void PSVECAdd(const Vec* a, const Vec* b, Vec* ab) { - puts("PSVECAdd is a stub"); -} - -void PSVECCrossProduct(const Vec* a, const Vec* b, Vec* axb) { - puts("PSVECCrossProduct is a stub"); -} - -f32 PSVECDistance(const Vec* a, const Vec* b) { - puts("PSVECDistance is a stub"); - return 0.f; -} - -f32 PSVECDotProduct(const Vec* a, const Vec* b) { - puts("PSVECDotProduct is a stub"); - return 0.f; -} - -f32 PSVECMag(const Vec* v) { - puts("PSVECMag is a stub"); - return 0.f; -} - -void PSVECNormalize(const Vec* src, Vec* unit) { - puts("PSVECNormalize is a stub"); -} - -void PSVECScale(const Vec* src, Vec* dst, f32 scale) { - puts("PSVECScale is a stub"); -} - -f32 PSVECSquareDistance(const Vec* a, const Vec* b) { - puts("PSVECSquareDistance is a stub"); - return 0.f; -} - -f32 PSVECSquareMag(const Vec* v) { - puts("PSVECSquareMag is a stub"); - return 0.f; -} - -void PSVECSubtract(const Vec* a, const Vec* b, Vec* a_b) { - puts("PSVECSubtract is a stub"); -} - -void* VIGetCurrentFrameBuffer(void) { - puts("VIGetCurrentFrameBuffer is a stub"); - return NULL; -} - -u32 VIGetDTVStatus(void) { - puts("VIGetDTVStatus is a stub"); - return 0; -} - -void* VIGetNextFrameBuffer(void) { - puts("VIGetNextFrameBuffer is a stub"); - return NULL; -} - -VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback cb) { - puts("VISetPreRetraceCallback is a stub"); - return NULL; +# pragma mark WPAD +// uh.. this is revolution include not dolphin? +typedef void (*WPADExtensionCallback)(s32 chan, s32 devType); +extern "C" WPADExtensionCallback WPADSetExtensionCallback(s32 chan, WPADExtensionCallback cb) { + puts("WPADSetExtensionCallback is a stub"); + return cb; } +# pragma mark GF +#include void GFSetZMode(u8 compare_enable, GXCompare func, u8 update_enable) { puts("GFSetZMode is a stub"); } - void GFSetGenMode2(u8 nTexGens, u8 nChans, u8 nTevs, u8 nInds, GXCullMode cm) { puts("GFSetGenMode2 is a stub"); } - -void OSSwitchFiberEx(u32 a, u32 b, u32 c, u32 d, u32 e, u32 f) { - puts("OSSwitchFiberEx is a stub"); -} - void GFSetTevColorS10(GXTevRegID reg, GXColorS10 color) { puts("GFSetTevColorS10 is a stub"); } - void GFSetBlendModeEtc(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor dst_factor, GXLogicOp logic_op, u8 color_update_enable, u8 alpha_update_enable, u8 dither_enable) { puts("GFSetBlendModeEtc is a stub"); } - void GFSetChanAmbColor(GXChannelID chan, GXColor color) { puts("GFSetChanAmbColor is a stub"); } - -void J3DPSMtxArrayConcat(f32 (*a)[4], f32 (*b)[4], f32 (*c)[4], u32 d) { - puts("J3DPSMtxArrayConcat is a stub"); -} - -void __dcbz(void* a, int b) { - puts("__dcbz is a stub"); -} - void GFSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color) { puts("GFSetFog is a stub"); } -int __cntlzw(unsigned int a) { - puts("__cntlzw is a stub"); - return 0; +# pragma mark DEBUGPAD +#include +dDebugPad_c::dDebugPad_c() { + puts("constructing debug pad, stubbed?"); } -void* __memcpy(void* a, const void* b, int c) { - puts("__cntlzw is a stub"); - return NULL; +# pragma mark f_ap +#include +u8 fapGm_HIO_c::mCaptureScreenDivH = 1; + +# pragma mark dMsgObject +#include +void dMsgObject_c::setSelectWordFlag(u8 flag) { + puts("dMsgObject_c::setSelectWordFlag is a stub"); +} +void dMsgObject_c::setWord(const char* i_word) { + puts("dMsgObject_c::setWord is a stub"); +} +void dMsgObject_c::setSelectWord(int i_no, const char* i_word) { + puts("dMsgObject_c::setSelectWord is a stub"); } +#pragma mark HIO +#include +#include BOOL HIO2Close(s32 handle) { puts("HIO2Close is a stub"); return FALSE; @@ -1354,3 +1695,44 @@ BOOL HIOWrite(u32 addr, void* buffer, s32 size) { puts("HIOWrite is a stub"); return FALSE; } + +#pragma mark JHICommBuf +#include +void JHICommBufHeader::init() { + puts("JHICommBufHeader::init is a stub"); +} + +int JHICommBufHeader::load() { + puts("JHICommBufHeader::load is a stub"); +} + +int JHICommBufReader::read(void*, int) { + puts("JHICommBufReader::read is a stub"); + return 0; +} +void JHICommBufReader::readEnd() { + puts("JHICommBufReader::readEnd is a stub"); +} + +int JHICommBufReader::readBegin() { + puts("JHICommBufReader::readBegin is a stub"); +} + +int JHICommBufWriter::writeBegin() { + puts("JHICommBufWriter::writeBegin is a stub"); + return 0; +} + +int JHICommBufWriter::write(void*, int) { + puts("JHICommBufWriter::write is a stub"); + return 0; +} + +void JHICommBufWriter::writeEnd() { + puts("JHICommBufWriter::writeEnd is a stub"); +} + +u32 JHICommBufReader::Header::getReadableSize() const { + puts("JHICommBufReader::Header::getReadableSize is a stub"); + return 0; +} diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 748959eb67..9f753ef4a9 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -774,9 +774,16 @@ void main01(void) { } while (true); } +#if !__MWERKS__ +template +JHIComPortManager* JHIComPortManager::instance = nullptr; + +template<> +JHIComPortManager* JHIComPortManager::instance = nullptr; +#endif + #if DEBUG JHIComPortManager* JHIComPortManager:: instance; - // DEBUG NONMATCHING void parse_args(int argc, const char* argv[]) { int i;