| 1 |
/** |
| 2 |
* Furnace Tracker - multi-system chiptune tracker |
| 3 |
* Copyright (C) 2021-2025 tildearrow and contributors |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation; either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License along |
| 16 |
* with this program; if not, write to the Free Software Foundation, Inc., |
| 17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef _GENESIS_H |
| 21 |
#define _GENESIS_H |
| 22 |
|
| 23 |
#include "fmshared_OPN.h" |
| 24 |
#include "sound/ymfm/ymfm_opn.h" |
| 25 |
extern "C" { |
| 26 |
#include "../../../extern/YMF276-LLE/fmopn2.h" |
| 27 |
} |
| 28 |
|
| 29 |
class DivPlatformGenesis: public DivPlatformOPN { |
| 30 |
protected: |
| 31 |
const unsigned short chanOffs[6]={ |
| 32 |
0x00, 0x01, 0x02, 0x100, 0x101, 0x102 |
| 33 |
}; |
| 34 |
|
| 35 |
const unsigned char konOffs[6]={ |
| 36 |
0, 1, 2, 4, 5, 6 |
| 37 |
}; |
| 38 |
|
| 39 |
struct Channel: public FMChannelStereo { |
| 40 |
bool furnaceDac; |
| 41 |
bool dacMode; |
| 42 |
int dacPeriod; |
| 43 |
int dacRate; |
| 44 |
unsigned int dacPos; |
| 45 |
int dacSample; |
| 46 |
int dacDelay; |
| 47 |
bool dacDirection; |
| 48 |
bool setPos; |
| 49 |
unsigned char sampleBank; |
| 50 |
signed char dacOutput; |
| 51 |
Channel(): |
| 52 |
FMChannelStereo(), |
| 53 |
furnaceDac(false), |
| 54 |
dacMode(false), |
| 55 |
dacPeriod(0), |
| 56 |
dacRate(0), |
| 57 |
dacPos(0), |
| 58 |
dacSample(-1), |
| 59 |
dacDelay(0), |
| 60 |
dacDirection(false), |
| 61 |
setPos(false), |
| 62 |
sampleBank(0), |
| 63 |
dacOutput(0) {} |
| 64 |
}; |
| 65 |
Channel chan[10]; |
| 66 |
DivDispatchOscBuffer* oscBuf[10]; |
| 67 |
bool isMuted[10]; |
| 68 |
ym3438_t fm; |
| 69 |
fmopn2_t fm_276; |
| 70 |
|
| 71 |
ymfm::ym2612* fm_ymfm; |
| 72 |
ymfm::ym2612::output_data out_ymfm; |
| 73 |
DivOPNInterface iface; |
| 74 |
|
| 75 |
int softPCMTimer; |
| 76 |
|
| 77 |
bool extMode, softPCM, noExtMacros, canWriteDAC, msw; |
| 78 |
unsigned char useYMFM; |
| 79 |
unsigned char chipType; |
| 80 |
short dacWrite; |
| 81 |
|
| 82 |
int lleCycle; |
| 83 |
int llePrevCycle; |
| 84 |
int lleOscData[6]; |
| 85 |
int dacShifter, o_lro, o_bco; |
| 86 |
|
| 87 |
int interruptSim; |
| 88 |
int interruptSimCycles; |
| 89 |
|
| 90 |
unsigned char dacVolTable[128]; |
| 91 |
|
| 92 |
friend void putDispatchChip(void*,int); |
| 93 |
friend void putDispatchChan(void*,int,int); |
| 94 |
|
| 95 |
inline void processDAC(int iRate); |
| 96 |
inline void commitState(int ch, DivInstrument* ins); |
| 97 |
inline void acquire276OscSub(int h); |
| 98 |
void acquire_nuked(short** buf, size_t len); |
| 99 |
void acquire_nuked276(short** buf, size_t len); |
| 100 |
void acquire_ymfm(short** buf, size_t len); |
| 101 |
|
| 102 |
friend void putDispatchChip(void*,int); |
| 103 |
friend void putDispatchChan(void*,int,int); |
| 104 |
public: |
| 105 |
void acquire(short** buf, size_t len); |
| 106 |
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len); |
| 107 |
int dispatch(DivCommand c); |
| 108 |
void* getChanState(int chan); |
| 109 |
DivMacroInt* getChanMacroInt(int ch); |
| 110 |
virtual unsigned short getPan(int chan); |
| 111 |
DivSamplePos getSamplePos(int ch); |
| 112 |
DivDispatchOscBuffer* getOscBuffer(int chan); |
| 113 |
virtual int mapVelocity(int ch, float vel); |
| 114 |
unsigned char* getRegisterPool(); |
| 115 |
int getRegisterPoolSize(); |
| 116 |
void reset(); |
| 117 |
void forceIns(); |
| 118 |
void tick(bool sysTick=true); |
| 119 |
void muteChannel(int ch, bool mute); |
| 120 |
int getOutputCount(); |
| 121 |
void setYMFM(unsigned char use); |
| 122 |
bool keyOffAffectsArp(int ch); |
| 123 |
bool keyOffAffectsPorta(int ch); |
| 124 |
float getPostAmp(); |
| 125 |
void toggleRegisterDump(bool enable); |
| 126 |
void setFlags(const DivConfig& flags); |
| 127 |
void notifyInsChange(int ins); |
| 128 |
virtual void notifyInsDeletion(void* ins); |
| 129 |
void setSoftPCM(bool value); |
| 130 |
int getPortaFloor(int ch); |
| 131 |
void poke(unsigned int addr, unsigned short val); |
| 132 |
void poke(std::vector<DivRegWrite>& wlist); |
| 133 |
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); |
| 134 |
void quit(); |
| 135 |
DivPlatformGenesis(): |
| 136 |
DivPlatformOPN(2, 6, 6, 6, 6, 9440540.0, 72, 32, false, 7) {} |
| 137 |
~DivPlatformGenesis(); |
| 138 |
}; |
| 139 |
#endif |