2022-02-14 22:12:20 -05: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-05-16 18:43:10 -04:00
|
|
|
#ifndef _GENESIS_H
|
|
|
|
#define _GENESIS_H
|
2021-05-12 18:19:18 -04:00
|
|
|
#include "../dispatch.h"
|
2022-03-14 02:38:11 -04:00
|
|
|
#include <deque>
|
2021-05-12 18:19:18 -04:00
|
|
|
#include "../../../extern/Nuked-OPN2/ym3438.h"
|
2022-02-02 23:08:45 -05:00
|
|
|
#include "sound/ymfm/ymfm_opn.h"
|
2021-05-12 18:19:18 -04:00
|
|
|
|
2021-05-15 17:59:57 -04:00
|
|
|
#include "sms.h"
|
|
|
|
|
2022-02-02 23:08:45 -05:00
|
|
|
class DivYM2612Interface: public ymfm::ymfm_interface {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-05-12 18:19:18 -04:00
|
|
|
class DivPlatformGenesis: public DivDispatch {
|
2021-05-16 18:43:10 -04:00
|
|
|
protected:
|
|
|
|
struct Channel {
|
2022-01-22 17:43:57 -05:00
|
|
|
DivInstrumentFM state;
|
2022-01-23 13:19:19 -05:00
|
|
|
DivMacroInt std;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char freqH, freqL;
|
2022-04-28 01:50:09 -04:00
|
|
|
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note;
|
2022-04-25 19:58:17 -04:00
|
|
|
int ins;
|
2022-04-10 03:11:36 -04:00
|
|
|
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, hardReset;
|
2022-01-26 18:03:08 -05:00
|
|
|
int vol, outVol;
|
2021-05-16 18:43:10 -04:00
|
|
|
unsigned char pan;
|
2022-04-28 02:31:16 -04:00
|
|
|
void macroInit(DivInstrument* which) {
|
|
|
|
std.init(which);
|
|
|
|
pitch2=0;
|
|
|
|
}
|
2022-01-23 15:55:12 -05:00
|
|
|
Channel():
|
|
|
|
freqH(0),
|
|
|
|
freqL(0),
|
|
|
|
freq(0),
|
|
|
|
baseFreq(0),
|
|
|
|
pitch(0),
|
2022-04-28 01:50:09 -04:00
|
|
|
pitch2(0),
|
2022-04-23 19:02:43 -04:00
|
|
|
portaPauseFreq(0),
|
2022-01-23 15:55:12 -05:00
|
|
|
note(0),
|
|
|
|
ins(-1),
|
|
|
|
active(false),
|
|
|
|
insChanged(true),
|
|
|
|
freqChanged(false),
|
|
|
|
keyOn(false),
|
|
|
|
keyOff(false),
|
|
|
|
portaPause(false),
|
|
|
|
furnaceDac(false),
|
|
|
|
inPorta(false),
|
2022-04-10 03:11:36 -04:00
|
|
|
hardReset(false),
|
2022-01-23 15:55:12 -05:00
|
|
|
vol(0),
|
|
|
|
pan(3) {}
|
2021-05-16 18:43:10 -04:00
|
|
|
};
|
|
|
|
Channel chan[10];
|
2022-04-30 23:59:26 -04:00
|
|
|
DivDispatchOscBuffer* oscBuf[10];
|
2021-12-18 03:25:42 -05:00
|
|
|
bool isMuted[10];
|
2021-05-16 18:43:10 -04:00
|
|
|
struct QueuedWrite {
|
|
|
|
unsigned short addr;
|
|
|
|
unsigned char val;
|
|
|
|
bool addrOrVal;
|
|
|
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
|
|
|
};
|
2022-03-14 02:38:11 -04:00
|
|
|
std::deque<QueuedWrite> writes;
|
2021-05-16 18:43:10 -04:00
|
|
|
ym3438_t fm;
|
|
|
|
int delay;
|
|
|
|
unsigned char lastBusy;
|
2022-02-02 23:08:45 -05:00
|
|
|
|
|
|
|
ymfm::ym2612* fm_ymfm;
|
|
|
|
ymfm::ym2612::output_data out_ymfm;
|
|
|
|
DivYM2612Interface iface;
|
2022-02-21 22:31:27 -05:00
|
|
|
unsigned char regPool[512];
|
2021-05-16 18:43:10 -04:00
|
|
|
|
|
|
|
bool dacMode;
|
|
|
|
int dacPeriod;
|
|
|
|
int dacRate;
|
2021-12-14 12:33:26 -05:00
|
|
|
unsigned int dacPos;
|
2021-05-16 18:43:10 -04:00
|
|
|
int dacSample;
|
2022-04-25 02:42:26 -04:00
|
|
|
int dacDelay;
|
|
|
|
bool dacReady;
|
2022-05-27 03:47:44 -04:00
|
|
|
bool dacDirection;
|
2021-12-14 12:33:26 -05:00
|
|
|
unsigned char sampleBank;
|
2022-01-23 15:15:46 -05:00
|
|
|
unsigned char lfoValue;
|
2021-05-16 21:49:54 -04:00
|
|
|
|
2022-02-02 23:08:45 -05:00
|
|
|
bool extMode, useYMFM;
|
2022-02-02 03:06:30 -05:00
|
|
|
bool ladder;
|
2021-05-16 18:43:10 -04:00
|
|
|
|
|
|
|
short oldWrites[512];
|
|
|
|
short pendingWrites[512];
|
2021-05-18 02:20:38 -04:00
|
|
|
|
2022-01-27 00:29:16 -05:00
|
|
|
friend void putDispatchChan(void*,int,int);
|
2022-02-02 23:08:45 -05: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-05-16 18:43:10 -04:00
|
|
|
|
2021-05-12 18:19:18 -04:00
|
|
|
public:
|
2021-12-06 16:51:18 -05:00
|
|
|
void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
2021-05-12 18:19:18 -04:00
|
|
|
int dispatch(DivCommand c);
|
2022-01-27 00:29:16 -05:00
|
|
|
void* getChanState(int chan);
|
2022-04-30 23:59:26 -04:00
|
|
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
2022-02-21 22:31:27 -05:00
|
|
|
unsigned char* getRegisterPool();
|
|
|
|
int getRegisterPoolSize();
|
2021-12-11 13:14:38 -05:00
|
|
|
void reset();
|
2021-12-21 01:29:07 -05:00
|
|
|
void forceIns();
|
2022-04-15 16:01:11 -04:00
|
|
|
void tick(bool sysTick=true);
|
2021-12-18 03:25:42 -05:00
|
|
|
void muteChannel(int ch, bool mute);
|
2021-12-06 16:51:18 -05:00
|
|
|
bool isStereo();
|
2022-02-02 23:08:45 -05:00
|
|
|
void setYMFM(bool use);
|
2021-12-08 00:33:00 -05:00
|
|
|
bool keyOffAffectsArp(int ch);
|
2021-12-29 02:08:50 -05:00
|
|
|
bool keyOffAffectsPorta(int ch);
|
2022-01-24 01:01:08 -05:00
|
|
|
void toggleRegisterDump(bool enable);
|
2022-01-28 12:59:53 -05:00
|
|
|
void setFlags(unsigned int flags);
|
2022-01-17 23:59:52 -05:00
|
|
|
void notifyInsChange(int ins);
|
2022-01-13 19:36:02 -05:00
|
|
|
void notifyInsDeletion(void* ins);
|
2022-01-30 15:55:31 -05:00
|
|
|
int getPortaFloor(int ch);
|
2022-02-01 18:08:19 -05:00
|
|
|
void poke(unsigned int addr, unsigned short val);
|
|
|
|
void poke(std::vector<DivRegWrite>& wlist);
|
2022-02-15 01:46:03 -05:00
|
|
|
const char* getEffectName(unsigned char effect);
|
2022-01-28 12:59:53 -05:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
2021-12-15 00:37:27 -05:00
|
|
|
void quit();
|
|
|
|
~DivPlatformGenesis();
|
2021-05-12 18:19:18 -04:00
|
|
|
};
|
2021-05-16 18:43:10 -04:00
|
|
|
#endif
|