2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
|
|
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2021-12-08 22:40:35 +00:00
|
|
|
#ifndef _ARCADE_H
|
|
|
|
#define _ARCADE_H
|
|
|
|
#include "../dispatch.h"
|
2022-01-23 05:57:47 +00:00
|
|
|
#include "../instrument.h"
|
2021-12-08 22:40:35 +00:00
|
|
|
#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"
|
2022-01-27 07:17:09 +00:00
|
|
|
#include "../macroInt.h"
|
2021-12-15 06:23:58 +00:00
|
|
|
|
|
|
|
class DivArcadeInterface: public ymfm::ymfm_interface {
|
|
|
|
|
|
|
|
};
|
2021-12-08 22:40:35 +00:00
|
|
|
|
|
|
|
class DivPlatformArcade: public DivDispatch {
|
|
|
|
protected:
|
|
|
|
struct Channel {
|
2022-01-23 05:57:47 +00:00
|
|
|
DivInstrumentFM state;
|
2022-01-27 07:17:09 +00:00
|
|
|
DivMacroInt std;
|
2021-12-08 22:40:35 +00:00
|
|
|
unsigned char freqH, freqL;
|
2022-04-28 05:50:09 +00:00
|
|
|
int freq, baseFreq, pitch, pitch2, note;
|
2022-04-25 23:58:17 +00:00
|
|
|
int ins;
|
2021-12-08 22:40:35 +00:00
|
|
|
signed char konCycles;
|
2022-04-10 07:11:36 +00:00
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
|
2022-01-27 07:17:09 +00:00
|
|
|
int vol, outVol;
|
2021-12-08 23:29:50 +00:00
|
|
|
unsigned char chVolL, chVolR;
|
2022-04-28 06:31:16 +00:00
|
|
|
void macroInit(DivInstrument* which) {
|
|
|
|
std.init(which);
|
|
|
|
pitch2=0;
|
|
|
|
}
|
2022-04-10 07:11:36 +00:00
|
|
|
Channel():
|
|
|
|
freqH(0),
|
|
|
|
freqL(0),
|
|
|
|
freq(0),
|
|
|
|
baseFreq(0),
|
|
|
|
pitch(0),
|
2022-04-28 05:50:09 +00:00
|
|
|
pitch2(0),
|
2022-04-10 07:11:36 +00:00
|
|
|
note(0),
|
|
|
|
ins(-1),
|
|
|
|
active(false),
|
|
|
|
insChanged(true),
|
|
|
|
freqChanged(false),
|
|
|
|
keyOn(false),
|
|
|
|
keyOff(false),
|
|
|
|
inPorta(false),
|
|
|
|
portaPause(false),
|
|
|
|
furnacePCM(false),
|
|
|
|
hardReset(false),
|
|
|
|
vol(0),
|
|
|
|
outVol(0),
|
|
|
|
chVolL(127),
|
|
|
|
chVolR(127) {}
|
2021-12-08 22:40:35 +00:00
|
|
|
};
|
2022-02-23 07:52:30 +00:00
|
|
|
Channel chan[8];
|
2022-05-01 03:59:26 +00:00
|
|
|
DivDispatchOscBuffer* oscBuf[8];
|
2021-12-08 22:40:35 +00:00
|
|
|
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 05:20:27 +00:00
|
|
|
int delay, baseFreqOff;
|
2021-12-14 17:33:26 +00:00
|
|
|
int pcmL, pcmR, pcmCycles;
|
2021-12-08 22:40:35 +00:00
|
|
|
unsigned char lastBusy;
|
2022-01-20 22:54:11 +00:00
|
|
|
unsigned char amDepth, pmDepth;
|
2021-12-08 22:40:35 +00:00
|
|
|
|
2021-12-15 06:23:58 +00:00
|
|
|
ymfm::ym2151* fm_ymfm;
|
|
|
|
ymfm::ym2151::output_data out_ymfm;
|
|
|
|
DivArcadeInterface iface;
|
|
|
|
|
2022-02-22 03:31:27 +00:00
|
|
|
unsigned char regPool[256];
|
|
|
|
|
2021-12-15 06:23:58 +00:00
|
|
|
bool extMode, useYMFM;
|
2021-12-18 08:25:42 +00:00
|
|
|
|
2022-02-23 07:52:30 +00:00
|
|
|
bool isMuted[8];
|
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
|
|
|
|
2022-01-27 05:29:16 +00:00
|
|
|
friend void putDispatchChan(void*,int,int);
|
|
|
|
|
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);
|
2022-01-27 05:29:16 +00:00
|
|
|
void* getChanState(int chan);
|
2022-05-01 03:59:26 +00:00
|
|
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
2022-02-22 03:31:27 +00:00
|
|
|
unsigned char* getRegisterPool();
|
|
|
|
int getRegisterPoolSize();
|
2021-12-11 18:14:38 +00:00
|
|
|
void reset();
|
2021-12-21 06:29:07 +00:00
|
|
|
void forceIns();
|
2022-04-15 20:01:11 +00:00
|
|
|
void tick(bool sysTick=true);
|
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);
|
2022-01-29 05:20:27 +00:00
|
|
|
void setFlags(unsigned int flags);
|
2021-12-08 22:40:35 +00:00
|
|
|
bool isStereo();
|
2021-12-15 06:23:58 +00:00
|
|
|
void setYMFM(bool use);
|
2022-02-01 23:08:19 +00:00
|
|
|
void poke(unsigned int addr, unsigned short val);
|
|
|
|
void poke(std::vector<DivRegWrite>& wlist);
|
2022-02-03 23:38:57 +00:00
|
|
|
const char** getRegisterSheet();
|
2022-02-15 06:46:03 +00:00
|
|
|
const char* getEffectName(unsigned char effect);
|
2022-01-28 17:59:53 +00:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
2021-12-15 05:37:27 +00:00
|
|
|
void quit();
|
|
|
|
~DivPlatformArcade();
|
2021-12-08 22:40:35 +00:00
|
|
|
};
|
|
|
|
#endif
|