Reduce more FM codes

This commit is contained in:
cam900 2022-06-06 19:40:37 +09:00
parent d1aeabe464
commit ebbd9784e6
8 changed files with 19 additions and 55 deletions

View File

@ -19,19 +19,18 @@
#ifndef _ARCADE_H
#define _ARCADE_H
#include "../dispatch.h"
#include "fmshared_OPM.h"
#include "../macroInt.h"
#include "../instrument.h"
#include <queue>
#include "../../../extern/opm/opm.h"
#include "sound/ymfm/ymfm_opm.h"
#include "fmshared_OPM.h"
class DivArcadeInterface: public ymfm::ymfm_interface {
};
class DivPlatformArcade: public DivDispatch, public DivPlatformOPMBase {
class DivPlatformArcade: public DivPlatformOPMBase {
protected:
const unsigned short chanOffs[8]={
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
@ -85,14 +84,9 @@ class DivPlatformArcade: public DivDispatch, public DivPlatformOPMBase {
ymfm::ym2151::output_data out_ymfm;
DivArcadeInterface iface;
unsigned char regPool[256];
bool extMode, useYMFM;
bool isMuted[8];
short oldWrites[256];
short pendingWrites[256];
int octave(int freq);
int toFreq(int freq);

View File

@ -20,6 +20,7 @@
#ifndef _FMSHARED_BASE_H
#define _FMSHARED_BASE_H
#include "../dispatch.h"
#include <deque>
#define rWrite(a,v) if (!skipRegisterWrites) {pendingWrites[a]=v;}
@ -37,7 +38,7 @@
} \
}
class DivPlatformFMBase {
class DivPlatformFMBase: public DivDispatch {
protected:
const bool isOutput[8][4]={
// 1 3 2 4
@ -69,6 +70,10 @@ class DivPlatformFMBase {
unsigned char lastBusy;
int delay;
unsigned char regPool[512];
short oldWrites[512];
short pendingWrites[512];
DivPlatformFMBase():
lastBusy(0),
delay(0) {}

View File

@ -19,18 +19,17 @@
#ifndef _GENESIS_H
#define _GENESIS_H
#include "../dispatch.h"
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "../../../extern/Nuked-OPN2/ym3438.h"
#include "sound/ymfm/ymfm_opn.h"
#include "fmshared_OPN.h"
class DivYM2612Interface: public ymfm::ymfm_interface {
};
class DivPlatformGenesis: public DivDispatch, public DivPlatformOPNBase {
class DivPlatformGenesis: public DivPlatformOPNBase {
protected:
const unsigned short chanOffs[6]={
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
@ -112,7 +111,6 @@ class DivPlatformGenesis: public DivDispatch, public DivPlatformOPNBase {
ymfm::ym2612* fm_ymfm;
ymfm::ym2612::output_data out_ymfm;
DivYM2612Interface iface;
unsigned char regPool[512];
unsigned char lfoValue;
@ -121,9 +119,6 @@ class DivPlatformGenesis: public DivDispatch, public DivPlatformOPNBase {
bool extMode, softPCM, useYMFM;
bool ladder;
short oldWrites[512];
short pendingWrites[512];
unsigned char dacVolTable[128];
friend void putDispatchChan(void*,int,int);
@ -160,7 +155,6 @@ class DivPlatformGenesis: public DivDispatch, public DivPlatformOPNBase {
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
DivPlatformGenesis():
DivDispatch(),
DivPlatformOPNBase(9440540.0, 72, 32) {}
~DivPlatformGenesis();
};

View File

@ -19,18 +19,17 @@
#ifndef _TX81Z_H
#define _TX81Z_H
#include "../dispatch.h"
#include "fmshared_OPM.h"
#include "../macroInt.h"
#include "../instrument.h"
#include <queue>
#include "sound/ymfm/ymfm_opz.h"
#include "fmshared_OPM.h"
class DivTXInterface: public ymfm::ymfm_interface {
};
class DivPlatformTX81Z: public DivDispatch, public DivPlatformOPMBase {
class DivPlatformTX81Z: public DivPlatformOPMBase {
protected:
const unsigned short chanOffs[8]={
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
@ -82,15 +81,10 @@ class DivPlatformTX81Z: public DivDispatch, public DivPlatformOPMBase {
ymfm::ym2414::output_data out_ymfm;
DivTXInterface iface;
unsigned char regPool[330];
bool extMode;
bool isMuted[8];
short oldWrites[330];
short pendingWrites[330];
int octave(int freq);
int toFreq(int freq);

View File

@ -19,18 +19,17 @@
#ifndef _YM2203_H
#define _YM2203_H
#include "../dispatch.h"
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "sound/ymfm/ymfm_opn.h"
#include "ay.h"
#include "fmshared_OPN.h"
class DivYM2203Interface: public ymfm::ymfm_interface {
};
class DivPlatformYM2203: public DivDispatch, public DivPlatformOPNBase {
class DivPlatformYM2203: public DivPlatformOPNBase {
protected:
const unsigned short chanOffs[3]={
0x00, 0x01, 0x02
@ -86,16 +85,12 @@ class DivPlatformYM2203: public DivDispatch, public DivPlatformOPNBase {
ymfm::ym2203* fm;
ymfm::ym2203::output_data fmout;
DivYM2203Interface iface;
unsigned char regPool[256];
DivPlatformAY8910* ay;
unsigned char sampleBank;
bool extMode;
short oldWrites[256];
short pendingWrites[256];
friend void putDispatchChan(void*,int,int);
public:
@ -123,7 +118,6 @@ class DivPlatformYM2203: public DivDispatch, public DivPlatformOPNBase {
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
DivPlatformYM2203():
DivDispatch(),
DivPlatformOPNBase(4720270.0, 36, 16) {}
~DivPlatformYM2203();
};

View File

@ -19,12 +19,11 @@
#ifndef _YM2608_H
#define _YM2608_H
#include "../dispatch.h"
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "sound/ymfm/ymfm_opn.h"
#include "ay.h"
#include "fmshared_OPN.h"
class DivYM2608Interface: public ymfm::ymfm_interface {
public:
@ -35,7 +34,7 @@ class DivYM2608Interface: public ymfm::ymfm_interface {
DivYM2608Interface(): adpcmBMem(NULL), sampleBank(0) {}
};
class DivPlatformYM2608: public DivDispatch, public DivPlatformOPNBase {
class DivPlatformYM2608: public DivPlatformOPNBase {
protected:
const unsigned short chanOffs[6]={
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
@ -92,7 +91,6 @@ class DivPlatformYM2608: public DivDispatch, public DivPlatformOPNBase {
bool isMuted[16];
ymfm::ym2608* fm;
ymfm::ym2608::output_data fmout;
unsigned char regPool[512];
unsigned char* adpcmBMem;
size_t adpcmBMemLen;
@ -106,9 +104,6 @@ class DivPlatformYM2608: public DivDispatch, public DivPlatformOPNBase {
double fmFreqBase;
unsigned char ayDiv;
short oldWrites[512];
short pendingWrites[512];
double NOTE_OPNB(int ch, int note);
double NOTE_ADPCMB(int note);
friend void putDispatchChan(void*,int,int);
@ -142,7 +137,6 @@ class DivPlatformYM2608: public DivDispatch, public DivPlatformOPNBase {
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
DivPlatformYM2608():
DivDispatch(),
DivPlatformOPNBase(9440540.0, 72, 32) {}
~DivPlatformYM2608();
};

View File

@ -19,10 +19,9 @@
#ifndef _YM2610_H
#define _YM2610_H
#include "../dispatch.h"
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "ay.h"
#include "fmshared_OPN.h"
#include "sound/ymfm/ymfm_opn.h"
class DivYM2610Interface: public ymfm::ymfm_interface {
@ -35,7 +34,7 @@ class DivYM2610Interface: public ymfm::ymfm_interface {
DivYM2610Interface(): adpcmAMem(NULL), adpcmBMem(NULL), sampleBank(0) {}
};
class DivPlatformYM2610Base: public DivDispatch, public DivPlatformOPNBase {
class DivPlatformYM2610Base: public DivPlatformOPNBase {
protected:
unsigned char* adpcmAMem;
size_t adpcmAMemLen;
@ -51,7 +50,6 @@ class DivPlatformYM2610Base: public DivDispatch, public DivPlatformOPNBase {
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
DivPlatformYM2610Base():
DivDispatch(),
DivPlatformOPNBase(9440540.0, 72, 32) {}
};
@ -118,15 +116,11 @@ class DivPlatformYM2610: public DivPlatformYM2610Base {
ymfm::ym2610::output_data fmout;
DivPlatformAY8910* ay;
unsigned char regPool[512];
unsigned char sampleBank;
bool extMode;
short oldWrites[512];
short pendingWrites[512];
double NOTE_OPNB(int ch, int note);
double NOTE_ADPCMB(int note);
friend void putDispatchChan(void*,int,int);

View File

@ -19,12 +19,11 @@
#ifndef _YM2610B_H
#define _YM2610B_H
#include "../dispatch.h"
#include "ym2610.h"
#include "../macroInt.h"
#include <queue>
#include "sound/ymfm/ymfm_opn.h"
#include "ym2610.h"
class DivPlatformYM2610B: public DivPlatformYM2610Base {
protected:
@ -83,7 +82,6 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
bool isMuted[16];
ymfm::ym2610b* fm;
ymfm::ym2610b::output_data fmout;
unsigned char regPool[512];
DivPlatformAY8910* ay;
unsigned char sampleBank;
@ -91,9 +89,6 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base {
bool extMode;
double fmFreqBase=9440540;
unsigned char ayDiv=32;
short oldWrites[512];
short pendingWrites[512];
double NOTE_OPNB(int ch, int note);
double NOTE_ADPCMB(int note);