Merge pull request #771 from tildearrow/duplicate_channel_struct

Reduce duplicates at channel struct
This commit is contained in:
tildearrow 2022-12-13 00:19:03 -05:00 committed by GitHub
commit f455d2d942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
71 changed files with 472 additions and 1169 deletions

65
src/engine/chipUtils.h Normal file
View File

@ -0,0 +1,65 @@
/**
* 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.
*/
#ifndef _CHIP_UTILS_H
#define _CHIP_UTILS_H
// custom clock limits
#define MIN_CUSTOM_CLOCK 100000
#define MAX_CUSTOM_CLOCK 40000000
// common shared channel struct
struct SharedChannel {
int ins;
int note;
bool active, insChanged, keyOn, keyOff;
SharedChannel():
ins(-1),
note(0),
active(false),
insChanged(true),
keyOn(false),
keyOff(false) {}
};
// common shared channel struct with frequency
struct SharedChannelFreq: public SharedChannel {
int freq, baseFreq, pitch, pitch2;
bool freqChanged, inPorta, portaPause;
SharedChannelFreq():
SharedChannel(),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
freqChanged(false),
inPorta(false),
portaPause(false) {}
};
// common shared channel volume struct
template<typename T>
struct SharedChannelVolume {
T vol, outVol;
SharedChannelVolume(T initVol):
vol(initVol),
outVol(initVol) {}
};
#endif

View File

