C64: 20xy and 21xy for setting ADSR

dropping DefleJank
This commit is contained in:
tildearrow 2023-10-23 13:49:03 -05:00
parent aad3557693
commit 6dddee40d5
5 changed files with 25 additions and 0 deletions

View file

@ -47,6 +47,7 @@ two versions of aforementioned chip exist - 6581 (original chip) and 8580 (impro
- if `y` is not 0: now - if `y` is not 0: now
- this effect is not necessary if the instrument's duty macro is absolute. - this effect is not necessary if the instrument's duty macro is absolute.
- `1Exy`: **change additional parameters.** - `1Exy`: **change additional parameters.**
- _this effect only exists for compatibility reasons, and its use is discouraged._
- `x` may be one of the following: - `x` may be one of the following:
- `0`: attack (`y` from `0` to `F`) - `0`: attack (`y` from `0` to `F`)
- `1`: decay (`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`) - `4`: ring modulation (`y` is `0` or `1`)
- `5`: oscillator sync (`y` is `0` or `1`) - `5`: oscillator sync (`y` is `0` or `1`)
- `6`: disable channel 3 (`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`. - `3xxx`: **set duty cycle.** `xxx` range is `000` to `FFF`.
- `4xxx`: **set cutoff.** `xxx` range is `000` to `7FF`. - `4xxx`: **set cutoff.** `xxx` range is `000` to `7FF`.

View file

@ -238,6 +238,9 @@ enum DivDispatchCmds {
DIV_CMD_EXTERNAL, // (value) DIV_CMD_EXTERNAL, // (value)
DIV_CMD_C64_AD, // (value)
DIV_CMD_C64_SR, // (value)
DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol DIV_ALWAYS_SET_VOLUME, // () -> alwaysSetVol
DIV_CMD_MAX DIV_CMD_MAX

View file

@ -493,6 +493,16 @@ int DivPlatformC64::dispatch(DivCommand c) {
break; break;
} }
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: case DIV_CMD_MACRO_OFF:
chan[c.chan].std.mask(c.value,true); chan[c.chan].std.mask(c.value,true);
break; break;

View file

@ -239,6 +239,9 @@ const char* cmdName[]={
"EXTERNAL", "EXTERNAL",
"C64_AD",
"C64_SR",
"ALWAYS_SET_VOLUME" "ALWAYS_SET_VOLUME"
}; };

View file

@ -598,6 +598,8 @@ void DivEngine::registerSystems() {
{0x1b, {DIV_CMD_C64_FILTER_RESET, "1Bxy: Reset cutoff (x: on new note; y: now)"}}, {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)"}}, {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"}}, {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 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>); const EffectHandler c64FineCutoffHandler(DIV_CMD_C64_FINE_CUTOFF, "4xxx: Set cutoff (0 to 7FF)", effectValLong<11>);