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:
parent
5c5d9368bc
commit
7c42453422
88 changed files with 477 additions and 2571 deletions
|
|
@ -292,13 +292,39 @@ int DivEngine::dispatchCmd(DivCommand c) {
|
|||
}
|
||||
|
||||
bool DivEngine::perSystemEffect(int ch, unsigned char effect, unsigned char effectVal) {
|
||||
if (sysDefs[sysOfChan[ch]]==NULL) return false;
|
||||
return sysDefs[sysOfChan[ch]]->effectFunc(ch,effect,effectVal);
|
||||
DivSysDef* sysDef=sysDefs[sysOfChan[ch]];
|
||||
if (sysDef==NULL) return false;
|
||||
auto iter=sysDef->effectHandlers.find(effect);
|
||||
if (iter==sysDef->effectHandlers.end()) return false;
|
||||
EffectHandler handler=iter->second;
|
||||
int val=0;
|
||||
int val2=0;
|
||||
try {
|
||||
val=handler.val?handler.val(effect,effectVal):effectVal;
|
||||
val2=handler.val2?handler.val2(effect,effectVal):0;
|
||||
} catch (DivDoNotHandleEffect& e) {
|
||||
return false;
|
||||
}
|
||||
// wouldn't this cause problems if it were to return 0?
|
||||
return dispatchCmd(DivCommand(handler.dispatchCmd,ch,val,val2));
|
||||
}
|
||||
|
||||
bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char effectVal) {
|
||||
if (sysDefs[sysOfChan[ch]]==NULL) return false;
|
||||
return sysDefs[sysOfChan[ch]]->postEffectFunc(ch,effect,effectVal);
|
||||
DivSysDef* sysDef=sysDefs[sysOfChan[ch]];
|
||||
if (sysDef==NULL) return false;
|
||||
auto iter=sysDef->postEffectHandlers.find(effect);
|
||||
if (iter==sysDef->postEffectHandlers.end()) return false;
|
||||
EffectHandler handler=iter->second;
|
||||
int val=0;
|
||||
int val2=0;
|
||||
try {
|
||||
val=handler.val?handler.val(effect,effectVal):effectVal;
|
||||
val2=handler.val2?handler.val2(effect,effectVal):0;
|
||||
} catch (DivDoNotHandleEffect& e) {
|
||||
return true;
|
||||
}
|
||||
// wouldn't this cause problems if it were to return 0?
|
||||
return dispatchCmd(DivCommand(handler.dispatchCmd,ch,val,val2));
|
||||
}
|
||||
|
||||
void DivEngine::processRow(int i, bool afterDelay) {
|
||||
|
|
@ -609,9 +635,6 @@ void DivEngine::processRow(int i, bool afterDelay) {
|
|||
clockDrift=0;
|
||||
subticks=0;
|
||||
break;
|
||||
case 0xdf: // set sample direction
|
||||
dispatchCmd(DivCommand(DIV_CMD_SAMPLE_DIR,i,effectVal));
|
||||
break;
|
||||
case 0xe0: // arp speed
|
||||
if (effectVal>0) {
|
||||
curSubSong->arpLen=effectVal;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue