mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-15 05:40:55 -04:00
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include "JSystem/JKernel/JKRExpHeap.h"
|
||||
#include "JSystem/JKernel/JKRFileCache.h"
|
||||
#include "JSystem/JUtility/JUTConsole.h"
|
||||
#include "stdio.h"
|
||||
#include <stdio>
|
||||
#include "m_Do/m_Do_dvd_thread.h"
|
||||
#include "m_Do/m_Do_ext.h"
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
|
||||
J2DGrafContext::J2DGrafContext(f32 x, f32 y, f32 width, f32 height)
|
||||
: mBounds(x, y, x + width, y + height), mScissorBounds(x, y, x + width, y + height) {
|
||||
if (x < 0.0f || y < 0.0f) {
|
||||
OS_REPORT("J2DWarning::ViewPort-Bounds \"Avoid using negative values for left or top.\"\n");
|
||||
}
|
||||
JUtility::TColor color(-1);
|
||||
setColor(color);
|
||||
setLineWidth(6);
|
||||
@@ -81,13 +84,15 @@ void J2DGrafContext::scissor(JGeometry::TBox2<f32> const& bounds) {
|
||||
}
|
||||
|
||||
void J2DGrafContext::place(JGeometry::TBox2<f32> const& bounds) {
|
||||
if (bounds.i.x < 0.0f || bounds.i.y < 0.0f) {
|
||||
if (mBounds.i.x >= 0.0f && mBounds.i.y >= 0.0f) {
|
||||
OS_REPORT("J2DWarning::ViewPort-Bounds \"Avoid using negative values for left or top.\"\n");
|
||||
}
|
||||
}
|
||||
mBounds = bounds;
|
||||
mScissorBounds = bounds;
|
||||
}
|
||||
|
||||
/* 802E9118-802E9234 2E3A58 011C+00 1/1 4/4 0/0 .text
|
||||
* setColor__14J2DGrafContextFQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColor
|
||||
*/
|
||||
void J2DGrafContext::setColor(JUtility::TColor colorTL, JUtility::TColor colorTR,
|
||||
JUtility::TColor colorBR, JUtility::TColor colorBL) {
|
||||
mColorTL = colorTL;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "JSystem/J2DGraph/J2DManage.h"
|
||||
#include "JSystem/JSupport/JSUInputStream.h"
|
||||
#include "string.h"
|
||||
#include <string>
|
||||
|
||||
void* J2DDataManage::get(char const* name) {
|
||||
for (J2DataManageLink* link = mList; link != NULL; link = link->mNext) {
|
||||
|
||||
@@ -40,7 +40,7 @@ void J2DMaterial::setGX() {
|
||||
}
|
||||
|
||||
J2DTevBlock* J2DMaterial::createTevBlock(int block_type, bool noAlign) {
|
||||
J2DTevBlock* block;
|
||||
J2DTevBlock* block = NULL;
|
||||
|
||||
if (noAlign) {
|
||||
if (block_type <= 1) {
|
||||
@@ -67,12 +67,15 @@ J2DTevBlock* J2DMaterial::createTevBlock(int block_type, bool noAlign) {
|
||||
block = new (-4) J2DTevBlock16();
|
||||
}
|
||||
}
|
||||
if (!block) {
|
||||
OS_PANIC(101, "Error : allocate memory.");
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
|
||||
J2DIndBlock* J2DMaterial::createIndBlock(int block_type, bool noAlign) {
|
||||
J2DIndBlock* block;
|
||||
J2DIndBlock* block = NULL;
|
||||
|
||||
if (noAlign) {
|
||||
if (block_type != 0) {
|
||||
@@ -87,6 +90,9 @@ J2DIndBlock* J2DMaterial::createIndBlock(int block_type, bool noAlign) {
|
||||
block = new (-4) J2DIndBlockNull();
|
||||
}
|
||||
}
|
||||
if (!block) {
|
||||
OS_PANIC(133, "Error : allocate memory.");
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
@@ -116,8 +122,18 @@ J2DMaterial::J2DMaterialAnmPointer::J2DMaterialAnmPointer() {
|
||||
}
|
||||
|
||||
void J2DMaterial::makeAnmPointer() {
|
||||
int r29;
|
||||
int r28;
|
||||
if (mAnmPointer == NULL) {
|
||||
mAnmPointer = new J2DMaterialAnmPointer();
|
||||
r29 = 1;
|
||||
if (mAnmPointer == NULL) {
|
||||
OS_PANIC(171, "Error : allocate memory.");
|
||||
r28 = 0;
|
||||
if (!r28) {
|
||||
r29 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,9 +173,7 @@ void J2DMaterial::setAnimation(J2DAnmTextureSRTKey* anm) {
|
||||
u16 index = getIndex();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
u16 matID = anm->getUpdateMaterialID(i);
|
||||
|
||||
if (index == matID) {
|
||||
if (index == anm->getUpdateMaterialID(i)) {
|
||||
u8 mtxID = anm->getUpdateTexMtxID(i);
|
||||
mAnmPointer->mSRTIds[mtxID] = i;
|
||||
}
|
||||
@@ -183,9 +197,7 @@ void J2DMaterial::setAnimation(J2DAnmTexPattern* anm) {
|
||||
J3DAnmTexPatternFullTable* anmTbl = anm->getAnmTable();
|
||||
|
||||
for (u16 i = 0; i < matNum; i++) {
|
||||
u16 matID = anm->getUpdateMaterialID(i);
|
||||
|
||||
if (index == matID) {
|
||||
if (index == anm->getUpdateMaterialID(i)) {
|
||||
mAnmPointer->mPatternIds[anmTbl[i].mTexNo] = i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
#include "string.h"
|
||||
#include <string>
|
||||
#include "dolphin/types.h"
|
||||
|
||||
J2DMaterialFactory::J2DMaterialFactory(J2DMaterialBlock const& param_0) {
|
||||
@@ -60,9 +60,6 @@ u32 J2DMaterialFactory::countStages(int param_0) const {
|
||||
return uVar3;
|
||||
}
|
||||
|
||||
/* 802F2D1C-802F362C 2ED65C 0910+00 0/0 1/1 0/0 .text
|
||||
* create__18J2DMaterialFactoryCFP11J2DMaterialiUlP15J2DResReferenceP15J2DResReferenceP10JKRArchive
|
||||
*/
|
||||
J2DMaterial* J2DMaterialFactory::create(J2DMaterial* param_0, int index, u32 param_2,
|
||||
J2DResReference* param_3, J2DResReference* param_4,
|
||||
JKRArchive* param_5) const {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JUtility/JUTFont.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio>
|
||||
#include <stdlib>
|
||||
|
||||
char* J2DPrint::mStrBuff;
|
||||
|
||||
@@ -34,9 +34,6 @@ J2DPrint::J2DPrint(JUTFont* pFont, JUtility::TColor charColor, JUtility::TColor
|
||||
private_initiate(pFont, 0.0f, 0.0f, charColor, gradColor, 0, 0xFFFFFFFF, true);
|
||||
}
|
||||
|
||||
/* 802F4394-802F4420 2EECD4 008C+00 0/0 6/6 0/0 .text
|
||||
* __ct__8J2DPrintFP7JUTFontffQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColor
|
||||
*/
|
||||
J2DPrint::J2DPrint(JUTFont* pFont, f32 charSpacing, f32 lineSpacing, JUtility::TColor charColor,
|
||||
JUtility::TColor gradColor, JUtility::TColor blackColor, JUtility::TColor whiteColor) {
|
||||
private_initiate(pFont, charSpacing, lineSpacing, charColor, gradColor, blackColor, whiteColor, false);
|
||||
@@ -50,9 +47,6 @@ void J2DPrint::initiate() {
|
||||
}
|
||||
}
|
||||
|
||||
/* 802F4468-802F4658 2EEDA8 01F0+00 1/1 0/0 0/0 .text
|
||||
* private_initiate__8J2DPrintFP7JUTFontffQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColorb
|
||||
*/
|
||||
void J2DPrint::private_initiate(JUTFont* pFont, f32 charSpacing, f32 lineSpacing, JUtility::TColor charColor,
|
||||
JUtility::TColor gradColor, JUtility::TColor blackColor,
|
||||
JUtility::TColor whiteColor, bool param_7) {
|
||||
@@ -317,7 +311,7 @@ f32 J2DPrint::parse(const u8* pString, int length, int param_2, u16* param_3,
|
||||
} else {
|
||||
if (param_6) {
|
||||
if (param_3 != NULL) {
|
||||
mFont->drawChar_scale(mCursorH + (f32)(s16)param_3[someIndex], mCursorV, (s32)mScaleX, (s32)mScaleY, iCharacter, true);
|
||||
mFont->drawChar_scale(mCursorH + (s16)param_3[someIndex], mCursorV, (s32)mScaleX, (s32)mScaleY, iCharacter, true);
|
||||
} else {
|
||||
mFont->drawChar_scale(mCursorH, mCursorV, (s32)mScaleX, (s32)mScaleY, iCharacter, true);
|
||||
}
|
||||
|
||||
@@ -6,32 +6,33 @@
|
||||
|
||||
#include "JSystem/J2DGraph/J2DTevs.h"
|
||||
#include "JSystem/J2DGraph/J2DMatBlock.h"
|
||||
#include "math.h"
|
||||
#include <math>
|
||||
#include "dolphin/gx.h"
|
||||
|
||||
void J2DTexMtx::load(u32 mtxIdx) {
|
||||
GXLoadTexMtxImm(mTexMtx, mtxIdx * 3 + GX_TEXMTX0, mInfo.getTexMtxType());
|
||||
GXLoadTexMtxImm(mTexMtx, mtxIdx * 3 + GX_TEXMTX0, (GXTexMtxType)mInfo.mTexMtxType);
|
||||
}
|
||||
|
||||
void J2DTexMtx::calc() {
|
||||
if (mInfo.mTexMtxDCC == J2DTexMtxInfo::DCC_NONE) {
|
||||
u32 dcc = mInfo.mTexMtxDCC;
|
||||
if (dcc == J2DTexMtxInfo::DCC_NONE) {
|
||||
getTextureMtx(mInfo.mTexSRTInfo, mInfo.mCenter, mTexMtx);
|
||||
} else if (mInfo.mTexMtxDCC == J2DTexMtxInfo::DCC_MAYA) {
|
||||
} else if (dcc == J2DTexMtxInfo::DCC_MAYA) {
|
||||
getTextureMtxMaya(mInfo.mTexSRTInfo, mTexMtx);
|
||||
}
|
||||
}
|
||||
|
||||
void J2DTexMtx::getTextureMtx(J2DTextureSRTInfo const& param_0, Vec param_1, Mtx param_2) {
|
||||
float f31 = (param_0.mRotationDeg * M_PI) / 180.0f;
|
||||
param_2[0][0] = param_0.mScaleX * i_cosf(f31);
|
||||
param_2[0][1] = -param_0.mScaleX * i_sinf(f31);
|
||||
param_2[0][0] = param_0.mScaleX * cosf(f31);
|
||||
param_2[0][1] = -param_0.mScaleX * sinf(f31);
|
||||
param_2[0][2] = 0.0f;
|
||||
param_2[0][3] = -param_0.mScaleX * i_cosf(f31) * param_1.x + param_1.y * (param_0.mScaleX * i_sinf(f31)) +
|
||||
param_2[0][3] = -param_0.mScaleX * cosf(f31) * param_1.x + param_1.y * (param_0.mScaleX * sinf(f31)) +
|
||||
param_1.x + param_0.mTranslationX;
|
||||
param_2[1][0] = param_0.mScaleY * i_sinf(f31);
|
||||
param_2[1][1] = param_0.mScaleY * i_cosf(f31);
|
||||
param_2[1][0] = param_0.mScaleY * sinf(f31);
|
||||
param_2[1][1] = param_0.mScaleY * cosf(f31);
|
||||
param_2[1][2] = 0.0f;
|
||||
param_2[1][3] = -param_0.mScaleY * i_sinf(f31) * param_1.x - param_1.y * (param_0.mScaleY * i_cosf(f31)) +
|
||||
param_2[1][3] = -param_0.mScaleY * sinf(f31) * param_1.x - param_1.y * (param_0.mScaleY * cosf(f31)) +
|
||||
param_1.y + param_0.mTranslationY;
|
||||
param_2[2][0] = 0.0f;
|
||||
param_2[2][1] = 0.0f;
|
||||
@@ -41,16 +42,16 @@ void J2DTexMtx::getTextureMtx(J2DTextureSRTInfo const& param_0, Vec param_1, Mtx
|
||||
|
||||
void J2DTexMtx::getTextureMtxMaya(J2DTextureSRTInfo const& param_0, Mtx param_1) {
|
||||
float f31 = (param_0.mRotationDeg * M_PI) / 180.0f;
|
||||
param_1[0][0] = param_0.mScaleX * i_cosf(f31);
|
||||
param_1[0][1] = param_0.mScaleY * i_sinf(f31);
|
||||
param_1[0][0] = param_0.mScaleX * cosf(f31);
|
||||
param_1[0][1] = param_0.mScaleY * sinf(f31);
|
||||
param_1[0][2] = 0.0f;
|
||||
param_1[0][3] = (param_0.mTranslationX - 0.5f) * i_cosf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * i_sinf(f31) + 0.5f;
|
||||
param_1[1][0] = -param_0.mScaleX * i_sinf(f31);
|
||||
param_1[1][1] = param_0.mScaleY * i_cosf(f31);
|
||||
param_1[0][3] = (param_0.mTranslationX - 0.5f) * cosf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * sinf(f31) + 0.5f;
|
||||
param_1[1][0] = -param_0.mScaleX * sinf(f31);
|
||||
param_1[1][1] = param_0.mScaleY * cosf(f31);
|
||||
param_1[1][2] = 0.0f;
|
||||
param_1[1][3] = -(param_0.mTranslationX - 0.5f) * i_sinf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * i_cosf(f31) + 0.5f;
|
||||
param_1[1][3] = -(param_0.mTranslationX - 0.5f) * sinf(f31) -
|
||||
(param_0.mTranslationY - 0.5f + param_0.mScaleY) * cosf(f31) + 0.5f;
|
||||
param_1[2][0] = 0.0f;
|
||||
param_1[2][1] = 0.0f;
|
||||
param_1[2][2] = 1.0f;
|
||||
@@ -58,8 +59,8 @@ void J2DTexMtx::getTextureMtxMaya(J2DTextureSRTInfo const& param_0, Mtx param_1)
|
||||
}
|
||||
|
||||
void J2DIndTevStage::load(u8 tevStage) {
|
||||
GXSetTevIndirect((GXTevStageID)tevStage, getIndStage(), getIndFormat(), getBiasSel(),
|
||||
getMtxSel(), getWrapS(), getWrapT(), getPrev(), getLod(), getAlphaSel());
|
||||
GXSetTevIndirect((GXTevStageID)tevStage, (GXIndTexStageID)getIndStage(), (GXIndTexFormat)getIndFormat(), (GXIndTexBiasSel)getBiasSel(),
|
||||
(GXIndTexMtxID)getMtxSel(), (GXIndTexWrap)getWrapS(), (GXIndTexWrap)getWrapT(), (GXBool)getPrev(), (GXBool)getLod(), (GXIndTexAlphaSel)getAlphaSel());
|
||||
}
|
||||
|
||||
void J2DIndTexMtx::load(u8 indTexMtx) {
|
||||
@@ -68,11 +69,11 @@ void J2DIndTexMtx::load(u8 indTexMtx) {
|
||||
}
|
||||
|
||||
void J2DIndTexCoordScale::load(u8 indTexStage) {
|
||||
GXSetIndTexCoordScale((GXIndTexStageID)indTexStage, mInfo.getScaleS(), mInfo.getScaleT());
|
||||
GXSetIndTexCoordScale((GXIndTexStageID)indTexStage, (GXIndTexScale)mInfo.mScaleS, (GXIndTexScale)mInfo.mScaleT);
|
||||
}
|
||||
|
||||
void J2DIndTexOrder::load(u8 indTexStage) {
|
||||
GXSetIndTexOrder((GXIndTexStageID)indTexStage, mInfo.getTexCoordID(), mInfo.getTexMapID());
|
||||
GXSetIndTexOrder((GXIndTexStageID)indTexStage, (GXTexCoordID)mInfo.mTexCoordID, (GXTexMapID)mInfo.mTexMapID);
|
||||
}
|
||||
|
||||
static void dummyVirtual(J2DTevBlock* block, J2DIndBlock* indBlock) {
|
||||
@@ -107,48 +108,48 @@ J2DTexMtxInfo const j2dDefaultTexMtxInfo = {1, 1, 255, 255, 0.5f, 0.5f,
|
||||
|
||||
J2DIndTexMtxInfo const j2dDefaultIndTexMtxInfo = {{0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f}, 1};
|
||||
|
||||
extern J2DTevStageInfo const j2dDefaultTevStageInfo = {
|
||||
J2DTevStageInfo const j2dDefaultTevStageInfo = {
|
||||
4, GX_CC_RASC, GX_CC_ZERO, GX_CC_ZERO, GX_CC_CPREV, GX_TEV_ADD,
|
||||
GX_TB_ZERO, GX_CS_SCALE_1, 1, GX_TEVPREV, GX_CA_RASA, GX_CA_ZERO,
|
||||
GX_CA_ZERO, GX_CA_APREV, GX_TEV_ADD, GX_TB_ZERO, GX_CS_SCALE_1, 1,
|
||||
GX_TEVPREV};
|
||||
|
||||
extern const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = {
|
||||
const J2DIndTevStageInfo j2dDefaultIndTevStageInfo = {
|
||||
GX_INDTEXSTAGE0, GX_ITB_NONE, GX_ITB_NONE, GX_ITM_OFF, GX_ITW_OFF,
|
||||
GX_ITW_OFF, 0, 0, GX_ITBA_OFF,
|
||||
};
|
||||
|
||||
extern const GXColor j2dDefaultColInfo = {255, 255, 255, 255};
|
||||
const GXColor j2dDefaultColInfo = {255, 255, 255, 255};
|
||||
|
||||
extern const J2DTevOrderInfo j2dDefaultTevOrderInfoNull = {
|
||||
const J2DTevOrderInfo j2dDefaultTevOrderInfoNull = {
|
||||
GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR_NULL, 0};
|
||||
|
||||
extern const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = {
|
||||
const J2DIndTexOrderInfo j2dDefaultIndTexOrderNull = {
|
||||
GX_TEXCOORD_NULL,
|
||||
GX_TEXMAP_NULL,
|
||||
};
|
||||
|
||||
extern const GXColorS10 j2dDefaultTevColor = {255, 255, 255, 255};
|
||||
const GXColorS10 j2dDefaultTevColor = {255, 255, 255, 255};
|
||||
|
||||
extern const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = {
|
||||
const J2DIndTexCoordScaleInfo j2dDefaultIndTexCoordScaleInfo = {
|
||||
GX_ITS_1,
|
||||
GX_ITS_1,
|
||||
};
|
||||
|
||||
extern const GXColor j2dDefaultTevKColor = {255, 255, 255, 255};
|
||||
const GXColor j2dDefaultTevKColor = {255, 255, 255, 255};
|
||||
|
||||
extern const J2DTevSwapModeInfo j2dDefaultTevSwapMode = {GX_TEV_SWAP0, GX_TEV_SWAP0, 0, 0};
|
||||
const J2DTevSwapModeInfo j2dDefaultTevSwapMode = {GX_TEV_SWAP0, GX_TEV_SWAP0, 0, 0};
|
||||
|
||||
extern const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = {
|
||||
const J2DTevSwapModeTableInfo j2dDefaultTevSwapModeTable = {
|
||||
GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA};
|
||||
|
||||
extern const J2DBlendInfo j2dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA,
|
||||
const J2DBlendInfo j2dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA,
|
||||
GX_LO_NOOP};
|
||||
|
||||
extern const u8 j2dDefaultPEBlockDither = 0;
|
||||
const u8 j2dDefaultPEBlockDither = 0;
|
||||
|
||||
extern const J2DColorChanInfo j2dDefaultColorChanInfo = {0, 3, 0, 0};
|
||||
const J2DColorChanInfo j2dDefaultColorChanInfo = {0, 3, 0, 0};
|
||||
|
||||
extern const u8 j2dDefaultTevSwapTableID = 0x1B;
|
||||
const u8 j2dDefaultTevSwapTableID = 0x1B;
|
||||
|
||||
extern const u16 j2dDefaultAlphaCmp = 0x00E7;
|
||||
const u16 j2dDefaultAlphaCmp = 0x00E7;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTResFont.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
|
||||
J2DTextBox::J2DTextBox()
|
||||
: mFont(NULL), mCharColor(), mGradientColor(), mStringPtr(NULL), mWhiteColor(), mBlackColor() {
|
||||
@@ -77,12 +78,8 @@ J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 para
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
mStringLength = strLength;
|
||||
int temp_r0 = (u16)strLength - 1;
|
||||
u16 var_r26_2 = info.field_0x1e;
|
||||
|
||||
if (temp_r0 < var_r26_2) {
|
||||
var_r26_2 = (u16)temp_r0;
|
||||
}
|
||||
u16 var_r26_2 = strLength - 1 < info.field_0x1e ? u16(strLength - 1) : info.field_0x1e;
|
||||
|
||||
p_stream->peek(mStringPtr, var_r26_2);
|
||||
mStringPtr[var_r26_2] = 0;
|
||||
@@ -94,20 +91,11 @@ J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 para
|
||||
mWhiteColor = JUtility::TColor(0xFFFFFFFF);
|
||||
|
||||
if (mat != NULL && mat->getTevBlock() != NULL) {
|
||||
if (mat->getTevBlock()->getTevStageNum() != 1) {
|
||||
J2DGXColorS10* color0p = mat->getTevBlock()->getTevColor(0);
|
||||
GXColorS10 color0;
|
||||
color0.r = color0p->r;
|
||||
color0.g = color0p->g;
|
||||
color0.b = color0p->b;
|
||||
color0.a = color0p->a;
|
||||
u8 tevStageNum = u32(mat->getTevBlock()->getTevStageNum());
|
||||
if (tevStageNum != 1) {
|
||||
J2DGXColorS10 color0(*mat->getTevBlock()->getTevColor(0));
|
||||
|
||||
J2DGXColorS10* color1p = mat->getTevBlock()->getTevColor(1);
|
||||
GXColorS10 color1;
|
||||
color1.r = color1p->r;
|
||||
color1.g = color1p->g;
|
||||
color1.b = color1p->b;
|
||||
color1.a = color1p->a;
|
||||
J2DGXColorS10 color1(*mat->getTevBlock()->getTevColor(1));
|
||||
|
||||
mBlackColor = JUtility::TColor(((u8)color0.r << 0x18) | ((u8)color0.g << 0x10) |
|
||||
((u8)color0.b << 8) | (u8)color0.a);
|
||||
@@ -121,9 +109,6 @@ J2DTextBox::J2DTextBox(J2DPane* p_pane, JSURandomInputStream* p_stream, u32 para
|
||||
mTextFontOwned = true;
|
||||
}
|
||||
|
||||
/* 802FFBC4-802FFC58 2FA504 0094+00 0/0 1/1 0/0 .text
|
||||
* __ct__10J2DTextBoxFUxRCQ29JGeometry8TBox2<f>PC7ResFONTPCcs18J2DTextBoxHBinding18J2DTextBoxVBinding
|
||||
*/
|
||||
J2DTextBox::J2DTextBox(u64 tag, JGeometry::TBox2<f32> const& bounds, ResFONT const* p_font,
|
||||
char const* string, s16 strLength, J2DTextBoxHBinding hBind,
|
||||
J2DTextBoxVBinding vBind)
|
||||
@@ -194,6 +179,7 @@ void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_str
|
||||
mKind = header.mTag;
|
||||
|
||||
makePaneStream(p_pane, p_stream);
|
||||
{JUTResReference ref;}
|
||||
u8 spA = p_stream->readU8();
|
||||
|
||||
ResFONT* fontPtr = (ResFONT*)getPointer(p_stream, 'FONT', p_archive);
|
||||
@@ -203,7 +189,8 @@ void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_str
|
||||
|
||||
mCharColor.set(p_stream->read32b());
|
||||
mGradientColor.set(p_stream->read32b());
|
||||
mFlags = p_stream->read8b();
|
||||
u8 tmp = p_stream->read8b();
|
||||
mFlags = tmp;
|
||||
mCharSpacing = p_stream->readS16();
|
||||
mLineSpacing = p_stream->readS16();
|
||||
mFontSizeX = p_stream->read16b();
|
||||
@@ -223,8 +210,8 @@ void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_str
|
||||
|
||||
spA -= 10;
|
||||
if (spA != 0) {
|
||||
u8 sp8 = p_stream->read8b();
|
||||
if (sp8 != 0) {
|
||||
tmp = p_stream->read8b();
|
||||
if (tmp != 0) {
|
||||
setConnectParent(true);
|
||||
}
|
||||
|
||||
@@ -241,6 +228,7 @@ void J2DTextBox::private_readStream(J2DPane* p_pane, JSURandomInputStream* p_str
|
||||
|
||||
if (spA != 0) {
|
||||
mWhiteColor.set(p_stream->read32b());
|
||||
spA--;
|
||||
}
|
||||
|
||||
field_0x10c = 0.0f;
|
||||
@@ -283,7 +271,7 @@ void J2DTextBox::draw(f32 posX, f32 posY) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
print.print(0.0f, 0.0f, mAlpha, "%s", mStringPtr);
|
||||
@@ -309,7 +297,7 @@ void J2DTextBox::draw(f32 posX, f32 posY, f32 param_2, J2DTextBoxHBinding hBind)
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
print.printReturn(mStringPtr, param_2, 0.0f, hBind, VBIND_TOP, 0.0f, -mFontSizeY,
|
||||
@@ -337,8 +325,7 @@ s32 J2DTextBox::setString(char const* string, ...) {
|
||||
}
|
||||
|
||||
mStringLength = 0;
|
||||
char* tmp = new char[len + 1];
|
||||
mStringPtr = tmp;
|
||||
mStringPtr = new char[len + 1];
|
||||
|
||||
if (mStringPtr) {
|
||||
mStringLength = len + 1;
|
||||
@@ -416,7 +403,7 @@ void J2DTextBox::drawSelf(f32 param_0, f32 param_1, Mtx* p_mtx) {
|
||||
GXSetTevDirect((GXTevStageID)i);
|
||||
}
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60, GX_FALSE, 125);
|
||||
GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, 60);
|
||||
|
||||
print.locate(param_0 + mBounds.i.x, param_1 + mBounds.i.y);
|
||||
if (mStringPtr != NULL) {
|
||||
|
||||
@@ -70,12 +70,8 @@ J2DTextBoxEx::J2DTextBoxEx(J2DPane* p_pane, JSURandomInputStream* p_stream, u32
|
||||
|
||||
if (mStringPtr != NULL) {
|
||||
mStringLength = strLength;
|
||||
int temp_r0 = (u16)strLength - 1;
|
||||
u16 var_r26_2 = info.field_0x1e;
|
||||
|
||||
if (temp_r0 < var_r26_2) {
|
||||
var_r26_2 = (u16)temp_r0;
|
||||
}
|
||||
u16 var_r26_2 = strLength - 1 < info.field_0x1e ? u16(strLength - 1) : info.field_0x1e;
|
||||
|
||||
p_stream->peek(mStringPtr, var_r26_2);
|
||||
mStringPtr[var_r26_2] = 0;
|
||||
@@ -291,7 +287,8 @@ void J2DTextBoxEx::setTevStage(bool param_0) {
|
||||
setStage(stage, STAGE_0);
|
||||
} else {
|
||||
setStage(stage, STAGE_1);
|
||||
setStage(mMaterial->getTevBlock()->getTevStage(1), STAGE_2);
|
||||
stage = mMaterial->getTevBlock()->getTevStage(1);
|
||||
setStage(stage, STAGE_2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,12 +357,10 @@ bool J2DTextBoxEx::setBlackWhite(JUtility::TColor param_0, JUtility::TColor para
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bvar = false;
|
||||
if (param_0 != 0 || param_1 != -1) {
|
||||
bvar = true;
|
||||
}
|
||||
bool bvar = (param_0 != 0) || (param_1 != -1);
|
||||
|
||||
mMaterial->getTevBlock()->setTevStageNum(bvar ? 2 : 1);
|
||||
u8 stageNum = bvar ? 2 : 1;
|
||||
mMaterial->getTevBlock()->setTevStageNum(stageNum);
|
||||
setTevOrder(bvar);
|
||||
setTevStage(bvar);
|
||||
|
||||
@@ -396,38 +391,32 @@ bool J2DTextBoxEx::getBlackWhite(JUtility::TColor* param_0, JUtility::TColor* pa
|
||||
return false;
|
||||
}
|
||||
|
||||
bool tevStageNum = mMaterial->getTevBlock()->getTevStageNum() != 1;
|
||||
u32 tevStageNum = mMaterial->getTevBlock()->getTevStageNum();
|
||||
bool manyTevStages = tevStageNum == 1 ? false : true;
|
||||
*param_0 = JUtility::TColor(0);
|
||||
*param_1 = JUtility::TColor(0xffffffff);
|
||||
if (tevStageNum) {
|
||||
J2DGXColorS10* local_30 = mMaterial->getTevBlock()->getTevColor(0);
|
||||
s16 color0r = local_30->r;
|
||||
s16 color0g = local_30->g;
|
||||
s16 color0b = local_30->b;
|
||||
s16 color0a = local_30->a;
|
||||
J2DGXColorS10* local_38 = mMaterial->getTevBlock()->getTevColor(1);
|
||||
s16 color1r = local_38->r;
|
||||
s16 color1g = local_38->g;
|
||||
s16 color1b = local_38->b;
|
||||
s16 color1a = local_38->a;
|
||||
if (manyTevStages) {
|
||||
J2DGXColorS10 color0(*mMaterial->getTevBlock()->getTevColor(0));
|
||||
J2DGXColorS10 color1(*mMaterial->getTevBlock()->getTevColor(1));
|
||||
*param_0 = JUtility::TColor(
|
||||
(((u8)color0r) << 24) | (((u8)color0g) << 16) | (((u8)color0b) << 8) |
|
||||
((u8)color0a));
|
||||
(((u8)color0.r) << 24) | (((u8)color0.g) << 16) | (((u8)color0.b) << 8) |
|
||||
((u8)color0.a));
|
||||
*param_1 = JUtility::TColor(
|
||||
(((u8)color1r) << 24) | (((u8)color1g) << 16) | (((u8)color1b) << 8) |
|
||||
((u8)color1a));
|
||||
(((u8)color1.r) << 24) | (((u8)color1.g) << 16) | (((u8)color1.b) << 8) |
|
||||
((u8)color1.a));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool J2DTextBoxEx::isSetBlackWhite(JUtility::TColor param_0, JUtility::TColor param_1) const {
|
||||
if ((u32)param_0 == 0 && (u32)param_1 == 0xffffffff) {
|
||||
if (param_0 == 0 && param_1 == 0xffffffff) {
|
||||
return 1;
|
||||
}
|
||||
mMaterial->getTevBlock()->getTevStageNum();
|
||||
if (mMaterial->getTevBlock()->getMaxStage() == 1) {
|
||||
u32 tevStageNum = mMaterial->getTevBlock()->getTevStageNum();
|
||||
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
|
||||
if (maxStage == 1) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J2DGraph/J2DWindow.h"
|
||||
#include "JSystem/J2DGraph/J2DScreen.h"
|
||||
#include "JSystem/JSupport/JSURandomInputStream.h"
|
||||
#include "JSystem/JUtility/JUTPalette.h"
|
||||
#include "JSystem/JUtility/JUTResource.h"
|
||||
@@ -144,6 +145,43 @@ J2DWindow::J2DWindow(J2DPane* param_0, JSURandomInputStream* param_1, J2DMateria
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
J2DWindow::J2DWindow(u64 param_0, const JGeometry::TBox2<f32>& param_1, const char* param_2, J2DTextureBase param_3, const ResTLUT* param_4) :
|
||||
J2DPane(param_0, param_1),
|
||||
field_0x100(NULL),
|
||||
field_0x104(NULL),
|
||||
field_0x108(NULL),
|
||||
field_0x10c(NULL),
|
||||
field_0x110(NULL),
|
||||
mPalette(NULL) {
|
||||
const ResTIMG* r30 = (const ResTIMG*)J2DScreen::getNameResource(param_2);
|
||||
initiate(r30, r30, r30, r30, param_4, convertMirror(param_3), param_1);
|
||||
}
|
||||
|
||||
void J2DWindow::initiate(const ResTIMG* param_0, const ResTIMG* param_1, const ResTIMG* param_2, const ResTIMG* param_3, const ResTLUT* param_4, J2DWindowMirror param_5, const JGeometry::TBox2<f32>& param_6) {
|
||||
if (param_0) {
|
||||
field_0x100 = new JUTTexture(param_0, 0);
|
||||
}
|
||||
if (param_1) {
|
||||
field_0x104 = new JUTTexture(param_1, 0);
|
||||
}
|
||||
if (param_2) {
|
||||
field_0x108 = new JUTTexture(param_2, 0);
|
||||
}
|
||||
if (param_3) {
|
||||
field_0x10c = new JUTTexture(param_3, 0);
|
||||
}
|
||||
if (param_4) {
|
||||
mPalette = new JUTPalette(GX_TLUT0, const_cast<ResTLUT*>(param_4));
|
||||
}
|
||||
field_0x144 = param_5;
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
field_0x114.set(field_0x100->getWidth(), field_0x100->getHeight(), param_6.getWidth() - field_0x104->getWidth(), param_6.getHeight() - field_0x108->getHeight());
|
||||
} else {
|
||||
field_0x114.set(0.0f, 0.0f, param_6.getWidth(), param_6.getHeight());
|
||||
}
|
||||
initinfo();
|
||||
}
|
||||
|
||||
void J2DWindow::private_readStream(J2DPane* param_0, JSURandomInputStream* param_1,
|
||||
JKRArchive* param_2) {
|
||||
s32 local_188 = param_1->getPosition();
|
||||
@@ -183,7 +221,7 @@ void J2DWindow::private_readStream(J2DPane* param_0, JSURandomInputStream* param
|
||||
field_0x12C.set(param_1->read32b());
|
||||
field_0x130.set(param_1->read32b());
|
||||
field_0x134.set(param_1->read32b());
|
||||
r27 -= 14;
|
||||
r27 -= u8(14);
|
||||
field_0x110 = NULL;
|
||||
if (r27) {
|
||||
timg = (ResTIMG*)getPointer(param_1, 'TIMG', param_2);
|
||||
@@ -200,11 +238,20 @@ void J2DWindow::private_readStream(J2DPane* param_0, JSURandomInputStream* param
|
||||
}
|
||||
if (r27) {
|
||||
mWhite = JUtility::TColor(param_1->readU32());
|
||||
r27--;
|
||||
}
|
||||
param_1->seek(local_188 + local_180[1], JSUStreamSeekFrom_SET);
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
void J2DWindow::initinfo() {
|
||||
mKind = 'WIN1';
|
||||
setContentsColor(JUtility::TColor(0xffffffff));
|
||||
mBlack = JUtility::TColor(0);
|
||||
mWhite = JUtility::TColor(0xffffffff);
|
||||
initinfo2();
|
||||
}
|
||||
|
||||
void J2DWindow::initinfo2() {
|
||||
if (field_0x100 && field_0x104 && field_0x108 && field_0x10c) {
|
||||
field_0x140 = field_0x100->getWidth() + field_0x104->getWidth();
|
||||
@@ -229,6 +276,25 @@ void J2DWindow::initinfo2() {
|
||||
}
|
||||
}
|
||||
|
||||
J2DWindowMirror J2DWindow::convertMirror(J2DTextureBase texBase) {
|
||||
J2DWindowMirror winMirror = WINDOWMIRROR_39;
|
||||
switch (texBase) {
|
||||
case TEXTUREBASE_0:
|
||||
winMirror = WINDOWMIRROR_39;
|
||||
break;
|
||||
case TEXTUREBASE_1:
|
||||
winMirror = WINDOWMIRROR_141;
|
||||
break;
|
||||
case TEXTUREBASE_2:
|
||||
winMirror = WINDOWMIRROR_114;
|
||||
break;
|
||||
case TEXTUREBASE_3:
|
||||
winMirror = WINDOWMIRROR_216;
|
||||
break;
|
||||
}
|
||||
return winMirror;
|
||||
}
|
||||
|
||||
J2DWindow::~J2DWindow() {
|
||||
delete field_0x100;
|
||||
delete field_0x104;
|
||||
@@ -372,9 +438,6 @@ void J2DWindow::resize(f32 param_0, f32 param_1) {
|
||||
}
|
||||
}
|
||||
|
||||
/* 802FB12C-802FB1D8 2F5A6C 00AC+00 1/1 0/0 0/0 .text
|
||||
* setContentsColor__9J2DWindowFQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColorQ28JUtility6TColor
|
||||
*/
|
||||
void J2DWindow::setContentsColor(JUtility::TColor param_0, JUtility::TColor param_1,
|
||||
JUtility::TColor param_2, JUtility::TColor param_3) {
|
||||
field_0x128.set(param_0);
|
||||
@@ -488,10 +551,27 @@ void J2DWindow::drawFrameTexture(JUTTexture* param_0, f32 param_1, f32 param_2,
|
||||
|
||||
void J2DWindow::drawFrameTexture(JUTTexture* param_0, f32 param_1, f32 param_2, bool param_3,
|
||||
bool param_4, bool param_5) {
|
||||
u16 r31 = param_4 ? u16(0x8000) : u16(0);
|
||||
u16 r30 = param_3 ? u16(0x8000) : u16(0);
|
||||
u16 r29 = param_4 ? u16(0) : u16(0x8000);
|
||||
u16 r28 = param_3 ? u16(0) : u16(0x8000);
|
||||
u16 r31, r30, r29, r28;
|
||||
if (param_4) {
|
||||
r31 = 0x8000;
|
||||
} else {
|
||||
r31 = 0;
|
||||
}
|
||||
if (param_3) {
|
||||
r30 = 0x8000;
|
||||
} else {
|
||||
r30 = 0;
|
||||
}
|
||||
if (param_4) {
|
||||
r29 = 0;
|
||||
} else {
|
||||
r29 = 0x8000;
|
||||
}
|
||||
if (param_3) {
|
||||
r28 = 0;
|
||||
} else {
|
||||
r28 = 0x8000;
|
||||
}
|
||||
drawFrameTexture(param_0, param_1, param_2, param_0->getWidth(), param_0->getHeight(), r28, r29,
|
||||
r30, r31, param_5);
|
||||
}
|
||||
@@ -575,11 +655,7 @@ void J2DWindow::setTevMode(JUTTexture* param_0, JUtility::TColor param_1,
|
||||
}
|
||||
|
||||
JUTTexture* J2DWindow::getFrameTexture(u8 param_0, u8 param_1) const {
|
||||
JUTTexture* tmp[4] = {NULL, NULL, NULL, NULL};
|
||||
tmp[0] = field_0x100;
|
||||
tmp[1] = field_0x104;
|
||||
tmp[2] = field_0x108;
|
||||
tmp[3] = field_0x10c;
|
||||
JUTTexture* tmp[4] = {field_0x100, field_0x104, field_0x108, field_0x10c};
|
||||
if (param_0 >= 4 || param_1 != 0) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -587,12 +663,7 @@ JUTTexture* J2DWindow::getFrameTexture(u8 param_0, u8 param_1) const {
|
||||
}
|
||||
|
||||
bool J2DWindow::isUsed(ResTIMG const* param_0) {
|
||||
JUTTexture* tmp[5] = {NULL, NULL, NULL, NULL, NULL};
|
||||
tmp[0] = field_0x100;
|
||||
tmp[1] = field_0x104;
|
||||
tmp[2] = field_0x108;
|
||||
tmp[3] = field_0x10c;
|
||||
tmp[4] = field_0x110;
|
||||
JUTTexture* tmp[5] = {field_0x100, field_0x104, field_0x108, field_0x10c, field_0x110};
|
||||
for (u8 i = 0; i < 5; i++) {
|
||||
if (tmp[i] && tmp[i]->getTexInfo() == param_0) {
|
||||
return true;
|
||||
|
||||
@@ -20,9 +20,6 @@ J3DJointTree::J3DJointTree()
|
||||
mWEvlpMixMtxIndex(0), mWEvlpMixWeight(0), mInvJointMtx(NULL), mWEvlpImportantMtxIdx(0),
|
||||
field_0x40(0), mJointName(NULL) {}
|
||||
|
||||
/* 80325A9C-80325C00 3203DC 0164+00 1/0 2/2 0/0 .text
|
||||
* makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable
|
||||
*/
|
||||
void J3DJointTree::makeHierarchy(J3DJoint* pJoint, const J3DModelHierarchy** pHierarchy,
|
||||
J3DMaterialTable* pMaterialTable, J3DShapeTable* pShapeTable) {
|
||||
J3D_ASSERT_NULLPTR(95, pHierarchy != NULL);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h"
|
||||
#include "JSystem/J3DGraphAnimator/J3DModel.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
J3DSkinNList::J3DSkinNList() {
|
||||
field_0x0 = NULL;
|
||||
@@ -274,7 +274,7 @@ int J3DSkinDeform::initMtxIndexArray(J3DModelData* pModelData) {
|
||||
u8* pDListPos = pDList;
|
||||
int uVar13;
|
||||
for (;
|
||||
(int)pDListPos - (int)pDList < pModelData->getShapeNodePointer(i)->getShapeDraw(j)->getDisplayListSize();
|
||||
(intptr_t)pDListPos - (intptr_t)pDList < pModelData->getShapeNodePointer(i)->getShapeDraw(j)->getDisplayListSize();
|
||||
pDListPos += r23 * uVar13
|
||||
//TODO: This loop's logic has drastically different codegen between GCN and Shield
|
||||
// in a way that so far can't be pinned down as just compiler differences. This
|
||||
@@ -388,8 +388,8 @@ void J3DSkinDeform::changeFastSkinDL(J3DModelData* pModelData) {
|
||||
dl = (u8*)dl + vtxSize * vtxCount;
|
||||
}
|
||||
|
||||
int dlistSize = ((int)dst - (int)displayListStart + 0x1f) & ~0x1f;
|
||||
while ((int)dst - (int)displayListStart < pShapeNode->getShapeDraw(j)->getDisplayListSize()) {
|
||||
int dlistSize = ((intptr_t)dst - (intptr_t)displayListStart + 0x1f) & ~0x1f;
|
||||
while ((intptr_t)dst - (intptr_t)displayListStart < pShapeNode->getShapeDraw(j)->getDisplayListSize()) {
|
||||
*dst++ = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -335,9 +335,6 @@ static u8 GX2HWFiltConv[6] = {
|
||||
0x00, 0x04, 0x01, 0x05, 0x02, 0x06,
|
||||
};
|
||||
|
||||
/* 8030E438-8030E5D4 308D78 019C+00 0/0 1/1 0/0 .text
|
||||
* J3DGDSetTexLookupMode__F11_GXTexMapID14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilterfffUcUc13_GXAnisotropy
|
||||
*/
|
||||
void J3DGDSetTexLookupMode(GXTexMapID id, GXTexWrapMode wrap_s,
|
||||
GXTexWrapMode wrap_t, GXTexFilter min_filt,
|
||||
GXTexFilter mag_filt, f32 min_lod, f32 max_lod,
|
||||
@@ -435,9 +432,6 @@ void J3DGDSetIndTexMtx(GXIndTexMtxID mtx_id, f32 offset[2][3], s8 scale_exp) {
|
||||
));
|
||||
}
|
||||
|
||||
/* 8030EE10-8030EF08 309750 00F8+00 0/0 2/2 0/0 .text
|
||||
* J3DGDSetIndTexCoordScale__F16_GXIndTexStageID14_GXIndTexScale14_GXIndTexScale14_GXIndTexScale14_GXIndTexScale
|
||||
*/
|
||||
void J3DGDSetIndTexCoordScale(GXIndTexStageID indStageEven, GXIndTexScale scaleS0,
|
||||
GXIndTexScale scaleT0, GXIndTexScale scaleS1,
|
||||
GXIndTexScale scaleT1) {
|
||||
@@ -451,9 +445,6 @@ void J3DGDSetIndTexCoordScale(GXIndTexStageID indStageEven, GXIndTexScale scaleS
|
||||
));
|
||||
}
|
||||
|
||||
/* 8030EF08-8030F108 309848 0200+00 0/0 2/2 0/0 .text
|
||||
* J3DGDSetIndTexOrder__FUl13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID13_GXTexCoordID11_GXTexMapID
|
||||
*/
|
||||
void J3DGDSetIndTexOrder(u32 count, GXTexCoordID texCoord0, GXTexMapID texMap0,
|
||||
GXTexCoordID texCoord1, GXTexMapID texMap1,
|
||||
GXTexCoordID texCoord2, GXTexMapID texMap2,
|
||||
@@ -492,9 +483,6 @@ void J3DGDSetIndTexOrder(u32 count, GXTexCoordID texCoord0, GXTexMapID texMap0,
|
||||
J3DGDWriteBPCmd(BP_IND_MASK(mask, 0xF));
|
||||
}
|
||||
|
||||
/* 8030F108-8030F294 309A48 018C+00 0/0 9/9 0/0 .text
|
||||
* J3DGDSetTevOrder__F13_GXTevStageID13_GXTexCoordID11_GXTexMapID12_GXChannelID13_GXTexCoordID11_GXTexMapID12_GXChannelID
|
||||
*/
|
||||
void J3DGDSetTevOrder(GXTevStageID evenStage, GXTexCoordID coord0, GXTexMapID map0,
|
||||
GXChannelID color0, GXTexCoordID coord1, GXTexMapID map1,
|
||||
GXChannelID color1) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "JSystem/J3DGraphBase/J3DSys.h"
|
||||
#include "JSystem/J3DGraphBase/J3DTransform.h"
|
||||
#include "global.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
inline void loadMatColors(const J3DGXColor* color) {
|
||||
J3DGDWriteXFCmdHdr(0x100C, 2);
|
||||
@@ -295,8 +295,6 @@ static u32 SizeOfLoadAmbColors = 13;
|
||||
|
||||
static u32 SizeOfLoadColorChans = 21;
|
||||
|
||||
static u8 sdata_padding[4] = {};
|
||||
|
||||
static u32 SizeOfJ3DColorBlockLightOffLoad = SizeOfLoadMatColors + SizeOfLoadColorChans;
|
||||
|
||||
void J3DColorBlockLightOff::load() {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "JSystem/J3DGraphBase/J3DShapeMtx.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <dolphin/os.h>
|
||||
#include "string.h"
|
||||
#include <string>
|
||||
#include "global.h"
|
||||
|
||||
J3DError J3DDisplayListObj::newDisplayList(u32 maxSize) {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
#include "JSystem/J3DGraphBase/J3DShapeDraw.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <stdint>
|
||||
#include <dolphin/gx.h>
|
||||
|
||||
u32 J3DShapeDraw::countVertex(u32 stride) {
|
||||
|
||||
@@ -67,11 +67,8 @@ u32 J3DShapeMtx::sCurrentPipeline;
|
||||
|
||||
u8* J3DShapeMtx::sCurrentScaleFlag;
|
||||
|
||||
// This below is technically part of J3DScaleFlag.
|
||||
/* 804515B0 0001+00 data_804515B0 None */
|
||||
bool J3DShapeMtx::sNBTFlag;
|
||||
|
||||
/* 804515B1 0003+00 data_804515B1 None */
|
||||
bool J3DShapeMtx::sLODFlag;
|
||||
|
||||
u32 J3DShapeMtx::sTexMtxLoadType;
|
||||
|
||||
@@ -315,7 +315,7 @@ void loadNBTScale(J3DNBTScale& NBTScale) {
|
||||
}
|
||||
}
|
||||
|
||||
extern const J3DLightInfo j3dDefaultLightInfo = {
|
||||
const J3DLightInfo j3dDefaultLightInfo = {
|
||||
0.0f, 0.0f, 0.0f,
|
||||
0.0f, -1.0f, 0.0f,
|
||||
0xff, 0xff, 0xff, 0xff,
|
||||
@@ -323,14 +323,14 @@ extern const J3DLightInfo j3dDefaultLightInfo = {
|
||||
1.0f, 0.0f, 0.0f,
|
||||
};
|
||||
|
||||
extern J3DTexCoordInfo const j3dDefaultTexCoordInfo[8] = {
|
||||
J3DTexCoordInfo const j3dDefaultTexCoordInfo[8] = {
|
||||
{GX_MTX2x4, GX_TG_TEX0, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX1, GX_IDENTITY, 0},
|
||||
{GX_MTX2x4, GX_TG_TEX2, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX3, GX_IDENTITY, 0},
|
||||
{GX_MTX2x4, GX_TG_TEX4, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX5, GX_IDENTITY, 0},
|
||||
{GX_MTX2x4, GX_TG_TEX6, GX_IDENTITY, 0}, {GX_MTX2x4, GX_TG_TEX7, GX_IDENTITY, 0},
|
||||
};
|
||||
|
||||
extern J3DTexMtxInfo const j3dDefaultTexMtxInfo = {
|
||||
J3DTexMtxInfo const j3dDefaultTexMtxInfo = {
|
||||
0x01,
|
||||
0x00,
|
||||
0xFF,
|
||||
@@ -341,27 +341,27 @@ extern J3DTexMtxInfo const j3dDefaultTexMtxInfo = {
|
||||
1.0f},
|
||||
};
|
||||
|
||||
extern J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo = {
|
||||
J3DIndTexMtxInfo const j3dDefaultIndTexMtxInfo = {
|
||||
0.5f, 0.0f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f,
|
||||
1
|
||||
};
|
||||
|
||||
extern J3DTevStageInfo const j3dDefaultTevStageInfo = {
|
||||
J3DTevStageInfo const j3dDefaultTevStageInfo = {
|
||||
0x04, 0x0A, 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x05, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
||||
};
|
||||
|
||||
extern J3DIndTevStageInfo const j3dDefaultIndTevStageInfo = {
|
||||
J3DIndTevStageInfo const j3dDefaultIndTevStageInfo = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
|
||||
extern J3DFogInfo const j3dDefaultFogInfo = {
|
||||
J3DFogInfo const j3dDefaultFogInfo = {
|
||||
0x00, 0x00, 0x0140, 0.0f, 0.0f, 0.1f, 10000.0f, 0xFF, 0xFF, 0xFF, 0x00,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
};
|
||||
|
||||
extern J3DNBTScaleInfo const j3dDefaultNBTScaleInfo = {
|
||||
J3DNBTScaleInfo const j3dDefaultNBTScaleInfo = {
|
||||
0x00, 1.0f, 1.0f, 1.0f,
|
||||
};
|
||||
|
||||
@@ -413,7 +413,6 @@ void makeAlphaCmpTable() {
|
||||
}
|
||||
}
|
||||
|
||||
extern u8 j3dZModeTable[96];
|
||||
u8 j3dZModeTable[96];
|
||||
|
||||
void makeZModeTable() {
|
||||
@@ -492,43 +491,43 @@ static void J3DGDLoadPostTexMtxImm(f32 (*param_1)[4], u32 param_2) {
|
||||
J3DGDWrite_f32(param_1[2][3]);
|
||||
}
|
||||
|
||||
extern const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
const GXColor j3dDefaultColInfo = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
extern const GXColor j3dDefaultAmbInfo = {0x32, 0x32, 0x32, 0x32};
|
||||
const GXColor j3dDefaultAmbInfo = {0x32, 0x32, 0x32, 0x32};
|
||||
|
||||
extern const u8 j3dDefaultNumChans = 1;
|
||||
const u8 j3dDefaultNumChans = 1;
|
||||
|
||||
extern const J3DTevOrderInfo j3dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00};
|
||||
const J3DTevOrderInfo j3dDefaultTevOrderInfoNull = {0xFF, 0xFF, 0xFF, 0x00};
|
||||
|
||||
extern const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull = {0xFF, 0xFF, 0x00, 0x00};
|
||||
const J3DIndTexOrderInfo j3dDefaultIndTexOrderNull = {0xFF, 0xFF, 0x00, 0x00};
|
||||
|
||||
extern const GXColorS10 j3dDefaultTevColor = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
const GXColorS10 j3dDefaultTevColor = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
extern const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo = {
|
||||
const J3DIndTexCoordScaleInfo j3dDefaultIndTexCoordScaleInfo = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
extern const GXColor j3dDefaultTevKColor = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
const GXColor j3dDefaultTevKColor = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
extern J3DTevSwapModeInfo const j3dDefaultTevSwapMode = {
|
||||
J3DTevSwapModeInfo const j3dDefaultTevSwapMode = {
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
};
|
||||
|
||||
extern const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable = {0x00, 0x01, 0x02, 0x03};
|
||||
const J3DTevSwapModeTableInfo j3dDefaultTevSwapModeTable = {0x00, 0x01, 0x02, 0x03};
|
||||
|
||||
extern const J3DBlendInfo j3dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP};
|
||||
const J3DBlendInfo j3dDefaultBlendInfo = {GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_NOOP};
|
||||
|
||||
extern const J3DColorChanInfo j3dDefaultColorChanInfo = {
|
||||
const J3DColorChanInfo j3dDefaultColorChanInfo = {
|
||||
0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0xFF, 0xFF,
|
||||
};
|
||||
|
||||
extern const u8 j3dDefaultTevSwapTableID = 0x1B;
|
||||
const u8 j3dDefaultTevSwapTableID = 0x1B;
|
||||
|
||||
const u16 j3dDefaultAlphaCmpID = 0x00E7;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ void J3DTexture::addResTIMG(u16 newNum, const ResTIMG* newRes) {
|
||||
if (newNum == 0)
|
||||
return;
|
||||
|
||||
J3D_ASSERT_NULLPTR(105, newRes != 0);
|
||||
J3D_ASSERT_NULLPTR(105, newRes != NULL);
|
||||
|
||||
u16 oldNum = mNum;
|
||||
ResTIMG* oldRes = mpRes;
|
||||
|
||||
@@ -70,12 +70,12 @@ void J3DCalcBBoardMtx(__REGISTER Mtx mtx) {
|
||||
mtx[2][2] = z;
|
||||
}
|
||||
|
||||
extern J3DTransformInfo const j3dDefaultTransformInfo = {
|
||||
J3DTransformInfo const j3dDefaultTransformInfo = {
|
||||
{1.0f, 1.0f, 1.0f}, {0, 0, 0}, {0.0f, 0.0f, 0.0f}};
|
||||
|
||||
extern Vec const j3dDefaultScale = {1.0f, 1.0f, 1.0f};
|
||||
Vec const j3dDefaultScale = {1.0f, 1.0f, 1.0f};
|
||||
|
||||
extern Mtx const j3dDefaultMtx = {
|
||||
Mtx const j3dDefaultMtx = {
|
||||
{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}};
|
||||
|
||||
void J3DCalcYBBoardMtx(Mtx mtx) {
|
||||
@@ -101,7 +101,7 @@ void J3DCalcYBBoardMtx(Mtx mtx) {
|
||||
mtx[2][2] = vec.z * z;
|
||||
}
|
||||
|
||||
asm void J3DPSCalcInverseTranspose(__REGISTER Mtx src, __REGISTER Mtx33 dst) {
|
||||
ASM void J3DPSCalcInverseTranspose(__REGISTER Mtx src, __REGISTER Mtx33 dst) {
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
psq_l f0, 0(src), 1, 0
|
||||
psq_l f1, 4(src), 0, 0
|
||||
@@ -290,7 +290,7 @@ void J3DGetTextureMtxMayaOld(const J3DTextureSRTInfo& srt, Mtx dst) {
|
||||
dst[2][2] = 1.0f;
|
||||
}
|
||||
|
||||
asm void J3DScaleNrmMtx(__REGISTER Mtx mtx, const __REGISTER Vec& scl) {
|
||||
ASM void J3DScaleNrmMtx(__REGISTER Mtx mtx, const __REGISTER Vec& scl) {
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
nofralloc;
|
||||
|
||||
@@ -326,7 +326,7 @@ asm void J3DScaleNrmMtx(__REGISTER Mtx mtx, const __REGISTER Vec& scl) {
|
||||
#endif // clang-format on
|
||||
}
|
||||
|
||||
asm void J3DScaleNrmMtx33(__REGISTER Mtx33 mtx, const __REGISTER Vec& scale) {
|
||||
ASM void J3DScaleNrmMtx33(__REGISTER Mtx33 mtx, const __REGISTER Vec& scale) {
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
psq_l f0, 0(mtx), 0, 0
|
||||
psq_l f6, 0(scale), 0, 0
|
||||
@@ -352,7 +352,7 @@ asm void J3DScaleNrmMtx33(__REGISTER Mtx33 mtx, const __REGISTER Vec& scale) {
|
||||
#endif // clang-format on
|
||||
}
|
||||
|
||||
asm void J3DMtxProjConcat(__REGISTER Mtx mtx1, __REGISTER Mtx mtx2, __REGISTER Mtx dst) {
|
||||
ASM void J3DMtxProjConcat(__REGISTER Mtx mtx1, __REGISTER Mtx mtx2, __REGISTER Mtx dst) {
|
||||
#ifdef __MWERKS__ // clang-format off
|
||||
psq_l f2, 0(mtx1), 0, 0
|
||||
psq_l f3, 8(mtx1), 0, 0
|
||||
@@ -541,7 +541,7 @@ loop:
|
||||
}
|
||||
#endif // clang-format on
|
||||
|
||||
extern f32 const PSMulUnit01[] = {
|
||||
f32 const PSMulUnit01[] = {
|
||||
0.0f,
|
||||
-1.0f,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
|
||||
#include "JSystem/J3DGraphBase/J3DSys.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
J3DVertexData::J3DVertexData() {
|
||||
mVtxNum = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "dolphin/os.h"
|
||||
#include "string.h"
|
||||
#include <string>
|
||||
|
||||
void* J3DClusterLoaderDataBase::load(const void* i_data) {
|
||||
const JUTDataFileHeader* fileHeader = (JUTDataFileHeader*)i_data;
|
||||
@@ -70,9 +70,9 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) {
|
||||
mpDeformData->mVtxNrm = JSUConvertOffsetToPtr<f32>(block, block->mVtxNrm);
|
||||
|
||||
void* clusterPointer = block->mClusterPointer;
|
||||
int clusterKeyPointerSize = (int)block->mClusterKeyPointer - (int)clusterPointer;
|
||||
int clusterVertexPointerSize = (int)block->mClusterVertex - (int)clusterPointer;
|
||||
int vtxPosSize = (int)block->mVtxPos - (int)clusterPointer;
|
||||
int clusterKeyPointerSize = (intptr_t)block->mClusterKeyPointer - (intptr_t)clusterPointer;
|
||||
int clusterVertexPointerSize = (intptr_t)block->mClusterVertex - (intptr_t)clusterPointer;
|
||||
int vtxPosSize = (intptr_t)block->mVtxPos - (intptr_t)clusterPointer;
|
||||
u8* arr = new (0x20) u8[vtxPosSize];
|
||||
memcpy(arr, JSUConvertOffsetToPtr<J3DCluster>(block, clusterPointer), vtxPosSize);
|
||||
mpDeformData->mClusterPointer = (J3DCluster*)arr;
|
||||
@@ -81,10 +81,10 @@ void J3DClusterLoader_v15::readCluster(const J3DClusterBlock* block) {
|
||||
|
||||
for (int i = 0; i < mpDeformData->getClusterNum(); i++) {
|
||||
J3DCluster* cluster = &mpDeformData->mClusterPointer[i];
|
||||
cluster->mClusterKey = JSUConvertOffsetToPtr<J3DClusterKey>(arr - (int)clusterPointer, cluster->mClusterKey);
|
||||
cluster->mClusterKey = JSUConvertOffsetToPtr<J3DClusterKey>(arr - (intptr_t)clusterPointer, cluster->mClusterKey);
|
||||
cluster->field_0x18 = JSUConvertOffsetToPtr<u16>(block, cluster->field_0x18);
|
||||
cluster->mClusterVertex =
|
||||
JSUConvertOffsetToPtr<J3DClusterVertex>(arr - (int)clusterPointer, cluster->mClusterVertex);
|
||||
JSUConvertOffsetToPtr<J3DClusterVertex>(arr - (intptr_t)clusterPointer, cluster->mClusterVertex);
|
||||
J3DDeformer* deformer = new J3DDeformer(mpDeformData);
|
||||
if (cluster->field_0x14 != 0) {
|
||||
deformer->field_0xc = new f32[cluster->field_0x14 * 3];
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J3DU/J3DUClipper.h"
|
||||
#include "math.h"
|
||||
#include <math>
|
||||
|
||||
void J3DUClipper::init() {
|
||||
mNear = 1.0f;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAHostIO/JAHioMessage.h"
|
||||
#include "JSystem/JAHostIO/JAHioNode.h"
|
||||
#include "JSystem/JAHostIO/JAHioUtil.h"
|
||||
#include "JSystem/JHostIO/JORMContext.h"
|
||||
|
||||
u16 JAHControl::smButtonWidth[] = {20, 50, 100, 150, 300, 600};
|
||||
u16 JAHControl::smCommentWidth[] = {20, 50, 100, 200, 400, 800};
|
||||
u16 JAHControl::smComboWidth[] = { 50, 100, 150, 200, 300, 600};
|
||||
u16 JAHControl::smYTop = 5;
|
||||
u16 JAHControl::smXLeft = 5;
|
||||
u16 JAHControl::smIndentSize = 30;
|
||||
u16 JAHControl::smLineHeight = 23;
|
||||
u16 JAHControl::smContWidth = 450;
|
||||
u16 JAHControl::smIntX = 2;
|
||||
u16 JAHControl::smIntY = 5;
|
||||
u16 JAHControl::smNameWidth = 150;
|
||||
|
||||
void JAHControl::returnY(u16 param_1) {
|
||||
mY += u16(smIntY + smLineHeight * param_1);
|
||||
mX = smXLeft + field_0x4 * smIndentSize;
|
||||
}
|
||||
|
||||
void JAHControl::indent(s8 param_1) {
|
||||
field_0x4 += param_1;
|
||||
mX = smXLeft + field_0x4 * smIndentSize;
|
||||
}
|
||||
|
||||
void JAHControl::makeComment(const char* label, u32 id, u8 param_3, u32 style) {
|
||||
mContext->genLabel(label, id, style, NULL, mX, mY, smCommentWidth[param_3], smLineHeight);
|
||||
returnY(1);
|
||||
}
|
||||
|
||||
JAHControl::JAHControl(JORMContext* mctx, JAHioNode* node) {
|
||||
mContext = mctx;
|
||||
mNode = node;
|
||||
mX = smXLeft;
|
||||
mY = smYTop;
|
||||
field_0x4 = 0;
|
||||
char* name = node->getNodeName();
|
||||
if (name) {
|
||||
makeComment(JAHioUtil::getString("■■■ %s ■■■", name), 0xCCCC0000, 5, 0);
|
||||
} else {
|
||||
makeComment("■■■ NO NAMED NODE ■■■", 0, 5, 0);
|
||||
}
|
||||
indent(1);
|
||||
returnY(1);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAHostIO/JAHioMgr.h"
|
||||
#include "JSystem/JAHostIO/JAHFrameNode.h"
|
||||
#include "JSystem/JHostIO/JORServer.h"
|
||||
|
||||
JAHioMgr::JAHioMgr() : field_0x4(0), field_0x8(0) {}
|
||||
|
||||
void JAHioMgr::init_OnGame() {
|
||||
field_0x4 = 0;
|
||||
}
|
||||
|
||||
bool JAHioMgr::isGameMode() {
|
||||
return field_0x4 == 0;
|
||||
}
|
||||
|
||||
void JAHioMgr::appendRootNode(JORReflexible* param_1, JAHioNode* node) {
|
||||
JUT_ASSERT(44, isGameMode());
|
||||
JORMContext* mctx = JORAttachMContext(12);
|
||||
mctx->genNode(param_1, 1, node->getNodeName(), node, 0, 0);
|
||||
JORReleaseMContext(mctx);
|
||||
appendFrameNode(node);
|
||||
}
|
||||
|
||||
void JAHioMgr::appendFrameNode(JAHioNode* node) {
|
||||
if (node->getNodeType() == 1) {
|
||||
field_0xc.append(((JAHFrameNode*)node)->getFrameNodeLink());
|
||||
}
|
||||
}
|
||||
|
||||
void JAHioMgr::removeFrameNode(JAHioNode* node) {
|
||||
if (node->getNodeType() == 1) {
|
||||
field_0xc.remove(((JAHFrameNode*)node)->getFrameNodeLink());
|
||||
}
|
||||
JSUTreeIterator<JAHioNode> it;
|
||||
for (it = node->getTree()->getFirstChild(); it != node->getTree()->getEndChild(); ++it) {
|
||||
removeFrameNode(*it);
|
||||
}
|
||||
}
|
||||
|
||||
u32 JAHioMgr::framework() {
|
||||
JSUListIterator<JAHFrameNode> it;
|
||||
for (it = field_0xc.getFirst(); it != field_0xc.getEnd(); ++it) {
|
||||
it->framework();
|
||||
}
|
||||
JAHioNode* node = JAHioNode::getCurrentNode();
|
||||
if (node && node->getNodeType() == 1) {
|
||||
((JAHFrameNode*)node)->currentFramework();
|
||||
}
|
||||
u32 r30 = 0;
|
||||
if (field_0x4 == 1) {
|
||||
r30 = JOR_MESSAGELOOP();
|
||||
}
|
||||
return r30;
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAHostIO/JAHioNode.h"
|
||||
#include "JSystem/JAHostIO/JAHioMessage.h"
|
||||
#include "JSystem/JAHostIO/JAHioMgr.h"
|
||||
#include "JSystem/JHostIO/JORServer.h"
|
||||
|
||||
JAHioNode::JAHioNode(const char* name) : mTree(this) {
|
||||
mLastChild = NULL;
|
||||
if (name) {
|
||||
setNodeName(name);
|
||||
} else {
|
||||
setNodeName("no named");
|
||||
}
|
||||
}
|
||||
|
||||
JAHioNode::~JAHioNode() {
|
||||
if (getParent()) {
|
||||
getParent()->removeNode(this);
|
||||
}
|
||||
}
|
||||
|
||||
void JAHioNode::updateNode() {
|
||||
JORMContext* mctx = JORReflexible::getJORServer()->attachMCTX(5);
|
||||
mctx->invalidNode(this, 3);
|
||||
JORReflexible::getJORServer()->releaseMCTX(mctx);
|
||||
}
|
||||
|
||||
void JAHioNode::setNodeName(const char* name) {
|
||||
int size = strlen(name) + 1;
|
||||
JUT_ASSERT(51, size < 32);
|
||||
strcpy(mName, name);
|
||||
}
|
||||
|
||||
void JAHioNode::genMessage(JORMContext* mctx) {
|
||||
JAHControl control(mctx, this);
|
||||
message(control);
|
||||
if (JAHSingletonBase<JAHioMgr>::getIns()->getNodeSysType() == 0) {
|
||||
generateTempChildren(mctx);
|
||||
} else {
|
||||
generateRealChildren(mctx);
|
||||
}
|
||||
}
|
||||
|
||||
void JAHioNode::appendNode(JAHioNode* node, const char* name) {
|
||||
mTree.appendChild(&node->mTree);
|
||||
JAHSingletonBase<JAHioMgr>::getIns()->appendFrameNode(node);
|
||||
if (name) {
|
||||
node->setNodeName(name);
|
||||
}
|
||||
updateNode();
|
||||
}
|
||||
|
||||
void JAHioNode::prependNode(JAHioNode* node, const char* name) {
|
||||
mTree.prependChild(&node->mTree);
|
||||
JAHSingletonBase<JAHioMgr>::getIns()->appendFrameNode(node);
|
||||
if (name) {
|
||||
node->setNodeName(name);
|
||||
}
|
||||
updateNode();
|
||||
}
|
||||
|
||||
void JAHioNode::removeNode(JAHioNode* node) {
|
||||
if (smCurrentNode == this) {
|
||||
smCurrentNode = NULL;
|
||||
}
|
||||
mTree.removeChild(&node->mTree);
|
||||
JAHSingletonBase<JAHioMgr>::getIns()->removeFrameNode(node);
|
||||
updateNode();
|
||||
}
|
||||
|
||||
void JAHioNode::generateRealChildren(JORMContext* mctx) {
|
||||
for (JSUTreeIterator<JAHioNode> it(mTree.getFirstChild()); it != mTree.getEndChild(); ++it) {
|
||||
JAHioNode* node = it.getObject();
|
||||
mctx->startNode(node->mName, node, 4, node->getNodeIcon());
|
||||
node->genMessage(mctx);
|
||||
mctx->endNode();
|
||||
}
|
||||
}
|
||||
|
||||
void JAHioNode::generateTempChildren(JORMContext* mctx) {
|
||||
for (JSUTreeIterator<JAHioNode> it(mTree.getFirstChild()); it != mTree.getEndChild(); ++it) {
|
||||
JAHioNode* node = it.getObject();
|
||||
mctx->genNode(node->mName, node, 4, node->getNodeIcon());
|
||||
}
|
||||
}
|
||||
|
||||
u32 JAHioNode::getNodeKind() const { return 0; }
|
||||
|
||||
JAHioNode* JAHioNode::getParent() {
|
||||
if (mTree.getParent()) {
|
||||
return mTree.getParent()->getObject();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void JAHioNode::listenPropertyEvent(const JORPropertyEvent* event) {
|
||||
propertyEvent(JAH_P_EVENT0, (u32)event->id);
|
||||
JORReflexible::listenPropertyEvent(event);
|
||||
propertyEvent(JAH_P_EVENT1, (u32)event->id);
|
||||
}
|
||||
|
||||
void JAHioNode::listenNodeEvent(const JORNodeEvent* event) {
|
||||
if (event->field_0x0 == 3) {
|
||||
smCurrentNode = this;
|
||||
if (getParent()) {
|
||||
getParent()->setLastChild(this);
|
||||
}
|
||||
nodeEvent(JAH_N_EVENT0);
|
||||
} else if (event->field_0x0 == 4) {
|
||||
nodeEvent(JAH_N_EVENT1);
|
||||
} else if (event->field_0x0 == 5) {
|
||||
nodeEvent(JAH_N_EVENT2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAHostIO/JAHioUtil.h"
|
||||
#include <stdio>
|
||||
|
||||
char JAHioUtil::mStringBuffer[256];
|
||||
|
||||
char* JAHioUtil::getString(const char* msg, ...) {
|
||||
va_list args;
|
||||
va_start(msg, args);
|
||||
vsprintf(mStringBuffer, msg, args);
|
||||
va_end(args);
|
||||
return mStringBuffer;
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAWExtSystem/JAWExtSystem.h"
|
||||
#include "JSystem/J2DGraph/J2DOrthoGraph.h"
|
||||
#include "JSystem/JAWExtSystem/JAWGraphContext.h"
|
||||
#include "JSystem/JAWExtSystem/JAWWindow.h"
|
||||
#include "JSystem/JUtility/JUTGamePad.h"
|
||||
#include <algorithm>
|
||||
|
||||
JGadget::TList<JAWWindow*> JAWExtSystem::sPage[128];
|
||||
JAWExtSystem::TSystemInterface JAWExtSystem::sInterface;
|
||||
s32 JAWExtSystem::sCurrentPage = ARRAY_SIZE(sPage) - 1;
|
||||
u8 JAWExtSystem::lbl_80748E44;
|
||||
|
||||
BOOL JAWExtSystem::registWindow(u32 param_1, JAWWindow* param_2, int param_3, int param_4) {
|
||||
TCurrentHeap heap(sInterface);
|
||||
if (param_1 >= ARRAY_SIZE(sPage)) {
|
||||
return FALSE;
|
||||
}
|
||||
param_2->move(param_3, param_4);
|
||||
sPage[param_1].push_back(param_2);
|
||||
if (sCurrentPage > param_1) {
|
||||
sCurrentPage = param_1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JAWExtSystem::destroyWindow(u32 param_1, JAWWindow* param_2) {
|
||||
TCurrentHeap heap(sInterface);
|
||||
if (param_1 >= ARRAY_SIZE(sPage)) {
|
||||
return FALSE;
|
||||
}
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[param_1];
|
||||
JGadget::TList<JAWWindow*>::iterator it = std::find(page->begin(), page->end(), param_2);
|
||||
if (it == page->end()) {
|
||||
return FALSE;
|
||||
}
|
||||
page->erase(it);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void JAWExtSystem::nextPage() {
|
||||
int page = sCurrentPage;
|
||||
do {
|
||||
sCurrentPage++;
|
||||
if (sCurrentPage >= ARRAY_SIZE(sPage)) {
|
||||
sCurrentPage = 0;
|
||||
}
|
||||
if (page == sCurrentPage) {
|
||||
break;
|
||||
}
|
||||
} while (sPage[sCurrentPage].empty());
|
||||
}
|
||||
|
||||
void JAWExtSystem::prevPage() {
|
||||
int page = sCurrentPage;
|
||||
do {
|
||||
sCurrentPage--;
|
||||
if (sCurrentPage < 0) {
|
||||
sCurrentPage = ARRAY_SIZE(sPage) - 1;
|
||||
}
|
||||
if (page == sCurrentPage) {
|
||||
break;
|
||||
}
|
||||
} while (sPage[sCurrentPage].empty());
|
||||
}
|
||||
|
||||
void JAWExtSystem::nextWindow() {
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[sCurrentPage];
|
||||
JGadget::TList<JAWWindow*>::iterator begin = page->begin();
|
||||
if (begin == page->end()) {
|
||||
return;
|
||||
}
|
||||
JAWWindow* window = *begin;
|
||||
page->erase(begin);
|
||||
page->push_back(window);
|
||||
}
|
||||
|
||||
void JAWExtSystem::prevWindow() {
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[sCurrentPage];
|
||||
JGadget::TList<JAWWindow*>::iterator end = page->end();
|
||||
end--;
|
||||
if (end == page->end()) {
|
||||
return;
|
||||
}
|
||||
JAWWindow* window = *end;
|
||||
page->erase(end);
|
||||
page->push_front(window);
|
||||
}
|
||||
|
||||
void JAWExtSystem::draw() {
|
||||
TCurrentHeap heap(sInterface);
|
||||
if (!JAWGraphContext::lbl_8074CD30) {
|
||||
return;
|
||||
}
|
||||
J2DOrthoGraph ortho(0.0f, 0.0f, 640.0f, 480.0f, -1.0f, 1.0f);
|
||||
ortho.setOrtho(0.0f, -20.0f, 640.0f, 520.0f, -1.0, 1.0f);
|
||||
ortho.setPort();
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[sCurrentPage];
|
||||
JGadget::TIterator_reverse<JGadget::TList<JAWWindow*>::iterator> it;
|
||||
for (it = page->rbegin(); it != page->rend(); it++) {
|
||||
JAWWindow** window = &*it;
|
||||
(*window)->initIf();
|
||||
(*window)->setAlpha(lbl_80748E44);
|
||||
(*window)->draw(0, 0, &ortho);
|
||||
}
|
||||
for (int i = 0; i < ARRAY_SIZE(sPage); i++) {
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[i];
|
||||
JGadget::TIterator_reverse<JGadget::TList<JAWWindow*>::iterator> it;
|
||||
for (it = page->rbegin(); it != page->rend(); it++) {
|
||||
JAWWindow** window = &*it;
|
||||
(*window)->frameWork();
|
||||
}
|
||||
}
|
||||
GXSetScissor(0, 0, 640, 480);
|
||||
}
|
||||
|
||||
void JAWExtSystem::padProc(const JUTGamePad& pad) {
|
||||
TCurrentHeap heap(sInterface);
|
||||
if (pad.getAnalogR() && pad.testTrigger(PAD_BUTTON_MENU)) {
|
||||
JAWGraphContext::lbl_8074CD30 ^= true;
|
||||
}
|
||||
if (!JAWGraphContext::lbl_8074CD30) {
|
||||
return;
|
||||
}
|
||||
JGadget::TList<JAWWindow*>* page = &sPage[sCurrentPage];
|
||||
JGadget::TList<JAWWindow*>::iterator begin = page->begin();
|
||||
if (begin == page->end()) {
|
||||
return;
|
||||
}
|
||||
JAWWindow* window = *begin;
|
||||
if (pad.getAnalogR()) {
|
||||
f32 f31 = pad.getAnalogL() * 0.1f + 8.0f;
|
||||
int r25 = f31 * pad.getMainStickX();
|
||||
int r28 = -int(f31 * pad.getMainStickY());
|
||||
if (pad.testButton(PAD_BUTTON_X)) {
|
||||
window->addSize(r25, r28);
|
||||
} else if (pad.testButton(PAD_BUTTON_B)) {
|
||||
int r29 = lbl_80748E44;
|
||||
r29 += (r28 > 0 ? -2 : r28 < 0 ? 2 : 0) * (pad.getAnalogL() ? 2 : 1);
|
||||
if (r29 < 0) {
|
||||
r29 = 0;
|
||||
}
|
||||
if (r29 >= 256) {
|
||||
r29 = 255;
|
||||
}
|
||||
lbl_80748E44 = r29;
|
||||
} else {
|
||||
window->addPosition(r25, r28);
|
||||
}
|
||||
if (pad.testTrigger(PAD_BUTTON_RIGHT)) {
|
||||
nextPage();
|
||||
}
|
||||
if (pad.testTrigger(PAD_BUTTON_LEFT)) {
|
||||
prevPage();
|
||||
}
|
||||
if (pad.testTrigger(PAD_BUTTON_UP)) {
|
||||
prevWindow();
|
||||
}
|
||||
if (pad.testTrigger(PAD_BUTTON_DOWN)) {
|
||||
nextWindow();
|
||||
}
|
||||
} else {
|
||||
window->padProc(pad);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAWExtSystem/JAWGraphContext.h"
|
||||
#include "JSystem/J2DGraph/J2DPrint.h"
|
||||
#include "JSystem/JUtility/JUTResFont.h"
|
||||
|
||||
JUTResFont* JAWGraphContext::sFont;
|
||||
bool JAWGraphContext::lbl_8074CD30;
|
||||
|
||||
JAWGraphContext::JAWGraphContext() :
|
||||
field_0x0(NULL),
|
||||
field_0x4(255, 255, 255, 255),
|
||||
field_0x8(255, 255, 255, 255),
|
||||
field_0xc(255, 255, 255, 255),
|
||||
field_0x10(255, 255, 255, 255) {
|
||||
mParentAlpha = 255;
|
||||
field_0x15 = 6;
|
||||
field_0x16 = 6;
|
||||
field_0x18 = 0;
|
||||
if (!sFont) {
|
||||
sFont = new JUTResFont((ResFONT*)JUTResFONT_Ascfont_fix12, NULL);
|
||||
}
|
||||
field_0x0 = new J2DPrint(sFont, JUtility::TColor(255, 255, 255, 255), JUtility::TColor(255, 255, 255, 255));
|
||||
field_0x0->initiate();
|
||||
locate(0, 0);
|
||||
}
|
||||
|
||||
JAWGraphContext::~JAWGraphContext() {}
|
||||
|
||||
void JAWGraphContext::reset() {
|
||||
locate(0, 0);
|
||||
color(255, 255, 255, 255);
|
||||
setGXforPrint();
|
||||
}
|
||||
|
||||
void JAWGraphContext::color(u8 r, u8 g, u8 b, u8 a) {
|
||||
color(JUtility::TColor(r, g, b, a));
|
||||
}
|
||||
|
||||
void JAWGraphContext::color(const JUtility::TColor& c) {
|
||||
color(c, c, c, c);
|
||||
}
|
||||
|
||||
void JAWGraphContext::locate(int param_1, int param_2) {
|
||||
field_0x0->locate(param_1 * field_0x0->getFont()->getWidth(), (param_2 + 1) * field_0x0->getFont()->getHeight());
|
||||
}
|
||||
|
||||
void JAWGraphContext::print(char const* msg, ...) {
|
||||
va_list args;
|
||||
if (field_0x0->getCursorV() > 640.0f) {
|
||||
return;
|
||||
}
|
||||
if (field_0x18) {
|
||||
setGXforPrint();
|
||||
}
|
||||
va_start(args, msg);
|
||||
u8 alpha = field_0x4.a * mParentAlpha / 255;
|
||||
field_0x0->print_va(alpha, msg, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void JAWGraphContext::print(int param_1, int param_2, const char* msg, ...) {
|
||||
va_list args;
|
||||
locate(param_1, param_2);
|
||||
if (field_0x0->getCursorV() > 640.0f) {
|
||||
return;
|
||||
}
|
||||
if (field_0x18) {
|
||||
setGXforPrint();
|
||||
}
|
||||
va_start(args, msg);
|
||||
u8 alpha = field_0x4.a * mParentAlpha / 255;
|
||||
field_0x0->print_va(alpha, msg, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void JAWGraphContext::color(const JUtility::TColor& param_1, const JUtility::TColor& param_2, const JUtility::TColor& param_3, const JUtility::TColor& param_4) {
|
||||
field_0x4 = param_1;
|
||||
field_0x8 = param_2;
|
||||
field_0xc = param_3;
|
||||
field_0x10 = param_4;
|
||||
field_0x0->setCharColor(param_1);
|
||||
field_0x0->setGradColor(param_2);
|
||||
}
|
||||
|
||||
void JAWGraphContext::fillBox(const JGeometry::TBox2<f32>& box) {
|
||||
if (field_0x18 != 1) {
|
||||
setGXforDraw();
|
||||
}
|
||||
JUtility::TColor color0(field_0x4);
|
||||
JUtility::TColor color1(field_0x8);
|
||||
JUtility::TColor color2(field_0xc);
|
||||
JUtility::TColor color3(field_0x10);
|
||||
if (mParentAlpha != 255) {
|
||||
color0.a = field_0x4.a * mParentAlpha / 255;
|
||||
color1.a = field_0x8.a * mParentAlpha / 255;
|
||||
color2.a = field_0xc.a * mParentAlpha / 255;
|
||||
color3.a = field_0x10.a * mParentAlpha / 255;
|
||||
}
|
||||
GXBegin(GX_QUADS, GX_VTXFMT0, 4);
|
||||
GXPosition3s16(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(color0);
|
||||
GXPosition3s16(box.f.x, box.i.y, 0);
|
||||
GXColor1u32(color2);
|
||||
GXPosition3s16(box.f.x, box.f.y, 0);
|
||||
GXColor1u32(color3);
|
||||
GXPosition3s16(box.i.x, box.f.y, 0);
|
||||
GXColor1u32(color1);
|
||||
GXEnd();
|
||||
}
|
||||
|
||||
void JAWGraphContext::drawFrame(const JGeometry::TBox2<f32>& box) {
|
||||
if (field_0x18 != 1) {
|
||||
setGXforDraw();
|
||||
}
|
||||
JUtility::TColor color0(field_0x4);
|
||||
JUtility::TColor color1(field_0x8);
|
||||
JUtility::TColor color2(field_0xc);
|
||||
JUtility::TColor color3(field_0x10);
|
||||
if (mParentAlpha != 255) {
|
||||
color0.a = field_0x4.a * mParentAlpha / 255;
|
||||
color1.a = field_0x8.a * mParentAlpha / 255;
|
||||
color2.a = field_0xc.a * mParentAlpha / 255;
|
||||
color3.a = field_0x10.a * mParentAlpha / 255;
|
||||
}
|
||||
GXBegin(GX_LINESTRIP, GX_VTXFMT0, 5);
|
||||
GXPosition3s16(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(color0);
|
||||
GXPosition3s16(box.f.x, box.i.y, 0);
|
||||
GXColor1u32(color2);
|
||||
GXPosition3s16(box.f.x, box.f.y, 0);
|
||||
GXColor1u32(color3);
|
||||
GXPosition3s16(box.i.x, box.f.y, 0);
|
||||
GXColor1u32(color1);
|
||||
GXPosition3s16(box.i.x, box.i.y, 0);
|
||||
GXColor1u32(color0);
|
||||
GXEnd();
|
||||
}
|
||||
|
||||
void JAWGraphContext::line(const JGeometry::TVec2<f32>& p1, const JGeometry::TVec2<f32>& p2) {
|
||||
if (field_0x18 != 1) {
|
||||
setGXforDraw();
|
||||
}
|
||||
JUtility::TColor color0(field_0x4);
|
||||
JUtility::TColor color1(field_0x8);
|
||||
if (mParentAlpha != 255) {
|
||||
color0.a = field_0x4.a * mParentAlpha / 255;
|
||||
color1.a = field_0x8.a * mParentAlpha / 255;
|
||||
}
|
||||
GXBegin(GX_LINES, GX_VTXFMT0, 2);
|
||||
GXPosition3s16(p1.x, p1.y, 0);
|
||||
GXColor1u32(color0);
|
||||
GXPosition3s16(p2.x, p2.y, 0);
|
||||
GXColor1u32(color1);
|
||||
GXEnd();
|
||||
}
|
||||
|
||||
void JAWGraphContext::setGXforPrint() {
|
||||
GXSetNumChans(1);
|
||||
GXSetNumTevStages(1);
|
||||
GXSetNumTexGens(1);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_MODULATE);
|
||||
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_S16, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_RGBX8, 15);
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
|
||||
field_0x18 = 0;
|
||||
}
|
||||
|
||||
void JAWGraphContext::setGXforDraw() {
|
||||
GXClearVtxDesc();
|
||||
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||
GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
|
||||
GXSetNumChans(1);
|
||||
GXSetNumTexGens(0);
|
||||
GXSetNumTevStages(1);
|
||||
GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
|
||||
GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
|
||||
GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_VTX, 0, GX_DF_NONE, GX_AF_NONE);
|
||||
GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
GXSetPointSize(field_0x15, GX_TO_ZERO);
|
||||
GXSetLineWidth(field_0x16, GX_TO_ZERO);
|
||||
GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET);
|
||||
field_0x18 = 1;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAWExtSystem/JAWSystem.h"
|
||||
|
||||
JAWSystemInterface* JAWSystemInterface::sInstance;
|
||||
|
||||
JAWSystemInterface::JAWSystemInterface() {
|
||||
mHeap = NULL;
|
||||
sInstance = this;
|
||||
}
|
||||
|
||||
JKRHeap* JAWSystemInterface::getCurrentHeap() const {
|
||||
if (mHeap) {
|
||||
return mHeap;
|
||||
}
|
||||
return JKRGetCurrentHeap();
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAWExtSystem/JAWWindow.h"
|
||||
#include "JSystem/JUtility/JUTGamePad.h"
|
||||
#include "JSystem/JUtility/JUTResFont.h"
|
||||
#include "JSystem/JGeometry.h"
|
||||
|
||||
JAWWindow::JAWWindow(const char* param_1, int param_2, int param_3) :
|
||||
field_0x38('WIN1', JGeometry::TBox2<f32>(0.0f, 0.0f, param_2, param_3), "frame_lu.bti"),
|
||||
field_0x180('TITL', JGeometry::TBox2<f32>(10.0f, 10.0f, 640.0f, 170.0f), (const ResFONT*)JUTResFONT_Ascfont_fix16, param_1, -1, HBIND_LEFT, VBIND_TOP),
|
||||
field_0x2b0(this),
|
||||
field_0x3d8(JUtility::TColor(0, 0, 0, 255)),
|
||||
field_0x3dc(JUtility::TColor(0, 0, 0, 255)),
|
||||
field_0x3e0(JUtility::TColor(0, 0, 0, 255)),
|
||||
field_0x3e4(JUtility::TColor(0, 0, 0, 255)) {
|
||||
field_0x3e8 = 0;
|
||||
field_0x3ec = 0;
|
||||
field_0x38.setContentsColor(field_0x3d8, field_0x3e0, field_0x3dc, field_0x3e4);
|
||||
field_0x180.setCharColor(JUtility::TColor(0, 255, 0, 255));
|
||||
field_0x180.setGradColor(JUtility::TColor(255, 255, 255, 255));
|
||||
field_0x38.appendChild(&field_0x180);
|
||||
field_0x38.appendChild(&field_0x2b0);
|
||||
}
|
||||
|
||||
JAWWindow::TJ2DWindowDraw::TJ2DWindowDraw(u32 param_1, const JGeometry::TBox2<f32>& param_2, const char* param_3) : J2DWindow(param_1, param_2, param_3, TEXTUREBASE_0, NULL) {}
|
||||
|
||||
JAWWindow::~JAWWindow() {}
|
||||
|
||||
BOOL JAWWindow::initIf() {
|
||||
if (field_0x3ec) {
|
||||
return TRUE;
|
||||
} else {
|
||||
field_0x3ec = TRUE;
|
||||
return onInit();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL JAWWindow::onInit() { return TRUE; }
|
||||
|
||||
void JAWWindow::setTitleColor(const JUtility::TColor& param_1, const JUtility::TColor& param_2) {
|
||||
field_0x180.setCharColor(param_1);
|
||||
field_0x180.setGradColor(param_2);
|
||||
}
|
||||
|
||||
void JAWWindow::setWindowColor(const JUtility::TColor& param_1, const JUtility::TColor& param_2, const JUtility::TColor& param_3, const JUtility::TColor& param_4) {
|
||||
field_0x3d8 = param_1;
|
||||
field_0x3dc = param_2;
|
||||
field_0x3e0 = param_3;
|
||||
field_0x3e4 = param_4;
|
||||
field_0x38.setContentsColor(field_0x3d8, field_0x3e0, field_0x3dc, field_0x3e4);
|
||||
}
|
||||
|
||||
void JAWWindow::onDraw(JAWGraphContext*) {}
|
||||
|
||||
void JAWWindow::move(f32 param_1, f32 param_2) {
|
||||
field_0x38.move(param_1, param_2);
|
||||
}
|
||||
|
||||
void JAWWindow::addPosition(f32 param_1, f32 param_2) {
|
||||
field_0x38.add(param_1, param_2);
|
||||
}
|
||||
|
||||
void JAWWindow::addSize(f32 width, f32 height) {
|
||||
JGeometry::TBox2<f32> bounds = field_0x38.getBounds();
|
||||
f32 newWidth = width + bounds.getWidth();
|
||||
f32 newHeight = height + bounds.getHeight();
|
||||
if (newWidth < 36.0f) {
|
||||
newWidth = 36.0f;
|
||||
} else if (newWidth > 640.0f) {
|
||||
newWidth = 640.0f;
|
||||
}
|
||||
if (newHeight < 36.0f) {
|
||||
newHeight = 36.0f;
|
||||
} else if (newHeight > 480.0f) {
|
||||
newHeight = 480.0f;
|
||||
}
|
||||
field_0x38.resize(newWidth, newHeight);
|
||||
}
|
||||
|
||||
JUtility::TColor JAWWindow::convJudaColor(u16 param_1) {
|
||||
return JUtility::TColor((param_1 & 0xf800) >> 8, (param_1 & 0x7c0) >> 3, (param_1 & 0x3e) << 2, 255);
|
||||
}
|
||||
|
||||
void JAWWindow::padProc(const JUTGamePad& pad) {
|
||||
u32 trigger = pad.getTrigger();
|
||||
u32 release = pad.getRelease();
|
||||
u32 button = pad.getButton();
|
||||
u32 repeat = pad.getRepeat();
|
||||
onPadProc(pad);
|
||||
if (trigger & PAD_BUTTON_A) {
|
||||
onTrigA(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_B) {
|
||||
onTrigB(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_X) {
|
||||
onTrigX(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_Y) {
|
||||
onTrigY(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_MENU) {
|
||||
onTrigMenu(pad);
|
||||
}
|
||||
if (trigger & PAD_TRIGGER_L) {
|
||||
onTrigL(pad);
|
||||
}
|
||||
if (trigger & PAD_TRIGGER_Z) {
|
||||
onTrigZ(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_UP) {
|
||||
onTrigUp(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_DOWN) {
|
||||
onTrigDown(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_LEFT) {
|
||||
onTrigLeft(pad);
|
||||
}
|
||||
if (trigger & PAD_BUTTON_RIGHT) {
|
||||
onTrigRight(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_A) {
|
||||
onReleaseA(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_B) {
|
||||
onReleaseB(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_X) {
|
||||
onReleaseX(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_Y) {
|
||||
onReleaseY(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_MENU) {
|
||||
onReleaseMenu(pad);
|
||||
}
|
||||
if (release & PAD_TRIGGER_L) {
|
||||
onReleaseL(pad);
|
||||
}
|
||||
if (release & PAD_TRIGGER_Z) {
|
||||
onReleaseZ(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_UP) {
|
||||
onReleaseUp(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_DOWN) {
|
||||
onReleaseDown(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_LEFT) {
|
||||
onReleaseLeft(pad);
|
||||
}
|
||||
if (release & PAD_BUTTON_RIGHT) {
|
||||
onReleaseRight(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_A) {
|
||||
onKeyA(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_B) {
|
||||
onKeyB(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_X) {
|
||||
onKeyX(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_Y) {
|
||||
onKeyY(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_MENU) {
|
||||
onKeyMenu(pad);
|
||||
}
|
||||
if (repeat & PAD_TRIGGER_L) {
|
||||
onKeyL(pad);
|
||||
}
|
||||
if (repeat & PAD_TRIGGER_Z) {
|
||||
onKeyZ(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_UP) {
|
||||
onKeyUp(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_DOWN) {
|
||||
onKeyDown(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_LEFT) {
|
||||
onKeyLeft(pad);
|
||||
}
|
||||
if (repeat & PAD_BUTTON_RIGHT) {
|
||||
onKeyRight(pad);
|
||||
}
|
||||
}
|
||||
|
||||
JAWWindow::TWindowText::TWindowText(JAWWindow* window) :
|
||||
J2DPane('TEXT', JGeometry::TBox2<f32>(10.0f, 30.0f, 650.0f, 510.0f)),
|
||||
m_pParent(window),
|
||||
field_0x11c(0, 0) {
|
||||
}
|
||||
|
||||
void JAWWindow::TWindowText::drawSelf(f32 param_1, f32 param_2) {
|
||||
Mtx mtx;
|
||||
MTXIdentity(mtx);
|
||||
drawSelf(param_1, param_2, &mtx);
|
||||
}
|
||||
|
||||
void JAWWindow::TWindowText::drawSelf(f32, f32, Mtx* param_3) {
|
||||
field_0xfc.reset();
|
||||
MTXTrans(*param_3, -field_0x11c.x, -field_0x11c.y, 0.0f);
|
||||
Mtx stack_48;
|
||||
MTXConcat(*param_3, mGlobalMtx, stack_48);
|
||||
GXLoadPosMtxImm(stack_48, 0);
|
||||
field_0xfc.setParentAlpha(mColorAlpha);
|
||||
JUT_ASSERT(209, m_pParent != NULL);
|
||||
m_pParent->setMatrix(stack_48);
|
||||
m_pParent->onDraw(&field_0xfc);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAWExtSystem/JAWWindow3D.h"
|
||||
|
||||
JGeometry::TVec2<f32> JAWWindow3D::sPtOrigin(0, 0);
|
||||
@@ -36,7 +36,7 @@ void JAISe::stopTrack_() {
|
||||
case JASTrack::STATUS_RUN:
|
||||
inner_.track.stopSeq();
|
||||
break;
|
||||
case JASTrack::STATUS_STOP:
|
||||
case JASTrack::STATUS_STOPPED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void JAISe::stopTrack_() {
|
||||
void JAISe::startTrack_(const JASSoundParams& params) {
|
||||
JUT_ASSERT(72, inner_.track.getStatus() != JASTrack::STATUS_RUN);
|
||||
|
||||
if (inner_.track.getStatus() == JASTrack::STATUS_STOP) {
|
||||
if (inner_.track.getStatus() == JASTrack::STATUS_STOPPED) {
|
||||
inner_.track.init();
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ void JAISe::JAISeCategoryMgr_mixOut_(bool param_0, const JASSoundParams& params,
|
||||
if (status_.isPlaying()) {
|
||||
if (inner_.field_0x26c) {
|
||||
switch (inner_.track.getStatus()) {
|
||||
case JASTrack::STATUS_STOP:
|
||||
case JASTrack::STATUS_STOPPED:
|
||||
if (status_.field_0x1.flags.flag1) {
|
||||
startTrack_(params);
|
||||
} else {
|
||||
@@ -116,7 +116,7 @@ void JAISe::JAISeCategoryMgr_calc_() {
|
||||
bool JAISe::JAISound_tryDie_() {
|
||||
switch (inner_.track.getStatus()) {
|
||||
case JASTrack::STATUS_FREE:
|
||||
case JASTrack::STATUS_STOP:
|
||||
case JASTrack::STATUS_STOPPED:
|
||||
if (inner_.field_0x278) {
|
||||
inner_.mSoundStrategyMgr->virtual4(inner_.field_0x278);
|
||||
inner_.field_0x278 = NULL;
|
||||
|
||||
@@ -6,15 +6,16 @@
|
||||
#include "JSystem/JAudio2/JASReport.h"
|
||||
|
||||
bool JAISeCategoryMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
JSULink<JAISe>* i = mSeList.getFirst();
|
||||
while (i != NULL) {
|
||||
JAISe* obj = i->getObject();
|
||||
if (seqDataRegion.intersects(*obj->getSeqData())) {
|
||||
return true;
|
||||
{
|
||||
JSULink<JAISe>* i = mSeList.getFirst();
|
||||
while (i != NULL) {
|
||||
if (seqDataRegion.intersects(*i->getObject()->getSeqData())) {
|
||||
return true;
|
||||
}
|
||||
i = i->getNext();
|
||||
}
|
||||
i = i->getNext();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -162,7 +163,7 @@ JAISeMgr::JAISeMgr(bool setInstance) : JASGlobalInstance<JAISeMgr>(setInstance)
|
||||
mSeqDataMgr = NULL;
|
||||
mStrategyMgr = NULL;
|
||||
mParams.init();
|
||||
JAISoundActivity::init();
|
||||
mSoundActivity.init();
|
||||
}
|
||||
|
||||
bool JAISeMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
@@ -196,6 +197,17 @@ void JAISeMgr::setCategoryArrangement(const JAISeCategoryArrangement& arrangemen
|
||||
}
|
||||
}
|
||||
|
||||
void JAISeMgr::getCategoryArrangement(JAISeCategoryArrangement* arrangement) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int active = mCategoryMgrs[i].getMaxActiveSe();
|
||||
JUT_ASSERT(299, active <= 255);
|
||||
arrangement->mItems[i].mMaxActiveSe = active;
|
||||
int inactive = mCategoryMgrs[i].getMaxInactiveSe();
|
||||
JUT_ASSERT(302, inactive <= 255);
|
||||
arrangement->mItems[i].mMaxInactiveSe = inactive;
|
||||
}
|
||||
}
|
||||
|
||||
void JAISeMgr::stop() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
mCategoryMgrs[i].stop();
|
||||
@@ -268,7 +280,7 @@ void JAISeMgr::calc() {
|
||||
|
||||
void JAISeMgr::mixOut() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, *this);
|
||||
mCategoryMgrs[i].JAISeMgr_mixOut_(mParams, mSoundActivity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace {
|
||||
|
||||
static bool JASTrack_isFreeOrStopped(JASTrack* track) {
|
||||
u32 status = track->getStatus();
|
||||
return status == JASTrack::STATUS_FREE || status == JASTrack::STATUS_STOP;
|
||||
return status == JASTrack::STATUS_FREE || status == JASTrack::STATUS_STOPPED;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -73,10 +73,12 @@ void JAISeq::reserveChildTracks_(int param_0) {
|
||||
track->connectChild(j, track2);
|
||||
} else {
|
||||
JUT_WARN(117, "%s", "JASPoolAllocObject::<JASTrack>::operator new failed .\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JUT_WARN(124, "%s", "JASPoolAllocObject::<JASTrack>::operator new failed .\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +153,7 @@ bool JAISeq::prepare_(const JASSoundParams& params, JAISoundActivity activity) {
|
||||
}
|
||||
|
||||
void JAISeq::JAISeqMgr_calc_() {
|
||||
if (inner_.outputTrack.getStatus() == JASTrack::STATUS_STOP || (inner_.outputTrack.getStatus() == JASTrack::STATUS_FREE && status_.state.unk == 2)) {
|
||||
if (inner_.outputTrack.getStatus() == JASTrack::STATUS_STOPPED || (inner_.outputTrack.getStatus() == JASTrack::STATUS_FREE && status_.state.unk == 2)) {
|
||||
die_();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@
|
||||
#include "JSystem/JAudio2/JAISoundInfo.h"
|
||||
|
||||
bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
|
||||
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
|
||||
JSULink<JAISeq>* link;
|
||||
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
|
||||
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -16,9 +17,10 @@ bool JAISeqMgr::isUsingSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
|
||||
int JAISeqMgr::releaseSeqData(const JAISeqDataRegion& seqDataRegion) {
|
||||
bool bVar1 = false;
|
||||
for (JSULink<JAISeq>* i = mSeqList.getFirst(); i != NULL; i = i->getNext()) {
|
||||
if (seqDataRegion.intersects(i->getObject()->getSeqData())) {
|
||||
i->getObject()->stop();
|
||||
JSULink<JAISeq>* link;
|
||||
for (link = mSeqList.getFirst(); link != NULL; link = link->getNext()) {
|
||||
if (seqDataRegion.intersects(link->getObject()->getSeqData())) {
|
||||
link->getObject()->stop();
|
||||
bVar1 = true;
|
||||
}
|
||||
}
|
||||
@@ -120,7 +122,7 @@ void JAISeqMgr::mixOut() {
|
||||
JAISeq* JAISeqMgr::beginStartSeq_() {
|
||||
JAISeq* seq = new JAISeq(this, field_0x10);
|
||||
if (seq == NULL) {
|
||||
JUT_WARN(273, "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
|
||||
JUT_WARN(273, "%s", "JASPoolAllocObject::<JAISeq>::operator new failed .\n");
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
|
||||
@@ -10,19 +10,20 @@ JAISoundStarter::~JAISoundStarter() {}
|
||||
|
||||
bool JAISoundStarter::startLevelSound(JAISoundID id, JAISoundHandle* handlePtr, const JGeometry::TVec3<f32>* posPtr) {
|
||||
JUT_ASSERT(20, handlePtr);
|
||||
if (*handlePtr) {
|
||||
if ((*handlePtr)->getID() == id) {
|
||||
(*handlePtr)->updateLifeTime(1);
|
||||
JAISoundHandle* handlePtr2 = handlePtr;
|
||||
if (*handlePtr2) {
|
||||
if ((*handlePtr2)->getID() == id) {
|
||||
(*handlePtr2)->updateLifeTime(1);
|
||||
if (posPtr != NULL) {
|
||||
(*handlePtr)->setPos(*posPtr);
|
||||
(*handlePtr2)->setPos(*posPtr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool rt = startSound(id, handlePtr, posPtr);
|
||||
if (rt && *handlePtr) {
|
||||
(*handlePtr)->setLifeTime(1, false);
|
||||
if (rt && *handlePtr2) {
|
||||
(*handlePtr2)->setLifeTime(1, false);
|
||||
}
|
||||
return rt;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ JAISoundChild* JAIStream::getChild(int index) {
|
||||
if (children_[index] == NULL) {
|
||||
children_[index] = new JAISoundChild();
|
||||
if (children_[index] == NULL) {
|
||||
JUT_WARN(370, "%s", "JASPoolAllocObject::<JAISoundChild>::operator new failed .")
|
||||
JUT_WARN(370, "%s", "JASPoolAllocObject::<JAISoundChild>::operator new failed .\n")
|
||||
}
|
||||
}
|
||||
return children_[index];
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "dolphin/ai.h"
|
||||
#include <dolphin/os.h>
|
||||
#include <stdint.h>
|
||||
#include <stdint>
|
||||
|
||||
s16* JASDriver::sDmaDacBuffer[3];
|
||||
|
||||
@@ -30,7 +30,7 @@ s32 JASDriver::sDspDacReadBuffer;
|
||||
|
||||
s32 JASDriver::sDspStatus;
|
||||
|
||||
void (*JASDriver::sDspDacCallback)(s16*, u32);
|
||||
JASDriver::DSPBufCallback JASDriver::sDspDacCallback;
|
||||
|
||||
s16* JASDriver::lastRspMadep;
|
||||
|
||||
@@ -140,7 +140,6 @@ void JASDriver::updateDac() {
|
||||
}
|
||||
|
||||
void JASDriver::updateDSP() {
|
||||
static u32 history[10] = {0x000F4240};
|
||||
JASProbe::start(3, "SFR-UPDATE");
|
||||
JASDsp::invalChannelAll();
|
||||
|
||||
@@ -151,6 +150,7 @@ void JASDriver::updateDSP() {
|
||||
JASPortCmd::execAllCommand();
|
||||
DSPSyncCallback();
|
||||
static u32 old_time = 0;
|
||||
static u32 history[10] = {0x000F4240};
|
||||
u32 r28 = OSGetTick();
|
||||
u32 r27 = r28 - old_time;
|
||||
old_time = r28;
|
||||
@@ -210,15 +210,37 @@ void JASDriver::readDspBuffer(s16* param_0, u32 param_1) {
|
||||
JASCalc::imixcopy(endDacBuffer, dacBuffer, param_0, param_1);
|
||||
}
|
||||
|
||||
u32 sDspUpCount;
|
||||
|
||||
void JASDriver::finishDSPFrame() {
|
||||
static u32 waitcount;
|
||||
int r30 = sDspDacWriteBuffer + 1;
|
||||
if (r30 == data_804507A8) {
|
||||
r30 = 0;
|
||||
}
|
||||
if (r30 == sDspDacReadBuffer) {
|
||||
sDspStatus = 0;
|
||||
#if DEBUG
|
||||
if (sDspStatus != 0) {
|
||||
waitcount = 0;
|
||||
} else {
|
||||
waitcount++;
|
||||
}
|
||||
if (waitcount != 7) {
|
||||
return;
|
||||
}
|
||||
if (sDspUpCount != 0) {
|
||||
JUT_WARN(0, "forth DSP return\n");
|
||||
}
|
||||
if (sDspUpCount == 0) {
|
||||
sDspUpCount += 1;
|
||||
}
|
||||
JASReport("finishDSPFrame nbuf:%d sWBuf:%d BCount:%d stat:%d", r30, sDspDacWriteBuffer, data_804507A8, sDspStatus);
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
sDspDacWriteBuffer = r30;
|
||||
JASAudioThread::setDSPSyncCount(getSubFrames());
|
||||
JASProbe::start(7, "DSP-MAIN");
|
||||
@@ -236,6 +258,10 @@ void JASDriver::registerMixCallback(MixCallback param_0, JASMixMode param_1) {
|
||||
sMixMode = param_1;
|
||||
}
|
||||
|
||||
void JASDriver::registDSPBufCallback(DSPBufCallback cb) {
|
||||
sDspDacCallback = cb;
|
||||
}
|
||||
|
||||
f32 JASDriver::getDacRate() {
|
||||
return sDacRate;
|
||||
}
|
||||
@@ -254,68 +280,84 @@ u32 JASDriver::getFrameSamples() {
|
||||
|
||||
void JASDriver::mixMonoTrack(s16* buffer, u32 param_1, MixCallback param_2) {
|
||||
JASProbe::start(5, "MONO-MIX");
|
||||
s16* r31 = param_2(param_1);
|
||||
s16* pTrack = buffer;
|
||||
if (r31 == NULL) {
|
||||
s16* r26 = param_2(param_1);
|
||||
if (r26 == NULL) {
|
||||
return;
|
||||
}
|
||||
JASProbe::stop(5);
|
||||
s16* pTrack = buffer;
|
||||
s16* r28 = r26;
|
||||
for (u32 i = param_1; i != 0; i--) {
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(pTrack[0] + r31[0]);
|
||||
pTrack[1] = JASCalc::clamp<s16, s32>(pTrack[1] + r31[0]);
|
||||
pTrack += 2;
|
||||
r31++;
|
||||
s32 src = pTrack[0];
|
||||
src += r28[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(src);
|
||||
pTrack++;
|
||||
src = pTrack[0];
|
||||
src += r28[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(src);
|
||||
pTrack++;
|
||||
r28++;
|
||||
}
|
||||
}
|
||||
|
||||
void JASDriver::mixMonoTrackWide(s16* buffer, u32 param_1, MixCallback param_2) {
|
||||
JASProbe::start(5, "MONO(W)-MIX");
|
||||
s16* r31 = param_2(param_1);
|
||||
s16* pTrack = buffer;
|
||||
if (!r31) {
|
||||
s16* r26 = param_2(param_1);
|
||||
if (!r26) {
|
||||
return;
|
||||
}
|
||||
JASProbe::stop(5);
|
||||
s16* pTrack = buffer;
|
||||
s16* r28 = r26;
|
||||
for (u32 i = param_1; i != 0; i--) {
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(pTrack[0] + r31[0]);
|
||||
s32 src = pTrack[1];
|
||||
src -= r31[0];
|
||||
pTrack[1] = JASCalc::clamp<s16, s32>(src);
|
||||
pTrack += 2;
|
||||
r31++;
|
||||
s32 src = pTrack[0];
|
||||
src += r28[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(src);
|
||||
pTrack++;
|
||||
src = pTrack[0];
|
||||
src -= r28[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(src);
|
||||
pTrack++;
|
||||
r28++;
|
||||
}
|
||||
}
|
||||
|
||||
void JASDriver::mixExtraTrack(s16* buffer, u32 param_1, MixCallback param_2) {
|
||||
JASProbe::start(5, "DSPMIX");
|
||||
s16* r31 = param_2(param_1);
|
||||
if (!r31) {
|
||||
s16* r27 = param_2(param_1);
|
||||
if (!r27) {
|
||||
return;
|
||||
}
|
||||
JASProbe::stop(5);
|
||||
JASProbe::start(6, "MIXING");
|
||||
s16* pTrack = buffer;
|
||||
s16* r29 = r31 + getFrameSamples();
|
||||
s16* r29 = r27;
|
||||
s16* r28 = r27 + getFrameSamples();
|
||||
for (u32 i = param_1; i != 0; i--) {
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(pTrack[0] + r29[0]);
|
||||
pTrack[1] = JASCalc::clamp<s16, s32>(pTrack[1] + r31[0]);
|
||||
pTrack += 2;
|
||||
s32 r25 = pTrack[0] + r28[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(r25);
|
||||
pTrack++;
|
||||
r25 = pTrack[0] + r29[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(r25);
|
||||
pTrack++;
|
||||
r28++;
|
||||
r29++;
|
||||
r31++;
|
||||
}
|
||||
JASProbe::stop(6);
|
||||
}
|
||||
|
||||
void JASDriver::mixInterleaveTrack(s16* buffer, u32 param_1, MixCallback param_2) {
|
||||
s16* r31 = param_2(param_1);
|
||||
if (r31) {
|
||||
s16* pTrack = buffer;
|
||||
s16* r30 = r31;
|
||||
for (u32 i = param_1 * 2; i != 0; i--) {
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(pTrack[0] + r30[0]);
|
||||
pTrack += 1;
|
||||
r30++;
|
||||
}
|
||||
if (!r31) {
|
||||
return;
|
||||
}
|
||||
s16* pTrack = buffer;
|
||||
s16* r30 = r31;
|
||||
for (u32 i = param_1 * 2; i != 0; i--) {
|
||||
s32 r26 = pTrack[0] + r30[0];
|
||||
pTrack[0] = JASCalc::clamp<s16, s32>(r26);
|
||||
pTrack++;
|
||||
r30++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,20 +19,24 @@ u32 JASAramStream::sBlockSize;
|
||||
|
||||
u32 JASAramStream::sChannelMax;
|
||||
|
||||
/* 80451260 0001+00 data_80451260 None */
|
||||
/* 80451261 0001+00 data_80451261 None */
|
||||
/* 80451262 0006+00 data_80451262 None */
|
||||
bool struct_80451260;
|
||||
bool struct_80451261;
|
||||
|
||||
void JASAramStream::initSystem(u32 i_blockSize, u32 i_channelMax) {
|
||||
if (JASDriver::registerSubFrameCallback(dvdErrorCheck, NULL)) {
|
||||
void JASAramStream::initSystem(u32 block_size, u32 channel_max) {
|
||||
JUT_ASSERT(66, block_size % 32 == 0);
|
||||
JUT_ASSERT(67, block_size % 9 == 0);
|
||||
JUT_ASSERT(68, channel_max > 0 && channel_max <= CHANNEL_MAX);
|
||||
JUT_ASSERT(69, sReadBuffer == 0);
|
||||
if (!JASDriver::registerSubFrameCallback(dvdErrorCheck, NULL)) {
|
||||
JUT_WARN(72, "%s", "registerSubFrameCallback Failed");
|
||||
} else {
|
||||
if (sLoadThread == NULL) {
|
||||
sLoadThread = JASDvd::getThreadPointer();
|
||||
}
|
||||
sReadBuffer = new (JASDram, 0x20) u8[(i_blockSize + 0x20) * i_channelMax];
|
||||
sBlockSize = i_blockSize;
|
||||
sChannelMax = i_channelMax;
|
||||
sReadBuffer = new (JASDram, 0x20) u8[(block_size + 0x20) * channel_max];
|
||||
JUT_ASSERT(79, sReadBuffer);
|
||||
sBlockSize = block_size;
|
||||
sChannelMax = channel_max;
|
||||
struct_80451260 = false;
|
||||
struct_80451261 = false;
|
||||
}
|
||||
@@ -85,6 +89,7 @@ JASAramStream::JASAramStream() {
|
||||
}
|
||||
|
||||
void JASAramStream::init(u32 param_0, u32 param_1, StreamCallback i_callback, void* i_callbackData) {
|
||||
JUT_ASSERT(153, sReadBuffer != NULL);
|
||||
field_0x148 = param_0;
|
||||
field_0x14c = param_1;
|
||||
field_0x0c8 = 0.0f;
|
||||
@@ -110,9 +115,11 @@ void JASAramStream::init(u32 param_0, u32 param_1, StreamCallback i_callback, vo
|
||||
|
||||
bool JASAramStream::prepare(s32 param_0, int param_1) {
|
||||
if (!DVDFastOpen(param_0, &mDvdFileInfo)) {
|
||||
JUT_WARN(240, "%s", "DVDFastOpen Failed");
|
||||
return false;
|
||||
}
|
||||
if (!JASDriver::registerSubFrameCallback(channelProcCallback, this)) {
|
||||
JUT_WARN(245, "%s", "registerSubFrameCallback Failed");
|
||||
return false;
|
||||
}
|
||||
TaskData data;
|
||||
@@ -120,6 +127,7 @@ bool JASAramStream::prepare(s32 param_0, int param_1) {
|
||||
data.field_0x4 = field_0x14c;
|
||||
data.field_0x8 = param_1;
|
||||
if (!sLoadThread->sendCmdMsg(headerLoadTask, &data, 0xc)) {
|
||||
JUT_WARN(254, "%s", "sendCmdMsg headerLoadTask Failed");
|
||||
JASDriver::rejectCallback(channelProcCallback, this);
|
||||
return false;
|
||||
}
|
||||
@@ -127,21 +135,25 @@ bool JASAramStream::prepare(s32 param_0, int param_1) {
|
||||
}
|
||||
|
||||
bool JASAramStream::start() {
|
||||
return OSSendMessage(&field_0x000, (OSMessage)0, OS_MESSAGE_NOBLOCK);
|
||||
if (!OSSendMessage(&field_0x000, (OSMessage)0, OS_MESSAGE_NOBLOCK)) {
|
||||
JUT_WARN(273, "%s", "OSSendMessage Failed")
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JASAramStream::stop(u16 param_0) {
|
||||
return OSSendMessage(&field_0x000, (OSMessage)(param_0 << 0x10 | 1), OS_MESSAGE_NOBLOCK);
|
||||
if (!OSSendMessage(&field_0x000, (OSMessage)(param_0 << 0x10 | 1), OS_MESSAGE_NOBLOCK)) {
|
||||
JUT_WARN(290, "%s", "OSSendMessage Failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JASAramStream::pause(bool param_0) {
|
||||
OSMessage msg;
|
||||
if (param_0) {
|
||||
msg = (OSMessage)2;
|
||||
} else {
|
||||
msg = (OSMessage)3;
|
||||
}
|
||||
OSMessage msg = param_0 ? (OSMessage)2 : (OSMessage)3;
|
||||
if (!OSSendMessage(&field_0x000, msg, OS_MESSAGE_NOBLOCK)) {
|
||||
JUT_WARN(308, "%s", "OSSendMessage Failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -149,14 +161,15 @@ bool JASAramStream::pause(bool param_0) {
|
||||
|
||||
bool JASAramStream::cancel() {
|
||||
field_0x114 = 1;
|
||||
return sLoadThread->sendCmdMsg(finishTask, this);
|
||||
if (!sLoadThread->sendCmdMsg(finishTask, this)) {
|
||||
JUT_WARN(326, "%s", "sendCmdMsg finishTask Failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 JASAramStream::getBlockSamples() const {
|
||||
if (field_0x158 == 0) {
|
||||
return (sBlockSize << 4) / 9;
|
||||
}
|
||||
return sBlockSize >> 1;
|
||||
return field_0x158 == 0 ? (sBlockSize << 4) / 9 : sBlockSize >> 1;
|
||||
}
|
||||
|
||||
void JASAramStream::headerLoadTask(void* i_data) {
|
||||
@@ -174,6 +187,7 @@ void JASAramStream::firstLoadTask(void* i_data) {
|
||||
data->field_0x8--;
|
||||
if (data->field_0x8 == 0) {
|
||||
if (!sLoadThread->sendCmdMsg(prepareFinishTask, _this)) {
|
||||
JUT_WARN(364, "%s", "sendCmdMsg prepareFinishTask Failed");
|
||||
struct_80451261 = true;
|
||||
}
|
||||
}
|
||||
@@ -181,6 +195,7 @@ void JASAramStream::firstLoadTask(void* i_data) {
|
||||
if (data->field_0x4 != 0) {
|
||||
data->field_0x4--;
|
||||
if (!sLoadThread->sendCmdMsg(firstLoadTask, data, 0xc)) {
|
||||
JUT_WARN(372, "%s", "sendCmdMsg firstLoadTask Failed");
|
||||
struct_80451261 = true;
|
||||
}
|
||||
JASCriticalSection cs;
|
||||
@@ -189,12 +204,15 @@ void JASAramStream::firstLoadTask(void* i_data) {
|
||||
}
|
||||
|
||||
void JASAramStream::loadToAramTask(void* i_this) {
|
||||
((JASAramStream*)i_this)->load();
|
||||
JASAramStream* stream = (JASAramStream*)i_this;
|
||||
stream->load();
|
||||
}
|
||||
|
||||
void JASAramStream::finishTask(void* i_this) {
|
||||
JASAramStream* _this = (JASAramStream*)i_this;
|
||||
JASDriver::rejectCallback(channelProcCallback, _this);
|
||||
if (!JASDriver::rejectCallback(channelProcCallback, _this)) {
|
||||
JUT_WARN(392, "%s", "rejectSubFrameCallback Failed");
|
||||
}
|
||||
if (_this->mCallback != NULL) {
|
||||
_this->mCallback(CB_START, _this, _this->mCallbackData);
|
||||
_this->mCallback = NULL;
|
||||
@@ -217,10 +235,16 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
|
||||
return false;
|
||||
}
|
||||
if (DVDReadPrio(&mDvdFileInfo, sReadBuffer, sizeof(Header), 0, 1) < 0) {
|
||||
JUT_WARN(420, "%s", "DVDReadPrio Failed");
|
||||
struct_80451261 = true;
|
||||
return false;
|
||||
}
|
||||
Header* header = (Header*)sReadBuffer;
|
||||
JUT_ASSERT(426, header->tag == 'STRM');
|
||||
JUT_ASSERT(427, header->format <= 1);
|
||||
JUT_ASSERT(428, header->bits == 16);
|
||||
JUT_ASSERT(429, header->channels <= sChannelMax);
|
||||
JUT_ASSERT(430, header->block_size == sBlockSize);
|
||||
field_0x158 = header->format;
|
||||
mChannelNum = header->channels;
|
||||
field_0x164 = header->field_0x10;
|
||||
@@ -233,9 +257,16 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
|
||||
field_0x10c = 0;
|
||||
field_0x160 = (param_0 / sBlockSize) / header->channels;
|
||||
mBufCount = field_0x160;
|
||||
JUT_ASSERT(445, mBufCount > 0);
|
||||
mBufCount--;
|
||||
if (mBufCount < 3) {
|
||||
JUT_WARN(449, "%s", "Too few Buffer-Size");
|
||||
}
|
||||
field_0x108 = mBufCount;
|
||||
getBlockSamples();
|
||||
u32 local_2c = (mLoopEnd - 1) / getBlockSamples();
|
||||
if (local_2c <= mBufCount && mLoop) {
|
||||
JUT_WARN(458, "%s", "Too few samples for Loop-buffer");
|
||||
}
|
||||
if (param_1 < 0 || param_1 > field_0x108) {
|
||||
param_1 = field_0x108;
|
||||
}
|
||||
@@ -247,6 +278,7 @@ bool JASAramStream::headerLoad(u32 param_0, int param_1) {
|
||||
data.field_0x4 = field_0x108 - 1;
|
||||
data.field_0x8 = param_1;
|
||||
if (!sLoadThread->sendCmdMsg(firstLoadTask, &data, 0xc)) {
|
||||
JUT_WARN(472, "%s", "sendCmdMsg firstLoadTask Failed");
|
||||
struct_80451261 = true;
|
||||
return false;
|
||||
}
|
||||
@@ -331,11 +363,13 @@ bool JASAramStream::load() {
|
||||
}
|
||||
|
||||
s32 JASAramStream::channelProcCallback(void* i_this) {
|
||||
return ((JASAramStream*)i_this)->channelProc();
|
||||
JASAramStream* stream = (JASAramStream*)i_this;
|
||||
return stream->channelProc();
|
||||
}
|
||||
|
||||
s32 JASAramStream::dvdErrorCheck(void* param_0) {
|
||||
switch (DVDGetDriveStatus()) {
|
||||
s32 status = DVDGetDriveStatus();
|
||||
switch (status) {
|
||||
case DVD_STATE_END:
|
||||
struct_80451260 = false;
|
||||
break;
|
||||
@@ -359,7 +393,8 @@ s32 JASAramStream::dvdErrorCheck(void* param_0) {
|
||||
|
||||
void JASAramStream::channelCallback(u32 i_callbackType, JASChannel* i_channel,
|
||||
JASDsp::TChannel* i_dspChannel, void* i_this) {
|
||||
((JASAramStream*)i_this)->updateChannel(i_callbackType, i_channel, i_dspChannel);
|
||||
JASAramStream* stream = (JASAramStream*)i_this;
|
||||
stream->updateChannel(i_callbackType, i_channel, i_dspChannel);
|
||||
}
|
||||
|
||||
void JASAramStream::updateChannel(u32 i_callbackType, JASChannel* i_channel,
|
||||
@@ -632,18 +667,21 @@ void JASAramStream::channelStart() {
|
||||
// probably a fake match, this should be set in the JASWaveInfo constructor
|
||||
static u32 const one = 1;
|
||||
wave_info.field_0x20 = &one;
|
||||
JASChannel* channel = new JASChannel(channelCallback, this);
|
||||
channel->setPriority(0x7f7f);
|
||||
JASChannel* jc = new JASChannel(channelCallback, this);
|
||||
JUT_ASSERT(963, jc);
|
||||
jc->setPriority(0x7f7f);
|
||||
for (u32 j = 0; j < 6; j++) {
|
||||
channel->setMixConfig(j, field_0x1dc[j]);
|
||||
jc->setMixConfig(j, field_0x1dc[j]);
|
||||
}
|
||||
channel->setInitPitch(field_0x164 / JASDriver::getDacRate());
|
||||
channel->setOscInit(0, &OSC_ENV);
|
||||
channel->field_0xdc.field_0x4 = wave_info;
|
||||
channel->field_0x104 = field_0x148 + sBlockSize * field_0x160 * i;
|
||||
channel->field_0xdc.field_0x0 = 0;
|
||||
channel->playForce();
|
||||
mChannels[i] = channel;
|
||||
jc->setInitPitch(field_0x164 / JASDriver::getDacRate());
|
||||
jc->setOscInit(0, &OSC_ENV);
|
||||
jc->field_0xdc.field_0x4 = wave_info;
|
||||
jc->field_0x104 = field_0x148 + sBlockSize * field_0x160 * i;
|
||||
jc->field_0xdc.field_0x0 = 0;
|
||||
int ret = jc->playForce();
|
||||
JUT_ASSERT(977, ret);
|
||||
JUT_ASSERT_MSG(979, mChannels[i] == NULL, "channelStart for already playing channel");
|
||||
mChannels[i] = jc;
|
||||
}
|
||||
field_0x0a8 = NULL;
|
||||
}
|
||||
@@ -651,8 +689,9 @@ void JASAramStream::channelStart() {
|
||||
|
||||
void JASAramStream::channelStop(u16 i_directRelease) {
|
||||
for (int i = 0; i < mChannelNum; i++) {
|
||||
if (mChannels[i] != NULL) {
|
||||
mChannels[i]->release(i_directRelease);
|
||||
JASChannel* channel = mChannels[i];
|
||||
if (channel != NULL) {
|
||||
channel->release(i_directRelease);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,41 +10,46 @@ struct JASDSPChannel {
|
||||
void drop();
|
||||
static JASDSPChannel* getHandle(u32);
|
||||
|
||||
inline u32 getStatus() {return mStatus;}
|
||||
inline u8 getStatus() const { return mStatus; }
|
||||
u32 mStatus;
|
||||
};
|
||||
|
||||
JASAudioReseter::JASAudioReseter() {
|
||||
field_0x0 = 0;
|
||||
mIsDone = true;
|
||||
field_0xc = false;
|
||||
mDoneFlag = true;
|
||||
mThreadStopFlag = false;
|
||||
mDSPLevel = JASDriver::getDSPLevel();
|
||||
}
|
||||
|
||||
JASAudioReseter::~JASAudioReseter() {}
|
||||
JASAudioReseter::~JASAudioReseter() {
|
||||
JUT_ASSERT(28, mDoneFlag);
|
||||
}
|
||||
|
||||
bool JASAudioReseter::start(u32 param_0, bool param_1) {
|
||||
if (mIsDone == false) {
|
||||
if (mDoneFlag == false) {
|
||||
return false;
|
||||
}
|
||||
field_0xc = param_1;
|
||||
mThreadStopFlag = param_1;
|
||||
JASCriticalSection critical;
|
||||
if (!JASDriver::registerDspSyncCallback(callback, this)) {
|
||||
JUT_WARN(40, "%s", "Failed JASAudioReseter start\n");
|
||||
return false;
|
||||
} else {
|
||||
mDSPLevel = JASDriver::getDSPLevel();
|
||||
field_0x0 = param_0;
|
||||
mIsDone = false;
|
||||
mDoneFlag = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void JASAudioReseter::resume() {
|
||||
JUT_ASSERT(55, mDoneFlag);
|
||||
JUT_ASSERT(56, ! mThreadStopFlag);
|
||||
JASDriver::setDSPLevel(mDSPLevel);
|
||||
}
|
||||
|
||||
s32 JASAudioReseter::checkDone() const {
|
||||
return mIsDone;
|
||||
return mDoneFlag;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,23 +57,24 @@ s32 JASAudioReseter::calc() {
|
||||
if(field_0x0==0) {
|
||||
for(size_t i = 0; i<64; i++) {
|
||||
JASDSPChannel* handle = JASDSPChannel::getHandle(i);
|
||||
if ((handle->getStatus()&0xFF)==0) {
|
||||
if ((handle->getStatus())==0) {
|
||||
handle->drop();
|
||||
}
|
||||
}
|
||||
if(field_0xc!=false) {
|
||||
JASGlobalInstance<JASAudioThread>::getInstance()->stop();//JASGlobalInstance<JASAudioThread>::sInstance->stop();
|
||||
if(mThreadStopFlag!=false) {
|
||||
JASAudioThread* pAudioThread = JASGlobalInstance<JASAudioThread>::getInstance();
|
||||
JUT_ASSERT(78, pAudioThread);
|
||||
pAudioThread->stop();
|
||||
}
|
||||
mIsDone = 1;
|
||||
mDoneFlag = 1;
|
||||
return -1;
|
||||
}
|
||||
field_0x0--;
|
||||
u32 unk = field_0x0;
|
||||
float dspLevel = JASDriver::getDSPLevel();
|
||||
JASDriver::setDSPLevel(((float)unk*dspLevel)/(float)(unk+1));
|
||||
JASDriver::setDSPLevel(field_0x0 * JASDriver::getDSPLevel() / (field_0x0 + 1));
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 JASAudioReseter::callback(void* param_0) {
|
||||
return ((JASAudioReseter*)param_0)->calc();
|
||||
JASAudioReseter* i_this = (JASAudioReseter*) param_0;
|
||||
return i_this->calc();
|
||||
}
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#include "JSystem/JAudio2/JASDSPInterface.h"
|
||||
#include "JSystem/JAudio2/JASHeapCtrl.h"
|
||||
#include "JSystem/JAudio2/JASProbe.h"
|
||||
#include "JSystem/JAudio2/JASReport.h"
|
||||
#include "JSystem/JKernel/JKRSolidHeap.h"
|
||||
#include "dolphin/dsp.h"
|
||||
#include <stdint>
|
||||
|
||||
JASAudioThread::JASAudioThread(int stackSize, int msgCount, u32 threadPriority)
|
||||
:
|
||||
@@ -20,9 +22,17 @@ JASAudioThread::JASAudioThread(int stackSize, int msgCount, u32 threadPriority)
|
||||
}
|
||||
|
||||
void JASAudioThread::create(s32 threadPriority) {
|
||||
JASAudioThread* sAudioThread = new (JASDram, 0) JASAudioThread(threadPriority, 0x10, 0x1400);
|
||||
sAudioThread->setCurrentHeap(JKRGetSystemHeap());
|
||||
sAudioThread->resume();
|
||||
#if PLATFORM_GCN
|
||||
const int size = 0x1400;
|
||||
#else
|
||||
const int size = 0x2800;
|
||||
#endif
|
||||
JASAudioThread* pAudioThread = new (JASDram, 0) JASAudioThread(threadPriority, 0x10, size);
|
||||
JUT_ASSERT(46, pAudioThread);
|
||||
JKRHeap* pCurrentHeap = JKRGetSystemHeap();
|
||||
JUT_ASSERT(48, pCurrentHeap);
|
||||
pAudioThread->setCurrentHeap(pCurrentHeap);
|
||||
pAudioThread->resume();
|
||||
}
|
||||
|
||||
void JASAudioThread::stop() {
|
||||
@@ -58,19 +68,27 @@ void* JASAudioThread::run() {
|
||||
JASPoolAllocObject_MultiThreaded<JASChannel>::newMemPool(0x48);
|
||||
JASDriver::startDMA();
|
||||
|
||||
OSMessage msg;
|
||||
while (true) {
|
||||
OSMessage msg = waitMessageBlock();
|
||||
switch ((int)msg) {
|
||||
msg = waitMessageBlock();
|
||||
switch ((intptr_t)msg) {
|
||||
case AUDIOMSG_DMA:
|
||||
if (sbPauseFlag) {
|
||||
JUT_PANIC(107, "AUDIO THREAD PAUSED\n");
|
||||
JASDriver::stopDMA();
|
||||
OSSleepThread(&sThreadQueue);
|
||||
}
|
||||
#if DEBUG
|
||||
if (snIntCount != 0) {
|
||||
JASReport("DSP process is over.");
|
||||
}
|
||||
#endif
|
||||
JASDriver::updateDac();
|
||||
JASDriver::updateDacCallback();
|
||||
break;
|
||||
continue;
|
||||
|
||||
case AUDIOMSG_DSP:
|
||||
JUT_ASSERT(125, snIntCount != 0);
|
||||
snIntCount--;
|
||||
if (snIntCount == 0) {
|
||||
JASProbe::stop(7);
|
||||
@@ -80,31 +98,41 @@ void* JASAudioThread::run() {
|
||||
JASDriver::updateDSP();
|
||||
JASProbe::stop(2);
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
|
||||
case AUDIOMSG_STOP:
|
||||
JASDriver::stopDMA();
|
||||
OSExitThread(NULL);
|
||||
break;
|
||||
continue;
|
||||
default:
|
||||
JUT_PANIC(152, "AUDIO THREAD INVALID MESSAGE\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASAudioThread::DMACallback() {
|
||||
JASAudioThread* thread = getInstance();
|
||||
JASAudioThread* pAudioThread = getInstance();
|
||||
JUT_ASSERT(167, pAudioThread);
|
||||
JASProbe::stop(4);
|
||||
JASProbe::start(4, "UPDATE-DAC");
|
||||
thread->sendMessage((void*)AUDIOMSG_DMA);
|
||||
if (!pAudioThread->sendMessage((void*)AUDIOMSG_DMA)) {
|
||||
JUT_WARN_DEVICE(173, 1, "%s","----- DMACallback : Can\'t send DAC_SYNC message\n");
|
||||
}
|
||||
}
|
||||
|
||||
void JASAudioThread::DSPCallback(void*) {
|
||||
JASAudioThread* thread = getInstance();
|
||||
JASAudioThread* pAudioThread = getInstance();
|
||||
JUT_ASSERT(184, pAudioThread);
|
||||
while (DSPCheckMailFromDSP() == 0) { }
|
||||
|
||||
u32 mail = DSPReadMailFromDSP();
|
||||
if (mail >> 0x10 == 0xF355) {
|
||||
if (mail >> 0x10 != 0xF355) {
|
||||
JUT_WARN(196, "DSP Mail format error %x\n", mail);
|
||||
} else {
|
||||
if ((mail & 0xFF00) == 0xFF00) {
|
||||
thread->sendMessage((void*)AUDIOMSG_DSP);
|
||||
if (!pAudioThread->sendMessage((void*)AUDIOMSG_DSP)) {
|
||||
JUT_WARN_DEVICE(204, 1, "%s", "----- syncDSP : Send Miss\n");
|
||||
}
|
||||
} else {
|
||||
JASDsp::finishWork(mail);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ JASBasicBank* JASBNKParser::createBasicBank(void const* stream, JKRHeap* heap) {
|
||||
|
||||
JASBNKParser::Ver1::TChunk* JASBNKParser::Ver1::findChunk(void const* stream, u32 id) {
|
||||
TFileHeader* header = (TFileHeader*)stream;
|
||||
void* end = (void*)((int)stream + header->mSize);
|
||||
TChunk* chunk = (TChunk*)((int)stream + 0x20);
|
||||
void* end = (void*)((intptr_t)stream + header->mSize);
|
||||
TChunk* chunk = (TChunk*)((intptr_t)stream + 0x20);
|
||||
while (chunk < end) {
|
||||
if (chunk->mID == id) {
|
||||
return chunk;
|
||||
}
|
||||
chunk = (TChunk*)(((int)chunk + 0xb + chunk->mSize) & ~3);
|
||||
chunk = (TChunk*)(((intptr_t)chunk + 0xb + chunk->mSize) & ~3);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -62,8 +62,11 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
||||
}
|
||||
|
||||
TEnvtChunk* envt_chunk = (TEnvtChunk*)findChunk(stream, 'ENVT');
|
||||
JUT_ASSERT(139, envt_chunk);
|
||||
TOscChunk* osc_chunk = (TOscChunk*)findChunk(stream, 'OSCT');
|
||||
JUT_ASSERT(142, osc_chunk);
|
||||
TListChunk* list_chunk = (TListChunk*)findChunk(stream, 'LIST');
|
||||
JUT_ASSERT(145, list_chunk);
|
||||
|
||||
u8* envt = new (heap, 2) u8[envt_chunk->mSize];
|
||||
JASCalc::bcopy(envt_chunk->mData, envt, envt_chunk->mSize);
|
||||
@@ -72,36 +75,40 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
||||
u32 count = *ptr++;
|
||||
JASOscillator::Data* osc_data = new (heap, 0) JASOscillator::Data[count];
|
||||
for (int i = 0; i < count; i++, ptr += sizeof(TOsc) >> 2) {
|
||||
TOsc* osc = (TOsc*)ptr;
|
||||
TOsc* op = (TOsc*)ptr;
|
||||
JUT_ASSERT(155, op->id == 'Osci');
|
||||
JASOscillator::Data* data = &osc_data[i];
|
||||
data->mTarget = osc->mTarget;
|
||||
data->_04 = osc->_08;
|
||||
data->mScale = osc->mScale;
|
||||
data->_14 = osc->_18;
|
||||
data->mTable = (JASOscillator::Point*)(envt + osc->mTableOffset);
|
||||
data->_0C = (JASOscillator::Point*)(envt + osc->_10);
|
||||
data->mTarget = op->mTarget;
|
||||
data->_04 = op->_08;
|
||||
data->mScale = op->mScale;
|
||||
data->_14 = op->_18;
|
||||
data->mTable = (JASOscillator::Point*)(envt + op->mTableOffset);
|
||||
data->rel_table = (JASOscillator::Point*)(envt + op->_10);
|
||||
}
|
||||
TListChunk* list = list_chunk;
|
||||
JUT_ASSERT(172, list->count <= JASBank::PRG_OSC);
|
||||
|
||||
bank->newInstTable(list_chunk->mCount, heap);
|
||||
for (int i = 0; i < list_chunk->mCount; i++) {
|
||||
bank->newInstTable(list_chunk->count, heap);
|
||||
for (int i = 0; i < list_chunk->count; i++) {
|
||||
if (list_chunk->mOffsets[i] != 0) {
|
||||
u32* data = (u32*)((int)stream + list_chunk->mOffsets[i]);
|
||||
u32* data = (u32*)((intptr_t)stream + list_chunk->mOffsets[i]);
|
||||
switch (*data++) {
|
||||
case 'Inst': {
|
||||
JASBasicInst* inst = new (heap, 0) JASBasicInst();
|
||||
JASBasicInst* instp = new (heap, 0) JASBasicInst();
|
||||
JUT_ASSERT(187, instp != NULL);
|
||||
u32 count = *data++;
|
||||
for (int j = 0; j < count; j++) {
|
||||
u32 index = *data++;
|
||||
inst->setOsc(j, &osc_data[index]);
|
||||
instp->setOsc(j, &osc_data[index]);
|
||||
}
|
||||
count = *data++;
|
||||
for (int j = 0; j < count; j++) {
|
||||
data++;
|
||||
}
|
||||
count = *data++;
|
||||
inst->setKeyRegionCount(count, heap);
|
||||
instp->setKeyRegionCount(count, heap);
|
||||
for (int j = 0; j < count; j++) {
|
||||
JASBasicInst::TKeymap* keymap = inst->getKeyRegion(j);
|
||||
JASBasicInst::TKeymap* keymap = instp->getKeyRegion(j);
|
||||
keymap->setHighKey(*data >> 0x18);
|
||||
u32 fVar4 = data[1];
|
||||
keymap->field_0x4 = JSULoHalf(data[3]);
|
||||
@@ -112,42 +119,51 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
|
||||
data += 4;
|
||||
}
|
||||
}
|
||||
inst->setVolume(*(f32*)&data[0]);
|
||||
inst->setPitch(*(f32*)&data[1]);
|
||||
bank->setInst(i, inst);
|
||||
instp->setVolume(*(f32*)&data[0]);
|
||||
instp->setPitch(*(f32*)&data[1]);
|
||||
bank->setInst(i, instp);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'Perc': {
|
||||
JASDrumSet* drum = new (heap, 0) JASDrumSet();
|
||||
JASDrumSet* drump = new (heap, 0) JASDrumSet();
|
||||
JUT_ASSERT(264, drump != NULL);
|
||||
u32 pmap_count = data[1];
|
||||
JUT_ASSERT(268, pmap_count <= 128);
|
||||
u32 count = *data++;
|
||||
drum->newPercArray(count, heap);
|
||||
drump->newPercArray(count, heap);
|
||||
for (int j = 0; j < count; j++) {
|
||||
u32 offset = *data++;
|
||||
if (offset != 0) {
|
||||
JASDrumSet::TPerc* perc = new (heap, 0) JASDrumSet::TPerc();
|
||||
u32* ptr = (u32*)((int)stream + offset);
|
||||
JASDrumSet::TPerc* percp = new (heap, 0) JASDrumSet::TPerc();
|
||||
JUT_ASSERT(277, percp);
|
||||
u32 type = data[0];
|
||||
JUT_ASSERT(282, type == 'Pmap');
|
||||
u32* ptr = (u32*)((intptr_t)stream + offset);
|
||||
TPercData* perc_data = (TPercData*)(ptr + 1);
|
||||
perc->setVolume(perc_data->mVolume);
|
||||
perc->setPitch(perc_data->mPitch);
|
||||
perc->setPan((f32)perc_data->mPan / 127.0f);
|
||||
perc->setRelease(perc_data->mRelease);
|
||||
percp->setVolume(perc_data->mVolume);
|
||||
percp->setPitch(perc_data->mPitch);
|
||||
percp->setPan((f32)perc_data->mPan / 127.0f);
|
||||
percp->setRelease(perc_data->mRelease);
|
||||
ptr = (u32*)&perc_data->field_0xc;
|
||||
u32 count2 = *ptr++;
|
||||
for (int k = 0; k < count2; k++) {
|
||||
ptr++;
|
||||
}
|
||||
u32 pVar6 = ptr[0];
|
||||
perc->field_0xe = JSULoHalf(ptr[2]);
|
||||
perc->field_0x10 = *(f32*)&ptr[3];
|
||||
perc->field_0x14 = *(f32*)&ptr[4];
|
||||
percp->field_0xe = JSULoHalf(ptr[2]);
|
||||
percp->field_0x10 = *(f32*)&ptr[3];
|
||||
percp->field_0x14 = *(f32*)&ptr[4];
|
||||
for (int k = 0; k < pVar6; k++) {}
|
||||
drum->setPerc(j, perc);
|
||||
drump->setPerc(j, percp);
|
||||
}
|
||||
}
|
||||
bank->setInst(i, drum);
|
||||
bank->setInst(i, drump);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
JUT_PANIC(338, "Unexpected Inst Type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,9 +224,9 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
|
||||
JASOscillator::Point* table = new (heap, 0) JASOscillator::Point[size];
|
||||
JUT_ASSERT(409, table != NULL);
|
||||
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
|
||||
osc->_0C = table;
|
||||
osc->rel_table = table;
|
||||
} else {
|
||||
osc->_0C = NULL;
|
||||
osc->rel_table = NULL;
|
||||
}
|
||||
|
||||
osc->mScale = tosc->mScale;
|
||||
@@ -270,9 +286,6 @@ JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* h
|
||||
return bank;
|
||||
}
|
||||
|
||||
/* 80299E68-80299F8C 2947A8 0124+00 1/1 0/0 0/0 .text
|
||||
* findOscPtr__Q212JASBNKParser4Ver0FP12JASBasicBankPCQ312JASBNKParser4Ver07THeaderPCQ312JASBNKParser4Ver04TOsc
|
||||
*/
|
||||
JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader const* header,
|
||||
TOsc const* osc) {
|
||||
TOffsetData const* data = &header->mOffsets;
|
||||
@@ -280,8 +293,7 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
|
||||
TInst* tinst = data->mInstOffset[i].ptr(header);
|
||||
if (tinst != NULL) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
TOsc* tosc = tinst->mOscOffset[j].ptr(header);
|
||||
if (tosc == osc) {
|
||||
if (tinst->mOscOffset[j].ptr(header) == osc) {
|
||||
JASInst* inst = bank->getInst(i);
|
||||
if (inst != NULL) {
|
||||
JASInstParam param;
|
||||
@@ -298,12 +310,15 @@ JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader
|
||||
}
|
||||
|
||||
JASOscillator::Point const* JASBNKParser::Ver0::getOscTableEndPtr(JASOscillator::Point const* points) {
|
||||
s16 tmp;
|
||||
do {
|
||||
tmp = points->_0;
|
||||
points++;
|
||||
} while (tmp <= 10);
|
||||
return points;
|
||||
const JASOscillator::Point* ptr = points;
|
||||
while(true) {
|
||||
s16 tmp = ptr->_0;
|
||||
ptr++;
|
||||
if (tmp > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
// Fakematch? Why is this here?
|
||||
|
||||
@@ -10,6 +10,7 @@ JASBasicBank::JASBasicBank() {
|
||||
|
||||
void JASBasicBank::newInstTable(u8 num, JKRHeap* heap) {
|
||||
if (num != 0) {
|
||||
JUT_ASSERT(31, num <= JASBank::PRG_OSC);
|
||||
mInstNumMax = num;
|
||||
mInstTable = new (heap, 0) JASInst*[mInstNumMax];
|
||||
JASCalc::bzero(mInstTable, mInstNumMax * 4);
|
||||
@@ -27,6 +28,9 @@ bool JASBasicBank::getInstParam(int prg_no, int param_1, int param_2,
|
||||
|
||||
void JASBasicBank::setInst(int prg_no, JASInst* inst) {
|
||||
if (mInstTable != NULL) {
|
||||
JUT_ASSERT(50, prg_no < mInstNumMax);
|
||||
JUT_ASSERT(54, prg_no >= 0);
|
||||
JUT_ASSERT(56, mInstTable[prg_no] == 0);
|
||||
mInstTable[prg_no] = inst;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ JASBasicInst::~JASBasicInst() {
|
||||
}
|
||||
|
||||
bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) const {
|
||||
UNUSED(param_1);
|
||||
param_2->field_0x1c = 0;
|
||||
param_2->field_0x1e = 0;
|
||||
param_2->field_0x14 = (JASOscillator::Data**)&field_0xc;
|
||||
@@ -42,26 +43,39 @@ bool JASBasicInst::getParam(int param_0, int param_1, JASInstParam* param_2) con
|
||||
|
||||
param_2->mVolume *= keyMap->field_0x8;
|
||||
param_2->mPitch *= keyMap->field_0xc;
|
||||
param_2->field_0x1a = keyMap->field_0x4;
|
||||
param_2->field_0x1a = u16(keyMap->field_0x4);
|
||||
return true;
|
||||
}
|
||||
|
||||
void JASBasicInst::setKeyRegionCount(u32 count, JKRHeap* param_1) {
|
||||
delete [] mKeymap;
|
||||
mKeymap = new (param_1, 0) TKeymap[count];
|
||||
mKeymap = new (param_1, 0) TKeymap[count];
|
||||
JUT_ASSERT(114, mKeymap != NULL);
|
||||
mKeymapCount = count;
|
||||
}
|
||||
|
||||
void JASBasicInst::setOsc(int param_0, JASOscillator::Data const* param_1) {
|
||||
field_0xc[param_0] = param_1;
|
||||
void JASBasicInst::setOsc(int index, JASOscillator::Data const* param_1) {
|
||||
JUT_ASSERT(128, index < OSC_MAX);
|
||||
JUT_ASSERT(129, index >= 0);
|
||||
field_0xc[index] = param_1;
|
||||
}
|
||||
|
||||
JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int param_0) {
|
||||
if (param_0 >= mKeymapCount) {
|
||||
JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) {
|
||||
JUT_ASSERT(146, index >= 0);
|
||||
if (index >= mKeymapCount) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mKeymap + param_0;
|
||||
return mKeymap + index;
|
||||
}
|
||||
|
||||
JASBasicInst::TKeymap* JASBasicInst::getKeyRegion(int index) const {
|
||||
JUT_ASSERT(155, index >= 0);
|
||||
if (index >= mKeymapCount) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mKeymap + index;
|
||||
}
|
||||
|
||||
JASBasicInst::TKeymap::~TKeymap() {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "JSystem/JAudio2/JASMutex.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include <stdint>
|
||||
|
||||
JASBasicWaveBank::JASBasicWaveBank() {
|
||||
mWaveTable = NULL;
|
||||
@@ -130,5 +131,5 @@ int JASBasicWaveBank::TWaveHandle::getWavePtr() const {
|
||||
if (base == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (int)base + field_0x4.field_0x08;
|
||||
return (intptr_t)base + field_0x4.field_0x08;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASCalc.h"
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <math>
|
||||
#include <limits>
|
||||
|
||||
void JASCalc::imixcopy(const s16* s1, const s16* s2, s16* dst, u32 n) {
|
||||
for (n; n != 0; n--) {
|
||||
*dst++ = *((s16*)s1)++;
|
||||
*dst++ = *((s16*)s2)++;
|
||||
*dst++ = *(s1)++;
|
||||
*dst++ = *(s2)++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ void JASCalc::bcopyfast(const void* src, void* dest, u32 size) {
|
||||
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)++;
|
||||
copy1 = *(usrc)++;
|
||||
copy2 = *(usrc)++;
|
||||
copy3 = *(usrc)++;
|
||||
copy4 = *(usrc)++;
|
||||
|
||||
*udest++ = copy1;
|
||||
*udest++ = copy2;
|
||||
@@ -263,6 +263,9 @@ s16 const JASCalc::CUTOFF_TO_IIR_TABLE[128][4] = {
|
||||
0x7FFF, 0x0000, 0x0000, 0x0000,
|
||||
};
|
||||
|
||||
template <>
|
||||
s16 JASCalc::clamp(s32);
|
||||
|
||||
// currently required because of missing functions
|
||||
// JASCalc::hannWindow(short *, u32)
|
||||
// JASCalc::hammWindow(short *, u32)
|
||||
@@ -319,7 +322,7 @@ f32 JASCalc::pow2(f32 x) {
|
||||
|
||||
template <>
|
||||
s16 JASCalc::clamp(s32 x) {
|
||||
if (std::numeric_limits<s16>::min() >= x)
|
||||
if (x <= std::numeric_limits<s16>::min())
|
||||
return std::numeric_limits<s16>::min();
|
||||
if (x >= std::numeric_limits<s16>::max())
|
||||
return std::numeric_limits<s16>::max();
|
||||
|
||||
@@ -31,9 +31,12 @@ int JASCallbackMgr::reject(JASCallback* callback, void* argument) {
|
||||
|
||||
void JASCallbackMgr::callback() {
|
||||
for (int i = 0; i < NUM_CALLBACKS; i++) {
|
||||
if (callbacks_[i].callback_ && callbacks_[i].callback_(callbacks_[i].arg_) < 0) {
|
||||
callbacks_[i].callback_ = NULL;
|
||||
callbacks_[i].arg_ = NULL;
|
||||
if (callbacks_[i].callback_) {
|
||||
s32 result = callbacks_[i].callback_(callbacks_[i].arg_);
|
||||
if (result < 0) {
|
||||
callbacks_[i].callback_ = NULL;
|
||||
callbacks_[i].arg_ = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ OSMessage JASChannel::sBankDisposeList[16];
|
||||
int JASChannel::sBankDisposeListSize;
|
||||
|
||||
JASChannel::JASChannel(Callback i_callback, void* i_callbackData) :
|
||||
mStatus(STATUS_INACTIVE),
|
||||
mStatus(STATUS_STOP),
|
||||
mDspCh(NULL),
|
||||
mCallback(i_callback),
|
||||
mCallbackData(i_callbackData),
|
||||
@@ -45,6 +45,7 @@ JASChannel::JASChannel(Callback i_callback, void* i_callbackData) :
|
||||
|
||||
JASChannel::~JASChannel() {
|
||||
if (mDspCh != NULL) {
|
||||
JUT_WARN(62, "%s","~JASChannel:: mDspCh != NULL");
|
||||
mDspCh->drop();
|
||||
}
|
||||
if (mCallback != NULL) {
|
||||
@@ -61,7 +62,7 @@ int JASChannel::play() {
|
||||
}
|
||||
mDspCh = channel;
|
||||
channel->start();
|
||||
mStatus = STATUS_ACTIVE;
|
||||
mStatus = STATUS_PLAY;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -74,12 +75,12 @@ int JASChannel::playForce() {
|
||||
}
|
||||
mDspCh = channel;
|
||||
channel->start();
|
||||
mStatus = STATUS_ACTIVE;
|
||||
mStatus = STATUS_PLAY;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void JASChannel::release(u16 i_directRelease) {
|
||||
if (mStatus == STATUS_ACTIVE) {
|
||||
if (mStatus == STATUS_PLAY) {
|
||||
if (i_directRelease != 0) {
|
||||
setDirectRelease(i_directRelease);
|
||||
}
|
||||
@@ -88,17 +89,20 @@ void JASChannel::release(u16 i_directRelease) {
|
||||
mOscillators[i].release();
|
||||
}
|
||||
}
|
||||
JUT_ASSERT(135, mDspCh);
|
||||
mDspCh->setPriority(JSUHiByte(mPriority));
|
||||
mStatus = STATUS_RELEASE;
|
||||
}
|
||||
}
|
||||
|
||||
void JASChannel::setOscInit(u32 i_index, JASOscillator::Data const* i_data) {
|
||||
mOscillators[i_index].initStart(i_data);
|
||||
void JASChannel::setOscInit(u32 oscnum, JASOscillator::Data const* i_data) {
|
||||
JUT_ASSERT(147, oscnum < OSC_NUM);
|
||||
mOscillators[oscnum].initStart(i_data);
|
||||
}
|
||||
|
||||
void JASChannel::setMixConfig(u32 i_index, u16 i_config) {
|
||||
mMixConfig[i_index].whole = i_config;
|
||||
void JASChannel::setMixConfig(u32 bus, u16 i_config) {
|
||||
JUT_ASSERT(153, bus < BUSOUT_CPUCH);
|
||||
mMixConfig[bus].whole = i_config;
|
||||
}
|
||||
|
||||
f32 JASChannel::calcEffect(JASChannel::PanVector const* i_vector) {
|
||||
@@ -110,9 +114,10 @@ f32 JASChannel::calcPan(JASChannel::PanVector const* i_vector) {
|
||||
+ (i_vector->mChannel - 0.5f);
|
||||
}
|
||||
|
||||
void JASChannel::effectOsc(u32 i_index, JASOscillator::EffectParams* i_params) {
|
||||
f32 value = mOscillators[i_index].getValue();
|
||||
switch (mOscillators[i_index].getTarget()) {
|
||||
void JASChannel::effectOsc(u32 oscnum, JASOscillator::EffectParams* i_params) {
|
||||
JUT_ASSERT(176, oscnum < OSC_NUM);
|
||||
f32 value = mOscillators[oscnum].getValue();
|
||||
switch (mOscillators[oscnum].getTarget()) {
|
||||
case JASOscillator::TARGET_PITCH:
|
||||
i_params->mPitch *= value;
|
||||
break;
|
||||
@@ -135,6 +140,8 @@ void JASChannel::effectOsc(u32 i_index, JASOscillator::EffectParams* i_params) {
|
||||
case JASOscillator::TARGET_6:
|
||||
i_params->_18 *= value;
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(205, "%s", "Invalid osc target");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +214,8 @@ s32 JASChannel::dspUpdateCallback(u32 i_type, JASDsp::TChannel* i_channel, void*
|
||||
_this->mDspCh = NULL;
|
||||
delete _this;
|
||||
return -1;
|
||||
default:
|
||||
JUT_WARN(323, "Unexpected JASDSPChannel::UpdateStatus %d", i_type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -221,6 +230,7 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
}
|
||||
|
||||
if (field_0xdc.field_0x4.field_0x20[0] == 0) {
|
||||
JUT_WARN_DEVICE(346, 2, "%s", "Lost wave data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
@@ -228,6 +238,7 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
}
|
||||
|
||||
if (checkBankDispose()) {
|
||||
JUT_WARN_DEVICE(357, 2, "%s","Lost bank data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
@@ -290,11 +301,14 @@ s32 JASChannel::initialUpdateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
}
|
||||
|
||||
s32 JASChannel::updateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
JUT_ASSERT(444, mStatus == STATUS_PLAY || mStatus == STATUS_RELEASE);
|
||||
JUT_ASSERT(445, mDspCh);
|
||||
if (mCallback != NULL) {
|
||||
mCallback(CB_PLAY, this, i_channel, mCallbackData);
|
||||
}
|
||||
|
||||
if (field_0xdc.field_0x4.field_0x20[0] == 0) {
|
||||
JUT_WARN_DEVICE(456, 2, "%s","Lost wave data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
@@ -302,6 +316,7 @@ s32 JASChannel::updateDSPChannel(JASDsp::TChannel* i_channel) {
|
||||
}
|
||||
|
||||
if (checkBankDispose()) {
|
||||
JUT_WARN_DEVICE(467, 2, "%s", "Lost bank data while playing");
|
||||
mDspCh->free();
|
||||
mDspCh = NULL;
|
||||
delete this;
|
||||
@@ -368,9 +383,13 @@ void JASChannel::updateAutoMixer(JASDsp::TChannel* i_channel, f32 param_1, f32 p
|
||||
if (JASDriver::getOutputMode() == 0) {
|
||||
param_1 *= 0.707f;
|
||||
}
|
||||
f32 fvar1 = JASCalc::clamp01(param_1);
|
||||
i_channel->setAutoMixer(fvar1 * JASDriver::getChannelLevel_dsp(), param_2 * 127.5f,
|
||||
param_4 * 127.5f, param_3 * 127.5f, 0);
|
||||
param_1 = JASCalc::clamp01(param_1);
|
||||
|
||||
u16 r31 = param_1 * JASDriver::getChannelLevel_dsp();
|
||||
u8 r30 = param_2 * 127.5f;
|
||||
u8 r29 = param_4 * 127.5f;
|
||||
u8 r28 = param_3 * 127.5f;
|
||||
i_channel->setAutoMixer(r31, r30, r29, r28, 0);
|
||||
}
|
||||
|
||||
void JASChannel::updateMixer(f32 i_volume, f32 i_pan, f32 i_fxmix, f32 i_dolby, u16* i_volumeOut) {
|
||||
@@ -461,12 +480,14 @@ void JASChannel::updateMixer(f32 i_volume, f32 i_pan, f32 i_fxmix, f32 i_dolby,
|
||||
}
|
||||
}
|
||||
|
||||
i_volumeOut[i] = JASCalc::clamp01(volume) * JASDriver::getChannelLevel_dsp();
|
||||
volume = JASCalc::clamp01(volume);
|
||||
i_volumeOut[i] = volume * JASDriver::getChannelLevel_dsp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASChannel::free() {
|
||||
JUT_ASSERT(661, mStatus == STATUS_RELEASE || mStatus == STATUS_STOP);
|
||||
mCallback = NULL;
|
||||
mCallbackData = NULL;
|
||||
}
|
||||
|
||||
@@ -5,32 +5,48 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASCmdStack.h"
|
||||
#include "JSystem/JAudio2/JASCriticalSection.h"
|
||||
#include "dolphin/os.h"
|
||||
|
||||
JASPortCmd::TPortHead JASPortCmd::sCommandListOnce;
|
||||
|
||||
JASPortCmd::TPortHead JASPortCmd::sCommandListStay;
|
||||
|
||||
bool JASPortCmd::addPortCmdOnce() {
|
||||
JASCriticalSection cs;
|
||||
return sCommandListOnce.append(this);
|
||||
}
|
||||
|
||||
bool JASPortCmd::setPortCmd(Command func, JASPortArgs* args) {
|
||||
JUT_ASSERT(81, func != NULL);
|
||||
if (getSupervisor()) {
|
||||
return false;
|
||||
}
|
||||
mFunc = func;
|
||||
mArgs = args;
|
||||
return true;
|
||||
}
|
||||
|
||||
void JASPortCmd::execAllCommand() {
|
||||
sCommandListOnce.execCommandOnce();
|
||||
sCommandListStay.execCommandStay();
|
||||
}
|
||||
|
||||
void JASPortCmd::TPortHead::execCommandOnce() {
|
||||
volatile BOOL interrupts = OSDisableInterrupts();
|
||||
JASCriticalSection cs;
|
||||
JSULink<JASPortCmd>* next;
|
||||
for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = next) {
|
||||
next = link->getNext();
|
||||
link->getObject()->_10(link->getObject()->_14);
|
||||
JASPortCmd* cmd = link->getObject();
|
||||
cmd->getFunc()(cmd->getArgs());
|
||||
remove(link);
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
void JASPortCmd::TPortHead::execCommandStay() {
|
||||
volatile int interrupts = OSDisableInterrupts();
|
||||
JASCriticalSection cs;
|
||||
for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = link->getNext()) {
|
||||
link->getObject()->_10(link->getObject()->_14);
|
||||
JASPortCmd* cmd = link->getObject();
|
||||
cmd->getFunc()(cmd->getArgs());
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ void JASDSPChannel::drop() {
|
||||
|
||||
void JASDSPChannel::initAll() {
|
||||
sDspChannels = new (JASDram, 0x20) JASDSPChannel[0x40];
|
||||
JUT_ASSERT(102, sDspChannels);
|
||||
for (int i = 0; i < 0x40; i++) {
|
||||
sDspChannels[i].mChannel = JASDsp::getDSPHandle(i);
|
||||
}
|
||||
@@ -87,7 +88,7 @@ JASDSPChannel* JASDSPChannel::getLowestChannel(int i_priority) {
|
||||
JASDSPChannel* channel = &sDspChannels[i];
|
||||
s16 priority = channel->mPriority;
|
||||
if (priority < 0) {
|
||||
return channel;
|
||||
return &sDspChannels[i];
|
||||
}
|
||||
if (priority <= i_priority && priority <= best_priority) {
|
||||
if (priority != best_priority || channel->field_0xc > best_unknown) {
|
||||
@@ -127,7 +128,8 @@ JASDSPChannel* JASDSPChannel::getLowestActiveChannel() {
|
||||
}
|
||||
|
||||
void JASDSPChannel::updateProc() {
|
||||
int ret;
|
||||
int ret = 0;
|
||||
bool flush;
|
||||
if (mChannel->isFinish()) {
|
||||
mFlags &= ~2;
|
||||
if (mStatus == STATUS_ACTIVE) {
|
||||
@@ -173,7 +175,7 @@ void JASDSPChannel::updateProc() {
|
||||
mChannel->flush();
|
||||
}
|
||||
} else if (mStatus != STATUS_INACTIVE) {
|
||||
bool flush = false;
|
||||
flush = false;
|
||||
if (mCallback != NULL) {
|
||||
ret = mCallback(CB_PLAY, mChannel, mCallbackData);
|
||||
flush = true;
|
||||
@@ -225,3 +227,33 @@ int JASDSPChannel::killActiveChannel() {
|
||||
JASDSPChannel* JASDSPChannel::getHandle(u32 i_index) {
|
||||
return &sDspChannels[i_index];
|
||||
}
|
||||
|
||||
u32 JASDSPChannel::getNumUse() {
|
||||
u32 count = 0;
|
||||
for (int i = 0; i < 0x40; i++) {
|
||||
if (sDspChannels[i].mStatus == 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 JASDSPChannel::getNumFree() {
|
||||
u32 count = 0;
|
||||
for (int i = 0; i < 0x40; i++) {
|
||||
if (sDspChannels[i].mStatus == 1) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 JASDSPChannel::getNumBreak() {
|
||||
u32 count = 0;
|
||||
for (int i = 0; i < 0x40; i++) {
|
||||
if (sDspChannels[i].mStatus == 2) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,34 @@ JASDsp::FxBuf* JASDsp::FX_BUF;
|
||||
|
||||
f32 JASDsp::sDSPVolume;
|
||||
|
||||
u16 JASDsp::SEND_TABLE[] = {
|
||||
0x0D00,
|
||||
0x0D60,
|
||||
0x0DC8,
|
||||
0x0E28,
|
||||
0x0E88,
|
||||
0x0EE8,
|
||||
0x0CA0,
|
||||
0x0F40,
|
||||
0x0FA0,
|
||||
0x0B00,
|
||||
0x09A0,
|
||||
0x0000,
|
||||
};
|
||||
|
||||
u32 JASWaveInfo::one = 1;
|
||||
|
||||
#if DEBUG
|
||||
s32 JASDsp::dspMutex = 1;
|
||||
#endif
|
||||
|
||||
void JASDsp::boot(void (*param_0)(void*)) {
|
||||
static bool data_804512F4 = true;
|
||||
if (data_804512F4) {
|
||||
DspBoot(param_0);
|
||||
#if !PLATFORM_GCN
|
||||
// DsetVARAM(JKRHeap::getAltAramStartAdr());
|
||||
#endif
|
||||
data_804512F4 = false;
|
||||
}
|
||||
}
|
||||
@@ -40,6 +64,7 @@ void JASDsp::syncFrame(u32 param_0, u32 param_1, u32 param_2) {
|
||||
void JASDsp::setDSPMixerLevel(f32 dsp_level) {
|
||||
sDSPVolume = dsp_level;
|
||||
dsp_level *= 4.0f;
|
||||
JUT_ASSERT(277, (0.0 <= dsp_level) && (dsp_level <= 8.0));
|
||||
DsetMixerLevel(dsp_level);
|
||||
}
|
||||
|
||||
@@ -51,6 +76,10 @@ JASDsp::TChannel* JASDsp::getDSPHandle(int param_0) {
|
||||
return CH_BUF + param_0;
|
||||
}
|
||||
|
||||
JASDsp::TChannel* JASDsp::getDSPHandleNc(int param_0) {
|
||||
return (TChannel*)OSCachedToUncached(CH_BUF + param_0);
|
||||
}
|
||||
|
||||
void JASDsp::setFilterTable(s16* param_0, s16* param_1, u32 param_2) {
|
||||
for (int i = 0; i < param_2; i++) {
|
||||
*param_0++ = *param_1++;
|
||||
@@ -398,7 +427,9 @@ u32 const ATTRIBUTE_ALIGN(32) JASDsp::DSPRES_FILTER[320] = {
|
||||
|
||||
void JASDsp::initBuffer() {
|
||||
CH_BUF = new(JASDram, 0x20) TChannel[64];
|
||||
JUT_ASSERT(354, CH_BUF);
|
||||
FX_BUF = new(JASDram, 0x20) FxBuf[4];
|
||||
JUT_ASSERT(356, FX_BUF);
|
||||
JASCalc::bzero(CH_BUF, 0x6000);
|
||||
JASCalc::bzero(FX_BUF, sizeof(FxBuf) * 4);
|
||||
for (u8 i = 0; i < 4; i++) {
|
||||
@@ -408,22 +439,7 @@ void JASDsp::initBuffer() {
|
||||
flushBuffer();
|
||||
}
|
||||
|
||||
u16 JASDsp::SEND_TABLE[] = {
|
||||
0x0D00,
|
||||
0x0D60,
|
||||
0x0DC8,
|
||||
0x0E28,
|
||||
0x0E88,
|
||||
0x0EE8,
|
||||
0x0CA0,
|
||||
0x0F40,
|
||||
0x0FA0,
|
||||
0x0B00,
|
||||
0x09A0,
|
||||
0x0000,
|
||||
};
|
||||
|
||||
int JASDsp::setFXLine(u8 param_0, s16* param_1, JASDsp::FxlineConfig_* param_2) {
|
||||
int JASDsp::setFXLine(u8 param_0, s16* buffer, JASDsp::FxlineConfig_* param_2) {
|
||||
FxBuf* puVar3 = FX_BUF + param_0;
|
||||
JASCriticalSection aJStack_20;
|
||||
puVar3->field_0x0 = 0;
|
||||
@@ -433,15 +449,17 @@ int JASDsp::setFXLine(u8 param_0, s16* param_1, JASDsp::FxlineConfig_* param_2)
|
||||
puVar3->field_0xe = param_2->field_0x8;
|
||||
puVar3->field_0xc = SEND_TABLE[param_2->field_0x6];
|
||||
puVar3->field_0x2 = param_2->field_0xc;
|
||||
setFilterTable(puVar3->field_0x10, param_2->field_0x10, 8);
|
||||
setFilterTable((s16*)puVar3->field_0x10, param_2->field_0x10, 8);
|
||||
}
|
||||
if (param_1 != NULL && param_2 != NULL) {
|
||||
u32 iVar1 = param_2->field_0xc * 0xa0;
|
||||
puVar3->field_0x4 = param_1;
|
||||
JASCalc::bzero(param_1, iVar1);
|
||||
DCFlushRange(param_1, iVar1);
|
||||
} else if (param_2 == NULL || param_1 != NULL) {
|
||||
puVar3->field_0x4 = param_1;
|
||||
if (buffer != NULL && param_2 != NULL) {
|
||||
u32 bufsize = param_2->field_0xc * 0xa0;
|
||||
puVar3->field_0x4 = buffer;
|
||||
JASCalc::bzero(buffer, bufsize);
|
||||
JUT_ASSERT(420, (reinterpret_cast<u32>(buffer) & 0x1f) == 0);
|
||||
JUT_ASSERT(421, (bufsize & 0x1f) == 0);
|
||||
DCFlushRange(buffer, bufsize);
|
||||
} else if (param_2 == NULL || buffer != NULL) {
|
||||
puVar3->field_0x4 = buffer;
|
||||
}
|
||||
|
||||
if (puVar3->field_0x4 != NULL) {
|
||||
@@ -453,7 +471,31 @@ int JASDsp::setFXLine(u8 param_0, s16* param_1, JASDsp::FxlineConfig_* param_2)
|
||||
return 1;
|
||||
}
|
||||
|
||||
BOOL JASDsp::changeFXLineParam(u8 param_0, u8 param_1, u32 param_2) {
|
||||
JUT_ASSERT(450, dspMutex);
|
||||
FxBuf* buf = &FX_BUF[param_0];
|
||||
switch (param_1) {
|
||||
case 0: buf->field_0x8 = param_2; break;
|
||||
case 1: buf->field_0xc = param_2; break;
|
||||
case 2: buf->field_0xa = param_2; break;
|
||||
case 3: buf->field_0xe = param_2; break;
|
||||
case 4: buf->field_0x2 = param_2; break;
|
||||
case 5: buf->field_0x10[0] = param_2; break;
|
||||
case 6: buf->field_0x10[1] = param_2; break;
|
||||
case 7: buf->field_0x10[2] = param_2; break;
|
||||
case 8: buf->field_0x10[3] = param_2; break;
|
||||
case 9: buf->field_0x10[4] = param_2; break;
|
||||
case 10: buf->field_0x10[5] = param_2; break;
|
||||
case 11: buf->field_0x10[6] = param_2; break;
|
||||
case 12: buf->field_0x10[7] = param_2; break;
|
||||
case 13: setFilterTable((s16*)buf->field_0x10, (s16*)param_2, 8); break;
|
||||
case 14: buf->field_0x0 = param_2; break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::init() {
|
||||
JUT_ASSERT(489, dspMutex);
|
||||
mPauseFlag = 0;
|
||||
mIsFinished = 0;
|
||||
mForcedStop = 0;
|
||||
@@ -464,6 +506,7 @@ void JASDsp::TChannel::init() {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::playStart() {
|
||||
JUT_ASSERT(508, dspMutex);
|
||||
field_0x10c = 0;
|
||||
field_0x060 = 0;
|
||||
field_0x008 = 1;
|
||||
@@ -480,27 +523,34 @@ void JASDsp::TChannel::playStart() {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::playStop() {
|
||||
JUT_ASSERT(540, dspMutex);
|
||||
mIsActive = 0;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::replyFinishRequest() {
|
||||
JUT_ASSERT(549, dspMutex);
|
||||
mIsFinished = 0;
|
||||
mIsActive = 0;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::forceStop() {
|
||||
JUT_ASSERT(559, dspMutex);
|
||||
mForcedStop = 1;
|
||||
}
|
||||
|
||||
bool JASDsp::TChannel::isActive() const {
|
||||
JUT_ASSERT(568, dspMutex);
|
||||
return mIsActive != 0;
|
||||
}
|
||||
|
||||
bool JASDsp::TChannel::isFinish() const {
|
||||
JUT_ASSERT(577, dspMutex);
|
||||
return mIsFinished != 0;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setWaveInfo(JASWaveInfo const& param_0, u32 param_1, u32 param_2) {
|
||||
int i;
|
||||
JUT_ASSERT(610, dspMutex);
|
||||
field_0x118 = param_1;
|
||||
static const u8 COMP_BLOCKSAMPLES[8] = {0x10, 0x10, 0x01, 0x01, 0x01, 0x10, 0x10, 0x01};
|
||||
field_0x064 = COMP_BLOCKSAMPLES[param_0.field_0x00];
|
||||
@@ -536,19 +586,21 @@ void JASDsp::TChannel::setWaveInfo(JASWaveInfo const& param_0, u32 param_1, u32
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
field_0x0b0[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setOscInfo(u32 param_0) {
|
||||
JUT_ASSERT(671, dspMutex);
|
||||
field_0x118 = 0;
|
||||
field_0x064 = 16;
|
||||
field_0x100 = param_0;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::initAutoMixer() {
|
||||
JUT_ASSERT(688, dspMutex);
|
||||
if (field_0x058) {
|
||||
field_0x054 = field_0x056;
|
||||
} else {
|
||||
@@ -559,6 +611,7 @@ void JASDsp::TChannel::initAutoMixer() {
|
||||
|
||||
void JASDsp::TChannel::setAutoMixer(u16 param_0, u8 param_1, u8 param_2, u8 param_3,
|
||||
u8 param_4) {
|
||||
JUT_ASSERT(709, dspMutex);
|
||||
field_0x050 = (param_1 << 8) | param_2;
|
||||
field_0x052 = param_3 << 8 | param_3 << 1;
|
||||
field_0x056 = param_0;
|
||||
@@ -566,6 +619,7 @@ void JASDsp::TChannel::setAutoMixer(u16 param_0, u8 param_1, u8 param_2, u8 para
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setPitch(u16 param_0) {
|
||||
JUT_ASSERT(763, dspMutex);
|
||||
if (param_0 >= 0x7fff) {
|
||||
param_0 = 0x7fff;
|
||||
}
|
||||
@@ -573,6 +627,7 @@ void JASDsp::TChannel::setPitch(u16 param_0) {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setMixerInitVolume(u8 param_0, s16 param_1) {
|
||||
JUT_ASSERT(798, dspMutex);
|
||||
u16* tmp = field_0x010[param_0];
|
||||
tmp[2] = param_1;
|
||||
tmp[1] = param_1;
|
||||
@@ -580,14 +635,17 @@ void JASDsp::TChannel::setMixerInitVolume(u8 param_0, s16 param_1) {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setMixerVolume(u8 param_0, s16 param_1) {
|
||||
u16* tmp;
|
||||
JUT_ASSERT(841, dspMutex);
|
||||
if (mForcedStop == 0) {
|
||||
u16* tmp = field_0x010[param_0];
|
||||
tmp = field_0x010[param_0];
|
||||
tmp[1] = param_1;
|
||||
tmp[3] &= 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setPauseFlag(u8 param_0) {
|
||||
JUT_ASSERT(863, dspMutex);
|
||||
mPauseFlag = param_0;
|
||||
}
|
||||
|
||||
@@ -596,7 +654,8 @@ void JASDsp::TChannel::flush() {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::initFilter() {
|
||||
int i;
|
||||
u32 i;
|
||||
JUT_ASSERT(888, dspMutex);
|
||||
for (i = 0; i < 8; i++) {
|
||||
fir_filter_params[i] = 0;
|
||||
}
|
||||
@@ -609,6 +668,7 @@ void JASDsp::TChannel::initFilter() {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setFilterMode(u16 param_0) {
|
||||
JUT_ASSERT(914, dspMutex);
|
||||
u8 r30 = param_0 & 0x20;
|
||||
u8 r31 = param_0 & 0x1f;
|
||||
if (r30) {
|
||||
@@ -624,24 +684,30 @@ void JASDsp::TChannel::setFilterMode(u16 param_0) {
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setIIRFilterParam(s16* param_0) {
|
||||
JUT_ASSERT(937, dspMutex);
|
||||
setFilterTable(iir_filter_params, param_0, 8);
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setFIR8FilterParam(s16* param_0) {
|
||||
JUT_ASSERT(948, dspMutex);
|
||||
setFilterTable(fir_filter_params, param_0, 8);
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setDistFilter(s16 param_0) {
|
||||
JUT_ASSERT(959, dspMutex);
|
||||
iir_filter_params[4] = param_0;
|
||||
}
|
||||
|
||||
void JASDsp::TChannel::setBusConnect(u8 param_0, u8 param_1) {
|
||||
JUT_ASSERT(973, dspMutex);
|
||||
u16* tmp = field_0x010[param_0];
|
||||
static u16 const connect_table[12] = {
|
||||
0x0000, 0x0D00, 0x0D60, 0x0DC0, 0x0E20, 0x0E80,
|
||||
0x0EE0, 0x0CA0, 0x0F40, 0x0FA0, 0x0B00, 0x09A0,
|
||||
};
|
||||
tmp[0] = connect_table[param_1];
|
||||
u16 r30 = 0;
|
||||
r30 = connect_table[param_1];
|
||||
tmp[0] = r30;
|
||||
}
|
||||
|
||||
u16 DSP_CreateMap2(u32 param_0) {
|
||||
@@ -656,9 +722,3 @@ u16 DSP_CreateMap2(u32 param_0) {
|
||||
}
|
||||
return r30;
|
||||
}
|
||||
|
||||
u32 JASWaveInfo::one = 1;
|
||||
|
||||
#if DEBUG
|
||||
s32 dspMutex = 1;
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,10 @@ u16 JASDriver::getChannelLevel_dsp() {
|
||||
return JASDriver::MAX_MIXERLEVEL;
|
||||
}
|
||||
|
||||
f32 JASDriver::getChannelLevel() {
|
||||
return MAX_MIXERLEVEL / 16383.5f;
|
||||
}
|
||||
|
||||
f32 JASDriver::getDSPLevel() {
|
||||
return JASDsp::getDSPMixerLevel();
|
||||
}
|
||||
|
||||
@@ -6,37 +6,35 @@
|
||||
|
||||
|
||||
JASDrumSet::JASDrumSet() {
|
||||
field_0x4 = NULL;
|
||||
field_0x8 = 0;
|
||||
mPercArray = NULL;
|
||||
mPercNumMax = 0;
|
||||
}
|
||||
|
||||
JASDrumSet::~JASDrumSet() {
|
||||
}
|
||||
|
||||
void JASDrumSet::newPercArray(u8 param_0, JKRHeap* param_1) {
|
||||
if (param_0) {
|
||||
field_0x8 = param_0;
|
||||
field_0x4 = new (param_1, 0) TPerc*[field_0x8];
|
||||
JASCalc::bzero(field_0x4, field_0x8 * sizeof(TPerc*));
|
||||
void JASDrumSet::newPercArray(u8 num, JKRHeap* heap) {
|
||||
if (num) {
|
||||
JUT_ASSERT(39, num <= 128);
|
||||
mPercNumMax = num;
|
||||
mPercArray = new (heap, 0) TPerc*[mPercNumMax];
|
||||
JASCalc::bzero(mPercArray, mPercNumMax * sizeof(TPerc*));
|
||||
}
|
||||
}
|
||||
|
||||
static JASOscillator::Data osc;
|
||||
|
||||
static JASOscillator::Data* oscp;
|
||||
|
||||
static s8 data_80451274[4];
|
||||
|
||||
bool JASDrumSet::getParam(int param_0, int param_1, JASInstParam* param_2) const {
|
||||
if (field_0x4 == NULL) {
|
||||
bool JASDrumSet::getParam(int key, int param_1, JASInstParam* param_2) const {
|
||||
UNUSED(param_1);
|
||||
JUT_ASSERT(48, key >= 0);
|
||||
if (mPercArray == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param_0 >= field_0x8) {
|
||||
if (key >= mPercNumMax) {
|
||||
JUT_WARN(54, "JASDrumSet: key %d >= PERC_MAX %d\n", key, mPercNumMax);
|
||||
return false;
|
||||
}
|
||||
|
||||
TPerc* perc = field_0x4[param_0];
|
||||
TPerc* perc = mPercArray[key];
|
||||
if (perc == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -46,31 +44,60 @@ bool JASDrumSet::getParam(int param_0, int param_1, JASInstParam* param_2) const
|
||||
param_2->mVolume = perc->mVolume;
|
||||
param_2->mPitch = perc->mPitch;
|
||||
param_2->mPan = perc->mPan;
|
||||
param_2->field_0x18 = perc->field_0xc;
|
||||
param_2->field_0x18 = u16(perc->field_0xc);
|
||||
|
||||
static JASOscillator::Data osc;
|
||||
|
||||
osc.mTarget = 0;
|
||||
osc._04 = 1.0f;
|
||||
osc.mTable = NULL;
|
||||
osc._0C = NULL;
|
||||
osc.rel_table = NULL;
|
||||
osc.mScale = 1.0f;
|
||||
osc._14 = 0.0f;
|
||||
|
||||
if (data_80451274[0] == 0) {
|
||||
oscp = &osc;
|
||||
data_80451274[0] = 1;
|
||||
}
|
||||
static JASOscillator::Data* oscp = &osc;
|
||||
|
||||
param_2->field_0x14 = &oscp;
|
||||
param_2->field_0x1d = 1;
|
||||
param_2->mVolume *= perc->field_0x10;
|
||||
param_2->mPitch *= perc->field_0x14;
|
||||
param_2->field_0x1a = perc->field_0xe;
|
||||
param_2->field_0x1a = u16(perc->field_0xe);
|
||||
return true;
|
||||
}
|
||||
|
||||
void JASDrumSet::setPerc(int param_0, JASDrumSet::TPerc* param_1) {
|
||||
field_0x4[param_0] = param_1;
|
||||
void JASDrumSet::setPerc(int index, JASDrumSet::TPerc* param_1) {
|
||||
JUT_ASSERT(123, index >= 0);
|
||||
JUT_ASSERT(125, index < mPercNumMax);
|
||||
JUT_ASSERT(126, mPercArray);
|
||||
JUT_ASSERT(127, mPercArray[index] == 0);
|
||||
mPercArray[index] = param_1;
|
||||
}
|
||||
|
||||
JASDrumSet::TPerc* JASDrumSet::getPerc(int index) {
|
||||
if (index < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (index >= mPercNumMax) {
|
||||
return NULL;
|
||||
}
|
||||
if (!mPercArray) {
|
||||
return NULL;
|
||||
}
|
||||
return mPercArray[index];
|
||||
}
|
||||
|
||||
JASDrumSet::TPerc* JASDrumSet::getPerc(int index) const {
|
||||
if (index < 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (index >= mPercNumMax) {
|
||||
return NULL;
|
||||
}
|
||||
if (!mPercArray) {
|
||||
return NULL;
|
||||
}
|
||||
return mPercArray[index];
|
||||
}
|
||||
|
||||
JASDrumSet::TPerc::TPerc() {
|
||||
mVolume = 1.0f;
|
||||
@@ -79,8 +106,9 @@ JASDrumSet::TPerc::TPerc() {
|
||||
field_0xc = 1000;
|
||||
}
|
||||
|
||||
void JASDrumSet::TPerc::setRelease(u32 param_0) {
|
||||
field_0xc = param_0;
|
||||
void JASDrumSet::TPerc::setRelease(u32 release) {
|
||||
JUT_ASSERT(224, release < 0x10000);
|
||||
field_0xc = release;
|
||||
}
|
||||
|
||||
u32 JASDrumSet::getType() const { return 'PERC'; }
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "JSystem/JKernel/JKRExpHeap.h"
|
||||
#include "JSystem/JKernel/JKRSolidHeap.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "dolphin/ar.h"
|
||||
|
||||
JASHeap::JASHeap(JASDisposer* disposer) : mTree(this) {
|
||||
mDisposer = disposer;
|
||||
@@ -45,7 +46,8 @@ bool JASHeap::alloc(JASHeap* mother, u32 param_1) {
|
||||
bool local_43 = false;
|
||||
JASHeap* local_30 = NULL;
|
||||
void* local_34;
|
||||
for (JSUTreeIterator<JASHeap> it = mother->mTree.getFirstChild(); it != mother->mTree.getEndChild(); it++) {
|
||||
JSUTreeIterator<JASHeap> it;
|
||||
for (it = mother->mTree.getFirstChild(); it != mother->mTree.getEndChild(); it++) {
|
||||
if (r29 >= mother->mBase + local_2c) {
|
||||
break;
|
||||
}
|
||||
@@ -77,8 +79,10 @@ bool JASHeap::alloc(JASHeap* mother, u32 param_1) {
|
||||
}
|
||||
|
||||
bool JASHeap::allocTail(JASHeap* mother, u32 size) {
|
||||
JUT_ASSERT(208, mother != NULL);
|
||||
JASMutexLock lock(&mMutex);
|
||||
if (isAllocated()) {
|
||||
OS_REPORT("[JASHeap::alloc] すでにヒープは確保されています。初期化してからにしてください。\n");
|
||||
return false;
|
||||
}
|
||||
if (!mother->isAllocated()) {
|
||||
@@ -128,6 +132,39 @@ bool JASHeap::free() {
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 JASHeap::getTotalFreeSize() const {
|
||||
JASMutexLock lock(const_cast<OSMutex*>(&mMutex));
|
||||
u8* r28 = mBase;
|
||||
u32 r29 = 0;
|
||||
for (JSUTreeIterator<JASHeap> it = mTree.getFirstChild(); it != mTree.getEndChild(); it++) {
|
||||
r29 += it->mBase - r28;
|
||||
u32 r26 = it->mSize;
|
||||
r28 = it->mBase + r26;
|
||||
}
|
||||
r29 += mBase + mSize - r28;
|
||||
return r29;
|
||||
}
|
||||
|
||||
u32 JASHeap::getFreeSize() const {
|
||||
JASMutexLock lock(const_cast<OSMutex*>(&mMutex));
|
||||
u8* r27 = mBase;
|
||||
u32 r29 = 0;
|
||||
u32 r28;
|
||||
for (JSUTreeIterator<JASHeap> it = mTree.getFirstChild(); it != mTree.getEndChild(); it++) {
|
||||
r28 = it->mBase - r27;
|
||||
if (r28 > r29) {
|
||||
r29 = r28;
|
||||
}
|
||||
u32 r25 = it->mSize;
|
||||
r27 = it->mBase + r25;
|
||||
}
|
||||
r28 = mBase + mSize - r27;
|
||||
if (r28 > r29) {
|
||||
r29 = r28;
|
||||
}
|
||||
return r29;
|
||||
}
|
||||
|
||||
void JASHeap::insertChild(JASHeap* heap, JASHeap* next, void* param_2, u32 param_3, bool param_4) {
|
||||
JUT_ASSERT(513, heap != NULL);
|
||||
JUT_ASSERT(514, next == NULL || &mTree == next->mTree.getParent());
|
||||
@@ -151,6 +188,7 @@ void JASHeap::insertChild(JASHeap* heap, JASHeap* next, void* param_2, u32 param
|
||||
}
|
||||
|
||||
JASHeap* JASHeap::getTailHeap() {
|
||||
int r30 = 0;
|
||||
JSUTreeIterator<JASHeap> it;
|
||||
JASMutexLock lock(&mMutex);
|
||||
if (!field_0x40) {
|
||||
@@ -165,15 +203,25 @@ JASHeap* JASHeap::getTailHeap() {
|
||||
}
|
||||
|
||||
u32 JASHeap::getTailOffset() {
|
||||
u32 offset = 0;
|
||||
JASMutexLock lock(&mMutex);
|
||||
JASHeap* heap = getTailHeap();
|
||||
u32 offset = !heap ? mSize : heap->mBase - mBase;
|
||||
if (heap == NULL) {
|
||||
offset = mSize;
|
||||
} else {
|
||||
offset = heap->mBase - mBase;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
u32 JASHeap::getCurOffset() {
|
||||
u32 offset = 0;
|
||||
JASMutexLock lock(&mMutex);
|
||||
u32 offset = !field_0x40 ? 0 : field_0x40->mBase + field_0x40->mSize - mBase;
|
||||
if (field_0x40 == NULL) {
|
||||
offset = 0;
|
||||
} else {
|
||||
offset = field_0x40->mBase + field_0x40->mSize - mBase;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
@@ -214,10 +262,10 @@ void JASGenericMemPool::newMemPool(u32 n, int param_1) {
|
||||
}
|
||||
|
||||
void* JASGenericMemPool::alloc(u32 param_0) {
|
||||
void* chunk = field_0x0;
|
||||
if (chunk == NULL) {
|
||||
if (field_0x0 == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
void* chunk = field_0x0;
|
||||
field_0x0 = *(void**)chunk;
|
||||
freeMemCount--;
|
||||
if (usedMemCount < totalMemCount - freeMemCount) {
|
||||
@@ -227,11 +275,13 @@ void* JASGenericMemPool::alloc(u32 param_0) {
|
||||
}
|
||||
|
||||
void JASGenericMemPool::free(void* ptr, u32 param_1) {
|
||||
if (ptr != NULL) {
|
||||
*(void**)ptr = field_0x0;
|
||||
field_0x0 = ptr;
|
||||
freeMemCount++;
|
||||
if (!ptr) {
|
||||
return;
|
||||
}
|
||||
void* chunk = ptr;
|
||||
*(void**)chunk = field_0x0;
|
||||
field_0x0 = chunk;
|
||||
freeMemCount++;
|
||||
}
|
||||
|
||||
u32 JASKernel::sAramBase;
|
||||
@@ -260,6 +310,10 @@ JASMemChunkPool<1024, JASThreadingModel::ObjectLevelLockable>* JASKernel::getCom
|
||||
JASHeap JASKernel::audioAramHeap;
|
||||
|
||||
void JASKernel::setupAramHeap(u32 param_0, u32 param_1) {
|
||||
#if !PLATFORM_GCN
|
||||
OSReport("setupAramHeap %x, %x, %x\n", param_0, ARGetBaseAddress(), param_1);
|
||||
param_0 = ARGetBaseAddress();
|
||||
#endif
|
||||
sAramBase = param_0;
|
||||
audioAramHeap.initRootHeap((void*)sAramBase, param_1);
|
||||
}
|
||||
@@ -267,3 +321,11 @@ void JASKernel::setupAramHeap(u32 param_0, u32 param_1) {
|
||||
JASHeap* JASKernel::getAramHeap() {
|
||||
return &audioAramHeap;
|
||||
}
|
||||
|
||||
u32 JASKernel::getAramFreeSize() {
|
||||
return audioAramHeap.getFreeSize();
|
||||
}
|
||||
|
||||
u32 JASKernel::getAramSize() {
|
||||
return audioAramHeap.getSize();
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ JASOscillator::JASOscillator() {
|
||||
mDirectRelease = 0;
|
||||
_18 = 0;
|
||||
_1C = 0;
|
||||
_0C = 0.0f;
|
||||
_10 = 0.0f;
|
||||
_08 = 0.0f;
|
||||
_04 = 0.0f;
|
||||
_04 = _08 = _10 = _0C = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,11 +49,12 @@ void JASOscillator::incCounter(f32 param_0) {
|
||||
}
|
||||
|
||||
f32 JASOscillator::getValue() const {
|
||||
JUT_ASSERT(120, mData);
|
||||
return _08 * mData->mScale + mData->_14;
|
||||
}
|
||||
|
||||
void JASOscillator::release() {
|
||||
if (mData->_0C == NULL && mDirectRelease == 0) {
|
||||
if (mData->rel_table == NULL && mDirectRelease == 0) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
@@ -71,13 +69,14 @@ void JASOscillator::release() {
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mData->mTable != mData->_0C) {
|
||||
|
||||
if (mData->mTable != mData->rel_table) {
|
||||
JUT_ASSERT(157, mData->rel_table != NULL);
|
||||
_04 = 0.0f;
|
||||
_0C = _08;
|
||||
_10 = mData->_0C[0]._4 / 32768.0f;
|
||||
_10 = mData->rel_table[0]._4 / 32768.0f;
|
||||
_14 = 0;
|
||||
_18 = mData->_0C[0]._0;
|
||||
_18 = mData->rel_table[0]._0;
|
||||
}
|
||||
|
||||
_1C = 3;
|
||||
@@ -86,7 +85,7 @@ void JASOscillator::release() {
|
||||
|
||||
void JASOscillator::update() {
|
||||
if (_1C == 4) {
|
||||
s16 x = mDirectRelease & 0x3FFF;
|
||||
s32 x = mDirectRelease & 0x3FFF;
|
||||
if (_04 < x) {
|
||||
updateCurrentValue(x);
|
||||
} else {
|
||||
@@ -98,25 +97,21 @@ void JASOscillator::update() {
|
||||
|
||||
if (_1C == 2) return;
|
||||
|
||||
const Point* psVar1;
|
||||
if (_1C == 1) {
|
||||
psVar1 = mData->mTable;
|
||||
} else {
|
||||
psVar1 = mData->_0C;
|
||||
}
|
||||
const Point* psVar1 = _1C == 1 ? mData->mTable : mData->rel_table;
|
||||
|
||||
if (psVar1 == NULL) {
|
||||
_1C = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
while (_04 >= psVar1[_14]._2) {
|
||||
_04 -= psVar1[_14]._2;
|
||||
_08 = _10;
|
||||
_14++;
|
||||
_0C = _08;
|
||||
const s16* ps = &psVar1[_14]._0;
|
||||
switch(ps[0]) {
|
||||
s16 r26 = ps[0];
|
||||
switch(r26) {
|
||||
case 0xf:
|
||||
_1C = 0;
|
||||
return;
|
||||
@@ -127,7 +122,7 @@ void JASOscillator::update() {
|
||||
_14 = ps[2];
|
||||
break;
|
||||
default:
|
||||
_18 = ps[0];
|
||||
_18 = r26;
|
||||
_10 = ps[2] / 32768.0f;
|
||||
break;
|
||||
}
|
||||
@@ -172,7 +167,6 @@ void JASOscillator::updateCurrentValue(f32 param_0) {
|
||||
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];
|
||||
f32 fVar4 = (1.0f - fVar3) * table[index] + fVar3 * table[index + 1];
|
||||
_08 = _0C * fVar4 + _10 * (1.0f - fVar4);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASProbe.h"
|
||||
#include "dolphin/os.h"
|
||||
#include "JSystem/JAudio2/JASCriticalSection.h"
|
||||
|
||||
void JASProbe::start(char const* name) {
|
||||
volatile BOOL interrupts = OSDisableInterrupts();
|
||||
mName = name;
|
||||
mStartTime = OSGetTime();
|
||||
OSRestoreInterrupts(interrupts);
|
||||
JASCriticalSection cs;
|
||||
mName = name;
|
||||
mStartTime = OSGetTime();
|
||||
}
|
||||
|
||||
|
||||
void JASProbe::stop() {
|
||||
volatile int interrupts = OSDisableInterrupts();
|
||||
_08 = (u32)OSGetTime() - mStartTime;
|
||||
JASCriticalSection cs;
|
||||
u32 r29 = OSGetTime();
|
||||
_08 = r29 - mStartTime;
|
||||
_08 /= OS_TIMER_CLOCK / 59.94f;
|
||||
if (_10 < _08 && 100 < _1A8) {
|
||||
_10 = _08;
|
||||
@@ -24,23 +24,26 @@ void JASProbe::stop() {
|
||||
_18[resultIndex] = _08;
|
||||
_14 += _08;
|
||||
_1A8++;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
JASProbe* JASProbe::sProbeTable[16];
|
||||
|
||||
void JASProbe::start(s32 index, char const* name) {
|
||||
JASProbe* probe;
|
||||
if (index < 16) {
|
||||
if (sProbeTable[index] != NULL) {
|
||||
sProbeTable[index]->start(name);
|
||||
probe = sProbeTable[index];
|
||||
if (probe != NULL) {
|
||||
probe->start(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASProbe::stop(s32 index) {
|
||||
JASProbe* probe;
|
||||
if (index < 16) {
|
||||
if (sProbeTable[index] != NULL) {
|
||||
sProbeTable[index]->stop();
|
||||
probe = sProbeTable[index];
|
||||
if (probe != NULL) {
|
||||
probe->stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASRegisterParam.h"
|
||||
#include "JSystem/JSupport/JSupport.h"
|
||||
|
||||
JASRegisterParam::JASRegisterParam() {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
@@ -19,53 +20,55 @@ void JASRegisterParam::write(JASRegisterParam::RegID param_0, u32 param_1) {
|
||||
if (param_0 < 14) {
|
||||
if (param_0 <= 2) {
|
||||
field_0x0[param_0] = (u8)param_1;
|
||||
return;
|
||||
} else {
|
||||
field_0x0[param_0] = param_1;
|
||||
}
|
||||
|
||||
field_0x0[param_0] = param_1;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (param_0) {
|
||||
case 32:
|
||||
field_0x0[0] = (param_1 >> 8) & 0xff;
|
||||
field_0x0[1] = param_1 & 0xff;
|
||||
field_0x0[0] = JSUHiByte(param_1);
|
||||
field_0x0[1] = JSULoByte(param_1);
|
||||
break;
|
||||
case 33:
|
||||
field_0x0[4] = param_1 >> 16;
|
||||
field_0x0[5] = param_1;
|
||||
field_0x0[4] = JSUHiHalf(param_1);
|
||||
field_0x0[5] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 34:
|
||||
field_0x0[4] &= 0xff;
|
||||
field_0x0[4] |= ((param_1 & 0xff) << 8);
|
||||
field_0x0[4] = u8(field_0x0[4]);
|
||||
field_0x0[4] |= u16((param_1 & 0xff) << 8);
|
||||
break;
|
||||
case 35:
|
||||
field_0x0[4] &= 0xff00;
|
||||
field_0x0[4] |= param_1 & 0xff;
|
||||
field_0x0[4] |= u8(param_1);
|
||||
break;
|
||||
case 36:
|
||||
field_0x0[5] &= 0xff;
|
||||
field_0x0[5] |= (param_1 & 0xff) << 8;
|
||||
field_0x0[5] = u8(field_0x0[5]);
|
||||
field_0x0[5] |= u16((param_1 & 0xff) << 8);
|
||||
break;
|
||||
case 37:
|
||||
field_0x0[5] &= 0xff00;
|
||||
field_0x0[5] |= param_1 & 0xff;
|
||||
field_0x0[5] |= u8(param_1);
|
||||
break;
|
||||
case 38:
|
||||
field_0x0[6] = param_1 >> 16;
|
||||
field_0x0[7] = param_1;
|
||||
field_0x0[6] = JSUHiHalf(param_1);
|
||||
field_0x0[7] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 39:
|
||||
field_0x0[8] = param_1 >> 16;
|
||||
field_0x0[9] = param_1;
|
||||
field_0x0[8] = JSUHiHalf(param_1);
|
||||
field_0x0[9] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 40:
|
||||
field_0x0[10] = param_1 >> 16;
|
||||
field_0x0[11] = param_1;
|
||||
field_0x0[10] = JSUHiHalf(param_1);
|
||||
field_0x0[11] = JSULoHalf(param_1);
|
||||
break;
|
||||
case 41:
|
||||
field_0x0[12] = param_1 >> 16;
|
||||
field_0x0[13] = param_1;
|
||||
field_0x0[12] = JSUHiHalf(param_1);
|
||||
field_0x0[13] = JSULoHalf(param_1);
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(92, "%s", "Warning: Unsupported REG id");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -86,16 +89,16 @@ u32 JASRegisterParam::read(JASRegisterParam::RegID param_0) {
|
||||
rv |= field_0x0[5];
|
||||
break;
|
||||
case 34:
|
||||
rv = (u8)(field_0x0[4] >> 8);
|
||||
rv = JSUHiByte(field_0x0[4]);
|
||||
break;
|
||||
case 35:
|
||||
rv = (u8)field_0x0[4];
|
||||
rv = JSULoByte(field_0x0[4]);
|
||||
break;
|
||||
case 36:
|
||||
rv = (u8)(field_0x0[5] >> 8);
|
||||
rv = JSUHiByte(field_0x0[5]);
|
||||
break;
|
||||
case 37:
|
||||
rv = (u8)field_0x0[5];
|
||||
rv = JSULoByte(field_0x0[5]);
|
||||
break;
|
||||
case 38:
|
||||
rv = field_0x0[6];
|
||||
@@ -118,6 +121,9 @@ u32 JASRegisterParam::read(JASRegisterParam::RegID param_0) {
|
||||
rv <<= 16;
|
||||
rv |= field_0x0[11];
|
||||
break;
|
||||
default:
|
||||
JUT_WARN(160, "%s", "Warning: Unsupported REG id");
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASReport.h"
|
||||
#include "JSystem/JAudio2/JASCalc.h"
|
||||
#include "JSystem/JAudio2/JASMutex.h"
|
||||
#include "stdio.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <stdio>
|
||||
|
||||
static OSMutex sMutex;
|
||||
|
||||
@@ -18,19 +20,58 @@ static int sLineCount;
|
||||
|
||||
static int sTop;
|
||||
|
||||
void JASReport(const char * str, ...) {
|
||||
if(sBuffer) {
|
||||
va_list vl;
|
||||
va_start(vl, str);
|
||||
JASMutexLock mutexLock(&sMutex);
|
||||
vsnprintf(sBuffer + (sTop * 64), 64, str, vl);
|
||||
va_end(vl);
|
||||
|
||||
sTop++;
|
||||
if (sTop >= sLineMax)
|
||||
sTop = 0;
|
||||
|
||||
if (sLineCount < sLineMax)
|
||||
sLineCount++;
|
||||
}
|
||||
void JASReportInit(JKRHeap* heap, int lineMax) {
|
||||
JUT_ASSERT(33, sBuffer == NULL);
|
||||
JUT_ASSERT(35, heap != NULL);
|
||||
OSInitMutex(&sMutex);
|
||||
sLineMax = lineMax;
|
||||
sBuffer = new (heap, 0) char[sLineMax * 64];
|
||||
JUT_ASSERT(41, sBuffer);
|
||||
}
|
||||
|
||||
int JASReportGetLineMax() {
|
||||
return sLineMax;
|
||||
}
|
||||
|
||||
int JASReportCopyBuffer(char *param_1,int lines) {
|
||||
if (!sBuffer) {
|
||||
return 0;
|
||||
}
|
||||
if (lines < 0) {
|
||||
lines = sLineMax;
|
||||
}
|
||||
char* dest = param_1;
|
||||
JASMutexLock lock(&sMutex);
|
||||
int i;
|
||||
int r30 = sTop - 1;
|
||||
char* src;
|
||||
for (i = 0; i < sLineCount && i < lines; i++) {
|
||||
if (r30 < 0) {
|
||||
r30 = sLineMax - 1;
|
||||
}
|
||||
src = &sBuffer[r30 * 64];
|
||||
JASCalc::bcopy(src, dest, 64);
|
||||
r30--;
|
||||
dest += 64;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
void JASReport(const char * str, ...) {
|
||||
va_list vl;
|
||||
if(!sBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(vl, str);
|
||||
JASMutexLock mutexLock(&sMutex);
|
||||
vsnprintf(sBuffer + (sTop * 64), 64, str, vl);
|
||||
va_end(vl);
|
||||
|
||||
sTop++;
|
||||
if (sTop >= sLineMax)
|
||||
sTop = 0;
|
||||
|
||||
if (sLineCount < sLineMax)
|
||||
sLineCount++;
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ size_t JASResArcLoader::getResSize(JKRArchive const* i_archiveP, u16 i_resourceI
|
||||
size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) {
|
||||
u32 maxSize, index;
|
||||
u32 fileEntries = i_archiveP->countFile();
|
||||
|
||||
for (maxSize = 0, index = 0; index < fileEntries; index++) {
|
||||
maxSize = 0;
|
||||
for (index = 0; index < fileEntries; index++) {
|
||||
JKRArchive::SDIFileEntry* file = i_archiveP->findIdxResource(index);
|
||||
if (file) {
|
||||
if (maxSize < file->data_size) {
|
||||
@@ -37,7 +37,7 @@ size_t JASResArcLoader::getResMaxSize(JKRArchive const* i_archiveP) {
|
||||
}
|
||||
|
||||
static void JASResArcLoader::loadResourceCallback(void* args) {
|
||||
CallbackArgs* castedArgs = static_cast<CallbackArgs*>(args);
|
||||
TLoadResInfo* castedArgs = static_cast<TLoadResInfo*>(args);
|
||||
u32 readResult = castedArgs->mArchive->readResource(castedArgs->mBuffer, castedArgs->mBufferSize, castedArgs->mID);
|
||||
if (castedArgs->mCallback) {
|
||||
castedArgs->mCallback(readResult, castedArgs->mCallbackArg);
|
||||
@@ -47,19 +47,23 @@ static void JASResArcLoader::loadResourceCallback(void* args) {
|
||||
if (castedArgs->mQueue) {
|
||||
OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Error, OS_MESSAGE_BLOCK);
|
||||
}
|
||||
} else {
|
||||
if (castedArgs->mQueue) {
|
||||
OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Success, OS_MESSAGE_BLOCK);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (castedArgs->mQueue) {
|
||||
OSSendMessage(castedArgs->mQueue, (void*)RESARCMSG_Success, OS_MESSAGE_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int JASResArcLoader::loadResourceAsync(JKRArchive* archive, u16 id, u8* buffer, u32 size, LoadCallback callback, u32 cbArg)
|
||||
{
|
||||
CallbackArgs args(id, buffer, size, archive);
|
||||
TLoadResInfo args(archive, id, buffer, size);
|
||||
args.mCallback = callback;
|
||||
args.mCallbackArg = cbArg;
|
||||
|
||||
return JASDvd::getThreadPointer()->sendCmdMsg(&loadResourceCallback, (void*)&args, sizeof(CallbackArgs));
|
||||
int r31 = JASDvd::getThreadPointer()->sendCmdMsg(&loadResourceCallback, (void*)&args, sizeof(TLoadResInfo));
|
||||
if (!r31) {
|
||||
JUT_WARN(160, "%s", "sendCmdMsg loadResourceCallback Failed");
|
||||
}
|
||||
return r31;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
JASSeqParser JASSeqCtrl::sDefaultParser;
|
||||
|
||||
JASSeqCtrl::JASSeqCtrl() {
|
||||
mReader.init();
|
||||
field_0x3c = &sDefaultParser;
|
||||
field_0x40 = 0;
|
||||
field_0x44 = NULL;
|
||||
@@ -96,27 +95,35 @@ int JASSeqCtrl::retIntr() {
|
||||
}
|
||||
|
||||
int JASSeqCtrl::findIntr() {
|
||||
u32 uVar1 = field_0x4e & field_0x4c;
|
||||
for (int i = 0; uVar1 != 0; uVar1 >>= 1, i++) {
|
||||
u32 uVar1 = field_0x4e;
|
||||
uVar1 &= field_0x4c;
|
||||
int i;
|
||||
for (i = 0; uVar1 != 0; i++) {
|
||||
if (uVar1 & 1) {
|
||||
field_0x4c &= ~(1 << i);
|
||||
return i;
|
||||
}
|
||||
uVar1 >>= 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void JASSeqCtrl::checkIntr() {
|
||||
if (field_0x44) return;
|
||||
if (field_0x44) {
|
||||
return;
|
||||
}
|
||||
int intr = findIntr();
|
||||
|
||||
if (intr < 0) return;
|
||||
if (intr < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
u32 uVar2 = field_0x48;
|
||||
uVar2 += intr * 3;
|
||||
u32 uVar1 = get24(uVar2);
|
||||
u32 vec = field_0x48;
|
||||
JUT_ASSERT(144, vec != 0);
|
||||
vec += intr * 3;
|
||||
vec = get24(vec);
|
||||
field_0x44 = mReader.getCur();
|
||||
mReader.jump(uVar1);
|
||||
mReader.jump(vec);
|
||||
}
|
||||
|
||||
void JASSeqCtrl::timerProcess() {
|
||||
|
||||
@@ -999,7 +999,8 @@ s32 JASSeqParser::parseRegCommand(JASTrack* param_0, int param_1) {
|
||||
r30 <<= 1;
|
||||
r28 <<= 2;
|
||||
}
|
||||
return parseCommand(param_0, seqCtrl->readByte(), r29);
|
||||
u8 r25 = seqCtrl->readByte();
|
||||
return parseCommand(param_0, r25, r29);
|
||||
}
|
||||
|
||||
s32 JASSeqParser::parse(JASTrack* param_0) {
|
||||
|
||||
@@ -32,6 +32,7 @@ void JASSeqReader::init(void* param_0) {
|
||||
|
||||
bool JASSeqReader::call(u32 param_0) {
|
||||
if (field_0x08 >= 8) {
|
||||
JUT_WARN(42, "%s", "Cannot exec call command");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,6 +44,7 @@ bool JASSeqReader::call(u32 param_0) {
|
||||
|
||||
bool JASSeqReader::loopStart(u32 param_0) {
|
||||
if (8 <= field_0x08) {
|
||||
JUT_WARN(53, "%s", "Cannot exec loopStart command");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -55,6 +57,7 @@ bool JASSeqReader::loopStart(u32 param_0) {
|
||||
|
||||
bool JASSeqReader::loopEnd() {
|
||||
if (field_0x08 == 0) {
|
||||
JUT_WARN(65, "%s", "cannot loopE for call-stack is NULL");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,6 +100,7 @@ int JASSeqReader::readMidiValue() {
|
||||
|
||||
while (true) {
|
||||
if (2 < i) {
|
||||
JUT_WARN(100, "%s", "readMidiValue: Too large value");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JAudio2/JASSimpleWaveBank.h"
|
||||
#include <stdint>
|
||||
|
||||
JASSimpleWaveBank::JASSimpleWaveBank() {
|
||||
mWaveTable = NULL;
|
||||
@@ -14,6 +15,7 @@ JASSimpleWaveBank::~JASSimpleWaveBank() {
|
||||
void JASSimpleWaveBank::setWaveTableSize(u32 size, JKRHeap* heap) {
|
||||
delete[] mWaveTable;
|
||||
mWaveTable = new (heap, 0) TWaveHandle[size];
|
||||
JUT_ASSERT(29, mWaveTable != NULL);
|
||||
mWaveTableSize = size;
|
||||
}
|
||||
|
||||
@@ -42,7 +44,7 @@ int JASSimpleWaveBank::TWaveHandle::getWavePtr() const {
|
||||
if (base == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (int)base + mWaveInfo.field_0x08;
|
||||
return (intptr_t)base + mWaveInfo.field_0x08;
|
||||
}
|
||||
|
||||
JASSimpleWaveBank::TWaveHandle::TWaveHandle() {
|
||||
|
||||
@@ -21,18 +21,22 @@ JASTrack::TList JASTrack::sTrackList;
|
||||
|
||||
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
|
||||
JASTrack::~JASTrack() {
|
||||
JUT_ASSERT(70, mStatus != STATUS_RUN);
|
||||
for (int i = 1; i < 4; i++) {
|
||||
delete mChannelMgrs[i];
|
||||
}
|
||||
}
|
||||
|
||||
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
|
||||
void JASTrack::setChannelMgrCount(u32 i_count) {
|
||||
void JASTrack::setChannelMgrCount(u32 count) {
|
||||
JUT_ASSERT(79, mStatus != STATUS_RUN);
|
||||
JUT_ASSERT(80, count >= 1 && count <= CHANNEL_MGR_MAX);
|
||||
mChannelMgrCount = 1;
|
||||
for (int i = 1; i < i_count; i++) {
|
||||
for (int i = 1; i < count; i++) {
|
||||
if (mChannelMgrs[i] == NULL) {
|
||||
mChannelMgrs[i] = new TChannelMgr(this);
|
||||
if (mChannelMgrs[i] == NULL) {
|
||||
JUT_WARN(87, "%s", "Not enough JASTrackChannelMgr\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -59,6 +63,7 @@ JASOscillator::Data const JASTrack::sPitchEnvOsc = {1, 1.0f, NULL, NULL, 1.0f, 0
|
||||
|
||||
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
|
||||
void JASTrack::init() {
|
||||
JUT_ASSERT(104, mStatus == STATUS_FREE || mStatus == STATUS_STOPPED);
|
||||
mSeqCtrl.init();
|
||||
mTrackPort.init();
|
||||
initTimed();
|
||||
@@ -126,7 +131,7 @@ void JASTrack::init() {
|
||||
mFlags.autoDelete = false;
|
||||
mFlags.flag4 = false;
|
||||
mFlags.flag6 = false;
|
||||
mStatus = 0;
|
||||
mStatus = STATUS_FREE;
|
||||
}
|
||||
|
||||
void JASTrack::initTimed() {
|
||||
@@ -161,18 +166,22 @@ void JASTrack::inherit(JASTrack const& i_parent) {
|
||||
}
|
||||
}
|
||||
|
||||
void JASTrack::assignExtBuffer(u32 i_index, JASSoundParams* i_soundParams) {
|
||||
mChannelMgrs[i_index]->mSoundParams = i_soundParams;
|
||||
void JASTrack::assignExtBuffer(u32 index, JASSoundParams* i_soundParams) {
|
||||
JUT_ASSERT(249, index < mChannelMgrCount);
|
||||
mChannelMgrs[index]->mSoundParams = i_soundParams;
|
||||
}
|
||||
|
||||
void JASTrack::setSeqData(void* param_0, u32 param_1) {
|
||||
JUT_ASSERT(257, mStatus == STATUS_FREE);
|
||||
mSeqCtrl.start(param_0, param_1);
|
||||
}
|
||||
|
||||
void JASTrack::startSeq() {
|
||||
JUT_ASSERT(265, mParent == 0);
|
||||
JUT_ASSERT(266, mStatus == STATUS_FREE);
|
||||
JASCriticalSection critical_section;
|
||||
sTrackList.append(this);
|
||||
mStatus = 1;
|
||||
mStatus = STATUS_RUN;
|
||||
}
|
||||
|
||||
void JASTrack::stopSeq() {
|
||||
@@ -181,7 +190,9 @@ void JASTrack::stopSeq() {
|
||||
}
|
||||
|
||||
void JASTrack::start() {
|
||||
mStatus = 1;
|
||||
JUT_ASSERT(289, mParent != NULL);
|
||||
JUT_ASSERT(290, mStatus == STATUS_FREE);
|
||||
mStatus = STATUS_RUN;
|
||||
}
|
||||
|
||||
void JASTrack::close() {
|
||||
@@ -201,66 +212,77 @@ void JASTrack::close() {
|
||||
}
|
||||
}
|
||||
mParent = NULL;
|
||||
mStatus = 2;
|
||||
mStatus = STATUS_STOPPED;
|
||||
}
|
||||
|
||||
bool JASTrack::connectChild(u32 i_index, JASTrack* i_child) {
|
||||
if (mChildren[i_index] != NULL) {
|
||||
bool JASTrack::connectChild(u32 track_no, JASTrack* i_child) {
|
||||
JUT_ASSERT(326, track_no < MAX_CHILDREN);
|
||||
if (mChildren[track_no] != NULL) {
|
||||
return false;
|
||||
}
|
||||
i_child->mParent = this;
|
||||
mChildren[i_index] = i_child;
|
||||
mChildren[track_no] = i_child;
|
||||
return true;
|
||||
}
|
||||
|
||||
void JASTrack::closeChild(u32 i_index) {
|
||||
JASTrack* child = mChildren[i_index];
|
||||
void JASTrack::closeChild(u32 track_no) {
|
||||
JUT_ASSERT(340, track_no < MAX_CHILDREN);
|
||||
JASTrack* child = mChildren[track_no];
|
||||
if (child != NULL) {
|
||||
getRootTrack()->updateSeq(false, 1.0f);
|
||||
child->close();
|
||||
if (child->mFlags.autoDelete) {
|
||||
delete child;
|
||||
mChildren[i_index] = NULL;
|
||||
mChildren[track_no] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NONMATCHING JASPoolAllocObject_MultiThreaded<_> locations
|
||||
JASTrack* JASTrack::openChild(u32 i_index) {
|
||||
JASTrack* child = mChildren[i_index];
|
||||
JASTrack* JASTrack::openChild(u32 trk_no) {
|
||||
JUT_ASSERT(358, trk_no < MAX_CHILDREN);
|
||||
JASTrack* child = mChildren[trk_no];
|
||||
if (child != NULL) {
|
||||
switch (child->mStatus) {
|
||||
case 0:
|
||||
case STATUS_FREE:
|
||||
break;
|
||||
case 1:
|
||||
case STATUS_RUN:
|
||||
getRootTrack()->updateSeq(false, 1.0f);
|
||||
child->close();
|
||||
// no break
|
||||
case 2:
|
||||
case STATUS_STOPPED:
|
||||
bool auto_delete = child->mFlags.autoDelete;
|
||||
child->init();
|
||||
child->mFlags.autoDelete = auto_delete;
|
||||
mChildren[i_index] = NULL;
|
||||
connectChild(i_index, child);
|
||||
mChildren[trk_no] = NULL;
|
||||
connectChild(trk_no, child);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
child = new JASTrack();
|
||||
if (child == NULL) {
|
||||
JUT_WARN(388, "%s", "Not enough JASTrack\n");
|
||||
return NULL;
|
||||
}
|
||||
child->mFlags.autoDelete = true;
|
||||
connectChild(i_index, child);
|
||||
connectChild(trk_no, child);
|
||||
}
|
||||
child->setChannelMgrCount(mChannelMgrCount);
|
||||
child->inherit(*this);
|
||||
return child;
|
||||
}
|
||||
|
||||
void JASTrack::connectBus(int param_0, int param_1) {
|
||||
mMixConfig[param_0] = param_1;
|
||||
void JASTrack::connectBus(int line, int param_1) {
|
||||
JUT_ASSERT(404, line < JASChannel::BUSOUT_CPUCH);
|
||||
mMixConfig[line] = param_1;
|
||||
}
|
||||
|
||||
f32 JASTrack::getVolume() const { return mMoveParam.params.volume.mValue; }
|
||||
f32 JASTrack::getPitch() const { return mMoveParam.params.pitch.mValue; }
|
||||
f32 JASTrack::getPan() const { return mMoveParam.params.pan.mValue; }
|
||||
f32 JASTrack::getFxmix() const { return mMoveParam.params.fxmix.mValue; }
|
||||
f32 JASTrack::getDolby() const { return mMoveParam.params.dolby.mValue; }
|
||||
|
||||
void JASTrack::setLatestKey(u8 param_0) {
|
||||
field_0x22b = param_0;
|
||||
field_0x22b += getTransposeTotal();
|
||||
@@ -293,7 +315,8 @@ JASChannel* JASTrack::channelStart(JASTrack::TChannelMgr* i_channelMgr, u32 para
|
||||
return channel;
|
||||
}
|
||||
|
||||
int JASTrack::noteOn(u32 i_noteID, u32 param_1, u32 param_2) {
|
||||
int JASTrack::noteOn(u32 noteid, u32 param_1, u32 param_2) {
|
||||
JUT_ASSERT(486, noteid != 0 && noteid < TChannelMgr::CHANNEL_MAX);
|
||||
if (isMute()) {
|
||||
return 0;
|
||||
}
|
||||
@@ -301,30 +324,26 @@ int JASTrack::noteOn(u32 i_noteID, u32 param_1, u32 param_2) {
|
||||
param_1 += getTransposeTotal();
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
if (mChannelMgrs[i] != NULL) {
|
||||
mChannelMgrs[i]->noteOff(i_noteID, 0);
|
||||
mChannelMgrs[i]->noteOff(noteid, 0);
|
||||
JASChannel* channel = channelStart(mChannelMgrs[i], param_1, param_2, 0);
|
||||
if (channel == NULL) {
|
||||
ret = 0;
|
||||
}
|
||||
mChannelMgrs[i]->mChannels[i_noteID] = channel;
|
||||
mChannelMgrs[i]->mChannels[noteid] = channel;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
|
||||
bool result = true;
|
||||
param_0 += getTransposeTotal();
|
||||
if (mGateRate != 100) {
|
||||
i_time *= mGateRate / 100.0f;
|
||||
}
|
||||
u32 uvar2 = seqTimeToDspTime(i_time);
|
||||
u32 update_timer = (i_flags & 6) ? 0 : uvar2;
|
||||
int uvar7;
|
||||
if (i_flags & 1) {
|
||||
uvar7 = field_0x22b;
|
||||
} else {
|
||||
uvar7 = param_0;
|
||||
}
|
||||
int uvar7 = i_flags & 1 ? field_0x22b : param_0;
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
TChannelMgr* channel_mgr = mChannelMgrs[i];
|
||||
if (channel_mgr != NULL) {
|
||||
@@ -337,26 +356,30 @@ int JASTrack::gateOn(u32 param_0, u32 i_velocity, f32 i_time, u32 i_flags) {
|
||||
} else {
|
||||
JASChannel* channel = channel_mgr->mChannels[0];
|
||||
if (channel != NULL) {
|
||||
channel->mKey = uvar7 - channel->field_0xdc.field_0x4.field_0x01;
|
||||
channel->mVelocity = i_velocity;
|
||||
channel->mUpdateTimer = update_timer;
|
||||
channel->setKey(uvar7 - channel->field_0xdc.field_0x4.field_0x01);
|
||||
channel->setVelocity(i_velocity);
|
||||
channel->setUpdateTimer(update_timer);
|
||||
}
|
||||
}
|
||||
if ((i_flags & 1) && channel_mgr->mChannels[0] != NULL) {
|
||||
channel_mgr->mChannels[0]->setKeySweepTarget(param_0 - uvar7, uvar2);
|
||||
if (i_flags & 1) {
|
||||
JASChannel* channel = channel_mgr->mChannels[0];
|
||||
if (channel != NULL) {
|
||||
channel->setKeySweepTarget(param_0 - uvar7, uvar2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mFlags.flag4 = (i_flags >> 1) & 1;
|
||||
mFlags.flag4 = (i_flags & 2) ? true : false;
|
||||
field_0x22b = param_0;
|
||||
return 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
int JASTrack::noteOff(u32 i_noteID, u16 param_1) {
|
||||
int JASTrack::noteOff(u32 noteid, u16 param_1) {
|
||||
JUT_ASSERT(563, noteid < TChannelMgr::CHANNEL_MAX);
|
||||
int ret = 1;
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
if (mChannelMgrs[i] != NULL) {
|
||||
if (!mChannelMgrs[i]->noteOff(i_noteID, param_1)) {
|
||||
if (!mChannelMgrs[i]->noteOff(noteid, param_1)) {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
@@ -364,10 +387,14 @@ int JASTrack::noteOff(u32 i_noteID, u16 param_1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool JASTrack::checkNoteStop(u32 i_noteID) const {
|
||||
bool JASTrack::checkNoteStop(u32 noteid) const {
|
||||
JUT_ASSERT(581, noteid < TChannelMgr::CHANNEL_MAX);
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
if (mChannelMgrs[i] != NULL && mChannelMgrs[i]->mChannels[i_noteID] != NULL) {
|
||||
return false;
|
||||
if (mChannelMgrs[i] != NULL) {
|
||||
JASChannel* channel = mChannelMgrs[i]->mChannels[noteid];
|
||||
if (channel != NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -376,13 +403,14 @@ bool JASTrack::checkNoteStop(u32 i_noteID) const {
|
||||
void JASTrack::overwriteOsc(JASChannel* i_channel) {
|
||||
for (u32 i = 0; i < 2; i++) {
|
||||
if (mOscParam[i].mTable != NULL) {
|
||||
JUT_ASSERT(599, mOscParam[i].rel_table == 0);
|
||||
i_channel->setOscInit(i, &mOscParam[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JASTrack::updateTimedParam() {
|
||||
for (u32 i = 0; i < 6; i++) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
MoveParam_* param = &mMoveParam.array[i];
|
||||
if (param->mCount != 0) {
|
||||
param->mValue += (param->mTarget - param->mValue) / param->mCount;
|
||||
@@ -403,13 +431,12 @@ void JASTrack::updateTrack(f32 param_0) {
|
||||
f32 pan = (mMoveParam.params.pan.mValue - 0.5f) * mPanPower;
|
||||
f32 fxmix = mMoveParam.params.fxmix.mValue;
|
||||
f32 dolby = mMoveParam.params.dolby.mValue;
|
||||
JASSoundParams* sound_params = channel_mgr->mSoundParams;
|
||||
if (sound_params != NULL) {
|
||||
volume *= sound_params->mVolume;
|
||||
pitch *= sound_params->mPitch;
|
||||
pan += sound_params->mPan - 0.5f;
|
||||
fxmix += sound_params->mFxMix;
|
||||
dolby += sound_params->mDolby;
|
||||
if (channel_mgr->mSoundParams != NULL) {
|
||||
volume *= channel_mgr->mSoundParams->mVolume;
|
||||
pitch *= channel_mgr->mSoundParams->mPitch;
|
||||
pan += channel_mgr->mSoundParams->mPan - 0.5f;
|
||||
fxmix += channel_mgr->mSoundParams->mFxMix;
|
||||
dolby += channel_mgr->mSoundParams->mDolby;
|
||||
}
|
||||
pan *= param_0;
|
||||
if (mParent == NULL) {
|
||||
@@ -456,25 +483,26 @@ void JASTrack::updateSeq(bool param_0, f32 param_1) {
|
||||
}
|
||||
f32 fvar1 = param_1 * mPanPower;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
|
||||
mChildren[i]->updateSeq(param_0, fvar1);
|
||||
JASTrack* child = mChildren[i];
|
||||
if (child != NULL && child->mStatus == STATUS_RUN) {
|
||||
child->updateSeq(param_0, fvar1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 JASTrack::seqTimeToDspTime(f32 i_seqTime) {
|
||||
f32 dsp_time;
|
||||
if (mFlags.flag2) {
|
||||
dsp_time = i_seqTime / field_0x1dc;
|
||||
i_seqTime = i_seqTime / field_0x1dc;
|
||||
} else {
|
||||
dsp_time = i_seqTime * (120.0f / mTimebase);
|
||||
dsp_time *= JASDriver::getSubFrames() / 10.0f;
|
||||
i_seqTime = i_seqTime * (120.0f / mTimebase);
|
||||
i_seqTime *= JASDriver::getSubFrames() / 10.0f;
|
||||
}
|
||||
return dsp_time;
|
||||
return i_seqTime;
|
||||
}
|
||||
|
||||
void JASTrack::setParam(u32 i_index, f32 i_target, u32 i_count) {
|
||||
MoveParam_* param = &mMoveParam.array[i_index];
|
||||
void JASTrack::setParam(u32 target, f32 i_target, u32 i_count) {
|
||||
JUT_ASSERT(739, target < TIMED_PARAMS);
|
||||
MoveParam_* param = &mMoveParam.array[target];
|
||||
param->mTarget = i_target;
|
||||
if (i_count == 0) {
|
||||
param->mValue = param->mTarget;
|
||||
@@ -487,8 +515,9 @@ void JASTrack::noteOffAll(u16 param_0) {
|
||||
noteOff(i, param_0);
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (mChildren[i] != NULL && mChildren[i]->mStatus == 1) {
|
||||
mChildren[i]->noteOffAll(param_0);
|
||||
JASTrack* child = mChildren[i];
|
||||
if (child != NULL && child->mStatus == STATUS_RUN) {
|
||||
child->noteOffAll(param_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,14 +529,16 @@ void JASTrack::mute(bool i_mute) {
|
||||
}
|
||||
}
|
||||
|
||||
void JASTrack::setOscScale(u32 i_oscNo, f32 i_scale) {
|
||||
mOscParam[i_oscNo].mScale = i_scale;
|
||||
void JASTrack::setOscScale(u32 osc_no, f32 i_scale) {
|
||||
JUT_ASSERT(792, osc_no < OSC_NUM);
|
||||
mOscParam[osc_no].mScale = i_scale;
|
||||
}
|
||||
|
||||
void JASTrack::setOscTable(u32 i_oscNo, JASOscillator::Point const* i_table) {
|
||||
mOscParam[i_oscNo].mTable = i_table;
|
||||
if (i_oscNo != 0) {
|
||||
mOscParam[i_oscNo]._0C = NULL;
|
||||
void JASTrack::setOscTable(u32 osc_no, JASOscillator::Point const* i_table) {
|
||||
JUT_ASSERT(799, osc_no < OSC_NUM)
|
||||
mOscParam[osc_no].mTable = i_table;
|
||||
if (osc_no != 0) {
|
||||
mOscParam[osc_no].rel_table = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -547,9 +578,9 @@ void JASTrack::writePortSelf(u32 param_0, u16 param_1) {
|
||||
}
|
||||
|
||||
void JASTrack::writePort(u32 param_0, u16 param_1) {
|
||||
JASSeqCtrl::IntrType intr;
|
||||
mTrackPort.writeImport(param_0, param_1);
|
||||
if (param_0 == 0 || param_0 == 1) {
|
||||
JASSeqCtrl::IntrType intr;
|
||||
if (param_0 == 0) {
|
||||
intr = JASSeqCtrl::INTRTYPE_VALUE_2;
|
||||
} else {
|
||||
@@ -565,13 +596,15 @@ u16 JASTrack::readPort(u32 param_0) {
|
||||
|
||||
void JASTrack::setChannelPauseFlag(bool i_pause) {
|
||||
for (u32 i = 0; i < mChannelMgrCount; i++) {
|
||||
if (mChannelMgrs[i] != NULL) {
|
||||
mChannelMgrs[i]->setPauseFlag(i_pause);
|
||||
TChannelMgr* mgr = mChannelMgrs[i];
|
||||
if (mgr != NULL) {
|
||||
mgr->setPauseFlag(i_pause);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (mChildren[i] != NULL) {
|
||||
mChildren[i]->setChannelPauseFlag(i_pause);
|
||||
JASTrack* child = mChildren[i];
|
||||
if (child != NULL) {
|
||||
child->setChannelPauseFlag(i_pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,18 +634,21 @@ bool JASTrack::isMute() const {
|
||||
}
|
||||
|
||||
void JASTrack::setTempo(u16 i_tempo) {
|
||||
JUT_ASSERT(961, mParent == 0);
|
||||
mTempo = i_tempo;
|
||||
mFlags.flag5 = true;
|
||||
updateTempo();
|
||||
}
|
||||
|
||||
void JASTrack::setTempoRate(f32 i_tempoRate) {
|
||||
JUT_ASSERT(969, mParent == 0);
|
||||
mTempoRate = i_tempoRate;
|
||||
mFlags.flag5 = true;
|
||||
updateTempo();
|
||||
}
|
||||
|
||||
void JASTrack::setTimebase(u16 i_timebase) {
|
||||
JUT_ASSERT(977, mParent == 0);
|
||||
mTimebase = i_timebase;
|
||||
mFlags.flag5 = true;
|
||||
updateTempo();
|
||||
@@ -639,7 +675,7 @@ void JASTrack::channelUpdateCallback(u32 param_0, JASChannel* param_1,
|
||||
switch (param_0) {
|
||||
case 0:
|
||||
case 1:
|
||||
param_1->mParams = channel_mgr->mParams;
|
||||
param_1->setParams(channel_mgr->mParams);
|
||||
track->updateChannel(param_1, param_2);
|
||||
break;
|
||||
case 3:
|
||||
@@ -658,6 +694,21 @@ void JASTrack::channelUpdateCallback(u32 param_0, JASChannel* param_1,
|
||||
}
|
||||
}
|
||||
|
||||
int JASTrack::getChannelCount() const {
|
||||
JASCriticalSection cs;
|
||||
int count = 0;
|
||||
for (int i = 0; i < mChannelMgrCount; i++) {
|
||||
if (mChannelMgrs[i]) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
if (mChannelMgrs[i]->mChannels[j]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
JASTrack* JASTrack::getRootTrack() {
|
||||
JASTrack* track = this;
|
||||
while (track->mParent != NULL) {
|
||||
@@ -678,7 +729,8 @@ int JASTrack::tickProc() {
|
||||
}
|
||||
for (int i = 0; i < 16; i++) {
|
||||
JASTrack* child = mChildren[i];
|
||||
if (child != NULL && child->mStatus == 1) {
|
||||
if (child != NULL && child->mStatus == STATUS_RUN) {
|
||||
JUT_ASSERT(1090, this == child->mParent);
|
||||
ret = child->tickProc();
|
||||
if (ret < 0) {
|
||||
getRootTrack()->updateSeq(false, 1.0f);
|
||||
@@ -694,6 +746,7 @@ int JASTrack::tickProc() {
|
||||
}
|
||||
|
||||
int JASTrack::seqMain() {
|
||||
JUT_ASSERT(1108, mStatus == STATUS_RUN);
|
||||
if (mFlags.flag6) {
|
||||
updateSeq(true, 1.0f);
|
||||
close();
|
||||
@@ -701,7 +754,8 @@ int JASTrack::seqMain() {
|
||||
} else {
|
||||
while (field_0x1d8 >= 1.0f) {
|
||||
field_0x1d8 -= 1.0f;
|
||||
if (tickProc() < 0) {
|
||||
int ret = tickProc();
|
||||
if (ret < 0) {
|
||||
updateSeq(false, 1.0f);
|
||||
close();
|
||||
return -1;
|
||||
@@ -714,13 +768,15 @@ int JASTrack::seqMain() {
|
||||
}
|
||||
|
||||
s32 JASTrack::TList::cbSeqMain(void* i_this) {
|
||||
static_cast<JASTrack::TList*>(i_this)->seqMain();
|
||||
JASTrack::TList* list = static_cast<JASTrack::TList*>(i_this);
|
||||
list->seqMain();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void JASTrack::TList::append(JASTrack* i_track) {
|
||||
if (!mCallbackRegistered) {
|
||||
if (!JASDriver::registerSubFrameCallback(cbSeqMain, this)) {
|
||||
JUT_WARN(1157, "%s", "Failed: registerSubFrameCallback");
|
||||
return;
|
||||
}
|
||||
mCallbackRegistered = true;
|
||||
@@ -796,8 +852,9 @@ void JASTrack::TChannelMgr::releaseAll() {
|
||||
}
|
||||
}
|
||||
|
||||
bool JASTrack::TChannelMgr::noteOff(u32 i_channel, u16 param_1) {
|
||||
JASChannel* channel = mChannels[i_channel];
|
||||
bool JASTrack::TChannelMgr::noteOff(u32 noteid, u16 param_1) {
|
||||
JUT_ASSERT(1224, noteid < CHANNEL_MAX);
|
||||
JASChannel* channel = mChannels[noteid];
|
||||
if (channel == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -807,14 +864,15 @@ bool JASTrack::TChannelMgr::noteOff(u32 i_channel, u16 param_1) {
|
||||
channel->release(param_1);
|
||||
}
|
||||
channel->free();
|
||||
mChannels[i_channel] = NULL;
|
||||
mChannels[noteid] = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
void JASTrack::TChannelMgr::setPauseFlag(bool i_pause) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
if (mChannels[i] != NULL) {
|
||||
mChannels[i]->setPauseFlag(i_pause);
|
||||
JASChannel* channel = mChannels[i];
|
||||
if (channel != NULL) {
|
||||
channel->setPauseFlag(i_pause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,21 +11,25 @@ void JASTrackPort::init() {
|
||||
}
|
||||
|
||||
u16 JASTrackPort::readImport(u32 port_num) {
|
||||
JUT_ASSERT(27, port_num < MAX_PORTS);
|
||||
field_0x0 = field_0x0 & ~(1 << port_num);
|
||||
return field_0x4[port_num];
|
||||
}
|
||||
|
||||
u16 JASTrackPort::readExport(u32 port_num) {
|
||||
JUT_ASSERT(34, port_num < MAX_PORTS);
|
||||
field_0x2 = field_0x2 & ~(1 << port_num);
|
||||
return field_0x4[port_num];
|
||||
}
|
||||
|
||||
void JASTrackPort::writeImport(u32 port_num, u16 param_1) {
|
||||
JUT_ASSERT(41, port_num < MAX_PORTS);
|
||||
field_0x0 = field_0x0 | (1 << port_num);
|
||||
field_0x4[port_num] = param_1;
|
||||
}
|
||||
|
||||
void JASTrackPort::writeExport(u32 port_num, u16 param_1) {
|
||||
JUT_ASSERT(47, port_num < MAX_PORTS);
|
||||
field_0x2 = field_0x2 | (1 << port_num);
|
||||
field_0x4[port_num] = param_1;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
u32 JASWSParser::getGroupCount(void const* stream) {
|
||||
THeader* header = (THeader*)stream;
|
||||
return header->mCtrlGroupOffset.ptr(header)->mGroupCount;
|
||||
TCtrlGroup* group = header->mCtrlGroupOffset.ptr(header);
|
||||
return group->mGroupCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +39,11 @@ JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap*
|
||||
wave_bank->setGroupCount(ctrl_group->mGroupCount, heap);
|
||||
wave_bank->setWaveTableSize(header->mWaveTableSize, heap);
|
||||
for (u32 i = 0; i < ctrl_group->mGroupCount; i++) {
|
||||
TCtrl* ctrl = ctrl_group->mCtrlSceneOffsets[i].ptr(header)->mCtrlOffset.ptr(header);
|
||||
TCtrlScene* ctrlScene = ctrl_group->mCtrlSceneOffsets[i].ptr(header);
|
||||
TCtrl* ctrl = ctrlScene->mCtrlOffset.ptr(header);
|
||||
JASBasicWaveBank::TWaveGroup* wave_group = wave_bank->getWaveGroup(i);
|
||||
TWaveArchive* archive = header->mArchiveBankOffset.ptr(header)->mArchiveOffsets[i].ptr(header);
|
||||
TWaveArchiveBank* archiveBank = header->mArchiveBankOffset.ptr(header);
|
||||
TWaveArchive* archive = archiveBank->mArchiveOffsets[i].ptr(header);
|
||||
wave_group->setWaveCount(ctrl->mWaveCount, heap);
|
||||
for (int j = 0; j < ctrl->mWaveCount; j++) {
|
||||
TWave* wave = archive->mWaveOffsets[j].ptr(header);
|
||||
@@ -57,7 +60,8 @@ JASBasicWaveBank* JASWSParser::createBasicWaveBank(void const* stream, JKRHeap*
|
||||
wave_info.field_0x1c = wave->_20;
|
||||
wave_info.field_0x1e = wave->_22;
|
||||
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[j].ptr(header);
|
||||
wave_bank->setWaveInfo(wave_group, j, JSULoHalf(ctrl_wave->_00), wave_info);
|
||||
u16 local_74 = JSULoHalf(ctrl_wave->_00);
|
||||
wave_bank->setWaveInfo(wave_group, j, local_74, wave_info);
|
||||
}
|
||||
wave_group->setFileName(archive->mFileName);
|
||||
}
|
||||
@@ -84,10 +88,13 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
|
||||
}
|
||||
|
||||
u32 max = 0;
|
||||
TCtrl* ctrl = ctrl_group->mCtrlSceneOffsets[0].ptr(header)->mCtrlOffset.ptr(header);
|
||||
TWaveArchive* archive = header->mArchiveBankOffset.ptr(header)->mArchiveOffsets[0].ptr(header);
|
||||
TCtrlScene* ctrlScene = ctrl_group->mCtrlSceneOffsets[0].ptr(header);
|
||||
TCtrl* ctrl = ctrlScene->mCtrlOffset.ptr(header);
|
||||
TWaveArchiveBank* archiveBank = header->mArchiveBankOffset.ptr(header);
|
||||
TWaveArchive* archive = archiveBank->mArchiveOffsets[0].ptr(header);
|
||||
for (int i = 0; i < ctrl->mWaveCount; i++) {
|
||||
u32 tmp = JSULoHalf(ctrl->mCtrlWaveOffsets[i].ptr(header)->_00);
|
||||
TCtrlWave* ctrlWave = ctrl->mCtrlWaveOffsets[i].ptr(header);
|
||||
u32 tmp = JSULoHalf(ctrlWave->_00);
|
||||
if (max < tmp) {
|
||||
max = tmp;
|
||||
}
|
||||
@@ -109,7 +116,8 @@ JASSimpleWaveBank* JASWSParser::createSimpleWaveBank(void const* stream, JKRHeap
|
||||
wave_info.field_0x1c = wave->_20;
|
||||
wave_info.field_0x1e = wave->_22;
|
||||
TCtrlWave* ctrl_wave = ctrl->mCtrlWaveOffsets[i].ptr(header);
|
||||
wave_bank->setWaveInfo(JSULoHalf(ctrl_wave->_00), wave_info);
|
||||
u32 tmp = JSULoHalf(ctrl_wave->_00);
|
||||
wave_bank->setWaveInfo(tmp, wave_info);
|
||||
}
|
||||
wave_bank->setFileName(archive->mFileName);
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include "JSystem/JAudio2/JASTaskThread.h"
|
||||
#include "JSystem/JAudio2/JASMutex.h"
|
||||
#include "JSystem/JKernel/JKRDvdAramRipper.h"
|
||||
#include "cstring.h"
|
||||
#include <string>
|
||||
#include "dolphin/os.h"
|
||||
#include <stdint.h>
|
||||
#include <stdint>
|
||||
|
||||
JASHeap* JASWaveArcLoader::sAramHeap;
|
||||
|
||||
@@ -21,11 +21,11 @@ JASHeap* JASWaveArcLoader::getRootHeap() {
|
||||
char JASWaveArcLoader::sCurrentDir[DIR_MAX] = "/AudioRes/Waves/";
|
||||
|
||||
void JASWaveArcLoader::setCurrentDir(char const* dir) {
|
||||
ASSERT(std::strlen(dir) < DIR_MAX - 1);
|
||||
JUT_ASSERT(40, std::strlen(dir) < DIR_MAX - 1);
|
||||
strcpy(sCurrentDir, dir);
|
||||
u32 len = strlen(sCurrentDir);
|
||||
if (sCurrentDir[len - 1] != '/') {
|
||||
ASSERT(len + 1 < DIR_MAX);
|
||||
JUT_ASSERT(45, len + 1 < DIR_MAX);
|
||||
sCurrentDir[len] = '/';
|
||||
sCurrentDir[len + 1] = '\0';
|
||||
}
|
||||
@@ -77,10 +77,8 @@ bool JASWaveArc::eraseSetup() {
|
||||
void JASWaveArc::loadToAramCallback(void* this_) {
|
||||
loadToAramCallbackParams* tmp = (loadToAramCallbackParams*)this_;
|
||||
JASWaveArc* wavArc = tmp->mWavArc;
|
||||
JKRAramBlock* block = JKRDvdAramRipper::loadToAram(tmp->mEntryNum, tmp->mBase,
|
||||
EXPAND_SWITCH_UNKNOWN0, 0, 0, NULL);
|
||||
if (block == NULL) {
|
||||
// "loadToAram Failed"
|
||||
if (JKRDvdAramRipper::loadToAram(tmp->mEntryNum, tmp->mBase, EXPAND_SWITCH_UNKNOWN0, 0, 0, NULL) == NULL) {
|
||||
JUT_WARN(129, "%s", "loadToAram Failed");
|
||||
return;
|
||||
}
|
||||
wavArc->_5a--;
|
||||
@@ -93,19 +91,16 @@ bool JASWaveArc::sendLoadCmd() {
|
||||
JASMutexLock mutexLock(&mMutex);
|
||||
_48 = 0;
|
||||
mStatus = 1;
|
||||
void* base = mHeap.getBase();
|
||||
loadToAramCallbackParams commandInfo;
|
||||
commandInfo.mWavArc = this;
|
||||
commandInfo.mEntryNum = mEntryNum;
|
||||
commandInfo.mBase = (uintptr_t)mHeap.mBase;
|
||||
commandInfo.mBase = (uintptr_t)mHeap.getBase();
|
||||
commandInfo._c = ++_58;
|
||||
|
||||
_5a++;
|
||||
|
||||
JASTaskThread* thread = JASDvd::getThreadPointer();
|
||||
int status = thread->sendCmdMsg(loadToAramCallback, &commandInfo, 0x10);
|
||||
if (status == 0) {
|
||||
// "sendCmdMsg loadToAramCallback Failed"
|
||||
if (JASDvd::getThreadPointer()->sendCmdMsg(loadToAramCallback, &commandInfo, 0x10) == 0) {
|
||||
JUT_WARN(193, "%s", "sendCmdMsg loadToAramCallback Failed");
|
||||
mHeap.free();
|
||||
return false;
|
||||
}
|
||||
@@ -123,8 +118,7 @@ bool JASWaveArc::load(JASHeap* heap) {
|
||||
if (heap == NULL) {
|
||||
heap = JASWaveArcLoader::getRootHeap();
|
||||
}
|
||||
bool result = mHeap.alloc(heap, mFileLength);
|
||||
if (result == false) {
|
||||
if (mHeap.alloc(heap, mFileLength) == false) {
|
||||
return false;
|
||||
}
|
||||
return sendLoadCmd();
|
||||
@@ -141,8 +135,7 @@ bool JASWaveArc::loadTail(JASHeap* heap) {
|
||||
if (heap == NULL) {
|
||||
heap = JASWaveArcLoader::getRootHeap();
|
||||
}
|
||||
bool result = mHeap.allocTail(heap, mFileLength);
|
||||
if (result == false) {
|
||||
if (mHeap.allocTail(heap, mFileLength) == false) {
|
||||
return false;
|
||||
}
|
||||
return sendLoadCmd();
|
||||
@@ -163,8 +156,7 @@ void JASWaveArc::setEntryNum(s32 entryNum) {
|
||||
if (entryNum < 0) {
|
||||
return;
|
||||
}
|
||||
BOOL openStatus = DVDFastOpen(entryNum, &fileInfo);
|
||||
if (openStatus == FALSE) {
|
||||
if (DVDFastOpen(entryNum, &fileInfo) == FALSE) {
|
||||
return;
|
||||
}
|
||||
mFileLength = fileInfo.length;
|
||||
@@ -176,13 +168,13 @@ void JASWaveArc::setFileName(char const* fileName) {
|
||||
char* currentDir = JASWaveArcLoader::getCurrentDir();
|
||||
size_t length = strlen(currentDir);
|
||||
length = length + strlen(fileName);
|
||||
JKRHeap* systemHeap = JASKernel::getSystemHeap();
|
||||
char* fileString = new (systemHeap, -4) char[length + 1];
|
||||
strcpy(fileString, currentDir);
|
||||
strcat(fileString, fileName);
|
||||
fileString[length] = '\0';
|
||||
int entryNum = DVDConvertPathToEntrynum(fileString);
|
||||
delete[] fileString;
|
||||
char* path = new (JASKernel::getSystemHeap(), -4) char[length + 1];
|
||||
JUT_ASSERT(322, path);
|
||||
strcpy(path, currentDir);
|
||||
strcat(path, fileName);
|
||||
path[length] = '\0';
|
||||
int entryNum = DVDConvertPathToEntrynum(path);
|
||||
delete[] path;
|
||||
if (entryNum < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ bool JAUAudioArcInterpreter::readCommand_() {
|
||||
break;
|
||||
}
|
||||
case 'sect': {
|
||||
readU8_();
|
||||
u8 var1 = readU8_();
|
||||
u8 var2 = readU8_();
|
||||
u8 var3 = readU8_();
|
||||
readMaxSeCategory(var1, var2, var3);
|
||||
u8 var4 = readU8_();
|
||||
readMaxSeCategory(var2, var3, var4);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
|
||||
#include "JSystem/JAudio2/JAUAudioArcLoader.h"
|
||||
#include "JSystem/JAudio2/JAISeMgr.h"
|
||||
#include "JSystem/JAudio2/JASReport.h"
|
||||
#include "JSystem/JAudio2/JAUSectionHeap.h"
|
||||
|
||||
JAUAudioArcLoader::JAUAudioArcLoader(JAUSection* section) {
|
||||
//JUT_ASSERT(13, section->isOpen());
|
||||
//JUT_ASSERT(14, section->isBuilding());
|
||||
JUT_ASSERT(13, section->isOpen());
|
||||
JUT_ASSERT(14, section->isBuilding());
|
||||
mSection = section;
|
||||
}
|
||||
|
||||
@@ -68,9 +69,80 @@ void JAUAudioArcLoader::endBNKList() {
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader::readMaxSeCategory(int param_0, int param_1, int param_2) {
|
||||
JAISeMgr* seMgr = JASGlobalInstance<JAISeMgr>::getInstance();
|
||||
if (seMgr) {
|
||||
seMgr->getCategory(param_0)->setMaxActiveSe(param_1);
|
||||
seMgr->getCategory(param_0)->setMaxInactiveSe(param_2);
|
||||
{
|
||||
JAISeMgr* seMgr = JASGlobalInstance<JAISeMgr>::getInstance();
|
||||
if (seMgr) {
|
||||
seMgr->getCategory(param_0)->setMaxActiveSe(param_1);
|
||||
seMgr->getCategory(param_0)->setMaxInactiveSe(param_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readWS(u32 param_0, void const* param_1, u32 param_2) {
|
||||
mSection->newWaveBank(param_0, param_1);
|
||||
if (param_2) {
|
||||
mSection->loadWaveArc(param_0, param_2);
|
||||
}
|
||||
JASReport(".ws resource remains at Heap Head\n");
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBNK(u32 param_0, void const* param_1) {
|
||||
mSection->newBank(param_1, param_0);
|
||||
JASReport(".bnk resource remains at Heap Head\n");
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBSC(void const* param_0, u32 param_1) {
|
||||
UNUSED(param_1);
|
||||
mSection->newSeSeqCollection(param_0, 0);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBST(void const* param_0, u32 param_1) {
|
||||
UNUSED(param_1);
|
||||
mSection->newSoundTable(param_0, 0, true);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBSTN(void const* param_0, u32 param_1) {
|
||||
UNUSED(param_1);
|
||||
mSection->newSoundNameTable(param_0, 0, true);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBMS(u32 param_0, void const* param_1, u32 param_2) {
|
||||
UNUSED(param_2);
|
||||
mSection->newStaticSeqData(param_0, param_1, 0);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBMS_fromArchive(u32 param_0) {
|
||||
mSection->newStaticSeqData(param_0);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::newVoiceBank(u32 param_0, u32 param_1) {
|
||||
mSection->newVoiceBank(param_1, param_0);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::newDynamicSeqBlock(u32 param_0) {
|
||||
JAUSectionHeap* sectionHeap = mSection->asSectionHeap();
|
||||
JUT_ASSERT(166, sectionHeap);
|
||||
sectionHeap->newDynamicSeqBlock(param_0);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readBSFT(void const* param_0) {
|
||||
mSection->newStreamFileTable(param_0, false);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::beginBNKList(u32 param_0, u32 param_1) {
|
||||
mSection->beginNewBankTable(param_0, param_1);
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::endBNKList() {
|
||||
mSection->endNewBankTable();
|
||||
}
|
||||
|
||||
void JAUAudioArcLoader_withoutCopy::readMaxSeCategory(int param_0, int param_1, int param_2) {
|
||||
{
|
||||
JAISeMgr* seMgr = JASGlobalInstance<JAISeMgr>::getInstance();
|
||||
if (seMgr) {
|
||||
seMgr->getCategory(param_0)->setMaxActiveSe(param_1);
|
||||
seMgr->getCategory(param_0)->setMaxInactiveSe(param_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
|
||||
#include "JSystem/JAudio2/JAUClusterSound.h"
|
||||
#include "JSystem/JAudio2/JAISoundHandles.h"
|
||||
#include "JSystem/JAudio2/JAISoundStarter.h"
|
||||
|
||||
// Dummy function to generate JAISoundHandle::JAISoundHandle
|
||||
static void dummyCtor() {
|
||||
JASGlobalInstance<JAISoundStarter>::getInstance();
|
||||
JAISoundHandle dummy[20];
|
||||
JAISoundHandles handles(dummy, 20);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ JAIStreamDataMgr* JAUSection::newStreamFileTable(void const* param_0, bool param
|
||||
}
|
||||
|
||||
JAISeqDataMgr* JAUSection::newSeSeqCollection(void const* bsc, u32 param_1) {
|
||||
// JUT_ASSERT(398, asSectionHeap() == this);
|
||||
JUT_ASSERT(398, asSectionHeap() == this);
|
||||
JUT_ASSERT(399, sectionHeap_->sectionHeapData_.seSeqDataMgr_ == NULL);
|
||||
if (param_1) {
|
||||
bsc = newCopy(bsc, param_1, 4);
|
||||
@@ -224,14 +224,16 @@ u8* JAUSection::newStaticSeqDataBlock_(JAISoundID param_0, u32 size) {
|
||||
}
|
||||
JSULink<JAUSeqDataBlock>* link = new JSULink<JAUSeqDataBlock>(seqDataBlock);
|
||||
if (!link) {
|
||||
JUT_WARN(432, "%s", "created UNUSED object in Heap\n");
|
||||
return NULL;
|
||||
}
|
||||
u8* r28 = new(0x20) u8[size];
|
||||
if (!r28) {
|
||||
JUT_WARN(438, "%s", "created UNUSED object in Heap\n");
|
||||
return NULL;
|
||||
}
|
||||
seqDataBlock->field_0x14.addr = r28;
|
||||
seqDataBlock->field_0x14.size = size;
|
||||
seqDataBlock->region.addr = r28;
|
||||
seqDataBlock->region.size = size;
|
||||
seqDataBlock->field_0x10 = param_0;
|
||||
JASCriticalSection cs;
|
||||
if(data_.field_0x00.appendDynamicSeqDataBlock(seqDataBlock)) {
|
||||
@@ -243,10 +245,12 @@ u8* JAUSection::newStaticSeqDataBlock_(JAISoundID param_0, u32 size) {
|
||||
}
|
||||
|
||||
bool JAUSection::newStaticSeqData(JAISoundID param_0, void const* param_1, u32 param_2) {
|
||||
u8* r30 = newStaticSeqDataBlock_(param_0, param_2);
|
||||
if (r30) {
|
||||
memcpy(r30, param_1, param_2);
|
||||
return true;
|
||||
{
|
||||
u8* r30 = newStaticSeqDataBlock_(param_0, param_2);
|
||||
if (r30) {
|
||||
memcpy(r30, param_1, param_2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -256,6 +260,7 @@ bool JAUSection::newStaticSeqData(JAISoundID param_0) {
|
||||
JUT_ASSERT(481, seqArchive);
|
||||
JAUSoundInfo* soundInfo = JASGlobalInstance<JAUSoundInfo>::getInstance();
|
||||
if (!soundInfo) {
|
||||
JUT_WARN(485, "%s","cannot JAUSoundInfo::getInstance().");
|
||||
return false;
|
||||
}
|
||||
u16 r26 = soundInfo->getBgmSeqResourceID(param_0);
|
||||
@@ -286,15 +291,17 @@ static bool dummy_string(int i) {
|
||||
JASWaveBank* JAUSection::newWaveBank(u32 bank_no, void const* param_1) {
|
||||
JUT_ASSERT(528, isOpen());
|
||||
JUT_ASSERT(529, isBuilding());
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
s32 r27 = getHeap_()->getFreeSize();
|
||||
JASWaveBank* waveBank = JASWSParser::createWaveBank(param_1, getHeap_());
|
||||
if (waveBank) {
|
||||
JUT_ASSERT(536, sectionHeap_->getWaveBankTable().getWaveBank( bank_no ) == NULL);
|
||||
sectionHeap_->getWaveBankTable().registWaveBank(bank_no, waveBank);
|
||||
data_.registeredWaveBankTables.set(bank_no, true);
|
||||
data_.field_0xa0 += r27 - getHeap_()->getFreeSize();
|
||||
return waveBank;
|
||||
{
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
s32 r27 = getHeap_()->getFreeSize();
|
||||
JASWaveBank* waveBank = JASWSParser::createWaveBank(param_1, getHeap_());
|
||||
if (waveBank) {
|
||||
JUT_ASSERT(536, sectionHeap_->getWaveBankTable().getWaveBank( bank_no ) == NULL);
|
||||
sectionHeap_->getWaveBankTable().registWaveBank(bank_no, waveBank);
|
||||
data_.registeredWaveBankTables.set(bank_no, true);
|
||||
data_.field_0xa0 += r27 - getHeap_()->getFreeSize();
|
||||
return waveBank;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
@@ -306,7 +313,8 @@ bool JAUSection::loadWaveArc(u32 param_0, u32 param_1) {
|
||||
if (waveBank) {
|
||||
for (u32 i = 0; i < waveBank->getArcCount(); i++) {
|
||||
if (param_1 & 1 << i) {
|
||||
waveBank->getWaveArc(i)->load(NULL);
|
||||
JASWaveArc* waveArc = waveBank->getWaveArc(i);
|
||||
waveArc->load(NULL);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -320,22 +328,24 @@ JASBank* JAUSection::newBank(void const* param_0, u32 param_1) {
|
||||
JUT_ASSERT(648, isBuilding());
|
||||
JASWaveBank* waveBank = sectionHeap_->getWaveBankTable().getWaveBank(param_1);
|
||||
JUT_ASSERT(650, waveBank != NULL);
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
u32 bank_no = JASBNKParser::getBankNumber(param_0);
|
||||
s32 r25 = getHeap_()->getFreeSize();
|
||||
JASBank* bank = JASBNKParser::createBank(param_0, getHeap_());
|
||||
if (bank) {
|
||||
if (buildingBankTable_) {
|
||||
JUT_ASSERT(660, buildingBankTable_->getBank( bank_no ) == NULL);
|
||||
buildingBankTable_->registBank(bank_no, bank);
|
||||
} else {
|
||||
JUT_ASSERT(665, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == NULL);
|
||||
JASDefaultBankTable::getInstance()->registBank(bank_no, bank);
|
||||
data_.registeredBankTables.set(bank_no, true);
|
||||
{
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
u32 bank_no = JASBNKParser::getBankNumber(param_0);
|
||||
s32 r25 = getHeap_()->getFreeSize();
|
||||
JASBank* bank = JASBNKParser::createBank(param_0, getHeap_());
|
||||
if (bank) {
|
||||
if (buildingBankTable_) {
|
||||
JUT_ASSERT(660, buildingBankTable_->getBank( bank_no ) == NULL);
|
||||
buildingBankTable_->registBank(bank_no, bank);
|
||||
} else {
|
||||
JUT_ASSERT(665, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == NULL);
|
||||
JASDefaultBankTable::getInstance()->registBank(bank_no, bank);
|
||||
data_.registeredBankTables.set(bank_no, true);
|
||||
}
|
||||
bank->assignWaveBank(waveBank);
|
||||
data_.field_0x9c += r25 - getHeap_()->getFreeSize();
|
||||
return bank;
|
||||
}
|
||||
bank->assignWaveBank(waveBank);
|
||||
data_.field_0x9c += r25 - getHeap_()->getFreeSize();
|
||||
return bank;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -377,10 +387,10 @@ bool JAUSection::beginNewBankTable(u32 param_0, u32 param_1) {
|
||||
if (bankTableLink) {
|
||||
buildingBankTable_ = bankTableLink;
|
||||
} else {
|
||||
|
||||
JUT_WARN(730, "%s","created UNUSED object in Heap\n");
|
||||
}
|
||||
} else {
|
||||
|
||||
JUT_WARN(735, "%s","created UNUSED object in Heap\n");
|
||||
}
|
||||
}
|
||||
return bankTableLink;
|
||||
@@ -406,7 +416,8 @@ JAUSectionHeap::TSectionHeapData::TSectionHeapData() {
|
||||
|
||||
void JAUSectionHeap::setSeqDataArchive(JKRArchive* param_0) {
|
||||
sectionHeapData_.seqDataBlocks.setSeqDataArchive(param_0);
|
||||
for (JSULink<JAUSection>* link = mSectionList.getFirst(); link; link = link->getNext()) {
|
||||
JSULink<JAUSection>* link;
|
||||
for (link = mSectionList.getFirst(); link; link = link->getNext()) {
|
||||
link->getObject()->data_.field_0x00.setSeqDataArchive(param_0);
|
||||
}
|
||||
}
|
||||
@@ -423,7 +434,8 @@ static JAUSectionHeap* JAUNewSectionHeap(JKRSolidHeap* heap, bool param_1) {
|
||||
JUT_ASSERT(809, JKRSolidHeap_isEmpty( heap ));
|
||||
TPushCurrentHeap push(heap);
|
||||
s32 r29 = heap->getFreeSize();
|
||||
return new JAUSectionHeap(heap, param_1, r29);
|
||||
JAUSectionHeap* sectionHeap = new JAUSectionHeap(heap, param_1, r29);
|
||||
return sectionHeap;
|
||||
}
|
||||
|
||||
JAUSectionHeap* JAUNewSectionHeap(bool param_0) {
|
||||
@@ -443,42 +455,61 @@ JAUSection* JAUSectionHeap::getOpenSection() {
|
||||
return mSectionList.getLast()->getObject();
|
||||
}
|
||||
|
||||
JAUSection* JAUSectionHeap::getSection(int param_0) {
|
||||
JSULink<JAUSection>* link = mSectionList.getFirst();
|
||||
while (param_0 > 0) {
|
||||
JSULink<JAUSection>* link2 = link->getNext();
|
||||
if (!link2) {
|
||||
return NULL;
|
||||
}
|
||||
link = link2;
|
||||
param_0--;
|
||||
}
|
||||
return link->getObject();
|
||||
}
|
||||
|
||||
bool JAUSectionHeap::setSeqDataUser(JAISeqDataUser* param_0) {
|
||||
sectionHeapData_.seqDataUser = param_0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JAUSectionHeap::newDynamicSeqBlock(u32 size) {
|
||||
/* JUT_ASSERT(937, isOpen());
|
||||
JUT_ASSERT(937, isOpen());
|
||||
JUT_ASSERT(938, isBuilding());
|
||||
JUT_ASSERT(939, sectionHeap_ == this); */
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
JAUSeqDataBlock * seqDataBlock = new JAUSeqDataBlock();
|
||||
if (!seqDataBlock) {
|
||||
return false;
|
||||
}
|
||||
JSULink<JAUSeqDataBlock> * link = new JSULink<JAUSeqDataBlock>(seqDataBlock);
|
||||
if (!link) {
|
||||
return false;
|
||||
}
|
||||
u8* r25 = new(0x20) u8[size];
|
||||
if (!r25) {
|
||||
return false;
|
||||
}
|
||||
seqDataBlock->field_0x14.addr = r25;
|
||||
seqDataBlock->field_0x14.size = size;
|
||||
seqDataBlock->field_0x10.setAnonymous();
|
||||
JASCriticalSection cs;
|
||||
if (sectionHeap_->sectionHeapData_.seqDataBlocks.appendDynamicSeqDataBlock(seqDataBlock)) {
|
||||
return true;
|
||||
JUT_ASSERT(939, sectionHeap_ == this);
|
||||
{
|
||||
TPushCurrentHeap push(getHeap_());
|
||||
JAUSeqDataBlock * seqDataBlock = new JAUSeqDataBlock();
|
||||
if (!seqDataBlock) {
|
||||
return false;
|
||||
}
|
||||
JSULink<JAUSeqDataBlock> * link = new JSULink<JAUSeqDataBlock>(seqDataBlock);
|
||||
if (!link) {
|
||||
JUT_WARN(950, "%s", "created UNUSED object in Heap\n");
|
||||
return false;
|
||||
}
|
||||
u8* r25 = new(0x20) u8[size];
|
||||
if (!r25) {
|
||||
JUT_WARN(956, "%s", "created UNUSED object in Heap\n");
|
||||
return false;
|
||||
}
|
||||
seqDataBlock->region.addr = r25;
|
||||
seqDataBlock->region.size = size;
|
||||
seqDataBlock->field_0x10.setAnonymous();
|
||||
JASCriticalSection cs;
|
||||
if (sectionHeap_->sectionHeapData_.seqDataBlocks.appendDynamicSeqDataBlock(seqDataBlock)) {
|
||||
return true;
|
||||
}
|
||||
JUT_WARN(968, "%s","created UNUSED object in Heap\n");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
JAISeqDataMgr::SeqDataReturnValue JAUSectionHeap::getSeqData(JAISoundID param_0, JAISeqData* param_1) {
|
||||
const int JAI_ASYNC_RESULT_RETRY = 1;
|
||||
for (JSULink<JAUSection> * link = mSectionList.getFirst(); link; link = link->getNext()) {
|
||||
s32 result = link->getObject()->data_.field_0x00.getSeqData(param_0, sectionHeapData_.seqDataUser, param_1, false);
|
||||
// JUT_ASSERT(994, result != JAI_ASYNC_RESULT_RETRY);
|
||||
JUT_ASSERT(994, result != JAI_ASYNC_RESULT_RETRY);
|
||||
if (result == 2) {
|
||||
return JAISeqDataMgr::SeqDataReturnValue_2;
|
||||
}
|
||||
@@ -487,5 +518,6 @@ JAISeqDataMgr::SeqDataReturnValue JAUSectionHeap::getSeqData(JAISoundID param_0,
|
||||
}
|
||||
|
||||
int JAUSectionHeap::releaseSeqData() {
|
||||
JUT_WARN(1005, "%s", "JAUSectionHeap cannot release SeqData all at once. Please pop Section.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ bool JAUSeqCollection::getSeqData(int param_0, int param_1, JAISeqData* param_2)
|
||||
if (param_0 >= field_0x0) {
|
||||
return false;
|
||||
}
|
||||
u32* puVar2 = (u32*)((u8*)field_0x8 + field_0x4[param_0]);
|
||||
u32 r29 = field_0x4[param_0];
|
||||
u32* puVar2 = (u32*)((u8*)field_0x8 + r29);
|
||||
if (param_1 >= puVar2[0]) {
|
||||
return false;
|
||||
}
|
||||
@@ -55,7 +56,8 @@ int JAUSeqDataMgr_SeqCollection::releaseSeqData() {
|
||||
if (user_) {
|
||||
JAISeqDataRegion region;
|
||||
getSeqDataRegion(®ion);
|
||||
return user_->releaseSeqData(region);
|
||||
int result = user_->releaseSeqData(region);
|
||||
return result;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ u8* JAUSeqDataBlocks::getSeqData(JAISoundID param_0) {
|
||||
link = link->getNext())
|
||||
{
|
||||
if ((u32)link->getObject()->field_0x10 == (u32)param_0) {
|
||||
return link->getObject()->field_0x14.addr;
|
||||
return link->getObject()->region.addr;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -32,7 +32,7 @@ JSULink<JAUSeqDataBlock>* JAUSeqDataBlocks::seekFreeBlock(u32 size) {
|
||||
for (JSULink<JAUSeqDataBlock>* link = getFirst(); link != NULL; link = link->getNext())
|
||||
{
|
||||
if (link->getObject()->field_0x10.isAnonymous()) {
|
||||
u32 blockSize = link->getObject()->field_0x14.size;
|
||||
u32 blockSize = link->getObject()->region.size;
|
||||
if (blockSize >= size && blockSize < currentBlockSize) {
|
||||
rv = link;
|
||||
currentBlockSize = blockSize;
|
||||
@@ -54,8 +54,8 @@ bool JAUSeqDataBlocks::remove(JSULink<JAUSeqDataBlock>* param_0) {
|
||||
}
|
||||
|
||||
bool JAUSeqDataBlocks::hasFailedBlock(JAISoundID param_0) {
|
||||
JSULink<JAUSeqDataBlock>* rv = NULL;
|
||||
for (JSULink<JAUSeqDataBlock>* link = getFirst(); link != NULL; link = link->getNext())
|
||||
JSULink<JAUSeqDataBlock>* link;
|
||||
for (link = getFirst(); link != NULL; link = link->getNext())
|
||||
{
|
||||
if (link->getObject()->field_0x10 == param_0) {
|
||||
link->getObject()->field_0x10.setAnonymous();
|
||||
@@ -70,6 +70,7 @@ JAUDynamicSeqDataBlocks::JAUDynamicSeqDataBlocks() {
|
||||
}
|
||||
|
||||
void JAUDynamicSeqDataBlocks::setSeqDataArchive(JKRArchive* param_0) {
|
||||
JUT_ASSERT(104, seqDataArchive_ == NULL);
|
||||
seqDataArchive_ = param_0;
|
||||
}
|
||||
|
||||
@@ -98,17 +99,21 @@ s32 JAUDynamicSeqDataBlocks::getSeqData(JAISoundID param_0, JAISeqDataUser* para
|
||||
}
|
||||
|
||||
bool JAUDynamicSeqDataBlocks::appendDynamicSeqDataBlock(JAUSeqDataBlock* seqDataBlock) {
|
||||
JUT_ASSERT(135, ( reinterpret_cast < u32 > ( seqDataBlock->region.addr ) & 0x1f ) == 0);
|
||||
rearrangeLoadingSeqs_();
|
||||
bool result;
|
||||
if (seqDataBlock->field_0x10.isAnonymous()) {
|
||||
mFreeBlocks.append(&seqDataBlock->field_0x0);
|
||||
result = mFreeBlocks.append(&seqDataBlock->field_0x0);
|
||||
} else {
|
||||
mLoadedBlocks.append(&seqDataBlock->field_0x0);
|
||||
result = mLoadedBlocks.append(&seqDataBlock->field_0x0);
|
||||
}
|
||||
JUT_ASSERT(144, result);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void JAUDynamicSeqDataBlocks_receiveLoaded_(u32 param_0, u32 param_1) {
|
||||
JAUSeqDataBlock* seqDataBlock = ((JSULink<JAUSeqDataBlock>*)param_1)->getObject();
|
||||
JSULink<JAUSeqDataBlock>* link = (JSULink<JAUSeqDataBlock>*)param_1;
|
||||
JAUSeqDataBlock* seqDataBlock = link->getObject();
|
||||
if (param_0 != NULL) {
|
||||
seqDataBlock->field_0x1c = 2;
|
||||
} else {
|
||||
@@ -118,35 +123,38 @@ static void JAUDynamicSeqDataBlocks_receiveLoaded_(u32 param_0, u32 param_1) {
|
||||
|
||||
bool JAUDynamicSeqDataBlocks::loadDynamicSeq(JAISoundID param_0, bool param_1,
|
||||
JAISeqDataUser* param_2) {
|
||||
if (seqDataArchive_ == NULL) {
|
||||
return false;
|
||||
}
|
||||
JAUSoundInfo* soundInfo = JASGlobalInstance<JAUSoundInfo>::getInstance();
|
||||
if (soundInfo == NULL) {
|
||||
return false;
|
||||
}
|
||||
u16 resourceId = soundInfo->getBgmSeqResourceID(param_0);
|
||||
size_t resSize = JASResArcLoader::getResSize(seqDataArchive_, resourceId);
|
||||
JSULink<JAUSeqDataBlock>* link = mFreeBlocks.seekFreeBlock(resSize);
|
||||
if (link == NULL) {
|
||||
if (param_1) {
|
||||
link = &releaseIdleDynamicSeqDataBlock_(param_2, resSize)->field_0x0;
|
||||
if (link == NULL) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
{
|
||||
if (seqDataArchive_ == NULL) {
|
||||
JUT_WARN(192, "%s", "cannot get sequence data archive.");
|
||||
return false;
|
||||
}
|
||||
JAUSoundInfo* soundInfo = JASGlobalInstance<JAUSoundInfo>::getInstance();
|
||||
if (soundInfo == NULL) {
|
||||
JUT_WARN(198, "%s", "cannot JAUSoundInfo::getInstance().");
|
||||
return false;
|
||||
}
|
||||
u16 resourceId = soundInfo->getBgmSeqResourceID(param_0);
|
||||
size_t resSize = JASResArcLoader::getResSize(seqDataArchive_, resourceId);
|
||||
JSULink<JAUSeqDataBlock>* link = mFreeBlocks.seekFreeBlock(resSize);
|
||||
if (link == NULL) {
|
||||
if (param_1) {
|
||||
link = &releaseIdleDynamicSeqDataBlock_(param_2, resSize)->field_0x0;
|
||||
if (link == NULL) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
mFreeBlocks.remove(link);
|
||||
link->getObject()->field_0x10 = param_0;
|
||||
link->getObject()->field_0x1c = 1;
|
||||
field_0xc.append(link);
|
||||
JASResArcLoader::loadResourceAsync(
|
||||
seqDataArchive_, resourceId,
|
||||
link->getObject()->region.addr, link->getObject()->region.size,
|
||||
JAUDynamicSeqDataBlocks_receiveLoaded_, (u32)link);
|
||||
}
|
||||
mFreeBlocks.remove(link);
|
||||
JAUSeqDataBlock* seqDataBlock = link->getObject();
|
||||
seqDataBlock->field_0x10 = param_0;
|
||||
link->getObject()->field_0x1c = 1;
|
||||
field_0xc.append(link);
|
||||
JASResArcLoader::loadResourceAsync(
|
||||
seqDataArchive_, resourceId,
|
||||
link->getObject()->field_0x14.addr, link->getObject()->field_0x14.size,
|
||||
JAUDynamicSeqDataBlocks_receiveLoaded_, (u32)link);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,12 +165,12 @@ u32 JAUDynamicSeqDataBlocks::releaseIdleDynamicSeqDataBlock(JAISeqDataUser* para
|
||||
for (JSULink<JAUSeqDataBlock>* link = mLoadedBlocks.getFirst(); link != NULL; ) {
|
||||
nextLink = link->getNext();
|
||||
JAUSeqDataBlock* seqDataBlock = link->getObject();
|
||||
if (param_0 == NULL || !param_0->isUsingSeqData(seqDataBlock->field_0x14)) {
|
||||
if (param_0 == NULL || !param_0->isUsingSeqData(seqDataBlock->region)) {
|
||||
mLoadedBlocks.remove(link);
|
||||
JAUSeqDataBlock* seqDataBlock = link->getObject();
|
||||
link->getObject()->field_0x10.setAnonymous();
|
||||
if (size < seqDataBlock->field_0x14.size) {
|
||||
size = seqDataBlock->field_0x14.size;
|
||||
seqDataBlock->field_0x10.setAnonymous();
|
||||
if (size < seqDataBlock->region.size) {
|
||||
size = seqDataBlock->region.size;
|
||||
}
|
||||
mFreeBlocks.append(link);
|
||||
}
|
||||
@@ -181,8 +189,8 @@ JAUDynamicSeqDataBlocks::releaseIdleDynamicSeqDataBlock_(JAISeqDataUser* param_0
|
||||
while (link != NULL) {
|
||||
nextLink = link->getNext();
|
||||
JAUSeqDataBlock* seqDataBlock = link->getObject();
|
||||
if (param_0 == NULL || !param_0->isUsingSeqData(seqDataBlock->field_0x14)) {
|
||||
u32 size = seqDataBlock->field_0x14.size;
|
||||
if (param_0 == NULL || !param_0->isUsingSeqData(seqDataBlock->region)) {
|
||||
u32 size = seqDataBlock->region.size;
|
||||
if (size >= param_1 && size < minSize) {
|
||||
foundBlock = link;
|
||||
minSize = size;
|
||||
|
||||
@@ -7,18 +7,17 @@ JAUStreamFileTable::JAUStreamFileTable() {
|
||||
}
|
||||
|
||||
void JAUStreamFileTable::init(void const* data) {
|
||||
if (data == NULL) {
|
||||
const BinaryStreamFileTable* binaryTable = (const BinaryStreamFileTable*)data;
|
||||
if (binaryTable == NULL) {
|
||||
mData = NULL;
|
||||
return;
|
||||
}
|
||||
const BinaryStreamFileTable* binaryTable = (const BinaryStreamFileTable*)data;
|
||||
const char* ident = binaryTable->mIdentifier;
|
||||
if (ident[0] == 'b' && ident[1] == 's' && ident[2] == 'f' && ident[3] == 't') {
|
||||
if (binaryTable->mIdentifier[0] == 'b' && binaryTable->mIdentifier[1] == 's' && binaryTable->mIdentifier[2] == 'f' && binaryTable->mIdentifier[3] == 't') {
|
||||
mData = binaryTable;
|
||||
}
|
||||
}
|
||||
|
||||
int JAUStreamFileTable::getNumFiles() const {
|
||||
u32 JAUStreamFileTable::getNumFiles() const {
|
||||
return mData->mNumFiles;
|
||||
}
|
||||
|
||||
@@ -26,8 +25,8 @@ const char* JAUStreamFileTable::getFilePath(int index) const {
|
||||
if (mData == NULL) {
|
||||
return 0;
|
||||
}
|
||||
ASSERT(index >= 0);
|
||||
ASSERT(index < getNumFiles());
|
||||
JUT_ASSERT(52, index >= 0);
|
||||
JUT_ASSERT(53, index < getNumFiles());
|
||||
char* data = (char*)mData;
|
||||
return (char*)(data + *(int*)(data + 8 + (index * sizeof(s32))));
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ extern "C" void __DSP_remove_task(DSPTaskInfo* task);
|
||||
|
||||
static void Dsp_Update_Request();
|
||||
|
||||
/* 80451308 0001+00 data_80451308 None */
|
||||
/* 80451309 0003+00 data_80451309 None */
|
||||
static vu8 struct_80451308;
|
||||
static u8 struct_80451309;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "dolphin/gx.h"
|
||||
#include <dolphin/vi.h>
|
||||
#include "global.h"
|
||||
#include "stdint.h"
|
||||
#include <stdint>
|
||||
|
||||
void JFWDisplay::ctor_subroutine(bool enableAlpha) {
|
||||
mEnableAlpha = enableAlpha;
|
||||
|
||||
@@ -1,62 +1,81 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JGadget/binary.h"
|
||||
#include "JSystem/JGadget/define.h"
|
||||
#include <stdint>
|
||||
|
||||
const void*
|
||||
JGadget::binary::parseVariableUInt_16_32_following(void const* buffer, u32* param_1, u32* param_2,
|
||||
JGadget::binary::TEBit* param_3) {
|
||||
JGadget::binary::TEBit temp;
|
||||
if (param_3 == NULL) {
|
||||
param_3 = &temp;
|
||||
#if DEBUG
|
||||
static void dummyString() {
|
||||
// probably some stripped function that called JUT_ASSERT here
|
||||
DEAD_STRING("Halt");
|
||||
}
|
||||
#endif
|
||||
|
||||
const void* JGadget::binary::parseVariableUInt_16_32_following(const void* pBuffer, u32* pu32First, u32* pu32Second,
|
||||
JGadget::binary::TEBit* pTEBit) {
|
||||
u16* pu16 = (u16*)pBuffer;
|
||||
JUT_ASSERT(122, pu16!=NULL);
|
||||
JUT_ASSERT(123, pu32First!=NULL);
|
||||
JUT_ASSERT(124, pu32Second!=NULL);
|
||||
|
||||
JGadget::binary::TEBit spC;
|
||||
if (pTEBit == NULL) {
|
||||
pTEBit = &spC;
|
||||
}
|
||||
u32 uVar1 = *(u16*)buffer;
|
||||
const void* rv;
|
||||
if ((uVar1 & 0x8000) == 0) {
|
||||
param_3->value = 0x10;
|
||||
*param_1 = uVar1;
|
||||
*param_2 = *(u16*)((u8*)buffer + 2);
|
||||
rv = (u8*)buffer + 4;
|
||||
|
||||
u32 var_r30 = *pu16;
|
||||
if ((var_r30 & 0x8000) == 0) {
|
||||
pTEBit->value = 0x10;
|
||||
|
||||
*pu32First = var_r30;
|
||||
pu16++;
|
||||
*pu32Second = *pu16;
|
||||
|
||||
return pu16 + 1;
|
||||
} else {
|
||||
param_3->value = 0x20;
|
||||
uVar1 <<= 16;
|
||||
uVar1 &= 0x7fff0000;
|
||||
uVar1 |= *(u16*)((u8*)buffer + 2);
|
||||
*param_1 = uVar1;
|
||||
*param_2 = *(u32*)((u8*)buffer + 4);
|
||||
rv = (u8*)buffer + 8;
|
||||
pTEBit->value = 0x20;
|
||||
|
||||
var_r30 &= 0x7FFF;
|
||||
var_r30 <<= 16;
|
||||
pu16++;
|
||||
var_r30 |= *pu16;
|
||||
|
||||
*pu32First = var_r30;
|
||||
pu16++;
|
||||
*pu32Second = *(u32*)pu16;
|
||||
|
||||
return pu16 + 2;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
JGadget::binary::TParse_header_block::~TParse_header_block() {
|
||||
}
|
||||
JGadget::binary::TParse_header_block::~TParse_header_block() {}
|
||||
|
||||
bool JGadget::binary::TParse_header_block::parse_next(void const** ptrLocation, u32 idx) {
|
||||
u32 headerEnd, blockEnd;
|
||||
bool JGadget::binary::TParse_header_block::parse_next(const void** ppData_inout, u32 idx) {
|
||||
u32 uBlock, uData;
|
||||
|
||||
if ((ptrLocation == NULL) || (*ptrLocation == NULL)) {
|
||||
if (ppData_inout == NULL || *ppData_inout == NULL) {
|
||||
JGADGET_WARNMSG(172, "data not specified");
|
||||
return false;
|
||||
}
|
||||
bool check, checkLastBlock;
|
||||
checkLastBlock = check = false;
|
||||
|
||||
check = checkNext(ptrLocation, &headerEnd, idx);
|
||||
|
||||
checkLastBlock = check;
|
||||
if (!(idx & 1) && (check == false)) {
|
||||
return check;
|
||||
bool var_r29 = true;
|
||||
var_r29 = parseHeader_next(ppData_inout, &uBlock, idx) && var_r29;
|
||||
|
||||
if (!(idx & 1) && !var_r29) {
|
||||
return var_r29;
|
||||
}
|
||||
|
||||
while (headerEnd > 0) {
|
||||
check = false;
|
||||
if (parseBlock_next(ptrLocation, &blockEnd, idx) && checkLastBlock) {
|
||||
check = true;
|
||||
while (uBlock > 0) {
|
||||
const void* p = *ppData_inout;
|
||||
var_r29 = parseBlock_next(ppData_inout, &uData, idx) && var_r29;
|
||||
|
||||
JUT_ASSERT(192, std::uintptr_t(*ppData_inout)==std::uintptr_t(p)+uData);
|
||||
|
||||
if ((idx & 2) == 0 && !var_r29) {
|
||||
return var_r29;
|
||||
}
|
||||
checkLastBlock = check;
|
||||
if (((idx & 2) == 0) && (check == false)) {
|
||||
return check;
|
||||
}
|
||||
headerEnd--;
|
||||
uBlock--;
|
||||
}
|
||||
return checkLastBlock;
|
||||
|
||||
return var_r29;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JGadget/define.h"
|
||||
|
||||
#define MSL_USE_INLINES 1
|
||||
#include <ctype>
|
||||
|
||||
JGadget_outMessage::JGadget_outMessage(MessageFunc fn, const char* file, int line) {
|
||||
mMsgFunc = fn;
|
||||
mFile = file;
|
||||
mLine = line;
|
||||
|
||||
mWrite_p = mBuffer;
|
||||
*mWrite_p = 0;
|
||||
}
|
||||
|
||||
JGadget_outMessage::~JGadget_outMessage() {
|
||||
for (u8* p = (u8*)mBuffer; p != (u8*)mWrite_p; p++) {
|
||||
char c = *p;
|
||||
if (!isprint(c) && !isspace(c)) {
|
||||
*p = '_';
|
||||
}
|
||||
}
|
||||
|
||||
mMsgFunc(mFile, mLine, mBuffer);
|
||||
}
|
||||
|
||||
JGadget_outMessage& JGadget_outMessage::operator<<(const char* sz) {
|
||||
JUT_ASSERT(99, sz!=NULL);
|
||||
|
||||
while (*sz != 0 && mWrite_p < mBuffer + (BUFFER_SIZE - 1)) {
|
||||
*mWrite_p = *sz;
|
||||
mWrite_p++;
|
||||
sz++;
|
||||
}
|
||||
|
||||
*mWrite_p = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
JGadget_outMessage& JGadget_outMessage::operator<<(char c) {
|
||||
char sz[2];
|
||||
sz[0] = c;
|
||||
sz[1] = 0;
|
||||
|
||||
return *this << sz;
|
||||
}
|
||||
|
||||
JGadget_outMessage& JGadget_outMessage::operator<<(s32 value) {
|
||||
char sz[64];
|
||||
snprintf(sz, 64, "%d", value);
|
||||
|
||||
return *this << sz;
|
||||
}
|
||||
|
||||
JGadget_outMessage& JGadget_outMessage::operator<<(u32 value) {
|
||||
char sz[64];
|
||||
snprintf(sz, 64, "%u", value);
|
||||
|
||||
return *this << sz;
|
||||
}
|
||||
|
||||
JGadget_outMessage& JGadget_outMessage::operator<<(const void* data) {
|
||||
char sz[64];
|
||||
snprintf(sz, 64, "%p", data);
|
||||
|
||||
return *this << sz;
|
||||
}
|
||||
|
||||
void JGadget_outMessage::warning(const char* file, int line, const char* message) {
|
||||
JUTAssertion::setWarningMessage(3, (char*)file, line, message);
|
||||
}
|
||||
@@ -22,9 +22,6 @@ JGadget::TNodeLinkList::erase(JGadget::TNodeLinkList::iterator it) {
|
||||
return erase(it, next);
|
||||
}
|
||||
|
||||
/* 802DCAA0-802DCB08 2D73E0 0068+00 1/1 0/0 0/0 .text
|
||||
* erase__Q27JGadget13TNodeLinkListFQ37JGadget13TNodeLinkList8iteratorQ37JGadget13TNodeLinkList8iterator
|
||||
*/
|
||||
JGadget::TNodeLinkList::iterator JGadget::TNodeLinkList::erase(iterator a, iterator b) {
|
||||
TLinkListNode* cur = a.node;
|
||||
TLinkListNode* end = b.node;
|
||||
@@ -38,9 +35,6 @@ JGadget::TNodeLinkList::iterator JGadget::TNodeLinkList::erase(iterator a, itera
|
||||
return b;
|
||||
}
|
||||
|
||||
/* 802DCB08-802DCBA8 2D7448 00A0+00 1/1 0/0 0/0 .text
|
||||
* splice__Q27JGadget13TNodeLinkListFQ37JGadget13TNodeLinkList8iteratorRQ27JGadget13TNodeLinkListQ37JGadget13TNodeLinkList8iterator
|
||||
*/
|
||||
void JGadget::TNodeLinkList::splice(iterator it, TNodeLinkList& rSrc, iterator itSrc) {
|
||||
iterator itSrcNext = itSrc;
|
||||
++itSrcNext;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JGadget/search.h"
|
||||
|
||||
const char* JGadget::toStringFromIndex(int index, const char* const* pValue, u32 count, const char* fallback) {
|
||||
return toValueFromIndex<const char*>(index, pValue, count, fallback);
|
||||
}
|
||||
|
||||
int JGadget::toIndexFromString_linear(const char* sz, const char* const* pValue, u32 count, int fallback) {
|
||||
JUT_ASSERT(29, sz!=NULL);
|
||||
return toIndexFromValue_linear_if<const char*, search::TPR1IsEqual_string_>(
|
||||
search::TPR1IsEqual_string_(sz), pValue, count, fallback);
|
||||
}
|
||||
@@ -0,0 +1,413 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JGadget/std-stream.h"
|
||||
#include "JSystem/JGadget/define.h"
|
||||
#include <ctype>
|
||||
#include <float.h>
|
||||
|
||||
namespace JGadget {
|
||||
namespace {
|
||||
namespace floatingpoint_ {
|
||||
int classify(double x) {
|
||||
int fp = __fpclassifyd(x);
|
||||
switch (fp) {
|
||||
case FP_ZERO:
|
||||
return 1;
|
||||
case FP_SUBNORMAL:
|
||||
return 2;
|
||||
case FP_NORMAL:
|
||||
return 3;
|
||||
case FP_INFINITE:
|
||||
return 4;
|
||||
case FP_QNAN:
|
||||
return 5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TStream_base::~TStream_base() {}
|
||||
TStream::~TStream() {}
|
||||
|
||||
void TStream::init(TStreamBuffer* psb) {
|
||||
Init_();
|
||||
state_ = 0;
|
||||
rdbuf_ = psb;
|
||||
fill_ = widen(' ');
|
||||
|
||||
JUT_ASSERT(126, rdbuf()==psb);
|
||||
JUT_ASSERT(127, flags()==(skipws|dec));
|
||||
JUT_ASSERT(128, width()==0);
|
||||
JUT_ASSERT(129, precision()==6);
|
||||
JUT_ASSERT(130, fill()==' ');
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TInputStream::sentry::sentry(TInputStream& stream, bool param_1) {
|
||||
_0x0 = stream._0x0->good();
|
||||
if (!_0x0) {
|
||||
stream._0x0->setstate(2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!param_1 && (stream._0x0->flags() & TStream_base::dec)) {
|
||||
TStreamBuffer* rdbuf = stream._0x0->rdbuf();
|
||||
int var_r28 = rdbuf->sgetc();
|
||||
|
||||
while (true) {
|
||||
var_r28 = rdbuf->snextc();
|
||||
|
||||
if (TTrait_char<char>::eq_int_type(var_r28, TTrait_char<char>::eof())) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isspace(TTrait_char<char>::to_char_type(var_r28))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_0x0 = stream._0x0->good();
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TInputStream::~TInputStream() {}
|
||||
|
||||
int TInputStream::get() {
|
||||
int var_r29;
|
||||
int var_r28 = TTrait_char<char>::eof();
|
||||
field_0x8 = 0;
|
||||
|
||||
var_r29 = var_r28;
|
||||
sentry entry(*this, true);
|
||||
if (entry) {
|
||||
TStreamBuffer* var_r26 = _0x0->rdbuf();
|
||||
int var_r27 = 0;
|
||||
|
||||
var_r29 = var_r26->sbumpc();
|
||||
if (TTrait_char<char>::eq_int_type(var_r29, var_r28)) {
|
||||
var_r27 |= 0x3;
|
||||
} else {
|
||||
field_0x8++;
|
||||
}
|
||||
}
|
||||
|
||||
return var_r29;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream::~TOutputStream() {}
|
||||
|
||||
void TOutputStream::flush() {}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(const char* param_0) {
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(param_0, TTrait_char<char>::length(param_0));
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(char param_0) {
|
||||
char sz[2];
|
||||
sz[0] = param_0;
|
||||
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(sz, 1);
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(s32 param_0) {
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(param_0);
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(u32 param_0) {
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(param_0);
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(bool param_0) {
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(param_0);
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream& TOutputStream::operator<<(double param_0) {
|
||||
sentry entry(*this);
|
||||
if (entry) {
|
||||
TBufferIterator& sp8 = Put(param_0);
|
||||
if (TBufferIterator(sp8).failed()) {
|
||||
_0x0->setstate(6);
|
||||
}
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// NONMATCHING
|
||||
TOutputStream::TBufferIterator& TOutputStream::Put(double param_0) {
|
||||
u32 flags = _0x0->flags();
|
||||
|
||||
const saoCaseNumeral_struct& sp24 = getCaseNumeral_(flags);
|
||||
|
||||
const TCString_* var_r28 = &saoszPrefix_sign_[0];
|
||||
if (param_0 < 0.0f) {
|
||||
var_r28 = &saoszPrefix_sign_[2];
|
||||
param_0 = -param_0;
|
||||
} else if (flags & 0x1000) {
|
||||
var_r28 = &saoszPrefix_sign_[1];
|
||||
}
|
||||
|
||||
TCString_ sp30;
|
||||
int sp1C = floatingpoint_::classify(param_0);
|
||||
switch (sp1C) {
|
||||
case 5:
|
||||
sp30 = sp24._3;
|
||||
break;
|
||||
case 4:
|
||||
sp30 = sp24._2;
|
||||
break;
|
||||
default:
|
||||
char sp28[8];
|
||||
char* var_r30 = sp28;
|
||||
|
||||
*var_r30 = '%';
|
||||
if (flags & 0x800) {
|
||||
*++var_r30 = '#';
|
||||
}
|
||||
*++var_r30 = '.';
|
||||
*++var_r30 = '*';
|
||||
|
||||
static const char pcFormat[] = "gGffeE";
|
||||
const char* var_r29 = pcFormat;
|
||||
|
||||
u32 sp18 = flags & 0xF0000000;
|
||||
switch (sp18) {
|
||||
case 0:
|
||||
break;
|
||||
case 0x10000000:
|
||||
var_r29 += 2;
|
||||
break;
|
||||
case 0x20000000:
|
||||
var_r29 += 4;
|
||||
break;
|
||||
default:
|
||||
JGADGET_WARNMSG1(580, "illegal float-field : ", sp18);
|
||||
bool sp9 = false;
|
||||
}
|
||||
|
||||
if (flags & 4) {
|
||||
var_r29++;
|
||||
}
|
||||
|
||||
*++var_r30 = *var_r29;
|
||||
*++var_r30 = 0;
|
||||
|
||||
char sp38[64];
|
||||
int sp14 = snprintf(sp38, 64, sp28, param_0, _0x0->precision());
|
||||
sp30.sz = sp38;
|
||||
|
||||
int sp10;
|
||||
bool sp8 = sp14 >= 0 && (u32)sp14 < 64;
|
||||
if (sp8) {
|
||||
sp10 = sp14;
|
||||
} else {
|
||||
JUT_ASSERT(590, false);
|
||||
int spC = 0x3F;
|
||||
sp10 = spC;
|
||||
}
|
||||
|
||||
sp30.len = sp10;
|
||||
}
|
||||
|
||||
return Put_CString_prefixed_(sp30.sz, sp30.len, var_r28->sz, var_r28->len);
|
||||
}
|
||||
|
||||
TOutputStream::TBufferIterator& TOutputStream::Put_CString_prefixed_(const char* param_0, u32 param_1, const char* param_2, u32 param_3) {
|
||||
TBufferIterator sp8(_0x0->rdbuf());
|
||||
if (sp8.failed()) {
|
||||
return sp8;
|
||||
}
|
||||
|
||||
u32 flags = _0x0->flags();
|
||||
char fill = _0x0->fill();
|
||||
s32 width = _0x0->width();
|
||||
|
||||
s32 var_r26 = param_1 + param_3;
|
||||
s32 var_r31 = 0;
|
||||
if (width > var_r26) {
|
||||
var_r31 = width - var_r26;
|
||||
}
|
||||
|
||||
if (!(flags & 0x50000)) {
|
||||
while (var_r31 != 0) {
|
||||
*sp8 = fill;
|
||||
var_r31--;
|
||||
++sp8;
|
||||
}
|
||||
}
|
||||
|
||||
while (param_3 != 0) {
|
||||
*sp8 = *param_2;
|
||||
param_3--;
|
||||
param_2++;
|
||||
++sp8;
|
||||
}
|
||||
|
||||
if (flags & 0x40000) {
|
||||
while (var_r31 != 0) {
|
||||
*sp8 = fill;
|
||||
var_r31--;
|
||||
++sp8;
|
||||
}
|
||||
}
|
||||
|
||||
while (param_1 != 0) {
|
||||
*sp8 = *param_0;
|
||||
param_1--;
|
||||
param_0++;
|
||||
++sp8;
|
||||
}
|
||||
|
||||
if (flags & 0x10000) {
|
||||
while (var_r31 != 0) {
|
||||
*sp8 = fill;
|
||||
var_r31--;
|
||||
++sp8;
|
||||
}
|
||||
}
|
||||
|
||||
_0x0->width(0);
|
||||
return sp8;
|
||||
}
|
||||
|
||||
// NONMATCHING - stack
|
||||
TOutputStream::TBufferIterator& TOutputStream::Put_longInt_(u32 param_0, bool param_1) {
|
||||
bool spC = false;
|
||||
|
||||
char buf[33];
|
||||
char* pbufBegin = buf;
|
||||
char* pbufEnd = &buf[32];
|
||||
char* pbuf = pbufEnd;
|
||||
|
||||
u32 flags = _0x0->flags();
|
||||
|
||||
const saoCaseNumeral_struct& sp20 = getCaseNumeral_(flags);
|
||||
const char* sp1C = sp20._0;
|
||||
int sp18 = 10;
|
||||
|
||||
const TCString_* var_r29 = &saoszPrefix_sign_[0];
|
||||
|
||||
u32 sp14 = flags & 0xFC00000;
|
||||
switch (sp14) {
|
||||
case 0x400000:
|
||||
if (param_1) {
|
||||
int sp10 = param_0;
|
||||
if (sp10 < 0) {
|
||||
var_r29 = &saoszPrefix_sign_[2];
|
||||
param_0 = -sp10;
|
||||
} else if (flags & 0x1000) {
|
||||
var_r29 = &saoszPrefix_sign_[1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0x800000:
|
||||
sp18 = 0x10;
|
||||
if (param_0 != 0 && (flags & 0x400)) {
|
||||
var_r29 = &sp20._1;
|
||||
}
|
||||
break;
|
||||
case 0x1000000:
|
||||
sp18 = 8;
|
||||
if (param_0 != 0 && (flags & 0x400)) {
|
||||
var_r29 = &soszPrefix_oct_;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
JGADGET_WARNMSG1(737, "illegal base-field : ", sp14);
|
||||
bool spA = false;
|
||||
}
|
||||
|
||||
if (param_0 == 0) {
|
||||
pbuf--;
|
||||
*pbuf = TStream::widen('0');
|
||||
} else {
|
||||
do {
|
||||
pbuf--;
|
||||
*pbuf = TStream::widen(sp1C[param_0 % sp18]);
|
||||
param_0 /= sp18;
|
||||
} while (param_0 != 0);
|
||||
}
|
||||
|
||||
JUT_ASSERT(737, (pbufBegin<=pbuf)&&(pbuf<pbufEnd));
|
||||
return Put_CString_prefixed_(pbuf, pbufEnd - pbuf, var_r29->sz, var_r29->len);
|
||||
}
|
||||
|
||||
const TOutputStream::saoCaseNumeral_struct TOutputStream::saoCaseNumeral_[2] = {
|
||||
{
|
||||
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'},
|
||||
{"0x", 2},
|
||||
{"inf", 3},
|
||||
{"nan", 3},
|
||||
},
|
||||
{
|
||||
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'},
|
||||
{"0X", 2},
|
||||
{"INF", 3},
|
||||
{"NAN", 3},
|
||||
},
|
||||
};
|
||||
|
||||
const TOutputStream::TCString_ TOutputStream::saoszPrefix_sign_[3] = {
|
||||
{"", 0},
|
||||
{"+", 1},
|
||||
{"-", 1},
|
||||
};
|
||||
|
||||
const TOutputStream::TCString_ TOutputStream::saaosz_bool_[2][2] = {
|
||||
{{"0", 1}, {"1", 1}},
|
||||
{{"false", 5}, {"true", 4}},
|
||||
};
|
||||
|
||||
const TOutputStream::TCString_ TOutputStream::soszPrefix_oct_ = {"0", 1};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JGadget/std-streambuf.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace JGadget {
|
||||
TStreamBuffer::~TStreamBuffer() {}
|
||||
|
||||
void TStreamBuffer::setbuf(char*, s32) {}
|
||||
|
||||
s32 TStreamBuffer::sync() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TStreamBuffer::underflow() {
|
||||
return TTrait_char<char>::eof();
|
||||
}
|
||||
|
||||
int TStreamBuffer::uflow() {
|
||||
int var_r30 = TTrait_char<char>::eof();
|
||||
int var_r29;
|
||||
|
||||
if (TTrait_char<char>::eq_int_type(underflow(), var_r30)) {
|
||||
return var_r30;
|
||||
}
|
||||
|
||||
var_r29 = TTrait_char<char>::to_int_type(*pCurrent_get_);
|
||||
pCurrent_get_++;
|
||||
return var_r29;
|
||||
}
|
||||
|
||||
s32 TStreamBuffer::xsputn(const char* param_0, s32 param_1) {
|
||||
s32 var_r29 = std::min(param_1, pEnd_put_ - pCurrent_put_);
|
||||
if (var_r29 > 0) {
|
||||
const char* var_r27 = param_0 + var_r29;
|
||||
JUT_ASSERT(70, pCurrent_put_!=NULL);
|
||||
pCurrent_put_ = std::copy<char>(param_0, var_r27, pCurrent_put_);
|
||||
param_0 = var_r27;
|
||||
param_1 -= var_r29;
|
||||
}
|
||||
|
||||
while (param_1 > 0) {
|
||||
if (TTrait_char<char>::eq_int_type(sputc(*param_0), TTrait_char<char>::eof())) {
|
||||
break;
|
||||
}
|
||||
|
||||
param_1--;
|
||||
param_0++;
|
||||
var_r29++;
|
||||
s32 var_r25 = var_r29;
|
||||
}
|
||||
|
||||
return var_r29;
|
||||
}
|
||||
|
||||
int TStreamBuffer::overflow(int) {
|
||||
return TTrait_char<char>::eof();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
static void dummy() {
|
||||
u32 a = 0;
|
||||
u32 b = 1;
|
||||
std::min<u32>(a, b);
|
||||
}
|
||||
@@ -3,11 +3,8 @@
|
||||
#include "JSystem/JHostIO/JHIMccBuf.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JHostIO/JHIRMcc.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <cstring.h>
|
||||
|
||||
extern "C" int HIO2Read(u32, u32, void*, u32);
|
||||
extern "C" int HIO2Write(u32, u32, void*, u32);
|
||||
#include <revolution/hio2.h>
|
||||
#include <string>
|
||||
|
||||
void JHIReport(const char* fmt, ...) {}
|
||||
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/JHostIO/JHIMccBuf.h"
|
||||
#include <revolution/hio2.h>
|
||||
|
||||
enum HIO2DeviceType {
|
||||
DEVICE_INVALID = -1,
|
||||
};
|
||||
|
||||
typedef BOOL (*HIO2EnumCallback)(HIO2DeviceType);
|
||||
typedef void (*HIO2DisconnectCallback)(s32);
|
||||
|
||||
extern "C" BOOL HIO2Init();
|
||||
extern "C" BOOL HIO2EnumDevices(HIO2EnumCallback);
|
||||
extern "C" BOOL HIO2Close(s32);
|
||||
extern "C" s32 HIO2Open(HIO2DeviceType, int, HIO2DisconnectCallback);
|
||||
|
||||
HIO2DeviceType gExiDevice = DEVICE_INVALID;
|
||||
HIO2DeviceType gExiDevice = HIO2_DEVICE_INVALID;
|
||||
u8 data_8074bd04 = 1;
|
||||
|
||||
s32 ghHIO2;
|
||||
@@ -29,7 +18,7 @@ BOOL JHIhio2CallbackEnum(HIO2DeviceType type) {
|
||||
}
|
||||
|
||||
void JHIhio2DisconnectCallback(s32) {
|
||||
gExiDevice = DEVICE_INVALID;
|
||||
gExiDevice = HIO2_DEVICE_INVALID;
|
||||
}
|
||||
|
||||
u32 JHIInitInterface() {
|
||||
@@ -45,7 +34,7 @@ u32 JHIInitInterface() {
|
||||
data_8074bd04 = 0;
|
||||
}
|
||||
|
||||
if (gExiDevice == DEVICE_INVALID) {
|
||||
if (gExiDevice == HIO2_DEVICE_INVALID) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "JSystem/JHostIO/JORFile.h"
|
||||
#include "JSystem/JHostIO/JORHostInfo.h"
|
||||
#include "JSystem/JSupport/JSUMemoryStream.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
void JOREventCallbackListNode::JORAppend() {
|
||||
JORServer* pServer = JORServer::getInstance();
|
||||
|
||||
@@ -8,7 +8,13 @@
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include "dolphin/ar.h"
|
||||
#include <dolphin/os.h>
|
||||
#include "string.h"
|
||||
#include <string>
|
||||
|
||||
#if PLATFORM_GCN
|
||||
const u32 stack_size = 0xc00;
|
||||
#else
|
||||
const u32 stack_size = 0x4000;
|
||||
#endif
|
||||
|
||||
static u8* firstSrcData();
|
||||
static u8* nextSrcData(u8* param_0);
|
||||
@@ -21,7 +27,7 @@ JKRAram* JKRAram::sAramObject;
|
||||
JKRAram* JKRAram::create(u32 aram_audio_buffer_size, u32 aram_audio_graph_size, s32 stream_priority,
|
||||
s32 decomp_priority, s32 piece_priority) {
|
||||
if (!sAramObject) {
|
||||
sAramObject = new (JKRHeap::getSystemHeap(), 0)
|
||||
sAramObject = new (JKRGetSystemHeap(), 0)
|
||||
JKRAram(aram_audio_buffer_size, aram_audio_graph_size, piece_priority);
|
||||
}
|
||||
|
||||
@@ -41,11 +47,12 @@ OSMessage JKRAram::sMessageBuffer[4] = {
|
||||
OSMessageQueue JKRAram::sMessageQueue = {0};
|
||||
|
||||
JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, s32 priority)
|
||||
: JKRThread(0xC00, 0x10, priority) {
|
||||
: JKRThread(stack_size, 0x10, priority) {
|
||||
u32 aramBase = ARInit(mStackArray, ARRAY_SIZEU(mStackArray));
|
||||
ARQInit();
|
||||
|
||||
u32 aramSize = ARGetSize();
|
||||
OS_REPORT("ARAM size = %08x\n", aramSize);
|
||||
|
||||
mAudioMemorySize = audio_buffer_size;
|
||||
if (audio_graph_size == 0xFFFFFFFF) {
|
||||
@@ -65,7 +72,11 @@ JKRAram::JKRAram(u32 audio_buffer_size, u32 audio_graph_size, s32 priority)
|
||||
mAramMemoryPtr = NULL;
|
||||
}
|
||||
|
||||
mAramHeap = new (JKRHeap::getSystemHeap(), 0) JKRAramHeap(mGraphMemoryPtr, mGraphMemorySize);
|
||||
OS_REPORT("ARAM audio area %08x: %08x\n", mAudioMemoryPtr, mAudioMemorySize);
|
||||
OS_REPORT("ARAM graph area %08x: %08x\n", mGraphMemoryPtr, mGraphMemorySize);
|
||||
OS_REPORT("ARAM user area %08x: %08x\n", mAramMemoryPtr, mAramMemorySize);
|
||||
|
||||
mAramHeap = new (JKRGetSystemHeap(), 0) JKRAramHeap(mGraphMemoryPtr, mGraphMemorySize);
|
||||
}
|
||||
|
||||
JKRAram::~JKRAram() {
|
||||
@@ -75,14 +86,13 @@ JKRAram::~JKRAram() {
|
||||
}
|
||||
|
||||
void* JKRAram::run(void) {
|
||||
int result;
|
||||
JKRAMCommand* command;
|
||||
JKRAramPiece::Message* message;
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 4);
|
||||
do {
|
||||
OSReceiveMessage(&sMessageQueue, (OSMessage*)&message, OS_MESSAGE_BLOCK);
|
||||
result = message->field_0x00;
|
||||
command = message->command;
|
||||
OSMessage msg;
|
||||
OSReceiveMessage(&sMessageQueue, &msg, OS_MESSAGE_BLOCK);
|
||||
JKRAramCommand* message = (JKRAramCommand*)msg;
|
||||
int result = message->field_0x00;
|
||||
JKRAMCommand* command = (JKRAMCommand*)message->command;
|
||||
delete message;
|
||||
|
||||
switch (result) {
|
||||
@@ -104,9 +114,9 @@ void JKRAram::checkOkAddress(u8* addr, u32 size, JKRAramBlock* block, u32 param_
|
||||
}
|
||||
|
||||
void JKRAram::changeGroupIdIfNeed(u8* data, int groupId) {
|
||||
JKRHeap* currentHeap = JKRHeap::getCurrentHeap();
|
||||
JKRHeap* currentHeap = JKRGetCurrentHeap();
|
||||
if (currentHeap->getHeapType() == 'EXPH' && groupId >= 0) {
|
||||
JKRExpHeap::CMemBlock* block = JKRExpHeap::CMemBlock::getBlock(data);
|
||||
JKRExpHeap::CMemBlock* block = (JKRExpHeap::CMemBlock*)(data - sizeof(JKRExpHeap::CMemBlock));
|
||||
block->newGroupId(groupId);
|
||||
}
|
||||
}
|
||||
@@ -127,54 +137,55 @@ JKRAramBlock* JKRAram::mainRamToAram(u8* buf, u32 bufSize, u32 alignedSize,
|
||||
fileSize = ALIGN_NEXT(expandSize, 32);
|
||||
}
|
||||
if (bufSize == 0) {
|
||||
JKRAramBlock* allocatedBlock =
|
||||
(JKRAramBlock*)JKRAllocFromAram(fileSize, JKRAramHeap::HEAD);
|
||||
block = (JKRAramBlock*)allocatedBlock;
|
||||
if (allocatedBlock == NULL)
|
||||
block = JKRAllocFromAram(fileSize, JKRAramHeap::HEAD);
|
||||
if (block == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
allocatedBlock->newGroupID(decideAramGroupId(id));
|
||||
bufSize = allocatedBlock->getAddress();
|
||||
block->newGroupID(decideAramGroupId(id));
|
||||
bufSize = block->getAddress();
|
||||
}
|
||||
if (alignedSize == 0 || alignedSize > expandSize)
|
||||
if (alignedSize == 0 || alignedSize > expandSize) {
|
||||
alignedSize = ALIGN_NEXT(expandSize, 32);
|
||||
}
|
||||
|
||||
if (alignedSize > fileSize)
|
||||
if (alignedSize > fileSize) {
|
||||
alignedSize = fileSize;
|
||||
}
|
||||
|
||||
void* allocatedMem = JKRAllocFromHeap(heap, fileSize, -32);
|
||||
if (allocatedMem == NULL) {
|
||||
if (block != NULL) {
|
||||
JKRFreeToAram(block);
|
||||
}
|
||||
block = NULL;
|
||||
} else {
|
||||
JKRDecompress(buf, (u8*)allocatedMem, fileSize, 0);
|
||||
JKRAramPcs(0, (uintptr_t)allocatedMem, bufSize, alignedSize, block);
|
||||
JKRFreeToHeap(heap, allocatedMem);
|
||||
block = block == NULL ? (JKRAramBlock*)-1 : block;
|
||||
if (pSize != NULL) {
|
||||
*pSize = alignedSize;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (fileSize != 0 && alignedSize > fileSize)
|
||||
alignedSize = fileSize;
|
||||
if (bufSize == 0) {
|
||||
JKRAramBlock* allocatedBlock =
|
||||
(JKRAramBlock*)JKRAllocFromAram(alignedSize, JKRAramHeap::HEAD);
|
||||
block = allocatedBlock;
|
||||
block->newGroupID(decideAramGroupId(id));
|
||||
if (block == NULL)
|
||||
return NULL;
|
||||
|
||||
bufSize = allocatedBlock->getAddress();
|
||||
}
|
||||
|
||||
JKRAramPcs(0, (uintptr_t)buf, bufSize, alignedSize, block);
|
||||
JKRDecompress(buf, (u8*)allocatedMem, fileSize, 0);
|
||||
JKRAramPcs(0, (uintptr_t)allocatedMem, bufSize, alignedSize, block);
|
||||
JKRFreeToHeap(heap, allocatedMem);
|
||||
block = block == NULL ? (JKRAramBlock*)-1 : block;
|
||||
if (pSize != NULL)
|
||||
if (pSize != NULL) {
|
||||
*pSize = alignedSize;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
if (fileSize != 0 && alignedSize > fileSize) {
|
||||
alignedSize = fileSize;
|
||||
}
|
||||
if (bufSize == 0) {
|
||||
block = JKRAllocFromAram(alignedSize, JKRAramHeap::HEAD);
|
||||
block->newGroupID(decideAramGroupId(id));
|
||||
if (block == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bufSize = block->getAddress();
|
||||
}
|
||||
|
||||
JKRAramPcs(0, (uintptr_t)buf, bufSize, alignedSize, block);
|
||||
block = block == NULL ? (JKRAramBlock*)-1 : block;
|
||||
if (pSize != NULL) {
|
||||
*pSize = alignedSize;
|
||||
}
|
||||
return block;
|
||||
}
|
||||
@@ -201,14 +212,13 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
if (p5 != 0 && p5 < expandSize)
|
||||
expandSize = p5;
|
||||
|
||||
if (buf == NULL)
|
||||
buf = (u8*)JKRAllocFromHeap(heap, expandSize, 32);
|
||||
if (buf == NULL)
|
||||
u8* r26 = !buf ? (u8*)JKRAllocFromHeap(heap, expandSize, 32) : buf;
|
||||
if (r26 == NULL)
|
||||
return NULL;
|
||||
else {
|
||||
changeGroupIdIfNeed(buf, id);
|
||||
JKRDecompressFromAramToMainRam(address, buf, p3, expandSize, 0, pSize);
|
||||
return buf;
|
||||
changeGroupIdIfNeed(r26, id);
|
||||
JKRDecompressFromAramToMainRam(address, r26, p3, expandSize, 0, pSize);
|
||||
return r26;
|
||||
}
|
||||
} else if (compression == COMPRESSION_YAY0) { // SZP
|
||||
u8* szpSpace = (u8*)JKRAllocFromHeap(heap, p3, -32);
|
||||
@@ -219,12 +229,7 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
if (p5 != 0 && p5 < expandSize)
|
||||
expandSize = p5;
|
||||
|
||||
u8* rv;
|
||||
if (buf == NULL) {
|
||||
rv = (u8*)JKRAllocFromHeap(heap, expandSize, 32);
|
||||
} else {
|
||||
rv = buf;
|
||||
}
|
||||
u8* rv = !buf ? (u8*)JKRAllocFromHeap(heap, expandSize, 32) : buf;
|
||||
|
||||
if (rv == NULL) {
|
||||
JKRFree(szpSpace);
|
||||
@@ -240,17 +245,16 @@ u8* JKRAram::aramToMainRam(u32 address, u8* buf, u32 p3, JKRExpandSwitch expandS
|
||||
}
|
||||
}
|
||||
} else { // Not compressed or ASR
|
||||
if (buf == NULL)
|
||||
buf = (u8*)JKRAllocFromHeap(heap, p3, 32);
|
||||
if (buf == NULL) {
|
||||
u8* r24 = !buf ? (u8*)JKRAllocFromHeap(heap, p3, 32) : buf;
|
||||
if (r24 == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
changeGroupIdIfNeed(buf, id);
|
||||
JKRAramPcs(1, address, (uintptr_t)buf, p3, NULL);
|
||||
changeGroupIdIfNeed(r24, id);
|
||||
JKRAramPcs(1, address, (uintptr_t)r24, p3, NULL);
|
||||
if (pSize != NULL) {
|
||||
*pSize = p3;
|
||||
}
|
||||
return buf;
|
||||
return r24;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,10 +307,12 @@ static int JKRDecompressFromAramToMainRam(u32 src, void* dst, u32 srcLength, u32
|
||||
|
||||
u32 szsBufferSize = JKRAram::getSZSBufferSize();
|
||||
szpBuf = (u8*)JKRAllocFromSysHeap(szsBufferSize, 32);
|
||||
JUT_ASSERT(1114, szpBuf != NULL);
|
||||
|
||||
szpEnd = szpBuf + szsBufferSize;
|
||||
if (offset != 0) {
|
||||
refBuf = (u8*)JKRAllocFromSysHeap(0x1120, 0);
|
||||
JUT_ASSERT(1123, refBuf != NULL)
|
||||
refEnd = refBuf + 0x1120;
|
||||
refCurrent = refBuf;
|
||||
} else {
|
||||
@@ -321,7 +327,8 @@ static int JKRDecompressFromAramToMainRam(u32 src, void* dst, u32 srcLength, u32
|
||||
tsPtr = (resourceSize != 0) ? resourceSize : &tsArea;
|
||||
*tsPtr = 0;
|
||||
|
||||
decompSZS_subroutine(firstSrcData(), (u8*)dst);
|
||||
u8* first = firstSrcData();
|
||||
int r25 = decompSZS_subroutine(first, (u8*)dst);
|
||||
JKRFree(szpBuf);
|
||||
if (refBuf) {
|
||||
JKRFree(refBuf);
|
||||
@@ -350,14 +357,17 @@ int decompSZS_subroutine(u8* src, u8* dest) {
|
||||
}
|
||||
|
||||
src += 0x10;
|
||||
s32 b1;
|
||||
u32 dist;
|
||||
s32 numBytes;
|
||||
u8* copySource;
|
||||
do {
|
||||
if (validBitCount == 0) {
|
||||
if ((src > srcLimit) && transLeft) {
|
||||
src = nextSrcData(src);
|
||||
}
|
||||
currCodeByte = *src;
|
||||
currCodeByte = *src++;
|
||||
validBitCount = 8;
|
||||
src++;
|
||||
}
|
||||
if (currCodeByte & 0x80) {
|
||||
if (fileOffset != 0) {
|
||||
@@ -375,9 +385,7 @@ int decompSZS_subroutine(u8* src, u8* dest) {
|
||||
}
|
||||
src++;
|
||||
} else {
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
*dest++ = *src++;
|
||||
ts++;
|
||||
if (dest == endPtr) {
|
||||
break;
|
||||
@@ -385,10 +393,10 @@ int decompSZS_subroutine(u8* src, u8* dest) {
|
||||
}
|
||||
readCount++;
|
||||
} else {
|
||||
u32 dist = ((src[0] & 0x0f) << 8) | src[1];
|
||||
s32 numBytes = src[0] >> 4;
|
||||
b1 = src[0];
|
||||
dist = src[1] | ((b1 & 0x0f) << 8);
|
||||
numBytes = b1 >> 4;
|
||||
src += 2;
|
||||
u8* copySource;
|
||||
if (fileOffset != 0) {
|
||||
copySource = refCurrent - dist - 1;
|
||||
if (copySource < refBuf) {
|
||||
@@ -398,8 +406,7 @@ int decompSZS_subroutine(u8* src, u8* dest) {
|
||||
copySource = dest - dist - 1;
|
||||
}
|
||||
if (numBytes == 0) {
|
||||
numBytes = *src + 0x12;
|
||||
src += 1;
|
||||
numBytes = (*src++) + 0x12;
|
||||
} else {
|
||||
numBytes += 2;
|
||||
}
|
||||
@@ -432,9 +439,9 @@ int decompSZS_subroutine(u8* src, u8* dest) {
|
||||
if (dest == endPtr) {
|
||||
break;
|
||||
}
|
||||
copySource++;
|
||||
readCount++;
|
||||
numBytes--;
|
||||
copySource++;
|
||||
} while (numBytes != 0);
|
||||
}
|
||||
}
|
||||
@@ -449,18 +456,10 @@ static u8* firstSrcData() {
|
||||
srcLimit = szpEnd - 0x19;
|
||||
u8* buffer = szpBuf;
|
||||
|
||||
u32 length;
|
||||
u32 size = szpEnd - szpBuf;
|
||||
if (transLeft < size) {
|
||||
length = transLeft;
|
||||
} else {
|
||||
length = size;
|
||||
}
|
||||
u32 size = szpEnd - buffer;
|
||||
u32 length = transLeft < size ? transLeft : size;
|
||||
|
||||
u32 src = (uintptr_t)(srcAddress + srcOffset);
|
||||
u32 dst = (uintptr_t)buffer;
|
||||
u32 alignedLength = ALIGN_NEXT(length, 0x20);
|
||||
JKRAramPcs(1, src, dst, alignedLength, NULL);
|
||||
JKRAramPcs(1, srcAddress + srcOffset, uintptr_t(buffer), ALIGN_NEXT(length, 0x20), NULL);
|
||||
|
||||
srcOffset += length;
|
||||
transLeft -= length;
|
||||
@@ -474,16 +473,18 @@ static u8* firstSrcData() {
|
||||
static u8* nextSrcData(u8* current) {
|
||||
u8* dest;
|
||||
u32 left = (uintptr_t)(szpEnd - current);
|
||||
if (IS_NOT_ALIGNED(left, 0x20))
|
||||
if (IS_NOT_ALIGNED(left, 0x20)) {
|
||||
dest = szpBuf + 0x20 - (left & (0x20 - 1));
|
||||
else
|
||||
} else {
|
||||
dest = szpBuf;
|
||||
}
|
||||
|
||||
memcpy(dest, current, left);
|
||||
u32 transSize = (uintptr_t)(szpEnd - (dest + left));
|
||||
if (transSize > transLeft)
|
||||
transSize = transLeft;
|
||||
|
||||
JUT_ASSERT(1403, transSize > 0);
|
||||
JKRAramPcs(1, (uintptr_t)(srcAddress + srcOffset), ((uintptr_t)dest + left), ALIGN_NEXT(transSize, 0x20),
|
||||
NULL);
|
||||
srcOffset += transSize;
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
#include "JSystem/JKernel/JKRDvdFile.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include "math.h"
|
||||
#include "string.h"
|
||||
#include <math>
|
||||
#include <string>
|
||||
|
||||
JKRAramArchive::JKRAramArchive() {}
|
||||
|
||||
JKRAramArchive::JKRAramArchive(s32 entryNumber, JKRArchive::EMountDirection mountDirection)
|
||||
: JKRArchive(entryNumber, MOUNT_ARAM) {
|
||||
@@ -28,10 +30,11 @@ JKRAramArchive::~JKRAramArchive() {
|
||||
if (mIsMounted == true) {
|
||||
if (mArcInfoBlock != NULL) {
|
||||
SDIFileEntry* entry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; entry++, i++) {
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (entry->data != NULL) {
|
||||
JKRFreeToHeap(mHeap, entry->data);
|
||||
}
|
||||
entry++;
|
||||
}
|
||||
|
||||
JKRFreeToHeap(mHeap, mArcInfoBlock);
|
||||
@@ -56,8 +59,42 @@ JKRAramArchive::~JKRAramArchive() {
|
||||
}
|
||||
}
|
||||
|
||||
inline u32 alignNext(u32 var, u32 align) {
|
||||
return (var + align - 1) & ~(align - 1);
|
||||
void JKRAramArchive::fixedInit(s32 entryNumber, JKRArchive::EMountDirection mountDirection) {
|
||||
mIsMounted = false;
|
||||
mMountDirection = mountDirection;
|
||||
mMountMode = 2;
|
||||
mMountCount = 1;
|
||||
field_0x58 = 2;
|
||||
mHeap = JKRHeap::getCurrentHeap();
|
||||
mEntryNum = entryNumber;
|
||||
if (sCurrentVolume == NULL) {
|
||||
sCurrentVolume = this;
|
||||
sCurrentDirID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL JKRAramArchive::mountFixed(s32 entryNumber, JKRArchive::EMountDirection mountDirection) {
|
||||
if (entryNumber < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
if (check_mount_already(entryNumber, JKRGetCurrentHeap())) {
|
||||
return FALSE;
|
||||
}
|
||||
fixedInit(entryNumber, mountDirection);
|
||||
if (!open(entryNumber)) {
|
||||
return FALSE;
|
||||
}
|
||||
mVolumeType = 'RARC';
|
||||
mVolumeName = mStringTable + mNodes->name_offset;
|
||||
sVolumeList.prepend(&mFileLoaderLink);
|
||||
mIsMounted = true;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void dummy() {
|
||||
OS_REPORT(__FILE__);
|
||||
OS_REPORT("isMounted()");
|
||||
OS_REPORT("mMountCount == 1");
|
||||
}
|
||||
|
||||
bool JKRAramArchive::open(s32 entryNum) {
|
||||
@@ -76,7 +113,8 @@ bool JKRAramArchive::open(s32 entryNum) {
|
||||
|
||||
// NOTE: a different struct is used here for sure, unfortunately i can't get any hits on this
|
||||
// address, so gonna leave it like this for now
|
||||
SArcHeader* mem = (SArcHeader*)JKRAllocFromSysHeap(32, -32);
|
||||
SArcHeader* mem = NULL;
|
||||
mem = (SArcHeader*)JKRAllocFromSysHeap(32, -32);
|
||||
if (mem == NULL) {
|
||||
mMountMode = 0;
|
||||
} else {
|
||||
@@ -104,7 +142,7 @@ bool JKRAramArchive::open(s32 entryNum) {
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
u8 flag = fileEntry->type_flags_and_name_offset >> 24;
|
||||
if ((flag & 1)) {
|
||||
compressedFiles |= (flag & JKRARCHIVE_ATTR_COMPRESSION);
|
||||
compressedFiles |= u8(flag & JKRARCHIVE_ATTR_COMPRESSION);
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
@@ -160,7 +198,7 @@ void* JKRAramArchive::fetchResource(SDIFileEntry* pEntry, u32* pOutSize) {
|
||||
pOutSize = &outSize;
|
||||
}
|
||||
|
||||
JKRCompression compression = JKRConvertAttrToCompressionType(pEntry->getFlags());
|
||||
JKRCompression compression = JKRConvertAttrToCompressionType(u8(pEntry->type_flags_and_name_offset >> 24));
|
||||
if (pEntry->data == NULL) {
|
||||
u32 size = JKRAramArchive::fetchResource_subroutine(
|
||||
pEntry->data_offset + mBlock->getAddress(), pEntry->data_size, mHeap, compression,
|
||||
@@ -194,7 +232,7 @@ void* JKRAramArchive::fetchResource(void* buffer, u32 bufferSize, SDIFileEntry*
|
||||
size = bufferSize;
|
||||
}
|
||||
|
||||
JKRCompression compression = JKRConvertAttrToCompressionType(pEntry->getFlags());
|
||||
JKRCompression compression = JKRConvertAttrToCompressionType(u8(pEntry->type_flags_and_name_offset >> 24));
|
||||
if (pEntry->data == NULL) {
|
||||
bufferSize = (s32)ALIGN_PREV(bufferSize, 0x20);
|
||||
size = JKRAramArchive::fetchResource_subroutine(pEntry->data_offset + mBlock->getAddress(),
|
||||
@@ -228,12 +266,13 @@ u32 JKRAramArchive::getAramAddress_Entry(SDIFileEntry* pEntry) {
|
||||
}
|
||||
|
||||
u32 JKRAramArchive::getAramAddress(char const* name) {
|
||||
return JKRAramArchive::getAramAddress_Entry(this->findFsResource(name, 0));
|
||||
SDIFileEntry* entry = this->findFsResource(name, 0);
|
||||
return JKRAramArchive::getAramAddress_Entry(entry);
|
||||
}
|
||||
|
||||
u32 JKRAramArchive::fetchResource_subroutine(u32 srcAram, u32 srcLength, u8* dst, u32 dstLength,
|
||||
int compression) {
|
||||
JUT_ASSERT(628, (srcAram & 0x1f) == 0);
|
||||
JUT_ASSERT(628, ( srcAram & 0x1f ) == 0);
|
||||
u32 outLen;
|
||||
u32 srcSize = ALIGN_NEXT(srcLength, 0x20);
|
||||
u32 dstSize = ALIGN_PREV(dstLength, 0x20);
|
||||
@@ -299,7 +338,8 @@ u32 JKRAramArchive::getExpandedResSize(const void* ptr) const {
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
if (entry->getCompressFlag() == 0) {
|
||||
u8 flags = entry->type_flags_and_name_offset >> 24;
|
||||
if ((flags & 4) == 0) {
|
||||
return this->getResSize(ptr);
|
||||
}
|
||||
|
||||
@@ -312,8 +352,8 @@ u32 JKRAramArchive::getExpandedResSize(const void* ptr) const {
|
||||
u8* buf = (u8*)ALIGN_PREV((s32)&tmpBuf[0x1F], 0x20);
|
||||
JKRAramToMainRam(entry->data_offset + mBlock->getAddress(), buf, 0x20, EXPAND_SWITCH_UNKNOWN0,
|
||||
0, NULL, -1, NULL);
|
||||
expandSize = JKRDecompExpandSize(buf);
|
||||
u32 expandSize2 = JKRDecompExpandSize(buf);
|
||||
// ??? casting away const?
|
||||
((JKRArchive*)this)->setExpandSize(entry, expandSize);
|
||||
return expandSize;
|
||||
((JKRArchive*)this)->setExpandSize(entry, expandSize2);
|
||||
return expandSize2;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@ JKRAramBlock::~JKRAramBlock() {
|
||||
JSULink<JKRAramBlock>* prev = mBlockLink.getPrev();
|
||||
|
||||
if (prev) {
|
||||
JKRAramBlock* block = prev->getObject();
|
||||
block->mFreeSize = mSize + mFreeSize + block->mFreeSize;
|
||||
prev->getObject()->mFreeSize += mSize + mFreeSize;
|
||||
list->remove(&mBlockLink);
|
||||
} else {
|
||||
mFreeSize = mFreeSize + mSize;
|
||||
@@ -28,35 +27,24 @@ JKRAramBlock::~JKRAramBlock() {
|
||||
}
|
||||
|
||||
JKRAramBlock* JKRAramBlock::allocHead(u32 size, u8 groupId, JKRAramHeap* aramHeap) {
|
||||
u32 address = mAddress;
|
||||
u32 usedSize = mSize;
|
||||
u32 nextAddress = address + usedSize;
|
||||
u32 freeSize = mFreeSize;
|
||||
u32 nextFreeSize = freeSize - size;
|
||||
u32 nextAddress = mAddress + mSize;
|
||||
u32 nextFreeSize = mFreeSize - size;
|
||||
|
||||
JKRAramBlock* block = new (aramHeap->getMgrHeap(), 0)
|
||||
JKRAramBlock(nextAddress, size, nextFreeSize, groupId, false);
|
||||
|
||||
mFreeSize = 0;
|
||||
JSULink<JKRAramBlock>* next = mBlockLink.getNext();
|
||||
JSUList<JKRAramBlock>* list = mBlockLink.getSupervisor();
|
||||
list->insert(next, &block->mBlockLink);
|
||||
mBlockLink.getSupervisor()->insert(mBlockLink.getNext(), &block->mBlockLink);
|
||||
return block;
|
||||
}
|
||||
|
||||
JKRAramBlock* JKRAramBlock::allocTail(u32 size, u8 groupId, JKRAramHeap* aramHeap) {
|
||||
u32 freeSize = mFreeSize;
|
||||
u32 address = mAddress;
|
||||
u32 usedSize = mSize;
|
||||
u32 endAddress = address + usedSize + freeSize;
|
||||
u32 tailAddress = endAddress - size;
|
||||
u32 tailAddress = mAddress + mSize + mFreeSize - size;
|
||||
|
||||
JKRAramBlock* block =
|
||||
new (aramHeap->getMgrHeap(), 0) JKRAramBlock(tailAddress, size, 0, groupId, true);
|
||||
|
||||
mFreeSize -= size;
|
||||
JSULink<JKRAramBlock>* next = mBlockLink.getNext();
|
||||
JSUList<JKRAramBlock>* list = mBlockLink.getSupervisor();
|
||||
list->insert(next, &block->mBlockLink);
|
||||
mBlockLink.getSupervisor()->insert(mBlockLink.getNext(), &block->mBlockLink);
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "JSystem/JKernel/JKRAramHeap.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "global.h"
|
||||
#include <limits.h>
|
||||
#include <climits>
|
||||
|
||||
JSUList<JKRAramBlock> JKRAramHeap::sAramList;
|
||||
|
||||
@@ -21,11 +21,7 @@ JKRAramHeap::JKRAramHeap(u32 startAddress, u32 size) {
|
||||
}
|
||||
|
||||
JKRAramHeap::~JKRAramHeap() {
|
||||
JSUListIterator<JKRAramBlock> iterator(sAramList.getFirst());
|
||||
while (iterator != sAramList.getEnd())
|
||||
{
|
||||
delete (iterator++).getObject();
|
||||
}
|
||||
for (JSUListIterator<JKRAramBlock> iterator = sAramList.getFirst(); iterator != sAramList.getEnd(); delete (iterator++).getObject()) {}
|
||||
}
|
||||
|
||||
JKRAramBlock* JKRAramHeap::alloc(u32 size, JKRAramHeap::EAllocMode allocationMode) {
|
||||
@@ -47,18 +43,19 @@ JKRAramBlock* JKRAramHeap::allocFromHead(u32 size) {
|
||||
u32 bestFreeSize = UINT_MAX;
|
||||
JKRAramBlock* bestBlock = NULL;
|
||||
|
||||
JSUList<JKRAramBlock>* list = &sAramList;
|
||||
for (JSUListIterator<JKRAramBlock> iterator = list; iterator != list->getEnd(); ++iterator) {
|
||||
for (JSUListIterator<JKRAramBlock> iterator = sAramList.getFirst(); iterator != sAramList.getEnd(); ++iterator) {
|
||||
JKRAramBlock* block = iterator.getObject();
|
||||
if (block->mFreeSize < alignedSize)
|
||||
if (block->mFreeSize < alignedSize) {
|
||||
continue;
|
||||
if (bestFreeSize <= block->mFreeSize)
|
||||
}
|
||||
if (bestFreeSize <= block->mFreeSize) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bestFreeSize = block->mFreeSize;
|
||||
bestBlock = block;
|
||||
|
||||
if (block->mFreeSize == alignedSize) {
|
||||
if (bestFreeSize == alignedSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -74,9 +71,7 @@ JKRAramBlock* JKRAramHeap::allocFromTail(u32 size) {
|
||||
u32 alignedSize = ALIGN_NEXT(size, 0x20);
|
||||
JKRAramBlock* tailBlock = NULL;
|
||||
|
||||
JSUList<JKRAramBlock>* list = &sAramList;
|
||||
JSUListIterator<JKRAramBlock> iterator = list->getLast();
|
||||
for (; iterator != list->getEnd(); --iterator) {
|
||||
for (JSUListIterator<JKRAramBlock> iterator = sAramList.getLast(); iterator != sAramList.getEnd(); --iterator) {
|
||||
JKRAramBlock* block = iterator.getObject();
|
||||
if (block->mFreeSize >= alignedSize) {
|
||||
tailBlock = block;
|
||||
@@ -96,9 +91,7 @@ u32 JKRAramHeap::getFreeSize(void) {
|
||||
|
||||
lock();
|
||||
|
||||
JSUList<JKRAramBlock>* list = &sAramList;
|
||||
JSUListIterator<JKRAramBlock> iterator = list;
|
||||
for (; iterator != list->getEnd(); ++iterator) {
|
||||
for (JSUListIterator<JKRAramBlock> iterator = sAramList.getFirst(); iterator != sAramList.getEnd(); ++iterator) {
|
||||
if (iterator->mFreeSize > maxFreeSize) {
|
||||
maxFreeSize = iterator->mFreeSize;
|
||||
}
|
||||
@@ -113,9 +106,7 @@ u32 JKRAramHeap::getTotalFreeSize(void) {
|
||||
|
||||
lock();
|
||||
|
||||
JSUList<JKRAramBlock>* list = &sAramList;
|
||||
JSUListIterator<JKRAramBlock> iterator = list;
|
||||
for (; iterator != list->getEnd(); ++iterator) {
|
||||
for (JSUListIterator<JKRAramBlock> iterator = sAramList.getFirst(); iterator != sAramList.getEnd(); ++iterator) {
|
||||
totalFreeSize += iterator->mFreeSize;
|
||||
}
|
||||
|
||||
@@ -126,9 +117,21 @@ u32 JKRAramHeap::getTotalFreeSize(void) {
|
||||
void JKRAramHeap::dump(void) {
|
||||
lock();
|
||||
|
||||
JSUList<JKRAramBlock>* list = &sAramList;
|
||||
JSUListIterator<JKRAramBlock> iterator = list;
|
||||
for (; iterator != list->getEnd(); ++iterator) {}
|
||||
OS_REPORT("\nJKRAramHeap dump\n");
|
||||
OS_REPORT(" attr address: size gid\n");
|
||||
|
||||
u32 usedBytes = 0;
|
||||
for (JSUListIterator<JKRAramBlock> it = sAramList.getFirst(); it != sAramList.getEnd(); ++it) {
|
||||
if (it->mSize) {
|
||||
OS_REPORT("%s %08x: %08x %3d\n", it->isTempMemory() ? " temp" : "alloc", it->mAddress, it->mSize, it->mGroupId);
|
||||
}
|
||||
if (it->mFreeSize) {
|
||||
OS_REPORT(" free %08x: %08x 0\n", it->mAddress + it->mSize, it->mFreeSize);
|
||||
}
|
||||
usedBytes += it->mSize;
|
||||
}
|
||||
|
||||
OS_REPORT("%d / %d bytes (%6.2f%%) used\n", usedBytes, mSize, f32(usedBytes) / f32(mSize) * 100.0f);
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
JKRAMCommand* JKRAramPiece::prepareCommand(int direction, u32 src, u32 dst, u32 length,
|
||||
JKRAramBlock* block,
|
||||
JKRAMCommand::AsyncCallback callback) {
|
||||
JKRAMCommand* command = new (JKRHeap::getSystemHeap(), -4) JKRAMCommand();
|
||||
JKRAMCommand* command = new (JKRGetSystemHeap(), -4) JKRAMCommand();
|
||||
command->mTransferDirection = direction;
|
||||
command->mSrc = src;
|
||||
command->mDst = dst;
|
||||
@@ -23,7 +23,6 @@ void JKRAramPiece::sendCommand(JKRAMCommand* command) {
|
||||
startDMA(command);
|
||||
}
|
||||
|
||||
// JSUList<JKRAMCommand> JKRAramPiece::sAramPieceCommandList;
|
||||
JSUList<JKRAMCommand> JKRAramPiece::sAramPieceCommandList;
|
||||
|
||||
OSMutex JKRAramPiece::mMutex;
|
||||
@@ -39,11 +38,10 @@ JKRAMCommand* JKRAramPiece::orderAsync(int direction, u32 source, u32 destinatio
|
||||
JUTException::panic(__FILE__, 108, "illegal address. abort.");
|
||||
}
|
||||
|
||||
Message* message = new (JKRHeap::getSystemHeap(), -4) Message();
|
||||
JKRAramCommand* message = new (JKRGetSystemHeap(), -4) JKRAramCommand();
|
||||
JKRAMCommand* command =
|
||||
JKRAramPiece::prepareCommand(direction, source, destination, length, block, callback);
|
||||
message->field_0x00 = 1;
|
||||
message->command = command;
|
||||
message->setting(1, command);
|
||||
|
||||
OSSendMessage(&JKRAram::sMessageQueue, message, OS_MESSAGE_BLOCK);
|
||||
if (command->mCallback != NULL) {
|
||||
@@ -65,8 +63,7 @@ BOOL JKRAramPiece::sync(JKRAMCommand* command, int is_non_blocking) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL result = OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_NOBLOCK);
|
||||
if (!result) {
|
||||
if (!OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_NOBLOCK)) {
|
||||
unlock();
|
||||
return FALSE;
|
||||
}
|
||||
@@ -109,7 +106,7 @@ void JKRAramPiece::doneDMA(u32 requestAddress) {
|
||||
|
||||
if (command->field_0x60 != 0) {
|
||||
if (command->field_0x60 == 2) {
|
||||
JKRDecomp::sendCommand(command->mDecompCommand);
|
||||
JKRDecompress_SendCommand(command->mDecompCommand);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -140,5 +137,5 @@ JKRAMCommand::~JKRAMCommand() {
|
||||
delete field_0x90;
|
||||
|
||||
if (field_0x94)
|
||||
JKRHeap::free(field_0x94, NULL);
|
||||
JKRFree(field_0x94);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,20 @@
|
||||
#include "JSystem/JKernel/JKRAramPiece.h"
|
||||
#include "JSystem/JSupport/JSUFileStream.h"
|
||||
#include "JSystem/JUtility/JUTException.h"
|
||||
#include <stdint.h>
|
||||
#include <stdint>
|
||||
|
||||
#if PLATFORM_GCN
|
||||
const u32 stack_size = 0xc00;
|
||||
#else
|
||||
const u32 stack_size = 0x4000;
|
||||
#endif
|
||||
|
||||
JKRAramStream* JKRAramStream::sAramStreamObject;
|
||||
|
||||
JKRAramStream* JKRAramStream::create(s32 priority) {
|
||||
if (!sAramStreamObject) {
|
||||
sAramStreamObject = new (JKRGetSystemHeap(), 0) JKRAramStream(priority);
|
||||
setTransBuffer(NULL, 0, NULL);
|
||||
JKRResetAramTransferBuffer();
|
||||
}
|
||||
|
||||
return sAramStreamObject;
|
||||
@@ -26,7 +32,7 @@ void* JKRAramStream::sMessageBuffer[4] = {
|
||||
|
||||
OSMessageQueue JKRAramStream::sMessageQueue = {0};
|
||||
|
||||
JKRAramStream::JKRAramStream(s32 priority) : JKRThread(0xc00, 0x10, priority) {
|
||||
JKRAramStream::JKRAramStream(s32 priority) : JKRThread(stack_size, 0x10, priority) {
|
||||
resume();
|
||||
}
|
||||
|
||||
@@ -65,12 +71,12 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
|
||||
JKRHeap* heap = command->mHeap;
|
||||
|
||||
if (buffer) {
|
||||
bufferSize = (bufferSize) ? bufferSize : 0x8000;
|
||||
bufferSize = bufferSize == 0 ? 0x8000 : bufferSize;
|
||||
|
||||
command->mTransferBufferSize = bufferSize;
|
||||
command->mAllocatedTransferBuffer = false;
|
||||
} else {
|
||||
bufferSize = (bufferSize) ? bufferSize : 0x8000;
|
||||
bufferSize = bufferSize == 0 ? 0x8000 : bufferSize;
|
||||
|
||||
if (heap) {
|
||||
buffer = (u8*)JKRAllocFromHeap(heap, bufferSize, -0x20);
|
||||
@@ -107,6 +113,7 @@ s32 JKRAramStream::writeToAram(JKRAramStreamCommand* command) {
|
||||
|
||||
JKRAramPcs(0, (uintptr_t)buffer, destination, length, NULL);
|
||||
dstSize -= length;
|
||||
offset += length;
|
||||
writtenLength += length;
|
||||
destination += length;
|
||||
|
||||
@@ -159,20 +166,15 @@ JKRAramStreamCommand* JKRAramStream::sync(JKRAramStreamCommand* command, BOOL is
|
||||
if (isNonBlocking == 0) {
|
||||
OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_BLOCK);
|
||||
if (message == NULL) {
|
||||
command = NULL;
|
||||
return command;
|
||||
return NULL;
|
||||
} else {
|
||||
return command;
|
||||
}
|
||||
} else {
|
||||
BOOL receiveResult =
|
||||
OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_NOBLOCK);
|
||||
if (receiveResult == FALSE) {
|
||||
command = NULL;
|
||||
return command;
|
||||
if (OSReceiveMessage(&command->mMessageQueue, &message, OS_MESSAGE_NOBLOCK) == FALSE) {
|
||||
return NULL;
|
||||
} else if (message == NULL) {
|
||||
command = NULL;
|
||||
return command;
|
||||
return NULL;
|
||||
} else {
|
||||
return command;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
|
||||
#include "JSystem/JKernel/JKRArchive.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "ctype.h"
|
||||
#include "string.h"
|
||||
#include <ctype>
|
||||
#include <string>
|
||||
|
||||
u32 JKRArchive::sCurrentDirID;
|
||||
|
||||
JKRArchive::JKRArchive() {
|
||||
mIsMounted = false;
|
||||
mMountDirection = MOUNT_DIRECTION_HEAD;
|
||||
}
|
||||
|
||||
JKRArchive::JKRArchive(s32 entryNumber, JKRArchive::EMountMode mountMode) {
|
||||
mIsMounted = false;
|
||||
mMountMode = mountMode;
|
||||
@@ -19,9 +24,9 @@ JKRArchive::JKRArchive(s32 entryNumber, JKRArchive::EMountMode mountMode) {
|
||||
}
|
||||
|
||||
mEntryNum = entryNumber;
|
||||
if (getCurrentVolume() == NULL) {
|
||||
setCurrentVolume(this);
|
||||
setCurrentDirID(0);
|
||||
if (sCurrentVolume == NULL) {
|
||||
sCurrentVolume = this;
|
||||
sCurrentDirID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +41,12 @@ bool JKRArchive::isSameName(JKRArchive::CArcName& name, u32 nameOffset, u16 name
|
||||
|
||||
JKRArchive::SDIDirEntry* JKRArchive::findResType(u32 type) const {
|
||||
SDIDirEntry* node = mNodes;
|
||||
u32 count = 0;
|
||||
while (count < mArcInfoBlock->num_nodes) {
|
||||
for (u32 count = 0; count < mArcInfoBlock->num_nodes; count++) {
|
||||
if (node->type == type) {
|
||||
return node;
|
||||
}
|
||||
|
||||
node++;
|
||||
count++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -58,13 +61,14 @@ JKRArchive::SDIDirEntry* JKRArchive::findDirectory(const char* name, u32 directo
|
||||
SDIDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
for (int i = 0; i < dirEntry->num_entries; i++) {
|
||||
if (isSameName(arcName, fileEntry->type_flags_and_name_offset & 0xFFFFFF, fileEntry->name_hash)) {
|
||||
if ((fileEntry->type_flags_and_name_offset >> 24) & 2) {
|
||||
return findDirectory(name, fileEntry->data_offset);
|
||||
}
|
||||
break;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -77,10 +81,11 @@ JKRArchive::SDIFileEntry* JKRArchive::findTypeResource(u32 type, const char* nam
|
||||
|
||||
if (dirEntry) {
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->getNameHash())) {
|
||||
for (int i = 0; i < dirEntry->num_entries; i++) {
|
||||
if (isSameName(arcName, fileEntry->type_flags_and_name_offset & 0xFFFFFF, fileEntry->name_hash)) {
|
||||
return fileEntry;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,9 +99,9 @@ JKRArchive::SDIFileEntry* JKRArchive::findFsResource(const char* name, u32 direc
|
||||
SDIDirEntry* dirEntry = mNodes + directoryId;
|
||||
SDIFileEntry* fileEntry = mFiles + dirEntry->first_file_index;
|
||||
|
||||
for (int i = 0; i < dirEntry->num_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->name_hash)) {
|
||||
if (fileEntry->isDirectory()) {
|
||||
for (int i = 0; i < dirEntry->num_entries; i++) {
|
||||
if (isSameName(arcName, fileEntry->type_flags_and_name_offset & 0xFFFFFF, fileEntry->name_hash)) {
|
||||
if ((fileEntry->type_flags_and_name_offset >> 24) & 2) {
|
||||
return findFsResource(name, fileEntry->data_offset);
|
||||
}
|
||||
|
||||
@@ -106,6 +111,7 @@ JKRArchive::SDIFileEntry* JKRArchive::findFsResource(const char* name, u32 direc
|
||||
|
||||
return NULL;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,10 +130,11 @@ JKRArchive::SDIFileEntry* JKRArchive::findNameResource(const char* name) const {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
|
||||
CArcName arcName(name);
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (isSameName(arcName, fileEntry->getNameOffset(), fileEntry->getNameHash())) {
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (isSameName(arcName, fileEntry->type_flags_and_name_offset & 0xFFFFFF, fileEntry->name_hash)) {
|
||||
return fileEntry;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -135,10 +142,11 @@ JKRArchive::SDIFileEntry* JKRArchive::findNameResource(const char* name) const {
|
||||
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findPtrResource(const void* resource) const {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (fileEntry->data == resource) {
|
||||
return fileEntry;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -146,18 +154,20 @@ JKRArchive::SDIFileEntry* JKRArchive::findPtrResource(const void* resource) cons
|
||||
|
||||
JKRArchive::SDIFileEntry* JKRArchive::findIdResource(u16 id) const {
|
||||
if (id != 0xFFFF) {
|
||||
SDIFileEntry* fileEntry;
|
||||
if (id < mArcInfoBlock->num_file_entries) {
|
||||
SDIFileEntry* fileEntry = mFiles + id;
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
fileEntry = mFiles + id;
|
||||
if (fileEntry->file_id == id && ((fileEntry->type_flags_and_name_offset >> 24) & 1)) {
|
||||
return fileEntry;
|
||||
}
|
||||
}
|
||||
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
if (fileEntry->file_id == id && fileEntry->isUnknownFlag1()) {
|
||||
fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (fileEntry->file_id == id && ((fileEntry->type_flags_and_name_offset >> 24) & 1)) {
|
||||
return fileEntry;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,9 @@ JKRArchive* JKRArchive::check_mount_already(s32 entryNum, JKRHeap* heap) {
|
||||
heap = JKRGetCurrentHeap();
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
JKRArchive* archive = (JKRArchive*)iterator.getObject();
|
||||
JKRArchive* archive = (JKRArchive*)iterator.operator->();
|
||||
if (archive->mEntryNum == entryNum && archive->mHeap == heap) {
|
||||
archive->mMountCount++;
|
||||
return archive;
|
||||
@@ -41,60 +39,50 @@ JKRArchive* JKRArchive::mount(const char* path, EMountMode mountMode, JKRHeap* h
|
||||
JKRArchive* JKRArchive::mount(void* ptr, JKRHeap* heap,
|
||||
EMountDirection mountDirection) {
|
||||
JKRArchive* archive = check_mount_already((s32)ptr, heap);
|
||||
if (archive)
|
||||
if (archive) {
|
||||
return archive;
|
||||
|
||||
int alignment;
|
||||
if (mountDirection == MOUNT_DIRECTION_HEAD) {
|
||||
alignment = 4;
|
||||
} else {
|
||||
alignment = -4;
|
||||
}
|
||||
|
||||
archive = new (heap, alignment) JKRMemArchive(ptr, 0xFFFF, JKRMEMBREAK_FLAG_UNKNOWN0);
|
||||
return archive;
|
||||
int alignment = mountDirection == MOUNT_DIRECTION_HEAD ? 4 : -4;
|
||||
|
||||
JKRArchive* newArchive = new (heap, alignment) JKRMemArchive(ptr, 0xFFFF, JKRMEMBREAK_FLAG_UNKNOWN0);
|
||||
return newArchive;
|
||||
}
|
||||
|
||||
JKRArchive* JKRArchive::mount(s32 entryNum, JKRArchive::EMountMode mountMode, JKRHeap* heap,
|
||||
JKRArchive::EMountDirection mountDirection) {
|
||||
JKRArchive* archive = check_mount_already(entryNum, heap);
|
||||
if (archive != NULL) {
|
||||
return archive;
|
||||
} else {
|
||||
int alignment;
|
||||
if (mountDirection == JKRArchive::MOUNT_DIRECTION_HEAD) {
|
||||
alignment = 4;
|
||||
} else {
|
||||
alignment = -4;
|
||||
}
|
||||
|
||||
JKRArchive* archive;
|
||||
switch (mountMode) {
|
||||
case JKRArchive::MOUNT_MEM:
|
||||
archive = new (heap, alignment) JKRMemArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_ARAM:
|
||||
archive = new (heap, alignment) JKRAramArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_DVD:
|
||||
archive = new (heap, alignment) JKRDvdArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_COMP:
|
||||
archive = new (heap, alignment) JKRCompArchive(entryNum, mountDirection);
|
||||
break;
|
||||
}
|
||||
|
||||
if (archive && archive->getMountMode() == JKRArchive::UNKNOWN_MOUNT_MODE) {
|
||||
delete archive;
|
||||
archive = NULL;
|
||||
}
|
||||
|
||||
return archive;
|
||||
}
|
||||
int alignment = mountDirection == MOUNT_DIRECTION_HEAD ? 4 : -4;
|
||||
|
||||
JKRArchive* newArchive;
|
||||
switch (mountMode) {
|
||||
case JKRArchive::MOUNT_MEM:
|
||||
newArchive = new (heap, alignment) JKRMemArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_ARAM:
|
||||
newArchive = new (heap, alignment) JKRAramArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_DVD:
|
||||
newArchive = new (heap, alignment) JKRDvdArchive(entryNum, mountDirection);
|
||||
break;
|
||||
case JKRArchive::MOUNT_COMP:
|
||||
newArchive = new (heap, alignment) JKRCompArchive(entryNum, mountDirection);
|
||||
break;
|
||||
}
|
||||
|
||||
if (newArchive && newArchive->mMountMode == JKRArchive::UNKNOWN_MOUNT_MODE) {
|
||||
delete newArchive;
|
||||
newArchive = NULL;
|
||||
}
|
||||
|
||||
return newArchive;
|
||||
}
|
||||
|
||||
bool JKRArchive::becomeCurrent(const char* path) {
|
||||
SDIDirEntry* dirEntry;
|
||||
SDIDirEntry* dirEntry = NULL;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
@@ -102,13 +90,13 @@ bool JKRArchive::becomeCurrent(const char* path) {
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
dirEntry = findDirectory(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
bool found = dirEntry != NULL;
|
||||
if (found) {
|
||||
setCurrentVolume(this);
|
||||
setCurrentDirID(dirEntry - mNodes);
|
||||
sCurrentVolume = this;
|
||||
sCurrentDirID = dirEntry - mNodes;
|
||||
}
|
||||
|
||||
return found;
|
||||
@@ -119,9 +107,9 @@ bool JKRArchive::getDirEntry(SDirEntry* dirEntry, u32 index) const {
|
||||
if (!fileEntry)
|
||||
return false;
|
||||
|
||||
dirEntry->flags = fileEntry->getFlags();
|
||||
dirEntry->id = fileEntry->getFileID();
|
||||
dirEntry->name = mStringTable + fileEntry->getNameOffset();
|
||||
dirEntry->flags = fileEntry->type_flags_and_name_offset >> 24;
|
||||
dirEntry->id = fileEntry->file_id;
|
||||
dirEntry->name = mStringTable + (fileEntry->type_flags_and_name_offset & 0xFFFFFF);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -131,13 +119,13 @@ void* JKRArchive::getGlbResource(u32 param_1, const char* path, JKRArchive* arch
|
||||
return archive->getResource(param_1, path);
|
||||
}
|
||||
|
||||
JSUList<JKRFileLoader>& volumeList = getVolumeList();
|
||||
JSUListIterator<JKRFileLoader> iterator;
|
||||
for (iterator = volumeList.getFirst(); iterator != volumeList.getEnd(); ++iterator) {
|
||||
for (JSUListIterator<JKRFileLoader> iterator = sVolumeList.getFirst(); iterator != sVolumeList.getEnd(); ++iterator) {
|
||||
if (iterator->getVolumeType() == 'RARC') {
|
||||
resource = iterator->getResource(param_1, path);
|
||||
if (resource)
|
||||
JKRFileLoader* fileLoader = iterator.operator->();
|
||||
resource = fileLoader->getResource(param_1, path);
|
||||
if (resource) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +134,11 @@ void* JKRArchive::getGlbResource(u32 param_1, const char* path, JKRArchive* arch
|
||||
|
||||
void* JKRArchive::getResource(const char* path) {
|
||||
JUT_ASSERT(303, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
SDIFileEntry* fileEntry = NULL;
|
||||
if (*path == '/') {
|
||||
fileEntry = findFsResource(path + 1, 0);
|
||||
} else {
|
||||
fileEntry = findFsResource(path, getCurrentDirID());
|
||||
fileEntry = findFsResource(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
@@ -216,11 +204,11 @@ u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u32 type, const char*
|
||||
|
||||
u32 JKRArchive::readResource(void* buffer, u32 bufferSize, const char* path) {
|
||||
JUT_ASSERT(539, isMounted());
|
||||
SDIFileEntry* fileEntry;
|
||||
SDIFileEntry* fileEntry = NULL;
|
||||
if (*path == '/') {
|
||||
fileEntry = findFsResource(path + 1, 0);
|
||||
} else {
|
||||
fileEntry = findFsResource(path, getCurrentDirID());
|
||||
fileEntry = findFsResource(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (fileEntry) {
|
||||
@@ -259,11 +247,12 @@ u32 JKRArchive::readResource(void* buffer, u32 bufferSize, u16 id) {
|
||||
void JKRArchive::removeResourceAll() {
|
||||
if (mArcInfoBlock && mMountMode != MOUNT_MEM) {
|
||||
SDIFileEntry* fileEntry = mFiles;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; fileEntry++, i++) {
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (fileEntry->data) {
|
||||
JKRFreeToHeap(mHeap, fileEntry->data);
|
||||
fileEntry->data = NULL;
|
||||
}
|
||||
fileEntry++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,7 +290,7 @@ u32 JKRArchive::getResSize(const void* resource) const {
|
||||
u32 JKRArchive::countResource() const {
|
||||
u32 count = 0;
|
||||
for (int i = 0; i < mArcInfoBlock->num_file_entries; i++) {
|
||||
if (mFiles[i].isUnknownFlag1()) {
|
||||
if ((mFiles[i].type_flags_and_name_offset >> 24) & 1) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -309,7 +298,7 @@ u32 JKRArchive::countResource() const {
|
||||
}
|
||||
|
||||
u32 JKRArchive::countFile(const char* path) const {
|
||||
SDIDirEntry* dirEntry;
|
||||
SDIDirEntry* dirEntry = NULL;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
@@ -317,7 +306,7 @@ u32 JKRArchive::countFile(const char* path) const {
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
dirEntry = findDirectory(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
@@ -328,7 +317,7 @@ u32 JKRArchive::countFile(const char* path) const {
|
||||
}
|
||||
|
||||
JKRFileFinder* JKRArchive::getFirstFile(const char* path) const {
|
||||
SDIDirEntry* dirEntry;
|
||||
SDIDirEntry* dirEntry = NULL;
|
||||
if (*path == '/') {
|
||||
path++;
|
||||
|
||||
@@ -336,12 +325,12 @@ JKRFileFinder* JKRArchive::getFirstFile(const char* path) const {
|
||||
path = NULL;
|
||||
dirEntry = findDirectory(path, 0);
|
||||
} else {
|
||||
dirEntry = findDirectory(path, getCurrentDirID());
|
||||
dirEntry = findDirectory(path, sCurrentDirID);
|
||||
}
|
||||
|
||||
if (dirEntry) {
|
||||
// don't know what is correct here... for now we're casting away const
|
||||
return new (JKRHeap::getSystemHeap(), 0)
|
||||
return new (JKRGetSystemHeap(), 0)
|
||||
JKRArcFinder((JKRArchive*)this, dirEntry->first_file_index, (u32)dirEntry->num_entries);
|
||||
}
|
||||
|
||||
@@ -351,7 +340,7 @@ JKRFileFinder* JKRArchive::getFirstFile(const char* path) const {
|
||||
u32 JKRArchive::getFileAttribute(u32 index) const {
|
||||
SDIFileEntry* fileEntry = findIdxResource(index);
|
||||
if (fileEntry) {
|
||||
return fileEntry->getFlags();
|
||||
return u8(fileEntry->type_flags_and_name_offset >> 24);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -11,18 +11,17 @@ JKRAssertHeap::~JKRAssertHeap() {
|
||||
|
||||
JKRAssertHeap* JKRAssertHeap::create(JKRHeap* parent) {
|
||||
if (!parent) {
|
||||
parent = JKRHeap::getRootHeap();
|
||||
parent = sRootHeap;
|
||||
}
|
||||
|
||||
// 0x70 is sizeof(JKRAssertHeap) aligned to 16 bytes
|
||||
u32 size = 0x70;
|
||||
int alignment = 16;
|
||||
u32 size = ALIGN_NEXT(sizeof(JKRAssertHeap), 16);
|
||||
|
||||
void* ptr = JKRHeap::alloc(size, alignment, parent);
|
||||
void* ptr = JKRAllocFromHeap(parent, size, 16);
|
||||
if (!ptr)
|
||||
return NULL;
|
||||
|
||||
return new (ptr) JKRAssertHeap(NULL, 0, parent, false);
|
||||
JKRAssertHeap* heap = new (ptr) JKRAssertHeap(NULL, 0, parent, false);
|
||||
return heap;
|
||||
}
|
||||
|
||||
void JKRAssertHeap::do_destroy() {
|
||||
@@ -44,44 +43,3 @@ bool JKRAssertHeap::dump() {
|
||||
bool JKRAssertHeap::dump_sort() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
s32 JKRAssertHeap::do_changeGroupID(u8) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 JKRAssertHeap::do_getCurrentGroupId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* JKRAssertHeap::do_alloc(u32, int) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void JKRAssertHeap::do_free(void* param_0) {}
|
||||
|
||||
void JKRAssertHeap::do_freeAll() {}
|
||||
|
||||
void JKRAssertHeap::do_freeTail() {}
|
||||
|
||||
void JKRAssertHeap::do_fillFreeArea() {}
|
||||
|
||||
s32 JKRAssertHeap::do_resize(void*, u32) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 JKRAssertHeap::do_getSize(void*) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 JKRAssertHeap::do_getFreeSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* JKRAssertHeap::do_getMaxFreeBlock() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s32 JKRAssertHeap::do_getTotalFreeSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user