a lot of work
- round to nearest instead of round to zero in SMS period calc - implement arpeggio - implement arp macro (kinda) - polish the SMS platform - correct the DIV_CMD_PITCH range to 1 semitone - fix PSG volume in Genesis - use a better register write strat in Genesis - fix a bug caused by legacy code - implement ECxx command - implement EDxx command - implement SN noise mode command - vibrato table is now 64 positions long (instead of 60)
This commit is contained in:
parent
f2c70df4a8
commit
dbc2e6285f
12 changed files with 264 additions and 173 deletions
|
|
@ -2,7 +2,7 @@
|
|||
#include "../engine.h"
|
||||
#include <math.h>
|
||||
|
||||
void DivPlatformSMS::acquire(short& l, short& r) {
|
||||
void DivPlatformSMS::acquire(int& l, int& r) {
|
||||
short v;
|
||||
sn->sound_stream_update(&v,1);
|
||||
l=v;
|
||||
|
|
@ -13,10 +13,14 @@ void DivPlatformSMS::tick() {
|
|||
for (int i=0; i<4; i++) {
|
||||
chan[i].std.next();
|
||||
if (chan[i].std.hadVol) sn->write(0x90|(i<<5)|(15-((chan[i].vol*chan[i].std.vol)>>4)));
|
||||
if (chan[i].std.hadArp) {
|
||||
chan[i].baseFreq=round(1712.0f/pow(2.0f,((float)(chan[i].note+chan[i].std.arp-12)/12.0f)));
|
||||
chan[i].freqChanged=true;
|
||||
}
|
||||
}
|
||||
for (int i=0; i<3; i++) {
|
||||
if (chan[i].freqChanged) {
|
||||
chan[i].freq=(chan[i].baseFreq*(2048-chan[i].pitch))>>11;
|
||||
chan[i].freq=(chan[i].baseFreq*(ONE_SEMITONE-chan[i].pitch))/ONE_SEMITONE;
|
||||
sn->write(0x80|i<<5|(chan[i].freq&15));
|
||||
sn->write(chan[i].freq>>4);
|
||||
chan[i].freqChanged=false;
|
||||
|
|
@ -24,7 +28,7 @@ void DivPlatformSMS::tick() {
|
|||
}
|
||||
if (chan[3].freqChanged || updateSNMode) {
|
||||
updateSNMode=false;
|
||||
chan[3].freq=(chan[3].baseFreq*(2048-chan[3].pitch))>>11;
|
||||
chan[3].freq=(chan[3].baseFreq*(ONE_SEMITONE-chan[3].pitch))/ONE_SEMITONE;
|
||||
chan[3].freqChanged=false;
|
||||
if (snNoiseMode&2) { // take period from channel 3
|
||||
if (snNoiseMode&1) {
|
||||
|
|
@ -47,7 +51,7 @@ void DivPlatformSMS::tick() {
|
|||
int DivPlatformSMS::dispatch(DivCommand c) {
|
||||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON:
|
||||
chan[c.chan].baseFreq=1712/pow(2.0f,((float)c.value/12.0f));
|
||||
chan[c.chan].baseFreq=round(1712.0f/pow(2.0f,((float)c.value/12.0f)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
chan[c.chan].active=true;
|
||||
|
|
@ -61,7 +65,7 @@ int DivPlatformSMS::dispatch(DivCommand c) {
|
|||
break;
|
||||
case DIV_CMD_INSTRUMENT:
|
||||
chan[c.chan].ins=c.value;
|
||||
chan[c.chan].std.init(parent->song.ins[chan[c.chan].ins]);
|
||||
//chan[c.chan].std.init(parent->song.ins[chan[c.chan].ins]);
|
||||
break;
|
||||
case DIV_CMD_VOLUME:
|
||||
chan[c.chan].vol=c.value;
|
||||
|
|
@ -71,10 +75,35 @@ int DivPlatformSMS::dispatch(DivCommand c) {
|
|||
chan[c.chan].pitch=c.value;
|
||||
chan[c.chan].freqChanged=true;
|
||||
break;
|
||||
case DIV_CMD_NOTE_PORTA: {
|
||||
int destFreq=round(1712.0f/pow(2.0f,((float)c.value2/12.0f)));
|
||||
bool return2=false;
|
||||
if (destFreq>chan[c.chan].baseFreq) {
|
||||
chan[c.chan].baseFreq+=c.value;
|
||||
if (chan[c.chan].baseFreq>=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
} else {
|
||||
chan[c.chan].baseFreq-=c.value;
|
||||
if (chan[c.chan].baseFreq<=destFreq) {
|
||||
chan[c.chan].baseFreq=destFreq;
|
||||
return2=true;
|
||||
}
|
||||
}
|
||||
chan[c.chan].freqChanged=true;
|
||||
if (return2) return 2;
|
||||
break;
|
||||
}
|
||||
case DIV_CMD_STD_NOISE_MODE:
|
||||
snNoiseMode=(c.value&1)|((c.value&16)>>3);
|
||||
updateSNMode=true;
|
||||
break;
|
||||
case DIV_CMD_LEGATO:
|
||||
chan[c.chan].baseFreq=round(1712.0f/pow(2.0f,((float)c.value/12.0f)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue