From c777d699d24c4d57aced6053ccd9c033202cb43b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 20 Jun 2023 14:43:20 -0500 Subject: [PATCH] POKEY: implement two-tone mode effect --- doc/7-systems/pokey.md | 3 +++ src/engine/platform/pokey.cpp | 15 ++++++++++++++- src/engine/platform/pokey.h | 4 ++-- src/engine/sysDef.cpp | 1 + 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/doc/7-systems/pokey.md b/doc/7-systems/pokey.md index b05c4367..efebfcd3 100644 --- a/doc/7-systems/pokey.md +++ b/doc/7-systems/pokey.md @@ -32,3 +32,6 @@ a sound and input chip developed by Atari for their 8-bit computers (Atari 400, - filtered output on channel 2 (I suggest you to set channel 4 volume to 0). - use for PWM effects (not automatic!). - bit 0: 15KHz mode. +- 12xx: toggle two-tone mode. + - when enabled, channel 2 modulates channel 1. I don't know how, but it does. + - only on ASAP core. diff --git a/src/engine/platform/pokey.cpp b/src/engine/platform/pokey.cpp index d03fa6de..790346e1 100644 --- a/src/engine/platform/pokey.cpp +++ b/src/engine/platform/pokey.cpp @@ -35,6 +35,7 @@ const char* regCheatSheetPOKEY[]={ "AUDF4", "6", "AUDC4", "7", "AUDCTL", "8", + "SKCTL", "F", NULL }; @@ -154,6 +155,11 @@ void DivPlatformPOKEY::tick(bool sysTick) { } } + if (skctlChanged) { + skctlChanged=false; + rWrite(15,skctl); + } + for (int i=0; i<4; i++) { if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { chan[i].freq=parent->calcFreq(chan[i].baseFreq,parent->song.linearPitch?chan[i].pitch:0,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,parent->song.linearPitch?chan[i].pitch2:0,chipClock,CHIP_DIVIDER); @@ -320,6 +326,10 @@ int DivPlatformPOKEY::dispatch(DivCommand c) { audctl=c.value&0xff; audctlChanged=true; break; + case DIV_CMD_STD_NOISE_FREQ: + skctl=c.value?0x8b:0x03; + skctlChanged=true; + break; case DIV_CMD_NOTE_PORTA: { int destFreq=NOTE_PERIODIC(c.value2); bool return2=false; @@ -385,6 +395,7 @@ void DivPlatformPOKEY::forceIns() { chan[i].freqChanged=true; } audctlChanged=true; + skctlChanged=true; } void* DivPlatformPOKEY::getChanState(int ch) { @@ -408,7 +419,7 @@ unsigned char* DivPlatformPOKEY::getRegisterPool() { } int DivPlatformPOKEY::getRegisterPoolSize() { - return 9; + return 16; } void DivPlatformPOKEY::reset() { @@ -430,6 +441,8 @@ void DivPlatformPOKEY::reset() { audctl=0; audctlChanged=true; + skctl=3; + skctlChanged=true; } bool DivPlatformPOKEY::keyOffAffectsArp(int ch) { diff --git a/src/engine/platform/pokey.h b/src/engine/platform/pokey.h index f24ea56c..b5087517 100644 --- a/src/engine/platform/pokey.h +++ b/src/engine/platform/pokey.h @@ -48,8 +48,8 @@ class DivPlatformPOKEY: public DivDispatch { QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} }; std::queue writes; - unsigned char audctl; - bool audctlChanged; + unsigned char audctl, skctl; + bool audctlChanged, skctlChanged; unsigned char oscBufDelay; PokeyState pokey; AltASAP::Pokey altASAP; diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index c590ba10..f4d76ceb 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1169,6 +1169,7 @@ void DivEngine::registerSystems() { { {0x10, {DIV_CMD_WAVE, "10xx: Set waveform (0 to 7)"}}, {0x11, {DIV_CMD_STD_NOISE_MODE, "11xx: Set AUDCTL"}}, + {0x12, {DIV_CMD_STD_NOISE_FREQ, "12xx: Toggle two-tone mode"}}, } );