From e4ad569f8d097d8afef9f1bb47e8d6ea9e724250 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 24 Feb 2022 16:53:20 -0500 Subject: [PATCH] Lynx: fix stereo --- src/engine/platform/lynx.cpp | 35 +++++++++++++++++++++-------------- src/engine/platform/lynx.h | 4 +++- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/engine/platform/lynx.cpp b/src/engine/platform/lynx.cpp index eee2b2e2..856950f9 100644 --- a/src/engine/platform/lynx.cpp +++ b/src/engine/platform/lynx.cpp @@ -30,6 +30,7 @@ #define WRITE_CONTROL(ch,v) rWrite(0x25+(ch<<3),(v)) #define WRITE_OTHER(ch,v) rWrite(0x27+(ch<<3),(v)) #define WRITE_ATTEN(ch,v) rWrite((0x40+ch),(v)) +#define WRITE_STEREO(v) rWrite(0x50,(v)) #define CHIP_DIVIDER 64 @@ -88,9 +89,9 @@ const char* regCheatSheetLynx[]={ const char** DivPlatformLynx::getRegisterSheet() { return regCheatSheetLynx; -} - -const char* DivPlatformLynx::getEffectName(unsigned char effect) { +} + +const char* DivPlatformLynx::getEffectName(unsigned char effect) { switch (effect) { case 0x30: case 0x31: case 0x32: case 0x33: @@ -197,7 +198,8 @@ int DivPlatformLynx::dispatch(DivCommand c) { } break; case DIV_CMD_PANNING: - WRITE_ATTEN(c.chan, c.value); + chan[c.chan].pan=((c.value&0x0f)<<4)|((c.value&0xf0)>>4); + WRITE_ATTEN(c.chan,chan[c.chan].pan); break; case DIV_CMD_GET_VOLUME: if (chan[c.chan].std.hasVol) { @@ -261,6 +263,10 @@ void DivPlatformLynx::muteChannel(int ch, bool mute) { if (chan[ch].active) WRITE_VOLUME(ch,(isMuted[ch]?0:(chan[ch].outVol&127))); } +bool DivPlatformLynx::isStereo() { + return true; +} + void DivPlatformLynx::forceIns() { for (int i=0; i<4; i++) { if (chan[i].active) { @@ -272,16 +278,16 @@ void DivPlatformLynx::forceIns() { void* DivPlatformLynx::getChanState(int ch) { return &chan[ch]; -} - -unsigned char* DivPlatformLynx::getRegisterPool() -{ - return const_cast( mikey->getRegisterPool() ); -} - -int DivPlatformLynx::getRegisterPoolSize() -{ - return 4*8+4; +} + +unsigned char* DivPlatformLynx::getRegisterPool() +{ + return const_cast( mikey->getRegisterPool() ); +} + +int DivPlatformLynx::getRegisterPoolSize() +{ + return 4*8+4; } void DivPlatformLynx::reset() { @@ -294,6 +300,7 @@ void DivPlatformLynx::reset() { if (dumpWrites) { addWrite(0xffffffff,0); } + WRITE_STEREO(0); } bool DivPlatformLynx::keyOffAffectsArp(int ch) { diff --git a/src/engine/platform/lynx.h b/src/engine/platform/lynx.h index 8ad2bf2c..536a874a 100644 --- a/src/engine/platform/lynx.h +++ b/src/engine/platform/lynx.h @@ -45,7 +45,7 @@ class DivPlatformLynx: public DivDispatch { MikeyFreqDiv fd; MikeyDuty duty; int baseFreq, pitch, note, actualNote, lfsr; - unsigned char ins; + unsigned char ins, pan; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta; signed char vol, outVol; Channel(): @@ -58,6 +58,7 @@ class DivPlatformLynx: public DivDispatch { actualNote(0), lfsr(-1), ins(-1), + pan(0xff), active(false), insChanged(true), freqChanged(false), @@ -81,6 +82,7 @@ class DivPlatformLynx: public DivDispatch { void forceIns(); void tick(); void muteChannel(int ch, bool mute); + bool isStereo(); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); //int getPortaFloor(int ch);