Skip to content

Commit

Permalink
JKRExpHeap matching + other minor (#2243)
Browse files Browse the repository at this point in the history
  • Loading branch information
hatal175 authored Nov 10, 2024
1 parent aec7c1d commit 7c20cdb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 250 deletions.
6 changes: 3 additions & 3 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,12 @@ def MatchingFor(*versions):
Object(Matching, "JSystem/JAudio2/JASVoiceBank.cpp"),
Object(Matching, "JSystem/JAudio2/JASBasicInst.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(Matching, "JSystem/JAudio2/JASDrumSet.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBasicWaveBank.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBasicWaveBank.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(Matching, "JSystem/JAudio2/JASSimpleWaveBank.cpp"),
Object(Matching, "JSystem/JAudio2/JASWSParser.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASBNKParser.cpp"),
Object(Matching, "JSystem/JAudio2/JASWaveArcLoader.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(NonMatching, "JSystem/JAudio2/JASChannel.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASChannel.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(Matching, "JSystem/JAudio2/JASLfo.cpp"),
Object(Matching, "JSystem/JAudio2/JASOscillator.cpp"),
Object(NonMatching, "JSystem/JAudio2/JASAiCtrl.cpp"),
Expand Down Expand Up @@ -887,7 +887,7 @@ def MatchingFor(*versions):
"JKernel",
[
Object(Matching, "JSystem/JKernel/JKRHeap.cpp"),
Object(NonMatching, "JSystem/JKernel/JKRExpHeap.cpp"),
Object(Matching, "JSystem/JKernel/JKRExpHeap.cpp"),
Object(Matching, "JSystem/JKernel/JKRSolidHeap.cpp"),
Object(Matching, "JSystem/JKernel/JKRAssertHeap.cpp"),
Object(Matching, "JSystem/JKernel/JKRDisposer.cpp"),
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JAudio2/JAISeqMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void JAISeqMgr::freeDeadSeq_() {
JSULink<JAISeq>* link = mSeqList.getFirst();
while (link != NULL) {
JAISeq* seq = link->getObject();
JSULink<JAISeq>* next = seq->getNext();
JSULink<JAISeq>* next = link->getNext();
if (seq->status_.isDead()) {
mSeqList.remove(link);
delete seq;
Expand Down
1 change: 1 addition & 0 deletions src/JSystem/JAudio2/JASBasicWaveBank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ void JASBasicWaveBank::setWaveTableSize(u32 param_0, JKRHeap* param_1) {
/* 80298790-8029883C 2930D0 00AC+00 1/1 0/0 0/0 .text
* incWaveTable__16JASBasicWaveBankFPCQ216JASBasicWaveBank10TWaveGroup */
// NONMATCHING instruction order
// This works if argument type is changed to non const
void JASBasicWaveBank::incWaveTable(JASBasicWaveBank::TWaveGroup const* param_0) {
JASMutexLock lock(&field_0x4);
for (u32 i = 0; i < param_0->getWaveCount(); i++) {
Expand Down
89 changes: 1 addition & 88 deletions src/JSystem/JAudio2/JASChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,90 +12,6 @@
#include "JSystem/JMath/JMATrigonometric.h"
#include "JSystem/JGeometry.h"

//
// Forward References:
//

extern "C" void __ct__10JASChannelFPFUlP10JASChannelPQ26JASDsp8TChannelPv_vPv();
extern "C" void __dt__10JASChannelFv();
extern "C" void play__10JASChannelFv();
extern "C" void playForce__10JASChannelFv();
extern "C" void release__10JASChannelFUs();
extern "C" void setOscInit__10JASChannelFUlPCQ213JASOscillator4Data();
extern "C" void setMixConfig__10JASChannelFUlUs();
extern "C" void calcEffect__10JASChannelFPCQ210JASChannel9PanVector();
extern "C" void calcPan__10JASChannelFPCQ210JASChannel9PanVector();
extern "C" void effectOsc__10JASChannelFUlPQ213JASOscillator12EffectParams();
extern "C" void setKeySweepTarget__10JASChannelFlUl();
extern "C" void
updateEffectorParam__10JASChannelFPQ26JASDsp8TChannelPUsRCQ213JASOscillator12EffectParams();
extern "C" void dspUpdateCallback__10JASChannelFUlPQ26JASDsp8TChannelPv();
extern "C" void initialUpdateDSPChannel__10JASChannelFPQ26JASDsp8TChannel();
extern "C" void updateDSPChannel__10JASChannelFPQ26JASDsp8TChannel();
extern "C" void updateAutoMixer__10JASChannelFPQ26JASDsp8TChannelffff();
extern "C" void updateMixer__10JASChannelFffffPUs();
extern "C" void free__10JASChannelFv();
extern "C" void initBankDisposeMsgQueue__10JASChannelFv();
extern "C" void receiveBankDisposeMsg__10JASChannelFv();
extern "C" void checkBankDispose__10JASChannelCFv();
extern "C" u8 sBankDisposeMsgQ__10JASChannel[32];
extern "C" u8 sBankDisposeMsg__10JASChannel[64];
extern "C" u8 sBankDisposeList__10JASChannel[64];
extern "C" u8 sBankDisposeListSize__10JASChannel[4 + 4 /* padding */];

//
// External References:
//

extern "C" void pow2__7JASCalcFf();
extern "C" void __ct__17JASGenericMemPoolFv();
extern "C" void free__17JASGenericMemPoolFPvUl();
extern "C" void func_802978DC(void* _this);
extern "C" void __ct__6JASLfoFv();
extern "C" void getValue__6JASLfoCFv();
extern "C" void incCounter__6JASLfoFf();
extern "C" void resetCounter__6JASLfoFv();
extern "C" void __ct__13JASOscillatorFv();
extern "C" void initStart__13JASOscillatorFPCQ213JASOscillator4Data();
extern "C" void incCounter__13JASOscillatorFf();
extern "C" void getValue__13JASOscillatorCFv();
extern "C" void release__13JASOscillatorFv();
extern "C" void update__13JASOscillatorFv();
extern "C" void getDacRate__9JASDriverFv();
extern "C" void free__13JASDSPChannelFv();
extern "C" void start__13JASDSPChannelFv();
extern "C" void drop__13JASDSPChannelFv();
extern "C" void alloc__13JASDSPChannelFUcPFUlPQ26JASDsp8TChannelPv_lPv();
extern "C" void allocForce__13JASDSPChannelFUcPFUlPQ26JASDsp8TChannelPv_lPv();
extern "C" void setPriority__13JASDSPChannelFUc();
extern "C" void setWaveInfo__Q26JASDsp8TChannelFRC11JASWaveInfoUlUl();
extern "C" void setOscInfo__Q26JASDsp8TChannelFUl();
extern "C" void initAutoMixer__Q26JASDsp8TChannelFv();
extern "C" void setAutoMixer__Q26JASDsp8TChannelFUsUcUcUcUc();
extern "C" void setPitch__Q26JASDsp8TChannelFUs();
extern "C" void setMixerInitVolume__Q26JASDsp8TChannelFUcs();
extern "C" void setMixerVolume__Q26JASDsp8TChannelFUcs();
extern "C" void setPauseFlag__Q26JASDsp8TChannelFUc();
extern "C" void setBusConnect__Q26JASDsp8TChannelFUcUc();
extern "C" void getChannelLevel_dsp__9JASDriverFv();
extern "C" void getOutputMode__9JASDriverFv();
extern "C" void __register_global_object();
extern "C" void __construct_array();
extern "C" void _savegpr_27();
extern "C" void _savegpr_28();
extern "C" void _savegpr_29();
extern "C" void _restgpr_27();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
extern "C" extern u8 data_80431B34[16 + 4 /* padding */];
extern "C" u8 sincosTable___5JMath[65536];
extern "C" u32 one__11JASWaveInfo[1 + 1 /* padding */];
extern "C" extern u8 struct_80451260[8];

//
// Declarations:
//

/* 80431B90-80431BB0 05E8B0 0020+00 2/2 0/0 0/0 .bss sBankDisposeMsgQ__10JASChannel */
OSMessageQueue JASChannel::sBankDisposeMsgQ;

Expand Down Expand Up @@ -137,9 +53,6 @@ JASChannel::JASChannel(Callback i_callback, void* i_callbackData) :
mPauseFlag = false;
}

/* 80431C30-80431C40 05E950 000C+04 1/1 0/2 0/0 .bss @556 */
static u8 lit_556[12 + 4 /* padding */];

/* 8029A918-8029A9F0 295258 00D8+00 5/5 0/0 0/0 .text __dt__10JASChannelFv */
JASChannel::~JASChannel() {
if (mDspCh != NULL) {
Expand Down Expand Up @@ -625,4 +538,4 @@ bool JASChannel::checkBankDispose() const {
}
}
return false;
}
}
175 changes: 17 additions & 158 deletions src/JSystem/JKernel/JKRExpHeap.cpp
Original file line number Diff line number Diff line change
@@ -1,99 +1,11 @@
//
// Generated By: dol2asm
// Translation Unit: JKRExpHeap
// JKRExpHeap
//

#include "JSystem/JKernel/JKRExpHeap.h"
#include "JSystem/JSupport/JSupport.h"
#include "JSystem/JUtility/JUTConsole.h"
#include "JSystem/JUtility/JUTException.h"
#include "dol2asm.h"

//
// Forward References:
//

extern "C" void createRoot__10JKRExpHeapFib();
extern "C" void create__10JKRExpHeapFUlP7JKRHeapb();
extern "C" void create__10JKRExpHeapFPvUlP7JKRHeapb();
extern "C" void do_destroy__10JKRExpHeapFv();
extern "C" void __ct__10JKRExpHeapFPvUlP7JKRHeapb();
extern "C" void __dt__10JKRExpHeapFv();
extern "C" void do_alloc__10JKRExpHeapFUli();
extern "C" void allocFromHead__10JKRExpHeapFUli();
extern "C" void allocFromHead__10JKRExpHeapFUl();
extern "C" void allocFromTail__10JKRExpHeapFUli();
extern "C" void allocFromTail__10JKRExpHeapFUl();
extern "C" void do_free__10JKRExpHeapFPv();
extern "C" void do_freeAll__10JKRExpHeapFv();
extern "C" void do_freeTail__10JKRExpHeapFv();
extern "C" void do_fillFreeArea__10JKRExpHeapFv();
extern "C" void do_changeGroupID__10JKRExpHeapFUc();
extern "C" void do_resize__10JKRExpHeapFPvUl();
extern "C" void do_getSize__10JKRExpHeapFPv();
extern "C" void do_getFreeSize__10JKRExpHeapFv();
extern "C" void do_getMaxFreeBlock__10JKRExpHeapFv();
extern "C" void do_getTotalFreeSize__10JKRExpHeapFv();
extern "C" void getUsedSize__10JKRExpHeapCFUc();
extern "C" void getTotalUsedSize__10JKRExpHeapCFv();
extern "C" void appendUsedList__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock();
extern "C" void
setFreeBlock__10JKRExpHeapFPQ210JKRExpHeap9CMemBlockPQ210JKRExpHeap9CMemBlockPQ210JKRExpHeap9CMemBlock();
extern "C" void removeFreeBlock__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock();
extern "C" void removeUsedBlock__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock();
extern "C" void recycleFreeBlock__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock();
extern "C" void joinTwoBlocks__10JKRExpHeapFPQ210JKRExpHeap9CMemBlock();
extern "C" void check__10JKRExpHeapFv();
extern "C" void dump__10JKRExpHeapFv();
extern "C" void dump_sort__10JKRExpHeapFv();
extern "C" void
initiate__Q210JKRExpHeap9CMemBlockFPQ210JKRExpHeap9CMemBlockPQ210JKRExpHeap9CMemBlockUlUcUc();
extern "C" void allocFore__Q210JKRExpHeap9CMemBlockFUlUcUcUcUc();
extern "C" void allocBack__Q210JKRExpHeap9CMemBlockFUlUcUcUcUc();
extern "C" void free__Q210JKRExpHeap9CMemBlockFP10JKRExpHeap();
extern "C" void getHeapBlock__Q210JKRExpHeap9CMemBlockFPv();
extern "C" void state_register__10JKRExpHeapCFPQ27JKRHeap6TStateUl();
extern "C" void state_compare__10JKRExpHeapCFRCQ27JKRHeap6TStateRCQ27JKRHeap6TState();
extern "C" void getHeapType__10JKRExpHeapFv();
extern "C" void do_getCurrentGroupId__10JKRExpHeapFv();
extern "C" extern char const* const JKRExpHeap__stringBase0;

//
// External References:
//

extern "C" void __ct__7JKRHeapFPvUlP7JKRHeapb();
extern "C" void __dt__7JKRHeapFv();
extern "C" void initArena__7JKRHeapFPPcPUli();
extern "C" void alloc__7JKRHeapFUliP7JKRHeap();
extern "C" void free__7JKRHeapFPvP7JKRHeap();
extern "C" void callAllDisposer__7JKRHeapFv();
extern "C" void getTotalFreeSize__7JKRHeapFv();
extern "C" void getMaxAllocatableSize__7JKRHeapFi();
extern "C" void find__7JKRHeapCFPv();
extern "C" void dispose__7JKRHeapFPvUl();
extern "C" void dispose__7JKRHeapFv();
extern "C" void __dl__FPv();
extern "C" void state_dump__7JKRHeapCFRCQ27JKRHeap6TState();
extern "C" void panic_f__12JUTExceptionFPCciPCce();
extern "C" void JUTReportConsole_f(const char*, ...);
extern "C" void JUTReportConsole(const char*);
extern "C" void JUTWarningConsole_f(const char*, ...);
extern "C" void JUTWarningConsole(const char*);
extern "C" void _savegpr_25();
extern "C" void _savegpr_27();
extern "C" void _savegpr_28();
extern "C" void _savegpr_29();
extern "C" void _restgpr_25();
extern "C" void _restgpr_27();
extern "C" void _restgpr_28();
extern "C" void _restgpr_29();
extern "C" u8 sCurrentHeap__7JKRHeap[4];
extern "C" u8 sRootHeap__7JKRHeap[4];
extern "C" u8 mErrorHandler__7JKRHeap[4];

//
// Declarations:
//

/* 802CEDB4-802CEE2C 2C96F4 0078+00 0/0 1/1 0/0 .text createRoot__10JKRExpHeapFib */
JKRExpHeap* JKRExpHeap::createRoot(int maxHeaps, bool errorFlag) {
Expand Down Expand Up @@ -256,8 +168,6 @@ static JKRExpHeap::CMemBlock* DBnewFreeBlock;
static JKRExpHeap::CMemBlock* DBnewUsedBlock;

/* 802CF234-802CF490 2C9B74 025C+00 1/1 0/0 0/0 .text allocFromHead__10JKRExpHeapFUli */
// wrong register at end
#ifdef NONMATCHING
void* JKRExpHeap::allocFromHead(u32 size, int align) {
u32 foundOffset;
int foundSize;
Expand Down Expand Up @@ -342,16 +252,16 @@ void* JKRExpHeap::allocFromHead(u32 size, int align) {
CMemBlock* prev = foundBlock->mPrev;
CMemBlock* next = foundBlock->mNext;
// Works but very fake match
/*size = (u32)foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
size = (u32)foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
removeFreeBlock(foundBlock);
if (size) {
setFreeBlock((CMemBlock*)size, prev, next);
}*/
newFreeBlock = foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
removeFreeBlock(foundBlock);
if (newFreeBlock) {
setFreeBlock(newFreeBlock, prev, next);
}
// newFreeBlock = foundBlock->allocFore(size, mCurrentGroupId, 0, 0, 0);
// removeFreeBlock(foundBlock);
// if (newFreeBlock) {
// setFreeBlock(newFreeBlock, prev, next);
// }
appendUsedList(foundBlock);
return foundBlock->getContent();
}
Expand All @@ -360,11 +270,6 @@ void* JKRExpHeap::allocFromHead(u32 size, int align) {

return NULL;
}
#else
void* JKRExpHeap::allocFromHead(u32 param_0, int param_1) {
// NONMATCHING
}
#endif

/* 802CF490-802CF574 2C9DD0 00E4+00 1/1 0/0 0/0 .text allocFromHead__10JKRExpHeapFUl */
void* JKRExpHeap::allocFromHead(u32 size) {
Expand Down Expand Up @@ -1126,58 +1031,12 @@ u8 JKRExpHeap::do_getCurrentGroupId() {
return mCurrentGroupId;
}

/* ############################################################################################## */
/* 8039CD84-8039CDA0 0293E4 001C+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CD84 = "+---------------JKRExpHeap\n";
#pragma pop

/* 8039CDA0-8039CDD0 029400 0030+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CDA0 =
"| Align Group size ( prev , next )\n";
#pragma pop

/* 8039CDD0-8039CDE2 029430 0012+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CDD0 = "| ---- FreeFirst\n";
#pragma pop

/* 8039CDE2-8039CDEB 029442 0009+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CDE2 = "| %08x ";
#pragma pop

/* 8039CDEB-8039CE07 02944B 001C+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CDEB = "%2x %3d %6x (%08x %08x)\n";
#pragma pop

/* 8039CE07-8039CE18 029467 0011+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CE07 = "| ---- FreeLast\n";
#pragma pop

/* 8039CE18-8039CE2A 029478 0012+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CE18 = "| ---- UsedFirst\n";
#pragma pop

/* 8039CE2A-8039CE3B 02948A 0011+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CE2A = "| ---- UsedLast\n";
#pragma pop

/* 8039CE3B-8039CE50 02949B 0015+00 0/0 0/0 0/0 .rodata None */
#pragma push
#pragma force_active on
SECTION_DEAD static char const* const stringBase_8039CE3B = "+---------------End\n";
#pragma pop
static char* dummyLiteral1() { return "+---------------JKRExpHeap\n"; }
static char* dummyLiteral2() { return "| Align Group size ( prev , next )\n"; }
static char* dummyLiteral3() { return "| ---- FreeFirst\n"; }
static char* dummyLiteral4() { return "| %08x "; }
static char* dummyLiteral5() { return "%2x %3d %6x (%08x %08x)\n"; }
static char* dummyLiteral6() { return "| ---- FreeLast\n"; }
static char* dummyLiteral7() { return "| ---- UsedFirst\n"; }
static char* dummyLiteral8() { return "| ---- UsedLast\n"; }
static char* dummyLiteral9() { return "+---------------End\n"; }

0 comments on commit 7c20cdb

Please sign in to comment.