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 13:47:24 +03:00 committed by GitHub
parent 7025de1c9c
commit e43b660038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 54 additions and 55 deletions

View File

@ -64,7 +64,11 @@ public:
/* 8030A358 */ virtual ~J2DAnmVtxColor() {}
/* 8030363C */ virtual void getColor(u8, u16, _GXColor*) const {}
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]; }
/* 0x10 */ u16 mAnmTableNum[2];

View File

@ -11,7 +11,7 @@ class JASBank;
*/
class JASBankList {
public:
virtual JASBank* getBank(u32 param_0) const = 0;
virtual const JASBank* getBank(u32 param_0) const = 0;
};
#endif /* JASBANKLIST_H */
#endif /* JASBANKLIST_H */

View File

@ -11,7 +11,7 @@
template<size_t N>
class JASBankTable : public JASBankList {
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); }
void registBank(u32 param_0, JASBank* param_1) { mArray.set(param_0, param_1); }
@ -28,4 +28,4 @@ public:
JASDefaultBankTable() : JASGlobalInstance(true) {}
};
#endif /* JASBANKTABLE_H */
#endif /* JASBANKTABLE_H */

View File

@ -196,7 +196,7 @@ struct JASTrack : public JASPoolAllocObject_MultiThreaded<JASTrack> {
/* 0x170 */ TChannelMgr* mChannelMgrs[4];
/* 0x180 */ TChannelMgr mDefaultChannelMgr;
/* 0x1D0 */ int mChannelMgrCount;
/* 0x1D4 */ JASDefaultBankTable* mBankTable;
/* 0x1D4 */ const JASDefaultBankTable* mBankTable;
/* 0x1D8 */ f32 field_0x1d8;
/* 0x1DC */ f32 field_0x1dc;
/* 0x1E0 */ f32 mVibDepth;

View File

@ -16,7 +16,8 @@ public:
JAUBankTable(u32 param_0, JASBank** param_1, u32 param_2) : mBankPtrTable(param_1, param_2) {
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); }

View File

@ -63,8 +63,8 @@ public:
/* 802A5D9C */ JAUBankTable* endNewBankTable();
/* 802A6468 */ virtual ~JAUSection() {}
bool isBuilding() { return field_0x2c; }
bool isOpen();
bool isBuilding() const { return field_0x2c; }
bool isOpen() const;
JAUSectionHeap* asSectionHeap() { return (JAUSection*)sectionHeap_ == this ? sectionHeap_ : NULL; }
JKRHeap* getHeap_();
@ -123,7 +123,7 @@ public:
};
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);

View File