@ -24,6 +24,7 @@
#include <string.h>
#include <vector>
#include "config.h"
#include "chipUtils.h"
#define ONE_SEMITONE 2200
@ -453,6 +454,18 @@ class DivDispatch {
*/
virtual bool getWantPreNote();
/**
* get minimum chip clock.
* @return clock in Hz, or 0 if custom clocks are not supported.
*/
virtual int getClockRangeMin();
/**
* get maximum chip clock.
* @return clock in Hz, or 0 if custom clocks are not supported.
*/
virtual int getClockRangeMax();
/**
* set the chip flags.
* @param flags a DivConfig containing chip flags.
@ -582,9 +595,9 @@ class DivDispatch {
// custom chip clock helper define. put in setFlags, but before rate is set.
#define CHECK_CUSTOM_CLOCK \
if (flags.getInt("customClock",0)>0) { \
chipClock=flags.getInt("customClock",1000000); \
if (chipClock>20000000) chipClock=20000000; \
if (chipClock<100000) chipClock=100000; \
chipClock=flags.getInt("customClock",getClockRangeMin()); \
if (chipClock>getClockRangeMax()) chipClock=getClockRangeMax(); \
if (chipClock<getClockRangeMin()) chipClock=getClockRangeMin(); \
}
// pitch calculation:

View File

@ -97,6 +97,14 @@ bool DivDispatch::getWantPreNote() {
return false;
}
int DivDispatch::getClockRangeMin() {
return MIN_CUSTOM_CLOCK;
}
int DivDispatch::getClockRangeMax() {
return MAX_CUSTOM_CLOCK;
}
void DivDispatch::setFlags(const DivConfig& flags) {
}

View File

@ -26,19 +26,15 @@
#include "../waveSynth.h"
class DivPlatformAmiga: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned int audLoc;
unsigned short audLen;
unsigned int audPos;
int audSub;
signed char audDat;
int sample, wave;
int ins;
int busClock;
int note;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, useV, useP;
signed char vol, outVol;
bool useWave, setPos, useV, useP;
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -46,10 +42,8 @@ class DivPlatformAmiga: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(64),
audLoc(0),
audLen(0),
audPos(0),
@ -57,21 +51,11 @@ class DivPlatformAmiga: public DivDispatch {
audDat(0),
sample(-1),
wave(-1),
ins(-1),
busClock(0),
note(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
useWave(false),
setPos(false),
useV(false),
useP(false),
vol(64),
outVol(64) {}
useP(false) {}
};
Channel chan[4];
DivDispatchOscBuffer* oscBuf[4];

View File

@ -20,8 +20,6 @@
#ifndef _ARCADE_H
#define _ARCADE_H
#include "fmshared_OPM.h"
#include "../macroInt.h"
#include "../instrument.h"
#include <queue>
#include "../../../extern/opm/opm.h"
#include "sound/ymfm/ymfm_opm.h"
@ -36,44 +34,12 @@ class DivPlatformArcade: public DivPlatformOPM {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
};
struct Channel {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note;
int ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset, opMaskChanged;
int vol, outVol;
unsigned char chVolL, chVolR, opMask;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
struct Channel: public FMChannel {
unsigned char chVolL, chVolR;
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
portaPause(false),
furnacePCM(false),
hardReset(false),
opMaskChanged(false),
vol(0),
outVol(0),
chVolL(127),
chVolR(127),
opMask(15) {}
FMChannel(),
chVolL(1),
chVolR(1) {}
};
Channel chan[8];
DivDispatchOscBuffer* oscBuf[8];
@ -94,10 +60,9 @@ class DivPlatformArcade: public DivPlatformOPM {
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);
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
friend void putDispatchChip(void*,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -30,7 +30,7 @@ class DivPlatformAY8910: public DivDispatch {
0,4,1,5,2,6,9,8,11,12,13,3,7,10,14,15
};
inline unsigned char regRemap(unsigned char reg) { return intellivision?AY8914RegRemap[reg&0x0f]:reg&0x0f; }
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
struct PSGMode {
union {
struct {
@ -73,38 +73,21 @@ class DivPlatformAY8910: public DivDispatch {
furnaceDAC(0) {}
} dac;
int freq, baseFreq, note, pitch, pitch2;
int ins;
unsigned char autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(15),
curPSGMode(PSGMode(0)),
nextPSGMode(PSGMode(1)),
dac(DAC()),
freq(0),
baseFreq(0),
note(0),
pitch(0),
pitch2(0),
ins(-1),
autoEnvNum(0),
autoEnvDen(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
vol(0),
outVol(15) {}
autoEnvDen(0) {}
};
Channel chan[3];
bool isMuted[3];

View File

@ -26,7 +26,7 @@
class DivPlatformAY8930: public DivDispatch {
protected:
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
struct Envelope {
unsigned char mode;
unsigned short period;
@ -81,40 +81,23 @@ class DivPlatformAY8930: public DivDispatch {
furnaceDAC(0) {}
} dac;
int freq, baseFreq, note, pitch, pitch2;
int ins;
unsigned char autoEnvNum, autoEnvDen, duty;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(31),
envelope(Envelope()),
curPSGMode(PSGMode(0)),
nextPSGMode(PSGMode(1)),
dac(DAC()),
freq(0),
baseFreq(0),
note(0),
pitch(0),
pitch2(0),
ins(-1),
autoEnvNum(0),
autoEnvDen(0),
duty(4),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
vol(0),
outVol(31) {}
duty(4) {}
};
Channel chan[3];
bool isMuted[3];

View File

@ -27,10 +27,8 @@
#include "vgsound_emu/src/k005289/k005289.hpp"
class DivPlatformBubSysWSG: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
signed short wave;
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system
DivMacroInt std;
DivWaveSynth ws;
@ -39,20 +37,8 @@ class DivPlatformBubSysWSG: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
wave(-1) {}
};
Channel chan[2];

View File

@ -27,27 +27,22 @@
#include "sound/c64_fp/SID.h"
class DivPlatformC64: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, prevFreq, testWhen, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int prevFreq, testWhen;
unsigned char sweep, wave, attack, decay, sustain, release;
short duty;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, filter;
bool sweepChanged, filter;
bool resetMask, resetFilter, resetDuty, ring, sync, test;
signed char vol, outVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
prevFreq(65535),
testWhen(0),
note(0),
ins(-1),
sweep(0),
wave(0),
attack(0),
@ -55,21 +50,14 @@ class DivPlatformC64: public DivDispatch {
sustain(0),
release(0),
duty(0),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
filter(false),
resetMask(false),
resetFilter(false),
resetDuty(false),
ring(false),
sync(false),
test(false),
vol(15) {}
test(false) {}
};
Channel chan[3];
DivDispatchOscBuffer* oscBuf[3];

View File

@ -27,11 +27,11 @@
#include "sound/nes_nsfplay/nes_fds.h"
class DivPlatformFDS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, prevFreq, note, modFreq, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int prevFreq, modFreq;
unsigned char duty, sweep, modDepth, modPos;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, modOn;
signed char vol, outVol, wave;
bool sweepChanged, modOn;
signed short wave;
signed char modTable[32];
DivMacroInt std;
void macroInit(DivInstrument* which) {
@ -39,28 +39,16 @@ class DivPlatformFDS: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(32),
prevFreq(65535),
note(0),
modFreq(0),
ins(-1),
duty(0),
sweep(8),
modDepth(0),
modPos(0),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
modOn(false),
vol(32),
outVol(32),
wave(-1) {
memset(modTable,0,32);
}

View File

@ -101,6 +101,54 @@ class DivPlatformOPN: public DivPlatformFMBase {
0x00, 0x04, 0x08, 0x0c
};
struct OPNChannel: public FMChannel {
unsigned char psgMode, autoEnvNum, autoEnvDen;
bool furnacePCM;
int sample, macroVolMul;
OPNChannel():
FMChannel(),
psgMode(1),
autoEnvNum(0),
autoEnvDen(0),
furnacePCM(false),
sample(-1),
macroVolMul(255) {}
};
struct OPNChannelStereo: public OPNChannel {
unsigned char pan;
OPNChannelStereo():
OPNChannel(),
pan(3) {}
};
struct OPNOpChannel: public SharedChannelFreq, public SharedChannelVolume<int> {
DivMacroInt std;
unsigned char freqH, freqL;
int portaPauseFreq;
signed char konCycles;
bool mask;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
OPNOpChannel():
SharedChannelFreq(),
SharedChannelVolume<int>(0),
freqH(0),
freqL(0),
portaPauseFreq(0),
mask(true) {}
};
struct OPNOpChannelStereo: public OPNOpChannel {
unsigned char pan;
OPNOpChannelStereo():
OPNOpChannel(),
pan(3) {}
};
double fmFreqBase;
unsigned int fmDivBase;
unsigned int ayDiv;
@ -108,6 +156,8 @@ class DivPlatformOPN: public DivPlatformFMBase {
DivConfig ayFlags;
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false):
DivPlatformFMBase(),
fmFreqBase(f),

View File

@ -21,6 +21,8 @@
#define _FMSHARED_BASE_H
#include "../dispatch.h"
#include "../instrument.h"
#include "../macroInt.h"
#include <deque>
#define KVS(x,y) ((chan[x].state.op[y].kvs==2 && isOutput[chan[x].state.alg][y]) || chan[x].state.op[y].kvs==1)
@ -46,6 +48,38 @@ class DivPlatformFMBase: public DivDispatch {
0,2,1,3
};
struct FMChannel: public SharedChannelFreq, public SharedChannelVolume<int> {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int portaPauseFreq;
unsigned char opMask;
signed char konCycles;
bool hardReset, opMaskChanged;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
FMChannel():
SharedChannelFreq(),
SharedChannelVolume<int>(0),
freqH(0),
freqL(0),
portaPauseFreq(0),
opMask(15),
konCycles(0),
hardReset(false),
opMaskChanged(false) {}
};
struct FMChannelStereo: public FMChannel {
unsigned char pan;
FMChannelStereo():
FMChannel(),
pan(3) {}
};
struct QueuedWrite {
unsigned short addr;
unsigned char val;
@ -89,6 +123,8 @@ class DivPlatformFMBase: public DivDispatch {
}
}
friend void putDispatchChan(void*,int,int);
DivPlatformFMBase():
DivDispatch(),
lastBusy(0),

View File

@ -27,12 +27,12 @@
#include <queue>
class DivPlatformGB: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, released, softEnv, killIt;
bool sweepChanged, released, softEnv, killIt;
bool soManyHacksToMakeItDefleCompatible;
signed char vol, outVol, wave, lastKill;
signed short wave;
signed char lastKill;
unsigned char envVol, envDir, envLen, soundLen;
unsigned short hwSeqPos;
short hwSeqDelay;
@ -42,27 +42,15 @@ class DivPlatformGB: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
duty(0),
sweep(0),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
released(false),
softEnv(false),
killIt(false),
soManyHacksToMakeItDefleCompatible(false),
vol(15),
outVol(15),
wave(-1),
lastKill(0),
envVol(0),

View File

@ -39,16 +39,8 @@ class DivPlatformGenesis: public DivPlatformOPN {
0, 1, 2, 4, 5, 6
};
struct Channel {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note;
int ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, hardReset, opMaskChanged;
int vol, outVol;
unsigned char pan, opMask;
struct Channel: public FMChannelStereo {
bool furnaceDac;
bool dacMode;
int dacPeriod;
int dacRate;
@ -59,34 +51,9 @@ class DivPlatformGenesis: public DivPlatformOPN {
bool dacDirection;
unsigned char sampleBank;
signed char dacOutput;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
FMChannelStereo(),
furnaceDac(false),
inPorta(false),
hardReset(false),
opMaskChanged(false),
vol(0),
outVol(0),
pan(3),
opMask(15),
dacMode(false),
dacPeriod(0),
dacRate(0),
@ -123,6 +90,8 @@ class DivPlatformGenesis: public DivPlatformOPN {
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);
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
void fillStream(std::vector<DivDelayedWrite>& stream, int sRate, size_t len);

View File

@ -709,7 +709,7 @@ void DivPlatformGenesisExt::reset() {
DivPlatformGenesis::reset();
for (int i=0; i<4; i++) {
opChan[i]=DivPlatformGenesisExt::OpChannel();
opChan[i]=DivPlatformOPN::OPNOpChannelStereo();
opChan[i].std.setEngine(parent);
opChan[i].vol=127;
opChan[i].outVol=127;

View File

@ -22,41 +22,7 @@
#include "genesis.h"
class DivPlatformGenesisExt: public DivPlatformGenesis {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins, note;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, mask;
int vol, outVol;
unsigned char pan;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
OpChannel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
ins(-1),
note(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
mask(true),
vol(0),
outVol(0),
pan(3) {}
};
OpChannel opChan[4];
OPNOpChannelStereo opChan[4];
bool isOpMuted[4];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);

View File

@ -27,58 +27,46 @@
class DivPlatformLynx: public DivDispatch {
struct MikeyFreqDiv {
uint8_t clockDivider;
uint8_t backup;
unsigned char clockDivider;
unsigned char backup;
MikeyFreqDiv(int frequency);
};
struct MikeyDuty {
uint8_t int_feedback7;
uint8_t feedback;
unsigned char int_feedback7;
unsigned char feedback;
MikeyDuty(int duty);
};
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
DivMacroInt std;
MikeyFreqDiv fd;
MikeyDuty duty;
int baseFreq, pitch, pitch2, note, actualNote, lfsr, ins, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq;
int actualNote, lfsr, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, pcm;
signed char vol, outVol;
bool pcm;
int macroVolMul;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
SharedChannelFreq(),
SharedChannelVolume<signed char>(127),
std(),
fd(0),
duty(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
actualNote(0),
lfsr(-1),
ins(-1),
sample(-1),
samplePos(0),
sampleAccum(0),
sampleBaseFreq(0),
sampleFreq(0),
pan(0xff),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
pcm(false),
vol(127),
outVol(127),
macroVolMul(127) {}
};
Channel chan[4];

View File

@ -24,36 +24,24 @@
#include "../macroInt.h"
class DivPlatformMMC5: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, prevFreq, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int prevFreq;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
bool sweepChanged, furnaceDac;
signed char wave;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
prevFreq(65535),
note(0),
ins(-1),
duty(0),
sweep(8),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
furnaceDac(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[5];

View File

@ -26,32 +26,17 @@
#include "sound/oki/msm5232.h"
class DivPlatformMSM5232: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise;
signed char vol, outVol;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
bool noise;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
vol(127),
outVol(127) {}
SharedChannelFreq(),
SharedChannelVolume<signed char>(127),
noise(false) {}
};
Channel chan[8];
DivDispatchOscBuffer* oscBuf[8];

View File

@ -156,7 +156,6 @@ int DivPlatformMSM6258::dispatch(DivCommand c) {
//DivSample* s=parent->getSample(chan[c.chan].sample);
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;

View File

@ -26,44 +26,18 @@
class DivPlatformMSM6258: public DivDispatch {
protected:
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
int vol, outVol;
struct Channel: public SharedChannel, public SharedChannelVolume<int> {
bool furnacePCM;
int sample;
unsigned char pan;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
note(0),
ins(-1),
psgMode(1),
autoEnvNum(0),
autoEnvDen(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
SharedChannel(),
SharedChannelVolume<int>(8),
furnacePCM(false),
hardReset(false),
vol(0),
outVol(15),
sample(-1),
pan(3) {}
};

View File

@ -144,7 +144,6 @@ int DivPlatformMSM6295::dispatch(DivCommand c) {
//DivSample* s=parent->getSample(chan[c.chan].sample);
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
}
chan[c.chan].active=true;
chan[c.chan].keyOn=true;

View File

@ -26,28 +26,17 @@
class DivPlatformMSM6295: public DivDispatch, public vgsound_emu_mem_intf {
protected:
struct Channel {
int note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, furnacePCM, hardReset;
int vol, outVol;
struct Channel: public SharedChannel, public SharedChannelVolume<int> {
bool furnacePCM;
int sample;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
}
Channel():
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
SharedChannel(),
SharedChannelVolume<int>(8),
furnacePCM(false),
hardReset(false),
vol(8),
outVol(8),
sample(-1) {}
};
Channel chan[4];

View File

@ -27,14 +27,14 @@
#include "vgsound_emu/src/n163/n163.hpp"
class DivPlatformN163: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
short ins, wave, wavePos, waveLen;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
signed char resVol;
short wave, wavePos, waveLen;
unsigned char waveMode;
short loadWave, loadPos, loadLen;
unsigned char loadMode;
bool active, insChanged, freqChanged, volumeChanged, waveChanged, waveUpdated, keyOn, keyOff, inPorta;
signed char vol, outVol, resVol;
bool volumeChanged;
bool waveChanged, waveUpdated;
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -42,12 +42,9 @@ class DivPlatformN163: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
resVol(15),
wave(-1),
wavePos(0),
waveLen(0),
@ -56,18 +53,9 @@ class DivPlatformN163: public DivDispatch {
loadPos(0),
loadLen(0),
loadMode(0),
active(false),
insChanged(true),
freqChanged(false),
volumeChanged(false),
waveChanged(false),
waveUpdated(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15),
resVol(15) {}
waveUpdated(false) {}
};
Channel chan[8];
DivDispatchOscBuffer* oscBuf[8];

View File

@ -27,12 +27,10 @@
#include "sound/namco.h"
class DivPlatformNamcoWSG: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise;
signed char vol, outVol, wave;
bool noise;
signed char wave;
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -40,22 +38,10 @@ class DivPlatformNamcoWSG: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[8];

View File

@ -26,38 +26,26 @@
#include "sound/nes_nsfplay/nes_apu.h"
class DivPlatformNES: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, prevFreq, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int prevFreq;
unsigned char duty, sweep, envMode, len;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
bool sweepChanged, furnaceDac;
signed char wave;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
prevFreq(65535),
note(0),
ins(-1),
duty(0),
sweep(8),
envMode(3),
len(0x1f),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
furnaceDac(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[5];

View File

@ -36,13 +36,12 @@ class DivOPLAInterface: public ymfm::ymfm_interface {
class DivPlatformOPL: public DivDispatch {
protected:
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note, ins, sample, fixedFreq;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnacePCM, inPorta, fourOp, hardReset;
int vol, outVol;
int sample, fixedFreq;
bool furnacePCM, fourOp, hardReset;
unsigned char pan;
int macroVolMul;
void macroInit(DivInstrument* which) {
@ -50,27 +49,15 @@ class DivPlatformOPL: public DivDispatch {
pitch2=0;
}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(0),
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
sample(-1),
fixedFreq(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
furnacePCM(false),
inPorta(false),
fourOp(false),
hardReset(false),
vol(0),
pan(3),
macroVolMul(64) {
state.ops=2;

View File

@ -29,37 +29,24 @@ extern "C" {
class DivPlatformOPLL: public DivDispatch {
protected:
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note, ins, fixedFreq;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
int vol, outVol;
int fixedFreq;
bool furnaceDac;
unsigned char pan;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(0),
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
fixedFreq(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
furnaceDac(false),
inPorta(false),
vol(0),
pan(3) {}
};
Channel chan[11];

View File

@ -27,14 +27,14 @@
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, antiClickPeriodCount, antiClickWavePos;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int antiClickPeriodCount, antiClickWavePos;
int dacPeriod, dacRate, dacOut;
unsigned int dacPos;
int dacSample, ins;
int dacSample;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac, deferredWaveUpdate;
signed char vol, outVol, wave;
bool noise, pcm, furnaceDac, deferredWaveUpdate;
signed short wave;
int macroVolMul;
DivMacroInt std;
DivWaveSynth ws;
@ -43,11 +43,8 @@ class DivPlatformPCE: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(31),
antiClickPeriodCount(0),
antiClickWavePos(0),
dacPeriod(0),
@ -55,20 +52,11 @@ class DivPlatformPCE: public DivDispatch {
dacOut(0),
dacPos(0),
dacSample(-1),
ins(-1),
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
pcm(false),
furnaceDac(false),
deferredWaveUpdate(false),
vol(31),
outVol(31),
wave(-1),
macroVolMul(31) {}
};

View File

@ -26,17 +26,15 @@
#include "../waveSynth.h"
class DivPlatformPCMDAC: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
struct Channel: public SharedChannelFreq {
bool audDir;
unsigned int audLoc;
unsigned short audLen;
int audPos;
int audSub;
int sample, wave, ins;
int note;
int sample, wave;
int panL, panR;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos;
bool useWave, setPos;
int vol, envVol;
DivMacroInt std;
DivWaveSynth ws;
@ -45,10 +43,7 @@ class DivPlatformPCMDAC: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
audDir(false),
audLoc(0),
audLen(0),
@ -56,16 +51,8 @@ class DivPlatformPCMDAC: public DivDispatch {
audSub(0),
sample(-1),
wave(-1),
ins(-1),
note(0),
panL(255),
panR(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
useWave(false),
setPos(false),
vol(255),

View File

@ -28,36 +28,15 @@
#include <condition_variable>
class DivPlatformPCSpeaker: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
duty(0),
sweep(8),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
furnaceDac(false),
vol(15),
outVol(15),
wave(-1) {}
SharedChannelFreq(),
SharedChannelVolume<signed char>(15) {}
};
Channel chan[1];
DivDispatchOscBuffer* oscBuf;

View File

@ -24,10 +24,9 @@
#include "../macroInt.h"
class DivPlatformPET: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, enable;
int vol, outVol, wave;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
bool enable;
int wave;
unsigned char sreg;
int cnt;
short out;
@ -37,21 +36,9 @@ class DivPlatformPET: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
SharedChannelFreq(),
SharedChannelVolume<int>(1),
enable(false),
vol(1),
outVol(1),
wave(0b00001111),
sreg(0),
cnt(0),

View File

@ -24,36 +24,15 @@
#include "../macroInt.h"
class DivPlatformPong: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
duty(0),
sweep(8),
active(false),
insChanged(true),
freqChanged(false),
sweepChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
furnaceDac(false),
vol(1),
outVol(1),
wave(-1) {}
SharedChannelFreq(),
SharedChannelVolume<signed char>(1) {}
};
Channel chan[1];
DivDispatchOscBuffer* oscBuf;

View File

@ -26,41 +26,27 @@
#include "sound/qsound.h"
class DivPlatformQSound: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
int sample, wave, ins;
int note;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
int resVol;
int sample, wave;
int panning;
int echo;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, surround, isNewQSound;
int vol, outVol, resVol;
bool useWave, surround, isNewQSound;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<int>(255),
resVol(4095),
sample(-1),
ins(-1),
note(0),
panning(0x10),
echo(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
useWave(false),
surround(true),
isNewQSound(false),
vol(255),
outVol(255),
resVol(4096) {}
isNewQSound(false) {}
};
Channel chan[19];
DivDispatchOscBuffer* oscBuf[19];

View File

@ -26,14 +26,11 @@
#include "sound/rf5c68.h"
class DivPlatformRF5C68: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned int audPos;
int sample, wave, ins;
int note;
int sample, wave;
int panning;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, setPos;
int vol, outVol;
bool setPos;
int macroVolMul;
DivMacroInt std;
void macroInit(DivInstrument* which) {
@ -41,24 +38,12 @@ class DivPlatformRF5C68: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<int>(255),
audPos(0),
sample(-1),
ins(-1),
note(0),
panning(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
setPos(false),
vol(255),
outVol(255),
macroVolMul(64) {}
};
Channel chan[8];

View File

@ -26,20 +26,22 @@
class DivPlatformSAA1099: public DivDispatch {
protected:
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note, ins;
unsigned char psgMode;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;
unsigned char pan;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), pitch2(0), note(0), ins(-1), psgMode(1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), inPorta(false), vol(0), outVol(15), pan(255) {}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(15),
freqH(0),
freqL(0),
psgMode(1),
pan(255) {}
};
Channel chan[6];
DivDispatchOscBuffer* oscBuf[6];

View File

@ -27,11 +27,10 @@
#include "vgsound_emu/src/scc/scc.hpp"
class DivPlatformSCC: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
bool active, insChanged, freqChanged, freqInit, inPorta;
signed char vol, outVol, wave;
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
bool freqInit;
signed short wave;
signed char waveROM[32] = {0}; // 8 bit signed waveform
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -39,19 +38,9 @@ class DivPlatformSCC: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
freqInit(false),
inPorta(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[5];

View File

@ -26,11 +26,9 @@
class DivPlatformSegaPCM: public DivDispatch {
protected:
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
DivMacroInt std;
int freq, baseFreq, pitch, pitch2, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, isNewSegaPCM;
int vol, outVol;
bool furnacePCM, isNewSegaPCM;
unsigned char chVolL, chVolR;
unsigned char chPanL, chPanR;
int macroVolMul;
@ -47,23 +45,10 @@ class DivPlatformSegaPCM: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
portaPause(false),
SharedChannelFreq(),
SharedChannelVolume<int>(127),
furnacePCM(false),
isNewSegaPCM(false),
vol(0),
outVol(0),
chVolL(127),
chVolR(127),
chPanL(127),

View File

@ -29,32 +29,19 @@ extern "C" {
#include <queue>
class DivPlatformSMS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, actualNote, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, writeVol;
signed char vol, outVol;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int actualNote;
bool writeVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
actualNote(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
writeVol(false),
vol(15),
outVol(15) {}
writeVol(false) {}
};
Channel chan[4];
DivDispatchOscBuffer* oscBuf[4];

View File

@ -27,14 +27,11 @@
#include "sound/snes/SPC_DSP.h"
class DivPlatformSNES: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned int audPos;
int sample, wave, ins;
int note;
int sample, wave;
int panL, panR;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, noise, echo, pitchMod, invertL, invertR, shallWriteVol, shallWriteEnv;
int vol, outVol;
bool useWave, setPos, noise, echo, pitchMod, invertL, invertR, shallWriteVol, shallWriteEnv;
int wtLen;
DivInstrumentSNES state;
DivMacroInt std;
@ -44,23 +41,13 @@ class DivPlatformSNES: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<int>(127),
audPos(0),
sample(-1),
wave(-1),
ins(-1),
note(0),
panL(127),
panR(127),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
useWave(false),
setPos(false),
noise(false),
@ -70,8 +57,6 @@ class DivPlatformSNES: public DivDispatch {
invertR(false),
shallWriteVol(false),
shallWriteEnv(false),
vol(127),
outVol(127),
wtLen(16) {}
};
Channel chan[8];

View File

@ -26,30 +26,25 @@
#include "sound/su.h"
class DivPlatformSoundUnit: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins, cutoff, baseCutoff, res, control, hasOffset;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int cutoff, baseCutoff, res, control, hasOffset;
signed char pan;
unsigned char duty;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, phaseReset, filterPhaseReset, switchRoles;
bool noise, pcm, phaseReset, filterPhaseReset, switchRoles;
bool pcmLoop, timerSync, freqSweep, volSweep, cutSweep;
unsigned short freqSweepP, volSweepP, cutSweepP;
unsigned char freqSweepB, volSweepB, cutSweepB;
unsigned char freqSweepV, volSweepV, cutSweepV;
unsigned short syncTimer;
signed char vol, outVol, wave;
signed short wave;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(127),
cutoff(16383),
baseCutoff(16380),
res(0),
@ -57,12 +52,6 @@ class DivPlatformSoundUnit: public DivDispatch {
hasOffset(0),
pan(0),
duty(63),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
pcm(false),
phaseReset(false),
@ -83,8 +72,6 @@ class DivPlatformSoundUnit: public DivDispatch {
volSweepV(0),
cutSweepV(0),
syncTimer(0),
vol(127),
outVol(127),
wave(0) {}
};
Channel chan[8];

View File

@ -27,11 +27,9 @@
#include <queue>
class DivPlatformSwan: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
int wave;
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -39,21 +37,9 @@ class DivPlatformSwan: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<int>(15),
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[4];

View File

@ -26,35 +26,19 @@
#include "sound/t6w28/T6W28_Apu.h"
class DivPlatformT6W28: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned char panL, panR, duty;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
panL(15),
panR(15),
duty(7),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15) {}
duty(7) {}
};
Channel chan[4];
DivDispatchOscBuffer* oscBuf[4];

View File

@ -26,18 +26,17 @@
class DivPlatformTIA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned char shape;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel(): freq(0), baseFreq(0), pitch(0), pitch2(0), note(0), ins(-1), shape(4), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), inPorta(false), vol(0), outVol(15) {}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(15),
shape(4) {}
};
Channel chan[2];
DivDispatchOscBuffer* oscBuf[2];

View File

@ -20,8 +20,6 @@
#ifndef _TX81Z_H
#define _TX81Z_H
#include "fmshared_OPM.h"
#include "../macroInt.h"
#include "../instrument.h"
#include <queue>
#include "sound/ymfm/ymfm_opz.h"
@ -35,41 +33,12 @@ class DivPlatformTX81Z: public DivPlatformOPM {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
};
struct Channel {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
int vol, outVol;
struct Channel: public FMChannel {
unsigned char chVolL, chVolR;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
portaPause(false),
furnacePCM(false),
hardReset(false),
vol(0),
outVol(0),
chVolL(127),
chVolR(127) {}
FMChannel(),
chVolL(1),
chVolR(1) {}
};
Channel chan[8];
DivDispatchOscBuffer* oscBuf[8];
@ -87,10 +56,8 @@ class DivPlatformTX81Z: public DivPlatformOPM {
int octave(int freq);
int toFreq(int freq);
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -27,12 +27,10 @@
#include "sound/vsu.h"
class DivPlatformVB: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned char pan, envLow, envHigh;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, deferredWaveUpdate;
signed char vol, outVol, wave;
bool noise, deferredWaveUpdate;
signed short wave;
DivMacroInt std;
DivWaveSynth ws;
void macroInit(DivInstrument* which) {
@ -40,25 +38,13 @@ class DivPlatformVB: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
pan(255),
envLow(0),
envHigh(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
deferredWaveUpdate(false),
vol(15),
outVol(15),
wave(-1) {}
};
Channel chan[6];

View File

@ -28,11 +28,8 @@ struct VERA_PCM;
class DivPlatformVERA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned char pan;
bool active, freqChanged, inPorta;
int vol, outVol;
unsigned accum;
int noiseval;
DivMacroInt std;
@ -50,7 +47,13 @@ class DivPlatformVERA: public DivDispatch {
std.init(which);
pitch2=0;
}
Channel(): freq(0), baseFreq(0), pitch(0), pitch2(0), note(0), ins(-1), pan(0), active(false), freqChanged(false), inPorta(false), vol(0), outVol(0), accum(0), noiseval(0) {}
Channel():
SharedChannelFreq(),
SharedChannelVolume<int>(0),
pan(0),
accum(0),
noiseval(0),
pcm(PCMChannel()) {}
};
Channel chan[17];
DivDispatchOscBuffer* oscBuf[17];

View File

@ -26,32 +26,16 @@
#include <queue>
class DivPlatformVIC20: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave, waveWriteCycle;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
int wave, waveWriteCycle;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(15),
outVol(15),
SharedChannelFreq(),
SharedChannelVolume<int>(15),
wave(0),
waveWriteCycle(-1) {}
};

View File

@ -27,42 +27,28 @@
class DivPlatformVRC6: public DivDispatch, public vrcvi_intf {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
int dacPeriod, dacRate, dacOut;
unsigned int dacPos;
int dacSample, ins;
int dacSample;
unsigned char duty;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, pcm, furnaceDac;
signed char vol, outVol;
bool pcm, furnaceDac;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
SharedChannelFreq(),
SharedChannelVolume<signed char>(15),
dacPeriod(0),
dacRate(0),
dacOut(0),
dacPos(0),
dacSample(-1),
ins(-1),
duty(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
pcm(false),
furnaceDac(false),
vol(15),
outVol(15) {}
furnaceDac(false) {}
};
Channel chan[3];
DivDispatchOscBuffer* oscBuf[3];

View File

@ -27,7 +27,7 @@
#include "vgsound_emu/src/x1_010/x1_010.hpp"
class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
struct Channel {
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
struct Envelope {
struct EnvFlag {
unsigned char envEnable : 1;
@ -68,11 +68,11 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
slide(0),
slidefrac(0) {}
};
int freq, baseFreq, fixedFreq, pitch, pitch2, note;
int wave, sample, ins;
int fixedFreq;
int wave, sample;
unsigned char pan, autoEnvNum, autoEnvDen;
bool active, insChanged, envChanged, freqChanged, keyOn, keyOff, inPorta, furnacePCM, pcm;
int vol, outVol, lvol, rvol;
bool envChanged, furnacePCM, pcm;
int lvol, rvol;
int macroVolMul;
unsigned char waveBank;
unsigned int bankSlot;
@ -80,26 +80,34 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
DivMacroInt std;
DivWaveSynth ws;
void reset() {
freq = baseFreq = pitch = pitch2 = note = 0;
wave = sample = ins = -1;
pan = 255;
autoEnvNum = autoEnvDen = 0;
active = false;
insChanged = envChanged = freqChanged = true;
keyOn = keyOff = inPorta = furnacePCM = pcm = false;
vol = outVol = lvol = rvol = 15;
waveBank = 0;
freq=baseFreq=pitch=pitch2=note=0;
wave=sample=ins=-1;
pan=255;
autoEnvNum=autoEnvDen=0;
active=false;
insChanged=envChanged=freqChanged=true;
keyOn=keyOff=inPorta=furnacePCM=pcm=false;
vol=outVol=lvol=rvol=15;
waveBank=0;
}
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0), baseFreq(0), fixedFreq(0), pitch(0), pitch2(0), note(0),
wave(-1), sample(-1), ins(-1),
pan(255), autoEnvNum(0), autoEnvDen(0),
active(false), insChanged(true), envChanged(true), freqChanged(false), keyOn(false), keyOff(false), inPorta(false), furnacePCM(false), pcm(false),
vol(15), outVol(15), lvol(15), rvol(15),
SharedChannelFreq(),
SharedChannelVolume<int>(15),
fixedFreq(0),
wave(-1),
sample(-1),
pan(255),
autoEnvNum(0),
autoEnvDen(0),
envChanged(true),
furnacePCM(false),
pcm(false),
lvol(15),
rvol(15),
macroVolMul(15),
waveBank(0),
bankSlot(0) {}

View File

@ -851,7 +851,7 @@ void DivPlatformYM2203::reset() {
}
fm->reset();
for (int i=0; i<6; i++) {
chan[i]=DivPlatformYM2203::Channel();
chan[i]=DivPlatformOPN::OPNChannel();
chan[i].std.setEngine(parent);
}
for (int i=0; i<3; i++) {

View File

@ -20,7 +20,6 @@
#ifndef _YM2203_H
#define _YM2203_H
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "sound/ymfm/ymfm_opn.h"
#include "ay.h"
@ -39,49 +38,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
0, 1, 2
};
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen, opMask;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset, opMaskChanged;
int vol, outVol;
int sample;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
note(0),
ins(-1),
psgMode(1),
autoEnvNum(0),
autoEnvDen(0),
opMask(15),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
furnacePCM(false),
hardReset(false),
opMaskChanged(false),
vol(0),
outVol(15),
sample(-1) {}
};
Channel chan[6];
OPNChannel chan[6];
DivDispatchOscBuffer* oscBuf[6];
bool isMuted[6];
ymfm::ym2203* fm;
@ -93,10 +50,8 @@ class DivPlatformYM2203: public DivPlatformOPN {
bool extMode, noExtMacros;
unsigned char prescale;
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -483,7 +483,7 @@ void DivPlatformYM2203Ext::reset() {
DivPlatformYM2203::reset();
for (int i=0; i<4; i++) {
opChan[i]=DivPlatformYM2203Ext::OpChannel();
opChan[i]=DivPlatformOPN::OPNOpChannel();
opChan[i].vol=127;
}

View File

@ -22,37 +22,9 @@
#include "ym2203.h"
class DivPlatformYM2203Ext: public DivPlatformYM2203 {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, mask;
int vol;
// UGLY
OpChannel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
mask(true),
vol(0) {}
};
OpChannel opChan[4];
OPNOpChannel opChan[4];
bool isOpMuted[4];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
int dispatch(DivCommand c);
void* getChanState(int chan);

View File

@ -1245,7 +1245,7 @@ void DivPlatformYM2608::reset() {
}
fm->reset();
for (int i=0; i<16; i++) {
chan[i]=DivPlatformYM2608::Channel();
chan[i]=DivPlatformOPN::OPNChannelStereo();
chan[i].std.setEngine(parent);
}
for (int i=0; i<6; i++) {

View File

@ -20,7 +20,6 @@
#ifndef _YM2608_H
#define _YM2608_H
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "sound/ymfm/ymfm_opn.h"
#include "ay.h"
@ -44,53 +43,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
0, 1, 2, 4, 5, 6
};
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen, opMask;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset, opMaskChanged;
int vol, outVol;
int sample;
unsigned char pan;
int macroVolMul;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
note(0),
ins(-1),
psgMode(1),
autoEnvNum(0),
autoEnvDen(0),
opMask(15),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
furnacePCM(false),
hardReset(false),
opMaskChanged(false),
vol(0),
outVol(15),
sample(-1),
pan(3),
macroVolMul(255) {}
};
Channel chan[16];
OPNChannelStereo chan[16];
DivDispatchOscBuffer* oscBuf[16];
bool isMuted[16];
ymfm::ym2608* fm;
@ -112,9 +65,8 @@ class DivPlatformYM2608: public DivPlatformOPN {
double NOTE_OPNB(int ch, int note);
double NOTE_ADPCMB(int note);
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -519,7 +519,7 @@ void DivPlatformYM2608Ext::reset() {
DivPlatformYM2608::reset();
for (int i=0; i<4; i++) {
opChan[i]=DivPlatformYM2608Ext::OpChannel();
opChan[i]=DivPlatformOPN::OPNOpChannelStereo();
opChan[i].vol=127;
}

View File

@ -22,39 +22,9 @@
#include "ym2608.h"
class DivPlatformYM2608Ext: public DivPlatformYM2608 {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, mask;
int vol;
unsigned char pan;
// UGLY
OpChannel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
mask(true),
vol(0),
pan(3) {}
};
OpChannel opChan[4];
OPNOpChannelStereo opChan[4];
bool isOpMuted[4];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
int dispatch(DivCommand c);
void* getChanState(int chan);

View File

@ -1213,7 +1213,7 @@ void DivPlatformYM2610::reset() {
}
fm->reset();
for (int i=0; i<14; i++) {
chan[i]=DivPlatformYM2610::Channel();
chan[i]=DivPlatformOPN::OPNChannelStereo();
chan[i].std.setEngine(parent);
}
for (int i=0; i<psgChanOffs; i++) {

View File

@ -36,8 +36,6 @@ class DivPlatformYM2610: public DivPlatformYM2610Base<14> {
};
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -1276,7 +1276,7 @@ void DivPlatformYM2610B::reset() {
}
fm->reset();
for (int i=0; i<16; i++) {
chan[i]=DivPlatformYM2610B::Channel();
chan[i]=DivPlatformOPN::OPNChannelStereo();
chan[i].std.setEngine(parent);
}
for (int i=0; i<psgChanOffs; i++) {

View File

@ -32,8 +32,6 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base<16> {
};
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);

View File

@ -510,7 +510,7 @@ void DivPlatformYM2610BExt::reset() {
DivPlatformYM2610B::reset();
for (int i=0; i<4; i++) {
opChan[i]=DivPlatformYM2610BExt::OpChannel();
opChan[i]=DivPlatformOPN::OPNOpChannelStereo();
opChan[i].vol=127;
}

View File

@ -22,10 +22,9 @@
#include "ym2610b.h"
class DivPlatformYM2610BExt: public DivPlatformYM2610B {
DivPlatformYM2610Base::OpChannel opChan[4];
OPNOpChannelStereo opChan[4];
bool isOpMuted[4];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
int dispatch(DivCommand c);
void* getChanState(int chan);

View File

@ -510,7 +510,7 @@ void DivPlatformYM2610Ext::reset() {
DivPlatformYM2610::reset();
for (int i=0; i<4; i++) {
opChan[i]=DivPlatformYM2610Ext::OpChannel();
opChan[i]=DivPlatformOPN::OPNOpChannelStereo();
opChan[i].vol=127;
}

View File

@ -22,10 +22,9 @@
#include "ym2610.h"
class DivPlatformYM2610Ext: public DivPlatformYM2610 {
DivPlatformYM2610Base::OpChannel opChan[4];
OPNOpChannelStereo opChan[4];
bool isOpMuted[4];
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:
int dispatch(DivCommand c);
void* getChanState(int chan);

View File

@ -20,7 +20,6 @@
#ifndef _YM2610SHARED_H
#define _YM2610SHARED_H
#include "fmshared_OPN.h"
#include "../macroInt.h"
#include "../engine.h"
#include "../../ta-log.h"
#include "ay.h"
@ -46,83 +45,7 @@ class DivYM2610Interface: public ymfm::ymfm_interface {
template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
protected:
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset, opMaskChanged;
int vol, outVol;
int sample;
unsigned char pan, opMask;
int macroVolMul;
DivMacroInt std;
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
note(0),
ins(-1),
psgMode(1),
autoEnvNum(0),
autoEnvDen(0),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
furnacePCM(false),
hardReset(false),
opMaskChanged(false),
vol(0),
outVol(15),
sample(-1),
pan(3),
opMask(15),
macroVolMul(255) {}
};
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, pitch2, portaPauseFreq, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, mask;
int vol;
unsigned char pan;
// UGLY
OpChannel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
portaPauseFreq(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
inPorta(false),
mask(true),
vol(0),
pan(3) {}
};
Channel chan[ChanNum];
OPNChannelStereo chan[ChanNum];
DivDispatchOscBuffer* oscBuf[ChanNum];
bool isMuted[ChanNum];

View File

@ -26,14 +26,11 @@
#include "sound/ymz280b.h"
class DivPlatformYMZ280B: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<int> {
unsigned int audPos;
int sample, wave, ins;
int note;
int sample, wave;
int panning;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, setPos, isNewYMZ;
int vol, outVol;
bool setPos, isNewYMZ;
int macroVolMul;
DivMacroInt std;
void macroInit(DivInstrument* which) {
@ -41,25 +38,13 @@ class DivPlatformYMZ280B: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
SharedChannelFreq(),
SharedChannelVolume<int>(255),
audPos(0),
sample(-1),
ins(-1),
note(0),
panning(8),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
setPos(false),
isNewYMZ(false),
vol(255),
outVol(255),
macroVolMul(64) {}
};
Channel chan[8];

View File

@ -25,11 +25,7 @@
#include "../macroInt.h"
class DivPlatformZXBeeper: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, pitch2, note;
int ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
struct Channel: public SharedChannelFreq, public SharedChannelVolume<signed char> {
unsigned short sPosition;
unsigned char duty;
DivMacroInt std;
@ -38,20 +34,8 @@ class DivPlatformZXBeeper: public DivDispatch {
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
pitch2(0),
note(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
vol(1),
outVol(1),
SharedChannelFreq(),
SharedChannelVolume<signed char>(1),
sPosition(0),
duty(64) {}
};

View File

@ -19,6 +19,7 @@
#include "debug.h"
#include "imgui.h"
#include "../engine/platform/fmsharedbase.h"
#include "../engine/platform/genesis.h"
#include "../engine/platform/genesisext.h"
#include "../engine/platform/sms.h"
@ -160,7 +161,7 @@
ImGui::TextColored(ch->dacDirection?colorOn:colorOff,">> DACDirection");
#define GENESIS_OPCHAN_DEBUG \
DivPlatformGenesisExt::OpChannel* ch=(DivPlatformGenesisExt::OpChannel*)data; \
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data; \
ImGui::Text("> YM2612 (per operator)"); \
ImGui::Text("- freqHL: %.2x%.2x",ch->freqH,ch->freqL); \
ImGui::Text("* freq: %d",ch->freq); \
@ -170,6 +171,7 @@
ImGui::Text("- portaPauseFreq: %d",ch->portaPauseFreq); \
ImGui::Text("- ins: %d",ch->ins); \
ImGui::Text("- vol: %.2x",ch->vol); \
ImGui::Text("- outVol: %.2x",ch->outVol); \
ImGui::Text("- pan: %x",ch->pan); \
ImGui::TextColored(ch->active?colorOn:colorOff,">> Active"); \
ImGui::TextColored(ch->insChanged?colorOn:colorOff,">> InsChanged"); \
@ -198,7 +200,7 @@
ImGui::TextColored(ch->keyOff?colorOn:colorOff,">> KeyOff");
#define OPN_CHAN_DEBUG \
DivPlatformYM2203::Channel* ch=(DivPlatformYM2203::Channel*)data; \
DivPlatformOPN::OPNChannel* ch=(DivPlatformOPN::OPNChannel*)data; \
ImGui::Text("> YM2203"); \
ImGui::Text("- freqHL: %.2x%.2x",ch->freqH,ch->freqL); \
ImGui::Text("* freq: %d",ch->freq); \
@ -228,7 +230,7 @@
ImGui::TextColored(ch->furnacePCM?colorOn:colorOff,">> FurnacePCM");
#define OPN_OPCHAN_DEBUG \
DivPlatformYM2203Ext::OpChannel* ch=(DivPlatformYM2203Ext::OpChannel*)data; \
DivPlatformOPN::OPNOpChannel* ch=(DivPlatformOPN::OPNOpChannel*)data; \
ImGui::Text("> YM2203 (per operator)"); \
ImGui::Text("- freqHL: %.2x%.2x",ch->freqH,ch->freqL); \
ImGui::Text("* freq: %d",ch->freq); \
@ -238,6 +240,7 @@
ImGui::Text("- portaPauseFreq: %d",ch->portaPauseFreq); \
ImGui::Text("- ins: %d",ch->ins); \
ImGui::Text("- vol: %.2x",ch->vol); \
ImGui::Text("- outVol: %.2x",ch->outVol); \
ImGui::TextColored(ch->active?colorOn:colorOff,">> Active"); \
ImGui::TextColored(ch->insChanged?colorOn:colorOff,">> InsChanged"); \
ImGui::TextColored(ch->freqChanged?colorOn:colorOff,">> FreqChanged"); \
@ -286,6 +289,7 @@
ImGui::Text("- portaPauseFreq: %d",ch->portaPauseFreq); \
ImGui::Text("- ins: %d",ch->ins); \
ImGui::Text("- vol: %.2x",ch->vol); \
ImGui::Text("- outVol: %.2x",ch->outVol); \
ImGui::Text("- pan: %x",ch->pan); \
ImGui::TextColored(ch->active?colorOn:colorOff,">> Active"); \
ImGui::TextColored(ch->insChanged?colorOn:colorOff,">> InsChanged"); \
@ -574,7 +578,9 @@ void putDispatchChan(void* data, int chanNum, int type) {
if (chanNum>8) {
SMS_CHAN_DEBUG;
} else if (chanNum>=2 && chanNum<=5) {
GENESIS_OPCHAN_DEBUG
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data;
ImGui::Text("> YM2612 (per operator)");
OPNB_OPCHAN_DEBUG;
} else {
GENESIS_CHAN_DEBUG;
}
@ -588,7 +594,9 @@ void putDispatchChan(void* data, int chanNum, int type) {
case DIV_SYSTEM_YM2612_EXT:
case DIV_SYSTEM_YM2612_FRAC_EXT: {
if (chanNum>=2 && chanNum<=5) {
GENESIS_OPCHAN_DEBUG
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data;
ImGui::Text("> YM2612 (per operator)");
OPNB_OPCHAN_DEBUG;
} else {
GENESIS_CHAN_DEBUG;
}
@ -611,18 +619,18 @@ void putDispatchChan(void* data, int chanNum, int type) {
break;
}
case DIV_SYSTEM_PC98: {
DivPlatformYM2608::Channel* ch=(DivPlatformYM2608::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2608");
OPNB_CHAN_DEBUG;
break;
}
case DIV_SYSTEM_PC98_EXT: {
if (chanNum>=2 && chanNum<=5) {
DivPlatformYM2608Ext::OpChannel* ch=(DivPlatformYM2608Ext::OpChannel*)data;
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data;
ImGui::Text("> YM2608 (per operator)");
OPNB_OPCHAN_DEBUG;
} else {
DivPlatformYM2608Ext::Channel* ch=(DivPlatformYM2608Ext::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2608");
OPNB_CHAN_DEBUG;
}
@ -630,13 +638,13 @@ void putDispatchChan(void* data, int chanNum, int type) {
}
case DIV_SYSTEM_YM2610:
case DIV_SYSTEM_YM2610_FULL: {
DivPlatformYM2610::Channel* ch=(DivPlatformYM2610::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2610");
OPNB_CHAN_DEBUG;
break;
}
case DIV_SYSTEM_YM2610B: {
DivPlatformYM2610B::Channel* ch=(DivPlatformYM2610B::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2610B");
OPNB_CHAN_DEBUG;
break;
@ -644,11 +652,11 @@ void putDispatchChan(void* data, int chanNum, int type) {
case DIV_SYSTEM_YM2610_EXT:
case DIV_SYSTEM_YM2610_FULL_EXT: {
if (chanNum>=1 && chanNum<=4) {
DivPlatformYM2610Ext::OpChannel* ch=(DivPlatformYM2610Ext::OpChannel*)data;
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data;
ImGui::Text("> YM2610 (per operator)");
OPNB_OPCHAN_DEBUG;
} else {
DivPlatformYM2610Ext::Channel* ch=(DivPlatformYM2610Ext::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2610");
OPNB_CHAN_DEBUG;
}
@ -656,11 +664,11 @@ void putDispatchChan(void* data, int chanNum, int type) {
}
case DIV_SYSTEM_YM2610B_EXT: {
if (chanNum>=2 && chanNum<=5) {
DivPlatformYM2610BExt::OpChannel* ch=(DivPlatformYM2610BExt::OpChannel*)data;
DivPlatformOPN::OPNOpChannelStereo* ch=(DivPlatformOPN::OPNOpChannelStereo*)data;
ImGui::Text("> YM2610B (per operator)");
OPNB_OPCHAN_DEBUG;
} else {
DivPlatformYM2610BExt::Channel* ch=(DivPlatformYM2610BExt::Channel*)data;
DivPlatformOPN::OPNChannelStereo* ch=(DivPlatformOPN::OPNChannelStereo*)data;
ImGui::Text("> YM2610B");
OPNB_CHAN_DEBUG;
}

View File

@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "../engine/chipUtils.h"
#include "gui.h"
#include "misc/cpp/imgui_stdlib.h"
#include <imgui.h>
@ -1575,19 +1576,19 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
if (supportsCustomRate) {
ImGui::Separator();
int customClock=flags.getInt("customClock",0);
bool usingCustomClock=customClock>=100000;
bool usingCustomClock=customClock>=MIN_CUSTOM_CLOCK;
if (ImGui::Checkbox("Custom clock rate",&usingCustomClock)) {
if (usingCustomClock) {
customClock=1000000;
customClock=MIN_CUSTOM_CLOCK;
} else {
customClock=0;
}
altered=true;
}
if (ImGui::InputInt("Hz",&customClock)) {
if (customClock<100000) customClock=0;
if (customClock>20000000) customClock=20000000;
if (customClock<MIN_CUSTOM_CLOCK) customClock=0;
if (customClock>MAX_CUSTOM_CLOCK) customClock=MAX_CUSTOM_CLOCK;
altered=true;
}