2021-12-08 22:40:35 +00:00
|
|
|
#ifndef _ARCADE_H
|
|
|
|
#define _ARCADE_H
|
|
|
|
#include "../dispatch.h"
|
|
|
|
#include <queue>
|
2021-12-09 06:03:05 +00:00
|
|
|
#include "../../../extern/opm/opm.h"
|
2021-12-15 06:23:58 +00:00
|
|
|
#include "sound/ymfm/ymfm_opm.h"
|
|
|
|
|
|
|
|
class DivArcadeInterface: public ymfm::ymfm_interface {
|
|
|
|
|
|
|
|
};
|
2021-12-08 22:40:35 +00:00
|
|
|
|
|
|
|
class DivPlatformArcade: public DivDispatch {
|
|
|
|
protected:
|
|
|
|
struct Channel {
|
|
|
|
unsigned char freqH, freqL;
|
|
|
|
int freq, baseFreq, pitch;
|
|
|
|
unsigned char ins;
|
|
|
|
signed char konCycles;
|
2022-01-20 21:09:05 +00:00
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnacePCM;
|
2021-12-08 22:40:35 +00:00
|
|
|
int vol;
|
2021-12-08 23:29:50 +00:00
|
|
|
unsigned char chVolL, chVolR;
|
|
|
|
|
|
|
|
struct PCMChannel {
|
|
|
|
int sample;
|
|
|
|
unsigned int pos; // <<8
|
|
|
|
unsigned short len;
|
|
|
|
unsigned char freq;
|
|
|
|
PCMChannel(): sample(-1), pos(0), len(0), freq(0) {}
|
|
|
|
} pcm;
|
2022-01-20 21:09:05 +00:00
|
|
|
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), furnacePCM(false), vol(0), chVolL(127), chVolR(127) {}
|
2021-12-08 22:40:35 +00:00
|
|
|
};
|
|
|
|
Channel chan[13];
|
|
|
|
struct QueuedWrite {
|
|
|
|
unsigned short addr;
|
|
|
|
unsigned char val;
|
|
|
|
bool addrOrVal;
|
|
|
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
|
|
|
};
|
|
|
|
std::queue<QueuedWrite> writes;
|
|
|
|
opm_t fm;
|
|
|
|
int delay;
|
2021-12-14 17:33:26 +00:00
|
|
|
int pcmL, pcmR, pcmCycles;
|
|
|
|
unsigned char sampleBank;
|
2021-12-08 22:40:35 +00:00
|
|
|
unsigned char lastBusy;
|
|
|
|
|
2021-12-15 06:23:58 +00:00
|
|
|
ymfm::ym2151* fm_ymfm;
|
|
|
|
ymfm::ym2151::output_data out_ymfm;
|
|
|
|
DivArcadeInterface iface;
|
|
|
|
|
|
|
|
bool extMode, useYMFM;
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
bool isMuted[13];
|
2021-12-08 22:40:35 +00:00
|
|
|
|
|
|
|
short oldWrites[256];
|
|
|
|
short pendingWrites[256];
|
|
|
|
|
|
|
|
int octave(int freq);
|
|
|
|
int toFreq(int freq);
|
2021-12-15 06:23:58 +00:00
|
|
|
|
|
|
|
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);
|
|
|
|
void acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len);
|
2021-12-08 22:40:35 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
|
|
|
int dispatch(DivCommand c);
|
2021-12-11 18:14:38 +00:00
|
|
|
void reset();
|
2021-12-21 06:29:07 +00:00
|
|
|
void forceIns();
|
2021-12-08 22:40:35 +00:00
|
|
|
void tick();
|
2021-12-18 08:25:42 +00:00
|
|
|
void muteChannel(int ch, bool mute);
|
2022-01-18 04:59:52 +00:00
|
|
|
void notifyInsChange(int ins);
|
2021-12-08 22:40:35 +00:00
|
|
|
bool isStereo();
|
2021-12-15 06:23:58 +00:00
|
|
|
void setYMFM(bool use);
|
2021-12-08 22:40:35 +00:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, bool pal);
|
2021-12-15 05:37:27 +00:00
|
|
|
void quit();
|
|
|
|
~DivPlatformArcade();
|
2021-12-08 22:40:35 +00:00
|
|
|
};
|
|
|
|
#endif
|