diff options
| author | hatal175 <hatal175@users.noreply.github.com> | 2023-08-01 10:17:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-01 00:17:21 -0700 |
| commit | 2275eb710b4b0794f198059a7fd61db7499941ff (patch) | |
| tree | e4bb01dce37d78a88657b0240a247febbfa14c24 /libs | |
| parent | 396449b597bef772b4a79ef173671100e32ad5c1 (diff) | |
Work on J2DMaterialFactory (#394)
* Work on J2DMaterialFactory
* J3DUClipper OK
* Work on JAISoundStarter
* JAISoundHandles OK
* JAISoundInfo OK
* Fix JAISound::isStopping
* Work on J2DTextBoxEx
* dspproc OK
* osdsp OK
* osdsp_task OK
* Work on dsptask
* Import some JASCalc code
* JASCallback OK
* JASOscillator OK
* JASLfo OK
Diffstat (limited to 'libs')
22 files changed, 1357 insertions, 1143 deletions
diff --git a/libs/JSystem/J2DGraph/J2DMatBlock.cpp b/libs/JSystem/J2DGraph/J2DMatBlock.cpp index ffe8917633..c5c23c99ed 100644 --- a/libs/JSystem/J2DGraph/J2DMatBlock.cpp +++ b/libs/JSystem/J2DGraph/J2DMatBlock.cpp @@ -351,22 +351,17 @@ extern "C" void _restgpr_27(); extern "C" void _restgpr_28(); extern "C" void _restgpr_29(); extern "C" extern J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; -extern "C" extern u8 const j2dDefaultIndTexMtxInfo[28]; extern "C" extern J2DTevStageInfo const j2dDefaultTevStageInfo; extern "C" extern J2DIndTevStageInfo const j2dDefaultIndTevStageInfo; extern "C" extern void* __vt__11J2DIndBlock[14]; extern "C" extern GXColor j2dDefaultColInfo; extern "C" extern J2DTevOrderInfo j2dDefaultTevOrderInfoNull; -extern "C" extern u16 j2dDefaultIndTexOrderNull[1 + 1 /* padding */]; extern "C" extern J2DGXColorS10 j2dDefaultTevColor; -extern "C" extern u8 j2dDefaultIndTexCoordScaleInfo[2 + 2 /* padding */]; extern "C" extern GXColor j2dDefaultTevKColor; extern "C" extern J2DTevSwapModeInfo j2dDefaultTevSwapMode; -extern "C" extern J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable; extern "C" extern u8 data_804561A4; extern "C" extern J2DColorChanInfo j2dDefaultColorChanInfo; extern "C" extern u8 data_804561AC; -extern "C" extern u16 j2dDefaultAlphaCmp; // // Declarations: @@ -2583,7 +2578,7 @@ void J2DPEBlock::setGX() { } /* 802F18A0-802F1934 2EC1E0 0094+00 5/5 0/0 0/0 .text __ct__14J2DIndTevStageFv */ -// missing instruction +// should be inline #ifdef NONMATCHING J2DIndTevStage::J2DIndTevStage() { mFlags = J2DCalcIndTevStage(j2dDefaultIndTevStageInfo); @@ -2592,7 +2587,7 @@ J2DIndTevStage::J2DIndTevStage() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTevStage::J2DIndTevStage() { +asm void __ct__14J2DIndTevStageFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMatBlock/__ct__14J2DIndTevStageFv.s" } @@ -2600,9 +2595,16 @@ asm J2DIndTevStage::J2DIndTevStage() { #endif /* 802F1934-802F1940 2EC274 000C+00 5/5 0/0 0/0 .text __ct__19J2DTevSwapModeTableFv */ +// Should be inline +#ifdef NONMATCHING J2DTevSwapModeTable::J2DTevSwapModeTable() { field_0x0 = data_804561AC; } +#else +asm void __ct__19J2DTevSwapModeTableFv() { + #include "asm/JSystem/J2DGraph/J2DMatBlock/__ct__19J2DTevSwapModeTableFv.s" +} +#endif /* 802F1940-802F19A8 2EC280 0068+00 5/5 1/1 0/0 .text __ct__11J2DTevStageFv */ J2DTevStage::J2DTevStage() { @@ -2620,12 +2622,27 @@ void J2DTevStage::setTevStageInfo(J2DTevStageInfo const& info) { } /* 802F1B70-802F1B90 2EC4B0 0020+00 5/5 0/0 0/0 .text __ct__11J2DTevOrderFv */ +// Matching but should be inline +#ifdef NONMATCHING J2DTevOrder::J2DTevOrder() { mTevOrderInfo = j2dDefaultTevOrderInfoNull; } +#else +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +// J2DTevOrder::J2DTevOrder() { +asm void __ct__11J2DTevOrderFv() { + nofralloc +#include "asm/JSystem/J2DGraph/J2DMatBlock/__ct__11J2DTevOrderFv.s" +} +#pragma pop +#endif /* 802F1B90-802F1B94 2EC4D0 0004+00 5/5 0/0 0/0 .text __ct__13J2DGXColorS10Fv */ -J2DGXColorS10::J2DGXColorS10() { +// Most likely inlined +//J2DGXColorS10::J2DGXColorS10() { +void __ct__13J2DGXColorS10Fv() { /* empty function */ } @@ -2687,7 +2704,7 @@ u32 J2DTevBlock16::getType() { } /* 802F1D24-802F1D2C 2EC664 0008+00 1/0 0/0 0/0 .text getMaxStage__13J2DTevBlock16Fv */ -s32 J2DTevBlock16::getMaxStage() { +u8 J2DTevBlock16::getMaxStage() { return 16; } @@ -2707,7 +2724,7 @@ void J2DTevBlock16::setFontNo(u16 fontNo) { } /* 802F1D54-802F1D5C 2EC694 0008+00 1/0 0/0 0/0 .text getFontNo__13J2DTevBlock16CFv */ -u32 J2DTevBlock16::getFontNo() const { +u16 J2DTevBlock16::getFontNo() const { return mFontNo; } @@ -2869,7 +2886,7 @@ u32 J2DTevBlock8::getType() { } /* 802F1FC4-802F1FCC 2EC904 0008+00 1/0 0/0 0/0 .text getMaxStage__12J2DTevBlock8Fv */ -s32 J2DTevBlock8::getMaxStage() { +u8 J2DTevBlock8::getMaxStage() { return 8; } @@ -2889,7 +2906,7 @@ void J2DTevBlock8::setFontNo(u16 fontNo) { } /* 802F1FF4-802F1FFC 2EC934 0008+00 1/0 0/0 0/0 .text getFontNo__12J2DTevBlock8CFv */ -u32 J2DTevBlock8::getFontNo() const { +u16 J2DTevBlock8::getFontNo() const { return mFontNo; } @@ -3051,7 +3068,7 @@ u32 J2DTevBlock4::getType() { } /* 802F2264-802F226C 2ECBA4 0008+00 1/0 0/0 0/0 .text getMaxStage__12J2DTevBlock4Fv */ -s32 J2DTevBlock4::getMaxStage() { +u8 J2DTevBlock4::getMaxStage() { return 4; } @@ -3071,7 +3088,7 @@ void J2DTevBlock4::setFontNo(u16 fontNo) { } /* 802F2294-802F229C 2ECBD4 0008+00 1/0 0/0 0/0 .text getFontNo__12J2DTevBlock4CFv */ -u32 J2DTevBlock4::getFontNo() const { +u16 J2DTevBlock4::getFontNo() const { return mFontNo; } @@ -3233,7 +3250,7 @@ u32 J2DTevBlock2::getType() { } /* 802F2508-802F2510 2ECE48 0008+00 1/0 0/0 0/0 .text getMaxStage__12J2DTevBlock2Fv */ -s32 J2DTevBlock2::getMaxStage() { +u8 J2DTevBlock2::getMaxStage() { return 2; } @@ -3253,7 +3270,7 @@ void J2DTevBlock2::setFontNo(u16 fontNo) { } /* 802F2538-802F2540 2ECE78 0008+00 1/0 0/0 0/0 .text getFontNo__12J2DTevBlock2CFv */ -u32 J2DTevBlock2::getFontNo() const { +u16 J2DTevBlock2::getFontNo() const { return mFontNo; } @@ -3415,7 +3432,7 @@ u32 J2DTevBlock1::getType() { } /* 802F27AC-802F27B4 2ED0EC 0008+00 1/0 0/0 0/0 .text getMaxStage__12J2DTevBlock1Fv */ -s32 J2DTevBlock1::getMaxStage() { +u8 J2DTevBlock1::getMaxStage() { return 1; } @@ -3435,7 +3452,7 @@ void J2DTevBlock1::setFontNo(u16 fontNo) { } /* 802F27DC-802F27E4 2ED11C 0008+00 1/0 0/0 0/0 .text getFontNo__12J2DTevBlock1CFv */ -u32 J2DTevBlock1::getFontNo() const { +u16 J2DTevBlock1::getFontNo() const { return mFontNo; } diff --git a/libs/JSystem/J2DGraph/J2DMaterial.cpp b/libs/JSystem/J2DGraph/J2DMaterial.cpp index a712ba9f12..3b5c00027b 100644 --- a/libs/JSystem/J2DGraph/J2DMaterial.cpp +++ b/libs/JSystem/J2DGraph/J2DMaterial.cpp @@ -86,16 +86,10 @@ extern "C" void getTevKonstReg__15J2DAnmTevRegKeyCFUsP8_GXColor(); extern "C" void __construct_array(); extern "C" void _savegpr_26(); extern "C" void _restgpr_26(); -extern "C" extern u8 const j2dDefaultTexCoordInfo[32]; extern "C" extern u8 const j2dDefaultTexMtxInfo[36]; -extern "C" extern u8 const j2dDefaultIndTexMtxInfo[28]; extern "C" extern void* __vt__15J2DIndBlockFull[14]; extern "C" extern void* __vt__11J2DTevBlock[47]; extern "C" extern void* __vt__14J2DTexGenBlock[3 + 1 /* padding */]; -extern "C" extern u16 j2dDefaultIndTexOrderNull[1 + 1 /* padding */]; -extern "C" extern u8 j2dDefaultIndTexCoordScaleInfo[2 + 2 /* padding */]; -extern "C" extern u32 j2dDefaultColorChanInfo; -extern "C" extern u16 j2dDefaultAlphaCmp; // // Declarations: @@ -561,7 +555,8 @@ void J2DIndBlock::setIndTexCoordScale(u32 param_0, J2DIndTexCoordScale param_1) #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DTexCoord::J2DTexCoord() { +//asm J2DTexCoord::J2DTexCoord() { +asm void __ct__11J2DTexCoordFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__ct__11J2DTexCoordFv.s" } @@ -571,17 +566,20 @@ asm J2DTexCoord::J2DTexCoord() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DColorChan::J2DColorChan() { +asm void __ct__12J2DColorChanFv() { +//asm J2DColorChan::J2DColorChan() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__ct__12J2DColorChanFv.s" } #pragma pop /* 802EB290-802EB2CC 2E5BD0 003C+00 1/1 1/1 0/0 .text __dt__19J2DIndTexCoordScaleFv */ +// Most likely inline #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTexCoordScale::~J2DIndTexCoordScale() { +// asm J2DIndTexCoordScale::~J2DIndTexCoordScale() { +asm void __dt__19J2DIndTexCoordScaleFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__dt__19J2DIndTexCoordScaleFv.s" } @@ -591,7 +589,8 @@ asm J2DIndTexCoordScale::~J2DIndTexCoordScale() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTexCoordScale::J2DIndTexCoordScale() { +//asm J2DIndTexCoordScale::J2DIndTexCoordScale() { +asm void __ct__19J2DIndTexCoordScaleFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__ct__19J2DIndTexCoordScaleFv.s" } @@ -601,7 +600,8 @@ asm J2DIndTexCoordScale::J2DIndTexCoordScale() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTexMtx::~J2DIndTexMtx() { +asm void __dt__12J2DIndTexMtxFv() { +//asm J2DIndTexMtx::~J2DIndTexMtx() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__dt__12J2DIndTexMtxFv.s" } @@ -611,17 +611,20 @@ asm J2DIndTexMtx::~J2DIndTexMtx() { #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTexMtx::J2DIndTexMtx() { +//asm J2DIndTexMtx::J2DIndTexMtx() { +asm void __ct__12J2DIndTexMtxFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__ct__12J2DIndTexMtxFv.s" } #pragma pop /* 802EB378-802EB390 2E5CB8 0018+00 1/1 0/0 0/0 .text __ct__14J2DIndTexOrderFv */ +// Most likely inline #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm J2DIndTexOrder::J2DIndTexOrder() { +//asm J2DIndTexOrder::J2DIndTexOrder() { +asm void __ct__14J2DIndTexOrderFv() { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterial/__ct__14J2DIndTexOrderFv.s" } diff --git a/libs/JSystem/J2DGraph/J2DMaterialFactory.cpp b/libs/JSystem/J2DGraph/J2DMaterialFactory.cpp index ab65ee3cb4..8ea44dd5b2 100644 --- a/libs/JSystem/J2DGraph/J2DMaterialFactory.cpp +++ b/libs/JSystem/J2DGraph/J2DMaterialFactory.cpp @@ -5,6 +5,9 @@ #include "JSystem/J2DGraph/J2DMaterialFactory.h" #include "JSystem/J2DGraph/J2DMaterial.h" +#include "JSystem/J2DGraph/J2DScreen.h" +#include "JSystem/JSupport/JSupport.h" +#include "JSystem/JUtility/JUTResource.h" #include "MSL_C/string.h" #include "dol2asm.h" #include "dolphin/types.h" @@ -13,14 +16,6 @@ // Types: // -struct JUTResReference { - /* 802DE120 */ void getResource(void const*, u32, JKRArchive*); -}; - -struct J2DScreen { - static u8 mDataManage[4 + 4 /* padding */]; -}; - // // Forward References: // @@ -88,17 +83,8 @@ extern "C" void _savegpr_19(); extern "C" void _savegpr_29(); extern "C" void _restgpr_19(); extern "C" void _restgpr_29(); -extern "C" extern u8 const j2dDefaultTexCoordInfo[32]; -extern "C" extern u8 const j2dDefaultIndTexMtxInfo[28]; -extern "C" extern u8 const j2dDefaultIndTevStageInfo[12]; extern "C" u8 mDataManage__9J2DScreen[4 + 4 /* padding */]; -extern "C" extern u32 j2dDefaultTevOrderInfoNull; -extern "C" extern u16 j2dDefaultIndTexOrderNull[1 + 1 /* padding */]; -extern "C" extern u8 j2dDefaultIndTexCoordScaleInfo[2 + 2 /* padding */]; extern "C" extern u8 j2dDefaultTevSwapMode[4]; -extern "C" extern u32 j2dDefaultTevSwapModeTable; -extern "C" extern u32 j2dDefaultColorChanInfo; -extern "C" extern u16 j2dDefaultAlphaCmp; // // Declarations: @@ -106,6 +92,39 @@ extern "C" extern u16 j2dDefaultAlphaCmp; /* 802F2AD0-802F2C94 2ED410 01C4+00 0/0 1/1 0/0 .text * __ct__18J2DMaterialFactoryFRC16J2DMaterialBlock */ +// JSUConvertOffsetToPtr issues. Probably function order. +#ifdef NONMATCHING +J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) { + field_0x0 = param_0.field_0x8; + field_0x4 = JSUConvertOffsetToPtr<J2DMaterialInitData>(¶m_0, (void*)param_0.field_0xc); + field_0x8 = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x10); + if (param_0.field_0x18 && param_0.field_0x18 - param_0.field_0x14 > 4) { + field_0xc = JSUConvertOffsetToPtr<J2DIndInitData>(¶m_0, (void*)param_0.field_0x18); + } + else { + field_0xc = NULL; + } + field_0x30 = JSUConvertOffsetToPtr<_GXCullMode>(¶m_0, (void*)param_0.field_0x1c); + field_0x10 = JSUConvertOffsetToPtr<GXColor>(¶m_0, (void*)param_0.field_0x20); + field_0x14 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x24); + field_0x18 = JSUConvertOffsetToPtr<J2DColorChanInfo>(¶m_0, (void*)param_0.field_0x28); + field_0x1c = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x2c); + field_0x20 = JSUConvertOffsetToPtr<J2DTexCoordInfo>(¶m_0, (void*)param_0.field_0x30); + field_0x24 = JSUConvertOffsetToPtr<J2DTexMtxInfo>(¶m_0, (void*)param_0.field_0x34); + field_0x28 = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x38); + field_0x2c = JSUConvertOffsetToPtr<u16>(¶m_0, (void*)param_0.field_0x3c); + field_0x34 = JSUConvertOffsetToPtr<J2DTevOrderInfo>(¶m_0, (void*)param_0.field_0x40); + field_0x38 = JSUConvertOffsetToPtr<J2DGXColorS10>(¶m_0, (void*)param_0.field_0x44); + field_0x3c = JSUConvertOffsetToPtr<GXColor>(¶m_0, (void*)param_0.field_0x48); + field_0x40 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x4c); + field_0x44 = JSUConvertOffsetToPtr<J2DTevStageInfo>(¶m_0, (void*)param_0.field_0x50); + field_0x48 = JSUConvertOffsetToPtr<J2DTevSwapModeInfo>(¶m_0, (void*)param_0.field_0x54); + field_0x4c = JSUConvertOffsetToPtr<J2DTevSwapModeTableInfo>(¶m_0, (void*)param_0.field_0x58); + field_0x50 = JSUConvertOffsetToPtr<J2DAlphaCompInfo>(¶m_0, (void*)param_0.field_0x5c); + field_0x54 = JSUConvertOffsetToPtr<J2DBlendInfo>(¶m_0, (void*)param_0.field_0x60); + field_0x58 = JSUConvertOffsetToPtr<u8>(¶m_0, (void*)param_0.field_0x64); +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -114,283 +133,421 @@ asm J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) { #include "asm/JSystem/J2DGraph/J2DMaterialFactory/__ct__18J2DMaterialFactoryFRC16J2DMaterialBlock.s" } #pragma pop +#endif /* 802F2C94-802F2D1C 2ED5D4 0088+00 1/1 0/0 0/0 .text countStages__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::countStages(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/countStages__18J2DMaterialFactoryCFi.s" +u32 J2DMaterialFactory::countStages(int param_0) const { + J2DMaterialInitData* iVar5 = &field_0x4[field_0x8[param_0]]; + u32 uVar4 = 0; + u32 uVar3 = 0; + if (iVar5->field_0x4 != 0xff) { + uVar3 = field_0x40[iVar5->field_0x4]; + } + for (int i = 0; i < 8; i++) { + if (iVar5->field_0x38[i] != 0xffff) { + uVar4++; + } + } + if ((uVar3 != uVar4 && uVar4 != 0)) { + if (uVar3 > uVar4) { + return uVar3; + } + return uVar4; + } + return uVar3; } -#pragma pop /* 802F2D1C-802F362C 2ED65C 0910+00 0/0 1/1 0/0 .text * create__18J2DMaterialFactoryCFP11J2DMaterialiUlP15J2DResReferenceP15J2DResReferenceP10JKRArchive */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::create(J2DMaterial* param_0, int param_1, u32 param_2, +// Stack issues +#ifdef NONMATCHING +J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 param_2, + J2DResReference* param_3, J2DResReference* param_4, + JKRArchive* param_5) const { + u32 stages = countStages(index); + u32 uVar1 = ((param_2 & 0x1f0000) >> 16); + u32 r28 = stages > uVar1 ? stages : uVar1; + + u32 r25 = r28 <= 8 ? r28 : 8; + + s32 local_3bc = ((param_2 & 0x1000000) != 0); + s32 local_3c0 = (param_2 & 0x1f0000) ? local_3bc : 0; + bool temp = (param_2 & 0x1f0000); + u16 tevBlockNum = r28; + param_0->mTevBlock = J2DMaterial::createTevBlock(tevBlockNum, temp); + param_0->mIndBlock = J2DMaterial::createIndBlock(local_3c0, temp); + param_0->mIndex = index; + param_0->field_0x8 = getMaterialMode(index); + param_0->getColorBlock()->setColorChanNum(newColorChanNum(index)); + param_0->getColorBlock()->setCullMode(newCullMode(index)); + param_0->getTexGenBlock()->setTexGenNum(newTexGenNum(index)); + param_0->getPEBlock()->setAlphaComp(newAlphaComp(index)); + param_0->getPEBlock()->setBlend(newBlend(index)); + param_0->getPEBlock()->setDither(newDither(index)); + param_0->getTevBlock()->setTevStageNum(newTevStageNum(index)); + param_0->mMaterialAlphaCalc = getMaterialAlphaCalc(index); + + JUTResReference aJStack_12c; + for (u8 i = 0; i < r25; i++) { + u16 texNo = newTexNo(index, i); + s8* local_37c = param_3->getResReference(texNo); + void* local_380 = NULL; + if (local_37c != NULL) { + local_380 = aJStack_12c.getResource(local_37c, 'TIMG', param_5); + if (local_380 == NULL && param_5 != NULL) { + local_380 = aJStack_12c.getResource(local_37c, 'TIMG', NULL); + } + if (local_380 == NULL && J2DScreen::getDataManage() != NULL) { + char acStack_230[256]; + strcpy(acStack_230, param_3->getName(texNo)); + local_380 = J2DScreen::getDataManage()->get(acStack_230); + } + } + param_0->getTevBlock()->insertTexture(i, (ResTIMG*)local_380); + param_0->getTevBlock()->setTexNo(i, texNo); + } + u16 fontNo = newFontNo(index); + param_0->getTevBlock()->setFontNo(fontNo); + + s8* local_384 = param_4->getResReference(param_0->getTevBlock()->getFontNo()); + void* local_388 = NULL; + if (local_384 != NULL) { + local_388 = aJStack_12c.getResource(local_384, 'FONT', param_5); + if (local_388 == NULL && param_5 != NULL) { + local_388 = aJStack_12c.getResource(local_384, 'FONT', NULL); + } + if (local_388 == NULL && J2DScreen::getDataManage() != NULL) { + char* pcVar9 = param_4->getName(param_0->getTevBlock()->getFontNo()); + char acStack_334[256]; + strcpy(acStack_334, pcVar9); + local_388 = J2DScreen::getDataManage()->get(acStack_334); + } + } + + param_0->getTevBlock()->setFont((ResFONT*)local_388); + for (u8 i = 0; i < r28; i++) { + param_0->getTevBlock()->setTevOrder(i, newTevOrder(index, i)); + } + for (u8 i = 0; i < r28; i++) { + J2DMaterialInitData* local_38c = &field_0x4[field_0x8[index]]; + param_0->getTevBlock()->setTevStage(i, newTevStage(index, i)); + if (local_38c->field_0xba[i] != 0xffff) { + param_0->getTevBlock()->getTevStage(i)->setTexSel(field_0x48[local_38c->field_0xba[i]].field_0x1); + param_0->getTevBlock()->getTevStage(i)->setRasSel(field_0x48[local_38c->field_0xba[i]].field_0x0); + } + } + for (u8 i = 0; i < 4; i++) { + param_0->getTevBlock()->setTevKColor(i, newTevKColor(index, i)); + } + for (u8 i = 0; i < 4; i++) { + J2DTevBlock* block = param_0->getTevBlock(); + block->setTevColor(i, newTevColor(index, i)); + } + for (u8 i = 0; i < 4; i++) { + param_0->getTevBlock()->setTevSwapModeTable(i, newTevSwapModeTable(index, i)); + } + for (u8 i = 0; i < 2; i++) { + param_0->getColorBlock()->setMatColor(i, newMatColor(index, i)); + } + for (u8 i = 0; i < 4; i++) { + param_0->getColorBlock()->setColorChan(i, newColorChan(index, i)); + } + for (u8 i = 0; i < 8; i++) { + param_0->getTexGenBlock()->setTexCoord(i, newTexCoord(index, i)); + } + for (u8 i = 0; i < 8; i++) { + param_0->getTexGenBlock()->setTexMtx(i, newTexMtx(index, i)); + } + J2DMaterialInitData* local_394 = &field_0x4[field_0x8[index]]; + for (u8 i = 0; i < r28; i++) { + param_0->getTevBlock()->setTevKColorSel(i, local_394->field_0x52[i]); + } + for (u8 i = 0; i < r28; i++) { + param_0->getTevBlock()->setTevKAlphaSel(i, local_394->field_0x62[i]); + } + if (field_0xc != NULL || local_3c0 != 0) { + u8 local_410 = newIndTexStageNum(index); + param_0->mIndBlock->setIndTexStageNum(local_410); + for (u8 i = 0; i < local_410; i++) { + param_0->getIndBlock()->setIndTexMtx(i, newIndTexMtx(index, i)); + } + for (u8 i = 0; i < local_410; i++) { + param_0->getIndBlock()->setIndTexOrder(i, newIndTexOrder(index, i)); + } + for (u8 i = 0; i < local_410; i++) { + param_0->getIndBlock()->setIndTexCoordScale(i, newIndTexCoordScale(index, i)); + } + for (u8 i = 0; i < r28; i++) { + param_0->getTevBlock()->setIndTevStage(i, newIndTevStage(index, i)); + } + } + return param_0; +} +#else +#pragma push +#pragma optimization_level 0 +#pragma optimizewithasm off +asm J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int param_1, u32 param_2, J2DResReference* param_3, J2DResReference* param_4, JKRArchive* param_5) const { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterialFactory/func_802F2D1C.s" } #pragma pop +#endif /* ############################################################################################## */ -/* 804561C0-804561C4 0047C0 0004+00 1/1 0/0 0/0 .sdata2 @1887 */ -SECTION_SDATA2 static u32 lit_1887 = 0xFFFFFFFF; /* 802F362C-802F36CC 2EDF6C 00A0+00 1/1 0/0 0/0 .text newMatColor__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newMatColor(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newMatColor__18J2DMaterialFactoryCFii.s" +JUtility::TColor J2DMaterialFactory::newMatColor(int param_0, int param_1) const { + GXColor color = {0xff,0xff,0xff,0xff}; + JUtility::TColor local_20 = GXColor(color); + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x8[param_1] != 0xffff) { + return field_0x10[iVar2->field_0x8[param_1]]; + } + return local_20; } -#pragma pop /* 802F36CC-802F3704 2EE00C 0038+00 1/1 0/0 0/0 .text newColorChanNum__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newColorChanNum(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newColorChanNum__18J2DMaterialFactoryCFi.s" +u8 J2DMaterialFactory::newColorChanNum(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x2 != 0xff) { + return field_0x14[iVar2->field_0x2]; + } + return 0; } -#pragma pop /* 802F3704-802F3758 2EE044 0054+00 1/1 0/0 0/0 .text newColorChan__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newColorChan(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newColorChan__18J2DMaterialFactoryCFii.s" +J2DColorChan J2DMaterialFactory::newColorChan(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0xc[param_1] != 0xffff) { + return J2DColorChan(field_0x18[iVar2->field_0xc[param_1]]); + } + return J2DColorChan(); } -#pragma pop /* 802F3758-802F3790 2EE098 0038+00 1/1 0/0 0/0 .text newTexGenNum__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTexGenNum(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTexGenNum__18J2DMaterialFactoryCFi.s" +u32 J2DMaterialFactory::newTexGenNum(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x3 != 0xff) { + return field_0x1c[iVar2->field_0x3]; + } + return 0; } -#pragma pop /* 802F3790-802F3804 2EE0D0 0074+00 1/1 0/0 0/0 .text newTexCoord__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTexCoord(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTexCoord__18J2DMaterialFactoryCFii.s" +J2DTexCoord J2DMaterialFactory::newTexCoord(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x14[param_1] != 0xffff) { + return J2DTexCoord(field_0x20[iVar2->field_0x14[param_1]]); + } + return J2DTexCoord(); } -#pragma pop /* 802F3804-802F38E0 2EE144 00DC+00 1/1 0/0 0/0 .text newTexMtx__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTexMtx(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTexMtx__18J2DMaterialFactoryCFii.s" +J2DTexMtx* J2DMaterialFactory::newTexMtx(int param_0, int param_1) const { + J2DTexMtx* rv = NULL; + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x24[param_1] != 0xffff) { + rv = new J2DTexMtx(field_0x24[iVar2->field_0x24[param_1]]); + rv->calc(); + } + return rv; } -#pragma pop /* 802F38E0-802F3920 2EE220 0040+00 1/1 0/0 0/0 .text newCullMode__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newCullMode(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newCullMode__18J2DMaterialFactoryCFi.s" +u8 J2DMaterialFactory::newCullMode(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x1 != 0xff) { + return field_0x30[iVar2->field_0x1]; + } + return 0xff; } -#pragma pop /* 802F3920-802F3968 2EE260 0048+00 1/1 0/0 0/0 .text newTexNo__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTexNo(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTexNo__18J2DMaterialFactoryCFii.s" +u16 J2DMaterialFactory::newTexNo(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x38[param_1] != 0xffff) { + return field_0x28[iVar2->field_0x38[param_1]]; + } + return 0x1FFFF; } -#pragma pop /* 802F3968-802F39A8 2EE2A8 0040+00 1/1 0/0 0/0 .text newFontNo__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newFontNo(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newFontNo__18J2DMaterialFactoryCFi.s" +u16 J2DMaterialFactory::newFontNo(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x48 != 0xffff) { + return field_0x2c[iVar2->field_0x48]; + } + return 0x1FFFF; } -#pragma pop /* 802F39A8-802F3A1C 2EE2E8 0074+00 1/1 0/0 0/0 .text newTevOrder__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTevOrder(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevOrder__18J2DMaterialFactoryCFii.s" +J2DTevOrder J2DMaterialFactory::newTevOrder(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x72[param_1] != 0xffff) { + return J2DTevOrder(field_0x34[iVar2->field_0x72[param_1]]); + } + return J2DTevOrder(); } -#pragma pop /* ############################################################################################## */ /* 80456BB0-80456BB4 000050 0004+00 1/1 0/0 0/0 .sbss2 @2018 */ -SECTION_SBSS2 static u8 lit_2018[4]; - -/* 80456BB4-80456BB8 000054 0004+00 1/1 0/0 0/0 .sbss2 None */ -SECTION_SBSS2 static u8 data_80456BB4[4]; +SECTION_SBSS2 static GXColorS10 lit_2018; /* 802F3A1C-802F3AB4 2EE35C 0098+00 1/1 0/0 0/0 .text newTevColor__18J2DMaterialFactoryCFii */ +// J2DGXColorS10 init issues +#ifdef NONMATCHING +J2DGXColorS10 J2DMaterialFactory::newTevColor(int param_0, int param_1) const { + GXColorS10 x = lit_2018; + J2DGXColorS10 rv = J2DGXColorS10(x); + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x92[param_1] != 0xffff) { + return field_0x38[iVar2->field_0x92[param_1]]; + } + return rv; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void J2DMaterialFactory::newTevColor(int param_0, int param_1) const { +asm J2DGXColorS10 J2DMaterialFactory::newTevColor(int param_0, int param_1) const { nofralloc #include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevColor__18J2DMaterialFactoryCFii.s" } #pragma pop +#endif /* ############################################################################################## */ -/* 804561C4-804561C8 0047C4 0004+00 1/1 0/0 0/0 .sdata2 @2039 */ -SECTION_SDATA2 static u32 lit_2039 = 0xFFFFFFFF; /* 802F3AB4-802F3B54 2EE3F4 00A0+00 1/1 0/0 0/0 .text newTevKColor__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTevKColor(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevKColor__18J2DMaterialFactoryCFii.s" +JUtility::TColor J2DMaterialFactory::newTevKColor(int param_0, int param_1) const { + GXColor x = {0xFF, 0xFF, 0xFF, 0xFF}; + JUtility::TColor local_20 = GXColor(x); + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x4a[param_1] != 0xffff) { + return field_0x3c[iVar2->field_0x4a[param_1]]; + } + return local_20; } -#pragma pop /* 802F3B54-802F3B8C 2EE494 0038+00 1/1 0/0 0/0 .text newTevStageNum__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTevStageNum(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevStageNum__18J2DMaterialFactoryCFi.s" +u8 J2DMaterialFactory::newTevStageNum(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x4 != 0xff) { + return field_0x40[iVar2->field_0x4]; + } + return 0xFF; } -#pragma pop /* 802F3B8C-802F3BEC 2EE4CC 0060+00 1/1 0/0 0/0 .text newTevStage__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTevStage(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevStage__18J2DMaterialFactoryCFii.s" +J2DTevStage J2DMaterialFactory::newTevStage(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x9a[param_1] != 0xffff) { + return J2DTevStage(field_0x44[iVar2->field_0x9a[param_1]]); + } + return J2DTevStage(); } -#pragma pop /* 802F3BEC-802F3C88 2EE52C 009C+00 1/1 0/0 0/0 .text * newTevSwapModeTable__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newTevSwapModeTable(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newTevSwapModeTable__18J2DMaterialFactoryCFii.s" +J2DTevSwapModeTable J2DMaterialFactory::newTevSwapModeTable(int param_0, int param_1) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0xda[param_1] != 0xffff) { + return J2DTevSwapModeTable(field_0x4c[iVar2->field_0xda[param_1]]); + } + return J2DTevSwapModeTable(j2dDefaultTevSwapModeTable); } -#pragma pop /* 802F3C88-802F3CB8 2EE5C8 0030+00 1/1 0/0 0/0 .text newIndTexStageNum__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newIndTexStageNum(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newIndTexStageNum__18J2DMaterialFactoryCFi.s" +u8 J2DMaterialFactory::newIndTexStageNum(int param_0) const { + if (field_0xc != NULL) { + if (field_0xc[param_0].field_0x0 == 1) { + return field_0xc[param_0].field_0x1; + } + } + return 0; } -#pragma pop /* 802F3CB8-802F3D20 2EE5F8 0068+00 1/1 0/0 0/0 .text newIndTexOrder__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newIndTexOrder(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newIndTexOrder__18J2DMaterialFactoryCFii.s" +J2DIndTexOrder J2DMaterialFactory::newIndTexOrder(int param_0, int param_1) const { + J2DIndTexOrder rv; + if (field_0xc != NULL) { + if (field_0xc[param_0].field_0x0 == 1) { + return J2DIndTexOrder(field_0xc[param_0].field_0x4[param_1]); + } + } + return rv; } -#pragma pop /* 802F3D20-802F3E24 2EE660 0104+00 1/1 0/0 0/0 .text newIndTexMtx__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newIndTexMtx(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newIndTexMtx__18J2DMaterialFactoryCFii.s" +J2DIndTexMtx J2DMaterialFactory::newIndTexMtx(int param_0, int param_1) const { + J2DIndTexMtx rv; + if (field_0xc != NULL) { + if (field_0xc[param_0].field_0x0 == 1) { + return J2DIndTexMtx(field_0xc[param_0].field_0xc[param_1]); + } + } + return rv; } -#pragma pop /* 802F3E24-802F3F78 2EE764 0154+00 1/1 0/0 0/0 .text newIndTevStage__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newIndTevStage(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newIndTevStage__18J2DMaterialFactoryCFii.s" +J2DIndTevStage J2DMaterialFactory::newIndTevStage(int param_0, int param_1) const { + J2DIndTevStage rv; + if (field_0xc != NULL) { + if (field_0xc[param_0].field_0x0 == 1) { + return J2DIndTevStage(field_0xc[param_0].field_0x68[param_1]); + } + } + return rv; } -#pragma pop /* 802F3F78-802F3FE0 2EE8B8 0068+00 1/1 0/0 0/0 .text * newIndTexCoordScale__18J2DMaterialFactoryCFii */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newIndTexCoordScale(int param_0, int param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newIndTexCoordScale__18J2DMaterialFactoryCFii.s" +J2DIndTexCoordScale J2DMaterialFactory::newIndTexCoordScale(int param_0, int param_1) const { + J2DIndTexCoordScale rv; + if (field_0xc != NULL) { + if (field_0xc[param_0].field_0x0 == 1) { + return J2DIndTexCoordScale(field_0xc[param_0].field_0x60[param_1]); + } + } + return rv; } -#pragma pop /* 802F3FE0-802F405C 2EE920 007C+00 1/1 0/0 0/0 .text newAlphaComp__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newAlphaComp(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newAlphaComp__18J2DMaterialFactoryCFi.s" +J2DAlphaComp J2DMaterialFactory::newAlphaComp(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0xe2 != 0xffff) { + return J2DAlphaComp(field_0x50[iVar2->field_0xe2]); + } + return J2DAlphaComp(); } -#pragma pop /* 802F405C-802F40D8 2EE99C 007C+00 1/1 0/0 0/0 .text newBlend__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newBlend(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newBlend__18J2DMaterialFactoryCFi.s" +J2DBlend J2DMaterialFactory::newBlend(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0xe4 != 0xffff) { + return J2DBlend(field_0x54[iVar2->field_0xe4]); + } + return J2DBlend(); } -#pragma pop /* 802F40D8-802F4110 2EEA18 0038+00 1/1 0/0 0/0 .text newDither__18J2DMaterialFactoryCFi */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DMaterialFactory::newDither(int param_0) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DMaterialFactory/newDither__18J2DMaterialFactoryCFi.s" +u8 J2DMaterialFactory::newDither(int param_0) const { + J2DMaterialInitData* iVar2 = &field_0x4[field_0x8[param_0]]; + if (iVar2->field_0x5 != 0xff) { + return field_0x58[iVar2->field_0x5]; + } + return 0; } -#pragma pop /* 802F4110-802F4170 2EEA50 0060+00 1/1 0/0 0/0 .text __ct__11J2DTevStageFRC15J2DTevStageInfo */ #pragma push diff --git a/libs/JSystem/J2DGraph/J2DTevs.cpp b/libs/JSystem/J2DGraph/J2DTevs.cpp index 1c1e3bba44..fa2f8cf815 100644 --- a/libs/JSystem/J2DGraph/J2DTevs.cpp +++ b/libs/JSystem/J2DGraph/J2DTevs.cpp @@ -20,7 +20,7 @@ struct J2DTevBlock { /* 802EA14C */ bool getTevKAlphaSel(u32); /* 802EA154 */ bool getTevKColorSel(u32); /* 802EA15C */ bool getTevKColor(u32); - /* 802EA164 */ u32 getFontNo() const; + /* 802EA164 */ u16 getFontNo() const; /* 802EA170 */ u32 getTexNo(u32) const; /* 802EA17C */ bool getTevStageNum() const; /* 802EA184 */ bool getIndTevStage(u32); @@ -64,20 +64,14 @@ extern "C" extern J2DTexCoordInfo const j2dDefaultTexCoordInfo[8]; extern "C" extern J2DTexMtxInfo const j2dDefaultTexMtxInfo; extern "C" extern J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo; extern "C" extern J2DTevStageInfo const j2dDefaultTevStageInfo; -extern "C" extern u8 const j2dDefaultIndTevStageInfo[12]; extern "C" extern u32 j2dDefaultColInfo; -extern "C" extern u32 j2dDefaultTevOrderInfoNull; -extern "C" extern u16 j2dDefaultIndTexOrderNull[1 + 1 /* padding */]; extern "C" extern u8 j2dDefaultTevColor[8]; -extern "C" extern u8 j2dDefaultIndTexCoordScaleInfo[2 + 2 /* padding */]; extern "C" extern u32 j2dDefaultTevKColor; extern "C" extern u8 j2dDefaultTevSwapMode[4]; -extern "C" extern u32 j2dDefaultTevSwapModeTable; extern "C" extern u32 j2dDefaultBlendInfo; extern "C" extern u8 data_804561A4[4]; extern "C" extern u32 j2dDefaultColorChanInfo; extern "C" extern u16 data_804561AC; -extern "C" extern u16 j2dDefaultAlphaCmp; // // External References: @@ -211,7 +205,7 @@ bool J2DTevBlock::getTevKColor(u32 param_0) { } /* 802EA164-802EA170 2E4AA4 000C+00 0/0 1/0 0/0 .text getFontNo__11J2DTevBlockCFv */ -u32 J2DTevBlock::getFontNo() const { +u16 J2DTevBlock::getFontNo() const { return 0xFFFF; } @@ -270,8 +264,8 @@ extern J2DTevStageInfo const j2dDefaultTevStageInfo = {4, 10, 15, 15, 0, 0, 0, 0 0, 5, 7, 7, 0, 0, 0, 0, 1}; /* 803A1BF4-803A1C00 02E254 000C+00 0/0 7/7 0/0 .rodata j2dDefaultIndTevStageInfo */ -SECTION_RODATA extern u8 const j2dDefaultIndTevStageInfo[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +SECTION_RODATA extern const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; COMPILER_STRIP_GATE(0x803A1BF4, &j2dDefaultIndTevStageInfo); @@ -279,14 +273,10 @@ COMPILER_STRIP_GATE(0x803A1BF4, &j2dDefaultIndTevStageInfo); SECTION_SDATA2 extern u32 j2dDefaultColInfo = 0xFFFFFFFF; /* 80456180-80456184 004780 0004+00 0/0 7/7 0/0 .sdata2 j2dDefaultTevOrderInfoNull */ -SECTION_SDATA2 extern u32 j2dDefaultTevOrderInfoNull = 0xFFFFFF00; +SECTION_SDATA2 extern J2DTevOrderInfo j2dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00}; /* 80456184-80456188 004784 0002+02 0/0 3/3 0/0 .sdata2 j2dDefaultIndTexOrderNull */ -SECTION_SDATA2 extern u16 j2dDefaultIndTexOrderNull[1 + 1 /* padding */] = { - 0xFFFF, - /* padding */ - 0x0000, -}; +SECTION_SDATA2 extern const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = { 0xFF, 0xFF, }; /* 80456188-80456190 004788 0008+00 0/0 5/5 0/0 .sdata2 j2dDefaultTevColor */ SECTION_SDATA2 extern u8 j2dDefaultTevColor[8] = { @@ -294,10 +284,7 @@ SECTION_SDATA2 extern u8 j2dDefaultTevColor[8] = { }; /* 80456190-80456194 004790 0002+02 0/0 3/3 0/0 .sdata2 j2dDefaultIndTexCoordScaleInfo */ -SECTION_SDATA2 extern u8 j2dDefaultIndTexCoordScaleInfo[2 + 2 /* padding */] = { - 0x00, - 0x00, - /* padding */ +SECTION_SDATA2 extern const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = { 0x00, 0x00, }; @@ -314,7 +301,7 @@ SECTION_SDATA2 extern u8 j2dDefaultTevSwapMode[4] = { }; /* 8045619C-804561A0 00479C 0004+00 0/0 6/6 0/0 .sdata2 j2dDefaultTevSwapModeTable */ -SECTION_SDATA2 extern u32 j2dDefaultTevSwapModeTable = 0x00010203; +SECTION_SDATA2 extern const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = {0x00, 0x01, 0x02, 0x03}; /* 804561A0-804561A4 0047A0 0004+00 0/0 3/3 0/0 .sdata2 j2dDefaultBlendInfo */ SECTION_SDATA2 extern u32 j2dDefaultBlendInfo = 0x01040505; diff --git a/libs/JSystem/J2DGraph/J2DTextBoxEx.cpp b/libs/JSystem/J2DGraph/J2DTextBoxEx.cpp index 25da723acc..52907216c0 100644 --- a/libs/JSystem/J2DGraph/J2DTextBoxEx.cpp +++ b/libs/JSystem/J2DGraph/J2DTextBoxEx.cpp @@ -372,6 +372,28 @@ JUTFont* J2DTextBoxEx::getFont() const { } /* 80307E0C-80307EF0 30274C 00E4+00 1/1 0/0 0/0 .text setTevOrder__12J2DTextBoxExFb */ +// Stack issue +#ifdef NONMATCHING +void J2DTextBoxEx::setTevOrder(bool param_0) { + u16 local_18[2]; + if (!param_0) { + local_18[0] = 4; + local_18[1] = 0xffff; + } else { + local_18[0] = 0xff; + local_18[1] = 0xff04; + } + for (u8 i = 0; i < 2; i++) { + if (mMaterial->getTevBlock()->getMaxStage() > i) { + J2DTevOrderInfo info; + info.mTexCoord = (local_18[i]) >> 8; + info.mTexMap = (local_18[i]) >> 8; + info.mColor = local_18[i] & 0xff; + mMaterial->getTevBlock()->setTevOrder(i, J2DTevOrder(info)); + } + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -380,6 +402,7 @@ asm void J2DTextBoxEx::setTevOrder(bool param_0) { #include "asm/JSystem/J2DGraph/J2DTextBoxEx/setTevOrder__12J2DTextBoxExFb.s" } #pragma pop +#endif /* 80307EF0-80307F94 302830 00A4+00 1/1 0/0 0/0 .text setTevStage__12J2DTextBoxExFb */ void J2DTextBoxEx::setTevStage(bool param_0) { @@ -498,7 +521,6 @@ bool J2DTextBoxEx::setWhite(JUtility::TColor white) { /* 8030834C-803084CC 302C8C 0180+00 1/0 0/0 0/0 .text * setBlackWhite__12J2DTextBoxExFQ28JUtility6TColorQ28JUtility6TColor */ -#ifdef NONMATCHING bool J2DTextBoxEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) { if (mMaterial == NULL) { return false; @@ -522,36 +544,48 @@ bool J2DTextBoxEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor para setTevStage(bvar); if (bvar) { - J2DGXColorS10 color0; - color0.r = param_0.r; - color0.g = param_0.g; - color0.b = param_0.b; - color0.a = param_0.a; - mMaterial->getTevBlock()->setTevColor(0, color0); - - J2DGXColorS10 color1; - color1.r = param_1.r; - color1.g = param_1.g; - color1.b = param_1.b; - color1.a = param_1.a; - mMaterial->getTevBlock()->setTevColor(1, color1); + J2DGXColorS10 color; + color.r = param_0.r; + color.g = param_0.g; + color.b = param_0.b; + color.a = param_0.a; + mMaterial->getTevBlock()->setTevColor(0, color); + + color.r = param_1.r; + color.g = param_1.g; + color.b = param_1.b; + color.a = param_1.a; + mMaterial->getTevBlock()->setTevColor(1, color); } return true; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool J2DTextBoxEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/setBlackWhite__12J2DTextBoxExFQ28JUtility6TColorQ28JUtility6TColor.s" -} -#pragma pop -#endif /* 803084CC-80308668 302E0C 019C+00 4/4 0/0 0/0 .text * getBlackWhite__12J2DTextBoxExCFPQ28JUtility6TColorPQ28JUtility6TColor */ +// regalloc +#ifdef NONMATCHING +bool J2DTextBoxEx::getBlackWhite(JUtility::TColor* param_0, JUtility::TColor* param_1) const { + if (mMaterial == NULL) { + return false; + } + + if (mMaterial->getTevBlock() == NULL) { + return false; + } + + bool tevStageNum = mMaterial->getTevBlock()->getTevStageNum() != 1; + *param_0 = JUtility::TColor(0); + *param_1 = JUtility::TColor(0xffffffff); + if (tevStageNum) { + J2DGXColorS10 local_30(*mMaterial->getTevBlock()->getTevColor(0)); + J2DGXColorS10 local_38(*mMaterial->getTevBlock()->getTevColor(1)); + *param_0 = JUtility::TColor((((u8)local_30.r) << 24) | (((u8)local_30.g) << 16) | (((u8)local_30.b) << 8) | ((u8)local_30.a)); + *param_1 = JUtility::TColor((((u8)local_38.r) << 24) | (((u8)local_38.g) << 16) | (((u8)local_38.b) << 8) | ((u8)local_38.a)); + } + return true; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -560,37 +594,40 @@ asm bool J2DTextBoxEx::getBlackWhite(JUtility::TColor* param_0, JUtility::TColor #include "asm/JSystem/J2DGraph/J2DTextBoxEx/getBlackWhite__12J2DTextBoxExCFPQ28JUtility6TColorPQ28JUtility6TColor.s" } #pragma pop +#endif /* 80308668-803086FC 302FA8 0094+00 1/1 0/0 0/0 .text * isSetBlackWhite__12J2DTextBoxExCFQ28JUtility6TColorQ28JUtility6TColor */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool J2DTextBoxEx::isSetBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/isSetBlackWhite__12J2DTextBoxExCFQ28JUtility6TColorQ28JUtility6TColor.s" +bool J2DTextBoxEx::isSetBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) const { + if ((u32)param_0 == 0 && (u32)param_1 == 0xffffffff) { + return 1; + } + mMaterial->getTevBlock()->getTevStageNum(); + if (mMaterial->getTevBlock()->getMaxStage() == 1) { + return 0; + } + return 1; } -#pragma pop /* 803086FC-8030875C 30303C 0060+00 1/0 0/0 0/0 .text getBlack__12J2DTextBoxExCFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JUtility::TColor J2DTextBoxEx::getBlack() const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/getBlack__12J2DTextBoxExCFv.s" +JUtility::TColor J2DTextBoxEx::getBlack() const { + JUtility::TColor black; + JUtility::TColor white; + if (getBlackWhite(&black, &white) == 0) { + return JUtility::TColor(0); + } + return black; } -#pragma pop /* 8030875C-803087BC 30309C 0060+00 1/0 0/0 0/0 .text getWhite__12J2DTextBoxExCFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JUtility::TColor J2DTextBoxEx::getWhite() const { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/getWhite__12J2DTextBoxExCFv.s" +JUtility::TColor J2DTextBoxEx::getWhite() const { + JUtility::TColor black; + JUtility::TColor white; + if (getBlackWhite(&black, &white) == 0) { + return JUtility::TColor(0xffffffff); + } + return white; } -#pragma pop /* 803087BC-803087DC 3030FC 0020+00 1/0 0/0 0/0 .text setAlpha__12J2DTextBoxExFUc */ void J2DTextBoxEx::setAlpha(u8 alpha) { @@ -677,24 +714,23 @@ void J2DTextBoxEx::setAnimation(J2DAnmVisibilityFull* anm) { /* 8030896C-803089EC 3032AC 0080+00 1/0 0/0 0/0 .text * animationPane__12J2DTextBoxExFPC15J2DAnmTransform */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm const J2DAnmTransform* J2DTextBoxEx::animationPane(J2DAnmTransform const* param_0) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/animationPane__12J2DTextBoxExFPC15J2DAnmTransform.s" +const J2DAnmTransform* J2DTextBoxEx::animationPane(J2DAnmTransform const* param_0) { + if (mVisibilityAnm != NULL && field_0x13c != 0xffff) { + u8 visibility; + mVisibilityAnm->getVisibility(field_0x13c, &visibility); + if (visibility != 0) { + show(); + } else { + hide(); + } + } + return J2DPane::animationPane(param_0); } -#pragma pop /* 803089EC-80308A28 30332C 003C+00 1/0 0/0 0/0 .text setCullBack__12J2DTextBoxExFb */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void J2DTextBoxEx::setCullBack(bool param_0) { - nofralloc -#include "asm/JSystem/J2DGraph/J2DTextBoxEx/setCullBack__12J2DTextBoxExFb.s" +void J2DTextBoxEx::setCullBack(bool param_0) { + setCullBack(param_0 ? GX_CULL_BACK : GX_CULL_NONE); } -#pragma pop /* 80308A28-80308A48 303368 0020+00 1/0 0/0 0/0 .text isUsed__12J2DTextBoxExFPC7ResTIMG */ diff --git a/libs/JSystem/J3DU/J3DUClipper.cpp b/libs/JSystem/J3DU/J3DUClipper.cpp index ecd01d99df..8443fb3405 100644 --- a/libs/JSystem/J3DU/J3DUClipper.cpp +++ b/libs/JSystem/J3DU/J3DUClipper.cpp @@ -5,7 +5,6 @@ #include "JSystem/J3DU/J3DUClipper.h" #include "MSL_C/math.h" -#include "dol2asm.h" #include "dolphin/mtx/mtxvec.h" #include "dolphin/types.h" @@ -13,19 +12,10 @@ // Forward References: // -extern "C" void init__11J3DUClipperFv(); -extern "C" void calcViewFrustum__11J3DUClipperFv(); -extern "C" void clip__11J3DUClipperCFPA4_Cf3Vecf(); -extern "C" void clip__11J3DUClipperCFPA4_CfP3VecP3Vec(); -extern "C" extern char const* const J3DUClipper__stringBase0; - // // External References: // -extern "C" void _savegpr_29(); -extern "C" void _restgpr_29(); - // // Declarations: // @@ -37,14 +27,9 @@ void J3DUClipper::init() { } /* ############################################################################################## */ -/* 8039A948-8039A954 026FA8 000C+00 1/1 0/0 0/0 .rodata @898 */ -SECTION_RODATA static u8 const lit_898[12] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -COMPILER_STRIP_GATE(0x8039A948, &lit_898); - /* 8027378C-802738FC 26E0CC 0170+00 0/0 3/3 4/4 .text calcViewFrustum__11J3DUClipperFv */ void J3DUClipper::calcViewFrustum() { + static const f32 unused[3] = {0.0f}; f32 f0 = tan(0.5f * mFovY * 0.01745329238474369f); f32 f4 = mNear * f0; f32 f5 = mAspect * f4; @@ -63,58 +48,143 @@ void J3DUClipper::calcViewFrustum() { } /* 802738FC-80273A44 26E23C 0148+00 0/0 3/3 2/2 .text clip__11J3DUClipperCFPA4_Cf3Vecf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 J3DUClipper::clip(f32 const (*param_0)[4], Vec param_1, f32 param_2) const { - nofralloc -#include "asm/JSystem/J3DU/J3DUClipper/clip__11J3DUClipperCFPA4_Cf3Vecf.s" +u32 J3DUClipper::clip(f32 const (*param_0)[4], Vec param_1, f32 param_2) const { + Vec vec1; + PSMTXMultVec(param_0, ¶m_1, &vec1); + if (-vec1.z < mNear - param_2) { + return 1; + } + + if (-vec1.z > mFar + param_2) { + return 1; + } + + if (vec1.x * _04.x + vec1.y * _04.y + vec1.z * _04.z > param_2) { + return 1; + } + + if (vec1.x * _10.x + vec1.y * _10.y + vec1.z * _10.z > param_2) { + return 1; + } + + if (vec1.x * _1C.x + vec1.y * _1C.y + vec1.z * _1C.z > param_2) { + return 1; + } + + if (vec1.x * _28.x + vec1.y * _28.y + vec1.z * _28.z > param_2) { + return 1; + } + + return 0; } -#pragma pop /* ############################################################################################## */ -/* 80455288-80455290 003888 0004+04 1/1 0/0 0/0 .sdata2 @991 */ -SECTION_SDATA2 static f32 lit_991[1 + 1 /* padding */] = { - 0.0f, - /* padding */ - 0.0f, -}; /* 80273A44-80273E08 26E384 03C4+00 0/0 3/3 2/2 .text clip__11J3DUClipperCFPA4_CfP3VecP3Vec */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 J3DUClipper::clip(f32 const (*param_0)[4], Vec* param_1, Vec* param_2) const { - nofralloc -#include "asm/JSystem/J3DU/J3DUClipper/clip__11J3DUClipperCFPA4_CfP3VecP3Vec.s" +u32 J3DUClipper::clip(f32 const (*param_1)[4], Vec* param_2, Vec* param_3) const { + s32 local_98[6]; + for (int i = 0; i < 6; i++) { + local_98[i] = 0; + } + Vec local_80[8]; + local_80[0].x = param_3->x; + local_80[0].y = param_3->y; + local_80[0].z = param_2->z; + local_80[1].x = param_3->x; + local_80[1].y = param_3->y; + local_80[1].z = param_3->z; + local_80[2].x = param_2->x; + local_80[2].y = param_3->y; + local_80[2].z = param_3->z; + local_80[3].x = param_2->x; + local_80[3].y = param_3->y; + local_80[3].z = param_2->z; + local_80[4].x = param_3->x; + local_80[4].y = param_2->y; + local_80[4].z = param_2->z; + local_80[5].x = param_3->x; + local_80[5].y = param_2->y; + local_80[5].z = param_3->z; + local_80[6].x = param_2->x; + local_80[6].y = param_2->y; + local_80[6].z = param_3->z; + local_80[7].x = param_2->x; + local_80[7].y = param_2->y; + local_80[7].z = param_2->z; + + for (u32 i = 0; i < 8; i++) { + Vec vec1; + PSMTXMultVec(param_1, local_80 + i, &vec1); + s32 r4 = 0; + if (-vec1.z < mNear) { + local_98[4]++; + r4 = 1; + } + + if (-vec1.z > mFar) { + local_98[5]++; + r4++; + } + + if (vec1.x * _04.x + vec1.y * _04.y + vec1.z * _04.z > 0.0f) { + local_98[0]++; + r4++; + } + + if (vec1.x * _10.x + vec1.y * _10.y + vec1.z * _10.z > 0.0f) { + local_98[1]++; + r4++; + } + + if (vec1.x * _1C.x + vec1.y * _1C.y + vec1.z * _1C.z > 0.0f) { + local_98[2]++; + r4++; + } + + if (vec1.x * _28.x + vec1.y * _28.y + vec1.z * _28.z > 0.0f) { + local_98[3]++; + r4++; + } + + if (r4 == 0) { + return 0; + } + } + + if (local_98[0] == 8) { + return 1; + } + if (local_98[2] == 8) { + return 1; + } + if (local_98[1] == 8) { + return 1; + } + if (local_98[3] == 8) { + return 1; + } + if (local_98[4] == 8) { + return 1; + } + if (local_98[5] == 8) { + return 1; + } + return 0; } -#pragma pop /* ############################################################################################## */ /* 8039A984-8039A99D 026FE4 0019+00 0/0 0/0 0/0 .rodata None */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8039A984 = " J3DUClipper::mFovy = %f"; -#pragma pop +static char const* const stringBase_8039A984 = " J3DUClipper::mFovy = %f"; /* 8039A99D-8039A9B8 026FFD 001B+00 0/0 0/0 0/0 .rodata None */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8039A99D = " J3DUClipper::mAspect = %f"; -#pragma pop +static char const* const stringBase_8039A99D = " J3DUClipper::mAspect = %f"; /* 8039A9B8-8039A9D1 027018 0019+00 0/0 0/0 0/0 .rodata None */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8039A9B8 = " J3DUClipper::mNear = %f"; -#pragma pop +static char const* const stringBase_8039A9B8 = " J3DUClipper::mNear = %f"; /* 8039A9D1-8039A9F0 027031 0018+07 0/0 0/0 0/0 .rodata None */ -#pragma push -#pragma force_active on -SECTION_DEAD static char const* const stringBase_8039A9D1 = " J3DUClipper::mFar = %f"; +static char const* const stringBase_8039A9D1 = " J3DUClipper::mFar = %f"; /* @stringBase0 padding */ -SECTION_DEAD static char const* const pad_8039A9E9 = "\0\0\0\0\0\0"; -#pragma pop +static char const* const pad_8039A9E9 = "\0\0\0\0\0\0"; /* 8039A984-8039A984 026FE4 0000+00 0/0 0/0 0/0 .rodata @stringBase0 */ diff --git a/libs/JSystem/JAudio2/JAISe.cpp b/libs/JSystem/JAudio2/JAISe.cpp index 40d46c3084..5b8dcf39cc 100644 --- a/libs/JSystem/JAudio2/JAISe.cpp +++ b/libs/JSystem/JAudio2/JAISe.cpp @@ -253,7 +253,7 @@ SECTION_SDATA2 static f32 lit_736 = 1.0f / 100.0f; /* 8029F304-8029F4CC 299C44 01C8+00 0/0 1/1 0/0 .text * JAISeCategoryMgr_mixOut___5JAISeFbRC14JASSoundParams16JAISoundActivity */ -// isStopping inline +// Matches with literals #ifdef NONMATCHING void JAISe::JAISeCategoryMgr_mixOut_(bool param_0, JASSoundParams const& param_1, JAISoundActivity param_2) { mixOut_(param_1); @@ -302,7 +302,7 @@ asm void JAISe::JAISeCategoryMgr_mixOut_(bool param_0, JASSoundParams const& par #endif /* 8029F4CC-8029F5C8 299E0C 00FC+00 0/0 1/1 0/0 .text JAISeCategoryMgr_calc___5JAISeFv */ -// isStopping inline +// Matches with literals #ifdef NONMATCHING void JAISe::JAISeCategoryMgr_calc_() { prepare_(); diff --git a/libs/JSystem/JAudio2/JAISeMgr.cpp b/libs/JSystem/JAudio2/JAISeMgr.cpp index 538c8820d5..1861b2baac 100644 --- a/libs/JSystem/JAudio2/JAISeMgr.cpp +++ b/libs/JSystem/JAudio2/JAISeMgr.cpp @@ -182,41 +182,26 @@ extern "C" asm void func_8029FC34(void* _this) { #pragma pop /* ############################################################################################## */ -/* 80455788-8045578C 003D88 0004+00 1/1 0/0 0/0 .sdata2 @822 */ -SECTION_SDATA2 static f32 lit_822 = 1.0f / 100.0f; /* 8029FC88-8029FD40 29A5C8 00B8+00 1/1 0/0 0/0 .text * JAISeMgr_acceptsNewSe___16JAISeCategoryMgrCFUl */ -// isStopping issues -#ifdef NONMATCHING u32 JAISeCategoryMgr::JAISeMgr_acceptsNewSe_(u32 param_0) const { - s32 rv; - int maxSe = getMaxSe(); + s32 maxSe = getMaxSe(); if (maxSe <= 0) { return 1; } - int stopCount = 0; + s32 stopCount = 0; for (JSULink<JAISe>* link = mSeList.getFirst(); link != NULL; link = link->getNext()) { if (param_0 < link->getObject()->JAISeCategoryMgr_getProperPriority_()) { return 1; } - if (link->getObject()->isStopping() == 0) { + if (!link->getObject()->isStopping()) { stopCount++; } } return stopCount < maxSe; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm u32 JAISeCategoryMgr::JAISeMgr_acceptsNewSe_(u32 param_0) const { - nofralloc -#include "asm/JSystem/JAudio2/JAISeMgr/JAISeMgr_acceptsNewSe___16JAISeCategoryMgrCFUl.s" -} -#pragma pop -#endif /* 8029FD40-8029FDE0 29A680 00A0+00 1/1 0/0 0/0 .text sortByPriority___16JAISeCategoryMgrFv */ void JAISeCategoryMgr::sortByPriority_() { diff --git a/libs/JSystem/JAudio2/JAISound.cpp b/libs/JSystem/JAudio2/JAISound.cpp index c984885625..5cfbd6d807 100644 --- a/libs/JSystem/JAudio2/JAISound.cpp +++ b/libs/JSystem/JAudio2/JAISound.cpp @@ -300,15 +300,8 @@ void JAISound::increasePrepareCount_JAISound_() { } /* ############################################################################################## */ -/* 804557D0-804557D8 003DD0 0004+04 1/1 0/0 0/0 .sdata2 @887 */ -SECTION_SDATA2 static f32 lit_887[1 + 1 /* padding */] = { - 1.0f / 100.0f, - /* padding */ - 0.0f, -}; /* 802A26B8-802A29DC 29CFF8 0324+00 0/0 3/3 0/0 .text calc_JAISound___8JAISoundFv */ -#ifdef NONMATCHING bool JAISound::calc_JAISound_() { status_.state.flags.flag2 = 1; if (isStopping() && JAISound_tryDie_()) { @@ -349,16 +342,6 @@ bool JAISound::calc_JAISound_() { return playing; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm bool JAISound::calc_JAISound_() { - nofralloc -#include "asm/JSystem/JAudio2/JAISound/calc_JAISound___8JAISoundFv.s" -} -#pragma pop -#endif /* 802A29DC-802A2AB0 29D31C 00D4+00 0/0 2/2 0/0 .text initTrack_JAISound___8JAISoundFP8JASTrack */ void JAISound::initTrack_JAISound_(JASTrack* track) { diff --git a/libs/JSystem/JAudio2/JAISoundHandles.cpp b/libs/JSystem/JAudio2/JAISoundHandles.cpp index 80a65baecd..f037471855 100644 --- a/libs/JSystem/JAudio2/JAISoundHandles.cpp +++ b/libs/JSystem/JAudio2/JAISoundHandles.cpp @@ -4,38 +4,36 @@ // #include "JSystem/JAudio2/JAISoundHandles.h" -#include "dol2asm.h" #include "dolphin/types.h" // // Forward References: // -extern "C" void getHandleSoundID__15JAISoundHandlesF10JAISoundID(); -extern "C" void getFreeHandle__15JAISoundHandlesFv(); - // // Declarations: // /* 802A2C98-802A2CF4 29D5D8 005C+00 0/0 1/1 0/0 .text * getHandleSoundID__15JAISoundHandlesF10JAISoundID */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JAISoundHandles::getHandleSoundID(JAISoundID param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundHandles/getHandleSoundID__15JAISoundHandlesF10JAISoundID.s" +JAISoundHandle* JAISoundHandles::getHandleSoundID(JAISoundID param_0) { + for (int i = 0; i < numHandles_; i++) { + if (mSoundHandle[i].isSoundAttached()) { + if (JAISoundID(mSoundHandle[i]->soundID) == param_0) { + return &mSoundHandle[i]; + } + } + } + return NULL; } -#pragma pop /* 802A2CF4-802A2D34 29D634 0040+00 0/0 2/2 0/0 .text getFreeHandle__15JAISoundHandlesFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JAISoundHandle* JAISoundHandles::getFreeHandle() { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundHandles/getFreeHandle__15JAISoundHandlesFv.s" +JAISoundHandle* JAISoundHandles::getFreeHandle() { + for (int i = 0; i < numHandles_; i++) { + if (!mSoundHandle[i].isSoundAttached()) { + return &mSoundHandle[i]; + } + } + return NULL; } -#pragma pop diff --git a/libs/JSystem/JAudio2/JAISoundInfo.cpp b/libs/JSystem/JAudio2/JAISoundInfo.cpp index 88f29b5f6e..b155b40b16 100644 --- a/libs/JSystem/JAudio2/JAISoundInfo.cpp +++ b/libs/JSystem/JAudio2/JAISoundInfo.cpp @@ -4,59 +4,26 @@ // #include "JSystem/JAudio2/JAISoundInfo.h" -#include "dol2asm.h" #include "dolphin/types.h" // // Forward References: // -extern "C" void __ct__12JAISoundInfoFb(); -extern "C" void __dt__12JAISoundInfoFv(); - // // External References: // -extern "C" void __dl__FPv(); -extern "C" extern u8 __OSReport_disable; - // // Declarations: // /* ############################################################################################## */ -/* 803C99A0-803C99C8 026AC0 0024+04 2/2 0/0 0/0 .data __vt__12JAISoundInfo */ -SECTION_DATA extern void* __vt__12JAISoundInfo[9 + 1 /* padding */] = { - (void*)NULL /* RTTI */, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)NULL, - (void*)__dt__12JAISoundInfoFv, - /* padding */ - NULL, -}; /* 802A2D34-802A2D50 29D674 001C+00 0/0 1/1 0/0 .text __ct__12JAISoundInfoFb */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JAISoundInfo::JAISoundInfo(bool param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundInfo/__ct__12JAISoundInfoFb.s" +JAISoundInfo::JAISoundInfo(bool param_0) : JASGlobalInstance<JAISoundInfo>(param_0) { } -#pragma pop /* 802A2D50-802A2DB4 29D690 0064+00 1/0 2/2 0/0 .text __dt__12JAISoundInfoFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JAISoundInfo::~JAISoundInfo() { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundInfo/__dt__12JAISoundInfoFv.s" +JAISoundInfo::~JAISoundInfo() { } -#pragma pop diff --git a/libs/JSystem/JAudio2/JAISoundStarter.cpp b/libs/JSystem/JAudio2/JAISoundStarter.cpp index 21466c6c6b..ff57b6d9f9 100644 --- a/libs/JSystem/JAudio2/JAISoundStarter.cpp +++ b/libs/JSystem/JAudio2/JAISoundStarter.cpp @@ -4,6 +4,7 @@ // #include "JSystem/JAudio2/JAISoundStarter.h" +#include "JSystem/JAudio2/JAISoundHandles.h" #include "dol2asm.h" #include "dolphin/types.h" @@ -20,7 +21,6 @@ extern "C" void func_802A2FEC(); // extern "C" void __dl__FPv(); -extern "C" extern u8 __OSReport_disable; // // Declarations: @@ -36,33 +36,43 @@ SECTION_DATA extern void* __vt__15JAISoundStarter[4] = { }; /* 802A2F6C-802A2F88 29D8AC 001C+00 0/0 1/1 0/0 .text __ct__15JAISoundStarterFb */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JAISoundStarter::JAISoundStarter(bool param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundStarter/__ct__15JAISoundStarterFb.s" +JAISoundStarter::JAISoundStarter(bool param_0) : JASGlobalInstance<JAISoundStarter>(param_0) { } -#pragma pop /* 802A2F88-802A2FEC 29D8C8 0064+00 1/0 7/7 0/0 .text __dt__15JAISoundStarterFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JAISoundStarter::~JAISoundStarter() { - nofralloc -#include "asm/JSystem/JAudio2/JAISoundStarter/__dt__15JAISoundStarterFv.s" +JAISoundStarter::~JAISoundStarter() { } -#pragma pop /* 802A2FEC-802A30D4 29D92C 00E8+00 0/0 4/4 0/0 .text * startLevelSound__15JAISoundStarterF10JAISoundIDP14JAISoundHandlePCQ29JGeometry8TVec3<f> */ +// This function is probably virtual but it causes vtable issues. +#ifdef NONMATCHING +bool JAISoundStarter::startLevelSound(JAISoundID param_0, JAISoundHandle* param_1, + JGeometry::TVec3<f32> const* param_2) { + if (*param_1) { + if (JAISoundID((u32)(*param_1)->soundID) == param_0) { + (*param_1)->updateLifeTime(1); + if (param_2 != NULL) { + (*param_1)->setPos(*param_2); + } + return true; + } + } + + bool iVar2 = startLevelSound(param_0, param_1, param_2); + if ((iVar2) && *param_1) { + (*param_1)->setLifeTime(1, false); + } + return iVar2; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off -asm void JAISoundStarter::startLevelSound(JAISoundID param_0, JAISoundHandle* param_1, +asm bool JAISoundStarter::startLevelSound(JAISoundID param_0, JAISoundHandle* param_1, JGeometry::TVec3<f32> const* param_2) { nofralloc #include "asm/JSystem/JAudio2/JAISoundStarter/func_802A2FEC.s" } #pragma pop +#endif
\ No newline at end of file diff --git a/libs/JSystem/JAudio2/JASCalc.cpp b/libs/JSystem/JAudio2/JASCalc.cpp index e8bee7cc50..007716d9eb 100644 --- a/libs/JSystem/JAudio2/JASCalc.cpp +++ b/libs/JSystem/JAudio2/JASCalc.cpp @@ -6,99 +6,151 @@ #include "JSystem/JAudio2/JASCalc.h" #include "dol2asm.h" #include "dolphin/types.h" +#include "dolphin/os/OSCache.h" +#include "MSL_C/math.h" // // Types: // -struct JASCalc { - /* 8028F2E8 */ void imixcopy(s16 const*, s16 const*, s16*, u32); - /* 8028F318 */ void bcopyfast(void const*, void*, u32); - /* 8028F354 */ void bcopy(void const*, void*, u32); - /* 8028F454 */ void bzerofast(void*, u32); - /* 8028F480 */ void bzero(void*, u32); - /* 8028F578 */ void pow2(f32); - template <typename A1, typename B1> - void clamp(/* ... */); - /* 8028F69C */ /* JASCalc::clamp<s16, s32> */ - void func_8028F69C(void* _this, s32); - - static u8 const CUTOFF_TO_IIR_TABLE[1024]; -}; - // // Forward References: // -extern "C" void imixcopy__7JASCalcFPCsPCsPsUl(); -extern "C" void bcopyfast__7JASCalcFPCvPvUl(); -extern "C" void bcopy__7JASCalcFPCvPvUl(); -extern "C" void bzerofast__7JASCalcFPvUl(); -extern "C" void bzero__7JASCalcFPvUl(); -extern "C" void pow2__7JASCalcFf(); -extern "C" void func_8028F69C(void* _this, s32); -extern "C" u8 const CUTOFF_TO_IIR_TABLE__7JASCalc[1024]; - // // External References: // -extern "C" void DCZeroRange(); -extern "C" extern u32 __float_huge; - // // Declarations: // /* 8028F2E8-8028F318 289C28 0030+00 0/0 1/1 0/0 .text imixcopy__7JASCalcFPCsPCsPsUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::imixcopy(s16 const* param_0, s16 const* param_1, s16* param_2, u32 param_3) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/imixcopy__7JASCalcFPCsPCsPsUl.s" +void JASCalc::imixcopy(const s16 *s1, const s16 *s2, s16 *dst, u32 n) { + for (n; n != 0; n--) { + *dst++ = *((s16 *)s1)++; + *dst++ = *((s16 *)s2)++; + } } -#pragma pop /* 8028F318-8028F354 289C58 003C+00 1/1 0/0 0/0 .text bcopyfast__7JASCalcFPCvPvUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::bcopyfast(void const* param_0, void* param_1, u32 param_2) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/bcopyfast__7JASCalcFPCvPvUl.s" +void JASCalc::bcopyfast(const void *src, void *dest, u32 size) { + u32 copy1, copy2, copy3, copy4; + + u32 *usrc = (u32 *)src; + u32 *udest = (u32 *)dest; + + for (size = size / (4 * sizeof(u32)); size != 0; size--) { + copy1 = *((u32 *)usrc)++; + copy2 = *((u32 *)usrc)++; + copy3 = *((u32 *)usrc)++; + copy4 = *((u32 *)usrc)++; + + *udest++ = copy1; + *udest++ = copy2; + *udest++ = copy3; + *udest++ = copy4; + } } -#pragma pop /* 8028F354-8028F454 289C94 0100+00 0/0 3/3 0/0 .text bcopy__7JASCalcFPCvPvUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::bcopy(void const* param_0, void* param_1, u32 param_2) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/bcopy__7JASCalcFPCvPvUl.s" +void JASCalc::bcopy(const void *src, void *dest, u32 size) { + u32 *usrc; + u32 *udest; + + u8 *bsrc = (u8 *)src; + u8 *bdest = (u8 *)dest; + + u8 endbitsSrc = (reinterpret_cast<u32>(bsrc) & 0x03); + u8 enbitsDst = (reinterpret_cast<u32>(bdest) & 0x03); + if ((endbitsSrc) == (enbitsDst) && (size & 0x0f) == 0) { + bcopyfast(src, dest, size); + } + else if ((endbitsSrc == enbitsDst) && (size >= 16)) { + if (endbitsSrc != 0) { + for (endbitsSrc = 4 - endbitsSrc; endbitsSrc != 0; endbitsSrc--) { + *bdest++ = (u32)*bsrc++; + size--; + } + } + + udest = (u32 *)bdest; + usrc = (u32 *)bsrc; + + for (; size >= 4; size -= 4) { + *udest++ = *usrc++; + } + + if (size != 0) { + bdest = (u8 *)udest; + bsrc = (u8 *)usrc; + + for (; size != 0; size--) { + *bdest++ = (u32)*bsrc++; + } + } + } + else { + for (; size != 0; size--) { + *bdest++ = (u32)*bsrc++; + } + } } -#pragma pop /* 8028F454-8028F480 289D94 002C+00 1/1 0/0 0/0 .text bzerofast__7JASCalcFPvUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::bzerofast(void* param_0, u32 param_1) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/bzerofast__7JASCalcFPvUl.s" +void JASCalc::bzerofast(void *dest, u32 size) { + u32 *udest = (u32 *)dest; + + for (size = size / (4 * sizeof(u32)); size != 0; size--) { + *udest++ = 0; + *udest++ = 0; + *udest++ = 0; + *udest++ = 0; + } } -#pragma pop /* 8028F480-8028F578 289DC0 00F8+00 0/0 6/6 0/0 .text bzero__7JASCalcFPvUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::bzero(void* param_0, u32 param_1) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/bzero__7JASCalcFPvUl.s" +void JASCalc::bzero(void *dest, u32 size) { + u32 *udest; + u8 *bdest = (u8 *)dest; + if ((size & 0x1f) == 0 && (reinterpret_cast<u32>(dest) & 0x1f) == 0) { + DCZeroRange(dest, size); + return; + } + + u8 alignedbitsDst = reinterpret_cast<u32>(bdest) & 0x3; + + if ((size & 0xf) == 0 && alignedbitsDst == 0) { + bzerofast(dest, size); + return; + } + + if (size >= 16) { + if (alignedbitsDst != 0) { + for (alignedbitsDst = 4 - alignedbitsDst; alignedbitsDst != 0; alignedbitsDst--) { + *bdest++ = 0; + size--; + } + } + + udest = (u32 *)bdest; + for (; size >= 4; size -= 4) { + *udest++ = 0; + } + + if (size != 0) { + bdest = (u8 *)udest; + for (; size != 0; size--) { + *bdest++ = 0; + } + } + } + else { + for (; size != 0; size--) { + *bdest++ = 0; + } + } } -#pragma pop /* ############################################################################################## */ /* 8039ABB8-8039AFB8 027218 0400+00 0/0 4/4 0/0 .rodata CUTOFF_TO_IIR_TABLE__7JASCalc */ @@ -170,62 +222,63 @@ SECTION_RODATA u8 const JASCalc::CUTOFF_TO_IIR_TABLE[1024] = { }; COMPILER_STRIP_GATE(0x8039ABB8, &JASCalc::CUTOFF_TO_IIR_TABLE); -/* 8039AFB8-8039AFD0 027618 0018+00 1/1 0/0 0/0 .rodata __two_to_x$982 */ -SECTION_RODATA static f32 const __two_to_x[6] = { - 0.6931471824645996f, 0.240226611495018f, 0.055502913892269135f, - 0.009625022299587727f, 0.0013131053419783711f, 0.0001830080582294613f, -}; -COMPILER_STRIP_GATE(0x8039AFB8, &__two_to_x); +// currently required because of missing functions +// JASCalc::hannWindow(short *, unsigned long) +// JASCalc::hammWindow(short *, unsigned long) +// JASCalc::fft(float *, float *, unsigned long, long) +f32 JASCalc::fake1() { return 0.5f; } +f32 JASCalc::fake2(long x) { return JASCalc::clamp<s16, long>(x); } +f32 JASCalc::fake3() { return 0.0f; } -/* 80455558-80455560 003B58 0004+04 1/1 0/0 0/0 .sdata2 @847 */ -SECTION_SDATA2 static f32 lit_847[1 + 1 /* padding */] = { - 0.5f, - /* padding */ - 0.0f, -}; +/* 8028F578-8028F69C 289EB8 0124+00 0/0 2/2 0/0 .text pow2__7JASCalcFf */ +f32 JASCalc::pow2(f32 x) { + s32 frac_index = 0; + union { + s32 l; + f32 f; + } exponent; + exponent.l = (x >= 0.0f ? (s32)(x - 0.5f) : (s32)(x + 0.5f)); // Shift towards 0 and round + f32 pannedval = x - exponent.l; // strictly between 1.5 and -1.5 -/* 80455560-80455568 003B60 0008+00 1/1 0/0 0/0 .sdata2 @850 */ -SECTION_SDATA2 static f64 lit_850 = 4503601774854144.0 /* cast s32 to float */; + // 2^x will not fit in an IEEE-754 float + if(exponent.l > 128) { + return HUGE_VALF; + } -/* 80455568-8045556C 003B68 0004+00 1/1 0/0 0/0 .sdata2 @969 */ -SECTION_SDATA2 static u8 lit_969[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; + // convert to exponent of IEEE-754 float + exponent.l += 127; + exponent.l <<= 23; -/* 8045556C-80455574 003B6C 0008+00 1/1 0/0 0/0 .sdata2 scale_frac$980 */ -SECTION_SDATA2 static u8 scale_frac[8] = { - 0x00, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, -}; + // Calculate the mantissa -/* 80455574-8045557C 003B74 0008+00 1/1 0/0 0/0 .sdata2 two_to_frac$981 */ -SECTION_SDATA2 static u8 two_to_frac[8] = { - 0x3F, 0x80, 0x00, 0x00, 0x3F, 0x35, 0x04, 0xF3, -}; + static const f32 scale_frac[] = { 0.0f, 0.5f }; + // { 1 , 1/sqrt2 } + static const f32 two_to_frac[] = {1.0f, 0.70710677f}; + // coefficients of Taylor polynomial of 2^x - 1 at 0: + // 2^x - 1 = (log2) * x + (log2)^2 / 2! * x^2 + ... + static const f32 __two_to_x[] = { + 0.6931472f, 0.24022661, + 0.055502914f, 0.009625022f, + 0.0013131053f, 1.8300806E-4f + }; -/* 8045557C-80455580 003B7C 0004+00 1/1 0/0 0/0 .sdata2 @994 */ -SECTION_SDATA2 static f32 lit_994 = 0.75f; + if (pannedval < 0.0f) { + frac_index += 1; + } + + f32 ret = pannedval + scale_frac[frac_index]; -/* 80455580-80455588 003B80 0004+04 1/1 0/0 0/0 .sdata2 @995 */ -SECTION_SDATA2 static f32 lit_995[1 + 1 /* padding */] = { - 0.25f, - /* padding */ - 0.0f, -}; + // Evaluate Taylor polynomial using Horner's method + ret = ret * (ret * (ret * (ret * (ret * (ret * __two_to_x[5] + __two_to_x[4]) + + __two_to_x[3]) + __two_to_x[2]) + __two_to_x[1]) + __two_to_x[0]); + // 2^n * (corrected mantissa) + ret = exponent.f * (0.75f * two_to_frac[frac_index] + ((0.25f + ret) * two_to_frac[frac_index])); -/* 8028F578-8028F69C 289EB8 0124+00 0/0 2/2 0/0 .text pow2__7JASCalcFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCalc::pow2(f32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JASCalc/pow2__7JASCalcFf.s" + return ret; } -#pragma pop /* 8028F69C-8028F6C4 289FDC 0028+00 0/0 4/4 0/0 .text clamp<s,l>__7JASCalcFl */ +// Could not make clamp not inline #pragma push #pragma optimization_level 0 #pragma optimizewithasm off diff --git a/libs/JSystem/JAudio2/JASCallback.cpp b/libs/JSystem/JAudio2/JASCallback.cpp index 5e02d36ddd..1273bd6ca1 100644 --- a/libs/JSystem/JAudio2/JASCallback.cpp +++ b/libs/JSystem/JAudio2/JASCallback.cpp @@ -4,72 +4,61 @@ // #include "JSystem/JAudio2/JASCallback.h" -#include "dol2asm.h" +#include "JSystem/JAudio2/JASAudioReseter.h" #include "dolphin/types.h" // // Types: // -struct JASCallbackMgr { - /* 8028FFA8 */ void regist(s32 (*)(void*), void*); - /* 80290030 */ void reject(s32 (*)(void*), void*); - /* 802900C4 */ void callback(); -}; - // // Forward References: // -extern "C" void regist__14JASCallbackMgrFPFPv_lPv(); -extern "C" void reject__14JASCallbackMgrFPFPv_lPv(); -extern "C" void callback__14JASCallbackMgrFv(); - // // External References: // -extern "C" void OSDisableInterrupts(); -extern "C" void OSRestoreInterrupts(); -extern "C" void _savegpr_26(); -extern "C" void _savegpr_28(); -extern "C" void _savegpr_29(); -extern "C" void _restgpr_26(); -extern "C" void _restgpr_28(); -extern "C" void _restgpr_29(); - // // Declarations: // /* 8028FFA8-80290030 28A8E8 0088+00 0/0 2/2 0/0 .text regist__14JASCallbackMgrFPFPv_lPv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCallbackMgr::regist(s32 (*param_0)(void*), void* param_1) { - nofralloc -#include "asm/JSystem/JAudio2/JASCallback/regist__14JASCallbackMgrFPFPv_lPv.s" +bool JASCallbackMgr::regist(JASCallback* function, void* argument) +{ + JASCriticalSection criticalSection; + for (int i = 0; i < 0x20; i++) { + if (mCallbacks[i].mFunction == NULL) { + mCallbacks[i].mFunction = function; + mCallbacks[i].mArgument = argument; + return true; + } + } + return false; } -#pragma pop /* 80290030-802900C4 28A970 0094+00 0/0 1/1 0/0 .text reject__14JASCallbackMgrFPFPv_lPv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCallbackMgr::reject(s32 (*param_0)(void*), void* param_1) { - nofralloc -#include "asm/JSystem/JAudio2/JASCallback/reject__14JASCallbackMgrFPFPv_lPv.s" +int JASCallbackMgr::reject(JASCallback* function, void* argument) { + int rejectNum = 0; + JASCriticalSection criticalSection; + for (int i = 0; i < 0x20; i++) { + if (mCallbacks[i].mFunction == function && mCallbacks[i].mArgument == argument) { + mCallbacks[i].mFunction = NULL; + mCallbacks[i].mArgument = NULL; + rejectNum++; + } + } + return rejectNum; } -#pragma pop /* 802900C4-80290140 28AA04 007C+00 0/0 3/3 0/0 .text callback__14JASCallbackMgrFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASCallbackMgr::callback() { - nofralloc -#include "asm/JSystem/JAudio2/JASCallback/callback__14JASCallbackMgrFv.s" +void JASCallbackMgr::callback() { + for (int i = 0; i < 0x20; i++) { + if (mCallbacks[i].mFunction && mCallbacks[i].mFunction(mCallbacks[i].mArgument) < 0) { + mCallbacks[i].mFunction = NULL; + mCallbacks[i].mArgument = NULL; + } + } } -#pragma pop diff --git a/libs/JSystem/JAudio2/JASLfo.cpp b/libs/JSystem/JAudio2/JASLfo.cpp index 7d4efa9605..5636114ae5 100644 --- a/libs/JSystem/JAudio2/JASLfo.cpp +++ b/libs/JSystem/JAudio2/JASLfo.cpp @@ -4,129 +4,83 @@ // #include "JSystem/JAudio2/JASLfo.h" -#include "dol2asm.h" +#include "SSystem/SComponent/c_math.h" #include "dolphin/types.h" // // Types: // -struct JMath { - static u8 sincosTable_[65536]; -}; - -struct JASLfo { - /* 8029BD14 */ JASLfo(); - /* 8029BD44 */ void getValue() const; - /* 8029BDD8 */ void incCounter(f32); - /* 8029BE2C */ void resetCounter(); - - static u8 sFreeRunLfo[24]; -}; - // // Forward References: // -extern "C" void __ct__6JASLfoFv(); -extern "C" void getValue__6JASLfoCFv(); -extern "C" void incCounter__6JASLfoFf(); -extern "C" void resetCounter__6JASLfoFv(); -extern "C" void __sinit_JASLfo_cpp(); -extern "C" u8 sFreeRunLfo__6JASLfo[24]; - // // External References: // -extern "C" u8 sincosTable___5JMath[65536]; - // // Declarations: // /* ############################################################################################## */ -/* 804556E0-804556E4 003CE0 0004+00 3/3 0/0 0/0 .sdata2 @341 */ -SECTION_SDATA2 static u8 lit_341[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; - -/* 804556E4-804556E8 003CE4 0004+00 2/2 0/0 0/0 .sdata2 @342 */ -SECTION_SDATA2 static f32 lit_342 = 1.0f; /* 8029BD14-8029BD44 296654 0030+00 1/1 1/1 0/0 .text __ct__6JASLfoFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JASLfo::JASLfo() { - nofralloc -#include "asm/JSystem/JAudio2/JASLfo/__ct__6JASLfoFv.s" +JASLfo::JASLfo() { + field_0x0 = 0; + field_0x4 = 1; + field_0x8 = 0.0f; + field_0xC = 0.0f; + field_0x10 = 1.0f; + field_0x14 = 0; + field_0x16 = 0; } -#pragma pop /* ############################################################################################## */ -/* 804556E8-804556EC 003CE8 0004+00 1/1 0/0 0/0 .sdata2 @363 */ -SECTION_SDATA2 static f32 lit_363 = -8192.0f; - -/* 804556EC-804556F0 003CEC 0004+00 1/1 0/0 0/0 .sdata2 @364 */ -SECTION_SDATA2 static f32 lit_364 = 8192.0f; /* 8029BD44-8029BDD8 296684 0094+00 0/0 3/3 0/0 .text getValue__6JASLfoCFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASLfo::getValue() const { - nofralloc -#include "asm/JSystem/JAudio2/JASLfo/getValue__6JASLfoCFv.s" +f32 JASLfo::getValue() const { + if (field_0x16) { + return 0.0f; + } + + if (field_0xC == 0.0f) { + return 0.0f; + } + + return field_0xC * JMASinLap(field_0x8); } -#pragma pop /* ############################################################################################## */ -/* 804556F0-804556F8 003CF0 0004+04 1/1 0/0 0/0 .sdata2 @376 */ -SECTION_SDATA2 static f32 lit_376[1 + 1 /* padding */] = { - 1.0f / 72.0f, - /* padding */ - 0.0f, -}; /* 8029BDD8-8029BE2C 296718 0054+00 0/0 2/2 0/0 .text incCounter__6JASLfoFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASLfo::incCounter(f32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JASLfo/incCounter__6JASLfoFf.s" +void JASLfo::incCounter(f32 param_0) { + if (field_0x16) { + field_0x16--; + return; + } + + field_0x8 += param_0 * ((1.0f / 72.0f) * field_0x10); + if (field_0x8 >= 1.0f) { + field_0x8 -= 1.0f; + } } -#pragma pop /* ############################################################################################## */ /* 80431C40-80431C58 05E960 0018+00 2/2 1/1 0/0 .bss sFreeRunLfo__6JASLfo */ -u8 JASLfo::sFreeRunLfo[24]; +JASLfo JASLfo::sFreeRunLfo; /* 8029BE2C-8029BE6C 29676C 0040+00 0/0 1/1 0/0 .text resetCounter__6JASLfoFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASLfo::resetCounter() { - nofralloc -#include "asm/JSystem/JAudio2/JASLfo/resetCounter__6JASLfoFv.s" +void JASLfo::resetCounter() { + field_0x16 = field_0x14; + switch (field_0x4) { + case 0: + field_0x8 = sFreeRunLfo.field_0x8; + break; + case 1: + field_0x8 = 0.0f; + break; + } } -#pragma pop /* 8029BE6C-8029BE94 2967AC 0028+00 0/0 1/0 0/0 .text __sinit_JASLfo_cpp */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void __sinit_JASLfo_cpp() { - nofralloc -#include "asm/JSystem/JAudio2/JASLfo/__sinit_JASLfo_cpp.s" -} -#pragma pop - -#pragma push -#pragma force_active on -REGISTER_CTORS(0x8029BE6C, __sinit_JASLfo_cpp); -#pragma pop diff --git a/libs/JSystem/JAudio2/JASOscillator.cpp b/libs/JSystem/JAudio2/JASOscillator.cpp index 9d2f224a1c..dbd7f9b441 100644 --- a/libs/JSystem/JAudio2/JASOscillator.cpp +++ b/libs/JSystem/JAudio2/JASOscillator.cpp @@ -4,208 +4,215 @@ // #include "JSystem/JAudio2/JASOscillator.h" -#include "dol2asm.h" #include "dolphin/types.h" // // Types: // -struct JASOscillator { - struct Data {}; - - /* 8029BE94 */ JASOscillator(); - /* 8029BEC4 */ void initStart(JASOscillator::Data const*); - /* 8029BF68 */ void incCounter(f32); - /* 8029BFC8 */ void getValue() const; - /* 8029BFE4 */ void release(); - /* 8029C0E0 */ void update(); - /* 8029C2C0 */ void updateCurrentValue(f32); - - static u8 const sCurveTableLinear[68]; - static u8 const sCurveTableSampleCell[68]; - static u8 const sCurveTableSqRoot[68]; - static u8 const sCurveTableSquare[68]; -}; - // // Forward References: // -extern "C" void __ct__13JASOscillatorFv(); -extern "C" void initStart__13JASOscillatorFPCQ213JASOscillator4Data(); -extern "C" void incCounter__13JASOscillatorFf(); -extern "C" void getValue__13JASOscillatorCFv(); -extern "C" void release__13JASOscillatorFv(); -extern "C" void update__13JASOscillatorFv(); -extern "C" void updateCurrentValue__13JASOscillatorFf(); -extern "C" u8 const sCurveTableLinear__13JASOscillator[68]; -extern "C" u8 const sCurveTableSampleCell__13JASOscillator[68]; -extern "C" u8 const sCurveTableSqRoot__13JASOscillator[68]; -extern "C" u8 const sCurveTableSquare__13JASOscillator[68]; - // // External References: // -extern "C" void __cvt_fp2unsigned(); - // // Declarations: // /* ############################################################################################## */ -/* 804556F8-804556FC 003CF8 0004+00 3/3 0/0 0/0 .sdata2 @77 */ -SECTION_SDATA2 static u8 lit_77[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; /* 8029BE94-8029BEC4 2967D4 0030+00 0/0 1/1 0/0 .text __ct__13JASOscillatorFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm JASOscillator::JASOscillator() { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/__ct__13JASOscillatorFv.s" +JASOscillator::JASOscillator() { + mData = NULL; + _14 = 0; + _16 = 0; + _18 = 0; + _1C = 0; + _0C = 0.0f; + _10 = 0.0f; + _08 = 0.0f; + _04 = 0.0f; } -#pragma pop /* ############################################################################################## */ -/* 804556FC-80455700 003CFC 0004+00 2/2 0/0 0/0 .sdata2 @87 */ -SECTION_SDATA2 static f32 lit_87 = 1.0f; - -/* 80455700-80455708 003D00 0004+04 3/3 0/0 0/0 .sdata2 @88 */ -SECTION_SDATA2 static f32 lit_88[1 + 1 /* padding */] = { - 32768.0f, - /* padding */ - 0.0f, -}; - -/* 80455708-80455710 003D08 0008+00 3/3 0/0 0/0 .sdata2 @91 */ -SECTION_SDATA2 static f64 lit_91 = 4503601774854144.0 /* cast s32 to float */; /* 8029BEC4-8029BF68 296804 00A4+00 0/0 1/1 0/0 .text * initStart__13JASOscillatorFPCQ213JASOscillator4Data */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::initStart(JASOscillator::Data const* param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/initStart__13JASOscillatorFPCQ213JASOscillator4Data.s" +void JASOscillator::initStart(JASOscillator::Data const* data) { + mData = data; + _04 = 0.0f; + _08 = 0.0f; + _0C = 0.0f; + _14 = 0; + _16 = 0; + if (!data) { + _1C = 0; + return; + } + + if (mData->_08 == NULL) { + _1C = 2; + _08 = 1.0f; + return; + } + + _10 = mData->_08[2] / 32768.0f; + _18 = mData->_08[0]; + _1C = 1; } -#pragma pop /* 8029BF68-8029BFC8 2968A8 0060+00 0/0 1/1 0/0 .text incCounter__13JASOscillatorFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::incCounter(f32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/incCounter__13JASOscillatorFf.s" +void JASOscillator::incCounter(f32 param_0) { + const short* v1; + switch (_1C) { + case 0: + case 2: + return; + case 1: + break; + } + _04 += param_0 * mData->_04; + update(); } -#pragma pop /* 8029BFC8-8029BFE4 296908 001C+00 0/0 1/1 0/0 .text getValue__13JASOscillatorCFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::getValue() const { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/getValue__13JASOscillatorCFv.s" +f32 JASOscillator::getValue() const { + return _08 * mData->_10 + mData->_14; } -#pragma pop /* 8029BFE4-8029C0E0 296924 00FC+00 0/0 1/1 0/0 .text release__13JASOscillatorFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::release() { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/release__13JASOscillatorFv.s" +void JASOscillator::release() { + if (mData->_0C == NULL && _16 == 0) { + stop(); + return; + } + + if (_16 != 0) { + _04 = 0.0f; + _0C = _08; + _10 = 0.0f; + _14 = 0; + _18 = (_16 >> 14) & 3; + _1C = 4; + update(); + return; + } + + if (mData->_08 != mData->_0C) { + _04 = 0.0f; + _0C = _08; + _10 = mData->_0C[2] / 32768.0f; + _14 = 0; + _18 = mData->_0C[0]; + } + + _1C = 3; + update(); } -#pragma pop /* 8029C0E0-8029C2C0 296A20 01E0+00 2/2 1/1 0/0 .text update__13JASOscillatorFv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::update() { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/update__13JASOscillatorFv.s" +void JASOscillator::update() { + if (_1C == 4) { + s16 x = _16 & 0x3FFF; + if (_04 < x) { + updateCurrentValue(x); + } else { + _08 = _10; + _1C = 0; + } + return; + } + + if (_1C == 2) return; + + short* psVar1; + if (_1C == 1) { + psVar1 = mData->_08; + } else { + psVar1 = mData->_0C; + } + + if (psVar1 == NULL) { + _1C = 2; + return; + } + + while (_04 >= psVar1[_14 * 3 + 1]) { + _04 -= psVar1[_14 * 3 + 1]; + _08 = _10; + _14++; + _0C = _08; + s16* ps = &psVar1[_14 * 3]; + switch(ps[0]) { + case 0xf: + _1C = 0; + return; + case 0xe: + _1C = 2; + return; + case 0xd: + _14 = ps[2]; + break; + default: + _18 = ps[0]; + _10 = ps[2] / 32768.0f; + break; + } + } + + updateCurrentValue(psVar1[_14 * 3 + 1]); } -#pragma pop /* ############################################################################################## */ /* 8039B1D0-8039B214 027830 0044+00 1/0 0/0 0/0 .rodata sCurveTableLinear__13JASOscillator */ -SECTION_RODATA u8 const JASOscillator::sCurveTableLinear[68] = { - 0x3F, 0x80, 0x00, 0x00, 0x3F, 0x70, 0x00, 0x00, 0x3F, 0x60, 0x00, 0x00, 0x3F, 0x50, - 0x00, 0x00, 0x3F, 0x40, 0x00, 0x00, 0x3F, 0x30, 0x00, 0x00, 0x3F, 0x20, 0x00, 0x00, - 0x3F, 0x10, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0xE0, 0x00, 0x00, 0x3E, 0xC0, - 0x00, 0x00, 0x3E, 0xA0, 0x00, 0x00, 0x3E, 0x80, 0x00, 0x00, 0x3E, 0x40, 0x00, 0x00, - 0x3E, 0x00, 0x00, 0x00, 0x3D, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +f32 const JASOscillator::sCurveTableLinear[17] = { + 1.0, 0.9375, 0.875, 0.8125, 0.75, 0.6875, 0.625, 0.5625, 0.5, + 0.4375, 0.375, 0.3125, 0.25, 0.1875, 0.125, 0.0625, 0.0, }; -COMPILER_STRIP_GATE(0x8039B1D0, &JASOscillator::sCurveTableLinear); /* 8039B214-8039B258 027874 0044+00 1/0 0/0 0/0 .rodata sCurveTableSampleCell__13JASOscillator */ -SECTION_RODATA u8 const JASOscillator::sCurveTableSampleCell[68] = { - 0x3F, 0x80, 0x00, 0x00, 0x3F, 0x78, 0x71, 0xF8, 0x3F, 0x48, 0x01, 0x93, 0x3F, 0x0B, - 0xD9, 0x12, 0x3E, 0xCC, 0xB1, 0x89, 0x3E, 0x94, 0x21, 0x18, 0x3E, 0x59, 0x31, 0xCA, - 0x3E, 0x21, 0x41, 0x63, 0x3D, 0xE6, 0xA1, 0xA5, 0x3D, 0xA7, 0x81, 0x4E, 0x3D, 0x6D, - 0x81, 0xE4, 0x3D, 0x32, 0xC1, 0x6E, 0x3C, 0xFC, 0x81, 0xFC, 0x3C, 0xC2, 0x41, 0x8E, - 0x3C, 0x7A, 0x02, 0x25, 0x3C, 0x16, 0x01, 0x29, 0x00, 0x00, 0x00, 0x00, +f32 const JASOscillator::sCurveTableSampleCell[17] = { + 1.0, 0.9704890251159668, 0.7812740206718445, 0.5462809801101685, 0.39979198575019836, + 0.28931498527526855, 0.21210399270057678, 0.15747599303722382, 0.1126129999756813, 0.08178959786891937, + 0.057985201478004456, 0.04364150017499924, 0.03082370012998581, 0.023712899535894394, 0.015259300358593464, + 0.00915555004030466, 0.0 }; -COMPILER_STRIP_GATE(0x8039B214, &JASOscillator::sCurveTableSampleCell); /* 8039B258-8039B29C 0278B8 0044+00 1/0 0/0 0/0 .rodata sCurveTableSqRoot__13JASOscillator */ -SECTION_RODATA u8 const JASOscillator::sCurveTableSqRoot[68] = { - 0x3F, 0x80, 0x00, 0x00, 0x3F, 0x60, 0xFF, 0xFC, 0x3F, 0x44, 0x00, 0x00, 0x3F, 0x28, - 0xFF, 0xFC, 0x3F, 0x10, 0x00, 0x00, 0x3E, 0xF1, 0xFF, 0xF8, 0x3E, 0xC8, 0x00, 0x00, - 0x3E, 0xA1, 0xFF, 0xF8, 0x3E, 0x80, 0x00, 0x00, 0x3E, 0x43, 0xFF, 0xEF, 0x3E, 0x10, - 0x00, 0x00, 0x3D, 0xC7, 0xFF, 0xF9, 0x3D, 0x80, 0x00, 0x00, 0x3D, 0x0F, 0xFF, 0xF3, - 0x3C, 0x80, 0x00, 0x00, 0x3B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +f32 const JASOscillator::sCurveTableSqRoot[17] = { + 1.0, 0.8789060115814209, 0.765625, 0.6601560115814209, 0.5625, 0.4726560115814209, + 0.390625, 0.3164060115814209, 0.25, 0.1914059966802597, 0.140625, 0.09765619784593582, + 0.0625, 0.03515620157122612, 0.015625, 0.00390625, 0.0 }; -COMPILER_STRIP_GATE(0x8039B258, &JASOscillator::sCurveTableSqRoot); /* 8039B29C-8039B2E0 0278FC 0044+00 1/0 0/0 0/0 .rodata sCurveTableSquare__13JASOscillator */ -SECTION_RODATA u8 const JASOscillator::sCurveTableSquare[68] = { - 0x3F, 0x80, 0x00, 0x00, 0x3F, 0x77, 0xDE, 0xF8, 0x3F, 0x6F, 0x77, 0x4B, 0x3F, 0x66, - 0xC1, 0x5D, 0x3F, 0x5D, 0xB3, 0xD0, 0x3F, 0x54, 0x43, 0x91, 0x3F, 0x4A, 0x62, 0xBB, - 0x3F, 0x40, 0x00, 0x00, 0x3F, 0x35, 0x04, 0xF7, 0x3F, 0x29, 0x54, 0x00, 0x3F, 0x1C, - 0xC4, 0x69, 0x3F, 0x0F, 0x1B, 0xBD, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0xDD, 0xB3, 0xE1, - 0x3E, 0xB5, 0x04, 0xE6, 0x3E, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +f32 const JASOscillator::sCurveTableSquare[17] = { + 1.0, 0.9682459831237793, 0.9354140162467957, 0.9013879895210266, 0.8660249710083008, + 0.8291559815406799, 0.790569007396698, 0.75, 0.7071070075035095, 0.66143798828125, + 0.6123719811439514, 0.55901700258255, 0.5, 0.433012992143631, 0.35355299711227417, 0.25, 0.0, }; -COMPILER_STRIP_GATE(0x8039B29C, &JASOscillator::sCurveTableSquare); /* 803C78A8-803C78B8 -00001 0010+00 1/1 0/0 0/0 .data table_list$151 */ -SECTION_DATA static void* table_list[4] = { - (void*)&JASOscillator::sCurveTableLinear, - (void*)&JASOscillator::sCurveTableSquare, - (void*)&JASOscillator::sCurveTableSqRoot, - (void*)&JASOscillator::sCurveTableSampleCell, +static f32* table_list[4] = { + (f32*)JASOscillator::sCurveTableLinear, + (f32*)JASOscillator::sCurveTableSquare, + (f32*)JASOscillator::sCurveTableSqRoot, + (f32*)JASOscillator::sCurveTableSampleCell, }; -/* 80455710-80455718 003D10 0004+04 1/1 0/0 0/0 .sdata2 @154 */ -SECTION_SDATA2 static f32 lit_154[1 + 1 /* padding */] = { - 16.0f, - /* padding */ - 0.0f, -}; - -/* 80455718-80455720 003D18 0008+00 1/1 0/0 0/0 .sdata2 @156 */ -SECTION_SDATA2 static f64 lit_156 = 4503599627370496.0 /* cast u32 to float */; - /* 8029C2C0-8029C388 296C00 00C8+00 1/1 0/0 0/0 .text updateCurrentValue__13JASOscillatorFf */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -asm void JASOscillator::updateCurrentValue(f32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/JASOscillator/updateCurrentValue__13JASOscillatorFf.s" +void JASOscillator::updateCurrentValue(f32 param_0) { + f32* table = table_list[_18]; + f32 fVar1 = 16.0f * (_04 / param_0); + u32 index = (u32) fVar1; + f32 fVar3 = (fVar1 - index); + f32 fVar2 = (1.0f - fVar3) * table[index]; + f32 fVar4 = fVar2 + fVar3 * table[index + 1]; + _08 = _0C * fVar4 + _10 * (1.0f - fVar4); } -#pragma pop diff --git a/libs/JSystem/JAudio2/Makefile b/libs/JSystem/JAudio2/Makefile index 44416c8b62..7214a07a51 100644 --- a/libs/JSystem/JAudio2/Makefile +++ b/libs/JSystem/JAudio2/Makefile @@ -150,6 +150,13 @@ LIBJAUDIO2_A_LDFLAGS := \ -proc gekko \ -linkmode moreram \ +DSP_CFLAGS := -pragma "function_align 32" -Cpp_exceptions off -proc gekko -fp hard -O4,p -nodefaults -str nopool,readonly,reuse -RTTI off -maxerrors 5 -enum int $(INCLUDES) + +$(BUILD_DIR)/libs/JSystem/JAudio2/dspproc.o: CFLAGS := $(DSP_CFLAGS) +$(BUILD_DIR)/libs/JSystem/JAudio2/osdsp.o: CFLAGS := $(DSP_CFLAGS) +$(BUILD_DIR)/libs/JSystem/JAudio2/osdsp_task.o: CFLAGS := $(DSP_CFLAGS) +$(BUILD_DIR)/libs/JSystem/JAudio2/dsptask.o: CFLAGS := $(DSP_CFLAGS) + $(BUILD_DIR)/libJAudio2.a: $(LIBJAUDIO2_A_O_FILES) @echo linking... $(BUILD_DIR)/libJAudio2.a @echo $(LIBJAUDIO2_A_O_FILES) > build/LIBJAUDIO2_A_ofiles diff --git a/libs/JSystem/JAudio2/dspproc.cpp b/libs/JSystem/JAudio2/dspproc.cpp index 03ff047c84..ee31c95b5e 100644 --- a/libs/JSystem/JAudio2/dspproc.cpp +++ b/libs/JSystem/JAudio2/dspproc.cpp @@ -4,54 +4,28 @@ // #include "JSystem/JAudio2/dspproc.h" -#include "dol2asm.h" #include "dolphin/types.h" // // Forward References: // -extern "C" void DSPReleaseHalt2__FUl(); -extern "C" static void setup_callback__FUs(); -extern "C" void DsetupTable__FUlUlUlUlUl(); -extern "C" void DsetMixerLevel__Ff(); -extern "C" void DsyncFrame2ch__FUlUlUl(); -extern "C" void DsyncFrame4ch__FUlUlUlUlUl(); - // // External References: // -extern "C" void DSP_CreateMap2__FUl(); -extern "C" void DSPSendCommands2__FPUlUlPFUs_v(); - // // Declarations: // -//Different compiler version for this TU? Something to note is that JAudio 1 is 32 byte aligned like this file - -#pragma function_align 32 - /* 8029E4E0-8029E528 298E20 0048+00 0/0 1/1 0/0 .text DSPReleaseHalt2__FUl */ -#ifdef NONMATCHING void DSPReleaseHalt2(u32 msg) { u32 msgs[2]; - msgs[0] = (msg<<16) | DSP_CreateMap2(msg); + u16 dspMap = DSP_CreateMap2(msg); + msgs[0] = (msg<<16) | dspMap; DSPSendCommands2(msgs,0,NULL); } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DSPReleaseHalt2(u32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/DSPReleaseHalt2__FUl.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 804512F8-80451300 0007F8 0004+04 2/2 0/0 0/0 .sbss flag */ @@ -63,82 +37,49 @@ static void setup_callback(u16 param_0) { } /* 8029E560-8029E5C4 298EA0 0064+00 0/0 1/1 0/0 .text DsetupTable__FUlUlUlUlUl */ -#ifdef NONMATCHING void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { - u32 r8 = 1; - void(*callback_func)(u16) = setup_callback; - u32 table[5] = {param_0&0xFFFF,param_1,param_2,param_3,param_4}; - flag = r8; - DSPSendCommands2(table,5,callback_func); + u32 table[5]; + table[0] = (param_0 & 0xFFFF) | 0x81000000; + table[1] = param_1; + table[2] = param_2; + table[3] = param_3; + table[4] = param_4; + flag = 1; + DSPSendCommands2(table,5,setup_callback); while (true) { if (flag==0) { return; } } } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DsetupTable(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/DsetupTable__FUlUlUlUlUl.s" -} -#pragma pop -#endif /* ############################################################################################## */ /* 804507C8-804507D0 000248 0002+06 3/3 0/0 0/0 .sdata DSP_MIXERLEVEL */ static u16 DSP_MIXERLEVEL = 0x4000; /* 8029E5E0-8029E604 298F20 0024+00 0/0 1/1 0/0 .text DsetMixerLevel__Ff */ -#ifdef NONMATCHING void DsetMixerLevel(f32 level) { DSP_MIXERLEVEL = 4096.0f*level; } -#else -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 - -/* 80455770-80455778 003D70 0004+04 1/1 0/0 0/0 .sdata2 @333 */ -SECTION_SDATA2 static f32 lit_333[1 + 1 /* padding */] = { - 4096.0f, - /* padding */ - 0.0f, -}; - -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DsetMixerLevel(f32 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/DsetMixerLevel__Ff.s" -} -#pragma pop -#endif /* 8029E620-8029E674 298F60 0054+00 0/0 1/1 0/0 .text DsyncFrame2ch__FUlUlUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DsyncFrame2ch(u32 param_0, u32 param_1, u32 param_2) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/DsyncFrame2ch__FUlUlUl.s" +void DsyncFrame2ch(u32 param_0, u32 param_1, u32 param_2) { + u32 msgs[5]; + msgs[0] = (param_0 & 0xff) << 0x10 | 0x82000000 | DSP_MIXERLEVEL; + msgs[1] = param_1; + msgs[2] = param_2; + msgs[3] = 0; + msgs[4] = 0; + DSPSendCommands2(msgs, 5, 0); } -#pragma pop /* 8029E680-8029E6D0 298FC0 0050+00 0/0 1/1 0/0 .text DsyncFrame4ch__FUlUlUlUlUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DsyncFrame4ch(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { - nofralloc -#include "asm/JSystem/JAudio2/dspproc/DsyncFrame4ch__FUlUlUlUlUl.s" +void DsyncFrame4ch(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { + u32 msgs[5]; + msgs[0] = (param_0 & 0xff) << 0x10 | 0x82000000 | DSP_MIXERLEVEL; + msgs[1] = param_1; + msgs[2] = param_2; + msgs[3] = param_3; + msgs[4] = param_4; + DSPSendCommands2(msgs, 5, 0); } -#pragma pop diff --git a/libs/JSystem/JAudio2/dsptask.cpp b/libs/JSystem/JAudio2/dsptask.cpp index 219c57a5c2..5d0aa92f7c 100644 --- a/libs/JSystem/JAudio2/dsptask.cpp +++ b/libs/JSystem/JAudio2/dsptask.cpp @@ -4,8 +4,11 @@ // #include "JSystem/JAudio2/dsptask.h" +#include "JSystem/JAudio2/osdsp.h" #include "dol2asm.h" #include "dolphin/types.h" +#include "dolphin/dsp/dsp.h" +#include "dolphin/os/OS.h" // // Types: @@ -24,6 +27,10 @@ extern "C" static void DspInitWork__Fv(); extern "C" static void DspStartWork__FUlPFUs_v(); extern "C" void DspFinishWork__FUs(); +static void DspInitWork(); +static void DspHandShake(void* param_0); +static int DspStartWork(u32 param_0, void (*param_1)(u16)); + // // External References: // @@ -31,17 +38,11 @@ extern "C" void DspFinishWork__FUs(); extern "C" void DSPAddPriorTask__FP15STRUCT_DSP_TASK(); extern "C" void Dsp_Running_Check__Fv(); extern "C" void Dsp_Running_Start__Fv(); -extern "C" void OSDisableInterrupts(); -extern "C" void OSRestoreInterrupts(); -extern "C" void DSPCheckMailToDSP(); -extern "C" void DSPCheckMailFromDSP(); -extern "C" void DSPReadMailFromDSP(); -extern "C" void DSPSendMailToDSP(); -extern "C" void DSPAssertInt(); -extern "C" void DSPInit(); extern "C" void _savegpr_26(); extern "C" void _restgpr_26(); +extern int Dsp_Running_Check(); + // // Declarations: // @@ -565,32 +566,90 @@ static u8 audio_task[80 + 16 /* padding */]; static u8 AUDIO_YIELD_BUFFER[8192]; /* 8029E720-8029E7CC 299060 00AC+00 0/0 1/1 0/0 .text DspBoot__FPFPv_v */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DspBoot(void (*param_0)(void*)) { - nofralloc -#include "asm/JSystem/JAudio2/dsptask/DspBoot__FPFPv_v.s" +void DspBoot(void (*param_0)(void*)) { + DspInitWork(); + ((DSPTaskInfo*)audio_task)->priority = 0xf0; + ((DSPTaskInfo*)audio_task)->iram_mmem_addr = (u16*)(jdsp + 0x80000000); + ((DSPTaskInfo*)audio_task)->iram_length = sizeof(jdsp); + ((DSPTaskInfo*)audio_task)->iram_addr = 0; + ((DSPTaskInfo*)audio_task)->dram_mmem_addr = (u16*)(AUDIO_YIELD_BUFFER + 0x80000000); + ((DSPTaskInfo*)audio_task)->dram_length = sizeof(AUDIO_YIELD_BUFFER); + ((DSPTaskInfo*)audio_task)->dram_addr = 0; + ((DSPTaskInfo*)audio_task)->dsp_init_vector = 0; + ((DSPTaskInfo*)audio_task)->dsp_resume_vector = 0x10; + ((DSPTaskInfo*)audio_task)->init_cb = DspHandShake; + ((DSPTaskInfo*)audio_task)->res_cb = NULL; + ((DSPTaskInfo*)audio_task)->done_cb = NULL; + ((DSPTaskInfo*)audio_task)->req_cb = param_0; + DSPInit(); + DSPAddPriorTask((STRUCT_DSP_TASK*)audio_task); } -#pragma pop /* 8029E7E0-8029E8C8 299120 00E8+00 0/0 4/4 0/0 .text DSPSendCommands2__FPUlUlPFUs_v */ +// lwz instead of lwzx in loop +#ifdef NONMATCHING +int DSPSendCommands2(u32* param_0, u32 param_1, void (*param_2)(u16)) { + while (Dsp_Running_Check() == 0); + + BOOL status = OSDisableInterrupts(); + if (DSPCheckMailToDSP()) { + OSRestoreInterrupts(status); + return -1; + } + + DSPSendMailToDSP(param_1); + DSPAssertInt(); + while(DSPCheckMailToDSP() != 0); + + if (param_1 == 0) { + param_1 = 1; + } + + int startWorkStatus; + if (param_2 != NULL) { + startWorkStatus = DspStartWork(param_0[0], param_2); + } + + for (int i = 0; i < param_1; i++) { + DSPSendMailToDSP(param_0[i]); + while (DSPCheckMailToDSP() != 0); + } + + OSRestoreInterrupts(status); + return startWorkStatus; +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off #pragma function_align 32 -asm void DSPSendCommands2(u32* param_0, u32 param_1, void (*param_2)(u16)) { +asm int DSPSendCommands2(u32* param_0, u32 param_1, void (*param_2)(u16)) { nofralloc #include "asm/JSystem/JAudio2/dsptask/DSPSendCommands2__FPUlUlPFUs_v.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80433FE0-80434060 060D00 0080+00 3/3 0/0 0/0 .bss taskwork */ -static u8 taskwork[128]; + +typedef struct { + u16 field_0x0; + u16 field_0x2; + void (*field_0x4)(u16); +} TaskWorkStruct; + +static TaskWorkStruct taskwork[16]; /* 8029E8E0-8029E90C 299220 002C+00 1/1 0/0 0/0 .text DspInitWork__Fv */ +// Loop is unrolled but should not be +#ifdef NONMATCHING +static void DspInitWork() { + for (int i = 0; i < 16; i++) { + taskwork[i].field_0x4 = NULL; + } +} +#else #pragma push #pragma optimization_level 0 #pragma optimizewithasm off @@ -600,32 +659,36 @@ static asm void DspInitWork() { #include "asm/JSystem/JAudio2/dsptask/DspInitWork__Fv.s" } #pragma pop +#endif /* ############################################################################################## */ /* 80451300-80451304 000800 0004+00 2/2 0/0 0/0 .sbss taskreadp */ -static u8 taskreadp[4]; +static u32 taskreadp; /* 80451304-80451308 000804 0004+00 1/1 0/0 0/0 .sbss taskwritep */ -static u8 taskwritep[4]; +static u32 taskwritep; /* 8029E920-8029E968 299260 0048+00 1/1 0/0 0/0 .text DspStartWork__FUlPFUs_v */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -static asm void DspStartWork(u32 param_0, void (*param_1)(u16)) { - nofralloc -#include "asm/JSystem/JAudio2/dsptask/DspStartWork__FUlPFUs_v.s" +static int DspStartWork(u32 param_0, void (*param_1)(u16)) { + u32 taskWritePrev = taskwritep; + u32 writeVal = ((taskWritePrev + 1) & 0xf); + if (writeVal == taskreadp) { + return 0; + } + + taskwritep = writeVal; + taskwork[taskWritePrev].field_0x0 = param_0 >> 0x10; + taskwork[taskWritePrev].field_0x4 = param_1; + return taskWritePrev + 1; } -#pragma pop /* 8029E980-8029E9E8 2992C0 0068+00 0/0 1/1 0/0 .text DspFinishWork__FUs */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DspFinishWork(u16 param_0) { - nofralloc -#include "asm/JSystem/JAudio2/dsptask/DspFinishWork__FUs.s" +void DspFinishWork(u16 param_0) { + if (param_0 == taskwork[taskreadp].field_0x0) { + if (taskwork[taskreadp].field_0x4) { + taskwork[taskreadp].field_0x4(taskreadp); + } + + taskreadp = (taskreadp + 1) & 0xf; + } } -#pragma pop diff --git a/libs/JSystem/JAudio2/osdsp.cpp b/libs/JSystem/JAudio2/osdsp.cpp index 8b76ebf922..b45f225f16 100644 --- a/libs/JSystem/JAudio2/osdsp.cpp +++ b/libs/JSystem/JAudio2/osdsp.cpp @@ -4,133 +4,61 @@ // #include "JSystem/JAudio2/osdsp.h" -#include "dol2asm.h" +#include "JSystem/JAudio2/osdsp_task.h" #include "dolphin/types.h" +#include "dolphin/os/OS.h" +#include "dolphin/dsp/dsp.h" +#include "dolphin/dsp/dsp_task.h" // // Types: // -struct STRUCT_DSP_TASK {}; +// Unclear why this is a different type than DSPTaskInfo +struct STRUCT_DSP_TASK { + DSPTaskInfo info; +}; // // Forward References: // -extern "C" void DSPAddTask(); -extern "C" void DSPAddPriorTask__FP15STRUCT_DSP_TASK(); - // // External References: // -extern "C" void OSReport(); -extern "C" void OSDisableInterrupts(); -extern "C" void OSRestoreInterrupts(); -extern "C" void __DSP_boot_task(); -extern "C" void __DSP_insert_task(); -extern "C" extern u8 DSP_prior_task[4]; - // // Declarations: // /* ############################################################################################## */ -/* 8039B8B8-8039B8D4 027F18 001A+02 1/1 0/0 0/0 .rodata @81 */ -SECTION_RODATA static u8 const lit_81[26 + 2 /* padding */] = { - 0x50, - 0x72, - 0x69, - 0x6F, - 0x72, - 0x20, - 0x54, - 0x61, - 0x73, - 0x6B, - 0x20, - 0x69, - 0x73, - 0x20, - 0x6E, - 0x6F, - 0x74, - 0x20, - 0x69, - 0x6E, - 0x69, - 0x74, - 0x65, - 0x64, - 0x0A, - 0x00, - /* padding */ - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x8039B8B8, &lit_81); /* 8029EA00-8029EA84 299340 0084+00 0/0 1/1 0/0 .text DSPAddTask */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DSPAddTask() { - nofralloc -#include "asm/JSystem/JAudio2/osdsp/DSPAddTask.s" +DSPTaskInfo* DSPAddTask(DSPTaskInfo* task) { + if (DSP_prior_task == NULL) { + OSReport("Prior Task is not inited\n"); + return NULL; + } + BOOL status = OSDisableInterrupts(); + __DSP_insert_task(task); + task->state = 0; + task->flags = 1; + OSRestoreInterrupts(status); + return task; } -#pragma pop /* ############################################################################################## */ -/* 8039B8D4-8039B8F8 027F34 001F+05 1/1 0/0 0/0 .rodata @88 */ -SECTION_RODATA static u8 const lit_88[31 + 5 /* padding */] = { - 0x41, - 0x6C, - 0x72, - 0x65, - 0x61, - 0x64, - 0x79, - 0x20, - 0x69, - 0x6E, - 0x69, - 0x74, - 0x65, - 0x64, - 0x20, - 0x70, - 0x72, - 0x69, - 0x6F, - 0x72, - 0x20, - 0x44, - 0x53, - 0x50, - 0x20, - 0x74, - 0x61, - 0x73, - 0x6B, - 0x0A, - 0x00, - /* padding */ - 0x00, - 0x00, - 0x00, - 0x00, - 0x00, -}; -COMPILER_STRIP_GATE(0x8039B8D4, &lit_88); /* 8029EAA0-8029EB1C 2993E0 007C+00 0/0 1/1 0/0 .text DSPAddPriorTask__FP15STRUCT_DSP_TASK */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DSPAddPriorTask(STRUCT_DSP_TASK* param_0) { - nofralloc -#include "asm/JSystem/JAudio2/osdsp/DSPAddPriorTask__FP15STRUCT_DSP_TASK.s" +void DSPAddPriorTask(STRUCT_DSP_TASK* task) { + if (DSP_prior_task != NULL) { + OSReport("Already inited prior DSP task\n"); + return; + } + BOOL status = OSDisableInterrupts(); + DSP_prior_task = (DSPTaskInfo*)task; + task->info.state = 0; + task->info.flags = 1; + __DSP_boot_task((DSPTaskInfo*)task); + OSRestoreInterrupts(status); } -#pragma pop diff --git a/libs/JSystem/JAudio2/osdsp_task.cpp b/libs/JSystem/JAudio2/osdsp_task.cpp index 14a0b14a3d..9be61505df 100644 --- a/libs/JSystem/JAudio2/osdsp_task.cpp +++ b/libs/JSystem/JAudio2/osdsp_task.cpp @@ -4,41 +4,22 @@ // #include "JSystem/JAudio2/osdsp_task.h" -#include "dol2asm.h" +#include "JSystem/JAudio2/dspproc.h" #include "dolphin/types.h" +#include "dolphin/dsp/dsp.h" +#include "dolphin/dsp/dsp_task.h" +#include "dolphin/os/OSContext.h" // // Forward References: // -extern "C" void __DSPHandler(); -extern "C" void DsyncFrame2__FUlUlUl(); -extern "C" static void DsyncFrame3__FUlUlUlUlUl(); -extern "C" static void Dsp_Update_Request__Fv(); -extern "C" void Dsp_Running_Check__Fv(); -extern "C" void Dsp_Running_Start__Fv(); -extern "C" extern u8 data_80451310[8]; -extern "C" extern u8 data_80451318[8]; -extern "C" extern u8 data_80451320[8]; -extern "C" extern u8 data_80451328[8]; +static void Dsp_Update_Request(); // // External References: // -extern "C" void DsyncFrame2ch__FUlUlUl(); -extern "C" void DsyncFrame4ch__FUlUlUlUlUl(); -extern "C" void OSSetCurrentContext(); -extern "C" void OSClearContext(); -extern "C" void DSPCheckMailToDSP(); -extern "C" void DSPCheckMailFromDSP(); -extern "C" void DSPReadMailFromDSP(); -extern "C" void DSPSendMailToDSP(); -extern "C" void __DSP_exec_task(); -extern "C" void __DSP_remove_task(); -extern "C" extern u8 __DSP_first_task[4]; -extern "C" extern u8 __DSP_curr_task[4]; - // // Declarations: // @@ -47,95 +28,174 @@ extern "C" extern u8 __DSP_curr_task[4]; /* 80451308-8045130C -00001 0004+00 6/6 0/0 0/0 .sbss None */ /* 80451308 0001+00 data_80451308 None */ /* 80451309 0003+00 data_80451309 None */ -static u8 struct_80451308[4]; + +static vu8 struct_80451308; +static u8 struct_80451309; +static u8 struct_8045130a; +static u8 struct_8045130b; /* 8045130C-80451310 00080C 0004+00 1/1 2/2 0/0 .sbss DSP_prior_task */ -extern u8 DSP_prior_task[4]; -u8 DSP_prior_task[4]; +DSPTaskInfo* DSP_prior_task; /* 8029EB20-8029EE24 299460 0304+00 0/0 1/1 0/0 .text __DSPHandler */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void __DSPHandler() { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/__DSPHandler.s" +void __DSPHandler(OSInterrupt interrupt, OSContext* context) { + OSContext funcContext; + __DSPRegs[5] = ((u16)(__DSPRegs[5]) & ~0x28) | 0x80; + OSClearContext(&funcContext); + OSSetCurrentContext(&funcContext); + + if (struct_80451308 == 1 || struct_80451308 == 0) { + __DSP_curr_task = DSP_prior_task; + } + + while (DSPCheckMailFromDSP() == 0); + u32 mail = DSPReadMailFromDSP(); + + if ((__DSP_curr_task->flags & 2) && mail == 0xDCD10002) { + mail = 0xDCD10003; + } + + switch (mail) { + case 0xDCD10000: + __DSP_curr_task->state = 1; + if (__DSP_curr_task == DSP_prior_task) { + struct_80451308 = 1; + } + if (__DSP_curr_task->init_cb != NULL) { + __DSP_curr_task->init_cb(__DSP_curr_task); + } + break; + case 0xDCD10001: + __DSP_curr_task->state = 1; + if (__DSP_curr_task == DSP_prior_task) { + struct_80451308 = 1; + Dsp_Update_Request(); + } + if (__DSP_curr_task->res_cb != NULL) { + __DSP_curr_task->res_cb(__DSP_curr_task); + } + break; + case 0xDCD10002: + DSPSendMailToDSP(0xCDD10001); + while (DSPCheckMailToDSP() != 0); + __DSP_curr_task->state = 2; + if (__DSP_curr_task->next == NULL && struct_80451309) { + __DSP_exec_task(__DSP_curr_task, DSP_prior_task); + struct_80451309 = 0; + __DSP_curr_task = DSP_prior_task; + } else { + __DSP_exec_task(__DSP_curr_task, __DSP_curr_task->next); + __DSP_curr_task = __DSP_curr_task->next; + } + break; + case 0xDCD10003: + if (__DSP_curr_task->done_cb != NULL) { + __DSP_curr_task->done_cb(__DSP_curr_task); + } + DSPSendMailToDSP(0xCDD10001); + while (DSPCheckMailToDSP() != 0); + __DSP_curr_task->state = 3; + if (__DSP_curr_task->next == NULL) { + __DSP_exec_task(NULL, DSP_prior_task); + __DSP_remove_task(__DSP_curr_task); + __DSP_curr_task = DSP_prior_task; + } else { + __DSP_exec_task(NULL, __DSP_curr_task->next); + __DSP_curr_task = __DSP_curr_task->next; + __DSP_remove_task(__DSP_curr_task->prev); + } + break; + case 0xDCD10004: + if (__DSP_curr_task->req_cb != NULL) { + __DSP_curr_task->req_cb(__DSP_curr_task); + } + break; + case 0xDCD10005: + if (__DSP_first_task == NULL || struct_80451309) { + DSPSendMailToDSP(0xCDD10003); + while (DSPCheckMailToDSP() != 0); + struct_80451309 = 0; + __DSP_curr_task = DSP_prior_task; + Dsp_Update_Request(); + } else { + struct_80451308 = 3; + DSPSendMailToDSP(0xCDD10001); + while (DSPCheckMailToDSP() != 0); + __DSP_exec_task(DSP_prior_task, __DSP_first_task); + __DSP_curr_task = __DSP_first_task; + } + break; + } + + OSClearContext(&funcContext); + OSSetCurrentContext(context); } -#pragma pop /* ############################################################################################## */ /* 80434060-80434078 060D80 0014+04 3/3 0/0 0/0 .bss sync_stack */ -static u8 sync_stack[20 + 4 /* padding */]; +static u32 sync_stack[5]; /* 8029EE40-8029EE90 299780 0050+00 1/1 1/1 0/0 .text DsyncFrame2__FUlUlUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void DsyncFrame2(u32 param_0, u32 param_1, u32 param_2) { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/DsyncFrame2__FUlUlUl.s" +void DsyncFrame2(u32 param_0, u32 param_1, u32 param_2) { + if (struct_80451308 != 1) { + sync_stack[0] = param_0; + sync_stack[1] = param_1; + sync_stack[2] = param_2; + struct_80451309 = 1; + return; + } + DsyncFrame2ch(param_0, param_1, param_2); + struct_80451309 = 0; } -#pragma pop /* 8029EEA0-8029EEF8 2997E0 0058+00 1/1 0/0 0/0 .text DsyncFrame3__FUlUlUlUlUl */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -static asm void DsyncFrame3(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/DsyncFrame3__FUlUlUlUlUl.s" +static void DsyncFrame3(u32 param_0, u32 param_1, u32 param_2, u32 param_3, u32 param_4) { + if (struct_80451308 != 1) { + sync_stack[0] = param_0; + sync_stack[1] = param_1; + sync_stack[2] = param_2; + sync_stack[3] = param_3; + sync_stack[4] = param_4; + struct_80451309 = 2; + return; + } + DsyncFrame4ch(param_0, param_1, param_2, param_3, param_4); + struct_80451309 = 0; } -#pragma pop /* 8029EF00-8029EF78 299840 0078+00 1/1 0/0 0/0 .text Dsp_Update_Request__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -static asm void Dsp_Update_Request() { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/Dsp_Update_Request__Fv.s" +static void Dsp_Update_Request() { + switch (struct_80451309) { + case 0: + break; + case 1: + DsyncFrame2(sync_stack[0], sync_stack[1], sync_stack[2]); + break; + case 2: + DsyncFrame3(sync_stack[0], sync_stack[1], sync_stack[2], sync_stack[3], sync_stack[4]); + break; + } } -#pragma pop /* 8029EF80-8029EF94 2998C0 0014+00 0/0 1/1 0/0 .text Dsp_Running_Check__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void Dsp_Running_Check() { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/Dsp_Running_Check__Fv.s" +bool Dsp_Running_Check() { + return struct_80451308 == 1; } -#pragma pop /* 8029EFA0-8029EFAC 2998E0 000C+00 0/0 1/1 0/0 .text Dsp_Running_Start__Fv */ -#pragma push -#pragma optimization_level 0 -#pragma optimizewithasm off -#pragma function_align 32 -asm void Dsp_Running_Start() { - nofralloc -#include "asm/JSystem/JAudio2/osdsp_task/Dsp_Running_Start__Fv.s" +void Dsp_Running_Start() { + struct_80451308 = 1; } -#pragma pop /* ############################################################################################## */ /* 80451310-80451318 000810 0008+00 0/0 3/3 0/0 .sbss None */ -extern u8 data_80451310[8]; u8 data_80451310[8]; /* 80451318-80451320 000818 0008+00 0/0 7/7 0/0 .sbss None */ -extern u8 data_80451318[8]; u8 data_80451318[8]; /* 80451320-80451328 000820 0008+00 0/0 4/4 0/0 .sbss None */ -extern u8 data_80451320[8]; u8 data_80451320[8]; /* 80451328-80451330 000828 0008+00 0/0 3/3 0/0 .sbss None */ -extern u8 data_80451328[8]; u8 data_80451328[8]; diff --git a/libs/dolphin/dsp/dsp.c b/libs/dolphin/dsp/dsp.c index be2d4327b5..d13d807076 100644 --- a/libs/dolphin/dsp/dsp.c +++ b/libs/dolphin/dsp/dsp.c @@ -2,6 +2,7 @@ #include "dolphin/dsp/dsp_debug.h" #include "dolphin/dsp/dsp_task.h" #include "dolphin/os/OS.h" +#include "JSystem/JAudio2/osdsp_task.h" /* 80450A58-80450A60 -00001 0004+04 1/1 0/0 0/0 .sdata __DSPVersion */ static char* __DSPVersion = "<< Dolphin SDK - DSP\trelease build: Apr 5 2004 04:15:32 (0x2301) >>"; @@ -13,8 +14,6 @@ static s32 __DSP_init_flag; // External References: // -void __DSPHandler(s16 interrupt, OSContext* context); - // // Declarations: // |
