From f54d9a5840f38422347f87d5e352480764373cb0 Mon Sep 17 00:00:00 2001 From: wbcbz7 Date: Sat, 21 Mar 2026 20:34:00 +0700 Subject: [PATCH] SB: add registers for setting DSP version, IRQ/DMA settings readback and emulation options --- common/picogus.h | 4 ++++ sw/picogus.cpp | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/common/picogus.h b/common/picogus.h index b84af96..b874baa 100644 --- a/common/picogus.h +++ b/common/picogus.h @@ -68,6 +68,10 @@ static const char *modenames[8] = { #define CMD_MPUFAKE 0x22 // MPU fake all notes off #define CMD_OPLWAIT 0x30 // Adlib speed sensitive fix +#define CMD_SBOPTS 0x30 // SB options (mixer lock, time constant fix, etc.) - aliased to CMD_OPLWAIT +#define CMD_SBDSPVER 0x31 // SB DSP version +#define CMD_SBIRQ 0x32 // SB IRQ +#define CMD_SBDMA 0x33 // SB DMA #define CMD_MOUSEPORT 0x40 // Mouse Base port #define CMD_MOUSEPROTO 0x41 // Mouse protocol diff --git a/sw/picogus.cpp b/sw/picogus.cpp index 6c75e82..3738974 100644 --- a/sw/picogus.cpp +++ b/sw/picogus.cpp @@ -172,7 +172,8 @@ void processSettings(void); const char* firmware_string = PICO_PROGRAM_NAME " v" PICO_PROGRAM_VERSION_STRING; static uint8_t basePort_low; -static uint8_t mouseSensitivity_low; +static uint8_t mouseSensitivity_low; +static uint8_t picogus_dataLatch_low; __force_inline void select_picogus(uint8_t value) { // printf("select picogus %x\n", value); @@ -243,6 +244,13 @@ __force_inline void select_picogus(uint8_t value) { cur_read_idx = 0; #endif break; +#ifdef SOUND_SB + case CMD_SBDSPVER: + picogus_dataLatch_low = 0; + case CMD_SBIRQ: + case CMD_SBDMA: + break; +#endif case CMD_CDSTATUS: case CMD_CDLOAD: case CMD_CDAUTOADV: @@ -288,6 +296,12 @@ __force_inline void write_picogus_low(uint8_t value) { case CMD_MOUSESEN: // USB Mouse Sensitivity (8.8 fixedpoint) mouseSensitivity_low = value; break; +#ifdef SOUND_SB + case CMD_SBDSPVER: + picogus_dataLatch_low = value; + break; +#endif + break; } } @@ -358,7 +372,26 @@ __force_inline void write_picogus_high(uint8_t value) { #endif break; case CMD_OPLWAIT: // Adlib speed sensitive fix - settings.SB.oplSpeedSensitive = value; + //case CMD_SBOPTS: // ... and SB emulation options + settings.SB.oplSpeedSensitive = value & 1; // HACK until settings struct resolved +#ifdef SOUND_SB + sbdsp_set_options(value); +#endif + break; + case CMD_SBDSPVER: +#ifdef SOUND_SB + sbdsp_set_dsp_version((value << 8) | picogus_dataLatch_low); +#endif + break; + case CMD_SBIRQ: +#ifdef SOUND_SB + sbdsp_set_irq(value); +#endif + break; + case CMD_SBDMA: +#ifdef SOUND_SB + sbdsp_set_dma(value); +#endif break; case CMD_MOUSEPORT: // USB Mouse port (0 - disabled) settings.Mouse.basePort = (value || basePort_low) ? ((value << 8) | basePort_low) : 0xFFFF;