furnace/src/engine/platform/gb.h

106 lines
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.
*/
2021-05-26 04:17:12 -04:00
#ifndef _GB_H
#define _GB_H
#include "../dispatch.h"
#include "../macroInt.h"
#include "../waveSynth.h"
2021-05-26 04:17:12 -04:00
#include "sound/gb/gb.h"
class DivPlatformGB: public DivDispatch {
struct Channel {
2022-04-28 01:50:09 -04:00
int freq, baseFreq, pitch, pitch2, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta;
2021-05-27 17:47:09 -04:00
signed char vol, outVol, wave;
unsigned char envVol, envDir, envLen, soundLen;
2021-05-26 04:17:12 -04:00
DivMacroInt std;
2022-04-28 02:31:16 -04:00
void macroInit(DivInstrument* which) {
std.init(which);
pitch2=0;
}
2021-05-26 04:17:12 -04:00
Channel():
freq(0),
baseFreq(0),
pitch(0),
2022-04-28 01:50:09 -04:00
pitch2(0),
2021-05-26 04:17:12 -04:00
note(0),
2022-01-20 16:56:35 -05:00
ins(-1),
duty(0),
2021-05-28 02:26:57 -04:00
sweep(0),
2021-05-26 04:17:12 -04:00
active(false),
insChanged(true),
freqChanged(false),
2021-05-28 02:26:57 -04:00
sweepChanged(false),
2021-05-26 04:17:12 -04:00
keyOn(false),
keyOff(false),
inPorta(false),
2021-05-28 00:03:10 -04:00
vol(15),
outVol(15),
wave(-1),
envVol(0),
envDir(0),
envLen(0),
soundLen(0) {}
2021-05-26 04:17:12 -04:00
};
Channel chan[4];
DivDispatchOscBuffer* oscBuf[4];
2021-12-18 03:25:42 -05:00
bool isMuted[4];
2022-08-03 20:17:18 -04:00
bool antiClickEnabled;
unsigned char lastPan;
DivWaveSynth ws;
2022-08-03 20:17:18 -04:00
int antiClickPeriodCount, antiClickWavePos;
2021-05-26 04:17:12 -04:00
GB_gameboy_t* gb;
unsigned char regPool[128];
2021-12-18 03:25:42 -05:00
unsigned char procMute();
void updateWave();
2022-01-27 00:29:16 -05:00
friend void putDispatchChan(void*,int,int);
2021-05-26 04:17:12 -04:00
public:
void acquire(short* bufL, short* bufR, size_t start, 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);
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();
2022-01-17 23:59:52 -05:00
void notifyInsChange(int ins);
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-08-03 20:17:18 -04:00
void setFlags(unsigned int flags);
2022-01-28 12:59:53 -05:00
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit();
~DivPlatformGB();
2021-05-26 04:17:12 -04:00
};
#endif