2022-03-05 18:18:08 -05:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
2023-01-19 19:18:40 -05:00
|
|
|
* Copyright (C) 2021-2023 tildearrow and contributors
|
2022-03-05 18:18:08 -05:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OPL_H
|
|
|
|
#define _OPL_H
|
2022-12-13 02:22:48 -05:00
|
|
|
|
2022-03-05 18:18:08 -05:00
|
|
|
#include "../dispatch.h"
|
2023-07-13 05:09:20 -04:00
|
|
|
#include "../fixedQueue.h"
|
2022-05-04 19:06:32 -04:00
|
|
|
#include "../../../extern/opl/opl3.h"
|
2022-05-13 15:59:36 -04:00
|
|
|
#include "sound/ymfm/ymfm_adpcm.h"
|
|
|
|
|
|
|
|
class DivOPLAInterface: public ymfm::ymfm_interface {
|
|
|
|
public:
|
|
|
|
unsigned char* adpcmBMem;
|
|
|
|
int sampleBank;
|
|
|
|
uint8_t ymfm_external_read(ymfm::access_class type, uint32_t address);
|
|
|
|
void ymfm_external_write(ymfm::access_class type, uint32_t address, uint8_t data);
|
|
|
|
DivOPLAInterface(): adpcmBMem(NULL), sampleBank(0) {}
|
|
|
|
};
|
2022-03-05 18:18:08 -05:00
|
|
|
|
|
|
|
class DivPlatformOPL: public DivDispatch {
|
|
|
|
protected:
|
2022-12-13 02:22:48 -05:00
|
|
|
struct Channel: public SharedChannel<int> {
|
2022-03-05 18:18:08 -05:00
|
|
|
DivInstrumentFM state;
|
|
|
|
unsigned char freqH, freqL;
|
2022-12-04 05:58:58 -05:00
|
|
|
int sample, fixedFreq;
|
|
|
|
bool furnacePCM, fourOp, hardReset;
|
2022-03-05 18:18:08 -05:00
|
|
|
unsigned char pan;
|
Prepare for split sample chip instrument
(MSM6258, MSM6295, QSound, Sega PCM, ADPCM-A, ADPCM-B, YMZ280B, RF5C68)
Instrument color and icons are placeholder.
different volume range, hard panned/soft panned and/or independent volume per output, chip-dependent features (global volume, echo, etc)
Allow use sample in instrument tab for chip with sample support
Prepare to support X1-010 Seta 2 style bankswitch behavior
Prepare to support AY89x0 PCM DAC
Support volume for PCE sample (DAC)
Fix Lynx, Y8950 sample pitch matches to sample preview
Support PCM DAC with backward and pingpong loop mode
Reduce some codes
Add Sega PCM, AY89x0, QSound, PCM DAC, Lynx per-channel debug support
2022-08-27 03:27:36 -04:00
|
|
|
int macroVolMul;
|
2022-03-05 18:18:08 -05:00
|
|
|
Channel():
|
2022-12-13 02:22:48 -05:00
|
|
|
SharedChannel<int>(0),
|
2022-03-05 18:18:08 -05:00
|
|
|
freqH(0),
|
|
|
|
freqL(0),
|
2022-05-13 17:52:44 -04:00
|
|
|
sample(-1),
|
2022-05-16 22:06:49 -04:00
|
|
|
fixedFreq(0),
|
2022-05-13 17:52:44 -04:00
|
|
|
furnacePCM(false),
|
2022-03-14 03:30:25 -04:00
|
|
|
fourOp(false),
|
2022-05-07 22:48:29 -04:00
|
|
|
hardReset(false),
|
Prepare for split sample chip instrument
(MSM6258, MSM6295, QSound, Sega PCM, ADPCM-A, ADPCM-B, YMZ280B, RF5C68)
Instrument color and icons are placeholder.
different volume range, hard panned/soft panned and/or independent volume per output, chip-dependent features (global volume, echo, etc)
Allow use sample in instrument tab for chip with sample support
Prepare to support X1-010 Seta 2 style bankswitch behavior
Prepare to support AY89x0 PCM DAC
Support volume for PCE sample (DAC)
Fix Lynx, Y8950 sample pitch matches to sample preview
Support PCM DAC with backward and pingpong loop mode
Reduce some codes
Add Sega PCM, AY89x0, QSound, PCM DAC, Lynx per-channel debug support
2022-08-27 03:27:36 -04:00
|
|
|
pan(3),
|
|
|
|
macroVolMul(64) {
|
2022-03-16 02:53:46 -04:00
|
|
|
state.ops=2;
|
|
|
|
}
|
2022-03-05 18:18:08 -05:00
|
|
|
};
|
|
|
|
Channel chan[20];
|
2022-06-29 03:11:25 -04:00
|
|
|
DivDispatchOscBuffer* oscBuf[20];
|
2022-03-05 18:18:08 -05:00
|
|
|
bool isMuted[20];
|
|
|
|
struct QueuedWrite {
|
|
|
|
unsigned short addr;
|
|
|
|
unsigned char val;
|
|
|
|
bool addrOrVal;
|
2023-07-13 05:09:20 -04:00
|
|
|
QueuedWrite(): addr(0), val(0), addrOrVal(false) {}
|
2022-03-05 18:18:08 -05:00
|
|
|
QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v), addrOrVal(false) {}
|
|
|
|
};
|
2023-07-13 05:09:20 -04:00
|
|
|
FixedQueue<QueuedWrite,2048> writes;
|
2022-03-05 18:18:08 -05:00
|
|
|
opl3_chip fm;
|
2022-05-13 15:59:36 -04:00
|
|
|
unsigned char* adpcmBMem;
|
|
|
|
size_t adpcmBMemLen;
|
|
|
|
DivOPLAInterface iface;
|
2022-09-25 21:07:21 -04:00
|
|
|
unsigned int sampleOffB[256];
|
2022-11-26 18:44:04 -05:00
|
|
|
bool sampleLoaded[256];
|
2022-05-13 15:59:36 -04:00
|
|
|
|
|
|
|
ymfm::adpcm_b_engine* adpcmB;
|
2022-03-06 18:10:12 -05:00
|
|
|
const unsigned char** slotsNonDrums;
|
|
|
|
const unsigned char** slotsDrums;
|
|
|
|
const unsigned char** slots;
|
2022-03-07 17:07:29 -05:00
|
|
|
const unsigned short* chanMap;
|
2022-04-30 23:59:26 -04:00
|
|
|
const unsigned char* outChanMap;
|
2022-07-01 06:33:33 -04:00
|
|
|
int chipFreqBase, chipRateBase;
|
2023-01-13 22:11:26 -05:00
|
|
|
int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan, sampleBank, totalOutputs;
|
2022-03-05 18:18:08 -05:00
|
|
|
unsigned char lastBusy;
|
2022-03-16 02:53:46 -04:00
|
|
|
unsigned char drumState;
|
|
|
|
unsigned char drumVol[5];
|
2022-03-05 18:18:08 -05:00
|
|
|
|
|
|
|
unsigned char regPool[512];
|
|
|
|
|
2022-03-16 02:53:46 -04:00
|
|
|
bool properDrums, properDrumsSys, dam, dvb;
|
2022-03-07 17:07:29 -05:00
|
|
|
|
2022-03-05 18:18:08 -05:00
|
|
|
unsigned char lfoValue;
|
|
|
|
|
2023-01-05 03:08:57 -05:00
|
|
|
bool useYMFM, update4OpMask, pretendYMU, downsample, compatPan;
|
2022-03-05 18:18:08 -05:00
|
|
|
|
|
|
|
short oldWrites[512];
|
|
|
|
short pendingWrites[512];
|
|
|
|
|
|
|
|
int octave(int freq);
|
|
|
|
int toFreq(int freq);
|
2022-05-13 17:52:44 -04:00
|
|
|
double NOTE_ADPCMB(int note);
|
2023-01-19 02:45:02 -05:00
|
|
|
void commitState(int ch, DivInstrument* ins);
|
2022-03-05 18:18:08 -05:00
|
|
|
|
2022-09-23 10:24:02 -04:00
|
|
|
friend void putDispatchChip(void*,int);
|
2022-03-05 18:18:08 -05:00
|
|
|
friend void putDispatchChan(void*,int,int);
|
|
|
|
|
2023-01-03 01:09:46 -05:00
|
|
|
void acquire_nuked(short** buf, size_t len);
|
|
|
|
//void acquire_ymfm(short** buf, size_t len);
|
2022-03-05 18:18:08 -05:00
|
|
|
|
|
|
|
public:
|
2023-01-02 04:53:37 -05:00
|
|
|
void acquire(short** buf, size_t len);
|
2022-03-05 18:18:08 -05:00
|
|
|
int dispatch(DivCommand c);
|
|
|
|
void* getChanState(int chan);
|
2022-06-05 19:17:00 -04:00
|
|
|
DivMacroInt* getChanMacroInt(int ch);
|
2022-04-30 23:59:26 -04:00
|
|
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
2022-03-05 18:18:08 -05:00
|
|
|
unsigned char* getRegisterPool();
|
|
|
|
int getRegisterPoolSize();
|
|
|
|
void reset();
|
|
|
|
void forceIns();
|
2022-04-15 16:01:11 -04:00
|
|
|
void tick(bool sysTick=true);
|
2022-03-05 18:18:08 -05:00
|
|
|
void muteChannel(int ch, bool mute);
|
2023-01-01 19:46:08 -05:00
|
|
|
int getOutputCount();
|
2022-03-05 18:18:08 -05:00
|
|
|
void setYMFM(bool use);
|
2022-03-07 17:07:29 -05:00
|
|
|
void setOPLType(int type, bool drums);
|
2022-03-05 18:18:08 -05:00
|
|
|
bool keyOffAffectsArp(int ch);
|
|
|
|
bool keyOffAffectsPorta(int ch);
|
|
|
|
void toggleRegisterDump(bool enable);
|
2022-09-29 21:13:40 -04:00
|
|
|
void setFlags(const DivConfig& flags);
|
2022-03-05 18:18:08 -05:00
|
|
|
void notifyInsChange(int ins);
|
|
|
|
void notifyInsDeletion(void* ins);
|
|
|
|
int getPortaFloor(int ch);
|
|
|
|
void poke(unsigned int addr, unsigned short val);
|
|
|
|
void poke(std::vector<DivRegWrite>& wlist);
|
2022-05-13 15:59:36 -04:00
|
|
|
const void* getSampleMem(int index);
|
|
|
|
size_t getSampleMemCapacity(int index);
|
|
|
|
size_t getSampleMemUsage(int index);
|
2022-11-26 18:44:04 -05:00
|
|
|
bool isSampleLoaded(int index, int sample);
|
2022-11-26 23:50:20 -05:00
|
|
|
void renderSamples(int chipID);
|
2022-09-29 21:13:40 -04:00
|
|
|
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
2022-03-05 18:18:08 -05:00
|
|
|
void quit();
|
|
|
|
~DivPlatformOPL();
|
|
|
|
};
|
|
|
|
#endif
|