2022-02-14 22:12:20 -05:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
2023-01-19 19:18:40 -05:00
|
|
|
* Copyright (C) 2021-2023 tildearrow and contributors
|
2022-02-14 22:12:20 -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.
|
|
|
|
*/
|
|
|
|
|
2021-05-26 04:17:12 -04:00
|
|
|
#ifndef _GB_H
|
|
|
|
#define _GB_H
|
|
|
|
|
|
|
|
#include "../dispatch.h"
|
2022-04-08 03:11:33 -04:00
|
|
|
#include "../waveSynth.h"
|
2021-05-26 04:17:12 -04:00
|
|
|
#include "sound/gb/gb.h"
|
2022-08-11 01:46:15 -04:00
|
|
|
#include <queue>
|
2021-05-26 04:17:12 -04:00
|
|
|
|
|
|
|
class DivPlatformGB: public DivDispatch {
|
2022-12-13 02:22:48 -05:00
|
|
|
struct Channel: public SharedChannel<signed char> {
|
2022-04-25 19:58:17 -04:00
|
|
|
unsigned char duty, sweep;
|
2022-12-04 05:58:58 -05:00
|
|
|
bool sweepChanged, released, softEnv, killIt;
|
2022-08-15 00:07:19 -04:00
|
|
|
bool soManyHacksToMakeItDefleCompatible;
|
2022-12-04 05:58:58 -05:00
|
|
|
signed short wave;
|
|
|
|
signed char lastKill;
|
2022-08-07 01:03:27 -04:00
|
|
|
unsigned char envVol, envDir, envLen, soundLen;
|
2022-08-10 02:55:44 -04:00
|
|
|
unsigned short hwSeqPos;
|
|
|
|
short hwSeqDelay;
|
2021-05-26 04:17:12 -04:00
|
|
|
Channel():
|
2022-12-13 02:22:48 -05:00
|
|
|
SharedChannel<signed char>(15),
|
2021-05-26 18:43:14 -04:00
|
|
|
duty(0),
|
2021-05-28 02:26:57 -04:00
|
|
|
sweep(0),
|
|
|
|
sweepChanged(false),
|
2022-08-10 02:55:44 -04:00
|
|
|
released(false),
|
2022-08-10 17:27:29 -04:00
|
|
|
softEnv(false),
|
2022-08-11 02:24:53 -04:00
|
|
|
killIt(false),
|
2022-08-15 00:07:19 -04:00
|
|
|
soManyHacksToMakeItDefleCompatible(false),
|
2022-08-07 01:03:27 -04:00
|
|
|
wave(-1),
|
2022-08-11 02:24:53 -04:00
|
|
|
lastKill(0),
|
2022-08-07 01:03:27 -04:00
|
|
|
envVol(0),
|
|
|
|
envDir(0),
|
|
|
|
envLen(0),
|
2022-08-09 15:53:31 -04:00
|
|
|
soundLen(0),
|
|
|
|
hwSeqPos(0),
|
|
|
|
hwSeqDelay(0) {}
|
2021-05-26 04:17:12 -04:00
|
|
|
};
|
|
|
|
Channel chan[4];
|
2022-04-30 19:33:12 -04:00
|
|
|
DivDispatchOscBuffer* oscBuf[4];
|
2021-12-18 03:25:42 -05:00
|
|
|
bool isMuted[4];
|
2022-08-03 20:17:18 -04:00
|
|
|
bool antiClickEnabled;
|
2023-05-04 03:18:56 -04:00
|
|
|
bool invertWave;
|
2022-10-02 01:06:06 -04:00
|
|
|
bool enoughAlready;
|
2021-05-28 00:33:04 -04:00
|
|
|
unsigned char lastPan;
|
2022-04-08 03:11:33 -04:00
|
|
|
DivWaveSynth ws;
|
2022-08-11 01:46:15 -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;
|
2021-05-26 18:43:14 -04:00
|
|
|
|
2022-08-03 20:17:18 -04:00
|
|
|
int antiClickPeriodCount, antiClickWavePos;
|
|
|
|
|
2021-05-26 04:17:12 -04:00
|
|
|
GB_gameboy_t* gb;
|
2022-08-11 01:46:15 -04:00
|
|
|
GB_model_t model;
|
2022-02-21 22:31:27 -05:00
|
|
|
unsigned char regPool[128];
|
|
|
|
|
2021-12-18 03:25:42 -05:00
|
|
|
unsigned char procMute();
|
2022-09-23 10:24:02 -04:00
|
|
|
void updateWave();
|
|
|
|
friend void putDispatchChip(void*,int);
|
2022-01-27 00:29:16 -05:00
|
|
|
friend void putDispatchChan(void*,int,int);
|
2021-05-26 04:17:12 -04:00
|
|
|
public:
|
2023-01-02 04:53:37 -05:00
|
|
|
void acquire(short** buf, size_t len);
|
2021-05-26 04:17:12 -04:00
|
|
|
int dispatch(DivCommand c);
|
2022-01-27 00:29:16 -05:00
|
|
|
void* getChanState(int chan);
|
2022-06-05 19:17:00 -04:00
|
|
|
DivMacroInt* getChanMacroInt(int ch);
|
2022-04-30 19:33:12 -04:00
|
|
|
DivDispatchOscBuffer* getOscBuffer(int chan);
|
2022-02-21 22:31:27 -05:00
|
|
|
unsigned char* getRegisterPool();
|
|
|
|
int getRegisterPoolSize();
|
2021-12-11 13:14:38 -05:00
|
|
|
void reset();
|
2021-12-21 01:29:07 -05:00
|
|
|
void forceIns();
|
2022-04-15 16:01:11 -04:00
|
|
|
void tick(bool sysTick=true);
|
2021-12-18 03:25:42 -05:00
|
|
|
void muteChannel(int ch, bool mute);
|
2022-08-11 00:56:25 -04:00
|
|
|
int getPortaFloor(int ch);
|
2023-01-01 19:46:08 -05:00
|
|
|
int getOutputCount();
|
2022-08-11 01:46:15 -04:00
|
|
|
bool getDCOffRequired();
|
2022-01-17 23:59:52 -05:00
|
|
|
void notifyInsChange(int ins);
|
2022-01-18 00:25:10 -05:00
|
|
|
void notifyWaveChange(int wave);
|
2022-01-13 19:36:02 -05:00
|
|
|
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-09-29 21:13:40 -04:00
|
|
|
void setFlags(const DivConfig& flags);
|
|
|
|
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
2021-12-15 00:37:27 -05:00
|
|
|
void quit();
|
|
|
|
~DivPlatformGB();
|
2021-05-26 04:17:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|