GUI: fix loop not updating samples on SNES

This commit is contained in:
tildearrow 2022-10-02 01:32:12 -05:00
parent 85f739497f
commit 0c79280aae
4 changed files with 34 additions and 1 deletions

View File

@ -985,6 +985,16 @@ int DivEngine::loadSampleROM(String path, ssize_t expectedSize, unsigned char*&
return 0;
}
unsigned int DivEngine::getSampleFormatMask() {
unsigned int formatMask=1U<<16; // 16-bit is always on
for (int i=0; i<song.systemLen; i++) {
const DivSysDef* s=getSystemDef(song.system[i]);
if (s==NULL) continue;
formatMask|=s->sampleFormatMask;
}
return formatMask;
}
int DivEngine::loadSampleROMs() {
if (yrw801ROM!=NULL) {
delete[] yrw801ROM;
@ -1016,6 +1026,8 @@ void DivEngine::renderSamples() {
sPreview.pos=0;
sPreview.dir=false;
logD("rendering samples...");
// step 0: make sample format mask
unsigned int formatMask=1U<<16; // 16-bit is always on
for (int i=0; i<song.systemLen; i++) {

View File

@ -906,6 +906,9 @@ class DivEngine {
// load sample ROMs
int loadSampleROMs();
// get the sample format mask
unsigned int getSampleFormatMask();
// UNSAFE render samples - only execute when locked
void renderSamples();

View File

@ -447,7 +447,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
}
if (returnAfterPre) return;
} else {
logV("honoring delay at position %d",whatRow);
//logV("honoring delay at position %d",whatRow);
}
if (chan[i].delayLocked) return;

View File

@ -120,6 +120,9 @@ void FurnaceGUI::drawSampleEdit() {
sample->loopEnd=sample->samples;
}
updateSampleTex=true;
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
}
if (ImGui::IsItemHovered() && sample->depth==DIV_SAMPLE_DEPTH_BRR) {
ImGui::SetTooltip("changing the loop in a BRR sample may result in glitches!");
@ -156,6 +159,9 @@ void FurnaceGUI::drawSampleEdit() {
sample->loopStart=sample->loopEnd;
}
updateSampleTex=true;
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
}
if (ImGui::IsItemActive()) {
keepLoopAlive=true;
@ -175,6 +181,9 @@ void FurnaceGUI::drawSampleEdit() {
sample->loopEnd=sample->samples;
}
updateSampleTex=true;
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
}
if (ImGui::IsItemActive()) {
keepLoopAlive=true;
@ -693,6 +702,9 @@ void FurnaceGUI::drawSampleEdit() {
sample->loopEnd=sample->samples;
}
updateSampleTex=true;
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
}
if (ImGui::IsItemHovered() && sample->depth==DIV_SAMPLE_DEPTH_BRR) {
ImGui::SetTooltip("changing the loop in a BRR sample may result in glitches!");
@ -729,6 +741,9 @@ void FurnaceGUI::drawSampleEdit() {
if (sample->loopStart>sample->loopEnd) {
sample->loopStart=sample->loopEnd;
}
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
updateSampleTex=true;
}
if (ImGui::IsItemActive()) {
@ -748,6 +763,9 @@ void FurnaceGUI::drawSampleEdit() {
if (sample->loopEnd>=(int)sample->samples) {
sample->loopEnd=sample->samples;
}
if (e->getSampleFormatMask()&(1U<<DIV_SAMPLE_DEPTH_BRR)) {
e->renderSamplesP();
}
updateSampleTex=true;
}
if (ImGui::IsItemActive()) {