out of bounds and non-determinism fixes
the soldiers play properly now
This commit is contained in:
parent
485c4bbadc
commit
23dc645ced
|
@ -3,6 +3,10 @@
|
|||
void DivMacroInt::next() {
|
||||
if (ins==NULL) return;
|
||||
|
||||
if (finishedVol) finishedVol=false;
|
||||
if (hadVol!=hasVol) {
|
||||
finishedVol=true;
|
||||
}
|
||||
hadVol=hasVol;
|
||||
if (hasVol) {
|
||||
vol=ins->std.volMacro[volPos++];
|
||||
|
@ -15,6 +19,10 @@ void DivMacroInt::next() {
|
|||
}
|
||||
}
|
||||
|
||||
if (finishedArp) finishedArp=false;
|
||||
if (hadArp!=hasArp) {
|
||||
finishedArp=true;
|
||||
}
|
||||
hadArp=hasArp;
|
||||
if (hasArp) {
|
||||
arp=ins->std.arpMacro[arpPos++];
|
||||
|
@ -27,6 +35,10 @@ void DivMacroInt::next() {
|
|||
}
|
||||
}
|
||||
|
||||
if (finishedDuty) finishedDuty=false;
|
||||
if (hadDuty!=hasDuty) {
|
||||
finishedDuty=true;
|
||||
}
|
||||
hadDuty=hasDuty;
|
||||
if (hasDuty) {
|
||||
duty=ins->std.dutyMacro[dutyPos++];
|
||||
|
@ -39,6 +51,10 @@ void DivMacroInt::next() {
|
|||
}
|
||||
}
|
||||
|
||||
if (finishedWave) finishedWave=false;
|
||||
if (hadWave!=hasWave) {
|
||||
finishedWave=true;
|
||||
}
|
||||
hadWave=hasWave;
|
||||
if (hasWave) {
|
||||
wave=ins->std.waveMacro[wavePos++];
|
||||
|
|
|
@ -10,11 +10,16 @@ class DivMacroInt {
|
|||
unsigned char vol, arp, duty, wave;
|
||||
bool hasVol, hasArp, hasDuty, hasWave;
|
||||
bool hadVol, hadArp, hadDuty, hadWave;
|
||||
bool finishedVol, finishedArp, finishedDuty, finishedWave;
|
||||
bool arpMode;
|
||||
void next();
|
||||
void init(DivInstrument* which);
|
||||
DivMacroInt():
|
||||
ins(NULL),
|
||||
volPos(0),
|
||||
arpPos(0),
|
||||
dutyPos(0),
|
||||
wavePos(0),
|
||||
vol(0),
|
||||
arp(0),
|
||||
duty(0),
|
||||
|
@ -27,6 +32,10 @@ class DivMacroInt {
|
|||
hadArp(false),
|
||||
hadDuty(false),
|
||||
hadWave(false),
|
||||
finishedVol(false),
|
||||
finishedArp(false),
|
||||
finishedDuty(false),
|
||||
finishedWave(false),
|
||||
arpMode(false) {}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
struct DivOrders {
|
||||
unsigned char ord[32][128];
|
||||
|
||||
DivOrders() {
|
||||
memset(ord,0,32*128);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -68,6 +68,8 @@ void DivPlatformGB::tick() {
|
|||
} else {
|
||||
chan[i].baseFreq=chan[i].note+chan[i].std.arp-12;
|
||||
}
|
||||
if (chan[i].baseFreq>255) chan[i].baseFreq=255;
|
||||
if (chan[i].baseFreq<0) chan[i].baseFreq=0;
|
||||
} else {
|
||||
if (chan[i].std.arpMode) {
|
||||
chan[i].baseFreq=round(FREQ_BASE/pow(2.0f,((float)(chan[i].std.arp+24)/12.0f)));
|
||||
|
@ -76,6 +78,11 @@ void DivPlatformGB::tick() {
|
|||
}
|
||||
}
|
||||
chan[i].freqChanged=true;
|
||||
} else {
|
||||
if (chan[i].std.arpMode && chan[i].std.finishedArp) {
|
||||
chan[i].baseFreq=round(FREQ_BASE/pow(2.0f,((float)(chan[i].note)/12.0f)));
|
||||
chan[i].freqChanged=true;
|
||||
}
|
||||
}
|
||||
if (chan[i].std.hadDuty) {
|
||||
chan[i].duty=chan[i].std.duty;
|
||||
|
@ -139,13 +146,6 @@ void DivPlatformGB::tick() {
|
|||
chan[i].freqChanged=false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<64; i++) {
|
||||
if (pendingWrites[i]!=oldWrites[i]) {
|
||||
GB_apu_write(gb,i,pendingWrites[i]&0xff);
|
||||
oldWrites[i]=pendingWrites[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformGB::dispatch(DivCommand c) {
|
||||
|
@ -192,7 +192,7 @@ int DivPlatformGB::dispatch(DivCommand c) {
|
|||
if (c.chan!=2) break;
|
||||
chan[c.chan].wave=c.value;
|
||||
updateWave();
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].keyOn=true;
|
||||
break;
|
||||
case DIV_CMD_NOTE_PORTA: {
|
||||
int destFreq=round(FREQ_BASE/pow(2.0f,((float)c.value2/12.0f)));
|
||||
|
@ -268,14 +268,9 @@ int DivPlatformGB::init(DivEngine* p, int channels, int sugRate) {
|
|||
gb->model=GB_MODEL_DMG_B;
|
||||
GB_apu_init(gb);
|
||||
GB_set_sample_rate(gb,rate);
|
||||
for (int i=0; i<64; i++) {
|
||||
oldWrites[i]=-1;
|
||||
pendingWrites[i]=-1;
|
||||
}
|
||||
// enable all channels
|
||||
GB_apu_write(gb,0x26,0x80);
|
||||
GB_apu_write(gb,0x25,0xff);
|
||||
lastPan=0xff;
|
||||
updateSNMode=false;
|
||||
return 4;
|
||||
}
|
||||
|
|
|
@ -31,9 +31,6 @@ class DivPlatformGB: public DivDispatch {
|
|||
};
|
||||
Channel chan[4];
|
||||
unsigned char lastPan;
|
||||
bool updateSNMode;
|
||||
short oldWrites[64];
|
||||
short pendingWrites[64];
|
||||
|
||||
GB_gameboy_t* gb;
|
||||
void updateWave();
|
||||
|
|
|
@ -97,4 +97,36 @@ struct DivSong {
|
|||
|
||||
DivInstrument nullIns;
|
||||
DivWavetable nullWave;
|
||||
|
||||
DivSong():
|
||||
version(0),
|
||||
system(DIV_SYSTEM_NULL),
|
||||
name(""),
|
||||
author(""),
|
||||
carrier(""),
|
||||
composer(""),
|
||||
vendor(""),
|
||||
category(""),
|
||||
writer(""),
|
||||
arranger(""),
|
||||
copyright(""),
|
||||
manGroup(""),
|
||||
manInfo(""),
|
||||
createdDate(""),
|
||||
revisionDate(""),
|
||||
hilightA(4),
|
||||
hilightB(16),
|
||||
timeBase(1),
|
||||
speed1(6),
|
||||
speed2(6),
|
||||
arpLen(1),
|
||||
pal(false),
|
||||
customTempo(false),
|
||||
hz(60),
|
||||
patLen(0),
|
||||
ordersLen(0),
|
||||
insLen(0),
|
||||
waveLen(0),
|
||||
sampleLen(0) {
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
struct DivWavetable {
|
||||
int len;
|
||||
int data[32];
|
||||
|
||||
DivWavetable():
|
||||
len(32) {
|
||||
memset(data,0,32*sizeof(int));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue