dev193 - AY: fix wave macro

prior to this version, the wave macro was offset by 1
- 0 = square
- 1 = noise
- 2 = square + noise
- ...
due to Defle crap...

now it's no longer offset
- 0 = nothing
- 1 = square
- 2 = noise
- ...
This commit is contained in:
tildearrow 2024-02-19 18:58:50 -05:00
parent dbcd552811
commit b0be01146e
6 changed files with 34 additions and 10 deletions

View file

@ -54,8 +54,8 @@ class DivWorkPool;
#define DIV_UNSTABLE
#define DIV_VERSION "dev192 new osc"
#define DIV_ENGINE_VERSION 192
#define DIV_VERSION "dev193"
#define DIV_ENGINE_VERSION 193
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02

View file

@ -558,6 +558,11 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
} else {
ins->std.waveMacro.val[j]=reader.readI();
}
// piece of crap offset by 1
if (ds.system[0]==DIV_SYSTEM_YM2610 || ds.system[0]==DIV_SYSTEM_YM2610_EXT) {
ins->std.waveMacro.val[j]++;
}
}
if (ins->std.waveMacro.len>0) {
ins->std.waveMacro.open=true;
@ -1435,7 +1440,12 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
if (realWaveMacroLen>127) realWaveMacroLen=127;
w->writeC(realWaveMacroLen);
for (int j=0; j<realWaveMacroLen; j++) {
w->writeI(i->std.waveMacro.val[j]);
// piece of crap offset by 1
if (song.system[0]==DIV_SYSTEM_YM2610 || song.system[0]==DIV_SYSTEM_YM2610_EXT) {
w->writeI(i->std.waveMacro.val[j]-1);
} else {
w->writeI(i->std.waveMacro.val[j]);
}
}
if (realWaveMacroLen>0) {
w->writeC(i->std.waveMacro.loop);

View file

@ -1525,6 +1525,14 @@ void DivInstrument::readFeatureMA(SafeReader& reader, short version) {
}
}
if (version<193) {
if (type==DIV_INS_AY || type==DIV_INS_AY8930) {
for (int j=0; j<std.waveMacro.len; j++) {
std.waveMacro.val[j]++;
}
}
}
READ_FEAT_END;
}
@ -2325,6 +2333,13 @@ DivDataErrors DivInstrument::readInsDataOld(SafeReader &reader, short version) {
std.dutyMacro.val[j]-=12;
}
}
if (version<193) {
if (type==DIV_INS_AY || type==DIV_INS_AY8930) {
for (int j=0; j<std.waveMacro.len; j++) {
std.waveMacro.val[j]++;
}
}
}
if (version>=17) {
READ_MACRO_VALS(std.pitchMacro.val,std.pitchMacro.len);
READ_MACRO_VALS(std.ex1Macro.val,std.ex1Macro.len);

View file

@ -266,9 +266,7 @@ void DivPlatformAY8910::tick(bool sysTick) {
}
if (chan[i].std.wave.had) {
if (!(chan[i].nextPSGMode.val&8)) {
// TODO: clean up.
// why does Defle start from 1?!
chan[i].nextPSGMode.val=(chan[i].std.wave.val+1)&7;
chan[i].nextPSGMode.val=chan[i].std.wave.val&7;
if (chan[i].active) {
chan[i].curPSGMode.val=chan[i].nextPSGMode.val;
}

View file

@ -256,9 +256,7 @@ void DivPlatformAY8930::tick(bool sysTick) {
}
if (chan[i].std.wave.had) {
if (!(chan[i].nextPSGMode.val&8)) {
// TODO: clean up.
// why does Defle start from 1?!
chan[i].nextPSGMode.val=(chan[i].std.wave.val+1)&7;
chan[i].nextPSGMode.val=chan[i].std.wave.val&7;
if (chan[i].active) {
chan[i].curPSGMode.val=chan[i].nextPSGMode.val;
}

View file

@ -1529,6 +1529,9 @@ void FurnaceGUI::drawMacroEdit(FurnaceGUIMacroDesc& i, int totalFit, float avail
static float bit30Indicator[256];
static bool doHighlight[256];
// TODO: clean up
assert(i.bitOffset==0);
if ((i.macro->open&6)==0) {
for (int j=0; j<256; j++) {
bit30Indicator[j]=0;
@ -7136,7 +7139,7 @@ void FurnaceGUI::drawInsEdit() {
}
}
if (waveMax>0) {
macroList.push_back(FurnaceGUIMacroDesc(waveLabel,&ins->std.waveMacro,0,waveMax,(waveBitMode && ins->type!=DIV_INS_PET)?64:160,uiColors[GUI_COLOR_MACRO_WAVE],false,NULL,NULL,waveBitMode,waveNames,((ins->type==DIV_INS_AY || ins->type==DIV_INS_AY8930)?1:0)));
macroList.push_back(FurnaceGUIMacroDesc(waveLabel,&ins->std.waveMacro,0,waveMax,(waveBitMode && ins->type!=DIV_INS_PET)?64:160,uiColors[GUI_COLOR_MACRO_WAVE],false,NULL,NULL,waveBitMode,waveNames,0));
}
if (panMax>0) {
if (panSingle) {