rework some of the playback logic

paving the way for C64
This commit is contained in:
tildearrow 2021-12-05 16:11:12 -05:00
parent ff07a19405
commit 0f3f173b6e
5 changed files with 65 additions and 74 deletions

View file

@ -10,31 +10,6 @@ void DivPlatformC64::acquire(int& l, int& r) {
r=l;
}
static unsigned char noiseTable[256]={
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4,
15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4,
3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
15
};
void DivPlatformC64::tick() {
for (int i=0; i<3; i++) {
chan[i].std.next();
@ -84,16 +59,10 @@ void DivPlatformC64::tick() {
//rWrite(16+i*5,chan[i].sweep);
}
}
if (chan[i].onTheKey) {
DivInstrument* ins=parent->getIns(chan[i].ins);
sid.write(i*7+4,
(ins->c64.noiseOn<<7)|
(ins->c64.pulseOn<<6)|
(ins->c64.sawOn<<5)|
(ins->c64.triOn<<4)|
1
);
chan[i].onTheKey=false;
if (chan[i].testWhen>0) {
if (--chan[i].testWhen<1) {
sid.write(i*7+4,8);
}
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
DivInstrument* ins=parent->getIns(chan[i].ins);
@ -106,9 +75,8 @@ void DivPlatformC64::tick() {
(ins->c64.pulseOn<<6)|
(ins->c64.sawOn<<5)|
(ins->c64.triOn<<4)|
8
1
);
chan[i].onTheKey=true;
}
if (chan[i].keyOff) {
sid.write(i*7+5,(ins->c64.a<<4)|(ins->c64.d));
@ -207,6 +175,9 @@ int DivPlatformC64::dispatch(DivCommand c) {
chan[c.chan].std.init(parent->getIns(chan[c.chan].ins));
chan[c.chan].inPorta=c.value;
break;
case DIV_CMD_PRE_NOTE:
chan[c.chan].testWhen=c.value;
break;
case DIV_CMD_GET_VOLMAX:
return 15;
break;

View file

@ -7,9 +7,9 @@
class DivPlatformC64: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq;
int freq, baseFreq, pitch, prevFreq, testWhen;
unsigned char ins, note, duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, onTheKey;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
DivMacroInt std;
Channel():
@ -17,6 +17,7 @@ class DivPlatformC64: public DivDispatch {
baseFreq(0),
pitch(0),
prevFreq(65535),
testWhen(0),
ins(-1),
note(0),
duty(0),
@ -28,7 +29,6 @@ class DivPlatformC64: public DivDispatch {
keyOn(false),
keyOff(false),
inPorta(false),
onTheKey(false),
vol(15),
wave(-1) {}
};