diff --git a/doc/7-systems/c64.md b/doc/7-systems/c64.md index 28a69671b..1688f5e70 100644 --- a/doc/7-systems/c64.md +++ b/doc/7-systems/c64.md @@ -47,6 +47,7 @@ two versions of aforementioned chip exist - 6581 (original chip) and 8580 (impro - if `y` is not 0: now - this effect is not necessary if the instrument's duty macro is absolute. - `1Exy`: **change additional parameters.** + - _this effect only exists for compatibility reasons, and its use is discouraged._ - `x` may be one of the following: - `0`: attack (`y` from `0` to `F`) - `1`: decay (`y` from `0` to `F`) @@ -55,6 +56,12 @@ two versions of aforementioned chip exist - 6581 (original chip) and 8580 (impro - `4`: ring modulation (`y` is `0` or `1`) - `5`: oscillator sync (`y` is `0` or `1`) - `6`: disable channel 3 (`y` is `0` or `1`) +- `20xy`: **set attack/decay.** + - `x` is the attack. + - `y` is the decay. +- `21xy`: **set sustain/release.** + - `x` is the sustain. + - `y` is the release. - `3xxx`: **set duty cycle.** `xxx` range is `000` to `FFF`. - `4xxx`: **set cutoff.** `xxx` range is `000` to `7FF`. diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index 3f2dda6b1..6f2119356 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -238,6 +238,9 @@ enum DivDispatchCmds { DIV_CMD_EXTERNAL, // (value) + DIV_CMD_C64_AD, // (value) + DIV_CMD_C64_SR, // (value) + DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol DIV_CMD_MAX diff --git a/src/engine/platform/c64.cpp b/src/engine/platform/c64.cpp index a7e2e3e03..cfabd2049 100644 --- a/src/engine/platform/c64.cpp +++ b/src/engine/platform/c64.cpp @@ -493,6 +493,16 @@ int DivPlatformC64::dispatch(DivCommand c) { break; } break; + case DIV_CMD_C64_AD: + chan[c.chan].attack=c.value>>4; + chan[c.chan].decay=c.value&15; + rWrite(c.chan*7+5,(chan[c.chan].attack<<4)|(chan[c.chan].decay)); + break; + case DIV_CMD_C64_SR: + chan[c.chan].sustain=c.value>>4; + chan[c.chan].release=c.value&15; + rWrite(c.chan*7+6,(chan[c.chan].sustain<<4)|(chan[c.chan].release)); + break; case DIV_CMD_MACRO_OFF: chan[c.chan].std.mask(c.value,true); break; diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 438641797..de5c58a22 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -239,6 +239,9 @@ const char* cmdName[]={ "EXTERNAL", + "C64_AD", + "C64_SR", + "ALWAYS_SET_VOLUME" }; diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index d4a58dcad..410a4203b 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -598,6 +598,8 @@ void DivEngine::registerSystems() { {0x1b, {DIV_CMD_C64_FILTER_RESET, "1Bxy: Reset cutoff (x: on new note; y: now)"}}, {0x1c, {DIV_CMD_C64_DUTY_RESET, "1Cxy: Reset pulse width (x: on new note; y: now)"}}, {0x1e, {DIV_CMD_C64_EXTENDED, "1Exy: Change additional parameters"}}, + {0x20, {DIV_CMD_C64_AD, "20xy: Set attack/decay (x: attack; y: decay)"}}, + {0x21, {DIV_CMD_C64_SR, "21xy: Set sustain/release (x: sustain; y: release)"}}, }; const EffectHandler c64FineDutyHandler(DIV_CMD_C64_FINE_DUTY, "3xxx: Set pulse width (0 to FFF)", effectValLong<12>); const EffectHandler c64FineCutoffHandler(DIV_CMD_C64_FINE_CUTOFF, "4xxx: Set cutoff (0 to 7FF)", effectValLong<11>);