| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "blip_buf.h" |
| 21 |
#include "engine.h" |
| 22 |
#include "platform/genesis.h" |
| 23 |
#include "platform/genesisext.h" |
| 24 |
#include "platform/msm5232.h" |
| 25 |
#include "platform/msm6258.h" |
| 26 |
#include "platform/msm6295.h" |
| 27 |
#include "platform/namcowsg.h" |
| 28 |
#include "platform/sms.h" |
| 29 |
#include "platform/opll.h" |
| 30 |
#include "platform/gb.h" |
| 31 |
#include "platform/pce.h" |
| 32 |
#include "platform/nes.h" |
| 33 |
#include "platform/c64.h" |
| 34 |
#include "platform/arcade.h" |
| 35 |
#include "platform/t6w28.h" |
| 36 |
#include "platform/tx81z.h" |
| 37 |
#include "platform/ym2203.h" |
| 38 |
#include "platform/ym2203ext.h" |
| 39 |
#include "platform/ym2608.h" |
| 40 |
#include "platform/ym2608ext.h" |
| 41 |
#include "platform/ym2610.h" |
| 42 |
#include "platform/ym2610ext.h" |
| 43 |
#include "platform/ym2610b.h" |
| 44 |
#include "platform/ym2610bext.h" |
| 45 |
#include "platform/ay.h" |
| 46 |
#include "platform/ay8930.h" |
| 47 |
#include "platform/opl.h" |
| 48 |
#include "platform/tia.h" |
| 49 |
#include "platform/saa.h" |
| 50 |
#include "platform/amiga.h" |
| 51 |
#include "platform/pcspkr.h" |
| 52 |
#include "platform/pokemini.h" |
| 53 |
#include "platform/segapcm.h" |
| 54 |
#include "platform/qsound.h" |
| 55 |
#include "platform/vera.h" |
| 56 |
#include "platform/x1_010.h" |
| 57 |
#include "platform/su.h" |
| 58 |
#include "platform/swan.h" |
| 59 |
#include "platform/lynx.h" |
| 60 |
#include "platform/pokey.h" |
| 61 |
#include "platform/zxbeeper.h" |
| 62 |
#include "platform/zxbeeperquadtone.h" |
| 63 |
#include "platform/bubsyswsg.h" |
| 64 |
#include "platform/n163.h" |
| 65 |
#include "platform/pet.h" |
| 66 |
#include "platform/pong.h" |
| 67 |
#include "platform/vic20.h" |
| 68 |
#include "platform/vrc6.h" |
| 69 |
#include "platform/fds.h" |
| 70 |
#include "platform/mmc5.h" |
| 71 |
#include "platform/es5506.h" |
| 72 |
#include "platform/scc.h" |
| 73 |
#include "platform/ymz280b.h" |
| 74 |
#include "platform/rf5c68.h" |
| 75 |
#include "platform/snes.h" |
| 76 |
#include "platform/vb.h" |
| 77 |
#include "platform/k007232.h" |
| 78 |
#include "platform/ga20.h" |
| 79 |
#include "platform/supervision.h" |
| 80 |
#include "platform/scvtone.h" |
| 81 |
#include "platform/sm8521.h" |
| 82 |
#include "platform/pv1000.h" |
| 83 |
#include "platform/k053260.h" |
| 84 |
#include "platform/ted.h" |
| 85 |
#include "platform/c140.h" |
| 86 |
#include "platform/gbadma.h" |
| 87 |
#include "platform/gbaminmod.h" |
| 88 |
#include "platform/pcmdac.h" |
| 89 |
#include "platform/esfm.h" |
| 90 |
#include "platform/powernoise.h" |
| 91 |
#include "platform/dave.h" |
| 92 |
#include "platform/nds.h" |
| 93 |
#include "platform/bifurcator.h" |
| 94 |
#include "platform/sid2.h" |
| 95 |
#include "platform/sid3.h" |
| 96 |
#include "platform/dummy.h" |
| 97 |
#include "../ta-log.h" |
| 98 |
#include "song.h" |
| 99 |
|
| 100 |
void DivDispatchContainer::setRates(double gotRate) { |
| 101 |
int outs=dispatch->getOutputCount(); |
| 102 |
|
| 103 |
for (int i=0; i<outs; i++) { |
| 104 |
if (bb[i]==NULL) continue; |
| 105 |
blip_set_rates(bb[i],dispatch->rate,gotRate); |
| 106 |
} |
| 107 |
rateMemory=gotRate; |
| 108 |
} |
| 109 |
|
| 110 |
void DivDispatchContainer::setQuality(bool lowQual, bool dcHiPass) { |
| 111 |
lowQuality=lowQual; |
| 112 |
hiPass=dcHiPass; |
| 113 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 114 |
if (bb[i]==NULL) continue; |
| 115 |
blip_set_dc(bb[i],dcHiPass); |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
void DivDispatchContainer::grow(size_t size) { |
| 120 |
bbInLen=size; |
| 121 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 122 |
if (bbIn[i]!=NULL) { |
| 123 |
delete[] bbIn[i]; |
| 124 |
bbIn[i]=new short[bbInLen]; |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
#define CHECK_MISSING_BUFS \ |
| 130 |
int outs=dispatch->getOutputCount(); \ |
| 131 |
\ |
| 132 |
/* create missing buffers if any */ \ |
| 133 |
bool mustClear=false; \ |
| 134 |
for (int i=0; i<outs; i++) { \ |
| 135 |
if (bb[i]==NULL) { \ |
| 136 |
logV("creating buf %d because it doesn't exist",i); \ |
| 137 |
bb[i]=blip_new(bbInLen); \ |
| 138 |
if (bb[i]==NULL) { \ |
| 139 |
logE("not enough memory!"); \ |
| 140 |
return; \ |
| 141 |
} \ |
| 142 |
blip_set_dc(bb[i],hiPass); \ |
| 143 |
blip_set_rates(bb[i],dispatch->rate,rateMemory); \ |
| 144 |
\ |
| 145 |
if (bbIn[i]==NULL) bbIn[i]=new short[bbInLen]; \ |
| 146 |
if (bbOut[i]==NULL) bbOut[i]=new short[bbInLen]; \ |
| 147 |
memset(bbIn[i],0,bbInLen*sizeof(short)); \ |
| 148 |
memset(bbOut[i],0,bbInLen*sizeof(short)); \ |
| 149 |
mustClear=true; \ |
| 150 |
} \ |
| 151 |
} \ |
| 152 |
if (mustClear) clear(); \ |
| 153 |
|
| 154 |
void DivDispatchContainer::acquire(size_t count) { |
| 155 |
CHECK_MISSING_BUFS; |
| 156 |
|
| 157 |
if (dispatch->hasAcquireDirect()) { |
| 158 |
dispatch->acquireDirect(bb,count); |
| 159 |
} else { |
| 160 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 161 |
if (i>=outs) { |
| 162 |
bbInMapped[i]=NULL; |
| 163 |
} else { |
| 164 |
if (bbIn[i]==NULL) { |
| 165 |
bbInMapped[i]=NULL; |
| 166 |
} else { |
| 167 |
bbInMapped[i]=bbIn[i]; |
| 168 |
} |
| 169 |
} |
| 170 |
} |
| 171 |
dispatch->acquire(bbInMapped,count); |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
void DivDispatchContainer::flush(size_t offset, size_t count) { |
| 176 |
int outs=dispatch->getOutputCount(); |
| 177 |
|
| 178 |
for (int i=0; i<outs; i++) { |
| 179 |
if (bb[i]==NULL) continue; |
| 180 |
blip_read_samples(bb[i],bbOut[i]+offset,count,0); |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
void DivDispatchContainer::fillBuf(size_t runtotal, size_t offset, size_t size) { |
| 185 |
CHECK_MISSING_BUFS; |
| 186 |
|
| 187 |
if (!dispatch->hasAcquireDirect()) { |
| 188 |
if (dcOffCompensation && runtotal>0) { |
| 189 |
dcOffCompensation=false; |
| 190 |
if (hiPass) { |
| 191 |
for (int i=0; i<outs; i++) { |
| 192 |
if (bbIn[i]==NULL) continue; |
| 193 |
prevSample[i]=bbIn[i][0]; |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
for (int i=0; i<outs; i++) { |
| 198 |
if (bbIn[i]==NULL) continue; |
| 199 |
if (bb[i]==NULL) continue; |
| 200 |
for (size_t j=0; j<runtotal; j++) { |
| 201 |
if (bbIn[i][j]==temp[i]) continue; |
| 202 |
temp[i]=bbIn[i][j]; |
| 203 |
blip_add_delta(bb[i],j,temp[i]-prevSample[i]); |
| 204 |
prevSample[i]=temp[i]; |
| 205 |
} |
| 206 |
} |
| 207 |
} |
| 208 |
|
| 209 |
for (int i=0; i<outs; i++) { |
| 210 |
if (bbOut[i]==NULL) continue; |
| 211 |
if (bb[i]==NULL) continue; |
| 212 |
blip_end_frame(bb[i],runtotal); |
| 213 |
blip_read_samples(bb[i],bbOut[i]+offset,size,0); |
| 214 |
dispatch->postProcess(bbOut[i]+offset,i,size,rateMemory); |
| 215 |
} |
| 216 |
} |
| 217 |
|
| 218 |
void DivDispatchContainer::clear() { |
| 219 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 220 |
if (bb[i]!=NULL) blip_clear(bb[i]); |
| 221 |
temp[i]=0; |
| 222 |
prevSample[i]=0; |
| 223 |
} |
| 224 |
|
| 225 |
if (dispatch->getDCOffRequired() && hiPass) { |
| 226 |
dcOffCompensation=true; |
| 227 |
} |
| 228 |
} |
| 229 |
|
| 230 |
void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, const DivConfig& flags, bool isRender) { |
| 231 |
// quit if we already initialized |
| 232 |
if (dispatch!=NULL) return; |
| 233 |
|
| 234 |
// initialize chip |
| 235 |
switch (sys) { |
| 236 |
case DIV_SYSTEM_YMU759: |
| 237 |
dispatch=new DivPlatformOPL; |
| 238 |
((DivPlatformOPL*)dispatch)->setOPLType(759,false); |
| 239 |
break; |
| 240 |
case DIV_SYSTEM_YM2612: |
| 241 |
dispatch=new DivPlatformGenesis; |
| 242 |
if (isRender) { |
| 243 |
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612CoreRender",0)); |
| 244 |
} else { |
| 245 |
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0)); |
| 246 |
} |
| 247 |
((DivPlatformGenesis*)dispatch)->setSoftPCM(false); |
| 248 |
break; |
| 249 |
case DIV_SYSTEM_YM2612_EXT: |
| 250 |
dispatch=new DivPlatformGenesisExt; |
| 251 |
if (isRender) { |
| 252 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612CoreRender",0)); |
| 253 |
} else { |
| 254 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0)); |
| 255 |
} |
| 256 |
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(false); |
| 257 |
break; |
| 258 |
case DIV_SYSTEM_YM2612_CSM: |
| 259 |
dispatch=new DivPlatformGenesisExt; |
| 260 |
if (isRender) { |
| 261 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612CoreRender",0)); |
| 262 |
} else { |
| 263 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0)); |
| 264 |
} |
| 265 |
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(false); |
| 266 |
((DivPlatformGenesisExt*)dispatch)->setCSMChannel(6); |
| 267 |
break; |
| 268 |
case DIV_SYSTEM_YM2612_DUALPCM: |
| 269 |
dispatch=new DivPlatformGenesis; |
| 270 |
if (isRender) { |
| 271 |
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612CoreRender",0)); |
| 272 |
} else { |
| 273 |
((DivPlatformGenesis*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0)); |
| 274 |
} |
| 275 |
((DivPlatformGenesis*)dispatch)->setSoftPCM(true); |
| 276 |
break; |
| 277 |
case DIV_SYSTEM_YM2612_DUALPCM_EXT: |
| 278 |
dispatch=new DivPlatformGenesisExt; |
| 279 |
if (isRender) { |
| 280 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612CoreRender",0)); |
| 281 |
} else { |
| 282 |
((DivPlatformGenesisExt*)dispatch)->setYMFM(eng->getConfInt("ym2612Core",0)); |
| 283 |
} |
| 284 |
((DivPlatformGenesisExt*)dispatch)->setSoftPCM(true); |
| 285 |
break; |
| 286 |
case DIV_SYSTEM_SMS: |
| 287 |
dispatch=new DivPlatformSMS; |
| 288 |
if (isRender) { |
| 289 |
((DivPlatformSMS*)dispatch)->setNuked(eng->getConfInt("snCoreRender",0)); |
| 290 |
} else { |
| 291 |
((DivPlatformSMS*)dispatch)->setNuked(eng->getConfInt("snCore",0)); |
| 292 |
} |
| 293 |
break; |
| 294 |
case DIV_SYSTEM_GB: |
| 295 |
dispatch=new DivPlatformGB; |
| 296 |
if (isRender) { |
| 297 |
((DivPlatformGB*)dispatch)->setCoreQuality(eng->getConfInt("gbQualityRender",3)); |
| 298 |
} else { |
| 299 |
((DivPlatformGB*)dispatch)->setCoreQuality(eng->getConfInt("gbQuality",3)); |
| 300 |
} |
| 301 |
break; |
| 302 |
case DIV_SYSTEM_PCE: |
| 303 |
dispatch=new DivPlatformPCE; |
| 304 |
break; |
| 305 |
case DIV_SYSTEM_NES: |
| 306 |
dispatch=new DivPlatformNES; |
| 307 |
if (isRender) { |
| 308 |
((DivPlatformNES*)dispatch)->setNSFPlay(eng->getConfInt("nesCoreRender",0)==1); |
| 309 |
} else { |
| 310 |
((DivPlatformNES*)dispatch)->setNSFPlay(eng->getConfInt("nesCore",0)==1); |
| 311 |
} |
| 312 |
((DivPlatformNES*)dispatch)->set5E01(false); |
| 313 |
break; |
| 314 |
case DIV_SYSTEM_C64_6581: |
| 315 |
case DIV_SYSTEM_C64_PCM: |
| 316 |
dispatch=new DivPlatformC64; |
| 317 |
if (isRender) { |
| 318 |
((DivPlatformC64*)dispatch)->setCore(eng->getConfInt("c64CoreRender",1)); |
| 319 |
((DivPlatformC64*)dispatch)->setCoreQuality(eng->getConfInt("dsidQualityRender",3)); |
| 320 |
} else { |
| 321 |
((DivPlatformC64*)dispatch)->setCore(eng->getConfInt("c64Core",0)); |
| 322 |
((DivPlatformC64*)dispatch)->setCoreQuality(eng->getConfInt("dsidQuality",3)); |
| 323 |
} |
| 324 |
((DivPlatformC64*)dispatch)->setChipModel(true); |
| 325 |
((DivPlatformC64*)dispatch)->setSoftPCM(sys==DIV_SYSTEM_C64_PCM); |
| 326 |
break; |
| 327 |
case DIV_SYSTEM_C64_8580: |
| 328 |
dispatch=new DivPlatformC64; |
| 329 |
if (isRender) { |
| 330 |
((DivPlatformC64*)dispatch)->setCore(eng->getConfInt("c64CoreRender",1)); |
| 331 |
((DivPlatformC64*)dispatch)->setCoreQuality(eng->getConfInt("dsidQualityRender",3)); |
| 332 |
} else { |
| 333 |
((DivPlatformC64*)dispatch)->setCore(eng->getConfInt("c64Core",0)); |
| 334 |
((DivPlatformC64*)dispatch)->setCoreQuality(eng->getConfInt("dsidQuality",3)); |
| 335 |
} |
| 336 |
((DivPlatformC64*)dispatch)->setChipModel(false); |
| 337 |
((DivPlatformC64*)dispatch)->setSoftPCM(false); |
| 338 |
break; |
| 339 |
case DIV_SYSTEM_YM2151: |
| 340 |
dispatch=new DivPlatformArcade; |
| 341 |
if (isRender) { |
| 342 |
((DivPlatformArcade*)dispatch)->setYMFM(eng->getConfInt("arcadeCoreRender",1)==0); |
| 343 |
} else { |
| 344 |
((DivPlatformArcade*)dispatch)->setYMFM(eng->getConfInt("arcadeCore",0)==0); |
| 345 |
} |
| 346 |
break; |
| 347 |
case DIV_SYSTEM_YM2610: |
| 348 |
case DIV_SYSTEM_YM2610_FULL: |
| 349 |
dispatch=new DivPlatformYM2610; |
| 350 |
if (isRender) { |
| 351 |
((DivPlatformYM2610*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 352 |
} else { |
| 353 |
((DivPlatformYM2610*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 354 |
} |
| 355 |
break; |
| 356 |
case DIV_SYSTEM_YM2610_EXT: |
| 357 |
case DIV_SYSTEM_YM2610_FULL_EXT: |
| 358 |
dispatch=new DivPlatformYM2610Ext; |
| 359 |
if (isRender) { |
| 360 |
((DivPlatformYM2610Ext*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 361 |
} else { |
| 362 |
((DivPlatformYM2610Ext*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 363 |
} |
| 364 |
((DivPlatformYM2610Ext*)dispatch)->setCSM(0); |
| 365 |
break; |
| 366 |
case DIV_SYSTEM_YM2610_CSM: |
| 367 |
dispatch=new DivPlatformYM2610Ext; |
| 368 |
if (isRender) { |
| 369 |
((DivPlatformYM2610Ext*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 370 |
} else { |
| 371 |
((DivPlatformYM2610Ext*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 372 |
} |
| 373 |
((DivPlatformYM2610Ext*)dispatch)->setCSM(1); |
| 374 |
break; |
| 375 |
case DIV_SYSTEM_YM2610B: |
| 376 |
dispatch=new DivPlatformYM2610B; |
| 377 |
if (isRender) { |
| 378 |
((DivPlatformYM2610B*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 379 |
} else { |
| 380 |
((DivPlatformYM2610B*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 381 |
} |
| 382 |
break; |
| 383 |
case DIV_SYSTEM_YM2610B_EXT: |
| 384 |
dispatch=new DivPlatformYM2610BExt; |
| 385 |
if (isRender) { |
| 386 |
((DivPlatformYM2610BExt*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 387 |
} else { |
| 388 |
((DivPlatformYM2610BExt*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 389 |
} |
| 390 |
((DivPlatformYM2610BExt*)dispatch)->setCSM(0); |
| 391 |
break; |
| 392 |
case DIV_SYSTEM_YM2610B_CSM: |
| 393 |
dispatch=new DivPlatformYM2610BExt; |
| 394 |
if (isRender) { |
| 395 |
((DivPlatformYM2610BExt*)dispatch)->setCombo(eng->getConfInt("opnbCoreRender",1)); |
| 396 |
} else { |
| 397 |
((DivPlatformYM2610BExt*)dispatch)->setCombo(eng->getConfInt("opnbCore",1)); |
| 398 |
} |
| 399 |
((DivPlatformYM2610BExt*)dispatch)->setCSM(1); |
| 400 |
break; |
| 401 |
case DIV_SYSTEM_AMIGA: |
| 402 |
dispatch=new DivPlatformAmiga; |
| 403 |
break; |
| 404 |
case DIV_SYSTEM_AY8910: |
| 405 |
dispatch=new DivPlatformAY8910; |
| 406 |
if (isRender) { |
| 407 |
((DivPlatformAY8910*)dispatch)->setCore(eng->getConfInt("ayCoreRender",0)==1); |
| 408 |
} else { |
| 409 |
((DivPlatformAY8910*)dispatch)->setCore(eng->getConfInt("ayCore",0)==1); |
| 410 |
} |
| 411 |
break; |
| 412 |
case DIV_SYSTEM_AY8930: |
| 413 |
dispatch=new DivPlatformAY8930; |
| 414 |
break; |
| 415 |
case DIV_SYSTEM_FDS: |
| 416 |
dispatch=new DivPlatformFDS; |
| 417 |
if (isRender) { |
| 418 |
((DivPlatformFDS*)dispatch)->setNSFPlay(eng->getConfInt("fdsCoreRender",1)==1); |
| 419 |
} else { |
| 420 |
((DivPlatformFDS*)dispatch)->setNSFPlay(eng->getConfInt("fdsCore",0)==1); |
| 421 |
} |
| 422 |
break; |
| 423 |
case DIV_SYSTEM_TIA: |
| 424 |
dispatch=new DivPlatformTIA; |
| 425 |
break; |
| 426 |
case DIV_SYSTEM_YM2203: |
| 427 |
dispatch=new DivPlatformYM2203; |
| 428 |
if (isRender) { |
| 429 |
((DivPlatformYM2203*)dispatch)->setCombo(eng->getConfInt("opn1CoreRender",1)); |
| 430 |
} else { |
| 431 |
((DivPlatformYM2203*)dispatch)->setCombo(eng->getConfInt("opn1Core",1)); |
| 432 |
} |
| 433 |
break; |
| 434 |
case DIV_SYSTEM_YM2203_EXT: |
| 435 |
dispatch=new DivPlatformYM2203Ext; |
| 436 |
if (isRender) { |
| 437 |
((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opn1CoreRender",1)); |
| 438 |
} else { |
| 439 |
((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opn1Core",1)); |
| 440 |
} |
| 441 |
((DivPlatformYM2203Ext*)dispatch)->setCSM(0); |
| 442 |
break; |
| 443 |
case DIV_SYSTEM_YM2203_CSM: |
| 444 |
dispatch=new DivPlatformYM2203Ext; |
| 445 |
if (isRender) { |
| 446 |
((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opn1CoreRender",1)); |
| 447 |
} else { |
| 448 |
((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opn1Core",1)); |
| 449 |
} |
| 450 |
((DivPlatformYM2203Ext*)dispatch)->setCSM(1); |
| 451 |
break; |
| 452 |
case DIV_SYSTEM_YM2608: |
| 453 |
dispatch=new DivPlatformYM2608; |
| 454 |
if (isRender) { |
| 455 |
((DivPlatformYM2608*)dispatch)->setCombo(eng->getConfInt("opnaCoreRender",1)); |
| 456 |
} else { |
| 457 |
((DivPlatformYM2608*)dispatch)->setCombo(eng->getConfInt("opnaCore",1)); |
| 458 |
} |
| 459 |
break; |
| 460 |
case DIV_SYSTEM_YM2608_EXT: |
| 461 |
dispatch=new DivPlatformYM2608Ext; |
| 462 |
if (isRender) { |
| 463 |
((DivPlatformYM2608Ext*)dispatch)->setCombo(eng->getConfInt("opnaCoreRender",1)); |
| 464 |
} else { |
| 465 |
((DivPlatformYM2608Ext*)dispatch)->setCombo(eng->getConfInt("opnaCore",1)); |
| 466 |
} |
| 467 |
((DivPlatformYM2608Ext*)dispatch)->setCSM(0); |
| 468 |
break; |
| 469 |
case DIV_SYSTEM_YM2608_CSM: |
| 470 |
dispatch=new DivPlatformYM2608Ext; |
| 471 |
if (isRender) { |
| 472 |
((DivPlatformYM2608Ext*)dispatch)->setCombo(eng->getConfInt("opnaCoreRender",1)); |
| 473 |
} else { |
| 474 |
((DivPlatformYM2608Ext*)dispatch)->setCombo(eng->getConfInt("opnaCore",1)); |
| 475 |
} |
| 476 |
((DivPlatformYM2608Ext*)dispatch)->setCSM(1); |
| 477 |
break; |
| 478 |
case DIV_SYSTEM_OPLL: |
| 479 |
case DIV_SYSTEM_OPLL_DRUMS: |
| 480 |
case DIV_SYSTEM_VRC7: |
| 481 |
dispatch=new DivPlatformOPLL; |
| 482 |
if (isRender) { |
| 483 |
((DivPlatformOPLL*)dispatch)->setCore(eng->getConfInt("opllCoreRender",0)); |
| 484 |
} else { |
| 485 |
((DivPlatformOPLL*)dispatch)->setCore(eng->getConfInt("opllCore",0)); |
| 486 |
} |
| 487 |
((DivPlatformOPLL*)dispatch)->setVRC7(sys==DIV_SYSTEM_VRC7); |
| 488 |
((DivPlatformOPLL*)dispatch)->setProperDrums(sys==DIV_SYSTEM_OPLL_DRUMS); |
| 489 |
break; |
| 490 |
case DIV_SYSTEM_OPL: |
| 491 |
dispatch=new DivPlatformOPL; |
| 492 |
((DivPlatformOPL*)dispatch)->setOPLType(1,false); |
| 493 |
if (isRender) { |
| 494 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 495 |
} else { |
| 496 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 497 |
} |
| 498 |
break; |
| 499 |
case DIV_SYSTEM_OPL_DRUMS: |
| 500 |
dispatch=new DivPlatformOPL; |
| 501 |
((DivPlatformOPL*)dispatch)->setOPLType(1,true); |
| 502 |
if (isRender) { |
| 503 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 504 |
} else { |
| 505 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 506 |
} |
| 507 |
break; |
| 508 |
case DIV_SYSTEM_OPL2: |
| 509 |
dispatch=new DivPlatformOPL; |
| 510 |
((DivPlatformOPL*)dispatch)->setOPLType(2,false); |
| 511 |
if (isRender) { |
| 512 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 513 |
} else { |
| 514 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 515 |
} |
| 516 |
break; |
| 517 |
case DIV_SYSTEM_OPL2_DRUMS: |
| 518 |
dispatch=new DivPlatformOPL; |
| 519 |
((DivPlatformOPL*)dispatch)->setOPLType(2,true); |
| 520 |
if (isRender) { |
| 521 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 522 |
} else { |
| 523 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 524 |
} |
| 525 |
break; |
| 526 |
case DIV_SYSTEM_OPL3: |
| 527 |
dispatch=new DivPlatformOPL; |
| 528 |
((DivPlatformOPL*)dispatch)->setOPLType(3,false); |
| 529 |
if (isRender) { |
| 530 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl3CoreRender",0)); |
| 531 |
} else { |
| 532 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl3Core",0)); |
| 533 |
} |
| 534 |
break; |
| 535 |
case DIV_SYSTEM_OPL3_DRUMS: |
| 536 |
dispatch=new DivPlatformOPL; |
| 537 |
((DivPlatformOPL*)dispatch)->setOPLType(3,true); |
| 538 |
if (isRender) { |
| 539 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl3CoreRender",0)); |
| 540 |
} else { |
| 541 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl3Core",0)); |
| 542 |
} |
| 543 |
break; |
| 544 |
case DIV_SYSTEM_Y8950: |
| 545 |
dispatch=new DivPlatformOPL; |
| 546 |
((DivPlatformOPL*)dispatch)->setOPLType(8950,false); |
| 547 |
if (isRender) { |
| 548 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 549 |
} else { |
| 550 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 551 |
} |
| 552 |
break; |
| 553 |
case DIV_SYSTEM_Y8950_DRUMS: |
| 554 |
dispatch=new DivPlatformOPL; |
| 555 |
((DivPlatformOPL*)dispatch)->setOPLType(8950,true); |
| 556 |
if (isRender) { |
| 557 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2CoreRender",0)); |
| 558 |
} else { |
| 559 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl2Core",0)); |
| 560 |
} |
| 561 |
break; |
| 562 |
case DIV_SYSTEM_OPZ: |
| 563 |
dispatch=new DivPlatformTX81Z; |
| 564 |
break; |
| 565 |
case DIV_SYSTEM_SAA1099: { |
| 566 |
dispatch=new DivPlatformSAA1099; |
| 567 |
if (isRender) { |
| 568 |
((DivPlatformSAA1099*)dispatch)->setCoreQuality(eng->getConfInt("saaQualityRender",3)); |
| 569 |
} else { |
| 570 |
((DivPlatformSAA1099*)dispatch)->setCoreQuality(eng->getConfInt("saaQuality",3)); |
| 571 |
} |
| 572 |
break; |
| 573 |
} |
| 574 |
case DIV_SYSTEM_PCSPKR: |
| 575 |
dispatch=new DivPlatformPCSpeaker; |
| 576 |
break; |
| 577 |
case DIV_SYSTEM_POKEMINI: |
| 578 |
dispatch=new DivPlatformPokeMini; |
| 579 |
break; |
| 580 |
case DIV_SYSTEM_SFX_BEEPER: |
| 581 |
dispatch=new DivPlatformZXBeeper; |
| 582 |
break; |
| 583 |
case DIV_SYSTEM_SFX_BEEPER_QUADTONE: |
| 584 |
dispatch=new DivPlatformZXBeeperQuadTone; |
| 585 |
break; |
| 586 |
case DIV_SYSTEM_LYNX: |
| 587 |
dispatch=new DivPlatformLynx; |
| 588 |
break; |
| 589 |
case DIV_SYSTEM_POKEY: |
| 590 |
dispatch=new DivPlatformPOKEY; |
| 591 |
if (isRender) { |
| 592 |
((DivPlatformPOKEY*)dispatch)->setAltASAP(eng->getConfInt("pokeyCoreRender",1)==1); |
| 593 |
} else { |
| 594 |
((DivPlatformPOKEY*)dispatch)->setAltASAP(eng->getConfInt("pokeyCore",1)==1); |
| 595 |
} |
| 596 |
break; |
| 597 |
case DIV_SYSTEM_QSOUND: |
| 598 |
dispatch=new DivPlatformQSound; |
| 599 |
break; |
| 600 |
case DIV_SYSTEM_SEGAPCM: |
| 601 |
case DIV_SYSTEM_SEGAPCM_COMPAT: |
| 602 |
dispatch=new DivPlatformSegaPCM; |
| 603 |
break; |
| 604 |
case DIV_SYSTEM_X1_010: |
| 605 |
dispatch=new DivPlatformX1_010; |
| 606 |
break; |
| 607 |
case DIV_SYSTEM_SWAN: |
| 608 |
dispatch=new DivPlatformSwan; |
| 609 |
if (isRender) { |
| 610 |
((DivPlatformSwan*)dispatch)->setUseMdfn(eng->getConfInt("swanCoreRender",0)); |
| 611 |
} else { |
| 612 |
((DivPlatformSwan*)dispatch)->setUseMdfn(eng->getConfInt("swanCore",0)); |
| 613 |
} |
| 614 |
break; |
| 615 |
case DIV_SYSTEM_T6W28: |
| 616 |
dispatch=new DivPlatformT6W28; |
| 617 |
break; |
| 618 |
case DIV_SYSTEM_VBOY: |
| 619 |
dispatch=new DivPlatformVB; |
| 620 |
break; |
| 621 |
case DIV_SYSTEM_VERA: |
| 622 |
dispatch=new DivPlatformVERA; |
| 623 |
break; |
| 624 |
case DIV_SYSTEM_BUBSYS_WSG: |
| 625 |
dispatch=new DivPlatformBubSysWSG; |
| 626 |
break; |
| 627 |
case DIV_SYSTEM_N163: |
| 628 |
dispatch=new DivPlatformN163; |
| 629 |
break; |
| 630 |
case DIV_SYSTEM_PET: |
| 631 |
dispatch=new DivPlatformPET; |
| 632 |
break; |
| 633 |
case DIV_SYSTEM_VIC20: |
| 634 |
dispatch=new DivPlatformVIC20; |
| 635 |
break; |
| 636 |
case DIV_SYSTEM_PONG: |
| 637 |
dispatch=new DivPlatformPong; |
| 638 |
break; |
| 639 |
case DIV_SYSTEM_VRC6: |
| 640 |
dispatch=new DivPlatformVRC6; |
| 641 |
break; |
| 642 |
case DIV_SYSTEM_MMC5: |
| 643 |
dispatch=new DivPlatformMMC5; |
| 644 |
break; |
| 645 |
case DIV_SYSTEM_ES5506: |
| 646 |
dispatch=new DivPlatformES5506; |
| 647 |
break; |
| 648 |
case DIV_SYSTEM_SCC: |
| 649 |
dispatch=new DivPlatformSCC; |
| 650 |
((DivPlatformSCC*)dispatch)->setChipModel(false); |
| 651 |
break; |
| 652 |
case DIV_SYSTEM_SCC_PLUS: |
| 653 |
dispatch=new DivPlatformSCC; |
| 654 |
((DivPlatformSCC*)dispatch)->setChipModel(true); |
| 655 |
break; |
| 656 |
case DIV_SYSTEM_YMZ280B: |
| 657 |
dispatch=new DivPlatformYMZ280B; |
| 658 |
((DivPlatformYMZ280B*)dispatch)->setChipModel(280); |
| 659 |
break; |
| 660 |
case DIV_SYSTEM_RF5C68: |
| 661 |
dispatch=new DivPlatformRF5C68; |
| 662 |
break; |
| 663 |
case DIV_SYSTEM_SOUND_UNIT: |
| 664 |
dispatch=new DivPlatformSoundUnit; |
| 665 |
break; |
| 666 |
case DIV_SYSTEM_MSM6258: |
| 667 |
dispatch=new DivPlatformMSM6258; |
| 668 |
break; |
| 669 |
case DIV_SYSTEM_MSM6295: |
| 670 |
dispatch=new DivPlatformMSM6295; |
| 671 |
break; |
| 672 |
case DIV_SYSTEM_MSM5232: |
| 673 |
dispatch=new DivPlatformMSM5232; |
| 674 |
break; |
| 675 |
case DIV_SYSTEM_NAMCO: |
| 676 |
dispatch=new DivPlatformNamcoWSG; |
| 677 |
// Pac-Man |
| 678 |
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(1); |
| 679 |
break; |
| 680 |
case DIV_SYSTEM_NAMCO_15XX: |
| 681 |
dispatch=new DivPlatformNamcoWSG; |
| 682 |
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(15); |
| 683 |
break; |
| 684 |
case DIV_SYSTEM_NAMCO_CUS30: |
| 685 |
dispatch=new DivPlatformNamcoWSG; |
| 686 |
((DivPlatformNamcoWSG*)dispatch)->setDeviceType(30); |
| 687 |
break; |
| 688 |
case DIV_SYSTEM_SNES: |
| 689 |
dispatch=new DivPlatformSNES; |
| 690 |
break; |
| 691 |
case DIV_SYSTEM_K007232: |
| 692 |
dispatch=new DivPlatformK007232; |
| 693 |
break; |
| 694 |
case DIV_SYSTEM_GA20: |
| 695 |
dispatch=new DivPlatformGA20; |
| 696 |
break; |
| 697 |
case DIV_SYSTEM_SUPERVISION: |
| 698 |
dispatch=new DivPlatformSupervision; |
| 699 |
break; |
| 700 |
case DIV_SYSTEM_UPD1771C: |
| 701 |
dispatch=new DivPlatformSCV; |
| 702 |
break; |
| 703 |
case DIV_SYSTEM_SM8521: |
| 704 |
dispatch=new DivPlatformSM8521; |
| 705 |
break; |
| 706 |
case DIV_SYSTEM_PV1000: |
| 707 |
dispatch=new DivPlatformPV1000; |
| 708 |
break; |
| 709 |
case DIV_SYSTEM_K053260: |
| 710 |
dispatch=new DivPlatformK053260; |
| 711 |
break; |
| 712 |
case DIV_SYSTEM_TED: |
| 713 |
dispatch=new DivPlatformTED; |
| 714 |
break; |
| 715 |
case DIV_SYSTEM_C140: |
| 716 |
dispatch=new DivPlatformC140; |
| 717 |
((DivPlatformC140*)dispatch)->set219(false); |
| 718 |
break; |
| 719 |
case DIV_SYSTEM_C219: |
| 720 |
dispatch=new DivPlatformC140; |
| 721 |
((DivPlatformC140*)dispatch)->set219(true); |
| 722 |
break; |
| 723 |
case DIV_SYSTEM_GBA_DMA: |
| 724 |
dispatch=new DivPlatformGBADMA; |
| 725 |
break; |
| 726 |
case DIV_SYSTEM_GBA_MINMOD: |
| 727 |
dispatch=new DivPlatformGBAMinMod; |
| 728 |
break; |
| 729 |
case DIV_SYSTEM_BIFURCATOR: |
| 730 |
dispatch=new DivPlatformBifurcator; |
| 731 |
break; |
| 732 |
case DIV_SYSTEM_PCM_DAC: |
| 733 |
dispatch=new DivPlatformPCMDAC; |
| 734 |
break; |
| 735 |
case DIV_SYSTEM_ESFM: |
| 736 |
dispatch=new DivPlatformESFM; |
| 737 |
if (isRender) { |
| 738 |
((DivPlatformESFM*)dispatch)->setFast(eng->getConfInt("esfmCoreRender",0)); |
| 739 |
} else { |
| 740 |
((DivPlatformESFM*)dispatch)->setFast(eng->getConfInt("esfmCore",0)); |
| 741 |
} |
| 742 |
break; |
| 743 |
case DIV_SYSTEM_POWERNOISE: |
| 744 |
dispatch=new DivPlatformPowerNoise; |
| 745 |
if (isRender) { |
| 746 |
((DivPlatformPowerNoise*)dispatch)->setCoreQuality(eng->getConfInt("pnQualityRender",3)); |
| 747 |
} else { |
| 748 |
((DivPlatformPowerNoise*)dispatch)->setCoreQuality(eng->getConfInt("pnQuality",3)); |
| 749 |
} |
| 750 |
break; |
| 751 |
case DIV_SYSTEM_DAVE: |
| 752 |
dispatch=new DivPlatformDave; |
| 753 |
break; |
| 754 |
case DIV_SYSTEM_NDS: |
| 755 |
dispatch=new DivPlatformNDS; |
| 756 |
break; |
| 757 |
case DIV_SYSTEM_5E01: |
| 758 |
dispatch=new DivPlatformNES; |
| 759 |
if (isRender) { |
| 760 |
((DivPlatformNES*)dispatch)->setNSFPlay(eng->getConfInt("nesCoreRender",0)==1); |
| 761 |
} else { |
| 762 |
((DivPlatformNES*)dispatch)->setNSFPlay(eng->getConfInt("nesCore",0)==1); |
| 763 |
} |
| 764 |
((DivPlatformNES*)dispatch)->set5E01(true); |
| 765 |
break; |
| 766 |
case DIV_SYSTEM_SID2: |
| 767 |
dispatch=new DivPlatformSID2; |
| 768 |
break; |
| 769 |
case DIV_SYSTEM_SID3: |
| 770 |
dispatch=new DivPlatformSID3; |
| 771 |
break; |
| 772 |
case DIV_SYSTEM_OPL4: |
| 773 |
dispatch=new DivPlatformOPL; |
| 774 |
((DivPlatformOPL*)dispatch)->setOPLType(4,false); |
| 775 |
if (isRender) { |
| 776 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl4CoreRender",0)); |
| 777 |
} else { |
| 778 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl4Core",0)); |
| 779 |
} |
| 780 |
break; |
| 781 |
case DIV_SYSTEM_OPL4_DRUMS: |
| 782 |
dispatch=new DivPlatformOPL; |
| 783 |
((DivPlatformOPL*)dispatch)->setOPLType(4,true); |
| 784 |
if (isRender) { |
| 785 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl4CoreRender",0)); |
| 786 |
} else { |
| 787 |
((DivPlatformOPL*)dispatch)->setCore(eng->getConfInt("opl4Core",0)); |
| 788 |
} |
| 789 |
break; |
| 790 |
case DIV_SYSTEM_DUMMY: |
| 791 |
dispatch=new DivPlatformDummy; |
| 792 |
break; |
| 793 |
default: |
| 794 |
logW("this system is not supported yet! using dummy platform."); |
| 795 |
dispatch=new DivPlatformDummy; |
| 796 |
break; |
| 797 |
} |
| 798 |
dispatch->init(eng,chanCount,gotRate,flags); |
| 799 |
|
| 800 |
// initialize output buffers |
| 801 |
int outs=dispatch->getOutputCount(); |
| 802 |
bbInLen=32768; |
| 803 |
|
| 804 |
for (int i=0; i<outs; i++) { |
| 805 |
bb[i]=blip_new(bbInLen); |
| 806 |
if (bb[i]==NULL) { |
| 807 |
logE("not enough memory!"); |
| 808 |
return; |
| 809 |
} |
| 810 |
|
| 811 |
bbIn[i]=new short[bbInLen]; |
| 812 |
bbOut[i]=new short[bbInLen]; |
| 813 |
memset(bbIn[i],0,bbInLen*sizeof(short)); |
| 814 |
memset(bbOut[i],0,bbInLen*sizeof(short)); |
| 815 |
blip_set_dc(bb[i],hiPass); |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
void DivDispatchContainer::quit() { |
| 820 |
if (dispatch==NULL) return; |
| 821 |
dispatch->quit(); |
| 822 |
delete dispatch; |
| 823 |
dispatch=NULL; |
| 824 |
|
| 825 |
for (int i=0; i<DIV_MAX_OUTPUTS; i++) { |
| 826 |
if (bbOut[i]!=NULL) { |
| 827 |
delete[] bbOut[i]; |
| 828 |
bbOut[i]=NULL; |
| 829 |
} |
| 830 |
if (bbIn[i]!=NULL) { |
| 831 |
delete[] bbIn[i]; |
| 832 |
bbIn[i]=NULL; |
| 833 |
} |
| 834 |
if (bb[i]!=NULL) { |
| 835 |
blip_delete(bb[i]); |
| 836 |
bb[i]=NULL; |
| 837 |
} |
| 838 |
} |
| 839 |
bbInLen=0; |
| 840 |
} |