Rewrite per-system effect handling (#548)

* Rewrite per-system effect handling

* fix build

* C64: fix fine cutoff regression

* fix some more crashes

Co-authored-by: tildearrow <tildearrow@protonmail.com>
This commit is contained in:
Natt Akuma 2022-08-18 13:26:22 +07:00 committed by GitHub
parent 5c5d9368bc
commit 7c42453422
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
88 changed files with 477 additions and 2571 deletions

View file

@ -32,6 +32,7 @@
#include <thread>
#include <mutex>
#include <map>
#include <unordered_map>
#include <queue>
#define addWarning(x) \
@ -194,7 +195,29 @@ struct DivDispatchContainer {
dcOffCompensation(false) {}
};
typedef std::function<bool(int,unsigned char,unsigned char)> EffectProcess;
typedef int EffectValConversion(unsigned char,unsigned char);
struct EffectHandler {
DivDispatchCmds dispatchCmd;
const char* description;
EffectValConversion* val;
EffectValConversion* val2;
EffectHandler(
DivDispatchCmds dispatchCmd_,
const char* description_,
EffectValConversion val_=NULL,
EffectValConversion val2_=NULL
):
dispatchCmd(dispatchCmd_),
description(description_),
val(val_),
val2(val2_) {}
};
struct DivDoNotHandleEffect {
};
typedef std::unordered_map<unsigned char,const EffectHandler> EffectHandlerMap;
struct DivSysDef {
const char* name;
@ -211,8 +234,8 @@ struct DivSysDef {
// 0: primary
// 1: alternate (usually PCM)
DivInstrumentType chanInsType[DIV_MAX_CHANS][2];
EffectProcess effectFunc;
EffectProcess postEffectFunc;
const EffectHandlerMap effectHandlers;
const EffectHandlerMap postEffectHandlers;
DivSysDef(
const char* sysName, const char* sysNameJ, unsigned char fileID, unsigned char fileID_DMF, int chans,
bool isFMChip, bool isSTDChip, unsigned int vgmVer, bool compound, const char* desc,
@ -221,8 +244,8 @@ struct DivSysDef {
std::initializer_list<int> chTypes,
std::initializer_list<DivInstrumentType> chInsType1,
std::initializer_list<DivInstrumentType> chInsType2={},
EffectProcess fxHandler=[](int,unsigned char,unsigned char) -> bool {return false;},
EffectProcess postFxHandler=[](int,unsigned char,unsigned char) -> bool {return false;}):
const EffectHandlerMap fxHandlers_={},
const EffectHandlerMap postFxHandlers_={}):
name(sysName),
nameJ(sysNameJ),
description(desc),
@ -233,8 +256,8 @@ struct DivSysDef {
isSTD(isSTDChip),
isCompound(compound),
vgmVersion(vgmVer),
effectFunc(fxHandler),
postEffectFunc(postFxHandler) {
effectHandlers(fxHandlers_),
postEffectHandlers(postFxHandlers_) {
memset(chanNames,0,DIV_MAX_CHANS*sizeof(void*));
memset(chanShortNames,0,DIV_MAX_CHANS*sizeof(void*));
memset(chanTypes,0,DIV_MAX_CHANS*sizeof(int));