diff --git a/src/SOUND/snd_mpu401.c b/src/SOUND/snd_mpu401.c index c5c67611b..b85d646b1 100644 --- a/src/SOUND/snd_mpu401.c +++ b/src/SOUND/snd_mpu401.c @@ -21,12 +21,15 @@ */ #include "../ibm.h" +#include "../device.h" #include "../io.h" #include "../pic.h" #include "../timer.h" #include "../win/plat_midi.h" /*YUCK*/ +#include "sound.h" #include "snd_mpu401.h" +#include #include enum @@ -38,6 +41,8 @@ enum static void MPU401_WriteCommand(mpu_t *mpu, uint8_t val); static void MPU401_EOIHandlerDispatch(void *p); +int mpu401_standalone_enable = 0; + static int mpu401_event_callback = 0; static int mpu401_eoi_callback = 0; static int mpu401_reset_callback = 0; @@ -749,3 +754,118 @@ void mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode) MPU401_Reset(mpu); } + +void mpu401_device_add(void) +{ + char *n; + + if (!mpu401_standalone_enable) + { + return; + } + + n = sound_card_getname(sound_card_current); + if (n != NULL) + { + if (!strcmp(n, "sb16") || !strcmp(n, "sbawe32")) + { + return; + } + } + + device_add(&mpu401_device); +} + +void *mpu401_standalone_init() +{ + mpu_t *mpu; + + mpu = malloc(sizeof(mpu_t)); + memset(mpu, 0, sizeof(mpu_t)); + + pclog("mpu_init\n"); + mpu401_init(mpu, device_get_config_hex16("base"), device_get_config_int("irq"), device_get_config_int("mode")); + + return mpu; +} + +void mpu401_standalone_close(void *p) +{ + mpu_t *mpu = (mpu_t *)p; + + free(mpu); +} + +static device_config_t mpu401_standalone_config[] = +{ + { + "base", "MPU-401 Address", CONFIG_HEX16, "", 0x330, + { + { + "0x300", 0x300 + }, + { + "0x330", 0x330 + }, + { + "" + } + } + }, + { + "irq", "MPU-401 IRQ", CONFIG_SELECTION, "", 9, + { + { + "IRQ 9", 9 + }, + { + "IRQ 3", 3 + }, + { + "IRQ 4", 4 + }, + { + "IRQ 5", 5 + }, + { + "IRQ 7", 7 + }, + { + "IRQ 10", 10 + }, + { + "" + } + } + }, + { + "mode", "Mode", CONFIG_SELECTION, "", 1, + { + { + "UART", M_UART + }, + { + "Intelligent", M_INTELLIGENT + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + +device_t mpu401_device = +{ + "MPU-401 (Standalone)", + 0, + mpu401_standalone_init, + mpu401_standalone_close, + NULL, + NULL, + NULL, + NULL, + mpu401_standalone_config +}; diff --git a/src/SOUND/snd_mpu401.h b/src/SOUND/snd_mpu401.h index 264f2ed97..86dfa2058 100644 --- a/src/SOUND/snd_mpu401.h +++ b/src/SOUND/snd_mpu401.h @@ -83,3 +83,8 @@ typedef struct mpu_t uint8_t MPU401_ReadData(mpu_t *mpu); void mpu401_init(mpu_t *mpu, uint16_t addr, int irq, int mode); + +extern int mpu401_standalone_enable; + +void mpu401_device_add(void); +device_t mpu401_device; diff --git a/src/VIDEO/vid_s3_virge.c b/src/VIDEO/vid_s3_virge.c index d742051ae..283346da5 100644 --- a/src/VIDEO/vid_s3_virge.c +++ b/src/VIDEO/vid_s3_virge.c @@ -3925,7 +3925,7 @@ static void *s3_virge_988_init() return virge; } -static void *s3_virge_375_init() +static void *s3_virge_375_init(wchar_t *romfn) { virge_t *virge = malloc(sizeof(virge_t)); memset(virge, 0, sizeof(virge_t)); @@ -3940,7 +3940,7 @@ static void *s3_virge_375_init() s3_virge_hwcursor_draw, s3_virge_overlay_draw); - rom_init(&virge->bios_rom, L"roms/86c375_1.bin", 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); + rom_init(&virge->bios_rom, romfn, 0xc0000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); if (PCI) mem_mapping_disable(&virge->bios_rom.mapping); @@ -4021,6 +4021,16 @@ static void *s3_virge_375_init() return virge; } +static void *s3_virge_375_1_init() +{ + return s3_virge_init(L"roms/86c375_1.bin"); +} + +static void *s3_virge_375_4_init() +{ + return s3_virge_init(L"roms/86c375_4.bin"); +} + static void s3_virge_close(void *p) { virge_t *virge = (virge_t *)p; @@ -4054,11 +4064,16 @@ static int s3_virge_988_available() return rom_present(L"roms/diamondstealth3000.VBI"); } -static int s3_virge_375_available() +static int s3_virge_375_1_available() { return rom_present(L"roms/86c375_1.bin"); } +static int s3_virge_375_4_available() +{ + return rom_present(L"roms/86c375_4.bin"); +} + static void s3_virge_speed_changed(void *p) { virge_t *virge = (virge_t *)p; @@ -4190,9 +4205,22 @@ device_t s3_virge_375_device = { "S3 ViRGE/DX", 0, - s3_virge_375_init, + s3_virge_375_1_init, s3_virge_close, - s3_virge_375_available, + s3_virge_375_1_available, + s3_virge_speed_changed, + s3_virge_force_redraw, + s3_virge_add_status_info, + s3_virge_config +}; + +device_t s3_virge_375_4_device = +{ + "S3 ViRGE/DX (VBE 2.0)", + 0, + s3_virge_375_4_init, + s3_virge_close, + s3_virge_375_4_available, s3_virge_speed_changed, s3_virge_force_redraw, s3_virge_add_status_info, diff --git a/src/VIDEO/vid_s3_virge.h b/src/VIDEO/vid_s3_virge.h index 2e8dfbe91..74ee6454b 100644 --- a/src/VIDEO/vid_s3_virge.h +++ b/src/VIDEO/vid_s3_virge.h @@ -4,3 +4,4 @@ extern device_t s3_virge_device; extern device_t s3_virge_988_device; extern device_t s3_virge_375_device; +extern device_t s3_virge_375_4_device; diff --git a/src/VIDEO/video.c b/src/VIDEO/video.c index ae9e56048..07531f033 100644 --- a/src/VIDEO/video.c +++ b/src/VIDEO/video.c @@ -101,6 +101,7 @@ static VIDEO_CARD video_cards[] = {"Phoenix S3 Trio64", "px_trio64", &s3_phoenix_trio64_device, GFX_PHOENIX_TRIO64}, {"Plantronics ColorPlus", "plantronics", &colorplus_device, GFX_COLORPLUS}, {"S3 ViRGE/DX", "virge375", &s3_virge_375_device, GFX_VIRGEDX}, + {"S3 ViRGE/DX (VBE 2.0)", "virge375_vbe20", &s3_virge_375_4_device, GFX_VIRGEDX4}, {"Trident TGUI9440", "tgui9440", &tgui9440_device, GFX_TGUI9440}, {"Trident TVGA8900D", "tvga8900d", &tvga8900d_device, GFX_TVGA}, {"Tseng ET4000AX", "et4000ax", &et4000_device, GFX_ET4000}, diff --git a/src/WIN/86Box.rc b/src/WIN/86Box.rc index 380d8a423..0d8b6d8d2 100644 --- a/src/WIN/86Box.rc +++ b/src/WIN/86Box.rc @@ -327,7 +327,7 @@ BEGIN PUSHBUTTON "Joystick 4...",IDC_JOY4,209,44,50,14 END -CONFIGUREDLG_SOUND DIALOG DISCARDABLE 97, 0, 267, 78 +CONFIGUREDLG_SOUND DIALOG DISCARDABLE 97, 0, 267, 98 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN @@ -338,14 +338,20 @@ BEGIN COMBOBOX IDC_COMBO_MIDI,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "MIDI Out Device:",1801,7,26,59,10 - CONTROL "CMS / Game Blaster",IDC_CHECKCMS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,87,43,80,10 + + CONTROL "Standalone MPU-401",IDC_CHECK_MPU401,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10 + PUSHBUTTON "Configure",IDC_CONFIGURE_MPU401,214,44,46,12 + CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,43,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,63,94,10 + CONTROL "CMS / Game Blaster",IDC_CHECKCMS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,147,63,94,10 + CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,174,43,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,81,94,10 CONTROL "Use Nuked OPL",IDC_CHECKNUKEDOPL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,61,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,147,81,94,10 END CONFIGUREDLG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63 diff --git a/src/WIN/resource.h b/src/WIN/resource.h index 8541c17e1..73a8f97c4 100644 --- a/src/WIN/resource.h +++ b/src/WIN/resource.h @@ -8,7 +8,7 @@ * * Windows resource defines. * - * Version: @(#)resource.h 1.0.0 2017/05/30 + * Version: @(#)resource.h 1.0.1 2017/05/30 * * Author: Sarah Walker, * Miran Grca, @@ -51,7 +51,9 @@ #define IDC_CHECKNUKEDOPL 1018 #define IDC_COMBO_JOYSTICK 1018 #define IDC_CHECK_SYNC 1019 +#define IDC_CHECK_MPU401 1019 #define IDC_LIST_FLOPPY_DRIVES 1020 +#define IDC_CONFIGURE_MPU401 1020 #define IDC_LIST_CDROM_DRIVES 1021 #define IDC_CONFIGURE_MACHINE 1022 #define IDC_COMBO_LANG 1023 diff --git a/src/WIN/win_settings.c b/src/WIN/win_settings.c index 31d1ff303..7c187fe89 100644 --- a/src/WIN/win_settings.c +++ b/src/WIN/win_settings.c @@ -37,6 +37,7 @@ #include "../network.h" #include "../sound/sound.h" #include "../sound/snd_dbopl.h" +#include "../sound/snd_mpu401.h" #include "../video/video.h" #include "../video/vid_voodoo.h" #include "../gameport.h" @@ -56,7 +57,7 @@ static int temp_gfxcard, temp_video_speed, temp_voodoo; static int temp_mouse, temp_joystick; /* Sound category */ -static int temp_sound_card, temp_midi_id, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; +static int temp_sound_card, temp_midi_id, temp_mpu401, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; /* Network category */ static int temp_net_type, temp_net_card; @@ -117,6 +118,7 @@ static void win_settings_init(void) /* Sound category */ temp_sound_card = sound_card_current; temp_midi_id = midi_id; + temp_mpu401 = mpu401_standalone_enable; temp_SSI2001 = SSI2001; temp_GAMEBLASTER = GAMEBLASTER; temp_GUS = GUS; @@ -180,6 +182,7 @@ static int win_settings_changed(void) /* Sound category */ i = i || (sound_card_current != temp_sound_card); i = i || (midi_id != temp_midi_id); + i = i || (mpu401_standalone_enable != temp_mpu401); i = i || (SSI2001 != temp_SSI2001); i = i || (GAMEBLASTER != temp_GAMEBLASTER); i = i || (GUS != temp_GUS); @@ -275,6 +278,7 @@ static void win_settings_save(void) /* Sound category */ sound_card_current = temp_sound_card; midi_id = temp_midi_id; + mpu401_standalone_enable = temp_mpu401; SSI2001 = temp_SSI2001; GAMEBLASTER = temp_GAMEBLASTER; GUS = temp_GUS; @@ -1102,6 +1106,38 @@ int find_irq_in_array(int irq, int def) static char midi_dev_name_buf[512]; +int mpu401_present(void) +{ + char *n; + + n = sound_card_getname(temp_sound_card); + if (n != NULL) + { + if (!strcmp(n, "sb16") || !strcmp(n, "sbawe32")) + { + return 1; + } + } + + return temp_mpu401 ? 1 : 0; +} + +int mpu401_standalone_allow(void) +{ + char *n; + + n = sound_card_getname(temp_sound_card); + if (n != NULL) + { + if (!strcmp(n, "sb16") || !strcmp(n, "sbawe32")) + { + return 0; + } + } + + return 1; +} + static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; @@ -1174,6 +1210,13 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa if (c == temp_midi_id) SendMessage(h, CB_SETCURSEL, c, 0); } + EnableWindow(h, mpu401_present() ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CHECK_MPU401); + EnableWindow(h, mpu401_standalone_allow() ? TRUE : FALSE); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); + EnableWindow(h, (mpu401_standalone_allow() && temp_mpu401) ? TRUE : FALSE); h=GetDlgItem(hdlg, IDC_CHECKCMS); SendMessage(h, BM_SETCHECK, temp_GAMEBLASTER, 0); @@ -1214,6 +1257,21 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa { EnableWindow(h, FALSE); } + + h = GetDlgItem(hdlg, IDC_COMBO_MIDI); + EnableWindow(h, mpu401_present() ? TRUE : FALSE); + break; + + case IDC_CHECK_MPU401: + h = GetDlgItem(hdlg, IDC_CHECK_MPU401); + temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0); + + h = GetDlgItem(hdlg, IDC_CONFIGURE_MPU401); + EnableWindow(h, mpu401_present() ? TRUE : FALSE); + break; + + case IDC_CONFIGURE_MPU401: + deviceconfig_open(hdlg, (void *)&mpu401_device); break; } return FALSE; @@ -1225,6 +1283,9 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa h = GetDlgItem(hdlg, IDC_COMBO_MIDI); temp_midi_id = SendMessage(h, CB_GETCURSEL, 0, 0); + h = GetDlgItem(hdlg, IDC_CHECK_MPU401); + temp_mpu401 = SendMessage(h, BM_GETCHECK, 0, 0); + h = GetDlgItem(hdlg, IDC_CHECKCMS); temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0); diff --git a/src/config.c b/src/config.c index c325c3a5d..2a7913629 100644 --- a/src/config.c +++ b/src/config.c @@ -30,6 +30,7 @@ #include "win/plat_joystick.h" #include "win/plat_midi.h" #include "sound/snd_dbopl.h" +#include "sound/snd_mpu401.h" #include "sound/snd_opl.h" #include "sound/sound.h" #include "video/video.h" @@ -976,6 +977,7 @@ static void loadconfig_sound(void) sound_card_current = 0; midi_id = config_get_int(cat, "midi_host_device", 0); + mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0); SSI2001 = !!config_get_int(cat, "ssi2001", 0); GAMEBLASTER = !!config_get_int(cat, "gameblaster", 0); @@ -2004,6 +2006,15 @@ static void saveconfig_sound(void) config_set_int(cat, "midi_host_device", midi_id); } + if (mpu401_standalone_enable == 0) + { + config_delete_var(cat, "mpu401_standalone"); + } + else + { + config_set_int(cat, "mpu401_standalone", mpu401_standalone_enable); + } + if (SSI2001 == 0) { config_delete_var(cat, "ssi2001"); diff --git a/src/ibm.h b/src/ibm.h index e2f9c8de5..658ca5513 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -528,6 +528,7 @@ enum GFX_OTI037, /*Oak OTI-037*/ GFX_VIRGEVX, /*S3 Virge/VX*/ + GFX_VIRGEDX4, /*S3 Virge/DX (VBE 2.0)*/ GFX_MAX }; diff --git a/src/pc.c b/src/pc.c index b85f401a1..544c5ee30 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Emulation core dispatcher. * - * Version: @(#)pc.c 1.0.0 2017/05/30 + * Version: @(#)pc.c 1.0.1 2017/05/30 * * Author: Sarah Walker, * Miran Grca, @@ -64,6 +64,7 @@ #include "sound/sound.h" #include "sound/snd_cms.h" #include "sound/snd_dbopl.h" +#include "sound/snd_mpu401.h" #include "sound/snd_opl.h" #include "sound/snd_gus.h" #include "sound/snd_sb.h" @@ -522,6 +523,8 @@ void resetpchard(void) scsi_card_init(); sound_card_init(); + if (mpu401_standalone_enable) + mpu401_device_add(); if (GUS) device_add(&gus_device); if (GAMEBLASTER) diff --git a/src/pci.c b/src/pci.c index b48ac2072..4edd4b14f 100644 --- a/src/pci.c +++ b/src/pci.c @@ -150,7 +150,8 @@ void pci_issue_irq(int irq) if (irq_elcr) { - picintlevel(1 << irq); + /* picintlevel(1 << irq); */ + picint(1 << irq); } else {