furnace/src/engine/platform/pce.h

115 lines
3.3 KiB
C
Raw Normal View History

2022-02-14 22:12:20 -05: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.
*/
#ifndef _PCE_H
#define _PCE_H
#include "../dispatch.h"
2021-06-07 03:49:43 -04:00
#include <queue>
#include "../macroInt.h"
#include "../waveSynth.h"
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel {
2022-04-28 01:50:09 -04:00
int freq, baseFreq, pitch, pitch2, note;
2021-12-14 12:33:26 -05:00
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;
DivWaveSynth ws;
2022-04-28 02:31:16 -04:00
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
Channel():
freq(0),
baseFreq(0),
pitch(0),
2022-04-28 01:50:09 -04:00
pitch2(0),
2022-01-18 16:55:32 -05:00
note(0),
2021-12-04 01:19:54 -05:00
dacPeriod(0),
dacRate(0),
dacPos(0),
dacSample(-1),
ins(-1),
2021-06-07 03:49:43 -04:00
pan(255),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
inPorta(false),
noise(false),
2021-06-09 00:16:29 -04:00
pcm(false),
furnaceDac(false),
2021-06-07 03:49:43 -04:00
vol(31),
2021-06-08 17:46:27 -04:00
outVol(31),
wave(-1) {}
};
2021-06-07 03:49:43 -04:00
Channel chan[6];
DivDispatchOscBuffer* oscBuf[6];
2021-12-18 03:25:42 -05:00
bool isMuted[6];
2021-06-07 03:49:43 -04:00
struct QueuedWrite {
unsigned char addr;
unsigned char val;
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
};
std::queue<QueuedWrite> writes;
unsigned char lastPan;
2022-01-12 22:14:20 -05:00
int cycles, curChan, delay;
int tempL[32];
int tempR[32];
2022-02-05 16:19:22 -05:00
unsigned char sampleBank, lfoMode, lfoSpeed;
PCE_PSG* pce;
unsigned char regPool[128];
2021-06-07 03:49:43 -04:00
void updateWave(int ch);
2022-01-27 00:29:16 -05:00
friend void putDispatchChan(void*,int,int);
public:
void acquire(short* bufL, short* bufR, size_t start, size_t len);
int dispatch(DivCommand c);
2022-01-27 00:29:16 -05:00
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
2021-12-11 13:14:38 -05:00
void reset();
void forceIns();
void tick(bool sysTick=true);
2021-12-18 03:25:42 -05:00
void muteChannel(int ch, bool mute);
bool isStereo();
2021-12-08 00:33:00 -05:00
bool keyOffAffectsArp(int ch);
2022-01-28 12:59:53 -05:00
void setFlags(unsigned int flags);
2022-01-18 00:25:10 -05:00
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
2022-02-01 18:08:19 -05:00
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
2022-02-03 18:38:57 -05:00
const char** getRegisterSheet();
2022-02-15 01:46:03 -05:00
const char* getEffectName(unsigned char effect);
2022-01-28 12:59:53 -05:00
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformPCE();
};
#endif