2022-02-15 03:12:20 +00: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-12 08:58:55 +00:00
|
|
|
#ifndef _DISPATCH_H
|
|
|
|
#define _DISPATCH_H
|
|
|
|
|
2021-12-07 02:12:16 +00:00
|
|
|
#include <stdlib.h>
|
2022-01-17 04:21:27 +00:00
|
|
|
#include <vector>
|
2021-12-06 10:21:42 +00:00
|
|
|
|
2021-05-16 08:03:23 +00:00
|
|
|
#define ONE_SEMITONE 2200
|
|
|
|
|
2022-01-19 05:01:34 +00:00
|
|
|
#define DIV_NOTE_NULL 0x7fffffff
|
|
|
|
|
2022-01-17 18:29:35 +00:00
|
|
|
#define addWrite(a,v) regWrites.push_back(DivRegWrite(a,v));
|
|
|
|
|
2022-03-07 03:36:32 +00:00
|
|
|
// HOW TO ADD A NEW COMMAND:
|
|
|
|
// add it to this enum. then see playback.cpp.
|
|
|
|
// there is a const char* cmdName[] array, which contains the command
|
|
|
|
// names as strings for the commands (and other debug stuff).
|
|
|
|
//
|
|
|
|
// if you miss it, the program will crash or misbehave at some point.
|
2022-04-26 20:24:45 +00:00
|
|
|
//
|
|
|
|
// the comments are: (arg1, arg2) -> val
|
|
|
|
// not all commands have a return value
|
2021-05-11 20:08:08 +00:00
|
|
|
enum DivDispatchCmds {
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_NOTE_ON=0, // (note)
|
2021-05-11 20:08:08 +00:00
|
|
|
DIV_CMD_NOTE_OFF,
|
2022-02-08 08:50:42 +00:00
|
|
|
DIV_CMD_NOTE_OFF_ENV,
|
|
|
|
DIV_CMD_ENV_RELEASE,
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_INSTRUMENT, // (ins, force)
|
|
|
|
DIV_CMD_VOLUME, // (vol)
|
|
|
|
DIV_CMD_GET_VOLUME, // () -> vol
|
|
|
|
DIV_CMD_GET_VOLMAX, // () -> volMax
|
|
|
|
DIV_CMD_NOTE_PORTA, // (target, speed) -> 2 if target reached
|
|
|
|
DIV_CMD_PITCH, // (pitch)
|
|
|
|
DIV_CMD_PANNING, // (pan)
|
|
|
|
DIV_CMD_LEGATO, // (note)
|
|
|
|
DIV_CMD_PRE_PORTA, // (inPorta, isPortaOrSlide)
|
|
|
|
DIV_CMD_PRE_NOTE, // used in C64 (note)
|
|
|
|
|
|
|
|
DIV_CMD_SAMPLE_MODE, // (enabled)
|
|
|
|
DIV_CMD_SAMPLE_FREQ, // (frequency)
|
|
|
|
DIV_CMD_SAMPLE_BANK, // (bank)
|
|
|
|
DIV_CMD_SAMPLE_POS, // (pos)
|
|
|
|
|
|
|
|
DIV_CMD_FM_HARD_RESET, // (enabled)
|
|
|
|
DIV_CMD_FM_LFO, // (speed)
|
|
|
|
DIV_CMD_FM_LFO_WAVE, // (waveform)
|
|
|
|
DIV_CMD_FM_TL, // (op, value)
|
|
|
|
DIV_CMD_FM_AR, // (op, value)
|
|
|
|
DIV_CMD_FM_FB, // (value)
|
|
|
|
DIV_CMD_FM_MULT, // (op, value)
|
|
|
|
DIV_CMD_FM_EXTCH, // (enabled)
|
|
|
|
DIV_CMD_FM_AM_DEPTH, // (depth)
|
|
|
|
DIV_CMD_FM_PM_DEPTH, // (depth)
|
|
|
|
|
|
|
|
DIV_CMD_GENESIS_LFO, // unused?
|
2021-05-15 08:13:21 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_ARCADE_LFO, // unused?
|
2021-05-15 08:13:21 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_STD_NOISE_FREQ, // (freq)
|
|
|
|
DIV_CMD_STD_NOISE_MODE, // (mode)
|
2021-05-19 07:05:24 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_WAVE, // (waveform)
|
2021-05-28 05:36:25 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_GB_SWEEP_TIME, // (time)
|
|
|
|
DIV_CMD_GB_SWEEP_DIR, // (direction)
|
2021-05-28 05:36:25 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_PCE_LFO_MODE, // (mode)
|
|
|
|
DIV_CMD_PCE_LFO_SPEED, // (speed)
|
2021-06-09 06:08:42 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_NES_SWEEP, // (direction, value)
|
2022-02-01 23:28:48 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_C64_CUTOFF, // (value)
|
|
|
|
DIV_CMD_C64_RESONANCE, // (value)
|
|
|
|
DIV_CMD_C64_FILTER_MODE, // (value)
|
|
|
|
DIV_CMD_C64_RESET_TIME, // (value)
|
|
|
|
DIV_CMD_C64_RESET_MASK, // (mask)
|
|
|
|
DIV_CMD_C64_FILTER_RESET, // (value)
|
|
|
|
DIV_CMD_C64_DUTY_RESET, // (value)
|
|
|
|
DIV_CMD_C64_EXTENDED, // (value)
|
|
|
|
DIV_CMD_C64_FINE_DUTY, // (value)
|
|
|
|
DIV_CMD_C64_FINE_CUTOFF, // (value)
|
2021-12-07 06:23:57 +00:00
|
|
|
|
2021-12-09 22:06:28 +00:00
|
|
|
DIV_CMD_AY_ENVELOPE_SET,
|
|
|
|
DIV_CMD_AY_ENVELOPE_LOW,
|
|
|
|
DIV_CMD_AY_ENVELOPE_HIGH,
|
2022-01-11 23:38:26 +00:00
|
|
|
DIV_CMD_AY_ENVELOPE_SLIDE,
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_AY_NOISE_MASK_AND, // (value)
|
|
|
|
DIV_CMD_AY_NOISE_MASK_OR, // (value)
|
|
|
|
DIV_CMD_AY_AUTO_ENVELOPE, // (value)
|
|
|
|
DIV_CMD_AY_IO_WRITE, // (port, value)
|
2022-03-27 01:55:43 +00:00
|
|
|
DIV_CMD_AY_AUTO_PWM,
|
2021-12-09 22:06:28 +00:00
|
|
|
|
2022-04-04 03:37:16 +00:00
|
|
|
DIV_CMD_FDS_MOD_DEPTH,
|
|
|
|
DIV_CMD_FDS_MOD_HIGH,
|
|
|
|
DIV_CMD_FDS_MOD_LOW,
|
|
|
|
DIV_CMD_FDS_MOD_POS,
|
|
|
|
DIV_CMD_FDS_MOD_WAVE,
|
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_SAA_ENVELOPE, // (value)
|
2022-01-15 04:26:22 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_AMIGA_FILTER, // (enabled)
|
|
|
|
DIV_CMD_AMIGA_AM, // (enabled)
|
|
|
|
DIV_CMD_AMIGA_PM, // (enabled)
|
2022-03-27 04:39:20 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_CMD_LYNX_LFSR_LOAD, // (value)
|
2022-02-22 23:21:57 +00:00
|
|
|
|
2022-02-22 09:01:57 +00:00
|
|
|
DIV_CMD_QSOUND_ECHO_FEEDBACK,
|
2022-02-22 20:16:46 +00:00
|
|
|
DIV_CMD_QSOUND_ECHO_DELAY,
|
2022-02-22 09:01:57 +00:00
|
|
|
DIV_CMD_QSOUND_ECHO_LEVEL,
|
2022-02-21 11:41:06 +00:00
|
|
|
|
2022-03-06 17:31:03 +00:00
|
|
|
DIV_CMD_X1_010_ENVELOPE_SHAPE,
|
|
|
|
DIV_CMD_X1_010_ENVELOPE_ENABLE,
|
|
|
|
DIV_CMD_X1_010_ENVELOPE_MODE,
|
|
|
|
DIV_CMD_X1_010_ENVELOPE_PERIOD,
|
|
|
|
DIV_CMD_X1_010_ENVELOPE_SLIDE,
|
|
|
|
DIV_CMD_X1_010_AUTO_ENVELOPE,
|
|
|
|
|
2022-03-06 16:13:47 +00:00
|
|
|
DIV_CMD_WS_SWEEP_TIME,
|
|
|
|
DIV_CMD_WS_SWEEP_AMOUNT,
|
|
|
|
|
2022-03-22 16:48:45 +00:00
|
|
|
DIV_CMD_N163_WAVE_POSITION,
|
|
|
|
DIV_CMD_N163_WAVE_LENGTH,
|
|
|
|
DIV_CMD_N163_WAVE_MODE,
|
|
|
|
DIV_CMD_N163_WAVE_LOAD,
|
|
|
|
DIV_CMD_N163_WAVE_LOADPOS,
|
|
|
|
DIV_CMD_N163_WAVE_LOADLEN,
|
|
|
|
DIV_CMD_N163_WAVE_LOADMODE,
|
|
|
|
DIV_CMD_N163_CHANNEL_LIMIT,
|
|
|
|
DIV_CMD_N163_GLOBAL_WAVE_LOAD,
|
|
|
|
DIV_CMD_N163_GLOBAL_WAVE_LOADPOS,
|
|
|
|
DIV_CMD_N163_GLOBAL_WAVE_LOADLEN,
|
|
|
|
DIV_CMD_N163_GLOBAL_WAVE_LOADMODE,
|
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol
|
2021-05-28 05:36:25 +00:00
|
|
|
|
2021-05-19 07:05:24 +00:00
|
|
|
DIV_CMD_MAX
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DivCommand {
|
|
|
|
DivDispatchCmds cmd;
|
2022-01-08 21:03:32 +00:00
|
|
|
unsigned char chan, dis;
|
2021-05-14 19:16:48 +00:00
|
|
|
int value, value2;
|
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch, int val, int val2):
|
2021-05-12 10:22:01 +00:00
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
2022-01-08 21:03:32 +00:00
|
|
|
dis(ch),
|
2021-05-14 19:16:48 +00:00
|
|
|
value(val),
|
|
|
|
value2(val2) {}
|
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch, int val):
|
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
2022-01-08 21:03:32 +00:00
|
|
|
dis(ch),
|
2021-05-14 19:16:48 +00:00
|
|
|
value(val),
|
|
|
|
value2(0) {}
|
2021-05-12 10:22:01 +00:00
|
|
|
DivCommand(DivDispatchCmds c, unsigned char ch):
|
|
|
|
cmd(c),
|
|
|
|
chan(ch),
|
2022-01-08 21:03:32 +00:00
|
|
|
dis(ch),
|
2021-05-14 19:16:48 +00:00
|
|
|
value(0),
|
|
|
|
value2(0) {}
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DivDelayedCommand {
|
|
|
|
int ticks;
|
|
|
|
DivCommand cmd;
|
|
|
|
};
|
|
|
|
|
2022-01-17 04:21:27 +00:00
|
|
|
struct DivRegWrite {
|
|
|
|
/**
|
2022-01-24 06:01:08 +00:00
|
|
|
* an address of 0xffffxx00 indicates a Furnace specific command.
|
2022-01-17 04:21:27 +00:00
|
|
|
* the following addresses are available:
|
2022-01-24 06:01:08 +00:00
|
|
|
* - 0xffffxx00: start sample playback
|
|
|
|
* - xx is the instance ID
|
2022-01-17 04:21:27 +00:00
|
|
|
* - data is the sample number
|
2022-01-24 06:01:08 +00:00
|
|
|
* - 0xffffxx01: set sample rate
|
|
|
|
* - xx is the instance ID
|
|
|
|
* - data is the sample rate
|
|
|
|
* - 0xffffxx02: stop sample playback
|
|
|
|
* - xx is the instance ID
|
|
|
|
* - 0xffffffff: reset
|
2022-01-17 04:21:27 +00:00
|
|
|
*/
|
|
|
|
unsigned int addr;
|
2022-01-24 06:01:08 +00:00
|
|
|
unsigned short val;
|
|
|
|
DivRegWrite(unsigned int a, unsigned short v):
|
2022-01-17 18:29:35 +00:00
|
|
|
addr(a), val(v) {}
|
2022-01-17 04:21:27 +00:00
|
|
|
};
|
|
|
|
|
2021-05-12 08:58:55 +00:00
|
|
|
class DivEngine;
|
2022-04-26 20:24:45 +00:00
|
|
|
class DivMacroInt;
|
2021-05-12 08:58:55 +00:00
|
|
|
|
2021-05-11 20:08:08 +00:00
|
|
|
class DivDispatch {
|
2021-05-12 08:58:55 +00:00
|
|
|
protected:
|
|
|
|
DivEngine* parent;
|
2022-01-17 04:21:27 +00:00
|
|
|
std::vector<DivRegWrite> regWrites;
|
2021-12-21 06:29:07 +00:00
|
|
|
/**
|
2022-01-17 04:21:27 +00:00
|
|
|
* please honor these variables if needed.
|
2021-12-21 06:29:07 +00:00
|
|
|
*/
|
2022-01-17 04:21:27 +00:00
|
|
|
bool skipRegisterWrites, dumpWrites;
|
2021-05-11 20:08:08 +00:00
|
|
|
public:
|
2021-05-12 08:58:55 +00:00
|
|
|
/**
|
|
|
|
* the rate the samples are provided.
|
|
|
|
* the engine shall resample to the output rate.
|
2022-04-26 20:24:45 +00:00
|
|
|
* you have to initialize this one during init() or setFlags().
|
2021-05-12 08:58:55 +00:00
|
|
|
*/
|
|
|
|
int rate;
|
2022-01-28 05:55:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* the actual chip's clock.
|
2022-04-26 20:24:45 +00:00
|
|
|
* you have to initialize this one during init() or setFlags().
|
2022-01-28 05:55:51 +00:00
|
|
|
*/
|
|
|
|
int chipClock;
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* fill a buffer with sound data.
|
|
|
|
* @param bufL the left or mono channel buffer.
|
|
|
|
* @param bufR the right channel buffer.
|
|
|
|
* @param start the start offset.
|
|
|
|
* @param len the amount of samples to fill.
|
|
|
|
*/
|
2021-12-06 21:51:18 +00:00
|
|
|
virtual void acquire(short* bufL, short* bufR, size_t start, size_t len);
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* send a command to this dispatch.
|
|
|
|
* @param c a DivCommand.
|
|
|
|
* @return a return value which varies depending on the command.
|
|
|
|
*/
|
2021-05-11 20:08:08 +00:00
|
|
|
virtual int dispatch(DivCommand c);
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* reset the state of this dispatch.
|
|
|
|
*/
|
2021-12-11 08:34:43 +00:00
|
|
|
virtual void reset();
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ticks this dispatch.
|
2022-04-15 20:01:11 +00:00
|
|
|
* @param sysTick whether the engine has ticked (if not then this may be a sub-tick used in low-latency mode).
|
2021-12-18 08:25:42 +00:00
|
|
|
*/
|
2022-04-15 20:01:11 +00:00
|
|
|
virtual void tick(bool sysTick=true);
|
2021-05-11 20:08:08 +00:00
|
|
|
|
2022-01-27 05:29:16 +00:00
|
|
|
/**
|
|
|
|
* get the state of a channel.
|
|
|
|
* @return a pointer, or NULL.
|
|
|
|
*/
|
|
|
|
virtual void* getChanState(int chan);
|
2022-04-26 20:24:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the DivMacroInt of a chanmel.
|
|
|
|
* @return a pointer, or NULL.
|
|
|
|
*/
|
|
|
|
virtual DivMacroInt* getChanMacroInt(int chan);
|
2022-02-22 03:31:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the register pool of this dispatch.
|
|
|
|
* @return a pointer, or NULL.
|
|
|
|
*/
|
|
|
|
virtual unsigned char* getRegisterPool();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the size of the register pool of this dispatch.
|
|
|
|
* @return the size.
|
|
|
|
*/
|
|
|
|
virtual int getRegisterPoolSize();
|
2022-01-27 05:29:16 +00:00
|
|
|
|
2022-02-22 09:01:57 +00:00
|
|
|
/**
|
|
|
|
* get the bit depth of the register pool of this dispatch.
|
2022-02-23 03:13:17 +00:00
|
|
|
* If the result is 16, it should be casted to unsigned short.
|
2022-02-22 09:01:57 +00:00
|
|
|
* @return the depth. Default value is 8
|
|
|
|
*/
|
|
|
|
virtual int getRegisterPoolDepth();
|
|
|
|
|
2021-12-18 08:25:42 +00:00
|
|
|
/**
|
2022-02-22 03:31:27 +00:00
|
|
|
* get this dispatch's state. DO NOT IMPLEMENT YET.
|
2021-12-18 08:25:42 +00:00
|
|
|
* @return a pointer to the dispatch's state. must be deallocated manually!
|
|
|
|
*/
|
|
|
|
virtual void* getState();
|
|
|
|
|
|
|
|
/**
|
2022-02-22 03:31:27 +00:00
|
|
|
* set this dispatch's state. DO NOT IMPLEMENT YET.
|
2021-12-18 08:25:42 +00:00
|
|
|
* @param state a pointer to a state pertaining to this dispatch,
|
|
|
|
* or NULL if this dispatch does not support state saves.
|
|
|
|
*/
|
|
|
|
virtual void setState(void* state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mute a channel.
|
|
|
|
* @param ch the channel to mute.
|
|
|
|
* @param mute whether to mute or unmute.
|
|
|
|
*/
|
|
|
|
virtual void muteChannel(int ch, bool mute);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* test whether this dispatch outputs audio in two channels.
|
|
|
|
* @return whether it does.
|
|
|
|
*/
|
2021-12-06 21:51:18 +00:00
|
|
|
virtual bool isStereo();
|
2021-12-18 08:25:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* test whether sending a key off command to a channel should reset arp too.
|
|
|
|
* @param ch the channel in question.
|
|
|
|
* @return whether it does.
|
|
|
|
*/
|
2021-12-08 05:33:00 +00:00
|
|
|
virtual bool keyOffAffectsArp(int ch);
|
2021-12-18 08:25:42 +00:00
|
|
|
|
2021-12-29 07:08:50 +00:00
|
|
|
/**
|
|
|
|
* test whether sending a key off command to a channel should reset slides too.
|
|
|
|
* @param ch the channel in question.
|
|
|
|
* @return whether it does.
|
|
|
|
*/
|
|
|
|
virtual bool keyOffAffectsPorta(int ch);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get the lowest note in a portamento.
|
|
|
|
* @param ch the channel in question.
|
|
|
|
* @return the lowest note.
|
|
|
|
*/
|
|
|
|
virtual int getPortaFloor(int ch);
|
|
|
|
|
2022-04-09 23:25:25 +00:00
|
|
|
/**
|
|
|
|
* get the required amplification level of this dispatch's output.
|
|
|
|
* @return the amplification level.
|
|
|
|
*/
|
|
|
|
virtual float getPostAmp();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* check whether DC offset correction is required.
|
|
|
|
* @return truth.
|
|
|
|
*/
|
|
|
|
virtual bool getDCOffRequired();
|
|
|
|
|
2022-01-20 18:48:20 +00:00
|
|
|
/**
|
|
|
|
* get a description of a dispatch-specific effect.
|
|
|
|
* @param effect the effect.
|
|
|
|
* @return the description, or NULL if effect is invalid.
|
|
|
|
*/
|
|
|
|
virtual const char* getEffectName(unsigned char effect);
|
|
|
|
|
2021-12-18 08:25:42 +00:00
|
|
|
/**
|
2022-01-28 17:59:53 +00:00
|
|
|
* set the chip flags.
|
|
|
|
* @param flags the flags. see song.h for possible values.
|
2021-12-18 08:25:42 +00:00
|
|
|
*/
|
2022-01-28 17:59:53 +00:00
|
|
|
virtual void setFlags(unsigned int flags);
|
2021-12-06 21:51:18 +00:00
|
|
|
|
2021-12-21 06:29:07 +00:00
|
|
|
/**
|
|
|
|
* set skip reg writes.
|
|
|
|
*/
|
2022-04-06 23:03:30 +00:00
|
|
|
virtual void setSkipRegisterWrites(bool value);
|
2021-12-21 06:29:07 +00:00
|
|
|
|
2022-01-18 04:59:52 +00:00
|
|
|
/**
|
|
|
|
* notify instrument change.
|
|
|
|
*/
|
|
|
|
virtual void notifyInsChange(int ins);
|
|
|
|
|
2022-01-18 05:25:10 +00:00
|
|
|
/**
|
|
|
|
* notify wavetable change.
|
|
|
|
*/
|
|
|
|
virtual void notifyWaveChange(int wave);
|
|
|
|
|
2022-01-13 22:40:29 +00:00
|
|
|
/**
|
|
|
|
* notify deletion of an instrument.
|
|
|
|
*/
|
|
|
|
virtual void notifyInsDeletion(void* ins);
|
|
|
|
|
2022-03-07 06:48:48 +00:00
|
|
|
/**
|
|
|
|
* notify that playback stopped.
|
|
|
|
*/
|
|
|
|
virtual void notifyPlaybackStop();
|
|
|
|
|
2021-12-21 06:29:07 +00:00
|
|
|
/**
|
|
|
|
* force-retrigger instruments.
|
|
|
|
*/
|
|
|
|
virtual void forceIns();
|
|
|
|
|
2022-01-17 04:21:27 +00:00
|
|
|
/**
|
|
|
|
* enable register dumping.
|
|
|
|
*/
|
2022-01-24 06:01:08 +00:00
|
|
|
virtual void toggleRegisterDump(bool enable);
|
2022-01-17 04:21:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get register writes.
|
|
|
|
*/
|
|
|
|
std::vector<DivRegWrite>& getRegisterWrites();
|
|
|
|
|
2022-02-01 23:08:19 +00:00
|
|
|
/**
|
|
|
|
* poke a register.
|
|
|
|
* @param addr address.
|
|
|
|
* @param val value.
|
|
|
|
*/
|
|
|
|
virtual void poke(unsigned int addr, unsigned short val);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* poke a register.
|
|
|
|
* @param wlist a vector containing DivRegWrites.
|
|
|
|
*/
|
|
|
|
virtual void poke(std::vector<DivRegWrite>& wlist);
|
|
|
|
|
2022-02-03 23:38:57 +00:00
|
|
|
/**
|
|
|
|
* get available registers.
|
|
|
|
* @return an array of C strings, terminated by NULL; or NULL if none available.
|
|
|
|
*/
|
|
|
|
virtual const char** getRegisterSheet();
|
|
|
|
|
2021-05-11 20:08:08 +00:00
|
|
|
/**
|
|
|
|
* initialize this DivDispatch.
|
2021-05-12 08:58:55 +00:00
|
|
|
* @param parent the parent DivEngine.
|
2021-05-11 20:08:08 +00:00
|
|
|
* @param channels the number of channels to acquire.
|
2021-05-12 08:58:55 +00:00
|
|
|
* @param sugRate the suggested rate. this may change, so don't rely on it.
|
2022-01-28 17:59:53 +00:00
|
|
|
* @param flags the chip flags. see song.h for possible values.
|
2021-05-11 20:08:08 +00:00
|
|
|
* @return the number of channels allocated.
|
|
|
|
*/
|
2022-01-28 17:59:53 +00:00
|
|
|
virtual int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
|
2021-12-15 05:37:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* quit the DivDispatch.
|
|
|
|
*/
|
2022-04-27 05:56:15 +00:00
|
|
|
virtual void quit();
|
2021-12-15 05:37:27 +00:00
|
|
|
|
2022-04-27 05:56:15 +00:00
|
|
|
virtual ~DivDispatch();
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|
2022-01-28 05:55:51 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
// pitch calculation:
|
|
|
|
// - a DivDispatch usually contains four variables per channel:
|
|
|
|
// - baseFreq: this changes on new notes, legato, arpeggio and slides.
|
|
|
|
// - pitch: this changes with DIV_CMD_PITCH (E5xx/04xy).
|
|
|
|
// - freq: this is the result of combining baseFreq and pitch using DivEngine::calcFreq().
|
|
|
|
// - freqChanged: whether baseFreq and/or pitch have changed, and a frequency recalculation is required on the next tick.
|
|
|
|
// - the following definitions will help you calculate baseFreq.
|
|
|
|
// - to use them, define CHIP_DIVIDER and/or CHIP_FREQBASE in your code (not in the header though!).
|
2022-03-24 04:19:16 +00:00
|
|
|
#define NOTE_PERIODIC(x) round(parent->calcBaseFreq(chipClock,CHIP_DIVIDER,x,true))
|
|
|
|
#define NOTE_PERIODIC_NOROUND(x) parent->calcBaseFreq(chipClock,CHIP_DIVIDER,x,true)
|
2022-01-28 05:55:51 +00:00
|
|
|
#define NOTE_FREQUENCY(x) parent->calcBaseFreq(chipClock,CHIP_FREQBASE,x,false)
|
2022-04-25 03:45:59 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
// this is a special case definition. only use it for f-num/block-based chips.
|
2022-04-25 03:45:59 +00:00
|
|
|
#define NOTE_FNUM_BLOCK(x,bits) parent->calcBaseFreqFNumBlock(chipClock,CHIP_FREQBASE,x,bits)
|
2022-01-28 05:55:51 +00:00
|
|
|
|
2022-04-26 20:24:45 +00:00
|
|
|
// these are here for convenience.
|
|
|
|
// it is encouraged to use these, since you get an exact value this way.
|
|
|
|
// - NTSC colorburst: 3.58MHz
|
|
|
|
// - PAL colorburst: 4.43MHz
|
2022-01-28 05:55:51 +00:00
|
|
|
#define COLOR_NTSC (315000000.0/88.0)
|
|
|
|
#define COLOR_PAL (283.75*15625.0+25.0)
|
|
|
|
|
2021-05-12 10:22:01 +00:00
|
|
|
#endif
|