mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-02 09:17:26 +00:00
OPN/A/B: fix CSM when using ymfm
and now there's a crash
This commit is contained in:
parent
3164f311f5
commit
a0f0c863c9
13 changed files with 37 additions and 43 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "fmsharedbase.h"
|
||||
#include "../../../extern/opn/ym3438.h"
|
||||
#include "sound/ymfm/ymfm_opn.h"
|
||||
|
||||
#define PLEASE_HELP_ME(_targetChan) \
|
||||
int boundaryBottom=parent->calcBaseFreq(chipClock,CHIP_FREQBASE,0,false); \
|
||||
|
@ -86,6 +87,19 @@
|
|||
|
||||
#define IS_EXTCH_MUTED (isOpMuted[0] && isOpMuted[1] && isOpMuted[2] && isOpMuted[3])
|
||||
|
||||
class DivOPNInterface: public ymfm::ymfm_interface {
|
||||
int setA, setB;
|
||||
int countA, countB;
|
||||
|
||||
public:
|
||||
void clock(int cycles=144);
|
||||
void ymfm_set_timer(uint32_t tnum, int32_t duration_in_clocks);
|
||||
DivOPNInterface():
|
||||
ymfm::ymfm_interface(),
|
||||
countA(0),
|
||||
countB(0) {}
|
||||
};
|
||||
|
||||
class DivPlatformOPN: public DivPlatformFMBase {
|
||||
protected:
|
||||
const unsigned short ADDR_MULT_DT=0x30;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#define IS_REALLY_MUTED(x) (isMuted[x] && (x<5 || !softPCM || (isMuted[5] && isMuted[6])))
|
||||
|
||||
void DivYM2612Interface::ymfm_set_timer(uint32_t tnum, int32_t duration_in_clocks) {
|
||||
void DivOPNInterface::ymfm_set_timer(uint32_t tnum, int32_t duration_in_clocks) {
|
||||
if (tnum==1) {
|
||||
setB=duration_in_clocks;
|
||||
} else if (tnum==0) {
|
||||
|
@ -36,16 +36,16 @@ void DivYM2612Interface::ymfm_set_timer(uint32_t tnum, int32_t duration_in_clock
|
|||
}
|
||||
}
|
||||
|
||||
void DivYM2612Interface::clock() {
|
||||
void DivOPNInterface::clock(int cycles) {
|
||||
if (setA>=0) {
|
||||
countA-=144;
|
||||
countA-=cycles;
|
||||
if (countA<0) {
|
||||
m_engine->engine_timer_expired(0);
|
||||
countA+=setA;
|
||||
}
|
||||
}
|
||||
if (setB>=0) {
|
||||
countB-=144;
|
||||
countB-=cycles;
|
||||
if (countB<0) {
|
||||
m_engine->engine_timer_expired(1);
|
||||
countB+=setB;
|
||||
|
|
|
@ -26,19 +26,6 @@ extern "C" {
|
|||
#include "../../../extern/YMF276-LLE/fmopn2.h"
|
||||
}
|
||||
|
||||
class DivYM2612Interface: public ymfm::ymfm_interface {
|
||||
int setA, setB;
|
||||
int countA, countB;
|
||||
|
||||
public:
|
||||
void clock();
|
||||
void ymfm_set_timer(uint32_t tnum, int32_t duration_in_clocks);
|
||||
DivYM2612Interface():
|
||||
ymfm::ymfm_interface(),
|
||||
countA(0),
|
||||
countB(0) {}
|
||||
};
|
||||
|
||||
class DivPlatformGenesis: public DivPlatformOPN {
|
||||
protected:
|
||||
const unsigned short chanOffs[6]={
|
||||
|
@ -83,7 +70,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
|
|||
|
||||
ymfm::ym2612* fm_ymfm;
|
||||
ymfm::ym2612::output_data out_ymfm;
|
||||
DivYM2612Interface iface;
|
||||
DivOPNInterface iface;
|
||||
|
||||
int softPCMTimer;
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include "sound/ymfm/ymfm.h"
|
||||
#include "../engine.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define CHIP_FREQBASE fmFreqBase
|
||||
#define CHIP_DIVIDER fmDivBase
|
||||
|
@ -277,6 +276,7 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) {
|
|||
}
|
||||
|
||||
fm->generate(&fmout);
|
||||
iface.clock(24);
|
||||
|
||||
os=((fmout.data[0]*fmVol)>>8)+(((fmout.data[1]+fmout.data[2]+fmout.data[3])*ssgVol)>>8);
|
||||
if (os<-32768) os=-32768;
|
||||
|
|
|
@ -28,10 +28,6 @@ extern "C" {
|
|||
|
||||
#include "ay.h"
|
||||
|
||||
class DivYM2203Interface: public ymfm::ymfm_interface {
|
||||
|
||||
};
|
||||
|
||||
class DivPlatformYM2203: public DivPlatformOPN {
|
||||
protected:
|
||||
const unsigned short chanOffs[3]={
|
||||
|
@ -48,7 +44,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
|
|||
ym3438_t fm_nuked;
|
||||
ymfm::ym2203* fm;
|
||||
ymfm::ym2203::output_data fmout;
|
||||
DivYM2203Interface iface;
|
||||
DivOPNInterface iface;
|
||||
fmopna_t fm_lle;
|
||||
unsigned int dacVal;
|
||||
unsigned int dacVal2;
|
||||
|
@ -73,7 +69,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
|
|||
void acquire_lle(short** buf, size_t len);
|
||||
|
||||
public:
|
||||
bool isCSM;
|
||||
unsigned char isCSM;
|
||||
void acquire(short** buf, size_t len);
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
|
@ -100,7 +96,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
|
|||
DivPlatformYM2203():
|
||||
DivPlatformOPN(2, 3, 6, 6, 6, 4720270.0, 36, 16),
|
||||
prescale(0x2d),
|
||||
isCSM(false) {}
|
||||
isCSM(0) {}
|
||||
~DivPlatformYM2203();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "ym2203ext.h"
|
||||
#include "../engine.h"
|
||||
#include <math.h>
|
||||
|
||||
#define CHIP_FREQBASE fmFreqBase
|
||||
#define CHIP_DIVIDER fmDivBase
|
||||
|
@ -787,7 +786,7 @@ void DivPlatformYM2203Ext::quit() {
|
|||
}
|
||||
|
||||
void DivPlatformYM2203Ext::setCSM(bool isCSM) {
|
||||
this->isCSM=isCSM;
|
||||
this->isCSM=isCSM?1:0;
|
||||
if (isCSM) {
|
||||
csmChan=3;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,9 @@
|
|||
*/
|
||||
|
||||
#include "ym2608.h"
|
||||
#include "sound/ymfm/ymfm.h"
|
||||
#include "../engine.h"
|
||||
#include "../../ta-log.h"
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define CHIP_FREQBASE fmFreqBase
|
||||
#define CHIP_DIVIDER fmDivBase
|
||||
|
@ -462,6 +460,7 @@ void DivPlatformYM2608::acquire_ymfm(short** buf, size_t len) {
|
|||
}
|
||||
|
||||
fm->generate(&fmout);
|
||||
iface.clock(48);
|
||||
|
||||
os[0]=((fmout.data[0]*fmVol)>>8)+((fmout.data[2]*ssgVol)>>8);
|
||||
if (os[0]<-32768) os[0]=-32768;
|
||||
|
@ -2040,7 +2039,7 @@ int DivPlatformYM2608::init(DivEngine* p, int channels, int sugRate, const DivCo
|
|||
}
|
||||
|
||||
void DivPlatformYM2608::setCSM(bool isCSM) {
|
||||
this->isCSM=isCSM;
|
||||
this->isCSM=isCSM?1:0;
|
||||
psgChanOffs=6+isCSM; // doing this hurts me...
|
||||
adpcmAChanOffs=9+isCSM;
|
||||
adpcmBChanOffs=15+isCSM;
|
||||
|
|
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
|
||||
#include "ay.h"
|
||||
|
||||
class DivYM2608Interface: public ymfm::ymfm_interface {
|
||||
class DivYM2608Interface: public DivOPNInterface {
|
||||
public:
|
||||
unsigned char* adpcmBMem;
|
||||
int sampleBank;
|
||||
|
@ -92,7 +92,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
|
|||
void acquire_lle(short** buf, size_t len);
|
||||
|
||||
public:
|
||||
bool isCSM;
|
||||
unsigned char isCSM;
|
||||
void acquire(short** buf, size_t len);
|
||||
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
|
@ -127,7 +127,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
|
|||
DivPlatformYM2608():
|
||||
DivPlatformOPN(2, 6, 9, 15, 16, 9440540.0, 72, 32),
|
||||
prescale(0x2d),
|
||||
isCSM(false) {}
|
||||
isCSM(0) {}
|
||||
~DivPlatformYM2608();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
#include "ym2610.h"
|
||||
#include <math.h>
|
||||
|
||||
const char* regCheatSheetYM2610[]={
|
||||
// SSG
|
||||
|
@ -395,6 +394,7 @@ void DivPlatformYM2610::acquire_ymfm(short** buf, size_t len) {
|
|||
}
|
||||
|
||||
fm->generate(&fmout);
|
||||
iface.clock();
|
||||
|
||||
os[0]+=((fmout.data[0]*fmVol)>>8)+((fmout.data[2]*ssgVol)>>8);
|
||||
if (os[0]<-32768) os[0]=-32768;
|
||||
|
@ -1791,7 +1791,7 @@ int DivPlatformYM2610::init(DivEngine* p, int channels, int sugRate, const DivCo
|
|||
}
|
||||
|
||||
void DivPlatformYM2610::setCSM(bool isCSM) {
|
||||
this->isCSM=isCSM;
|
||||
this->isCSM=isCSM?1:0;
|
||||
psgChanOffs=4+isCSM; // doing this hurts me...
|
||||
adpcmAChanOffs=7+isCSM;
|
||||
adpcmBChanOffs=13+isCSM;
|
||||
|
|
|
@ -45,7 +45,7 @@ class DivPlatformYM2610: public DivPlatformYM2610Base {
|
|||
void acquire_lle(short** buf, size_t len);
|
||||
|
||||
public:
|
||||
bool isCSM;
|
||||
unsigned char isCSM;
|
||||
void acquire(short** buf, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
|
@ -71,7 +71,7 @@ class DivPlatformYM2610: public DivPlatformYM2610Base {
|
|||
void quit();
|
||||
DivPlatformYM2610():
|
||||
DivPlatformYM2610Base(1,4,7,13,14),
|
||||
isCSM(false) {}
|
||||
isCSM(0) {}
|
||||
~DivPlatformYM2610();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
#include "ym2610b.h"
|
||||
#include <math.h>
|
||||
|
||||
const char* regCheatSheetYM2610B[]={
|
||||
// SSG
|
||||
|
@ -1864,7 +1863,7 @@ int DivPlatformYM2610B::init(DivEngine* p, int channels, int sugRate, const DivC
|
|||
}
|
||||
|
||||
void DivPlatformYM2610B::setCSM(bool isCSM) {
|
||||
this->isCSM=isCSM;
|
||||
this->isCSM=isCSM?1:0;
|
||||
psgChanOffs=6+isCSM; // doing this hurts me...
|
||||
adpcmAChanOffs=9+isCSM;
|
||||
adpcmBChanOffs=15+isCSM;
|
||||
|
|
|
@ -41,7 +41,7 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
|
|||
void acquire_lle(short** buf, size_t len);
|
||||
|
||||
public:
|
||||
bool isCSM;
|
||||
unsigned char isCSM;
|
||||
void acquire(short** buf, size_t len);
|
||||
int dispatch(DivCommand c);
|
||||
void* getChanState(int chan);
|
||||
|
@ -67,7 +67,7 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
|
|||
void quit();
|
||||
DivPlatformYM2610B():
|
||||
DivPlatformYM2610Base(2,6,9,15,16),
|
||||
isCSM(false) {}
|
||||
isCSM(0) {}
|
||||
~DivPlatformYM2610B();
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
#define CHIP_FREQBASE fmFreqBase
|
||||
#define CHIP_DIVIDER fmDivBase
|
||||
|
||||
class DivYM2610Interface: public ymfm::ymfm_interface {
|
||||
class DivYM2610Interface: public DivOPNInterface {
|
||||
public:
|
||||
unsigned char* adpcmAMem;
|
||||
unsigned char* adpcmBMem;
|
||||
|
|
Loading…
Reference in a new issue