mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-09-06 18:01:01 -04:00
m_Do_lib OK (#278)
This commit is contained in:
+87
-125
@@ -1,89 +1,40 @@
|
||||
//
|
||||
// Generated By: dol2asm
|
||||
// Translation Unit: m_Do/m_Do_lib
|
||||
//
|
||||
/**
|
||||
* m_Do_lib.cpp
|
||||
* View and Projection Matrix Helper Functions
|
||||
*/
|
||||
|
||||
#include "m_Do/m_Do_lib.h"
|
||||
#include "JSystem/JMath/JMATrigonometric.h"
|
||||
#include "JSystem/JUtility/JUTTexture.h"
|
||||
#include "SSystem/SComponent/c_math.h"
|
||||
#include "d/com/d_com_inf_game.h"
|
||||
#include "dol2asm.h"
|
||||
#include "dolphin/types.h"
|
||||
|
||||
//
|
||||
// Forward References:
|
||||
//
|
||||
|
||||
extern "C" void mDoLib_setResTimgObj__FPC7ResTIMGP9_GXTexObjUlP10_GXTlutObj();
|
||||
extern "C" void setup__14mDoLib_clipperFffff();
|
||||
extern "C" void mDoLib_project__FP3VecP3Vec();
|
||||
extern "C" void mDoLib_pos2camera__FP3VecP3Vec();
|
||||
extern "C" void __sinit_m_Do_lib_cpp();
|
||||
extern "C" void __dt__11J3DUClipperFv();
|
||||
extern "C" u8 mClipper__14mDoLib_clipper[92];
|
||||
extern "C" f32 mSystemFar__14mDoLib_clipper;
|
||||
extern "C" f32 mFovyRate__14mDoLib_clipper;
|
||||
|
||||
//
|
||||
// External References:
|
||||
//
|
||||
|
||||
extern "C" void init__11J3DUClipperFv();
|
||||
extern "C" void calcViewFrustum__11J3DUClipperFv();
|
||||
extern "C" void __dl__FPv();
|
||||
extern "C" void __register_global_object();
|
||||
extern "C" void _savegpr_29();
|
||||
extern "C" void _restgpr_29();
|
||||
extern "C" extern u8 g_dComIfG_gameInfo[122384];
|
||||
extern "C" u8 sincosTable___5JMath[65536];
|
||||
|
||||
//
|
||||
// Declarations:
|
||||
//
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 80451B70-80451B74 000170 0004+00 1/1 0/0 0/0 .sdata2 @3634 */
|
||||
SECTION_SDATA2 static f32 lit_3634 = 0.125f;
|
||||
|
||||
/* 80451B74-80451B78 000174 0004+00 1/1 0/0 0/0 .sdata2 @3635 */
|
||||
SECTION_SDATA2 static f32 lit_3635 = 1.0f / 100.0f;
|
||||
|
||||
/* 80451B78-80451B80 000178 0008+00 1/1 0/0 0/0 .sdata2 @3638 */
|
||||
SECTION_SDATA2 static f64 lit_3638 = 4503601774854144.0 /* cast s32 to float */;
|
||||
|
||||
/* 8001513C-8001528C 00FA7C 0150+00 0/0 3/3 2/2 .text
|
||||
* mDoLib_setResTimgObj__FPC7ResTIMGP9_GXTexObjUlP10_GXTlutObj */
|
||||
#ifdef NONMATCHING
|
||||
bool mDoLib_setResTimgObj(ResTIMG const* res, _GXTexObj* o_texObj, u32 param_2,
|
||||
_GXTlutObj* o_tlutObj) {
|
||||
if (res->indexTexture) {
|
||||
GXInitTlutObj(o_tlutObj, (void*)(res + res->paletteOffset), (GXTlutFmt)res->colorFormat,
|
||||
res->numColors);
|
||||
GXInitTexObjCI(o_texObj, (void*)(res + res->imageOffset), res->width, res->height,
|
||||
(GXCITexFmt)res->format, (GXTexWrapMode)res->wrapS,
|
||||
(GXTexWrapMode)res->wrapT, 1 - res->mipmapCount, param_2);
|
||||
} else {
|
||||
GXInitTexObj(o_texObj, (void*)(res + res->imageOffset), res->width, res->height,
|
||||
(GXTexFmt)res->format, (GXTexWrapMode)res->wrapS, (GXTexWrapMode)res->wrapT,
|
||||
(s32)1 - res->mipmapCount);
|
||||
}
|
||||
GXInitTexObjLOD(o_texObj, (GXTexFilter)res->minFilter, (GXTexFilter)res->magFilter,
|
||||
(f32)res->minLOD * 0.125f, (f32)res->maxLOD * 0.125f, (f32)res->LODBias * 0.01f,
|
||||
(s32)res->biasClamp, (s32)res->doEdgeLOD, (GXAnisotropy)res->maxAnisotropy);
|
||||
u8 mDoLib_setResTimgObj(ResTIMG const* res, _GXTexObj* o_texObj, u32 tlut_name,
|
||||
_GXTlutObj* o_tlutObj) {
|
||||
ResTIMG* _res = (ResTIMG*)res;
|
||||
|
||||
return res->indexTexture;
|
||||
if (_res->indexTexture) {
|
||||
GXInitTlutObj(o_tlutObj, (void*)((u8*)_res + _res->paletteOffset),
|
||||
(GXTlutFmt)_res->colorFormat, _res->numColors);
|
||||
GXInitTexObjCI(o_texObj, (void*)((u8*)_res + _res->imageOffset), _res->width, _res->height,
|
||||
(GXCITexFmt)_res->format, (GXTexWrapMode)_res->wrapS,
|
||||
(GXTexWrapMode)_res->wrapT, _res->mipmapCount > 1, tlut_name);
|
||||
} else {
|
||||
GXInitTexObj(o_texObj, (void*)((u8*)_res + _res->imageOffset), _res->width, _res->height,
|
||||
(GXTexFmt)_res->format, (GXTexWrapMode)_res->wrapS, (GXTexWrapMode)_res->wrapT,
|
||||
_res->mipmapCount > 1);
|
||||
}
|
||||
GXInitTexObjLOD(o_texObj, (GXTexFilter)_res->minFilter, (GXTexFilter)_res->magFilter,
|
||||
(f32)_res->minLOD * 0.125f, (f32)_res->maxLOD * 0.125f,
|
||||
(f32)_res->LODBias * 0.01f, (s32)_res->biasClamp, (s32)_res->doEdgeLOD,
|
||||
(GXAnisotropy)_res->maxAnisotropy);
|
||||
|
||||
return _res->indexTexture;
|
||||
}
|
||||
#else
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm bool mDoLib_setResTimgObj(ResTIMG const* param_0, _GXTexObj* param_1, u32 param_2,
|
||||
_GXTlutObj* param_3) {
|
||||
nofralloc
|
||||
#include "asm/m_Do/m_Do_lib/mDoLib_setResTimgObj__FPC7ResTIMGP9_GXTexObjUlP10_GXTlutObj.s"
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
/* 803DD8E4-803DD940 00A604 005C+00 2/2 5/5 5/5 .bss mClipper__14mDoLib_clipper */
|
||||
J3DUClipper mDoLib_clipper::mClipper;
|
||||
@@ -94,9 +45,6 @@ f32 mDoLib_clipper::mSystemFar;
|
||||
/* 80450C74-80450C78 000174 0004+00 1/1 1/1 0/0 .sbss mFovyRate__14mDoLib_clipper */
|
||||
f32 mDoLib_clipper::mFovyRate;
|
||||
|
||||
/* 80451B80-80451B84 000180 0004+00 1/1 0/0 0/0 .sdata2 @3739 */
|
||||
SECTION_SDATA2 static f32 lit_3739 = 182.04444885253906f;
|
||||
|
||||
/* 8001528C-80015310 00FBCC 0084+00 0/0 1/1 0/0 .text setup__14mDoLib_clipperFffff */
|
||||
void mDoLib_clipper::setup(f32 fovy, f32 aspect, f32 near, f32 far) {
|
||||
mClipper.setFovy(fovy);
|
||||
@@ -111,56 +59,70 @@ void mDoLib_clipper::setup(f32 fovy, f32 aspect, f32 near, f32 far) {
|
||||
mFovyRate = cM_scos(tmp) / cM_ssin(tmp);
|
||||
}
|
||||
|
||||
/* ############################################################################################## */
|
||||
/* 80451B84-80451B88 000184 0004+00 2/2 0/0 0/0 .sdata2 @3784 */
|
||||
SECTION_SDATA2 static u8 lit_3784[4] = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
/* 80451B88-80451B8C 000188 0004+00 1/1 0/0 0/0 .sdata2 @3785 */
|
||||
SECTION_SDATA2 static f32 lit_3785 = 500000.0f;
|
||||
|
||||
/* 80451B8C-80451B90 00018C 0004+00 1/1 0/0 0/0 .sdata2 @3786 */
|
||||
SECTION_SDATA2 static f32 lit_3786 = 0.5f;
|
||||
|
||||
/* 80451B90-80451B94 000190 0004+00 1/1 0/0 0/0 .sdata2 @3787 */
|
||||
SECTION_SDATA2 static f32 lit_3787 = 2.0f;
|
||||
|
||||
/* 80451B94-80451B98 000194 0004+00 1/1 0/0 0/0 .sdata2 @3788 */
|
||||
SECTION_SDATA2 static f32 lit_3788 = 304.0f;
|
||||
|
||||
/* 80451B98-80451B9C 000198 0004+00 1/1 0/0 0/0 .sdata2 @3789 */
|
||||
SECTION_SDATA2 static f32 lit_3789 = 608.0f;
|
||||
|
||||
/* 80451B9C-80451BA0 00019C 0004+00 1/1 0/0 0/0 .sdata2 @3790 */
|
||||
SECTION_SDATA2 static f32 lit_3790 = 224.0f;
|
||||
|
||||
/* 80451BA0-80451BA8 0001A0 0004+04 1/1 0/0 0/0 .sdata2 @3791 */
|
||||
SECTION_SDATA2 static f32 lit_3791[1 + 1 /* padding */] = {
|
||||
448.0f,
|
||||
/* padding */
|
||||
0.0f,
|
||||
};
|
||||
|
||||
/* 80015310-800154EC 00FC50 01DC+00 0/0 21/21 23/23 .text mDoLib_project__FP3VecP3Vec */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void mDoLib_project(Vec* param_0, Vec* param_1) {
|
||||
nofralloc
|
||||
#include "asm/m_Do/m_Do_lib/mDoLib_project__FP3VecP3Vec.s"
|
||||
void mDoLib_project(Vec* src, Vec* dst) {
|
||||
if (dComIfGd_getView() == NULL) {
|
||||
dst->x = 0.0f;
|
||||
dst->y = 0.0f;
|
||||
dst->z = 0.0f;
|
||||
return;
|
||||
}
|
||||
Mtx44* projMtx = dComIfGd_getProjViewMtx();
|
||||
Vec multVec;
|
||||
cMtx_multVec(*projMtx, src, &multVec);
|
||||
|
||||
float calcFloat = (src->x * (*dComIfGd_getProjViewMtx())[3][0]) +
|
||||
(src->y * (*dComIfGd_getProjViewMtx())[3][1]) +
|
||||
(src->z * (*dComIfGd_getProjViewMtx())[3][2]) +
|
||||
(*dComIfGd_getProjViewMtx())[3][3];
|
||||
if (multVec.z >= 0.0f) {
|
||||
multVec.z = 0.0f;
|
||||
}
|
||||
float f3;
|
||||
if (calcFloat <= 0.0f) {
|
||||
if (calcFloat == 0.0f) {
|
||||
dst->z = multVec.z * 500000.0f;
|
||||
} else {
|
||||
dst->z = multVec.z * (0.5f / calcFloat);
|
||||
}
|
||||
f3 = 500000.0f;
|
||||
} else {
|
||||
f3 = 0.5f / calcFloat;
|
||||
dst->z = multVec.z * f3;
|
||||
}
|
||||
|
||||
view_port_class* viewPort = dComIfGd_getViewport();
|
||||
float xOffset;
|
||||
float yOffset;
|
||||
float xSize;
|
||||
float ySize;
|
||||
if (viewPort->mXOrig != 0.0f) {
|
||||
xOffset = (0.5f * ((2.0f * viewPort->mXOrig) + viewPort->mWidth)) - 304.0f;
|
||||
xSize = 608.0f;
|
||||
} else {
|
||||
xOffset = viewPort->mXOrig;
|
||||
xSize = viewPort->mWidth;
|
||||
}
|
||||
|
||||
if (viewPort->mYOrig != 0.0f) {
|
||||
yOffset = (0.5f * ((2.0f * viewPort->mYOrig) + viewPort->mHeight)) - 224.0f;
|
||||
ySize = 448.0f;
|
||||
} else {
|
||||
yOffset = viewPort->mYOrig;
|
||||
ySize = viewPort->mHeight;
|
||||
}
|
||||
|
||||
dst->x = ((0.5f + (multVec.x * f3)) * xSize) + xOffset;
|
||||
dst->y = ((0.5f + (multVec.y * (-f3))) * ySize) + yOffset;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
/* 800154EC-80015544 00FE2C 0058+00 0/0 2/2 9/9 .text mDoLib_pos2camera__FP3VecP3Vec */
|
||||
#pragma push
|
||||
#pragma optimization_level 0
|
||||
#pragma optimizewithasm off
|
||||
asm void mDoLib_pos2camera(Vec* param_0, Vec* param_1) {
|
||||
nofralloc
|
||||
#include "asm/m_Do/m_Do_lib/mDoLib_pos2camera__FP3VecP3Vec.s"
|
||||
void mDoLib_pos2camera(Vec* src, Vec* dst) {
|
||||
if (dComIfGd_getView() == NULL) {
|
||||
dst->x = 0.0f;
|
||||
dst->y = 0.0f;
|
||||
dst->z = 0.0f;
|
||||
return;
|
||||
}
|
||||
cMtx_multVec(dComIfGd_getView()->mViewMtx, src, dst);
|
||||
}
|
||||
#pragma pop
|
||||
Reference in New Issue
Block a user