From 9632f99552a0c31ab91cd0b4f63963248800fe8c Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Wed, 4 Aug 2021 13:46:26 +0500 Subject: [PATCH] Make the Game Blaster's I/O address configurable --- src/include/86box/resource.h | 1 + src/sound/snd_cms.c | 38 ++++++++++++++++++++++++++++++++++-- src/win/86Box.rc | 10 ++++++---- src/win/win_settings.c | 11 +++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index 7ce6edd18..3e5754e36 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -163,6 +163,7 @@ #define IDC_CHECK_FLOAT 1048 #define IDC_CONFIGURE_GUS 1049 #define IDC_COMBO_MIDI_IN 1050 +#define IDC_CONFIGURE_CMS 1051 #define IDC_COMBO_NET_TYPE 1060 /* network config */ #define IDC_COMBO_PCAP 1061 diff --git a/src/sound/snd_cms.c b/src/sound/snd_cms.c index 61278fa88..dae1f735f 100644 --- a/src/sound/snd_cms.c +++ b/src/sound/snd_cms.c @@ -181,7 +181,8 @@ void *cms_init(const device_t *info) cms_t *cms = malloc(sizeof(cms_t)); memset(cms, 0, sizeof(cms_t)); - io_sethandler(0x0220, 0x0010, cms_read, NULL, NULL, cms_write, NULL, NULL, cms); + uint16_t addr = device_get_config_hex16("base"); + io_sethandler(addr, 0x0010, cms_read, NULL, NULL, cms_write, NULL, NULL, cms); sound_add_handler(cms_get_buffer, cms); return cms; } @@ -193,11 +194,44 @@ void cms_close(void *p) free(cms); } +static const device_config_t cms_config[] = +{ + { + "base", "Address", CONFIG_HEX16, "", 0x220, "", { 0 }, + { + { + "0x210", 0x210 + }, + { + "0x220", 0x220 + }, + { + "0x230", 0x230 + }, + { + "0x240", 0x240 + }, + { + "0x250", 0x250 + }, + { + "0x260", 0x260 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + const device_t cms_device = { "Creative Music System / Game Blaster", 0, 0, cms_init, cms_close, NULL, { NULL }, NULL, NULL, - NULL + cms_config }; diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 2ee41aec1..736bd33b4 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -517,15 +517,17 @@ BEGIN CONTROL "Innovation SSI-2001",IDC_CHECK_SSI,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,84,95,10 + CONTROL "CMS / Game Blaster",IDC_CHECK_CMS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,147,84,95,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,102,95,10 + PUSHBUTTON "Configure",IDC_CONFIGURE_CMS,214,100,46,12 CONTROL "Gravis Ultrasound",IDC_CHECK_GUS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,101,94,10 - PUSHBUTTON "Configure",IDC_CONFIGURE_GUS,214,101,46,12 + BS_AUTOCHECKBOX | WS_TABSTOP,7,120,94,10 + PUSHBUTTON "Configure",IDC_CONFIGURE_GUS,214,118,46,12 CONTROL "Use FLOAT32 sound",IDC_CHECK_FLOAT,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,117,94,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,138,94,10 END DLG_CFG_NETWORK DIALOG DISCARDABLE 107, 0, 267, 65 diff --git a/src/win/win_settings.c b/src/win/win_settings.c index 811493a6a..4a7dbc0bb 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -1376,6 +1376,7 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) settings_enable_window(hdlg, IDC_CHECK_MPU401, mpu401_standalone_allow()); settings_enable_window(hdlg, IDC_CONFIGURE_MPU401, mpu401_standalone_allow() && temp_mpu401); settings_set_check(hdlg, IDC_CHECK_CMS, temp_GAMEBLASTER); + settings_enable_window(hdlg, IDC_CONFIGURE_CMS, temp_GAMEBLASTER); settings_set_check(hdlg, IDC_CHECK_GUS, temp_GUS); settings_enable_window(hdlg, IDC_CONFIGURE_GUS, temp_GUS); settings_set_check(hdlg, IDC_CHECK_SSI, temp_SSI2001); @@ -1437,6 +1438,16 @@ win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) (void *)&mpu401_mca_device : (void *)&mpu401_device); break; + case IDC_CHECK_CMS: + temp_GAMEBLASTER = settings_get_check(hdlg, IDC_CHECK_CMS); + + settings_enable_window(hdlg, IDC_CONFIGURE_CMS, temp_GAMEBLASTER); + break; + + case IDC_CONFIGURE_CMS: + temp_deviceconfig |= deviceconfig_open(hdlg, &cms_device); + break; + case IDC_CHECK_GUS: temp_GUS = settings_get_check(hdlg, IDC_CHECK_GUS); settings_enable_window(hdlg, IDC_CONFIGURE_GUS, temp_GUS);