furnace/src/engine/platform/arcade.h

89 lines
2.6 KiB
C
Raw Normal View History

2021-12-08 17:40:35 -05:00
#ifndef _ARCADE_H
#define _ARCADE_H
#include "../dispatch.h"
2022-01-23 00:57:47 -05:00
#include "../instrument.h"
2021-12-08 17:40:35 -05:00
#include <queue>
2021-12-09 01:03:05 -05:00
#include "../../../extern/opm/opm.h"
#include "sound/ymfm/ymfm_opm.h"
2022-01-27 02:17:09 -05:00
#include "../macroInt.h"
class DivArcadeInterface: public ymfm::ymfm_interface {
};
2021-12-08 17:40:35 -05:00
class DivPlatformArcade: public DivDispatch {
protected:
struct Channel {
2022-01-23 00:57:47 -05:00
DivInstrumentFM state;
2022-01-27 02:17:09 -05:00
DivMacroInt std;
2021-12-08 17:40:35 -05:00
unsigned char freqH, freqL;
2022-01-27 02:17:09 -05:00
int freq, baseFreq, pitch, note;
2021-12-08 17:40:35 -05:00
unsigned char ins;
signed char konCycles;
2022-01-27 02:17:09 -05:00
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM;
int vol, outVol;
2021-12-08 18:29:50 -05: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-27 02:17:09 -05:00
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), note(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), inPorta(false), portaPause(false), furnacePCM(false), vol(0), outVol(0), chVolL(127), chVolR(127) {}
2021-12-08 17:40:35 -05: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;
2022-01-29 00:20:27 -05:00
int delay, baseFreqOff;
2021-12-14 12:33:26 -05:00
int pcmL, pcmR, pcmCycles;
unsigned char sampleBank;
2021-12-08 17:40:35 -05:00
unsigned char lastBusy;
2022-01-20 17:54:11 -05:00
unsigned char amDepth, pmDepth;
2021-12-08 17:40:35 -05:00
ymfm::ym2151* fm_ymfm;
ymfm::ym2151::output_data out_ymfm;
DivArcadeInterface iface;
bool extMode, useYMFM;
2021-12-18 03:25:42 -05:00
bool isMuted[13];
2021-12-08 17:40:35 -05:00
short oldWrites[256];
short pendingWrites[256];
int octave(int freq);
int toFreq(int freq);
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 17:40:35 -05:00
2022-01-27 00:29:16 -05:00
friend void putDispatchChan(void*,int,int);
2021-12-08 17:40:35 -05:00
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
2022-01-27 00:29:16 -05:00
void* getChanState(int chan);
2021-12-11 13:14:38 -05:00
void reset();
void forceIns();
2021-12-08 17:40:35 -05:00
void tick();
2021-12-18 03:25:42 -05:00
void muteChannel(int ch, bool mute);
2022-01-17 23:59:52 -05:00
void notifyInsChange(int ins);
2022-01-29 00:20:27 -05:00
void setFlags(unsigned int flags);
2021-12-08 17:40:35 -05:00
bool isStereo();
void setYMFM(bool use);
2022-02-01 18:08:19 -05:00
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
2022-01-28 12:59:53 -05:00
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformArcade();
2021-12-08 17:40:35 -05:00
};
#endif