From 943e4e374f16c0549bd19cf04ba8918add125bb3 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 3 Jan 2022 23:22:39 -0500 Subject: [PATCH] better compatibility with old GB modules --- src/engine/engine.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 87c8cfc4c..d336dac54 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -819,6 +819,17 @@ bool DivEngine::load(unsigned char* f, size_t slen) { ins->gb.soundLen=reader.readC(); logD("GB data: vol %d dir %d len %d sl %d\n",ins->gb.envVol,ins->gb.envDir,ins->gb.envLen,ins->gb.soundLen); + } else if (ds.system==DIV_SYSTEM_GB) { + // try to convert macro to envelope + if (ins->std.volMacroLen>0) { + ins->gb.envVol=ins->std.volMacro[0]; + if (ins->std.volMacro[0]std.volMacro[1]) { + ins->gb.envDir=true; + } + if (ins->std.volMacro[ins->std.volMacroLen-1]==0) { + ins->gb.soundLen=ins->std.volMacroLen*2; + } + } } } @@ -878,6 +889,12 @@ bool DivEngine::load(unsigned char* f, size_t slen) { // ditto pat->data[k][1]--; } + if (ds.version<0x12) { + if (ds.system==DIV_SYSTEM_GB && i==3 && pat->data[k][1]>0) { + // back then noise was 2 octaves lower + pat->data[k][1]-=2; + } + } // volume pat->data[k][3]=reader.readS(); if (ds.version<0x0a) { @@ -888,6 +905,12 @@ bool DivEngine::load(unsigned char* f, size_t slen) { pat->data[k][3]>>=1; } } + if (ds.version<0x12) { + if (ds.system==DIV_SYSTEM_GB && i==2 && pat->data[k][3]>0) { + // volume range of GB wave channel was 0-3 rather than 0-F + pat->data[k][3]=(pat->data[k][3]&3)*5; + } + } for (int l=0; ldata[k][4+(l<<1)]=reader.readS();