2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
2023-01-20 00:18:40 +00:00
|
|
|
* Copyright (C) 2021-2023 tildearrow and contributors
|
2022-02-15 03:12:20 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2022-01-17 06:42:26 +00:00
|
|
|
#include "blip_buf.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
#include "engine.h"
|
|
|
|
#include "platform/genesis.h"
|
|
|
|
#include "platform/genesisext.h"
|
2022-10-01 08:15:40 +00:00
|
|
|
#include "platform/msm5232.h"
|
2022-05-24 00:01:10 +00:00
|
|
|
#include "platform/msm6258.h"
|
2022-05-23 06:46:58 +00:00
|
|
|
#include "platform/msm6295.h"
|
2022-05-20 20:29:09 +00:00
|
|
|
#include "platform/namcowsg.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
#include "platform/sms.h"
|
2022-02-25 09:26:01 +00:00
|
|
|
#include "platform/opll.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
#include "platform/gb.h"
|
|
|
|
#include "platform/pce.h"
|
|
|
|
#include "platform/nes.h"
|
|
|
|
#include "platform/c64.h"
|
|
|
|
#include "platform/arcade.h"
|
2022-10-12 05:12:56 +00:00
|
|
|
#include "platform/t6w28.h"
|
2022-04-07 03:56:06 +00:00
|
|
|
#include "platform/tx81z.h"
|
2022-05-11 08:29:03 +00:00
|
|
|
#include "platform/ym2203.h"
|
2022-05-15 07:00:36 +00:00
|
|
|
#include "platform/ym2203ext.h"
|
2022-05-13 07:52:43 +00:00
|
|
|
#include "platform/ym2608.h"
|
2022-05-19 03:49:21 +00:00
|
|
|
#include "platform/ym2608ext.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
#include "platform/ym2610.h"
|
|
|
|
#include "platform/ym2610ext.h"
|
2022-02-24 16:02:35 +00:00
|
|
|
#include "platform/ym2610b.h"
|
|
|
|
#include "platform/ym2610bext.h"
|
2022-01-13 07:52:19 +00:00
|
|
|
#include "platform/ay.h"
|
2022-01-14 05:02:10 +00:00
|
|
|
#include "platform/ay8930.h"
|
2022-03-05 23:18:08 +00:00
|
|
|
#include "platform/opl.h"
|
2022-01-14 08:37:36 +00:00
|
|
|
#include "platform/tia.h"
|
2022-01-14 21:29:27 +00:00
|
|
|
#include "platform/saa.h"
|
2022-01-15 22:28:33 +00:00
|
|
|
#include "platform/amiga.h"
|
2022-03-04 23:18:43 +00:00
|
|
|
#include "platform/pcspkr.h"
|
2022-12-13 18:32:35 +00:00
|
|
|
#include "platform/pokemini.h"
|
2022-02-23 07:52:30 +00:00
|
|
|
#include "platform/segapcm.h"
|
2022-02-22 09:01:57 +00:00
|
|
|
#include "platform/qsound.h"
|
2022-03-04 11:13:49 +00:00
|
|
|
#include "platform/vera.h"
|
2022-03-06 17:31:03 +00:00
|
|
|
#include "platform/x1_010.h"
|
2022-04-27 09:48:56 +00:00
|
|
|
#include "platform/su.h"
|
2022-03-07 12:04:20 +00:00
|
|
|
#include "platform/swan.h"
|
2022-02-20 17:15:15 +00:00
|
|
|
#include "platform/lynx.h"
|
2022-12-20 00:45:04 +00:00
|
|
|
#include "platform/pokey.h"
|
2022-07-02 18:42:47 +00:00
|
|
|
#include "platform/zxbeeper.h"
|
2022-03-17 01:11:48 +00:00
|
|
|
#include "platform/bubsyswsg.h"
|
2022-03-22 16:48:45 +00:00
|
|
|
#include "platform/n163.h"
|
2022-03-21 14:02:51 +00:00
|
|
|
#include "platform/pet.h"
|
2022-10-24 08:19:42 +00:00
|
|
|
#include "platform/pong.h"
|
2022-03-22 07:48:48 +00:00
|
|
|
#include "platform/vic20.h"
|
2022-03-27 16:06:56 +00:00
|
|
|
#include "platform/vrc6.h"
|
2022-04-04 03:37:16 +00:00
|
|
|
#include "platform/fds.h"
|
2022-04-06 05:34:12 +00:00
|
|
|
#include "platform/mmc5.h"
|
2022-04-20 16:52:37 +00:00
|
|
|
#include "platform/es5506.h"
|
2022-05-10 04:18:25 +00:00
|
|
|
#include "platform/scc.h"
|
2022-05-18 06:55:33 +00:00
|
|
|
#include "platform/ymz280b.h"
|
2022-05-20 18:45:26 +00:00
|
|
|
#include "platform/rf5c68.h"
|
2022-03-21 07:38:12 +00:00
|
|
|
#include "platform/snes.h"
|
2022-10-09 00:37:22 +00:00
|
|
|
#include "platform/vb.h"
|
2022-12-08 05:18:22 +00:00
|
|
|
#include "platform/k007232.h"
|
2022-12-15 11:03:54 +00:00
|
|
|
#include "platform/ga20.h"
|
2023-02-11 12:37:11 +00:00
|
|
|
#include "platform/sm8521.h"
|
2023-03-05 05:01:44 +00:00
|
|
|
#include "platform/d65010g031.h"
|
2022-07-02 18:42:47 +00:00
|
|
|
#include "platform/pcmdac.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
#include "platform/dummy.h"
|
|
|
|
#include "../ta-log.h"
|
2022-02-10 08:35:08 +00:00
|
|
|
#include "song.h"
|
2022-01-08 21:03:32 +00:00
|
|
|
|
|
|
|
void DivDispatchContainer::setRates(double gotRate) {
|
2023-01-03 06:09:46 +00:00
|
|
|
int outs=dispatch->getOutputCount();
|
|
|
|
|
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bb[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
blip_set_rates(bb[i],dispatch->rate,gotRate);
|
|
|
|
}
|
2023-01-03 19:39:31 +00:00
|
|
|
rateMemory=gotRate;
|
2022-01-08 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
2022-01-17 06:42:26 +00:00
|
|
|
void DivDispatchContainer::setQuality(bool lowQual) {
|
|
|
|
lowQuality=lowQual;
|
|
|
|
}
|
|
|
|
|
2023-01-04 22:01:14 +00:00
|
|
|
void DivDispatchContainer::grow(size_t size) {
|
|
|
|
bbInLen=size;
|
|
|
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
|
|
|
if (bbIn[i]!=NULL) {
|
|
|
|
delete[] bbIn[i];
|
|
|
|
bbIn[i]=new short[bbInLen];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-10 21:15:37 +00:00
|
|
|
#define CHECK_MISSING_BUFS \
|
|
|
|
int outs=dispatch->getOutputCount(); \
|
|
|
|
\
|
|
|
|
/* create missing buffers if any */ \
|
|
|
|
bool mustClear=false; \
|
|
|
|
for (int i=0; i<outs; i++) { \
|
|
|
|
if (bb[i]==NULL) { \
|
|
|
|
logV("creating buf %d because it doesn't exist",i); \
|
|
|
|
bb[i]=blip_new(bbInLen); \
|
|
|
|
if (bb[i]==NULL) { \
|
|
|
|
logE("not enough memory!"); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
blip_set_rates(bb[i],dispatch->rate,rateMemory); \
|
|
|
|
\
|
|
|
|
if (bbIn[i]==NULL) bbIn[i]=new short[bbInLen]; \
|
|
|
|
if (bbOut[i]==NULL) bbOut[i]=new short[bbInLen]; \
|
|
|
|
memset(bbIn[i],0,bbInLen*sizeof(short)); \
|
|
|
|
memset(bbOut[i],0,bbInLen*sizeof(short)); \
|
|
|
|
mustClear=true; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
if (mustClear) clear(); \
|
|
|
|
|
2022-01-08 22:15:12 +00:00
|
|
|
void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
2023-01-10 21:15:37 +00:00
|
|
|
CHECK_MISSING_BUFS;
|
|
|
|
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
|
|
|
if (i>=outs) {
|
|
|
|
bbInMapped[i]=NULL;
|
|
|
|
} else {
|
2023-01-10 21:15:37 +00:00
|
|
|
if (bbIn[i]==NULL) {
|
|
|
|
bbInMapped[i]=NULL;
|
|
|
|
} else {
|
|
|
|
bbInMapped[i]=&bbIn[i][offset];
|
|
|
|
}
|
2023-01-03 06:09:46 +00:00
|
|
|
}
|
2023-01-02 00:46:08 +00:00
|
|
|
}
|
|
|
|
dispatch->acquire(bbInMapped,count);
|
2022-01-08 22:15:12 +00:00
|
|
|
}
|
|
|
|
|
2022-02-08 02:31:58 +00:00
|
|
|
void DivDispatchContainer::flush(size_t count) {
|
2023-01-03 06:09:46 +00:00
|
|
|
int outs=dispatch->getOutputCount();
|
2022-02-08 02:31:58 +00:00
|
|
|
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bb[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
blip_read_samples(bb[i],bbOut[i],count,0);
|
2022-02-08 02:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) {
|
2023-01-10 21:15:37 +00:00
|
|
|
CHECK_MISSING_BUFS;
|
2023-01-04 22:01:14 +00:00
|
|
|
|
2022-04-09 23:25:25 +00:00
|
|
|
if (dcOffCompensation && runtotal>0) {
|
|
|
|
dcOffCompensation=false;
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bbIn[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
prevSample[i]=bbIn[i][0];
|
|
|
|
}
|
2022-04-09 23:25:25 +00:00
|
|
|
}
|
2022-01-17 06:42:26 +00:00
|
|
|
if (lowQuality) {
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bbIn[i]==NULL) continue;
|
|
|
|
if (bb[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
for (size_t j=0; j<runtotal; j++) {
|
|
|
|
temp[i]=bbIn[i][j];
|
|
|
|
blip_add_delta_fast(bb[i],j,temp[i]-prevSample[i]);
|
|
|
|
prevSample[i]=temp[i];
|
|
|
|
}
|
2022-01-17 06:42:26 +00:00
|
|
|
}
|
|
|
|
} else {
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bbIn[i]==NULL) continue;
|
|
|
|
if (bb[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
for (size_t j=0; j<runtotal; j++) {
|
|
|
|
temp[i]=bbIn[i][j];
|
|
|
|
blip_add_delta(bb[i],j,temp[i]-prevSample[i]);
|
|
|
|
prevSample[i]=temp[i];
|
|
|
|
}
|
2022-01-17 06:42:26 +00:00
|
|
|
}
|
2022-01-08 22:15:12 +00:00
|
|
|
}
|
|
|
|
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<outs; i++) {
|
2023-01-04 22:01:14 +00:00
|
|
|
if (bbOut[i]==NULL) continue;
|
|
|
|
if (bb[i]==NULL) continue;
|
2023-01-03 06:09:46 +00:00
|
|
|
blip_end_frame(bb[i],runtotal);
|
|
|
|
blip_read_samples(bb[i],bbOut[i]+offset,size,0);
|
|
|
|
}
|
2022-02-08 02:31:58 +00:00
|
|
|
/*if (totalRead<(int)size && totalRead>0) {
|
2022-01-18 03:15:00 +00:00
|
|
|
for (size_t i=totalRead; i<size; i++) {
|
|
|
|
bbOut[0][i]=bbOut[0][totalRead-1];//bbOut[0][totalRead];
|
|
|
|
}
|
2022-02-08 02:31:58 +00:00
|
|
|
}*/
|
2022-01-08 22:15:12 +00:00
|
|
|
}
|
|
|
|
|
2022-01-08 21:03:32 +00:00
|
|
|
void DivDispatchContainer::clear() {
|
2023-01-03 06:09:46 +00:00
|
|
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
|
|
|
if (bb[i]!=NULL) blip_clear(bb[i]);
|
|
|
|
temp[i]=0;
|
|
|
|
prevSample[i]=0;
|
|
|
|
}
|
|
|
|
|
2022-04-09 23:25:25 +00:00
|
|
|
if (dispatch->getDCOffRequired()) {
|
|
|
|
dcOffCompensation=true;
|
|
|
|
}
|
2022-01-20 02:04:51 +00:00
|
|
|
// run for one cycle to determine DC offset
|
2022-01-21 04:09:04 +00:00
|
|
|
// TODO: SAA1099 doesn't like that
|
|
|
|
/*dispatch->acquire(bbIn[0],bbIn[1],0,1);
|
2022-01-20 02:04:51 +00:00
|
|
|
temp[0]=bbIn[0][0];
|
|
|
|
temp[1]=bbIn[1][0];
|
|
|
|
prevSample[0]=temp[0];
|
2022-01-21 04:09:04 +00:00
|
|
|
prevSample[1]=temp[1];*/
|
2022-01-08 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
2022-09-30 01:13:40 +00:00
|
|
|
void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, const DivConfig& flags) {
|
2023-01-02 00:46:08 +00:00
|
|
|
// quit if we already initialized
|
2022-01-08 21:03:32 +00:00
|
|
|
if (dispatch!=NULL) return;
|
|
|
|
|
2023-01-02 00:46:08 +00:00
|
|
|
// initialize chip
|
2022-01-08 21:03:32 +00:00
|
|
|
switch (sys) {
|
2022-03-15 05:33:57 +00:00
|
|
|
case DIV_SYSTEM_YMU759:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(759,false);
|
|
|
|
break;
|
2022-01-13 06:03:57 +00:00
|
|
|
case DIV_SYSTEM_YM2612:
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformGenesis;
|
2022-02-03 04:08:45 +00:00
|
|
|
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0));
|
2022-05-27 09:02:53 +00:00
|
|
|
((DivPlatformGenesis*)dispatch)->setSoftPCM(false);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
2022-02-23 07:52:30 +00:00
|
|
|
case DIV_SYSTEM_YM2612_EXT:
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformGenesisExt;
|
2022-02-03 04:08:45 +00:00
|
|
|
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0));
|
2022-05-27 09:02:53 +00:00
|
|
|
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(false);
|
|
|
|
break;
|
2022-12-24 00:26:42 +00:00
|
|
|
case DIV_SYSTEM_YM2612_CSM:
|
|
|
|
dispatch=new DivPlatformGenesisExt;
|
|
|
|
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0));
|
|
|
|
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(false);
|
|
|
|
((DivPlatformGenesisExt*)dispatch)->setCSMChannel(6);
|
|
|
|
break;
|
2022-12-20 22:55:05 +00:00
|
|
|
case DIV_SYSTEM_YM2612_DUALPCM:
|
2022-05-27 09:02:53 +00:00
|
|
|
dispatch=new DivPlatformGenesis;
|
|
|
|
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0));
|
|
|
|
((DivPlatformGenesis*)dispatch)->setSoftPCM(true);
|
|
|
|
break;
|
2022-12-20 22:55:05 +00:00
|
|
|
case DIV_SYSTEM_YM2612_DUALPCM_EXT:
|
2022-05-27 09:02:53 +00:00
|
|
|
dispatch=new DivPlatformGenesisExt;
|
|
|
|
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0));
|
|
|
|
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(true);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_SMS:
|
|
|
|
dispatch=new DivPlatformSMS;
|
2022-05-26 23:46:20 +00:00
|
|
|
((DivPlatformSMS*)dispatch)->setNuked(eng->getConfInt("snCore",0));
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_GB:
|
|
|
|
dispatch=new DivPlatformGB;
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_PCE:
|
|
|
|
dispatch=new DivPlatformPCE;
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_NES:
|
|
|
|
dispatch=new DivPlatformNES;
|
2022-05-02 04:20:20 +00:00
|
|
|
((DivPlatformNES*)dispatch)->setNSFPlay(eng->getConfInt("nesCore",0)==1);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_C64_6581:
|
|
|
|
dispatch=new DivPlatformC64;
|
2022-08-29 08:26:49 +00:00
|
|
|
((DivPlatformC64*)dispatch)->setFP(eng->getConfInt("c64Core",1)==1);
|
2022-01-08 21:03:32 +00:00
|
|
|
((DivPlatformC64*)dispatch)->setChipModel(true);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_C64_8580:
|
|
|
|
dispatch=new DivPlatformC64;
|
2022-08-29 08:26:49 +00:00
|
|
|
((DivPlatformC64*)dispatch)->setFP(eng->getConfInt("c64Core",1)==1);
|
2022-01-08 21:03:32 +00:00
|
|
|
((DivPlatformC64*)dispatch)->setChipModel(false);
|
|
|
|
break;
|
2022-01-13 06:03:57 +00:00
|
|
|
case DIV_SYSTEM_YM2151:
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformArcade;
|
2022-01-17 21:27:57 +00:00
|
|
|
((DivPlatformArcade*)dispatch)->setYMFM(eng->getConfInt("arcadeCore",0)==0);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_YM2610:
|
2022-02-10 08:35:08 +00:00
|
|
|
case DIV_SYSTEM_YM2610_FULL:
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformYM2610;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2610*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_YM2610_EXT:
|
2022-02-10 08:35:08 +00:00
|
|
|
case DIV_SYSTEM_YM2610_FULL_EXT:
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformYM2610Ext;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2610Ext*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-01-08 21:03:32 +00:00
|
|
|
break;
|
2022-02-24 16:02:35 +00:00
|
|
|
case DIV_SYSTEM_YM2610B:
|
|
|
|
dispatch=new DivPlatformYM2610B;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2610B*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-02-24 16:02:35 +00:00
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_YM2610B_EXT:
|
|
|
|
dispatch=new DivPlatformYM2610BExt;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2610BExt*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-02-24 16:02:35 +00:00
|
|
|
break;
|
2022-01-15 22:28:33 +00:00
|
|
|
case DIV_SYSTEM_AMIGA:
|
|
|
|
dispatch=new DivPlatformAmiga;
|
|
|
|
break;
|
2022-01-13 07:52:19 +00:00
|
|
|
case DIV_SYSTEM_AY8910:
|
|
|
|
dispatch=new DivPlatformAY8910;
|
|
|
|
break;
|
2022-01-14 05:02:10 +00:00
|
|
|
case DIV_SYSTEM_AY8930:
|
|
|
|
dispatch=new DivPlatformAY8930;
|
|
|
|
break;
|
2022-04-04 03:37:16 +00:00
|
|
|
case DIV_SYSTEM_FDS:
|
|
|
|
dispatch=new DivPlatformFDS;
|
2022-05-02 21:53:55 +00:00
|
|
|
((DivPlatformFDS*)dispatch)->setNSFPlay(eng->getConfInt("fdsCore",0)==1);
|
2022-04-04 03:37:16 +00:00
|
|
|
break;
|
2022-01-14 08:37:36 +00:00
|
|
|
case DIV_SYSTEM_TIA:
|
|
|
|
dispatch=new DivPlatformTIA;
|
|
|
|
break;
|
2022-12-20 22:49:53 +00:00
|
|
|
case DIV_SYSTEM_YM2203:
|
2022-05-11 08:29:03 +00:00
|
|
|
dispatch=new DivPlatformYM2203;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2203*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-05-11 08:29:03 +00:00
|
|
|
break;
|
2022-12-20 22:49:53 +00:00
|
|
|
case DIV_SYSTEM_YM2203_EXT:
|
2022-05-15 07:00:36 +00:00
|
|
|
dispatch=new DivPlatformYM2203Ext;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-05-15 07:00:36 +00:00
|
|
|
break;
|
2022-12-20 22:49:53 +00:00
|
|
|
case DIV_SYSTEM_YM2608:
|
2022-05-13 07:52:43 +00:00
|
|
|
dispatch=new DivPlatformYM2608;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2608*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-05-13 07:52:43 +00:00
|
|
|
break;
|
2022-12-20 22:49:53 +00:00
|
|
|
case DIV_SYSTEM_YM2608_EXT:
|
2022-05-19 03:49:21 +00:00
|
|
|
dispatch=new DivPlatformYM2608Ext;
|
2022-12-24 07:29:37 +00:00
|
|
|
((DivPlatformYM2608Ext*)dispatch)->setCombo(eng->getConfInt("opnCore",1)==1);
|
2022-05-19 03:49:21 +00:00
|
|
|
break;
|
2022-02-25 09:26:01 +00:00
|
|
|
case DIV_SYSTEM_OPLL:
|
|
|
|
case DIV_SYSTEM_OPLL_DRUMS:
|
2022-02-26 08:27:37 +00:00
|
|
|
case DIV_SYSTEM_VRC7:
|
2022-02-25 09:26:01 +00:00
|
|
|
dispatch=new DivPlatformOPLL;
|
2022-02-28 07:19:27 +00:00
|
|
|
((DivPlatformOPLL*)dispatch)->setVRC7(sys==DIV_SYSTEM_VRC7);
|
2022-02-28 19:13:14 +00:00
|
|
|
((DivPlatformOPLL*)dispatch)->setProperDrums(sys==DIV_SYSTEM_OPLL_DRUMS);
|
2022-02-25 09:26:01 +00:00
|
|
|
break;
|
2022-03-07 22:07:29 +00:00
|
|
|
case DIV_SYSTEM_OPL:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(1,false);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_OPL_DRUMS:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(1,true);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_OPL2:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(2,false);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_OPL2_DRUMS:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(2,true);
|
|
|
|
break;
|
2022-03-05 23:18:08 +00:00
|
|
|
case DIV_SYSTEM_OPL3:
|
|
|
|
dispatch=new DivPlatformOPL;
|
2022-03-07 22:07:29 +00:00
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(3,false);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_OPL3_DRUMS:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(3,true);
|
2022-03-05 23:18:08 +00:00
|
|
|
break;
|
2022-05-13 21:52:44 +00:00
|
|
|
case DIV_SYSTEM_Y8950:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(8950,false);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_Y8950_DRUMS:
|
|
|
|
dispatch=new DivPlatformOPL;
|
|
|
|
((DivPlatformOPL*)dispatch)->setOPLType(8950,true);
|
|
|
|
break;
|
2022-04-07 03:56:06 +00:00
|
|
|
case DIV_SYSTEM_OPZ:
|
|
|
|
dispatch=new DivPlatformTX81Z;
|
|
|
|
break;
|
2022-02-13 22:49:24 +00:00
|
|
|
case DIV_SYSTEM_SAA1099: {
|
2022-01-14 21:29:27 +00:00
|
|
|
dispatch=new DivPlatformSAA1099;
|
|
|
|
break;
|
2022-02-13 22:49:24 +00:00
|
|
|
}
|
2022-03-04 23:18:43 +00:00
|
|
|
case DIV_SYSTEM_PCSPKR:
|
|
|
|
dispatch=new DivPlatformPCSpeaker;
|
|
|
|
break;
|
2022-12-13 18:32:35 +00:00
|
|
|
case DIV_SYSTEM_POKEMINI:
|
|
|
|
dispatch=new DivPlatformPokeMini;
|
|
|
|
break;
|
2022-05-14 05:22:23 +00:00
|
|
|
case DIV_SYSTEM_SFX_BEEPER:
|
|
|
|
dispatch=new DivPlatformZXBeeper;
|
|
|
|
break;
|
2022-02-20 17:15:15 +00:00
|
|
|
case DIV_SYSTEM_LYNX:
|
2022-02-22 23:21:57 +00:00
|
|
|
dispatch=new DivPlatformLynx;
|
|
|
|
break;
|
2022-12-20 00:45:04 +00:00
|
|
|
case DIV_SYSTEM_POKEY:
|
|
|
|
dispatch=new DivPlatformPOKEY;
|
2022-12-23 00:47:13 +00:00
|
|
|
((DivPlatformPOKEY*)dispatch)->setAltASAP(eng->getConfInt("pokeyCore",1)==1);
|
2022-12-20 00:45:04 +00:00
|
|
|
break;
|
2022-02-22 09:01:57 +00:00
|
|
|
case DIV_SYSTEM_QSOUND:
|
|
|
|
dispatch=new DivPlatformQSound;
|
2022-02-20 17:15:15 +00:00
|
|
|
break;
|
2022-02-23 07:52:30 +00:00
|
|
|
case DIV_SYSTEM_SEGAPCM:
|
|
|
|
case DIV_SYSTEM_SEGAPCM_COMPAT:
|
|
|
|
dispatch=new DivPlatformSegaPCM;
|
|
|
|
break;
|
2022-03-06 17:31:03 +00:00
|
|
|
case DIV_SYSTEM_X1_010:
|
|
|
|
dispatch=new DivPlatformX1_010;
|
|
|
|
break;
|
2022-03-06 16:13:47 +00:00
|
|
|
case DIV_SYSTEM_SWAN:
|
2022-03-07 12:04:20 +00:00
|
|
|
dispatch=new DivPlatformSwan;
|
2022-03-06 16:13:47 +00:00
|
|
|
break;
|
2022-10-12 05:12:56 +00:00
|
|
|
case DIV_SYSTEM_T6W28:
|
|
|
|
dispatch=new DivPlatformT6W28;
|
|
|
|
break;
|
2022-10-09 00:37:22 +00:00
|
|
|
case DIV_SYSTEM_VBOY:
|
|
|
|
dispatch=new DivPlatformVB;
|
|
|
|
break;
|
2022-03-04 11:13:49 +00:00
|
|
|
case DIV_SYSTEM_VERA:
|
2022-03-08 10:53:00 +00:00
|
|
|
dispatch=new DivPlatformVERA;
|
2022-03-04 11:13:49 +00:00
|
|
|
break;
|
2022-03-17 01:11:48 +00:00
|
|
|
case DIV_SYSTEM_BUBSYS_WSG:
|
|
|
|
dispatch=new DivPlatformBubSysWSG;
|
2022-03-14 10:22:12 +00:00
|
|
|
break;
|
2022-03-22 16:48:45 +00:00
|
|
|
case DIV_SYSTEM_N163:
|
|
|
|
dispatch=new DivPlatformN163;
|
|
|
|
break;
|
2022-03-21 14:02:51 +00:00
|
|
|
case DIV_SYSTEM_PET:
|
|
|
|
dispatch=new DivPlatformPET;
|
|
|
|
break;
|
2022-03-22 07:48:48 +00:00
|
|
|
case DIV_SYSTEM_VIC20:
|
|
|
|
dispatch=new DivPlatformVIC20;
|
|
|
|
break;
|
2022-10-24 08:19:42 +00:00
|
|
|
case DIV_SYSTEM_PONG:
|
|
|
|
dispatch=new DivPlatformPong;
|
|
|
|
break;
|
2022-03-27 16:06:56 +00:00
|
|
|
case DIV_SYSTEM_VRC6:
|
|
|
|
dispatch=new DivPlatformVRC6;
|
|
|
|
break;
|
2022-04-06 05:34:12 +00:00
|
|
|
case DIV_SYSTEM_MMC5:
|
|
|
|
dispatch=new DivPlatformMMC5;
|
|
|
|
break;
|
2022-04-20 16:52:37 +00:00
|
|
|
case DIV_SYSTEM_ES5506:
|
|
|
|
dispatch=new DivPlatformES5506;
|
|
|
|
break;
|
2022-05-10 04:18:25 +00:00
|
|
|
case DIV_SYSTEM_SCC:
|
|
|
|
dispatch=new DivPlatformSCC;
|
|
|
|
((DivPlatformSCC*)dispatch)->setChipModel(false);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_SCC_PLUS:
|
|
|
|
dispatch=new DivPlatformSCC;
|
|
|
|
((DivPlatformSCC*)dispatch)->setChipModel(true);
|
|
|
|
break;
|
2022-05-18 06:55:33 +00:00
|
|
|
case DIV_SYSTEM_YMZ280B:
|
|
|
|
dispatch=new DivPlatformYMZ280B;
|
|
|
|
((DivPlatformYMZ280B*)dispatch)->setChipModel(280);
|
|
|
|
break;
|
2022-05-20 18:45:26 +00:00
|
|
|
case DIV_SYSTEM_RF5C68:
|
|
|
|
dispatch=new DivPlatformRF5C68;
|
|
|
|
break;
|
2022-04-27 09:48:56 +00:00
|
|
|
case DIV_SYSTEM_SOUND_UNIT:
|
|
|
|
dispatch=new DivPlatformSoundUnit;
|
|
|
|
break;
|
2022-05-24 00:01:10 +00:00
|
|
|
case DIV_SYSTEM_MSM6258:
|
|
|
|
dispatch=new DivPlatformMSM6258;
|
|
|
|
break;
|
2022-05-23 06:46:58 +00:00
|
|
|
case DIV_SYSTEM_MSM6295:
|
|
|
|
dispatch=new DivPlatformMSM6295;
|
|
|
|
break;
|
2022-10-01 08:15:40 +00:00
|
|
|
case DIV_SYSTEM_MSM5232:
|
|
|
|
dispatch=new DivPlatformMSM5232;
|
|
|
|
break;
|
2022-05-20 20:29:09 +00:00
|
|
|
case DIV_SYSTEM_NAMCO:
|
|
|
|
dispatch=new DivPlatformNamcoWSG;
|
|
|
|
// Pac-Man (TODO: support Pole Position?)
|
|
|
|
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(1);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_NAMCO_15XX:
|
|
|
|
dispatch=new DivPlatformNamcoWSG;
|
|
|
|
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(15);
|
|
|
|
break;
|
|
|
|
case DIV_SYSTEM_NAMCO_CUS30:
|
|
|
|
dispatch=new DivPlatformNamcoWSG;
|
|
|
|
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(30);
|
|
|
|
break;
|
2022-03-21 07:38:12 +00:00
|
|
|
case DIV_SYSTEM_SNES:
|
|
|
|
dispatch=new DivPlatformSNES;
|
|
|
|
break;
|
2022-12-08 05:18:22 +00:00
|
|
|
case DIV_SYSTEM_K007232:
|
|
|
|
dispatch=new DivPlatformK007232;
|
|
|
|
break;
|
2022-12-15 11:03:54 +00:00
|
|
|
case DIV_SYSTEM_GA20:
|
|
|
|
dispatch=new DivPlatformGA20;
|
|
|
|
break;
|
2023-02-11 12:37:11 +00:00
|
|
|
case DIV_SYSTEM_SM8521:
|
|
|
|
dispatch=new DivPlatformSM8521;
|
|
|
|
break;
|
2023-03-05 05:01:44 +00:00
|
|
|
case DIV_SYSTEM_D65010G031:
|
|
|
|
dispatch=new DivPlatformD65010G031;
|
|
|
|
break;
|
2022-07-02 18:42:47 +00:00
|
|
|
case DIV_SYSTEM_PCM_DAC:
|
|
|
|
dispatch=new DivPlatformPCMDAC;
|
|
|
|
break;
|
2022-04-27 05:56:15 +00:00
|
|
|
case DIV_SYSTEM_DUMMY:
|
|
|
|
dispatch=new DivPlatformDummy;
|
|
|
|
break;
|
2022-01-08 21:03:32 +00:00
|
|
|
default:
|
2022-04-11 03:12:02 +00:00
|
|
|
logW("this system is not supported yet! using dummy platform.");
|
2022-01-08 21:03:32 +00:00
|
|
|
dispatch=new DivPlatformDummy;
|
|
|
|
break;
|
|
|
|
}
|
2022-02-04 22:04:36 +00:00
|
|
|
dispatch->init(eng,chanCount,gotRate,flags);
|
2023-01-02 00:46:08 +00:00
|
|
|
|
|
|
|
// initialize output buffers
|
|
|
|
int outs=dispatch->getOutputCount();
|
|
|
|
bbInLen=32768;
|
|
|
|
|
|
|
|
for (int i=0; i<outs; i++) {
|
|
|
|
bb[i]=blip_new(bbInLen);
|
|
|
|
if (bb[i]==NULL) {
|
|
|
|
logE("not enough memory!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bbIn[i]=new short[bbInLen];
|
|
|
|
bbOut[i]=new short[bbInLen];
|
2023-01-03 06:09:46 +00:00
|
|
|
memset(bbIn[i],0,bbInLen*sizeof(short));
|
|
|
|
memset(bbOut[i],0,bbInLen*sizeof(short));
|
2023-01-02 00:46:08 +00:00
|
|
|
}
|
2022-01-08 21:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DivDispatchContainer::quit() {
|
|
|
|
if (dispatch==NULL) return;
|
|
|
|
dispatch->quit();
|
|
|
|
delete dispatch;
|
|
|
|
dispatch=NULL;
|
|
|
|
|
2023-01-02 00:46:08 +00:00
|
|
|
for (int i=0; i<DIV_MAX_OUTPUTS; i++) {
|
|
|
|
if (bbOut[i]!=NULL) {
|
|
|
|
delete[] bbOut[i];
|
|
|
|
bbOut[i]=NULL;
|
|
|
|
}
|
|
|
|
if (bbIn[i]!=NULL) {
|
|
|
|
delete[] bbIn[i];
|
|
|
|
bbIn[i]=NULL;
|
|
|
|
}
|
|
|
|
if (bb[i]!=NULL) {
|
|
|
|
blip_delete(bb[i]);
|
|
|
|
bb[i]=NULL;
|
|
|
|
}
|
|
|
|
}
|
2022-01-08 21:03:32 +00:00
|
|
|
bbInLen=0;
|
|
|
|
}
|