a couple corrections, part 2

This commit is contained in:
tildearrow 2024-09-13 23:17:01 -05:00
parent 0b0e6d5e13
commit bf8250a82c
2 changed files with 75 additions and 101 deletions

View file

@ -1032,13 +1032,13 @@ void DivInstrument::writeFeatureS2(SafeWriter* w) {
void DivInstrument::writeFeatureS3(SafeWriter* w) { void DivInstrument::writeFeatureS3(SafeWriter* w) {
FEATURE_BEGIN("S3"); FEATURE_BEGIN("S3");
w->writeC(c64.a); w->writeC(sid3.a);
w->writeC(c64.d); w->writeC(sid3.d);
w->writeC(c64.s); w->writeC(sid3.s);
w->writeC(sid3.sr); w->writeC(sid3.sr);
w->writeC(c64.r); w->writeC(sid3.r);
w->writeC(sid2.mixMode); w->writeC(sid3.mixMode);
w->writeC( w->writeC(
(sid3.phase_mod?0x80:0)| (sid3.phase_mod?0x80:0)|
@ -1442,7 +1442,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
if (sid2!=defaultIns.sid2) { if (sid2!=defaultIns.sid2) {
featureS2=true; featureS2=true;
} }
if (sid3!=defaultIns.sid3 || type == DIV_INS_SID3) { if (sid3!=defaultIns.sid3) {
featureS3=true; featureS3=true;
} }
} }
@ -1900,42 +1900,25 @@ void DivInstrument::readFeature64(SafeReader& reader, bool& volIsCutoff, short v
c64.lp=next&1; c64.lp=next&1;
next=reader.readC(); next=reader.readC();
if(type != DIV_INS_SID3)
{
c64.a=(next>>4)&15; c64.a=(next>>4)&15;
c64.d=next&15; c64.d=next&15;
}
next=reader.readC(); next=reader.readC();
if(type != DIV_INS_SID3)
{
c64.s=(next>>4)&15; c64.s=(next>>4)&15;
c64.r=next&15; c64.r=next&15;
}
if(type == DIV_INS_SID3)
{
c64.duty = reader.readS();
}
else
{
c64.duty=reader.readS()&4095; c64.duty=reader.readS()&4095;
}
unsigned short cr=reader.readS(); unsigned short cr=reader.readS();
c64.cut=cr&4095; c64.cut=cr&4095;
c64.res=cr>>12; c64.res=cr>>12;
if (version>=199) if (version>=199) {
{
next=(unsigned char)reader.readC(); next=(unsigned char)reader.readC();
c64.res|=(next & 0xf)<<4; c64.res|=(next&15)<<4;
if(version >= 218) if (version>=222) {
{ c64.resetDuty=next&0x10;
c64.resetDuty = (next & 0x10) ? true : false;
} }
} }
@ -2455,12 +2438,7 @@ void DivInstrument::readFeatureS2(SafeReader& reader, short version) {
unsigned char next=reader.readC(); unsigned char next=reader.readC();
sid2.volume=next&0xf; sid2.volume=next&0xf;
if(type != DIV_INS_SID3)
{
sid2.mixMode=(next>>4)&3; sid2.mixMode=(next>>4)&3;
}
sid2.noiseMode=next>>6; sid2.noiseMode=next>>6;
READ_FEAT_END; READ_FEAT_END;
@ -2469,11 +2447,11 @@ void DivInstrument::readFeatureS2(SafeReader& reader, short version) {
void DivInstrument::readFeatureS3(SafeReader& reader, short version) { void DivInstrument::readFeatureS3(SafeReader& reader, short version) {
READ_FEAT_BEGIN; READ_FEAT_BEGIN;
c64.a=reader.readC(); sid3.a=reader.readC();
c64.d=reader.readC(); sid3.d=reader.readC();
c64.s=reader.readC(); sid3.s=reader.readC();
sid3.sr=reader.readC(); sid3.sr=reader.readC();
c64.r=reader.readC(); sid3.r=reader.readC();
sid2.mixMode=reader.readC(); sid2.mixMode=reader.readC();
@ -2494,8 +2472,9 @@ void DivInstrument::readFeatureS3(SafeReader& reader, short version) {
unsigned char numFilters=reader.readC(); unsigned char numFilters=reader.readC();
for(int i = 0; i < numFilters; i++) for (int i=0; i<numFilters; i++) {
{ if (i>=4) break;
next=reader.readC(); next=reader.readC();
sid3.filt[i].enabled=next&0x80; sid3.filt[i].enabled=next&0x80;

View file

@ -864,8 +864,7 @@ struct DivInstrumentSID2 {
noiseMode(0) {} noiseMode(0) {}
}; };
struct DivInstrumentSID3 struct DivInstrumentSID3 {
{
bool triOn, sawOn, pulseOn, noiseOn; bool triOn, sawOn, pulseOn, noiseOn;
unsigned char a, d, s, r; unsigned char a, d, s, r;
unsigned char sr; unsigned char sr;
@ -884,8 +883,7 @@ struct DivInstrumentSID3
unsigned char feedback; unsigned char feedback;
unsigned char mixMode; unsigned char mixMode;
struct Filter struct Filter {
{
unsigned short cutoff; unsigned short cutoff;
unsigned char resonance; unsigned char resonance;
unsigned char output_volume; unsigned char output_volume;
@ -910,8 +908,7 @@ struct DivInstrumentSID3
bool bindResonanceOnNote; // only do resonance scaling once, on new note bool bindResonanceOnNote; // only do resonance scaling once, on new note
bool operator==(const Filter& other); bool operator==(const Filter& other);
bool operator!=(const Filter& other) bool operator!=(const Filter& other) {
{
return !(*this==other); return !(*this==other);
} }
Filter(): Filter():
@ -937,8 +934,7 @@ struct DivInstrumentSID3
} filt[4]; } filt[4];
bool operator==(const DivInstrumentSID3& other); bool operator==(const DivInstrumentSID3& other);
bool operator!=(const DivInstrumentSID3& other) bool operator!=(const DivInstrumentSID3& other) {
{
return !(*this==other); return !(*this==other);
} }
DivInstrumentSID3(): DivInstrumentSID3():
@ -967,8 +963,7 @@ struct DivInstrumentSID3
resetDuty(false), resetDuty(false),
phaseInv(0), phaseInv(0),
feedback(0), feedback(0),
mixMode(0) mixMode(0) {
{
filt[0].mode=16|32; // default settings so filter just works, connect to input and channel output filt[0].mode=16|32; // default settings so filter just works, connect to input and channel output
filt[0].output_volume=0xff; filt[0].output_volume=0xff;
} }