implement two systems and system vol/pan
This commit is contained in:
tildearrow 2022-01-13 01:03:57 -05:00
parent 177fe0fbdd
commit 2fcb474544
6 changed files with 72 additions and 15 deletions

View file

@ -75,6 +75,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
switch (sys) {
case DIV_SYSTEM_GENESIS:
case DIV_SYSTEM_YM2612:
dispatch=new DivPlatformGenesis;
break;
case DIV_SYSTEM_GENESIS_EXT:
@ -101,6 +102,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
((DivPlatformC64*)dispatch)->setChipModel(false);
break;
case DIV_SYSTEM_ARCADE:
case DIV_SYSTEM_YM2151:
dispatch=new DivPlatformArcade;
((DivPlatformArcade*)dispatch)->setYMFM(true);
break;

View file

@ -1080,11 +1080,11 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
}
if (tchans>DIV_MAX_CHANS) tchans=DIV_MAX_CHANS;
// system volume, skipped for now
for (int i=0; i<32; i++) reader.readC();
// system volume
for (int i=0; i<32; i++) ds.systemVol[i]=reader.readC();
// system panning, skipped for now
for (int i=0; i<32; i++) reader.readC();
// system panning
for (int i=0; i<32; i++) ds.systemPan[i]=reader.readC();
// system props, skipped for now
for (int i=0; i<32; i++) reader.readI();
@ -1517,13 +1517,11 @@ SafeWriter* DivEngine::saveFur() {
}
for (int i=0; i<32; i++) {
// for now
w->writeC(64);
w->writeC(song.systemVol[i]);
}
for (int i=0; i<32; i++) {
// for now
w->writeC(0);
w->writeC(song.systemPan[i]);
}
for (int i=0; i<32; i++) {

View file

@ -101,6 +101,7 @@ bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effe
switch (sysOfChan[ch]) {
case DIV_SYSTEM_GENESIS:
case DIV_SYSTEM_GENESIS_EXT:
case DIV_SYSTEM_YM2612:
switch (effect) {
case 0x17: // DAC enable
dispatchCmd(DivCommand(DIV_CMD_SAMPLE_MODE,ch,(effectVal>0)));
@ -179,12 +180,14 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char
switch (sysOfChan[ch]) {
case DIV_SYSTEM_GENESIS:
case DIV_SYSTEM_GENESIS_EXT:
case DIV_SYSTEM_YM2612:
case DIV_SYSTEM_ARCADE:
case DIV_SYSTEM_YM2151:
case DIV_SYSTEM_YM2610:
case DIV_SYSTEM_YM2610_EXT:
switch (effect) {
case 0x10: // LFO or noise mode
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE) {
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE || sysOfChan[ch]==DIV_SYSTEM_YM2151) {
dispatchCmd(DivCommand(DIV_CMD_STD_NOISE_FREQ,ch,effectVal));
} else {
dispatchCmd(DivCommand(DIV_CMD_FM_LFO,ch,effectVal));
@ -211,12 +214,12 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char
}
break;
case 0x17: // arcade LFO
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE) {
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE || sysOfChan[ch]==DIV_SYSTEM_YM2151) {
dispatchCmd(DivCommand(DIV_CMD_FM_LFO,ch,effectVal));
}
break;
case 0x18: // EXT or LFO waveform
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE) {
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE || sysOfChan[ch]==DIV_SYSTEM_YM2151) {
dispatchCmd(DivCommand(DIV_CMD_FM_LFO_WAVE,ch,effectVal));
} else {
dispatchCmd(DivCommand(DIV_CMD_FM_EXTCH,ch,effectVal));
@ -238,7 +241,7 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char
dispatchCmd(DivCommand(DIV_CMD_FM_AR,ch,3,effectVal&31));
break;
case 0x20: // PCM frequency or Neo Geo PSG mode
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE) {
if (sysOfChan[ch]==DIV_SYSTEM_ARCADE || sysOfChan[ch]==DIV_SYSTEM_YM2151) {
dispatchCmd(DivCommand(DIV_CMD_SAMPLE_FREQ,ch,effectVal));
} else if (sysOfChan[ch]==DIV_SYSTEM_YM2610 || sysOfChan[ch]==DIV_SYSTEM_YM2610_EXT) {
dispatchCmd(DivCommand(DIV_CMD_STD_NOISE_MODE,ch,effectVal));
@ -540,7 +543,7 @@ void DivEngine::processRow(int i, bool afterDelay) {
break;
case 0xe5: // pitch
chan[i].pitch=effectVal-0x80;
if (sysOfChan[i]==DIV_SYSTEM_ARCADE) { // arcade pitch oddity
if (sysOfChan[i]==DIV_SYSTEM_ARCADE || sysOfChan[i]==DIV_SYSTEM_YM2151) { // YM2151 pitch oddity
chan[i].pitch*=2;
if (chan[i].pitch<-128) chan[i].pitch=-128;
if (chan[i].pitch>127) chan[i].pitch=127;
@ -967,6 +970,12 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
out[1][j]+=(float)disCont[i].bbOut[0][j]/16384.0;
}
}
float volL=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127-(int)song.systemPan[i])/127.0f);
float volR=((float)song.systemVol[i]/64.0f)*((float)MIN(127,127+(int)song.systemPan[i])/127.0f);
for (size_t j=0; j<size; j++) {
out[0][j]*=volL;
out[1][j]*=volR;
}
}
if (metronome) for (size_t i=0; i<size; i++) {

View file

@ -84,9 +84,10 @@ struct DivSong {
unsigned char version;
// system
// TODO: multi-chip support
DivSystem system[32];
unsigned char systemLen;
signed char systemVol[32];
signed char systemPan[32];
// song information
String name, author;
@ -146,6 +147,8 @@ struct DivSong {
sampleLen(0) {
for (int i=0; i<32; i++) {
system[i]=DIV_SYSTEM_NULL;
systemVol[i]=64;
systemPan[i]=0;
}
system[0]=DIV_SYSTEM_GENESIS;
}