From 61f332cac56bf7717adef78e0807e4813bd994aa Mon Sep 17 00:00:00 2001 From: Morio Date: Mon, 11 Dec 2023 16:49:05 -0800 Subject: [PATCH] Fix SCSI ID reporting using dip switch setting There was a bug where the hardware preset settings were being applied no matter if direct/raw mode was enabled or disabled and the dip switch set SCSI ID was being reported in the wrong mode. This fixes the bug and reports the SCSI ID in the correct mode. It also changes the text of the DIP switch settings. --- .../ZuluSCSI_platform.cpp | 8 +- .../platform_hw_config.cpp | 82 +++++++++---------- src/ZuluSCSI.cpp | 1 + 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp b/lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp index fae52f6d..99bbdd9c 100644 --- a/lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp +++ b/lib/ZuluSCSI_platform_GD32F205/ZuluSCSI_platform.cpp @@ -343,7 +343,7 @@ static void set_termination(uint32_t port, uint32_t pin, const char *switch_name } else { - logmsg(switch_name, "is OFF: SCSI termination disabled"); + logmsg(switch_name, " is OFF: Disabling SCSI termination"); } } @@ -351,9 +351,10 @@ static bool get_debug(uint32_t port, uint32_t pin, const char *switch_name) { if (gpio_input_bit_get(port, pin)) { - logmsg(switch_name, " is ON: enabling debug messages"); + logmsg(switch_name, " is ON: Enabling debug messages"); return true; } + logmsg(switch_name, " is OFF: Disabling debug messages"); return false; } @@ -361,9 +362,10 @@ static bool get_quirks(uint32_t port, uint32_t pin, const char *switch_name) { if (gpio_input_bit_get(port, pin)) { - logmsg(switch_name, " is ON: enabling Apple quirks by default"); + logmsg(switch_name, " is ON: Enabling Apple quirks by default"); return true; } + logmsg(switch_name, " is OFF: Disabling Apple quirks mode by default"); return false; } diff --git a/lib/ZuluSCSI_platform_GD32F205/platform_hw_config.cpp b/lib/ZuluSCSI_platform_GD32F205/platform_hw_config.cpp index a9fc277f..66023417 100644 --- a/lib/ZuluSCSI_platform_GD32F205/platform_hw_config.cpp +++ b/lib/ZuluSCSI_platform_GD32F205/platform_hw_config.cpp @@ -58,50 +58,50 @@ void HardwareConfig::init_gpios() void HardwareConfig::init_state(bool is_active) { m_is_active = is_active; - m_scsi_id = (gpio_input_port_get(DIPSW_SCSI_ID_BIT_PORT) & DIPSW_SCSI_ID_BIT_PINS) >> DIPSW_SCSI_ID_BIT_SHIFT; - m_device_preset = DEV_PRESET_NONE; - logmsg("SCSI ID set via DIP switch to ", m_scsi_id); - scsi_device_settings_t &cfg_dev = *g_scsi_settings.getDevice(m_scsi_id); - - uint8_t rotary_select = (gpio_input_port_get(DIPROT_DEVICE_SEL_BIT_PORT) & DIPROT_DEVICE_SEL_BIT_PINS) >> DIPROT_DEVICE_SEL_BIT_SHIFT; - switch (rotary_select) - { - case 0: - cfg_dev.deviceType = S2S_CFG_FIXED; - break; - case 1: - cfg_dev.deviceType = S2S_CFG_OPTICAL; - break; - case 2: - cfg_dev.deviceType = S2S_CFG_FLOPPY_14MB; - break; - case 3: - cfg_dev.deviceType = S2S_CFG_REMOVABLE; - break; - case 4: - cfg_dev.deviceType = S2S_CFG_MO; - break; - case 5: - m_device_preset = DEV_PRESET_ST32430N; - cfg_dev.deviceType = S2S_CFG_FIXED; - break; - case 6: - cfg_dev.deviceType = S2S_CFG_SEQUENTIAL; - break; - default: - cfg_dev.deviceType = S2S_CFG_FIXED; - } - - if (cfg_dev.deviceType == S2S_CFG_OPTICAL) + if (m_is_active) { - m_blocksize = DEFAULT_BLOCKSIZE_OPTICAL; - } - else - { - m_blocksize = RAW_FALLBACK_BLOCKSIZE; - } + m_scsi_id = (gpio_input_port_get(DIPSW_SCSI_ID_BIT_PORT) & DIPSW_SCSI_ID_BIT_PINS) >> DIPSW_SCSI_ID_BIT_SHIFT; + m_device_preset = DEV_PRESET_NONE; + scsi_device_settings_t &cfg_dev = *g_scsi_settings.getDevice(m_scsi_id); + uint8_t rotary_select = (gpio_input_port_get(DIPROT_DEVICE_SEL_BIT_PORT) & DIPROT_DEVICE_SEL_BIT_PINS) >> DIPROT_DEVICE_SEL_BIT_SHIFT; + switch (rotary_select) + { + case 0: + cfg_dev.deviceType = S2S_CFG_FIXED; + break; + case 1: + cfg_dev.deviceType = S2S_CFG_OPTICAL; + break; + case 2: + cfg_dev.deviceType = S2S_CFG_FLOPPY_14MB; + break; + case 3: + cfg_dev.deviceType = S2S_CFG_REMOVABLE; + break; + case 4: + cfg_dev.deviceType = S2S_CFG_MO; + break; + case 5: + m_device_preset = DEV_PRESET_ST32430N; + cfg_dev.deviceType = S2S_CFG_FIXED; + break; + case 6: + cfg_dev.deviceType = S2S_CFG_SEQUENTIAL; + break; + default: + cfg_dev.deviceType = S2S_CFG_FIXED; + } + if (cfg_dev.deviceType == S2S_CFG_OPTICAL) + { + m_blocksize = DEFAULT_BLOCKSIZE_OPTICAL; + } + else + { + m_blocksize = RAW_FALLBACK_BLOCKSIZE; + } + } } #endif // ZULUSCSI_HARDWARE_CONFIG \ No newline at end of file diff --git a/src/ZuluSCSI.cpp b/src/ZuluSCSI.cpp index 2f49f844..ccb76f2b 100644 --- a/src/ZuluSCSI.cpp +++ b/src/ZuluSCSI.cpp @@ -652,6 +652,7 @@ static void reinitSCSI() g_scsi_settings.initDevice(scsiId, g_hw_config.device_type()); logmsg("Direct/Raw mode enabled, using hardware switches for configuration"); + logmsg("-- SCSI ID set via DIP switch to ", (int) g_hw_config.scsi_id()); char raw_filename[32]; uint32_t start = g_scsi_settings.getDevice(scsiId)->sectorSDBegin; uint32_t end = g_scsi_settings.getDevice(scsiId)->sectorSDEnd;