| 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 _YM2608_H |
| 21 |
#define _YM2608_H |
| 22 |
|
| 23 |
#include "fmshared_OPN.h" |
| 24 |
#include "sound/ymfm/ymfm_opn.h" |
| 25 |
extern "C" { |
| 26 |
#include "../../../extern/YM2608-LLE/fmopna_2608.h" |
| 27 |
} |
| 28 |
|
| 29 |
#include "ay.h" |
| 30 |
|
| 31 |
class DivYM2608Interface: public DivOPNInterface { |
| 32 |
public: |
| 33 |
unsigned char* adpcmBMem; |
| 34 |
int sampleBank; |
| 35 |
uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address); |
| 36 |
void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data); |
| 37 |
DivYM2608Interface(): adpcmBMem(NULL), sampleBank(0) {} |
| 38 |
}; |
| 39 |
|
| 40 |
class DivPlatformYM2608: public DivPlatformOPN { |
| 41 |
protected: |
| 42 |
const unsigned short chanOffs[6]={ |
| 43 |
0x00, 0x01, 0x02, 0x100, 0x101, 0x102 |
| 44 |
}; |
| 45 |
|
| 46 |
const unsigned char konOffs[6]={ |
| 47 |
0, 1, 2, 4, 5, 6 |
| 48 |
}; |
| 49 |
|
| 50 |
OPNChannelStereo chan[17]; |
| 51 |
DivDispatchOscBuffer* oscBuf[17]; |
| 52 |
bool isMuted[17]; |
| 53 |
ym3438_t fm_nuked; |
| 54 |
ymfm::ym2608* fm; |
| 55 |
ymfm::ym2608::output_data fmout; |
| 56 |
fmopna_t fm_lle; |
| 57 |
unsigned int dacVal; |
| 58 |
unsigned int dacVal2; |
| 59 |
int dacOut[2]; |
| 60 |
int rssOut[6]; |
| 61 |
bool lastSH; |
| 62 |
bool lastSH2; |
| 63 |
bool lastS; |
| 64 |
unsigned char cas, ras, rssCycle, rssSubCycle; |
| 65 |
unsigned int adMemAddr; |
| 66 |
|
| 67 |
unsigned char* adpcmBMem; |
| 68 |
size_t adpcmBMemLen; |
| 69 |
DivYM2608Interface iface; |
| 70 |
unsigned int* sampleOffB; |
| 71 |
bool* sampleLoaded; |
| 72 |
|
| 73 |
DivPlatformAY8910* ay; |
| 74 |
unsigned char sampleBank; |
| 75 |
unsigned char writeRSSOff, writeRSSOn; |
| 76 |
int globalRSSVolume; |
| 77 |
|
| 78 |
bool extMode, noExtMacros; |
| 79 |
unsigned char prescale, nukedMult, memConfig; |
| 80 |
|
| 81 |
DivMemoryComposition memCompo; |
| 82 |
|
| 83 |
double NOTE_OPNB(int ch, int note); |
| 84 |
double NOTE_ADPCMB(int note); |
| 85 |
|
| 86 |
friend void putDispatchChip(void*,int); |
| 87 |
|
| 88 |
inline void commitState(int ch, DivInstrument* ins); |
| 89 |
|
| 90 |
void acquire_combo(short** buf, size_t len); |
| 91 |
void acquire_ymfm(short** buf, size_t len); |
| 92 |
void acquire_lle(short** buf, size_t len); |
| 93 |
|
| 94 |
public: |
| 95 |
unsigned char isCSM; |
| 96 |
void acquire(short** buf, size_t len); |
| 97 |
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len); |
| 98 |
int dispatch(DivCommand c); |
| 99 |
void* getChanState(int chan); |
| 100 |
DivMacroInt* getChanMacroInt(int ch); |
| 101 |
virtual unsigned short getPan(int chan); |
| 102 |
DivDispatchOscBuffer* getOscBuffer(int chan); |
| 103 |
unsigned char* getRegisterPool(); |
| 104 |
int getRegisterPoolSize(); |
| 105 |
void reset(); |
| 106 |
void forceIns(); |
| 107 |
void tick(bool sysTick=true); |
| 108 |
void muteChannel(int ch, bool mute); |
| 109 |
int getOutputCount(); |
| 110 |
bool keyOffAffectsArp(int ch); |
| 111 |
void notifyInsChange(int ins); |
| 112 |
virtual void notifyInsDeletion(void* ins); |
| 113 |
void setSkipRegisterWrites(bool val); |
| 114 |
void poke(unsigned int addr, unsigned short val); |
| 115 |
void poke(std::vector<DivRegWrite>& wlist); |
| 116 |
const char** getRegisterSheet(); |
| 117 |
const void* getSampleMem(int index); |
| 118 |
size_t getSampleMemCapacity(int index); |
| 119 |
size_t getSampleMemUsage(int index); |
| 120 |
bool isSampleLoaded(int index, int sample); |
| 121 |
const DivMemoryComposition* getMemCompo(int index); |
| 122 |
void renderSamples(int chipID); |
| 123 |
void setFlags(const DivConfig& flags); |
| 124 |
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); |
| 125 |
void setCSM(bool isCSM); |
| 126 |
void quit(); |
| 127 |
DivPlatformYM2608(); |
| 128 |
~DivPlatformYM2608(); |
| 129 |
}; |
| 130 |
#endif |