furnace/src/engine/platform/pce.h

105 lines
3.1 KiB
C
Raw Normal View History

2022-02-15 03:12:20 +00:00
/**
* Furnace Tracker - multi-system chiptune tracker
2023-01-20 00:18:40 +00:00
* Copyright (C) 2021-2023 tildearrow and contributors
2022-02-15 03:12:20 +00: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 _PCE_H
#define _PCE_H
#include "../dispatch.h"
2021-06-07 07:49:43 +00:00
#include <queue>
#include "../waveSynth.h"
#include "sound/pce_psg.h"
class DivPlatformPCE: public DivDispatch {
struct Channel: public SharedChannel<signed char> {
int antiClickPeriodCount, antiClickWavePos;
int dacPeriod, dacRate, dacOut;
2021-12-14 17:33:26 +00:00
unsigned int dacPos;
int dacSample;
unsigned char pan;
bool noise, pcm, furnaceDac, deferredWaveUpdate;
signed short wave;
2023-01-19 08:38:29 +00:00
int macroVolMul, noiseSeek;
DivWaveSynth ws;
Channel():
SharedChannel<signed char>(31),
2022-07-30 06:00:51 +00:00
antiClickPeriodCount(0),
antiClickWavePos(0),
2021-12-04 06:19:54 +00:00
dacPeriod(0),
dacRate(0),
dacOut(0),
2021-12-04 06:19:54 +00:00
dacPos(0),
dacSample(-1),
2021-06-07 07:49:43 +00:00
pan(255),
noise(false),
2021-06-09 04:16:29 +00:00
pcm(false),
furnaceDac(false),
deferredWaveUpdate(false),
wave(-1),
2023-01-19 08:38:29 +00:00
macroVolMul(31),
noiseSeek(0) {}
};
2021-06-07 07:49:43 +00:00
Channel chan[6];
DivDispatchOscBuffer* oscBuf[6];
2021-12-18 08:25:42 +00:00
bool isMuted[6];
2022-07-30 06:00:51 +00:00
bool antiClickEnabled;
2022-11-15 21:40:27 +00:00
bool updateLFO;
2021-06-07 07:49:43 +00: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-13 03:14:20 +00:00
int cycles, curChan, delay;
int tempL[32];
int tempR[32];
2022-02-05 21:19:22 +00:00
unsigned char sampleBank, lfoMode, lfoSpeed;
PCE_PSG* pce;
unsigned char regPool[128];
2021-06-07 07:49:43 +00:00
void updateWave(int ch);
friend void putDispatchChip(void*,int);
2022-01-27 05:29:16 +00:00
friend void putDispatchChan(void*,int,int);
public:
2023-01-02 09:53:37 +00:00
void acquire(short** buf, size_t len);
int dispatch(DivCommand c);
2022-01-27 05:29:16 +00:00
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();
2021-12-11 18:14:38 +00:00
void reset();
void forceIns();
void tick(bool sysTick=true);
2021-12-18 08:25:42 +00:00
void muteChannel(int ch, bool mute);
int getOutputCount();
2021-12-08 05:33:00 +00:00
bool keyOffAffectsArp(int ch);
void setFlags(const DivConfig& flags);
2022-01-18 05:25:10 +00:00
void notifyWaveChange(int wave);
void notifyInsDeletion(void* ins);
2022-02-01 23:08:19 +00:00
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);
2022-02-03 23:38:57 +00:00
const char** getRegisterSheet();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
~DivPlatformPCE();
};
#endif