@ -14,6 +14,7 @@
(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_PANIC(LINE, COND, MSG) ((COND) != 0 || (OSPanic(__FILE__, LINE, MSG), 0));
#define JUT_PANIC(LINE, TEXT) \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, TEXT); \
@ -36,6 +37,7 @@
#define JUT_ASSERT_MSG(...) (void)0;
#define JUT_ASSERT_MSG_F(...) (void)0;
#define J3D_ASSERT(...) (void)0;
#define J3D_PANIC(...) (void)0;
#define JUT_PANIC(...)
#define JUT_WARN(...)
#define JUT_WARN_DEVICE(...)

View File

@ -287,12 +287,12 @@ bool J2DPictureEx::isInsert(u8 pos) const {
if (texGenNum >= 8 || pos >= 8 || pos > texGenNum) {
return false;
}
u8 bVar5 = mMaterial->getTevBlock()->getMaxStage();
if (bVar5 <= 2 && texGenNum != 0) {
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
if (maxStage <= 2 && texGenNum != 0) {
return false;
}
if (bVar5 == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) {
if (maxStage == mMaterial->getTevBlock()->getTevStageNum() && texGenNum != 0) {
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 */
// NONMATCHING regalloc
bool J2DPictureEx::remove(u8 pos) {
if (!isRemove(pos)) {
return false;
@ -308,7 +307,7 @@ bool J2DPictureEx::remove(u8 pos) {
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
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, 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 */
// NONMATCHING stack ordering
void J2DPictureEx::drawOut(f32 param_0, f32 param_1, f32 param_2, f32 param_3, f32 param_4,
f32 param_5) {
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);
if (texture != NULL) {
JGeometry::TBox2<f32> box1(param_4, param_5, param_4 + texture->getWidth(), param_5 + texture->getHeight());
JGeometry::TBox2<f32> box2(param_0, param_1, param_0 + param_2, param_1 + param_3);
drawOut(box1, box2);
drawOut(JGeometry::TBox2<f32>(param_0, param_1, param_0 + param_2, param_1 + param_3),
JGeometry::TBox2<f32>(param_4, param_5, param_4 + texture->getWidth(),
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
*/
// NONMATCHING small regalloc
const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
if (mMaterial == NULL || img == NULL) {
return NULL;
@ -899,7 +896,7 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
}
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) {
return NULL;
}
@ -912,10 +909,9 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* img, u8 param_1) {
}
getTexture(param_1)->storeTIMG(img, uVar6);
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
@ -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
* 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) {
if (mMaterial == NULL || param_0 == NULL) {
return NULL;
@ -940,10 +931,10 @@ const ResTIMG* J2DPictureEx::changeTexture(ResTIMG const* param_0, u8 param_1, J
if (param_1 > uVar2) {
return NULL;
}
u8 bVar5 = mMaterial->getTevBlock()->getMaxStage();
bVar5 = bVar5 > 8 ? 8 : bVar5;
u8 maxStage = mMaterial->getTevBlock()->getMaxStage();
maxStage = (u8) (maxStage > 8 ? (u8) 8 : maxStage);
if (param_1 >= bVar5) {
if (param_1 >= maxStage) {
return NULL;
}
if (param_1 < uVar2) {
@ -1073,12 +1064,12 @@ bool J2DPictureEx::getBlackWhite(JUtility::TColor* black, JUtility::TColor* whit
}
u8 tex_gen_num = mMaterial->getTexGenBlock()->getTexGenNum();
u32 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum();
u8 tev_stage_num = mMaterial->getTevBlock()->getTevStageNum() & 0xff;
bool bVar1;
if (tex_gen_num == 1) {
bVar1 = tev_stage_num != 1;
bVar1 = tev_stage_num == 1 ? false : true;
} else {
bVar1 = tev_stage_num != tex_gen_num + 1;
bVar1 = tev_stage_num == tex_gen_num + 1 ? false : true;
}
*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
* isSetBlackWhite__12J2DPictureExCFQ28JUtility6TColorQ28JUtility6TColor */
// NONMATCHING missing clrlwi, regalloc
bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor white) const {
if (black == 0x00000000 && white == 0xffffffff) {
return true;
@ -1114,8 +1104,8 @@ bool J2DPictureEx::isSetBlackWhite(JUtility::TColor black, JUtility::TColor whit
return false;
}
u8 tmp = tex_gen_num == 1 ? 2 : tex_gen_num + 2;
return max_tev_stage <= tmp;
u8 tmp = (u8)(tex_gen_num == 1 ? 2 : (tex_gen_num + 2));
return tmp <= max_tev_stage;
}
/* 803068F8-80306958 301238 0060+00 1/0 0/0 0/0 .text getBlack__12J2DPictureExCFv */

View File

@ -12,6 +12,6 @@ void JAUBankTableDictionary::appendBankTable(JSULink<JAUBankTable>* bankTableLis
}
// 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);
}

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 */
// NONMATCHING regalloc
JASVoiceBank* JAUSection::newVoiceBank(u32 bank_no, u32 param_1) {
JUT_ASSERT(685, isOpen());
JUT_ASSERT(686, isBuilding());
JASWaveBank* waveBank = sectionHeap_->getWaveBankTable().getWaveBank(param_1);
JUT_ASSERT(688, waveBank != 0);
TPushCurrentHeap push(getHeap_());
JASVoiceBank* voiceBank = new JASVoiceBank();
if (voiceBank) {
if (buildingBankTable_) {
JUT_ASSERT(696, buildingBankTable_->getBank( bank_no ) == 0);
buildingBankTable_->registBank(bank_no, voiceBank);
} else {
JUT_ASSERT(701, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == 0);
JASDefaultBankTable::getInstance()->registBank(bank_no, voiceBank);
data_.registeredBankTables.set(bank_no, true);
{
JUT_ASSERT(685, isOpen());
JUT_ASSERT(686, isBuilding());
JASWaveBank* waveBank = sectionHeap_->getWaveBankTable().getWaveBank(param_1);
JUT_ASSERT(688, waveBank != 0);
TPushCurrentHeap push(getHeap_());
JASVoiceBank* voiceBank = new JASVoiceBank();
if (voiceBank) {
if (buildingBankTable_) {
JUT_ASSERT(696, buildingBankTable_->getBank( bank_no ) == 0);
buildingBankTable_->registBank(bank_no, voiceBank);
} else {
JUT_ASSERT(701, JASDefaultBankTable::getInstance() ->getBank( bank_no ) == 0);
JASDefaultBankTable::getInstance()->registBank(bank_no, voiceBank);
data_.registeredBankTables.set(bank_no, true);
}
voiceBank->assignWaveBank(waveBank);
return voiceBank;
}
voiceBank->assignWaveBank(waveBank);
return voiceBank;
}
return NULL;
}