truly fix .dmp arp macro saving

(hopefully)
This commit is contained in:
tildearrow 2022-10-01 23:59:23 -05:00
parent 7b55ba4e77
commit bcc94fd459
2 changed files with 32 additions and 11 deletions

View file

@ -4977,8 +4977,6 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
} }
} }
// TODO: take care of new arp macro format
w->writeC(i->std.arpMacro.len);
bool arpMacroMode=false; bool arpMacroMode=false;
int arpMacroHowManyFixed=0; int arpMacroHowManyFixed=0;
int realArpMacroLen=i->std.arpMacro.len; int realArpMacroLen=i->std.arpMacro.len;
@ -4996,15 +4994,27 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
} }
} }
if (realArpMacroLen>127) realArpMacroLen=127;
w->writeC(realArpMacroLen);
if (arpMacroMode) { if (arpMacroMode) {
for (int j=0; j<realArpMacroLen; j++) { for (int j=0; j<realArpMacroLen; j++) {
if ((i->std.arpMacro.val[j]&0xc0000000)==0x40000000 || (i->std.arpMacro.val[j]&0xc0000000)==0x80000000) {
w->writeI(i->std.arpMacro.val[j]^0x40000000);
} else {
w->writeI(i->std.arpMacro.val[j]); w->writeI(i->std.arpMacro.val[j]);
} }
}
} else { } else {
for (int j=0; j<realArpMacroLen; j++) { for (int j=0; j<realArpMacroLen; j++) {
if ((i->std.arpMacro.val[j]&0xc0000000)==0x40000000 || (i->std.arpMacro.val[j]&0xc0000000)==0x80000000) {
w->writeI((i->std.arpMacro.val[j]^0x40000000)+12);
} else {
w->writeI(i->std.arpMacro.val[j]+12); w->writeI(i->std.arpMacro.val[j]+12);
} }
} }
}
if (realArpMacroLen>0) { if (realArpMacroLen>0) {
w->writeC(i->std.arpMacro.loop); w->writeC(i->std.arpMacro.loop);
} }

View file

@ -1501,12 +1501,11 @@ bool DivInstrument::saveDMP(const char* path) {
if (std.volMacro.len>0) w->writeC(std.volMacro.loop); if (std.volMacro.len>0) w->writeC(std.volMacro.loop);
} }
w->writeC(std.arpMacro.len);
bool arpMacroMode=false; bool arpMacroMode=false;
int arpMacroHowManyFixed=0; int arpMacroHowManyFixed=0;
int realArpMacroLen=std.arpMacro.len; int realArpMacroLen=std.arpMacro.len;
for (int i=0; i<std.arpMacro.len; i++) { for (int j=0; j<std.arpMacro.len; j++) {
if ((std.arpMacro.val[i]&0xc0000000)==0x40000000 || (std.arpMacro.val[i]&0xc0000000)==0x80000000) { if ((std.arpMacro.val[j]&0xc0000000)==0x40000000 || (std.arpMacro.val[j]&0xc0000000)==0x80000000) {
arpMacroHowManyFixed++; arpMacroHowManyFixed++;
} }
} }
@ -1519,13 +1518,25 @@ bool DivInstrument::saveDMP(const char* path) {
} }
} }
if (realArpMacroLen>127) realArpMacroLen=127;
w->writeC(realArpMacroLen);
if (arpMacroMode) { if (arpMacroMode) {
for (int i=0; i<realArpMacroLen; i++) { for (int j=0; j<realArpMacroLen; j++) {
w->writeI(std.arpMacro.val[i]); if ((std.arpMacro.val[j]&0xc0000000)==0x40000000 || (std.arpMacro.val[j]&0xc0000000)==0x80000000) {
w->writeI(std.arpMacro.val[j]^0x40000000);
} else {
w->writeI(std.arpMacro.val[j]);
}
} }
} else { } else {
for (int i=0; i<realArpMacroLen; i++) { for (int j=0; j<realArpMacroLen; j++) {
w->writeI(std.arpMacro.val[i]+12); if ((std.arpMacro.val[j]&0xc0000000)==0x40000000 || (std.arpMacro.val[j]&0xc0000000)==0x80000000) {
w->writeI((std.arpMacro.val[j]^0x40000000)+12);
} else {
w->writeI(std.arpMacro.val[j]+12);
}
} }
} }
if (realArpMacroLen>0) { if (realArpMacroLen>0) {