furnace/src/engine/platform/genesis.h

130 lines
3.6 KiB
C
Raw Normal View History

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-05-16 22:43:10 +00:00
#ifndef _GENESIS_H
#define _GENESIS_H
2021-05-12 22:19:18 +00:00
#include "../dispatch.h"
2022-03-14 06:38:11 +00:00
#include <deque>
2021-05-12 22:19:18 +00:00
#include "../../../extern/Nuked-OPN2/ym3438.h"
#include "sound/ymfm/ymfm_opn.h"
2021-05-12 22:19:18 +00:00
2021-05-15 21:59:57 +00:00
#include "sms.h"
class DivYM2612Interface: public ymfm::ymfm_interface {
};
2021-05-12 22:19:18 +00:00
class DivPlatformGenesis: public DivDispatch {
2021-05-16 22:43:10 +00:00
protected:
struct Channel {
DivInstrumentFM state;
DivMacroInt std;
2021-05-16 22:43:10 +00:00
unsigned char freqH, freqL;
2022-01-23 20:55:12 +00:00
int freq, baseFreq, pitch, note;
2021-05-16 22:43:10 +00:00
unsigned char ins;
2022-01-23 20:55:12 +00:00
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
2022-01-26 23:03:08 +00:00
int vol, outVol;
2021-05-16 22:43:10 +00:00
unsigned char pan;
2022-01-23 20:55:12 +00: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),
portaPause(false),
furnaceDac(false),
inPorta(false),
vol(0),
pan(3) {}
2021-05-16 22:43:10 +00:00
};
Channel chan[10];
2021-12-18 08:25:42 +00:00
bool isMuted[10];
2021-05-16 22:43:10 +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) {}
};
2022-03-14 06:38:11 +00:00
std::deque<QueuedWrite> writes;
2021-05-16 22:43:10 +00:00
ym3438_t fm;
int delay;
unsigned char lastBusy;
ymfm::ym2612* fm_ymfm;
ymfm::ym2612::output_data out_ymfm;
DivYM2612Interface iface;
unsigned char regPool[512];
2021-05-16 22:43:10 +00:00
bool dacMode;
int dacPeriod;
int dacRate;
2021-12-14 17:33:26 +00:00
unsigned int dacPos;
2021-05-16 22:43:10 +00:00
int dacSample;
2021-12-14 17:33:26 +00:00
unsigned char sampleBank;
unsigned char lfoValue;
bool extMode, useYMFM;
2022-02-02 08:06:30 +00:00
bool ladder;
2021-05-16 22:43:10 +00:00
short oldWrites[512];
short pendingWrites[512];
int octave(int freq);
int toFreq(int freq);
2022-01-27 05:29:16 +00:00
friend void putDispatchChan(void*,int,int);
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 22:43:10 +00:00
2021-05-12 22:19:18 +00:00
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
2021-05-12 22:19:18 +00:00
int dispatch(DivCommand c);
2022-01-27 05:29:16 +00:00
void* getChanState(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
2021-12-11 18:14:38 +00:00
void reset();
void forceIns();
2021-05-12 22:19:18 +00:00
void tick();
2021-12-18 08:25:42 +00:00
void muteChannel(int ch, bool mute);
bool isStereo();
void setYMFM(bool use);
2021-12-08 05:33:00 +00:00
bool keyOffAffectsArp(int ch);
bool keyOffAffectsPorta(int ch);
void toggleRegisterDump(bool enable);
2022-01-28 17:59:53 +00:00
void setFlags(unsigned int flags);
2022-01-18 04:59:52 +00:00
void notifyInsChange(int ins);
void notifyInsDeletion(void* ins);
int getPortaFloor(int ch);
2022-02-01 23:08:19 +00:00
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
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);
void quit();
~DivPlatformGenesis();
2021-05-12 22:19:18 +00:00
};
2021-05-16 22:43:10 +00:00
#endif