mirror of https://github.com/PrimeDecomp/prime.git
Match and link synth_vsamples.c
Former-commit-id: 6817810884b70efe70d1c5633b4ac32af08e1816
This commit is contained in:
parent
48191b46b7
commit
e4d1a69518
|
@ -1177,7 +1177,7 @@ config.libs = [
|
|||
Object(NonMatching, "musyx/runtime/synthvoice.c"),
|
||||
Object(Matching, "musyx/runtime/synth_ac.c"),
|
||||
Object(NonMatching, "musyx/runtime/synth_adsr.c"),
|
||||
Object(NonMatching, "musyx/runtime/synth_vsamples.c"),
|
||||
Object(Matching, "musyx/runtime/synth_vsamples.c"),
|
||||
Object(Matching, "musyx/runtime/synth_dbtab.c"),
|
||||
Object(Matching, "musyx/runtime/s_data.c"),
|
||||
Object(NonMatching, "musyx/runtime/hw_dspctrl.c"),
|
||||
|
|
|
@ -24,6 +24,11 @@ u32 hwGetVirtualSampleState(u32 voice);
|
|||
bool hwVoiceInStartup(u32 v);
|
||||
void hwBreak(s32 vid);
|
||||
u32 hwGetPos(u32 v);
|
||||
void hwInitSampleMem(u32 baseAddr, u32 length);
|
||||
void hwExitSampleMem();
|
||||
void hwSetVirtualSampleLoopBuffer(u32 voice, void* addr, u32 len);
|
||||
u16 hwGetSampleID(u32 voice);
|
||||
u8 hwGetSampleType(u32 voice);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ u32 vsSampleStartNotify(unsigned char voice) {
|
|||
sb = vs.voices[voice] = vsAllocateBuffer();
|
||||
if (sb != 0xFF) {
|
||||
addr = aramGetStreamBufferAddress(vs.voices[voice], 0);
|
||||
hwSetVirtualSampleLoopBuffer(voice, addr, vs.bufferLength);
|
||||
hwSetVirtualSampleLoopBuffer(voice, (void*)addr, vs.bufferLength);
|
||||
vs.streamBuffer[sb].info.smpID = hwGetSampleID(voice);
|
||||
vs.streamBuffer[sb].info.instID = vsNewInstanceID();
|
||||
vs.streamBuffer[sb].smpType = hwGetSampleType(voice);
|
||||
|
@ -108,41 +108,49 @@ void vsUpdateBuffer(struct VS_BUFFER* sb, unsigned long cpos) {
|
|||
return;
|
||||
}
|
||||
if ((s32)sb->last < cpos) {
|
||||
if ((s8)sb->smpType != 5) {
|
||||
cpos = cpos;
|
||||
} else {
|
||||
switch (sb->smpType) {
|
||||
case 5:
|
||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||
sb->info.data.update.len1 = cpos - sb->last;
|
||||
sb->info.data.update.off2 = 0;
|
||||
sb->info.data.update.len2 = 0;
|
||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||
off = sb->last + len;
|
||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
||||
sb->last = off % vs.bufferLength;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (cpos == 0) {
|
||||
if ((s8)sb->smpType != 5) {
|
||||
cpos = cpos;
|
||||
} else {
|
||||
switch (sb->smpType) {
|
||||
case 5:
|
||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
||||
sb->info.data.update.off2 = 0;
|
||||
sb->info.data.update.len2 = 0;
|
||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||
off = sb->last + len;
|
||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
||||
sb->last = off % vs.bufferLength;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if ((s8)sb->smpType != 5) {
|
||||
cpos = cpos;
|
||||
} else {
|
||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
||||
sb->info.data.update.off2 = 0;
|
||||
sb->info.data.update.len2 = cpos;
|
||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||
off = sb->last + len;
|
||||
sb->last = off - (off / vs.bufferLength) * vs.bufferLength;
|
||||
switch (sb->smpType) {
|
||||
case 5:
|
||||
sb->info.data.update.off1 = (sb->last / 14) * 8;
|
||||
sb->info.data.update.len1 = vs.bufferLength - sb->last;
|
||||
sb->info.data.update.off2 = 0;
|
||||
sb->info.data.update.len2 = cpos;
|
||||
if ((len = vs.callback(1, &sb->info)) != 0) {
|
||||
off = sb->last + len;
|
||||
sb->last = off % vs.bufferLength;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,12 +171,13 @@ void vsSampleUpdates() {
|
|||
sb = &vs.streamBuffer[vs.voices[i]];
|
||||
realCPos = hwGetPos(i);
|
||||
cpos = sb->smpType == 5 ? (realCPos / 14) * 14 : realCPos;
|
||||
|
||||
|
||||
switch (sb->state) {
|
||||
case 1:
|
||||
vsUpdateBuffer(sb, cpos);
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
if (((sb->info.instID << 8) | sb->voice) == hwGetVirtualSampleID(sb->voice)) {
|
||||
vsUpdateBuffer(sb, cpos);
|
||||
|
||||
|
@ -179,7 +188,7 @@ void vsSampleUpdates() {
|
|||
}
|
||||
|
||||
sb->finalLast = realCPos;
|
||||
nextSamples = (((synthVoice[sb->voice].curPitch * 160) + 0xFFF) >> 12);
|
||||
nextSamples = (synthVoice[sb->voice].curPitch * 160 + 0xFFF) / 4096;
|
||||
if ((s32)nextSamples > (s32)sb->finalGoodSamples) {
|
||||
if (!hwVoiceInStartup(sb->voice)) {
|
||||
#if MUSY_VERSION >= MUSY_VERSION_CHECK(1, 5, 4)
|
||||
|
|
|
@ -280,9 +280,9 @@ bool dataRemoveSDir(struct SDIR_DATA* sdir) {
|
|||
|
||||
hwDisableIrq();
|
||||
|
||||
for (data = sdir; data->id != 0xFFFF;
|
||||
++data) {
|
||||
if (data->ref_cnt != 0xFFFF && data->ref_cnt != 0) break;
|
||||
for (data = sdir; data->id != 0xFFFF; ++data) {
|
||||
if (data->ref_cnt != 0xFFFF && data->ref_cnt != 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (data->id == 0xFFFF) {
|
||||
|
@ -290,35 +290,36 @@ bool dataRemoveSDir(struct SDIR_DATA* sdir) {
|
|||
|
||||
for (data = sdir; data->id != 0xFFFF; ++data) {
|
||||
if (data->ref_cnt != 0xFFFF) {
|
||||
for (i = 0; i < dataSmpSDirNum; ++i) {
|
||||
if (dataSmpSDirs[i].data == sdir) continue;
|
||||
for (j = 0; j < dataSmpSDirs[i].numSmp; ++j) {
|
||||
if (data->id == dataSmpSDirs[i].data[j].id && dataSmpSDirs[i].data[j].ref_cnt == 0xFFFF) {
|
||||
dataSmpSDirs[i].data[j].ref_cnt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != dataSmpSDirs[i].numSmp) {
|
||||
for (i = 0; i < dataSmpSDirNum; ++i) {
|
||||
if (dataSmpSDirs[i].data == sdir)
|
||||
continue;
|
||||
for (j = 0; j < dataSmpSDirs[i].numSmp; ++j) {
|
||||
if (data->id == dataSmpSDirs[i].data[j].id &&
|
||||
dataSmpSDirs[i].data[j].ref_cnt == 0xFFFF) {
|
||||
dataSmpSDirs[i].data[j].ref_cnt = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (j != dataSmpSDirs[i].numSmp) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
}
|
||||
}
|
||||
data = sdir;
|
||||
for (; data->id != 0xFFFF; ++data) {
|
||||
data->ref_cnt = 0;
|
||||
}
|
||||
data = sdir;
|
||||
for (; data->id != 0xFFFF; ++data) {
|
||||
data->ref_cnt = 0;
|
||||
}
|
||||
|
||||
for (j = index + 1; j < dataSmpSDirNum; ++j) {
|
||||
dataSmpSDirs[j - 1] = dataSmpSDirs[j];
|
||||
}
|
||||
for (j = index + 1; j < dataSmpSDirNum; ++j) {
|
||||
dataSmpSDirs[j - 1] = dataSmpSDirs[j];
|
||||
}
|
||||
|
||||
--dataSmpSDirNum;
|
||||
hwEnableIrq();
|
||||
return TRUE;
|
||||
--dataSmpSDirNum;
|
||||
hwEnableIrq();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
hwEnableIrq();
|
||||
|
@ -344,7 +345,8 @@ bool dataAddSampleReference(u16 sid) {
|
|||
}
|
||||
done:
|
||||
#line 542
|
||||
MUSY_ASSERT_MSG(sdir != NULL, "Sample ID to be inserted could not be found in any sample directory.\n");
|
||||
MUSY_ASSERT_MSG(sdir != NULL,
|
||||
"Sample ID to be inserted could not be found in any sample directory.\n");
|
||||
|
||||
if (sdir->ref_cnt == 0) {
|
||||
sdir->addr = (void*)(sdir->offset + (s32)dataSmpSDirs[i].base);
|
||||
|
@ -420,11 +422,11 @@ bool dataRemoveFX(u16 gid) {
|
|||
}
|
||||
|
||||
bool dataInsertMacro(u16 mid, void* macroaddr) {
|
||||
long main; // r28
|
||||
long pos; // r29
|
||||
long base; // r27
|
||||
long i; // r31
|
||||
|
||||
long main; // r28
|
||||
long pos; // r29
|
||||
long base; // r27
|
||||
long i; // r31
|
||||
|
||||
hwDisableIrq();
|
||||
|
||||
main = (mid >> 6) & 0x3ff;
|
||||
|
@ -572,8 +574,8 @@ void* dataGetCurve(u16 cid) {
|
|||
static DATA_TAB* result;
|
||||
|
||||
key.id = cid;
|
||||
if (result =
|
||||
(DATA_TAB*)sndBSearch(&key, dataCurveTab, dataCurveNum, sizeof(DATA_TAB), curvecmp)) {
|
||||
if ((result =
|
||||
(DATA_TAB*)sndBSearch(&key, dataCurveTab, dataCurveNum, sizeof(DATA_TAB), curvecmp))) {
|
||||
return result->data;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -584,8 +586,8 @@ void* dataGetKeymap(u16 cid) {
|
|||
static DATA_TAB* result;
|
||||
|
||||
key.id = cid;
|
||||
if (result =
|
||||
(DATA_TAB*)sndBSearch(&key, dataKeymapTab, dataKeymapNum, sizeof(DATA_TAB), curvecmp)) {
|
||||
if ((result =
|
||||
(DATA_TAB*)sndBSearch(&key, dataKeymapTab, dataKeymapNum, sizeof(DATA_TAB), curvecmp))) {
|
||||
return result->data;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -598,8 +600,8 @@ void* dataGetLayer(u16 cid, u16* n) {
|
|||
static LAYER_TAB* result;
|
||||
|
||||
key.id = cid;
|
||||
if (result =
|
||||
(LAYER_TAB*)sndBSearch(&key, dataLayerTab, dataLayerNum, sizeof(LAYER_TAB), layercmp)) {
|
||||
if ((result =
|
||||
(LAYER_TAB*)sndBSearch(&key, dataLayerTab, dataLayerNum, sizeof(LAYER_TAB), layercmp))) {
|
||||
*n = result->num;
|
||||
return result->data;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue