Improve some J2DPictureEx matches (#2493)

* Improve some J2DPictureEx matches

+ other minor debug improvements

* Fix JASTrack::channelStart
This commit is contained in:
hatal175
2025-06-21 03:47:24 -07:00
committed by GitHub
parent 7025de1c9c
commit e43b660038
10 changed files with 54 additions and 55 deletions
+5 -1
View File
@@ -64,7 +64,11 @@ public:
/* 8030A358 */ virtual ~J2DAnmVtxColor() {} /* 8030A358 */ virtual ~J2DAnmVtxColor() {}
/* 8030363C */ virtual void getColor(u8, u16, _GXColor*) const {} /* 8030363C */ virtual void getColor(u8, u16, _GXColor*) const {}
u16 getAnmTableNum(u8 param_0) const { return mAnmTableNum[param_0]; } u16 getAnmTableNum(u8 param_0) const { return mAnmTableNum[param_0]; }
J3DAnmVtxColorIndexData* getAnmVtxColorIndexData(u8 param_0, u16 param_1) const { return &mVtxColorIndexData[param_0][param_1]; } J3DAnmVtxColorIndexData* getAnmVtxColorIndexData(u8 param_1, u16 param_2) const {
J3D_PANIC(344, param_1 < 2, "Error : range over.");
J3D_PANIC(345, param_2 < mAnmTableNum[param_1], "Error : range over.");
return &mVtxColorIndexData[param_1][param_2];
}
u16* getVtxColorIndexPointer(u8 param_0) const { return mVtxColorIndexPointer[param_0]; } u16* getVtxColorIndexPointer(u8 param_0) const { return mVtxColorIndexPointer[param_0]; }
/* 0x10 */ u16 mAnmTableNum[2]; /* 0x10 */ u16 mAnmTableNum[2];
+2 -2
View File
@@ -11,7 +11,7 @@ class JASBank;
*/ */
class JASBankList { class JASBankList {
public: public:
virtual JASBank* getBank(u32 param_0) const = 0; virtual const JASBank* getBank(u32 param_0) const = 0;
}; };
#endif /* JASBANKLIST_H */ #endif /* JASBANKLIST_H */
+2 -2
View File
@@ -11,7 +11,7 @@
template<size_t N> template<size_t N>
class JASBankTable : public JASBankList { class JASBankTable : public JASBankList {
public: public:
// JASBank* getBank(u32 param_0) { return mArray.get(param_0); } JASBank* getBank(u32 param_0) { return mArray.get(param_0); }
virtual JASBank* getBank(u32 param_0) const { return mArray.get(param_0); } virtual JASBank* getBank(u32 param_0) const { return mArray.get(param_0); }
void registBank(u32 param_0, JASBank* param_1) { mArray.set(param_0, param_1); } void registBank(u32 param_0, JASBank* param_1) { mArray.set(param_0, param_1); }
@@ -28,4 +28,4 @@ public:
JASDefaultBankTable() : JASGlobalInstance(true) {} JASDefaultBankTable() : JASGlobalInstance(true) {}
}; };
#endif /* JASBANKTABLE_H */ #endif /* JASBANKTABLE_H */
+1 -1
View File
@@ -196,7 +196,7 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
/* 0x170 */ TChannelMgr* mChannelMgrs[4]; /* 0x170 */ TChannelMgr* mChannelMgrs[4];
/* 0x180 */ TChannelMgr mDefaultChannelMgr; /* 0x180 */ TChannelMgr mDefaultChannelMgr;
/* 0x1D0 */ int mChannelMgrCount; /* 0x1D0 */ int mChannelMgrCount;
/* 0x1D4 */ JASDefaultBankTable* mBankTable; /* 0x1D4 */ const JASDefaultBankTable* mBankTable;
/* 0x1D8 */ f32 field_0x1d8; /* 0x1D8 */ f32 field_0x1d8;
/* 0x1DC */ f32 field_0x1dc; /* 0x1DC */ f32 field_0x1dc;
/* 0x1E0 */ f32 mVibDepth; /* 0x1E0 */ f32 mVibDepth;
+2 -1
View File
@@ -16,7 +16,8 @@ public:
JAUBankTable(u32 param_0, JASBank** param_1, u32 param_2) : mBankPtrTable(param_1, param_2) { JAUBankTable(u32 param_0, JASBank** param_1, u32 param_2) : mBankPtrTable(param_1, param_2) {
field_0xc = param_0; field_0xc = param_0;
} }
/* 802A4AA0 */ JASBank* getBank(u32 bank) const { return mBankPtrTable.get(bank); } /* 802A4AA0 */ const JASBank* getBank(u32 bank) const { return mBankPtrTable.get(bank); }
JASBank* getBank(u32 bank) { return mBankPtrTable.get(bank); }
void registBank(u32 param_0, JASBank* param_1) { mBankPtrTable.set(param_0, param_1); } void registBank(u32 param_0, JASBank* param_1) { mBankPtrTable.set(param_0, param_1); }
+3 -3
View File
@@ -63,8 +63,8 @@ public:
/* 802A5D9C */ JAUBankTable* endNewBankTable(); /* 802A5D9C */ JAUBankTable* endNewBankTable();
/* 802A6468 */ virtual ~JAUSection() {} /* 802A6468 */ virtual ~JAUSection() {}
bool isBuilding() { return field_0x2c; } bool isBuilding() const { return field_0x2c; }
bool isOpen(); bool isOpen() const;
JAUSectionHeap* asSectionHeap() { return (JAUSection*)sectionHeap_ == this ? sectionHeap_ : NULL; } JAUSectionHeap* asSectionHeap() { return (JAUSection*)sectionHeap_ == this ? sectionHeap_ : NULL; }
JKRHeap* getHeap_(); JKRHeap* getHeap_();
@@ -123,7 +123,7 @@ public:
}; };
inline JKRHeap* JAUSection::getHeap_() { return sectionHeap_->mHeap; } inline JKRHeap* JAUSection::getHeap_() { return sectionHeap_->mHeap; }
inline bool JAUSection::isOpen() { return this == sectionHeap_->getOpenSection(); } inline bool JAUSection::isOpen() const { return this == sectionHeap_->getOpenSection(); }
JAUSectionHeap* JAUNewSectionHeap(bool); JAUSectionHeap* JAUNewSectionHeap(bool);
+2
View File
@@ -14,6 +14,7 @@
(COND) ? (void)0 : (JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, LINE, MSG, __VA_ARGS__), OSPanic(__FILE__, LINE, "Halt")); (COND) ? (void)0 : (JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, LINE, MSG, __VA_ARGS__), OSPanic(__FILE__, LINE, "Halt"));
#define J3D_ASSERT(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG) #define J3D_ASSERT(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG)
#define J3D_PANIC(LINE, COND, MSG) ((COND) != 0 || (OSPanic(__FILE__, LINE, MSG), 0));
#define JUT_PANIC(LINE, TEXT) \ #define JUT_PANIC(LINE, TEXT) \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, TEXT); \ JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, TEXT); \
@@ -36,6 +37,7 @@
#define JUT_ASSERT_MSG(...) (void)0; #define JUT_ASSERT_MSG(...) (void)0;
#define JUT_ASSERT_MSG_F(...) (void)0; #define JUT_ASSERT_MSG_F(...) (void)0;
#define J3D_ASSERT(...) (void)0; #define J3D_ASSERT(...) (void)0;
#define J3D_PANIC(...) (void)0;
#define JUT_PANIC(...) #define JUT_PANIC(...)
#define JUT_WARN(...) #define JUT_WARN(...)
#define JUT_WARN_DEVICE(...) #define JUT_WARN_DEVICE(...)
+18 -28
View File
@@ -287,12 +287,12 @@ bool J2DPictureEx::isInsert(u8 pos) const {
if (texGenNum >= 8 || pos >= 8 || pos > texGenNum) { if (texGenNum >= 8 || pos >= 8 || pos > texGenNum) {
return false; return false;
} }
u8 bVar5 = mMaterial->getTevBlock()->getMaxStage(); u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
if (bVar5 <= 2 && texGenNum != 0) { if (maxStage <= 2 && texGenNum != 0) {
return false; return false;
} }
if (bVar5 == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) { if (maxStage == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) {
return false; return false;
} }
@@ -300,7 +300,6 @@ bool J2DPictureEx::isInsert(u8 pos) const {
} }
/* 8030446C-80304608 2FEDAC 019C+00 1/0 0/0 0/0 .text remove__12J2DPictureExFUc */ /* 8030446C-80304608 2FEDAC 019C+00 1/0 0/0 0/0 .text remove__12J2DPictureExFUc */
// NONMATCHING regalloc
bool J2DPictureEx::remove(u8 pos) { bool J2DPictureEx::remove(u8 pos) {
if (!isRemove(pos)) { if (!isRemove(pos)) {
return false; return false;
@@ -308,7 +307,7 @@ bool J2DPictureEx::remove(u8 pos) {
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum(); u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum(); u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
bool bVar1 = tev_stage_num != tex_gen_num + 1; bool bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
shiftSetBlendRatio(pos, 0.0f, true, false); shiftSetBlendRatio(pos, 0.0f, true, false);
shiftSetBlendRatio(pos, 0.0f, false, false); shiftSetBlendRatio(pos, 0.0f, false, false);
@@ -511,7 +510,6 @@ void J2DPictureEx::draw(f32 param_0, f32 param_1, f32 width, f32 height, bool pa
} }
/* 80304D88-80304EF0 2FF6C8 0168+00 1/0 0/0 0/0 .text drawOut__12J2DPictureExFffffff */ /* 80304D88-80304EF0 2FF6C8 0168+00 1/0 0/0 0/0 .text drawOut__12J2DPictureExFffffff */
// NONMATCHING stack ordering
void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4, void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4,
f32 param_5) { f32 param_5) {
if (mMaterial == NULL) { if (mMaterial == NULL) {
@@ -528,9 +526,9 @@ void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f
JUTTexture* texture = mMaterial->getTevBlock()->getTexture(0); JUTTexture* texture = mMaterial->getTevBlock()->getTexture(0);
if (texture != NULL) { if (texture != NULL) {
JGeometry::TBox2<f32> box1(param_4, param_5, param_4 + texture->getWidth(), param_5 + texture->getHeight()); drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3),
JGeometry::TBox2<f32> box2(param_0, param_1, param_0 + param_2, param_1 + param_3); JGeometry::TBox2<f32>(param_4, param_5, param_4 + texture->getWidth(),
drawOut(box1, box2); param_5 + texture->getHeight()));
} }
} }
@@ -887,7 +885,6 @@ void J2DPictureEx::setBlendAlphaRatio(f32 param_0, f32 param_1) {
/* 80305F94-803060DC 3008D4 0148+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPC7ResTIMGUc /* 80305F94-803060DC 3008D4 0148+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPC7ResTIMGUc
*/ */
// NONMATCHING small regalloc
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) { const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
if (mMaterial == NULL || img == NULL) { if (mMaterial == NULL || img == NULL) {
return NULL; return NULL;
@@ -899,7 +896,7 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
} }
u8 max_stage = mMaterial->getTevBlock()->getMaxStage(); u8 max_stage = mMaterial->getTevBlock()->getMaxStage();
max_stage = max_stage > 8 ? 8 : max_stage; max_stage = (u8) (max_stage > 8 ? (u8)8 : max_stage);
if (param_1 >= max_stage) { if (param_1 >= max_stage) {
return NULL; return NULL;
} }
@@ -912,10 +909,9 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
} }
getTexture(param_1)->storeTIMG(img, uVar6); getTexture(param_1)->storeTIMG(img, uVar6);
return texinfo; return texinfo;
} else {
append(img, 1.0f);
return NULL;
} }
append(img, 1.0f);
return NULL;
} }
/* 803060DC-80306134 300A1C 0058+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPCcUc /* 803060DC-80306134 300A1C 0058+00 1/0 0/0 0/0 .text changeTexture__12J2DPictureExFPCcUc
@@ -927,11 +923,6 @@ const ResTIMG* J2DPictureEx::changeTexture(char const* param_0, u8 param_1) {
/* 80306134-80306298 300A74 0164+00 1/0 0/0 0/0 .text /* 80306134-80306298 300A74 0164+00 1/0 0/0 0/0 .text
* changeTexture__12J2DPictureExFPC7ResTIMGUcP10JUTPalette */ * changeTexture__12J2DPictureExFPC7ResTIMGUcP10JUTPalette */
// NONMATCHING Issues with param_1 >= bVar5. Maybe some inline min function.
inline u8 mina(u8 a, u8 b) {
return a > b ? b : a;
}
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, JUTPalette* param_2) { const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, JUTPalette* param_2) {
if (mMaterial == NULL || param_0 == NULL) { if (mMaterial == NULL || param_0 == NULL) {
return NULL; return NULL;
@@ -940,10 +931,10 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, J
if (param_1 > uVar2) { if (param_1 > uVar2) {
return NULL; return NULL;
} }
u8 bVar5 = mMaterial->getTevBlock()->getMaxStage(); u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
bVar5 = bVar5 > 8 ? 8 : bVar5; maxStage = (u8) (maxStage > 8 ? (u8) 8 : maxStage);
if (param_1 >= bVar5) { if (param_1 >= maxStage) {
return NULL; return NULL;
} }
if (param_1 < uVar2) { if (param_1 < uVar2) {
@@ -1073,12 +1064,12 @@ bool J2DPictureEx::getBlackWhite(JUtility::TColor* black, JUtility::TColor* whit
} }
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum(); u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u32 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum(); u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum() & 0xff;
bool bVar1; bool bVar1;
if (tex_gen_num == 1) { if (tex_gen_num == 1) {
bVar1 = tev_stage_num != 1; bVar1 = tev_stage_num == 1 ? false : true;
} else { } else {
bVar1 = tev_stage_num != tex_gen_num + 1; bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
} }
*black = 0x00000000; *black = 0x00000000;
@@ -1096,7 +1087,6 @@ bool J2DPictureEx::getBlackWhite(JUtility::TColor* black, JUtility::TColor* whit
/* 80306824-803068F8 301164 00D4+00 1/1 0/0 0/0 .text /* 80306824-803068F8 301164 00D4+00 1/1 0/0 0/0 .text
* isSetBlackWhite__12J2DPictureExCFQ28JUtility6TColorQ28JUtility6TColor */ * isSetBlackWhite__12J2DPictureExCFQ28JUtility6TColorQ28JUtility6TColor */
// NONMATCHING missing clrlwi, regalloc
bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor white) const { bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor white) const {
if (black == 0x00000000 && white == 0xffffffff) { if (black == 0x00000000 && white == 0xffffffff) {
return true; return true;
@@ -1114,8 +1104,8 @@ bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor whit
return false; return false;
} }
u8 tmp = tex_gen_num == 1 ? 2 : tex_gen_num + 2; u8 tmp = (u8)(tex_gen_num == 1 ? 2 : (tex_gen_num + 2));
return max_tev_stage <= tmp; return tmp <= max_tev_stage;
} }
/* 803068F8-80306958 301238 0060+00 1/0 0/0 0/0 .text getBlack__12J2DPictureExCFv */ /* 803068F8-80306958 301238 0060+00 1/0 0/0 0/0 .text getBlack__12J2DPictureExCFv */
+1 -1
View File
@@ -12,6 +12,6 @@ void JAUBankTableDictionary::appendBankTable(JSULink<JAUBankTable>* bankTableLis
} }
// Needed to make the inline function JAUBankTable::getBank appear in this TU // Needed to make the inline function JAUBankTable::getBank appear in this TU
static JASBank* dummy(JAUBankTable* table) { static const JASBank* dummy(const JAUBankTable* table) {
return table->getBank(0); return table->getBank(0);
} }
+18 -16
View File
@@ -363,23 +363,25 @@ JASBank* JAUSection::newBank(void const* param_0, u32 param_1) {
/* 802A5B84-802A5CAC 2A04C4 0128+00 0/0 1/1 0/0 .text newVoiceBank__10JAUSectionFUlUl */ /* 802A5B84-802A5CAC 2A04C4 0128+00 0/0 1/1 0/0 .text newVoiceBank__10JAUSectionFUlUl */
// NONMATCHING regalloc // NONMATCHING regalloc
JASVoiceBank* JAUSection::newVoiceBank(u32 bank_no, u32 param_1) { JASVoiceBank* JAUSection::newVoiceBank(u32 bank_no, u32 param_1) {
JUT_ASSERT(685, isOpen()); {
JUT_ASSERT(686, isBuilding()); JUT_ASSERT(685, isOpen());
JASWaveBank* waveBank = sectionHeap_->getWaveBankTable().getWaveBank(param_1); JUT_ASSERT(686, isBuilding());
JUT_ASSERT(688, waveBank != 0); JASWaveBank* waveBank = sectionHeap_->getWaveBankTable().getWaveBank(param_1);
TPushCurrentHeap push(getHeap_()); JUT_ASSERT(688, waveBank != 0);
JASVoiceBank* voiceBank = new JASVoiceBank(); TPushCurrentHeap push(getHeap_());
if (voiceBank) { JASVoiceBank* voiceBank = new JASVoiceBank();
if (buildingBankTable_) { if (voiceBank) {
JUT_ASSERT(696, buildingBankTable_->getBank( bank_no ) == 0); if (buildingBankTable_) {
buildingBankTable_->registBank(bank_no, voiceBank); JUT_ASSERT(696, buildingBankTable_->getBank( bank_no ) == 0);
} else { buildingBankTable_->registBank(bank_no, voiceBank);
JUT_ASSERT(701, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == 0); } else {
JASDefaultBankTable::getInstance()->registBank(bank_no, voiceBank); JUT_ASSERT(701, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == 0);
data_.registeredBankTables.set(bank_no, true); JASDefaultBankTable::getInstance()->registBank(bank_no, voiceBank);
data_.registeredBankTables.set(bank_no, true);
}
voiceBank->assignWaveBank(waveBank);
return voiceBank;
} }
voiceBank->assignWaveBank(waveBank);
return voiceBank;
} }
return NULL; return NULL;
} }