furnace/src/engine/macroInt.h

174 lines
3.8 KiB
C
Raw Normal View History

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.
*/
#ifndef _MACROINT_H
#define _MACROINT_H
#include "instrument.h"
2022-04-10 05:01:55 +00:00
class DivEngine;
2022-04-10 05:01:55 +00:00
struct DivMacroStruct {
2022-08-22 08:52:32 +00:00
int pos, lastPos, delay;
2022-04-10 05:01:55 +00:00
int val;
2022-08-22 08:52:32 +00:00
bool has, had, actualHad, finished, will, linger, began;
2022-04-10 05:01:55 +00:00
unsigned int mode;
2022-04-15 19:38:25 +00:00
void doMacro(DivInstrumentMacro& source, bool released, bool tick);
2022-04-10 05:01:55 +00:00
void init() {
2022-08-22 08:52:32 +00:00
pos=lastPos=mode=delay=0;
2022-04-15 19:38:25 +00:00
has=had=actualHad=will=false;
linger=false;
2022-08-22 08:52:32 +00:00
began=true;
2022-04-15 08:37:16 +00:00
// TODO: test whether this breaks anything?
val=0;
2022-04-10 05:01:55 +00:00
}
void prepare(DivInstrumentMacro& source, DivEngine* e);
2022-04-10 05:01:55 +00:00
DivMacroStruct():
pos(0),
2022-08-22 08:52:32 +00:00
lastPos(0),
delay(0),
2022-04-10 05:01:55 +00:00
val(0),
has(false),
had(false),
2022-04-15 19:38:25 +00:00
actualHad(false),
2022-04-10 05:01:55 +00:00
finished(false),
will(false),
linger(false),
began(true),
2022-04-10 05:01:55 +00:00
mode(0) {}
};
class DivMacroInt {
DivEngine* e;
DivInstrument* ins;
2022-04-10 23:07:30 +00:00
DivMacroStruct* macroList[128];
DivInstrumentMacro* macroSource[128];
size_t macroListLen;
int subTick;
bool released;
public:
2022-04-10 05:01:55 +00:00
// common macro
DivMacroStruct vol;
DivMacroStruct arp;
DivMacroStruct duty, wave, pitch, ex1, ex2, ex3;
2022-04-10 21:52:03 +00:00
DivMacroStruct alg, fb, fms, ams;
2022-04-10 05:01:55 +00:00
DivMacroStruct panL, panR, phaseReset, ex4, ex5, ex6, ex7, ex8;
// FM operator macro
struct IntOp {
2022-04-10 05:01:55 +00:00
DivMacroStruct am, ar, dr, mult;
DivMacroStruct rr, sl, tl, dt2;
DivMacroStruct rs, dt, d2r, ssg;
DivMacroStruct dam, dvb, egt, ksl;
DivMacroStruct sus, vib, ws, ksr;
IntOp():
2022-04-10 05:01:55 +00:00
am(),
ar(),
dr(),
mult(),
rr(),
sl(),
tl(),
dt2(),
rs(),
dt(),
d2r(),
ssg(),
dam(),
dvb(),
egt(),
ksl(),
sus(),
vib(),
ws(),
ksr() {}
} op[4];
2022-03-16 03:05:55 +00:00
2022-06-05 21:24:12 +00:00
// state
bool hasRelease;
2022-03-16 03:05:55 +00:00
/**
* trigger macro release.
*/
void release();
2022-03-16 03:05:55 +00:00
/**
* trigger next macro tick.
*/
void next();
2022-03-16 03:05:55 +00:00
/**
* set the engine.
* @param the engine
*/
void setEngine(DivEngine* eng);
2022-03-16 03:05:55 +00:00
/**
* initialize the macro interpreter.
* @param which an instrument, or NULL.
*/
void init(DivInstrument* which);
2022-03-16 03:05:55 +00:00
/**
* notify this macro interpreter that an instrument has been deleted.
* @param which the instrument in question.
*/
void notifyInsDeletion(DivInstrument* which);
2022-03-16 03:05:55 +00:00
/**
* get DivMacroStruct by macro name.
* @param which the macro name.
* @return a DivMacroStruct, or NULL if none found.
*/
DivMacroStruct* structByName(const String& name);
DivMacroInt():
e(NULL),
ins(NULL),
2022-04-10 23:07:30 +00:00
macroListLen(0),
2022-04-15 19:38:25 +00:00
subTick(1),
released(false),
2022-04-10 05:01:55 +00:00
vol(),
arp(),
duty(),
wave(),
pitch(),
ex1(),
ex2(),
ex3(),
alg(),
fb(),
fms(),
ams(),
panL(),
panR(),
phaseReset(),
ex4(),
ex5(),
ex6(),
ex7(),
2022-06-05 21:24:12 +00:00
ex8(),
hasRelease(false) {
2022-04-10 23:07:30 +00:00
memset(macroList,0,128*sizeof(void*));
memset(macroSource,0,128*sizeof(void*));
}
};
#endif