From 391855860c75cb1aa9eed0109b34aa8bdd6d5da9 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 3 Jan 2017 02:35:24 +0100 Subject: [PATCH] SCSI controller model is now switchable between Adaptec AHA-154x and the BusLogic BT-542B. --- src/buslogic.c | 3 ++- src/pc.c | 2 ++ src/pc.rc | 5 +++++ src/resources.h | 32 +++++++++++++++++--------------- src/win.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/buslogic.c b/src/buslogic.c index 6b1bdd670..03dd1106d 100644 --- a/src/buslogic.c +++ b/src/buslogic.c @@ -515,6 +515,7 @@ typedef struct __attribute__((packed)) Buslogic_t int Mbx24bit; } Buslogic_t; +int scsi_model = 1; int scsi_base = 0x330; int scsi_dma = 6; int scsi_irq = 11; @@ -1034,7 +1035,7 @@ void BuslogicWrite(uint16_t Port, uint8_t Val, void *p) case 0x04: Buslogic->DataBuf[0] = 0x41; - Buslogic->DataBuf[1] = 0x41; + Buslogic->DataBuf[1] = scsi_model ? 0x41 : 0x30; Buslogic->DataBuf[2] = '5'; Buslogic->DataBuf[3] = '0'; Buslogic->DataReplyLeft = 4; diff --git a/src/pc.c b/src/pc.c index be914d36b..7669af806 100644 --- a/src/pc.c +++ b/src/pc.c @@ -641,6 +641,7 @@ void loadconfig(char *fn) voodoo_enabled = config_get_int(NULL, "voodoo", 0); buslogic_enabled = config_get_int(NULL, "buslogic", 0); + scsi_model = config_get_int(NULL, "scsi_model", 1); scsi_base = config_get_int(NULL, "scsi_base", 0x330); scsi_irq = config_get_int(NULL, "scsi_irq", 11); scsi_dma = config_get_int(NULL, "scsi_dma", 6); @@ -846,6 +847,7 @@ void saveconfig() config_set_int(NULL, "voodoo", voodoo_enabled); config_set_int(NULL, "buslogic", buslogic_enabled); + config_set_int(NULL, "scsi_model", scsi_model); config_set_int(NULL, "scsi_base", scsi_base); config_set_int(NULL, "scsi_irq", scsi_irq); config_set_int(NULL, "scsi_dma", scsi_dma); diff --git a/src/pc.rc b/src/pc.rc index 0c98dd3b1..165dc8274 100644 --- a/src/pc.rc +++ b/src/pc.rc @@ -71,6 +71,11 @@ BEGIN POPUP "&SCSI controller" BEGIN MENUITEM "&Enabled",IDM_SCSI_ENABLED + POPUP "&Model" + BEGIN + MENUITEM "&Adaptec AHA-154x",IDM_SCSI_MODEL0 + MENUITEM "&BusLogic BT-542B",IDM_SCSI_MODEL1 + END POPUP "&Base address" BEGIN MENUITEM "0x&130",IDM_SCSI_BASE130 diff --git a/src/resources.h b/src/resources.h index 26a26020f..083275bfd 100644 --- a/src/resources.h +++ b/src/resources.h @@ -55,21 +55,23 @@ #define IDM_IDE_QUA_IRQ14 40512 #define IDM_IDE_QUA_IRQ15 40513 #define IDM_SCSI_ENABLED 40600 -#define IDM_SCSI_BASE130 40601 -#define IDM_SCSI_BASE134 40602 -#define IDM_SCSI_BASE230 40603 -#define IDM_SCSI_BASE234 40604 -#define IDM_SCSI_BASE330 40605 -#define IDM_SCSI_BASE334 40606 -#define IDM_SCSI_IRQ9 40607 -#define IDM_SCSI_IRQ10 40608 -#define IDM_SCSI_IRQ11 40609 -#define IDM_SCSI_IRQ12 40610 -#define IDM_SCSI_IRQ14 40611 -#define IDM_SCSI_IRQ15 40612 -#define IDM_SCSI_DMA5 40613 -#define IDM_SCSI_DMA6 40614 -#define IDM_SCSI_DMA7 40615 +#define IDM_SCSI_MODEL0 40601 +#define IDM_SCSI_MODEL1 40602 +#define IDM_SCSI_BASE130 40603 +#define IDM_SCSI_BASE134 40604 +#define IDM_SCSI_BASE230 40605 +#define IDM_SCSI_BASE234 40606 +#define IDM_SCSI_BASE330 40607 +#define IDM_SCSI_BASE334 40608 +#define IDM_SCSI_IRQ9 40609 +#define IDM_SCSI_IRQ10 40610 +#define IDM_SCSI_IRQ11 40611 +#define IDM_SCSI_IRQ12 40612 +#define IDM_SCSI_IRQ14 40613 +#define IDM_SCSI_IRQ15 40614 +#define IDM_SCSI_DMA5 40615 +#define IDM_SCSI_DMA6 40616 +#define IDM_SCSI_DMA7 40617 #define IDC_COMBO1 1000 #define IDC_COMBOVID 1001 diff --git a/src/win.c b/src/win.c index 6ae987587..88b067960 100644 --- a/src/win.c +++ b/src/win.c @@ -708,6 +708,22 @@ int WINAPI WinMain (HINSTANCE hThisInstance, if (buslogic_enabled) CheckMenuItem(menu, IDM_SCSI_ENABLED, MF_CHECKED); + CheckMenuItem(menu, IDM_SCSI_MODEL0, MF_UNCHECKED); + CheckMenuItem(menu, IDM_SCSI_MODEL1, MF_UNCHECKED); + + if (scsi_model == 0) + { + CheckMenuItem(menu, IDM_SCSI_MODEL0, MF_CHECKED); + } + else if (scsi_model == 1) + { + CheckMenuItem(menu, IDM_SCSI_MODEL1, MF_CHECKED); + } + else + { + fatal("Unrecognized SCSI model\n"); + } + CheckMenuItem(menu, IDM_SCSI_BASE130, MF_UNCHECKED); CheckMenuItem(menu, IDM_SCSI_BASE134, MF_UNCHECKED); CheckMenuItem(menu, IDM_SCSI_BASE230, MF_UNCHECKED); @@ -1192,6 +1208,28 @@ int ide_qua_set_irq(HMENU hmenu, int irq, int id) return 1; } +int scsi_set_model(HMENU hmenu, int model, int id) +{ + if (scsi_model == model) + { + return 0; + } + if (MessageBox(NULL,"This will reset 86Box!\nOkay to continue?","86Box",MB_OKCANCEL) != IDOK) + { + return 0; + } + pause = 1; + Sleep(100); + scsi_model = model; + CheckMenuItem(hmenu, IDM_SCSI_MODEL0, MF_UNCHECKED); + CheckMenuItem(hmenu, IDM_SCSI_MODEL1, MF_UNCHECKED); + CheckMenuItem(hmenu, id, MF_CHECKED); + saveconfig(); + resetpchard(); + pause = 0; + return 1; +} + int scsi_set_base(HMENU hmenu, int base, int id) { if (scsi_base == base) @@ -1643,6 +1681,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM pause = 0; break; + case IDM_SCSI_MODEL0: + scsi_set_base(hmenu, 0, IDM_SCSI_MODEL0); + break; + + case IDM_SCSI_MODEL1: + scsi_set_base(hmenu, 1, IDM_SCSI_MODEL1); + break; + case IDM_SCSI_BASE130: scsi_set_base(hmenu, 0x130, IDM_SCSI_BASE130); break;