Various JSystem work (#2383)

* JKernel and JStudio cleanup

* JMessage cleanup

* JAudio cleanup

* JASBNKParser work

* functionvalue work

* fvb work

* J2D and J3D cleanup

* steal from tww

* J2DPictureEx mostly done

* fix build
This commit is contained in:
Caroline Madsen
2025-04-09 16:45:30 -04:00
committed by GitHub
parent 6672817e41
commit c6f76e7240
78 changed files with 1793 additions and 2710 deletions
+152 -30
View File
@@ -59,7 +59,6 @@ JASBNKParser::Ver1::TChunk* JASBNKParser::Ver1::findChunk(void const* stream, u3
/* 8029963C-80299A3C 293F7C 0400+00 1/1 0/0 0/0 .text
* createBasicBank__Q212JASBNKParser4Ver1FPCvP7JKRHeap */
// NONMATCHING instruction ordering, regalloc
JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* heap) {
if (heap == NULL) {
heap = JASDram;
@@ -74,44 +73,40 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
TOscChunk* osc_chunk = (TOscChunk*)findChunk(stream, 'OSCT');
TListChunk* list_chunk = (TListChunk*)findChunk(stream, 'LIST');
void* envt = new (heap, 2) u8[envt_chunk->mSize];
u8* envt = new (heap, 2) u8[envt_chunk->mSize];
JASCalc::bcopy(envt_chunk->mData, envt, envt_chunk->mSize);
u32 count = osc_chunk->mCount;
TOsc* osc = osc_chunk->mOsc;
u32* ptr = &osc_chunk->mCount;
u32 count = *ptr++;
JASOscillator::Data* osc_data = new (heap, 0) JASOscillator::Data[count];
for (int i = 0; i < count; i++, osc++) {
for (int i = 0; i < count; i++, ptr += sizeof(TOsc) >> 2) {
TOsc* osc = (TOsc*)ptr;
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*)((int)envt + osc->mTableOffset);
data->_0C = (JASOscillator::Point*)((int)envt + osc->_10);
data->mTable = (JASOscillator::Point*)(envt + osc->mTableOffset);
data->_0C = (JASOscillator::Point*)(envt + osc->_10);
}
bank->newInstTable(list_chunk->mCount, heap);
for (int i = 0; i < list_chunk->mCount; i++) {
if (list_chunk->mOffsets[i] != 0) {
u32* ptr = (u32*)((int)stream + list_chunk->mOffsets[i]);
u32* data = ptr + 1;
switch (*ptr) {
u32* data = (u32*)((int)stream + list_chunk->mOffsets[i]);
switch (*data++) {
case 'Inst': {
JASBasicInst* inst = new (heap, 0) JASBasicInst();
u32 count = *data;
data++;
u32 count = *data++;
for (int j = 0; j < count; j++) {
u32 index = *data;
data++;
u32 index = *data++;
inst->setOsc(j, &osc_data[index]);
}
count = *data;
data++;
count = *data++;
for (int j = 0; j < count; j++) {
data++;
}
count = *data;
data++;
count = *data++;
inst->setKeyRegionCount(count, heap);
for (int j = 0; j < count; j++) {
JASBasicInst::TKeymap* keymap = inst->getKeyRegion(j);
@@ -133,12 +128,10 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
case 'Perc': {
JASDrumSet* drum = new (heap, 0) JASDrumSet();
u32 count = *data;
data++;
u32 count = *data++;
drum->newPercArray(count, heap);
for (int j = 0; j < count; j++) {
u32 offset = *data;
data++;
u32 offset = *data++;
if (offset != 0) {
JASDrumSet::TPerc* perc = new (heap, 0) JASDrumSet::TPerc();
u32* ptr = (u32*)((int)stream + offset);
@@ -148,8 +141,7 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
perc->setPan((f32)perc_data->mPan / 127.0f);
perc->setRelease(perc_data->mRelease);
ptr = (u32*)&perc_data->field_0xc;
u32 count2 = *ptr;
ptr++;
u32 count2 = *ptr++;
for (int k = 0; k < count2; k++) {
ptr++;
}
@@ -173,20 +165,150 @@ JASBasicBank* JASBNKParser::Ver1::createBasicBank(void const* stream, JKRHeap* h
/* 80299A3C-80299E68 29437C 042C+00 1/1 0/0 0/0 .text
* createBasicBank__Q212JASBNKParser4Ver0FPCvP7JKRHeap */
// NONMATCHING
JASBasicBank* JASBNKParser::Ver0::createBasicBank(void const* stream, JKRHeap* heap) {
// NONMATCHING
THeader const* header = (THeader*)stream;
if (heap == NULL) {
heap = JASDram;
}
JASBasicBank* bank = new (heap, 0) JASBasicBank();
if (bank == NULL) {
return NULL;
}
bank->newInstTable(0x80, heap);
for (int i = 0; i < 0x80; i++) {
TInst* tinst = header->mOffsets.mInstOffset[i].ptr(stream);
if (tinst != NULL) {
JASBasicInst* inst = new (heap, 0) JASBasicInst();
inst->setVolume(tinst->mVolume);
inst->setPitch(tinst->mPitch);
int osc_idx = 0;
for (int j = 0; j < 2; j++) {
TOsc* tosc = tinst->mOscOffset[j].ptr(stream);
if (tosc != NULL) {
JASOscillator::Data* osc_data = findOscPtr(bank, header, tosc);
if (osc_data != NULL) {
inst->setOsc(osc_idx, osc_data);
} else {
osc_data = new (heap, 0) JASOscillator::Data();
osc_data->mTarget = tosc->mTarget;
osc_data->_04 = tosc->field_0x4;
u32 size;
JASOscillator::Point* points = tosc->mPointOffset.ptr(stream);
if (points != NULL) {
size = getOscTableEndPtr(points) - points;
JASOscillator::Point* table = new (heap, 0) JASOscillator::Point[size];
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
osc_data->mTable = table;
} else {
osc_data->mTable = NULL;
}
points = tosc->field_0xc.ptr(stream);
if (points != NULL) {
size = getOscTableEndPtr(points) - points;
JASOscillator::Point* table = new (heap, 0) JASOscillator::Point[size];
JASCalc::bcopy(points, table, size * sizeof(JASOscillator::Point));
osc_data->_0C = table;
} else {
osc_data->_0C = NULL;
}
osc_data->mScale = tosc->mScale;
osc_data->_14 = tosc->field_0x14;
inst->setOsc(osc_idx, osc_data);
}
osc_idx++;
}
}
inst->setKeyRegionCount(tinst->mKeyRegionCount, heap);
for (int j = 0; j < tinst->mKeyRegionCount; j++) {
JASBasicInst::TKeymap* keymap = inst->getKeyRegion(j);
TKeymap* tkeymap = tinst->mKeymapOffset[j].ptr(stream);
keymap->setHighKey(tkeymap->mHighKey);
TVmap* tvmap = tkeymap->mVmapOffset.ptr(stream);
keymap->field_0x4 = JSULoHalf(tvmap->field_0x4);
keymap->field_0x8 = tvmap->field_0x8;
keymap->field_0xc = tvmap->field_0xc;
}
bank->setInst(i, inst);
}
}
for (int i = 0; i < 12; i++) {
TPerc* tperc = header->mOffsets.mPercOffset[i].ptr(stream);
if (tperc != NULL) {
JASDrumSet* drumset = new (heap, 0) JASDrumSet();
drumset->newPercArray(0x80, heap);
for (int j = 0; j < 0x80; j++) {
TPmap* tpmap = tperc->mPmapOffset[j].ptr(stream);
if (tpmap != NULL) {
JASDrumSet::TPerc* perc = new (heap, 0) JASDrumSet::TPerc();
perc->setVolume(tpmap->mVolume);
perc->setPitch(tpmap->mPitch);
if (tperc->mMagic == 'PER2') {
perc->setPan(tperc->mPan[j] / 127.0f);
perc->setRelease(tperc->mRelease[j]);
}
TVmap* vmap = tpmap->mVmapOffset.ptr(stream);
perc->field_0xe = JSULoHalf(vmap->field_0x4);
perc->field_0x10 = vmap->field_0x8;
perc->field_0x14 = vmap->field_0xc;
drumset->setPerc(j, perc);
}
}
bank->setInst(i + 0xe4, drumset);
}
}
return bank;
}
/* 80299E68-80299F8C 2947A8 0124+00 1/1 0/0 0/0 .text
* findOscPtr__Q212JASBNKParser4Ver0FP12JASBasicBankPCQ312JASBNKParser4Ver07THeaderPCQ312JASBNKParser4Ver04TOsc
*/
void JASBNKParser::Ver0::findOscPtr(JASBasicBank* param_0, THeader const* param_1,
TOsc const* param_2) {
// NONMATCHING
JASOscillator::Data* JASBNKParser::Ver0::findOscPtr(JASBasicBank* bank, THeader const* header,
TOsc const* osc) {
TOffsetData const* data = &header->mOffsets;
for (int i = 0; i < 0x80; i++) {
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) {
JASInst* inst = bank->getInst(i);
if (inst != NULL) {
JASInstParam param;
inst->getParam(0x3c, 0x7f, &param);
if (j < param.field_0x1d) {
return param.field_0x14[j];
}
}
}
}
}
}
return NULL;
}
/* 80299F8C-80299FA0 2948CC 0014+00 1/1 0/0 0/0 .text
* getOscTableEndPtr__Q212JASBNKParser4Ver0FPCQ213JASOscillator5Point */
void JASBNKParser::Ver0::getOscTableEndPtr(JASOscillator::Point const* param_0) {
// NONMATCHING
JASOscillator::Point const* JASBNKParser::Ver0::getOscTableEndPtr(JASOscillator::Point const* points) {
s16 tmp;
do {
tmp = points->_0;
points++;
} while (tmp <= 10);
return points;
}