diff --git a/src/86Box.rc b/src/86Box.rc index 388ab93b7..fb5d56296 100644 --- a/src/86Box.rc +++ b/src/86Box.rc @@ -112,7 +112,7 @@ BEGIN MENUITEM SEPARATOR POPUP "&Video" BEGIN - MENUITEM "&Resizeable window", IDM_VID_RESIZE + MENUITEM "&Resizeable window", IDM_VID_RESIZE MENUITEM "R&emember size && position", IDM_VID_REMEMBER MENUITEM SEPARATOR MENUITEM "&DirectDraw", IDM_VID_DDRAW @@ -323,7 +323,7 @@ BEGIN CONTROL "Dynamic Recompiler",IDC_CHECK_DYNAREC,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10 CONTROL "Enable FPU",IDC_CHECK_FPU,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,147,81,113,10 + WS_TABSTOP,147,80,113,10 EDITTEXT IDC_MEMTEXT,70,63,45,12,ES_AUTOHSCROLL | ES_NUMBER CONTROL "",IDC_MEMSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS,113,63, @@ -346,7 +346,7 @@ BEGIN LTEXT "Video speed:",1800,7,26,58,10 CONTROL "Voodoo Graphics",IDC_CHECK_VOODOO,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,45,199,10 - PUSHBUTTON "Configure",IDC_CONFIGURE_VOODOO,215,44,45,12 + PUSHBUTTON "Configure",IDC_CONFIGURE_VOODOO,214,44,46,12 PUSHBUTTON "Configure",IDC_CONFIGUREVID,214,7,46,12 END @@ -366,53 +366,75 @@ BEGIN PUSHBUTTON "Joystick 4...",IDC_JOY4,209,44,50,14 END -CONFIGUREDLG_SOUND DIALOG DISCARDABLE 97, 0, 267, 60 +CONFIGUREDLG_SOUND DIALOG DISCARDABLE 97, 0, 267, 78 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - COMBOBOX IDC_COMBOSND,71,7,141,120,CBS_DROPDOWNLIST | WS_VSCROLL | + COMBOBOX IDC_COMBOSND,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Sound card:",1800,7,8,59,10 - PUSHBUTTON "Configure",IDC_CONFIGURESND,215,7,45,14 + PUSHBUTTON "Configure",IDC_CONFIGURESND,214,7,46,12 + 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,25,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,87,43,80,10 CONTROL "Innovation SSI-2001",IDC_CHECKSSI,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,25,80,10 - CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,174,25,80,10 - CONTROL "Use Nuked OPL",IDC_CHECKNUKEDOPL,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,43,80,10 + CONTROL "Gravis Ultrasound",IDC_CHECKGUS,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,174,43,80,10 + CONTROL "Use Nuked OPL",IDC_CHECKNUKEDOPL,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,61,80,10 END -CONFIGUREDLG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 132 +CONFIGUREDLG_NETWORK DIALOG DISCARDABLE 97, 0, 267, 63 STYLE DS_CONTROL | WS_CHILD FONT 9, "Segoe UI" BEGIN - PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,215,24,45,14 - LTEXT "HD Controller:",1799,7,44,61,10 - COMBOBOX IDC_COMBO_HDC,71,43,189,120,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - LTEXT "Network adapter:",1801,7,8,59,10 - COMBOBOX IDC_COMBONET,71,7,141,120,CBS_DROPDOWNLIST | WS_VSCROLL | + LTEXT "Network type:",1800,7,8,59,10 + COMBOBOX IDC_COMBONETTYPE,71,7,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure",IDC_CONFIGURENET,215,6,45,14 - LTEXT "Tertiary IDE:",1802,7,62,61,10 - COMBOBOX IDC_COMBO_IDE_TER,71,61,189,120,CBS_DROPDOWNLIST | + + LTEXT "PCap device:",1801,7,26,59,10 + COMBOBOX IDC_COMBOPCAP,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + + LTEXT "Network adapter:",1802,7,44,59,10 + COMBOBOX IDC_COMBONET,71,43,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | + WS_TABSTOP + PUSHBUTTON "Configure",IDC_CONFIGURENET,214,43,46,12 +END + +CONFIGUREDLG_PERIPHERALS DIALOG DISCARDABLE 97, 0, 267, 115 +STYLE DS_CONTROL | WS_CHILD +FONT 9, "Segoe UI" +BEGIN + LTEXT "SCSI Controller:",1804,7,8,59,10 + COMBOBOX IDC_COMBO_SCSI,71,7,140,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Quaternary IDE:",1803,7,81,61,10 - COMBOBOX IDC_COMBO_IDE_QUA,71,79,189,120,CBS_DROPDOWNLIST | + PUSHBUTTON "Configure",IDC_CONFIGURE_SCSI,214,7,46,12 + + LTEXT "HD Controller:",1799,7,26,61,10 + COMBOBOX IDC_COMBO_HDC,71,25,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "SCSI Controller:",1804,7,26,59,10 - COMBOBOX IDC_COMBO_SCSI,71,25,141,120,CBS_DROPDOWNLIST | + + LTEXT "Tertiary IDE:",1802,7,44,61,10 + COMBOBOX IDC_COMBO_IDE_TER,71,43,189,120,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + + LTEXT "Quaternary IDE:",1803,7,62,61,10 + COMBOBOX IDC_COMBO_IDE_QUA,71,61,189,120,CBS_DROPDOWNLIST | + WS_VSCROLL | WS_TABSTOP + CONTROL "Serial port 1",IDC_CHECKSERIAL1,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,97,80,10 - CONTROL "Parallel port",IDC_CHECKPARALLEL,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,174,97,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,7,80,94,10 CONTROL "Serial port 2",IDC_CHECKSERIAL2,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,87,97,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,147,80,94,10 + + CONTROL "Parallel port",IDC_CHECKPARALLEL,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,98,94,10 CONTROL "ISABugger device",IDC_CHECKBUGGER,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,115,80,10 + BS_AUTOCHECKBOX | WS_TABSTOP,147,98,94,10 END CONFIGUREDLG_HARD_DISKS DIALOG DISCARDABLE 97, 0, 267, 154 @@ -526,9 +548,10 @@ END 257 ICON DISCARDABLE "ICONS/video.ico" 258 ICON DISCARDABLE "ICONS/input_devices.ico" 259 ICON DISCARDABLE "ICONS/sound.ico" -260 ICON DISCARDABLE "ICONS/other_peripherals.ico" -261 ICON DISCARDABLE "ICONS/hard_disk.ico" -262 ICON DISCARDABLE "ICONS/removable_devices.ico" +260 ICON DISCARDABLE "ICONS/network.ico" +261 ICON DISCARDABLE "ICONS/other_peripherals.ico" +262 ICON DISCARDABLE "ICONS/hard_disk.ico" +263 ICON DISCARDABLE "ICONS/removable_devices.ico" 384 ICON DISCARDABLE "ICONS/floppy_525_1dd_empty.ico" 385 ICON DISCARDABLE "ICONS/floppy_525_1dd_empty_active.ico" 386 ICON DISCARDABLE "ICONS/floppy_525_2dd_empty.ico" @@ -625,12 +648,28 @@ BEGIN BOTTOMMARGIN, 58 END + CONFIGUREDLG_SOUND, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 260 + TOPMARGIN, 7 + BOTTOMMARGIN, 71 + END + + CONFIGUREDLG_NETWORK, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 260 + TOPMARGIN, 7 + BOTTOMMARGIN, 56 + END + CONFIGUREDLG_PERIPHERALS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 260 TOPMARGIN, 7 - BOTTOMMARGIN, 125 + BOTTOMMARGIN, 102 END CONFIGUREDLG_HARD_DISKS, DIALOG @@ -684,10 +723,10 @@ BEGIN IDS_STRING2066 "Video" IDS_STRING2067 "Input devices" IDS_STRING2068 "Sound" - IDS_STRING2069 "Other peripherals" - IDS_STRING2070 "Hard disks" - IDS_STRING2071 "Removable devices" - IDS_STRING2072 "Disabled floppy drive" + IDS_STRING2069 "Network" + IDS_STRING2070 "Other peripherals" + IDS_STRING2071 "Hard disks" + IDS_STRING2072 "Removable devices" IDS_STRING2073 "%i"" floppy drive: %s" IDS_STRING2074 "Disabled CD-ROM drive" IDS_STRING2075 "%s CD-ROM drive: %s" @@ -714,7 +753,7 @@ BEGIN 2092 "Bus" 2093 "DMA" 2094 "KB" - 2095 "Master" + 2095 "MFM, RLL, or ESDI CD-ROM drives never existed" END STRINGTABLE DISCARDABLE @@ -730,7 +769,7 @@ BEGIN 2104 "Network Type" 2105 "Surround Module" 2106 "MPU-401 Base Address" - 2107 "MIDI Out Device" + 2107 "No PCap devices found" 2108 "On-board RAM" 2109 "Memory Size" 2110 "Display Type" @@ -834,7 +873,9 @@ BEGIN 2196 "Add New Hard Disk" 2197 "Add Existing Hard Disk" 2198 "Removable disk %i: %s" - 2199 "English (United States)" + 2199 "USB is not yet supported" + 2200 "Invalid PCap device" + 2201 "English (United States)" END diff --git a/src/SOUND/snd_sb.c b/src/SOUND/snd_sb.c index d1471ee34..40bfd4213 100644 --- a/src/SOUND/snd_sb.c +++ b/src/SOUND/snd_sb.c @@ -780,9 +780,6 @@ static device_config_t sb_config[] = } } }, - { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 - }, { "", "", -1 } @@ -821,9 +818,6 @@ static device_config_t sb_mcv_config[] = } } }, - { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 - }, { "", "", -1 } @@ -879,9 +873,6 @@ static device_config_t sb_pro_config[] = } } }, - { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 - }, { "", "", -1 } @@ -1003,9 +994,6 @@ static device_config_t sb_16_config[] = } } }, - { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 - }, { "mode401", "MPU-401 mode", CONFIG_SELECTION, "", 1, { @@ -1141,9 +1129,6 @@ static device_config_t sb_awe32_config[] = } } }, - { - "midi", "MIDI out device", CONFIG_MIDI, "", 0 - }, { "mode401", "MPU-401 mode", CONFIG_SELECTION, "", 1, { diff --git a/src/SOUND/sound.c b/src/SOUND/sound.c index aa4c944bd..c3086b8e1 100644 --- a/src/SOUND/sound.c +++ b/src/SOUND/sound.c @@ -146,7 +146,7 @@ static void sound_cd_thread(void *param) has_audio = 0; for (i = 0; i < CDROM_NUM; i++) { - if (cdrom_drives[i].enabled && cdrom_drives[i].sound_on) + if (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on) { has_audio++; } @@ -161,7 +161,7 @@ static void sound_cd_thread(void *param) if (cdrom_drives[i].handler->audio_callback) { cdrom_drives[i].handler->audio_callback(i, cd_buffer[i], CD_BUFLEN*2); - has_audio = (cdrom_drives[i].enabled && cdrom_drives[i].sound_on); + has_audio = (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on); } if (soundon && has_audio) { @@ -240,7 +240,7 @@ void sound_init() for (i = 0; i < CDROM_NUM; i++) { - if (cdrom_drives[i].enabled && cdrom_drives[i].sound_on) + if (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on) { available_cdrom_drives++; } @@ -329,7 +329,7 @@ void sound_cd_thread_reset() for (i = 0; i < CDROM_NUM; i++) { - if (cdrom_drives[i].enabled && cdrom_drives[i].sound_on) + if (cdrom_drives[i].bus_type && cdrom_drives[i].sound_on) { available_cdrom_drives++; } diff --git a/src/cdrom.c b/src/cdrom.c index 8617e35af..60ad3afe5 100644 --- a/src/cdrom.c +++ b/src/cdrom.c @@ -175,25 +175,10 @@ uint8_t cdrom_command_flags[0x100] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -uint8_t cdrom_mode_sense_page_flags[CDROM_NUM][0x40] = -{ - { 0, IMPLEMENTED, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, IMPLEMENTED, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED }, - { 0, IMPLEMENTED, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, IMPLEMENTED, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED }, - { 0, IMPLEMENTED, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, IMPLEMENTED, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED }, - { 0, IMPLEMENTED, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, IMPLEMENTED, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, IMPLEMENTED } -}; +uint64_t cdrom_mode_sense_page_flags[CDROM_NUM] = { (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), + (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), + (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES), + (1LL << GPMODE_R_W_ERROR_PAGE) | (1LL << GPMODE_CDROM_PAGE) | (1LL << GPMODE_CDROM_AUDIO_PAGE) | (1LL << GPMODE_CAPABILITIES_PAGE) | (1LL << GPMODE_ALL_PAGES) }; const uint8_t cdrom_mode_sense_pages_default[CDROM_NUM][0x40][0x40] = { @@ -747,7 +732,7 @@ int find_cdrom_for_channel(uint8_t channel) for (i = 0; i < CDROM_NUM; i++) { - if (!cdrom_drives[i].bus_type && (cdrom_drives[i].ide_channel == channel)) + if ((cdrom_drives[i].bus_type < 4) && (cdrom_drives[i].ide_channel == channel)) { return i; } @@ -755,7 +740,7 @@ int find_cdrom_for_channel(uint8_t channel) return 0xff; } -void cdrom_init(int id, int cdb_len_setting, int bus_type); +void cdrom_init(int id, int cdb_len_setting); void build_atapi_cdrom_map() { @@ -768,7 +753,7 @@ void build_atapi_cdrom_map() atapi_cdrom_drives[i] = find_cdrom_for_channel(i); if (atapi_cdrom_drives[i] != 0xff) { - cdrom_init(atapi_cdrom_drives[i], 12, 0); + cdrom_init(atapi_cdrom_drives[i], 12); } } } @@ -779,7 +764,7 @@ int find_cdrom_for_scsi_id(uint8_t scsi_id, uint8_t scsi_lun) for (i = 0; i < CDROM_NUM; i++) { - if (cdrom_drives[i].bus_type && (cdrom_drives[i].scsi_device_id == scsi_id) && (cdrom_drives[i].scsi_device_lun == scsi_lun)) + if ((cdrom_drives[i].bus_type == 4) && (cdrom_drives[i].scsi_device_id == scsi_id) && (cdrom_drives[i].scsi_device_lun == scsi_lun)) { return i; } @@ -804,7 +789,7 @@ void build_scsi_cdrom_map() scsi_cdrom_drives[i][j] = find_cdrom_for_scsi_id(i, j); if (scsi_cdrom_drives[i][j] != 0xff) { - cdrom_init(scsi_cdrom_drives[i][j], 12, 1); + cdrom_init(scsi_cdrom_drives[i][j], 12); } } } @@ -830,7 +815,7 @@ void cdrom_set_signature(int id) cdrom[id].request_length = 0xEB14; } -void cdrom_init(int id, int cdb_len_setting, int bus_type) +void cdrom_init(int id, int cdb_len_setting) { if (id >= CDROM_NUM) { @@ -847,9 +832,17 @@ void cdrom_init(int id, int cdb_len_setting, int bus_type) cdrom[id].cd_status = CD_STATUS_EMPTY; cdrom[id].sense[0] = 0xf0; cdrom[id].sense[7] = 10; - cdrom_drives[id].bus_mode = cdrom_drives[id].bus_type ? 2 : (cdrom_drives[id].atapi_dma ? 3 : 1); + cdrom_drives[id].bus_mode = 0; + if (cdrom_drives[id].bus_type > 2) + { + cdrom_drives[id].bus_mode |= 2; + } + if (cdrom_drives[id].bus_type < 4) + { + cdrom_drives[id].bus_mode |= 1; + } cdrom_log("CD-ROM %i: Bus type %i, bus mode %i\n", id, cdrom_drives[id].bus_type, cdrom_drives[id].bus_mode); - if (!cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type < 4) { cdrom_set_signature(id); cdrom_drives[id].max_blocks_at_once = 1; @@ -1083,7 +1076,7 @@ int cdrom_mode_select_header(uint8_t id, uint8_t val) } else if (cdrom[id].current_page_pos == (cdrom[id].current_page_len - 2)) { - if (cdrom_drives[id].bus_type && (cdrom[id].current_page_len == 8)) + if ((cdrom_drives[id].bus_type == 4) && (cdrom[id].current_page_len == 8)) { cdrom[id].block_descriptor_len |= ((uint16_t) val) << 8; cdrom_log("CD-ROM %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, cdrom[id].current_page_pos, val, cdrom[id].block_descriptor_len); @@ -1091,7 +1084,7 @@ int cdrom_mode_select_header(uint8_t id, uint8_t val) } else if (cdrom[id].current_page_pos == (cdrom[id].current_page_len - 1)) { - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { cdrom[id].block_descriptor_len |= (uint16_t) val; cdrom_log("CD-ROM %i: Position: %02X, value: %02X, block descriptor length: %02X\n", id, cdrom[id].current_page_pos, val, cdrom[id].block_descriptor_len); @@ -1134,7 +1127,7 @@ int cdrom_mode_select_page_header(uint8_t id, uint8_t val) if (cdrom[id].current_page_pos == 0) { cdrom[id].current_page_code = val & 0x3f; - if (cdrom_mode_sense_page_flags[id][cdrom[id].current_page_code] != IMPLEMENTED) + if (!(cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code))) { cdrom_log("CD-ROM %i: Trying to modify an unimplemented page: %02X\n", id, cdrom[id].current_page_code); cdrom_mode_select_terminate(id, 1); @@ -1342,7 +1335,7 @@ uint32_t cdrom_mode_sense(uint8_t id, uint8_t *buf, uint32_t pos, uint8_t type, { if ((type == GPMODE_ALL_PAGES) || (type == i)) { - if (cdrom_mode_sense_page_flags[id][i] == IMPLEMENTED) + if (cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code)) { buf[pos++] = cdrom_mode_sense_read(id, page_control, i, 0); msplen = cdrom_mode_sense_read(id, page_control, i, 1); @@ -1477,7 +1470,7 @@ static void cdrom_command_write_dma(uint8_t id) static int cdrom_request_length_is_zero(uint8_t id) { - if ((cdrom[id].request_length == 0) && !cdrom_drives[id].bus_type) + if ((cdrom[id].request_length == 0) && (cdrom_drives[id].bus_type < 4)) { return 1; } @@ -1497,7 +1490,7 @@ static void cdrom_data_command_finish(uint8_t id, int len, int block_len, int al } if (cdrom_request_length_is_zero(id) || (len == 0) || (cdrom_current_mode(id) == 0)) { - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { SCSIDevices[cdrom_drives[id].scsi_device_id][cdrom_drives[id].scsi_device_lun].InitLength = 0; } @@ -1513,7 +1506,7 @@ static void cdrom_data_command_finish(uint8_t id, int len, int block_len, int al { if (direction == 0) { - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { SCSIDevices[cdrom_drives[id].scsi_device_id][cdrom_drives[id].scsi_device_lun].InitLength = alloc_len; } @@ -2070,7 +2063,7 @@ int cdrom_pre_execution_check(uint8_t id, uint8_t *cdb) { int ready = 0; - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { if (((cdrom[id].request_length >> 5) & 7) != cdrom_drives[id].scsi_device_lun) { @@ -2082,19 +2075,20 @@ int cdrom_pre_execution_check(uint8_t id, uint8_t *cdb) if (!(cdrom_command_flags[cdb[0]] & IMPLEMENTED)) { - cdrom_log("CD-ROM %i: Attempting to execute unknown command %02X over %s\n", id, cdb[0], cdrom_drives[id].bus_type ? "SCSI" : "ATAPI"); + cdrom_log("CD-ROM %i: Attempting to execute unknown command %02X over %s\n", id, cdb[0], (cdrom_drives[id].bus_type == 4) ? "SCSI" : ((cdrom_drives[id].bus_type == 3) ? "ATAPI PIO/DMA" : "ATAPI PIO")); + cdrom_illegal_opcode(id); return 0; } - if (!cdrom_drives[id].bus_type && (cdrom_command_flags[cdb[0]] & SCSI_ONLY)) + if ((cdrom_drives[id].bus_type < 4) && (cdrom_command_flags[cdb[0]] & SCSI_ONLY)) { cdrom_log("CD-ROM %i: Attempting to execute SCSI-only command %02X over ATAPI\n", id, cdb[0]); cdrom_illegal_opcode(id); return 0; } - if (cdrom_drives[id].bus_type && (cdrom_command_flags[cdb[0]] & ATAPI_ONLY)) + if ((cdrom_drives[id].bus_type == 4) && (cdrom_command_flags[cdb[0]] & ATAPI_ONLY)) { cdrom_log("CD-ROM %i: Attempting to execute ATAPI-only command %02X over SCSI\n", id, cdb[0]); cdrom_illegal_opcode(id); @@ -2155,7 +2149,7 @@ int cdrom_pre_execution_check(uint8_t id, uint8_t *cdb) return 0; } - cdrom_log("CD-ROM %i: Continuing with command\n", id); + cdrom_log("CD-ROM %i: Continuing with command %02X\n", id, cdb[0]); return 1; } @@ -2309,7 +2303,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) #if 0 int CdbLength; #endif - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { cdrom[id].status &= ~ERR_STAT; } @@ -2507,7 +2501,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) } max_len = cdrom[id].sector_len; - /* if (cdrom_drives[id].bus_type) */ + /* if (cdrom_drives[id].bus_type == 4) */ if (cdrom_current_mode(id) == 2) { cdrom[id].requested_blocks = max_len; @@ -2579,7 +2573,7 @@ void cdrom_command(uint8_t id, uint8_t *cdb) case GPCMD_MODE_SENSE_6: case GPCMD_MODE_SENSE_10: - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { block_desc = ((cdb[1] >> 3) & 1) ? 0 : 1; } @@ -2597,7 +2591,9 @@ void cdrom_command(uint8_t id, uint8_t *cdb) len = (cdb[8] | (cdb[7] << 8)); } - if (!(cdrom_mode_sense_page_flags[id][cdb[2] & 0x3F] & IMPLEMENTED)) + cdrom[id].current_page_code = cdb[2] & 0x3F; + + if (!(cdrom_mode_sense_page_flags[id] & (1LL << cdrom[id].current_page_code))) { cdrom_invalid_field(id); return; @@ -3201,8 +3197,8 @@ void cdrom_command(uint8_t id, uint8_t *cdb) memset(cdbufferb, 0, 8); cdbufferb[0] = 5; /*CD-ROM*/ cdbufferb[1] = 0x80; /*Removable*/ - cdbufferb[2] = cdrom_drives[id].bus_type ? 0x02 : 0x00; /*SCSI-2 compliant*/ - cdbufferb[3] = cdrom_drives[id].bus_type ? 0x02 : 0x21; + cdbufferb[2] = (cdrom_drives[id].bus_type == 4) ? 0x02 : 0x00; /*SCSI-2 compliant*/ + cdbufferb[3] = (cdrom_drives[id].bus_type == 4) ? 0x02 : 0x21; cdbufferb[4] = 31; ide_padstr8(cdbufferb + 8, 8, "86Box"); /* Vendor */ @@ -3356,7 +3352,7 @@ void cdrom_callback(uint8_t id) /* Callback for non-Read CD commands */ { int old_pos = 0; - if (!cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type < 4) { cdrom_log("CD-ROM %i: Lowering IDE IRQ\n", id); ide_irq_lower(&(ide_drives[cdrom_drives[id].ide_channel])); @@ -3482,7 +3478,7 @@ int cdrom_read_from_dma(uint8_t id) int in_data_length = 0; - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { ret = cdrom_read_from_scsi_dma(cdrom_drives[id].scsi_device_id, cdrom_drives[id].scsi_device_lun); } @@ -3496,7 +3492,7 @@ int cdrom_read_from_dma(uint8_t id) return 0; } - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { in_data_length = SCSIDevices[cdrom_drives[id].scsi_device_id][cdrom_drives[id].scsi_device_lun].InitLength; cdrom_log("CD-ROM %i: SCSI Input data length: %i\n", id, in_data_length); @@ -3602,7 +3598,7 @@ int cdrom_write_to_dma(uint8_t id) { int ret = 0; - if (cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type == 4) { ret = cdrom_write_to_scsi_dma(cdrom_drives[id].scsi_device_id, cdrom_drives[id].scsi_device_lun); } @@ -3621,7 +3617,7 @@ int cdrom_write_to_dma(uint8_t id) void cdrom_irq_raise(uint8_t id) { - if (!cdrom_drives[id].bus_type) + if (cdrom_drives[id].bus_type < 4) { ide_irq_raise(&(ide_drives[cdrom_drives[id].ide_channel])); } diff --git a/src/cdrom.h b/src/cdrom.h index a3a3a69a9..63470c36f 100644 --- a/src/cdrom.h +++ b/src/cdrom.h @@ -59,7 +59,7 @@ typedef struct __attribute__((__packed__)) int requested_blocks; /* This will be set to something other than 1 when block reads are implemented. */ - int current_page_code; + uint64_t current_page_code; int current_page_len; int current_page_pos; @@ -132,8 +132,6 @@ typedef struct typedef struct __attribute__((__packed__)) #endif { - int enabled; - int max_blocks_at_once; CDROM *handler; @@ -141,17 +139,17 @@ typedef struct __attribute__((__packed__)) int host_drive; int prev_host_drive; - uint8_t bus_type; /* 0 = ATAPI, 1 = SCSI */ + unsigned int bus_type; /* 0 = ATAPI, 1 = SCSI */ uint8_t bus_mode; /* Bit 0 = PIO suported; Bit 1 = DMA supportd. */ uint8_t ide_channel; - uint8_t scsi_device_id; - uint8_t scsi_device_lun; + unsigned int scsi_device_id; + unsigned int scsi_device_lun; - uint8_t sound_on; - uint8_t atapi_dma; + unsigned int sound_on; + unsigned int atapi_dma; } cdrom_drive_t; #ifdef __MSC__ # pragma pack(pop) diff --git a/src/config.c b/src/config.c index 8b31042d3..d4e47b727 100644 --- a/src/config.c +++ b/src/config.c @@ -1,6 +1,7 @@ /* Copyright holders: Sarah Walker see COPYING for more details */ +#include #include #include #include @@ -23,12 +24,22 @@ #include "network.h" #include "nvr.h" #include "plat-joystick.h" +#include "plat-midi.h" #include "scsi.h" #include "sound/snd_dbopl.h" #include "sound/snd_opl.h" #include "sound/sound.h" #include "video/video.h" +#ifndef __unix +#define UNICODE +#define BITMAP WINDOWS_BITMAP +#include +#undef BITMAP +#include "win.h" +#include "win-language.h" +#endif + wchar_t config_file_default[256]; @@ -123,8 +134,18 @@ void config_free(void) } } +static wchar_t cfgbuffer[1024]; +static char sname[256]; +static char ename[256]; + void config_load(wchar_t *fn) { + int c; + + section_t *new_section; + entry_t *new_entry; + int sd = 0, ed = 0, data_pos; + FILE *f = _wfopen(fn, L"rt, ccs=UNICODE"); section_t *current_section; @@ -139,74 +160,64 @@ void config_load(wchar_t *fn) while (1) { - int c; - wchar_t buffer[1024]; - int org_pos; - - memset(buffer, 0, 2048); - fgetws(buffer, 255, f); + memset(cfgbuffer, 0, 2048); + fgetws(cfgbuffer, 255, f); if (feof(f)) break; c = 0; - while (buffer[c] == L' ') + while (cfgbuffer[c] == L' ') c++; - if (buffer[c] == L'\0') continue; + if (cfgbuffer[c] == L'\0') continue; - if (buffer[c] == L'#') /*Comment*/ + if (cfgbuffer[c] == L'#') /*Comment*/ continue; - if (buffer[c] == L'[') /*Section*/ + if (cfgbuffer[c] == L'[') /*Section*/ { - section_t *new_section; - char name[256]; - int d = 0; - + sd = 0; c++; - while (buffer[c] != L']' && buffer[c]) - wctomb(&(name[d++]), buffer[c++]); + while (cfgbuffer[c] != L']' && cfgbuffer[c]) + wctomb(&(sname[sd++]), cfgbuffer[c++]); - if (buffer[c] != L']') + if (cfgbuffer[c] != L']') continue; - name[d] = 0; + sname[sd] = 0; new_section = malloc(sizeof(section_t)); memset(new_section, 0, sizeof(section_t)); - strncpy(new_section->name, name, 256); + strncpy(new_section->name, sname, 256); list_add(&new_section->list, &config_head); current_section = new_section; } else { - entry_t *new_entry; - char name[256]; - int d = 0, data_pos; - - while (buffer[c] != L'=' && buffer[c] != L' ' && buffer[c]) - wctomb(&(name[d++]), buffer[c++]); + ed = 0; + while (cfgbuffer[c] != L'=' && cfgbuffer[c] != L' ' && cfgbuffer[c]) + wctomb(&(ename[ed++]), cfgbuffer[c++]); - if (buffer[c] == L'\0') continue; - name[d] = 0; + if (cfgbuffer[c] == L'\0') continue; + ename[ed] = 0; - while ((buffer[c] == L'=' || buffer[c] == L' ') && buffer[c]) + while ((cfgbuffer[c] == L'=' || cfgbuffer[c] == L' ') && cfgbuffer[c]) c++; - if (!buffer[c]) continue; + if (!cfgbuffer[c]) continue; data_pos = c; - while (buffer[c]) + while (cfgbuffer[c]) { - if (buffer[c] == L'\n') - buffer[c] = L'\0'; + if (cfgbuffer[c] == L'\n') + cfgbuffer[c] = L'\0'; c++; } new_entry = malloc(sizeof(entry_t)); memset(new_entry, 0, sizeof(entry_t)); - strncpy(new_entry->name, name, 256); - memcpy(new_entry->wdata, &buffer[data_pos], 512); + strncpy(new_entry->name, ename, 256); + memcpy(new_entry->wdata, &cfgbuffer[data_pos], 512); new_entry->wdata[255] = L'\0'; wcstombs(new_entry->data, new_entry->wdata, 512); new_entry->data[255] = '\0'; @@ -304,6 +315,27 @@ int config_get_int(char *head, char *name, int def) return value; } +int config_get_hex16(char *head, char *name, int def) +{ + section_t *section; + entry_t *entry; + int value; + + section = find_section(head); + + if (!section) + return def; + + entry = find_entry(section, name); + + if (!entry) + return def; + + sscanf(entry->data, "%04X", &value); + + return value; +} + char *config_get_string(char *head, char *name, char *def) { section_t *section; @@ -359,6 +391,25 @@ void config_set_int(char *head, char *name, int val) mbstowcs(entry->wdata, entry->data, 512); } +void config_set_hex16(char *head, char *name, int val) +{ + section_t *section; + entry_t *entry; + + section = find_section(head); + + if (!section) + section = create_section(head); + + entry = find_entry(section, name); + + if (!entry) + entry = create_entry(section, name); + + sprintf(entry->data, "%04X", val); + mbstowcs(entry->wdata, entry->data, 512); +} + void config_set_string(char *head, char *name, char *val) { section_t *section; @@ -483,6 +534,8 @@ void config_save(wchar_t *fn) { FILE *f = _wfopen(fn, L"wt, ccs=UNICODE"); section_t *current_section; + + int fl = 0; current_section = (section_t *)config_head.next; @@ -493,7 +546,15 @@ void config_save(wchar_t *fn) if (current_section->name[0]) { mbstowcs(wname, current_section->name, strlen(current_section->name) + 1); - fwprintf(f, L"\n[%ws]\n", wname); + if (fl) + { + fwprintf(f, L"\n[%ws]\n", wname); + } + else + { + fwprintf(f, L"[%ws]\n", wname); + } + fl++; } current_entry = (entry_t *)current_section->entry_head.next; @@ -509,6 +570,7 @@ void config_save(wchar_t *fn) { fwprintf(f, L"%ws = %ws\n", wname, current_entry->wdata); } + fl++; current_entry = (entry_t *)current_entry->list.next; } @@ -518,274 +580,52 @@ void config_save(wchar_t *fn) fclose(f); } -void loadconfig(wchar_t *fn) + +static char temps[512]; + +void loadconfig_general(void) { - int c, d; - char s[512]; + wchar_t *wp; char *p; - wchar_t *wp, *wq; - char temps[512]; - - if (!fn) - config_load(config_file_default); - else - config_load(fn); - - GAMEBLASTER = !!config_get_int(NULL, "gameblaster", 0); - GUS = !!config_get_int(NULL, "gus", 0); - SSI2001 = !!config_get_int(NULL, "ssi2001", 0); - voodoo_enabled = !!config_get_int(NULL, "voodoo", 0); - /* SCSI */ - p = (char *)config_get_string(NULL, "scsicard", ""); - if (p) - scsi_card_current = scsi_card_get_from_internal_name(p); - else - scsi_card_current = 0; - - /* Network */ - network_type = config_get_int(NULL, "net_type", -1); - p = (char *)config_get_string(NULL, "net_card", NULL); - network_card = (p) ? network_card_get_from_internal_name(p) : 0; - - p = (char *)config_get_string(NULL, "model", ""); - if (p) - model = model_get_model_from_internal_name(p); - else - model = 0; - - if (model >= model_count()) - model = model_count() - 1; - - romset = model_getromset(); - cpu_manufacturer = config_get_int(NULL, "cpu_manufacturer", 0); - cpu = config_get_int(NULL, "cpu", 0); - cpu_use_dynarec = !!config_get_int(NULL, "cpu_use_dynarec", 0); - - cpu_waitstates = config_get_int(NULL, "cpu_waitstates", 0); - - p = (char *)config_get_string(NULL, "gfxcard", ""); - if (p) - gfxcard = video_get_video_from_internal_name(p); - else - gfxcard = 0; - video_speed = config_get_int(NULL, "video_speed", 3); - p = (char *)config_get_string(NULL, "sndcard", ""); - if (p) - sound_card_current = sound_card_get_from_internal_name(p); - else - sound_card_current = 0; - - mem_size = config_get_int(NULL, "mem_size", 4096); - if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) - mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); - if (mem_size > 1048576) - { - mem_size = 1048576; - } - - for (c = 0; c < FDD_NUM; c++) - { - sprintf(temps, "fdd_%02i_type", c + 1); - p = (char *)config_get_string(NULL, temps, (c < 2) ? "525_2dd" : "none"); - if (p) - fdd_set_type(c, fdd_get_from_internal_name(p)); - else - fdd_set_type(c, (c < 2) ? 2 : 0); - if (fdd_get_type(c) > 13) - { - fdd_set_type(c, 13); - } - - sprintf(temps, "fdd_%02i_fn", c + 1); - wp = (wchar_t *)config_get_wstring(NULL, temps, L""); - if (wp) memcpy(discfns[c], wp, 512); - else { - memcpy(discfns[c], L"", 2); - discfns[c][0] = L'\0'; - } - printf("Floppy: %ws\n", discfns[c]); - sprintf(temps, "fdd_%02i_writeprot", c + 1); - ui_writeprot[c] = !!config_get_int(NULL, temps, 0); - } - - p = (char *)config_get_string(NULL, "hdd_controller", ""); - if (p) - strncpy(hdd_controller_name, p, sizeof(hdd_controller_name)-1); - else - strncpy(hdd_controller_name, "none", sizeof(hdd_controller_name)-1); + /* General */ + vid_resize = !!config_get_int("General", "vid_resize", 0); + p = (char *)config_get_string("General", "vid_renderer", "d3d9"); memset(temps, 0, 512); - for (c = 2; c < 4; c++) + if (p) { - sprintf(temps, "ide_%02i_enable", c + 1); - ide_enable[c] = config_get_int(NULL, temps, 0); - sprintf(temps, "ide_%02i_irq", c + 1); - ide_irq[c] = config_get_int(NULL, temps, 8 + c); + strcpy(temps, p); + } + if (!strcmp(temps, "ddraw")) + { + vid_api = 0; + } + else + { + vid_api = 1; } - memset(temps, 0, 512); - for (c = 0; c < HDC_NUM; c++) + video_fullscreen_scale = config_get_int("General", "video_fullscreen_scale", 0); + video_fullscreen_first = config_get_int("General", "video_fullscreen_first", 1); + + force_43 = !!config_get_int("General", "force_43", 0); + scale = !!config_get_int("General", "scale", 1); + enable_overscan = !!config_get_int("General", "enable_overscan", 0); + + p = config_get_string("General", "window_w_coordinates", "0, 0, 0, 0"); + if (p) { - sprintf(temps, "hdd_%02i_sectors", c + 1); - hdc[c].spt = config_get_int(NULL, temps, 0); - if (hdc[c].spt > 99) - { - hdc[c].spt = 99; - } - sprintf(temps, "hdd_%02i_heads", c + 1); - hdc[c].hpc = config_get_int(NULL, temps, 0); - if (hdc[c].hpc > 64) - { - hdc[c].hpc = 64; - } - sprintf(temps, "hdd_%02i_cylinders", c + 1); - hdc[c].tracks = config_get_int(NULL, temps, 0); - if (hdc[c].tracks > 266305) - { - hdc[c].tracks = 266305; - } - sprintf(temps, "hdd_%02i_bus_type", c + 1); - hdc[c].bus = config_get_int(NULL, temps, 0); - if (hdc[c].bus > 4) - { - hdc[c].bus = 4; - } - sprintf(temps, "hdd_%02i_mfm_channel", c + 1); - hdc[c].mfm_channel = config_get_int(NULL, temps, 0); - if (hdc[c].mfm_channel > 1) - { - hdc[c].mfm_channel = 1; - } - sprintf(temps, "hdd_%02i_ide_channel", c + 1); - hdc[c].ide_channel = config_get_int(NULL, temps, 0); - if (hdc[c].ide_channel > 7) - { - hdc[c].ide_channel = 7; - } - sprintf(temps, "hdd_%02i_scsi_device_id", c + 1); - hdc[c].scsi_id = config_get_int(NULL, temps, (c < 7) ? c : ((c < 15) ? (c + 1) : 15)); - if (hdc[c].scsi_id > 15) - { - hdc[c].scsi_id = 15; - } - sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1); - hdc[c].scsi_lun = config_get_int(NULL, temps, 0); - if (hdc[c].scsi_lun > 7) - { - hdc[c].scsi_lun = 7; - } - sprintf(temps, "hdd_%02i_fn", c + 1); - wp = (wchar_t *)config_get_wstring(NULL, temps, L""); - if (wp) memcpy(hdd_fn[c], wp, 512); - else { - memcpy(hdd_fn[c], L"", 2); - hdd_fn[c][0] = L'\0'; - } + sscanf(temps, "%i, %i, %i, %i", &window_w, &window_h, &window_x, &window_y); } - - memset(temps, 0, 512); - for (c = 0; c < CDROM_NUM; c++) + else { - sprintf(temps, "cdrom_%02i_host_drive", c + 1); - cdrom_drives[c].host_drive = config_get_int(NULL, temps, 0); - cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive; - sprintf(temps, "cdrom_%02i_enabled", c + 1); - cdrom_drives[c].enabled = !!config_get_int(NULL, temps, 0); - sprintf(temps, "cdrom_%02i_sound_on", c + 1); - cdrom_drives[c].sound_on = !!config_get_int(NULL, temps, 1); - sprintf(temps, "cdrom_%02i_bus_type", c + 1); - cdrom_drives[c].bus_type = config_get_int(NULL, temps, 0); - if (cdrom_drives[c].bus_type > 1) - { - cdrom_drives[c].bus_type = 1; - } - sprintf(temps, "cdrom_%02i_atapi_dma", c + 1); - cdrom_drives[c].atapi_dma = !!config_get_int(NULL, temps, 0); - sprintf(temps, "cdrom_%02i_ide_channel", c + 1); - cdrom_drives[c].ide_channel = config_get_int(NULL, temps, 2); - if (cdrom_drives[c].ide_channel > 7) - { - cdrom_drives[c].ide_channel = 7; - } - sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1); - cdrom_drives[c].scsi_device_id = config_get_int(NULL, temps, c + 2); - if (cdrom_drives[c].scsi_device_id > 15) - { - cdrom_drives[c].scsi_device_id = 15; - } - sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1); - cdrom_drives[c].scsi_device_lun = config_get_int(NULL, temps, 0); - if (cdrom_drives[c].scsi_device_lun > 7) - { - cdrom_drives[c].scsi_device_lun = 7; - } - - sprintf(temps, "cdrom_%02i_image_path", c + 1); - wp = (wchar_t *)config_get_wstring(NULL, temps, L""); - if (wp) memcpy(cdrom_image[c].image_path, wp, 512); - else { - memcpy(cdrom_image[c].image_path, L"", 2); - cdrom_image[c].image_path[0] = L'\0'; - } + sscanf(temps, "0, 0, 0, 0", &window_w, &window_h, &window_x, &window_y); } - - vid_resize = !!config_get_int(NULL, "vid_resize", 0); - vid_api = config_get_int(NULL, "vid_api", 0); - video_fullscreen_scale = config_get_int(NULL, "video_fullscreen_scale", 0); - video_fullscreen_first = config_get_int(NULL, "video_fullscreen_first", 1); - - force_43 = !!config_get_int(NULL, "force_43", 0); - scale = !!config_get_int(NULL, "scale", 1); - enable_overscan = !!config_get_int(NULL, "enable_overscan", 0); - - enable_sync = !!config_get_int(NULL, "enable_sync", 1); - opl3_type = !!config_get_int(NULL, "opl3_type", 1); - - window_w = config_get_int(NULL, "window_w", 0); - window_h = config_get_int(NULL, "window_h", 0); - window_x = config_get_int(NULL, "window_x", 0); - window_y = config_get_int(NULL, "window_y", 0); - window_remember = config_get_int(NULL, "window_remember", 0); - - joystick_type = config_get_int(NULL, "joystick_type", 0); - p = (char *)config_get_string(NULL, "mouse_type", ""); - if (p) - mouse_type = mouse_get_from_internal_name(p); - else - mouse_type = 0; - - enable_external_fpu = !!config_get_int(NULL, "enable_external_fpu", 0); - - for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) - { - sprintf(s, "joystick_%i_nr", c); - joystick_state[c].plat_joystick_nr = config_get_int("Joysticks", s, 0); - - if (joystick_state[c].plat_joystick_nr) - { - for (d = 0; d < joystick_get_axis_count(joystick_type); d++) - { - sprintf(s, "joystick_%i_axis_%i", c, d); - joystick_state[c].axis_mapping[d] = config_get_int("Joysticks", s, d); - } - for (d = 0; d < joystick_get_button_count(joystick_type); d++) - { - sprintf(s, "joystick_%i_button_%i", c, d); - joystick_state[c].button_mapping[d] = config_get_int("Joysticks", s, d); - } - for (d = 0; d < joystick_get_pov_count(joystick_type); d++) - { - sprintf(s, "joystick_%i_pov_%i_x", c, d); - joystick_state[c].pov_mapping[d][0] = config_get_int("Joysticks", s, d); - sprintf(s, "joystick_%i_pov_%i_y", c, d); - joystick_state[c].pov_mapping[d][1] = config_get_int("Joysticks", s, d); - } - } - } + window_remember = config_get_int("General", "window_remember", 0); memset(nvr_path, 0, 2048); - wp = (wchar_t *)config_get_wstring(NULL, "nvr_path", L""); + wp = (wchar_t *)config_get_wstring("General", "nvr_path", L""); if (wp) { if (wcslen(wp) && (wcslen(wp) <= 992)) wcscpy(nvr_path, wp); else @@ -806,10 +646,484 @@ void loadconfig(wchar_t *fn) path_len = wcslen(nvr_path); - serial_enabled[0] = !!config_get_int(NULL, "serial1_enabled", 1); - serial_enabled[1] = !!config_get_int(NULL, "serial2_enabled", 1); - lpt_enabled = !!config_get_int(NULL, "lpt_enabled", 1); - bugger_enabled = !!config_get_int(NULL, "bugger_enabled", 0); +#ifndef __unix + /* Currently, 86Box is English (US) only, but in the future (version 1.30 at the earliest) other languages will be added, + therefore it is better to future-proof the code. */ + dwLanguage = config_get_hex16("General", "language", 0x0409); +#endif +} + +static void loadconfig_machine(void) +{ + char *p; + + /* Machine */ + p = (char *)config_get_string("Machine", "model", ""); + if (p) + model = model_get_model_from_internal_name(p); + else + model = 0; + + if (model >= model_count()) + model = model_count() - 1; + + romset = model_getromset(); + cpu_manufacturer = config_get_int("Machine", "cpu_manufacturer", 0); + cpu = config_get_int("Machine", "cpu", 0); + + cpu_waitstates = config_get_int("Machine", "cpu_waitstates", 0); + + mem_size = config_get_int("Machine", "mem_size", 4096); + if (mem_size < ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram)) + mem_size = ((models[model].flags & MODEL_AT) ? models[model].min_ram*1024 : models[model].min_ram); + if (mem_size > 1048576) + { + mem_size = 1048576; + } + + cpu_use_dynarec = !!config_get_int("Machine", "cpu_use_dynarec", 0); + + enable_external_fpu = !!config_get_int("Machine", "cpu_enable_fpu", 0); + + enable_sync = !!config_get_int("Machine", "enable_sync", 1); +} + +static void loadconfig_video(void) +{ + char *p; + + /* Video */ + p = (char *)config_get_string("Video", "gfxcard", ""); + if (p) + gfxcard = video_get_video_from_internal_name(p); + else + gfxcard = 0; + + video_speed = config_get_int("Video", "video_speed", 3); + + voodoo_enabled = !!config_get_int("Video", "voodoo", 0); +} + +static char s[512]; + +static void loadconfig_input_devices(void) +{ + int c, d; + char *p; + + /* Input devices */ + p = (char *)config_get_string("Input devices", "mouse_type", ""); + if (p) + mouse_type = mouse_get_from_internal_name(p); + else + mouse_type = 0; + + joystick_type = config_get_int("Input devices", "joystick_type", 0); + + for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) + { + sprintf(s, "joystick_%i_nr", c); + joystick_state[c].plat_joystick_nr = config_get_int("Input devices", s, 0); + + if (joystick_state[c].plat_joystick_nr) + { + for (d = 0; d < joystick_get_axis_count(joystick_type); d++) + { + sprintf(s, "joystick_%i_axis_%i", c, d); + joystick_state[c].axis_mapping[d] = config_get_int("Input devices", s, d); + } + for (d = 0; d < joystick_get_button_count(joystick_type); d++) + { + sprintf(s, "joystick_%i_button_%i", c, d); + joystick_state[c].button_mapping[d] = config_get_int("Input devices", s, d); + } + for (d = 0; d < joystick_get_pov_count(joystick_type); d++) + { + sprintf(s, "joystick_%i_pov_%i", c, d); + p = (char *)config_get_string("Input devices", s, "0, 0"); + joystick_state[c].pov_mapping[d][0] = joystick_state[c].pov_mapping[d][1] = 0; + sscanf(p, "%i, %i", &joystick_state[c].pov_mapping[d][0], &joystick_state[c].pov_mapping[d][1]); + } + } + } +} + +static void loadconfig_sound(void) +{ + char *p; + + /* Sound */ + p = (char *)config_get_string("Sound", "sndcard", ""); + if (p) + sound_card_current = sound_card_get_from_internal_name(p); + else + sound_card_current = 0; + + midi_id = config_get_int("Sound", "midi_host_device", 0); + + SSI2001 = !!config_get_int("Sound", "ssi2001", 0); + GAMEBLASTER = !!config_get_int("Sound", "gameblaster", 0); + GUS = !!config_get_int("Sound", "gus", 0); + opl3_type = !!config_get_int("Sound", "opl3_type", 1); +} + +static void loadconfig_network(void) +{ + char *p; + + /* Network */ + network_type = config_get_int("Network", "net_type", -1); + memset(pcap_dev, 0, 512); + p = (char *)config_get_string("Network", "net_pcap_device", "none"); + if (p) + if ((network_dev_to_id(p) == -1) || (netdev_num == 1)) + { + if ((netdev_num == 1) && strcmp(pcap_dev, "none")) + { + msgbox_error(ghwnd, 2107); + } + else if (network_dev_to_id(p) == -1) + { + msgbox_error(ghwnd, 2200); + } + + strcpy(pcap_dev, "none"); + } + else + { + strcpy(pcap_dev, p); + } + else + strcpy(pcap_dev, "none"); + p = (char *)config_get_string("Network", "net_card", NULL); + network_card = (p) ? network_card_get_from_internal_name(p) : 0; +} + +static void loadconfig_other_peripherals(void) +{ + int c; + char *p; + + /* Other peripherals */ + p = (char *)config_get_string("Other peripherals", "scsicard", ""); + if (p) + scsi_card_current = scsi_card_get_from_internal_name(p); + else + scsi_card_current = 0; + + memset(hdd_controller_name, 0, 16); + p = (char *)config_get_string("Other peripherals", "hdd_controller", ""); + if (p) + strcpy(hdd_controller_name, p); + else + strcpy(hdd_controller_name, "none"); + + memset(temps, 0, 512); + for (c = 2; c < 4; c++) + { + sprintf(temps, "ide_%02i", c + 1); + p = config_get_string("Other peripherals", temps, "0, 00"); + if (p) + { + sscanf(p, "%i, %02i", &ide_enable[c], &ide_irq[c]); + } + else + { + sscanf(p, "0, 00", &ide_enable[c], &ide_irq[c]); + } + } + + serial_enabled[0] = !!config_get_int("Other peripherals", "serial1_enabled", 1); + serial_enabled[1] = !!config_get_int("Other peripherals", "serial2_enabled", 1); + lpt_enabled = !!config_get_int("Other peripherals", "lpt_enabled", 1); + bugger_enabled = !!config_get_int("Other peripherals", "bugger_enabled", 0); +} + +static char temps2[512]; + +static int config_string_to_bus(char *str, int cdrom) +{ + if (!strcmp(str, "none")) + { + return 0; + } + + if (!strcmp(str, "mfm")) + { + if (cdrom) goto no_mfm_cdrom; + + return 1; + } + + if (!strcmp(str, "rll")) + { + if (cdrom) goto no_mfm_cdrom; + + return 1; + } + + if (!strcmp(str, "esdi")) + { + if (cdrom) goto no_mfm_cdrom; + + return 1; + } + + if (!strcmp(str, "ide_pio_only")) + { + return 2; + } + + if (!strcmp(str, "ide")) + { + return 2; + } + + if (!strcmp(str, "eide")) + { + return 2; + } + + if (!strcmp(str, "xtide")) + { + return 2; + } + + if (!strcmp(str, "atide")) + { + return 2; + } + + if (!strcmp(str, "ide_pio_and_dma")) + { + return 3; + } + + if (!strcmp(str, "scsi")) + { + return 4; + } + + if (!strcmp(str, "usb")) + { + msgbox_error(ghwnd, 2199); + return 0; + } + + return 0; + +no_mfm_cdrom: + msgbox_error(ghwnd, 2095); + return 0; +} + +static void loadconfig_hard_disks(void) +{ + int c; + char *p; + wchar_t *wp; + + /* Hard disks */ + memset(temps, 0, 512); + for (c = 0; c < HDC_NUM; c++) + { + sprintf(temps, "hdd_%02i_parameters", c + 1); + p = (char *)config_get_string("Hard disks", temps, "0, 0, 0, none"); + if (p) + { + sscanf(p, "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %s", &hdc[c].spt, &hdc[c].hpc, &hdc[c].tracks, s); + } + else + { + sscanf("0, 0, 0, none", "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %s", &hdc[c].spt, &hdc[c].hpc, &hdc[c].tracks, s); + } + + hdc[c].bus = config_string_to_bus(s, 0); + + if (hdc[c].spt > 99) + { + hdc[c].spt = 99; + } + if (hdc[c].hpc > 64) + { + hdc[c].hpc = 64; + } + if (hdc[c].tracks > 266305) + { + hdc[c].tracks = 266305; + } + + sprintf(temps, "hdd_%02i_mfm_channel", c + 1); + hdc[c].mfm_channel = config_get_int("Hard disks", temps, 0); + if (hdc[c].mfm_channel > 1) + { + hdc[c].mfm_channel = 1; + } + + sprintf(temps, "hdd_%02i_ide_channel", c + 1); + hdc[c].ide_channel = config_get_int("Hard disks", temps, 0); + if (hdc[c].ide_channel > 7) + { + hdc[c].ide_channel = 7; + } + + sprintf(temps, "hdd_%02i_scsi_location", c + 1); + sprintf(temps2, "%02u:%02u", c, 0); + p = (char *)config_get_string("Hard disks", temps, temps2); + if (p) + { + sscanf(p, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun); + } + else + { + sscanf(temps2, "%02u:%02u", &hdc[c].scsi_id, &hdc[c].scsi_lun); + } + + if (hdc[c].scsi_id > 15) + { + hdc[c].scsi_id = 15; + } + if (hdc[c].scsi_lun > 7) + { + hdc[c].scsi_lun = 7; + } + + memset(hdd_fn[c], 0, 1024); + sprintf(temps, "hdd_%02i_fn", c + 1); + wp = (wchar_t *)config_get_wstring("Hard disks", temps, L""); + if (wp) memcpy(hdd_fn[c], wp, 512); + else { + memcpy(hdd_fn[c], L"", 2); + hdd_fn[c][0] = L'\0'; + } + } +} + +static void loadconfig_removable_devices(void) +{ + int c; + char *p; + wchar_t *wp; + + /* Removable devices */ + for (c = 0; c < FDD_NUM; c++) + { + sprintf(temps, "fdd_%02i_type", c + 1); + p = (char *)config_get_string("Removable devices", temps, (c < 2) ? "525_2dd" : "none"); + if (p) + fdd_set_type(c, fdd_get_from_internal_name(p)); + else + fdd_set_type(c, (c < 2) ? 2 : 0); + if (fdd_get_type(c) > 13) + { + fdd_set_type(c, 13); + } + + sprintf(temps, "fdd_%02i_fn", c + 1); + wp = (wchar_t *)config_get_wstring("Removable devices", temps, L""); + if (wp) memcpy(discfns[c], wp, 512); + else { + memcpy(discfns[c], L"", 2); + discfns[c][0] = L'\0'; + } + printf("Floppy: %ws\n", discfns[c]); + sprintf(temps, "fdd_%02i_writeprot", c + 1); + ui_writeprot[c] = !!config_get_int("Removable devices", temps, 0); + } + + memset(temps, 0, 512); + for (c = 0; c < CDROM_NUM; c++) + { + sprintf(temps, "cdrom_%02i_host_drive", c + 1); + cdrom_drives[c].host_drive = config_get_int("Removable devices", temps, 0); + cdrom_drives[c].prev_host_drive = cdrom_drives[c].host_drive; + + sprintf(temps, "cdrom_%02i_parameters", c + 1); + p = (char *)config_get_string("Removable devices", temps, "0, none"); + if (p) + { + sscanf(p, "%u, %s", &cdrom_drives[c].sound_on, s); + } + else + { + sscanf("0, none", "%u, %s", &cdrom_drives[c].sound_on, s); + } + + cdrom_drives[c].bus_type = config_string_to_bus(s, 1); + + sprintf(temps, "cdrom_%02i_ide_channel", c + 1); + cdrom_drives[c].ide_channel = config_get_int("Removable devices", temps, c + 2); + if (cdrom_drives[c].ide_channel > 7) + { + cdrom_drives[c].ide_channel = 7; + } + + sprintf(temps, "cdrom_%02i_scsi_location", c + 1); + sprintf(temps2, "%02u:%02u", c + 2, 0); + p = (char *)config_get_string("Removable devices", temps, temps2); + if (p) + { + sscanf(p, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun); + } + else + { + sscanf(temps2, "%02u:%02u", &cdrom_drives[c].scsi_device_id, &cdrom_drives[c].scsi_device_lun); + } + + + if (cdrom_drives[c].scsi_device_id > 15) + { + cdrom_drives[c].scsi_device_id = 15; + } + if (cdrom_drives[c].scsi_device_lun > 7) + { + cdrom_drives[c].scsi_device_lun = 7; + } + + sprintf(temps, "cdrom_%02i_image_path", c + 1); + wp = (wchar_t *)config_get_wstring("Removable devices", temps, L""); + if (wp) memcpy(cdrom_image[c].image_path, wp, 512); + else { + memcpy(cdrom_image[c].image_path, L"", 2); + cdrom_image[c].image_path[0] = L'\0'; + } + } +} + +void loadconfig(wchar_t *fn) +{ + if (!fn) + config_load(config_file_default); + else + config_load(fn); + + /* General */ + loadconfig_general(); + + /* Machine */ + loadconfig_machine(); + + /* Video */ + loadconfig_video(); + + /* Input devices */ + loadconfig_input_devices(); + + /* Sound */ + loadconfig_sound(); + + /* Network */ + loadconfig_network(); + + /* Other peripherals */ + loadconfig_other_peripherals(); + + /* Hard disks */ + loadconfig_hard_disks(); + + /* Removable devices */ + loadconfig_removable_devices(); + } wchar_t temp_nvr_path[1024]; @@ -817,177 +1131,280 @@ wchar_t temp_nvr_path[1024]; wchar_t *nvr_concat(wchar_t *to_concat) { char *p; + wchar_t *wp; memset(temp_nvr_path, 0, 2048); wcscpy(temp_nvr_path, nvr_path); p = (char *) temp_nvr_path; p += (path_len * 2); - wchar_t *wp = (wchar_t *) p; + wp = (wchar_t *) p; wcscpy(wp, to_concat); return temp_nvr_path; } -void saveconfig(void) +void saveconfig_general(void) +{ + config_set_int("General", "vid_resize", vid_resize); + switch(vid_api) + { + case 0: + config_set_string("General", "vid_renderer", "ddraw"); + break; + case 1: + default: + config_set_string("General", "vid_renderer", "d3d9"); + break; + } + config_set_int("General", "video_fullscreen_scale", video_fullscreen_scale); + config_set_int("General", "video_fullscreen_first", video_fullscreen_first); + + config_set_int("General", "force_43", force_43); + config_set_int("General", "scale", scale); + config_set_int("General", "enable_overscan", enable_overscan); + + sprintf(temps, "%i, %i, %i, %i", window_w, window_h, window_x, window_y); + config_set_string("General", "window_coordinates", temps); + config_set_int("General", "window_remember", window_remember); + + config_set_wstring("General", "nvr_path", nvr_path); + +#ifndef __unix + config_set_hex16("General", "language", dwLanguage); +#endif +} + +void saveconfig_machine(void) +{ + /* Machine */ + config_set_string("Machine", "model", model_get_internal_name()); + config_set_int("Machine", "cpu_manufacturer", cpu_manufacturer); + config_set_int("Machine", "cpu", cpu); + config_set_int("Machine", "cpu_waitstates", cpu_waitstates); + + config_set_int("Machine", "mem_size", mem_size); + config_set_int("Machine", "cpu_use_dynarec", cpu_use_dynarec); + config_set_int("Machine", "cpu_enable_fpu", enable_external_fpu); + config_set_int("Machine", "enable_sync", enable_sync); +} + +void saveconfig_video(void) +{ + /* Video */ + config_set_string("Video", "gfxcard", video_get_internal_name(video_old_to_new(gfxcard))); + config_set_int("Video", "video_speed", video_speed); + config_set_int("Video", "voodoo", voodoo_enabled); +} + +void saveconfig_input_devices(void) { int c, d; - char temps[512]; + /* Input devices */ + config_set_string("Input devices", "mouse_type", mouse_get_internal_name(mouse_type)); - config_set_int(NULL, "gameblaster", GAMEBLASTER); - config_set_int(NULL, "gus", GUS); - config_set_int(NULL, "ssi2001", SSI2001); - config_set_int(NULL, "voodoo", voodoo_enabled); - - config_set_string(NULL, "scsicard", scsi_card_get_internal_name(scsi_card_current)); - - config_set_string(NULL, "net_card", network_card_get_internal_name(network_card)); - config_set_int(NULL, "net_type", network_type); -#if 1 - config_set_int(NULL, "maclocal", ne2000_get_maclocal()); - config_set_int(NULL, "maclocal_pci", ne2000_get_maclocal_pci()); -#endif - - config_set_string(NULL, "model", model_get_internal_name()); - config_set_int(NULL, "cpu_manufacturer", cpu_manufacturer); - config_set_int(NULL, "cpu", cpu); - config_set_int(NULL, "cpu_use_dynarec", cpu_use_dynarec); - config_set_int(NULL, "cpu_waitstates", cpu_waitstates); - - config_set_string(NULL, "gfxcard", video_get_internal_name(video_old_to_new(gfxcard))); - config_set_int(NULL, "video_speed", video_speed); - config_set_string(NULL, "sndcard", sound_card_get_internal_name(sound_card_current)); - config_set_int(NULL, "cpu_speed", cpuspeed); - config_set_int(NULL, "has_fpu", hasfpu); - - config_set_int(NULL, "mem_size", mem_size); - - memset(temps, 0, 512); - for (c = 0; c < FDD_NUM; c++) - { - sprintf(temps, "fdd_%02i_type", c + 1); - config_set_string(NULL, temps, fdd_get_internal_name(fdd_get_type(c))); - sprintf(temps, "fdd_%02i_fn", c + 1); - config_set_wstring(NULL, temps, discfns[c]); - sprintf(temps, "fdd_%02i_writeprot", c + 1); - config_set_int(NULL, temps, ui_writeprot[c]); - } - - config_set_string(NULL, "hdd_controller", hdd_controller_name); - - memset(temps, 0, 512); - for (c = 2; c < 4; c++) - { - sprintf(temps, "ide_%02i_enable", c + 1); - config_set_int(NULL, temps, ide_enable[c]); - sprintf(temps, "ide_%02i_irq", c + 1); - config_set_int(NULL, temps, ide_irq[c]); - } - - memset(temps, 0, 512); - for (c = 0; c < HDC_NUM; c++) - { - sprintf(temps, "hdd_%02i_sectors", c + 1); - config_set_int(NULL, temps, hdc[c].spt); - sprintf(temps, "hdd_%02i_heads", c + 1); - config_set_int(NULL, temps, hdc[c].hpc); - sprintf(temps, "hdd_%02i_cylinders", c + 1); - config_set_int(NULL, temps, hdc[c].tracks); - sprintf(temps, "hdd_%02i_bus_type", c + 1); - config_set_int(NULL, temps, hdc[c].bus); - sprintf(temps, "hdd_%02i_mfm_channel", c + 1); - config_set_int(NULL, temps, hdc[c].mfm_channel); - sprintf(temps, "hdd_%02i_ide_channel", c + 1); - config_set_int(NULL, temps, hdc[c].ide_channel); - sprintf(temps, "hdd_%02i_scsi_device_id", c + 1); - config_set_int(NULL, temps, hdc[c].scsi_id); - sprintf(temps, "hdd_%02i_scsi_device_lun", c + 1); - config_set_int(NULL, temps, hdc[c].scsi_lun); - sprintf(temps, "hdd_%02i_fn", c + 1); - config_set_wstring(NULL, temps, hdd_fn[c]); - } - - memset(temps, 0, 512); - for (c = 0; c < CDROM_NUM; c++) - { - sprintf(temps, "cdrom_%02i_host_drive", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].host_drive); - sprintf(temps, "cdrom_%02i_enabled", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].enabled); - sprintf(temps, "cdrom_%02i_sound_on", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].sound_on); - sprintf(temps, "cdrom_%02i_bus_type", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].bus_type); - sprintf(temps, "cdrom_%02i_atapi_dma", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].atapi_dma); - sprintf(temps, "cdrom_%02i_ide_channel", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].ide_channel); - sprintf(temps, "cdrom_%02i_scsi_device_id", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].scsi_device_id); - sprintf(temps, "cdrom_%02i_scsi_device_lun", c + 1); - config_set_int(NULL, temps, cdrom_drives[c].scsi_device_lun); - - sprintf(temps, "cdrom_%02i_image_path", c + 1); - config_set_wstring(NULL, temps, cdrom_image[c].image_path); - } - - config_set_int(NULL, "vid_resize", vid_resize); - config_set_int(NULL, "vid_api", vid_api); - config_set_int(NULL, "video_fullscreen_scale", video_fullscreen_scale); - config_set_int(NULL, "video_fullscreen_first", video_fullscreen_first); - - config_set_int(NULL, "force_43", force_43); - config_set_int(NULL, "scale", scale); - config_set_int(NULL, "enable_overscan", enable_overscan); - - config_set_int(NULL, "enable_sync", enable_sync); - config_set_int(NULL, "opl3_type", opl3_type); - - config_set_int(NULL, "joystick_type", joystick_type); - config_set_string(NULL, "mouse_type", mouse_get_internal_name(mouse_type)); - - config_set_int(NULL, "enable_external_fpu", enable_external_fpu); + config_set_int("Input devices", "joystick_type", joystick_type); for (c = 0; c < joystick_get_max_joysticks(joystick_type); c++) { - char s[80]; - sprintf(s, "joystick_%i_nr", c); - config_set_int("Joysticks", s, joystick_state[c].plat_joystick_nr); + config_set_int("Input devices", s, joystick_state[c].plat_joystick_nr); if (joystick_state[c].plat_joystick_nr) { for (d = 0; d < joystick_get_axis_count(joystick_type); d++) { sprintf(s, "joystick_%i_axis_%i", c, d); - config_set_int("Joysticks", s, joystick_state[c].axis_mapping[d]); + config_set_int("Input devices", s, joystick_state[c].axis_mapping[d]); } for (d = 0; d < joystick_get_button_count(joystick_type); d++) { sprintf(s, "joystick_%i_button_%i", c, d); - config_set_int("Joysticks", s, joystick_state[c].button_mapping[d]); + config_set_int("Input devices", s, joystick_state[c].button_mapping[d]); } for (d = 0; d < joystick_get_pov_count(joystick_type); d++) { - sprintf(s, "joystick_%i_pov_%i_x", c, d); - config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][0]); - sprintf(s, "joystick_%i_pov_%i_y", c, d); - config_set_int("Joysticks", s, joystick_state[c].pov_mapping[d][1]); + sprintf(s, "joystick_%i_pov_%i", c, d); + sprintf(temps, "%i, %i", joystick_state[c].pov_mapping[d][0], joystick_state[c].pov_mapping[d][1]); + config_set_string("Input devices", s, temps); } } } +} - config_set_int(NULL, "window_w", window_w); - config_set_int(NULL, "window_h", window_h); - config_set_int(NULL, "window_x", window_x); - config_set_int(NULL, "window_y", window_y); - config_set_int(NULL, "window_remember", window_remember); +void saveconfig_sound(void) +{ + /* Sound */ + config_set_string("Sound", "sndcard", sound_card_get_internal_name(sound_card_current)); + + config_set_int("Sound", "midi_host_device", midi_id); + + config_set_int("Sound", "gameblaster", GAMEBLASTER); + config_set_int("Sound", "gus", GUS); + config_set_int("Sound", "ssi2001", SSI2001); + config_set_int("Sound", "opl3_type", opl3_type); +} + +void saveconfig_network(void) +{ + /* Network */ + if (pcap_dev != NULL) + { + config_set_string("Network", "net_pcap_device", pcap_dev); + } + else + { + config_set_string("Network", "net_pcap_device", "none"); + } + config_set_int("Network", "net_type", network_type); + config_set_string("Network", "net_card", network_card_get_internal_name(network_card)); +} + +void saveconfig_other_peripherals(void) +{ + int c, d; + + /* Other peripherals */ + config_set_string("Other peripherals", "scsicard", scsi_card_get_internal_name(scsi_card_current)); + + config_set_string("Other peripherals", "hdd_controller", hdd_controller_name); + + memset(temps, 0, 512); + for (c = 2; c < 4; c++) + { + sprintf(temps, "ide_%02i", c + 1); + sprintf(temps2, "%i, %02i", !!ide_enable[c], ide_irq[c]); + config_set_string("Other peripherals", temps, temps2); + } + + config_set_int("Other peripherals", "serial1_enabled", serial_enabled[0]); + config_set_int("Other peripherals", "serial2_enabled", serial_enabled[1]); + config_set_int("Other peripherals", "lpt_enabled", lpt_enabled); + config_set_int("Other peripherals", "bugger_enabled", bugger_enabled); +} + +static char *config_bus_to_string(int bus) +{ + switch (bus) + { + case 0: + default: + return "none"; + break; + case 1: + return "mfm"; + break; + case 2: + return "ide_pio_only"; + break; + case 3: + return "ide_pio_and_dma"; + break; + case 4: + return "scsi"; + break; + } +} + +void saveconfig_hard_disks(void) +{ + int c, d; + char *p; + + /* Hard disks */ + memset(temps, 0, 512); + for (c = 0; c < HDC_NUM; c++) + { + sprintf(temps, "hdd_%02i_parameters", c + 1); + memset(s, 0, 512); + p = config_bus_to_string(hdc[c].bus); + sprintf(temps2, "%" PRIu64 ", %" PRIu64", %" PRIu64 ", %s", hdc[c].spt, hdc[c].hpc, hdc[c].tracks, p); + config_set_string("Hard disks", temps, temps2); + + sprintf(temps, "hdd_%02i_mfm_channel", c + 1); + config_set_int("Hard disks", temps, hdc[c].mfm_channel); + + sprintf(temps, "hdd_%02i_ide_channel", c + 1); + config_set_int("Hard disks", temps, hdc[c].ide_channel); + + sprintf(temps, "hdd_%02i_scsi_location", c + 1); + sprintf(temps2, "%02u:%02u", hdc[c].scsi_id, hdc[c].scsi_lun); + config_set_string("Hard disks", temps, temps2); + + sprintf(temps, "hdd_%02i_fn", c + 1); + config_set_wstring("Hard disks", temps, hdd_fn[c]); + } +} + +void saveconfig_removable_devices(void) +{ + int c, d; + + /* Removable devices */ + memset(temps, 0, 512); + for (c = 0; c < FDD_NUM; c++) + { + sprintf(temps, "fdd_%02i_type", c + 1); + config_set_string("Removable devices", temps, fdd_get_internal_name(fdd_get_type(c))); + sprintf(temps, "fdd_%02i_fn", c + 1); + config_set_wstring("Removable devices", temps, discfns[c]); + sprintf(temps, "fdd_%02i_writeprot", c + 1); + config_set_int("Removable devices", temps, ui_writeprot[c]); + } + + memset(temps, 0, 512); + for (c = 0; c < CDROM_NUM; c++) + { + sprintf(temps, "cdrom_%02i_host_drive", c + 1); + config_set_int("Removable devices", temps, cdrom_drives[c].host_drive); + + sprintf(temps, "cdrom_%02i_parameters", c + 1); + sprintf(temps2, "%u, %s", cdrom_drives[c].sound_on, config_bus_to_string(cdrom_drives[c].bus_type)); + config_set_string("Removable devices", temps, temps2); + + sprintf(temps, "cdrom_%02i_ide_channel", c + 1); + config_set_int("Removable devices", temps, cdrom_drives[c].ide_channel); + + sprintf(temps, "cdrom_%02i_scsi_location", c + 1); + sprintf(temps2, "%02u:%02u", cdrom_drives[c].scsi_device_id, cdrom_drives[c].scsi_device_lun); + config_set_string("Removable devices", temps, temps2); + + sprintf(temps, "cdrom_%02i_image_path", c + 1); + config_set_wstring("Removable devices", temps, cdrom_image[c].image_path); + } +} + +void saveconfig(void) +{ + int c, d; + + /* General */ + saveconfig_general(); + + /* Machine */ + saveconfig_machine(); + + /* Video */ + saveconfig_video(); + + /* Input devices */ + saveconfig_input_devices(); + + /* Sound */ + saveconfig_sound(); + + /* Network */ + saveconfig_network(); + + /* Other peripherals */ + saveconfig_other_peripherals(); + + /* Hard disks */ + saveconfig_hard_disks(); + + /* Removable devices */ + saveconfig_removable_devices(); - config_set_int(NULL, "serial1_enabled", serial_enabled[0]); - config_set_int(NULL, "serial2_enabled", serial_enabled[1]); - config_set_int(NULL, "lpt_enabled", lpt_enabled); - config_set_int(NULL, "bugger_enabled", bugger_enabled); - config_save(config_file_default); } diff --git a/src/device.c b/src/device.c index ec63744d5..5d92699c5 100644 --- a/src/device.c +++ b/src/device.c @@ -131,6 +131,37 @@ int device_get_config_int(char *s) return 0; } +int device_get_config_int_ex(char *s, int default_int) +{ + device_config_t *config = current_device->config; + + while (config->type != -1) + { + if (!strcmp(s, config->name)) + return config_get_int(current_device->name, s, default_int); + + config++; + } + return default_int; +} + +void device_set_config_int(char *s, int val) +{ + device_config_t *config = current_device->config; + + while (config->type != -1) + { + if (!strcmp(s, config->name)) + { + config_set_int(current_device->name, s, val); + return; + } + + config++; + } + return; +} + char *device_get_config_string(char *s) { device_config_t *config = current_device->config; diff --git a/src/device.h b/src/device.h index fb509ce7f..172c5c69b 100644 --- a/src/device.h +++ b/src/device.h @@ -2,7 +2,7 @@ #define CONFIG_INT 1 #define CONFIG_BINARY 2 #define CONFIG_SELECTION 3 -#define CONFIG_MIDI 4 +#define CONFIG_MAC 4 typedef struct device_config_selection_t { @@ -42,6 +42,8 @@ void device_force_redraw(); char *device_add_status_info(char *s, int max_len); int device_get_config_int(char *name); +int device_get_config_int_ex(char *s, int default_int); +void device_set_config_int(char *s, int val); char *device_get_config_string(char *name); enum diff --git a/src/ibm.h b/src/ibm.h index 44c9c1df6..8b4680fc0 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -560,11 +560,11 @@ typedef struct { int is_hdi; uint32_t base; uint64_t at_spt,at_hpc; /*[Translation] Sectors per track, heads per cylinder*/ - int bus; /* 0 = none, 1 = MFM/RLL, 2 = IDE, 3 = SCSI */ - uint8_t mfm_channel; - uint8_t ide_channel; - uint8_t scsi_id; - uint8_t scsi_lun; + unsigned int bus; /* 0 = none, 1 = MFM/RLL, 2 = IDE, 3 = SCSI */ + unsigned int mfm_channel; + unsigned int ide_channel; + unsigned int scsi_id; + unsigned int scsi_lun; } hard_disk_t; #pragma pack(pop) diff --git a/src/ide.c b/src/ide.c index afcb47778..b2b5a51bc 100644 --- a/src/ide.c +++ b/src/ide.c @@ -132,7 +132,7 @@ int ide_drive_is_cdrom(IDE *ide) } else { - if (cdrom_drives[atapi_cdrom_drives[ide->channel]].enabled && !cdrom_drives[atapi_cdrom_drives[ide->channel]].bus_type && (cdrom_drives[atapi_cdrom_drives[ide->channel]].bus_mode & 1)) + if ((cdrom_drives[atapi_cdrom_drives[ide->channel]].bus_type > 0) && (cdrom_drives[atapi_cdrom_drives[ide->channel]].bus_type < 3)) { return 1; } diff --git a/src/net_ne2000.c b/src/net_ne2000.c index 365cd2b75..0a4a66781 100644 --- a/src/net_ne2000.c +++ b/src/net_ne2000.c @@ -1767,6 +1767,19 @@ nic_rom_init(nic_t *dev, wchar_t *s) } +uint32_t +ne2000_get_maclocal(void) +{ + uint32_t temp; + + temp = (((int) maclocal[3]) << 16); + temp |= (((int) maclocal[4]) << 8); + temp |= ((int) maclocal[5]); + + return(temp); +} + + static void * nic_init(int board) { @@ -1779,44 +1792,50 @@ nic_init(int board) dev->board = board; dev->is_rtl8029as = (PCI && (board == NE2K_RTL8029AS)) ? 1 : 0; if (board == NE2K_RTL8029AS) + { strcpy(dev->name, "RTL8029AS"); - else if (board == NE2K_NE1000) + } + else if (board == NE2K_NE1000) + { strcpy(dev->name, "NE1000"); - else + } + else + { strcpy(dev->name, "NE2000"); + } dev->base_irq = device_get_config_int("irq"); dev->disable_netbios = device_get_config_int("disable_netbios"); if (dev->is_rtl8029as) { dev->base_address = 0x340; - mac = config_get_int(NULL, "maclocal_pci", -1); } else { dev->base_address = device_get_config_int("addr"); - mac = config_get_int(NULL, "maclocal", -1); } + mac = device_get_config_int_ex("mac", -1); + /* Set up our MAC address. */ if (dev->is_rtl8029as) { - maclocal_pci[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */ - maclocal_pci[1] = 0x20; - maclocal_pci[2] = 0x18; - ptr = maclocal_pci; + maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */ + maclocal[1] = 0x20; + maclocal[2] = 0x18; } else { maclocal[0] = 0x00; /* 00:00:D8 (NE2000 ISA vendor prefix). */ maclocal[1] = 0x00; maclocal[2] = 0xD8; - ptr = maclocal; } + ptr = maclocal; pclog(1, "MAClocal: mac=%08lx\n", mac); if (mac & 0xff000000) { /* Generating new MAC. */ ptr[3] = disc_random_generate(); ptr[4] = disc_random_generate(); - ptr[5] = disc_random_generate(); + ptr[5] = disc_random_generate() | 1; + device_set_config_int("mac", ne2000_get_maclocal()); } else { ptr[3] = (mac>>16) & 0xff; ptr[4] = (mac>>8) & 0xff; - ptr[5] = mac & 0xff; + ptr[5] = (mac & 0xff) | 1; } memcpy(dev->physaddr, ptr, 6); @@ -1906,32 +1925,6 @@ nic_close(void *priv) } -uint32_t -ne2000_get_maclocal(void) -{ - uint32_t temp; - - temp = (((int) maclocal[3]) << 16); - temp |= (((int) maclocal[4]) << 8); - temp |= ((int) maclocal[5]); - - return(temp); -} - - -uint32_t -ne2000_get_maclocal_pci(void) -{ - uint32_t temp; - - temp = (((int) maclocal_pci[3]) << 16); - temp |= (((int) maclocal_pci[4]) << 8); - temp |= ((int) maclocal_pci[5]); - - return(temp); -} - - static void * ne1000_init(void) { @@ -2012,6 +2005,9 @@ static device_config_t ne1000_config[] = } }, }, + { + "mac", "MAC Address", CONFIG_MAC, "", -1 + }, { "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 }, @@ -2085,6 +2081,9 @@ static device_config_t ne2000_config[] = } }, }, + { + "mac", "MAC Address", CONFIG_MAC, "", -1 + }, { "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 }, @@ -2132,6 +2131,9 @@ static device_config_t rtl8029as_config[] = } }, }, + { + "mac", "MAC Address", CONFIG_MAC, "", -1 + }, { "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 }, diff --git a/src/net_pcap.c b/src/net_pcap.c index f3db05131..459e04c71 100644 --- a/src/net_pcap.c +++ b/src/net_pcap.c @@ -29,6 +29,34 @@ static thread_t *poll_tid; static NETRXCB poll_rx; /* network RX function to call */ static void *poll_arg; /* network RX function arg */ + int netdev_num; + netdev_t netdev_list[512]; + + +#ifdef WALTJE +int pcap_do_log = 1; +# define ENABLE_PCAP_LOG +#else +int pcap_do_log = 0; +#endif + + +static void +pcap_log(const char *format, ...) +{ +#ifdef ENABLE_PCAP_LOG + va_list ap; + + if (pcap_do_log) { + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + fflush(stdout); + } +#endif +} +#define pclog pcap_log + /* Check if the interface has a packet for us. */ static void @@ -80,6 +108,8 @@ poll_thread(void *arg) } +char pcap_dev[512]; + /* Initialize WinPcap for us. */ int network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg) @@ -105,12 +135,11 @@ network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg) pclog("Initializing WinPcap, version %s\n", temp); /* Get the value of our capture interface. */ - dev = config_get_string(NULL, "pcap_device", NULL); - if (dev == NULL) { + if (pcap_dev == NULL) { pclog(" No network device configured!\n"); return(-1); } - pclog(" Network interface: '%s'\n", dev); + pclog(" Network interface: '%s'\n", pcap_dev); pcap = pcap_open_live(dev, /* interface name */ 1518, /* maximum packet size */ @@ -198,10 +227,16 @@ network_devlist(netdev_t *list) pcap_if_t *devlist, *dev; int i = 0; + /* Note by Kotori: Add the first (and guaranteed to be always present) device - "None". */ + strcpy(list->device, "none"); + strcpy(list->description, "None"); + list++; + i++; + /* Retrieve the device list from the local machine */ if (pcap_findalldevs(&devlist, errbuf) == -1) { pclog("NETWORK: error in pcap_findalldevs_ex: %s\n", errbuf); - return(-1); + return(i); /* Note by Kotori: The list will always have at least one entry - "None". */ } for (dev=devlist; dev!=NULL; dev=dev->next) { @@ -219,3 +254,19 @@ network_devlist(netdev_t *list) return(i); } + +int network_dev_to_id(char *dev) +{ + int i = 0; + + for (i = 0; i < netdev_num; i++) + { + if (!strcmp(netdev_list[i].device, dev)) + { + return i; + } + } + + /* If the device does not match the list, consider it as if it was set to "none". */ + return 0; +} \ No newline at end of file diff --git a/src/network.c b/src/network.c index f79f91628..7d1d6e98f 100644 --- a/src/network.c +++ b/src/network.c @@ -215,5 +215,5 @@ network_card_get_from_internal_name(char *s) c++; } - return(0); + return(-1); } diff --git a/src/network.h b/src/network.h index ed971e9b7..965d66f0b 100644 --- a/src/network.h +++ b/src/network.h @@ -45,6 +45,11 @@ typedef struct { extern int network_card; extern int network_type; +extern char pcap_dev[512]; + +extern int netdev_num; +extern netdev_t netdev_list[512]; + /* Function prototypes. */ extern void network_init(void); @@ -70,5 +75,6 @@ extern char *network_card_get_internal_name(int); extern int network_card_get_from_internal_name(char *); extern struct device_t *network_card_getdevice(int); + int network_dev_to_id(char *dev); #endif /*NETWORK_H*/ diff --git a/src/pc.c b/src/pc.c index 3dd43745b..9fced90fb 100644 --- a/src/pc.c +++ b/src/pc.c @@ -288,6 +288,9 @@ void initpc(int argc, wchar_t *argv[]) *p=L'\0'; pclog("path = %ws\n", pcempath); + /* Initialize list of PCap devices. */ + netdev_num = network_devlist(netdev_list); + for (c = 1; c < argc; c++) { if (!_wcsicmp(argv[c], L"--help")) diff --git a/src/plat-midi.h b/src/plat-midi.h index f258cdbcb..87ed57306 100644 --- a/src/plat-midi.h +++ b/src/plat-midi.h @@ -6,3 +6,5 @@ void midi_close(); void midi_write(uint8_t val); int midi_get_num_devs(); void midi_get_dev_name(int num, char *s); + +extern int midi_id; diff --git a/src/resource.h b/src/resource.h index bc0d8da03..5364bf674 100644 --- a/src/resource.h +++ b/src/resource.h @@ -11,11 +11,12 @@ #define CONFIGUREDLG_VIDEO 102 #define CONFIGUREDLG_INPUT 103 #define CONFIGUREDLG_SOUND 104 -#define CONFIGUREDLG_PERIPHERALS 105 -#define CONFIGUREDLG_HARD_DISKS 106 -#define CONFIGUREDLG_REMOVABLE_DEVICES 107 -#define ABOUTDLG 108 -#define CONFIGUREDLG_HARD_DISKS_ADD 109 +#define CONFIGUREDLG_NETWORK 105 +#define CONFIGUREDLG_PERIPHERALS 106 +#define CONFIGUREDLG_HARD_DISKS 107 +#define CONFIGUREDLG_REMOVABLE_DEVICES 108 +#define ABOUTDLG 109 +#define CONFIGUREDLG_HARD_DISKS_ADD 110 #define CONFIGUREDLG_MAIN 117 #define IDC_SETTINGSCATLIST 1004 #define IDC_LIST_HARD_DISKS 1005 @@ -77,6 +78,7 @@ #define IDC_COMBO_CD_CHANNEL_IDE 1073 #define IDC_COMBO_CD_ID 1074 #define IDC_COMBO_CD_LUN 1075 +#define IDC_COMBO_MIDI 1076 #define IDC_CHECK_CDROM_1_AUDIO_ENABLED 1584 #define IDC_CHECK_CDROM_2_AUDIO_ENABLED 1585 #define IDC_CHECK_CDROM_3_AUDIO_ENABLED 1586 @@ -228,7 +230,9 @@ #define IDC_COMBO386 1005 #define IDC_COMBO486 1006 #define IDC_COMBOSND 1007 -#define IDC_COMBONET 1008 +#define IDC_COMBONETTYPE 1008 +#define IDC_COMBOPCAP 1009 +#define IDC_COMBONET 1010 #define IDC_COMBOCPUM 1060 #define IDC_COMBOSPD 1061 #define IDC_COMBODR1 1062 @@ -361,8 +365,10 @@ #define IDC_CONFIGURESND 1201 #define IDC_CONFIGUREVOODOO 1202 #define IDC_CONFIGUREMOD 1203 -#define IDC_CONFIGURENET 1204 +#define IDC_CONFIGURENETTYPE 1204 #define IDC_CONFIGUREBUSLOGIC 1205 +#define IDC_CONFIGUREPCAP 1206 +#define IDC_CONFIGURENET 1207 #define IDC_JOY1 1210 #define IDC_JOY2 1211 #define IDC_JOY3 1212 @@ -418,7 +424,7 @@ #ifdef APSTUDIO_INVOKED # ifndef APSTUDIO_READONLY_SYMBOLS # define _APS_NO_MFC 1 -# define _APS_NEXT_RESOURCE_VALUE 110 +# define _APS_NEXT_RESOURCE_VALUE 111 # define _APS_NEXT_COMMAND_VALUE 40002 # define _APS_NEXT_CONTROL_VALUE 1055 # define _APS_NEXT_SYMED_VALUE 101 diff --git a/src/scsi_aha154x.c b/src/scsi_aha154x.c index 067b5dcea..7babc817a 100644 --- a/src/scsi_aha154x.c +++ b/src/scsi_aha154x.c @@ -1370,9 +1370,7 @@ aha_dev_present(uint8_t id, uint8_t lun) if (scsi_cdrom_drives[id][lun] >= CDROM_NUM) return(0); - if (cdrom_drives[scsi_cdrom_drives[id][lun]].enabled && - cdrom_drives[scsi_cdrom_drives[id][lun]].bus_type && - (cdrom_drives[scsi_cdrom_drives[id][lun]].bus_mode & 2)) return(1); + if ((cdrom_drives[scsi_cdrom_drives[id][lun]].bus_type == 4)) return(1); return(0); } diff --git a/src/scsi_buslogic.c b/src/scsi_buslogic.c index 11a4d3d27..e6631958d 100644 --- a/src/scsi_buslogic.c +++ b/src/scsi_buslogic.c @@ -1006,9 +1006,7 @@ buslogic_dev_present(uint8_t id, uint8_t lun) if (scsi_cdrom_drives[id][lun] >= CDROM_NUM) return(0); - if (cdrom_drives[scsi_cdrom_drives[id][lun]].enabled && - cdrom_drives[scsi_cdrom_drives[id][lun]].bus_type && - (cdrom_drives[scsi_cdrom_drives[id][lun]].bus_mode & 2)) return(1); + if ((cdrom_drives[scsi_cdrom_drives[id][lun]].bus_type == 4)) return(1); return(0); } diff --git a/src/win-deviceconfig.c b/src/win-deviceconfig.c index 6d00a0050..196845359 100644 --- a/src/win-deviceconfig.c +++ b/src/win-deviceconfig.c @@ -9,7 +9,6 @@ #include "ibm.h" #include "config.h" #include "device.h" -#include "plat-midi.h" #include "resource.h" #include "win.h" @@ -60,21 +59,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam id += 2; break; - - case CONFIG_MIDI: - val_int = config_get_int(NULL, config->name, config->default_int); - - num = midi_get_num_devs(); - for (c = 0; c < num; c++) - { - midi_get_dev_name(c, s); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s); - if (val_int == c) - SendMessage(h, CB_SETCURSEL, c, 0); - } - - id += 2; - break; } config++; } @@ -120,17 +104,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam id += 2; break; - - case CONFIG_MIDI: - val_int = config_get_int(NULL, config->name, config->default_int); - - c = SendMessage(h, CB_GETCURSEL, 0, 0); - - if (val_int != c) - changed = 1; - - id += 2; - break; } config++; } @@ -171,13 +144,6 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam id += 2; break; - - case CONFIG_MIDI: - c = SendMessage(h, CB_GETCURSEL, 0, 0); - config_set_int(NULL, config->name, c); - - id += 2; - break; } config++; } @@ -254,7 +220,6 @@ void deviceconfig_open(HWND hwnd, device_t *device) break; case CONFIG_SELECTION: - case CONFIG_MIDI: /*Combo box*/ item = (DLGITEMTEMPLATE *)data; item->x = 70; diff --git a/src/win-language.c b/src/win-language.c index a2820beb8..c2525db48 100644 --- a/src/win-language.c +++ b/src/win-language.c @@ -21,7 +21,7 @@ LCID dwLanguage; uint32_t dwLangID, dwSubLangID; -#define STRINGS_NUM 152 +#define STRINGS_NUM 154 WCHAR lpResourceString[STRINGS_NUM][512]; diff --git a/src/win-language.h b/src/win-language.h index 113c16f44..5c4237249 100644 --- a/src/win-language.h +++ b/src/win-language.h @@ -2,6 +2,8 @@ extern "C" { #endif +LCID dwLanguage; + int msgbox_reset(HWND hwndParent); int msgbox_reset_yn(HWND hwndParent); int msgbox_question(HWND hwndParent, int i); diff --git a/src/win-midi.c b/src/win-midi.c index 621510ab2..a11c7bfea 100644 --- a/src/win-midi.c +++ b/src/win-midi.c @@ -7,34 +7,65 @@ #include "config.h" #include "plat-midi.h" -static int midi_id; +int midi_id; static HMIDIOUT midi_out_device = NULL; HANDLE m_event; void midi_close(); +static uint8_t midi_rt_buf[1024]; +static uint8_t midi_cmd_buf[1024]; +static int midi_cmd_pos = 0; +static int midi_cmd_len = 0; +static uint8_t midi_status = 0; +static unsigned int midi_sysex_start = 0; +static unsigned int midi_sysex_delay = 0; + +uint8_t MIDI_evt_len[256] = { + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x00 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x10 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x20 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x30 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x40 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x50 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x60 + 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x70 + + 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x80 + 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x90 + 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xa0 + 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xb0 + + 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xc0 + 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xd0 + + 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xe0 + + 0,2,3,2, 0,0,1,0, 1,0,1,1, 1,0,1,0 // 0xf0 +}; + void midi_init() { MMRESULT hr = MMSYSERR_NOERROR; - + + memset(midi_rt_buf, 0, 1024); + memset(midi_cmd_buf, 0, 1024); + + midi_cmd_pos = midi_cmd_len = 0; + midi_status = 0; + + midi_sysex_start = midi_sysex_delay = 0; + midi_id = config_get_int(NULL, "midi", 0); m_event = CreateEvent(NULL, TRUE, TRUE, NULL); -#if 0 - hr = midiOutOpen(&midi_out_device, midi_id, 0, - 0, CALLBACK_NULL); -#endif hr = midiOutOpen(&midi_out_device, midi_id, (DWORD) m_event, 0, CALLBACK_EVENT); if (hr != MMSYSERR_NOERROR) { printf("midiOutOpen error - %08X\n",hr); midi_id = 0; -#if 0 - hr = midiOutOpen(&midi_out_device, midi_id, 0, - 0, CALLBACK_NULL); -#endif hr = midiOutOpen(&midi_out_device, midi_id, (DWORD) m_event, 0, CALLBACK_EVENT); if (hr != MMSYSERR_NOERROR) { @@ -82,82 +113,13 @@ static void midi_send_sysex() hdr.lpData = midi_sysex_data; hdr.dwBufferLength = midi_pos; hdr.dwFlags = 0; - -/* pclog("Sending sysex : "); - for (c = 0; c < midi_pos; c++) - pclog("%02x ", midi_sysex_data[c]); - pclog("\n");*/ - + midiOutPrepareHeader(midi_out_device, &hdr, sizeof(MIDIHDR)); midiOutLongMsg(midi_out_device, &hdr, sizeof(MIDIHDR)); - + midi_insysex = 0; } -#if 0 -void midi_write(uint8_t val) -{ - if ((val & 0x80) && !(val == 0xf7 && midi_insysex)) - { - midi_pos = 0; - midi_len = midi_lengths[(val >> 4) & 7]; - midi_command = 0; - if (val == 0xf0) - midi_insysex = 1; - } - - if (midi_insysex) - { - midi_sysex_data[midi_pos++] = val; - - if (val == 0xf7 || midi_pos >= 1024+2) - midi_send_sysex(); - return; - } - - if (midi_len) - { - midi_command |= (val << (midi_pos * 8)); - - midi_pos++; - - if (midi_pos == midi_len) - midiOutShortMsg(midi_out_device, midi_command); - } -} -#endif - -static uint8_t midi_rt_buf[1024] = { 0, 0, 0, 0 }; -static uint8_t midi_cmd_buf[1024] = { 0, 0, 0, 0 }; -static int midi_cmd_pos = 0; -static int midi_cmd_len = 0; -static uint8_t midi_status = 0; -static int midi_sysex_start = 0; -static int midi_sysex_delay = 0; - -uint8_t MIDI_evt_len[256] = { - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x00 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x10 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x20 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x30 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x40 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x50 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x60 - 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // 0x70 - - 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x80 - 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0x90 - 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xa0 - 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xb0 - - 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xc0 - 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, // 0xd0 - - 3,3,3,3, 3,3,3,3, 3,3,3,3, 3,3,3,3, // 0xe0 - - 0,2,3,2, 0,0,1,0, 1,0,1,1, 1,0,1,0 // 0xf0 -}; - void PlayMsg(uint8_t *msg) { midiOutShortMsg(midi_out_device, *(uint32_t *) msg); @@ -197,12 +159,19 @@ void PlaySysex(uint8_t *sysex, unsigned int len) #define SYSEX_SIZE 1024 #define RAWBUF 1024 -int GetTicks() -{ -} - void midi_write(uint8_t val) { + uint32_t passed_ticks; + + if (midi_sysex_start) + { + passed_ticks = GetTickCount() - midi_sysex_start; + if (passed_ticks < midi_sysex_delay) + { + Sleep(midi_sysex_delay - passed_ticks); + } + } + /* Test for a realtime MIDI message */ if (val >= 0xf8) { @@ -248,7 +217,7 @@ void midi_write(uint8_t val) else midi_sysex_delay = (unsigned int) (((float) (midi_pos) * 1.25f) * 1000.0f / 3125.0f) + 2; - midi_sysex_start = GetTicks(); + midi_sysex_start = GetTickCount(); } } } diff --git a/src/win-settings.c b/src/win-settings.c index 8567391d1..308477b70 100644 --- a/src/win-settings.c +++ b/src/win-settings.c @@ -23,6 +23,7 @@ #include "scsi.h" #include "scsi_buslogic.h" #include "network.h" +#include "plat-midi.h" #include "sound/sound.h" #include "sound/snd_dbopl.h" #include "video/video.h" @@ -47,10 +48,14 @@ int temp_gfxcard, temp_video_speed, temp_voodoo; int temp_mouse, temp_joystick; /* Sound category */ -int temp_sound_card, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; +int temp_sound_card, temp_midi_id, temp_SSI2001, temp_GAMEBLASTER, temp_GUS, temp_opl3_type; + +/* Network category */ +int temp_net_type, temp_net_card; +char temp_pcap_dev[520]; /* Peripherals category */ -int temp_scsi_card, temp_net_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; +int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; int temp_serial[2], temp_lpt, temp_bugger; char temp_hdc_name[16]; @@ -102,14 +107,20 @@ static void win_settings_init() /* Sound category */ temp_sound_card = sound_card_current; + temp_midi_id = midi_id; temp_SSI2001 = SSI2001; temp_GAMEBLASTER = GAMEBLASTER; temp_GUS = GUS; temp_opl3_type = opl3_type; + /* Network category */ + temp_net_type = network_type; + memset(temp_pcap_dev, 0, 520); + strcpy(temp_pcap_dev, pcap_dev); + temp_net_card = network_card; + /* Peripherals category */ temp_scsi_card = scsi_card_current; - temp_net_card = network_card; strncpy(temp_hdc_name, hdd_controller_name, sizeof(temp_hdc_name) - 1); temp_ide_ter = ide_enable[2]; temp_ide_ter_irq = ide_irq[2]; @@ -161,14 +172,19 @@ static int win_settings_changed() /* Sound category */ i = i || (sound_card_current != temp_sound_card); + i = i || (midi_id != temp_midi_id); i = i || (SSI2001 != temp_SSI2001); i = i || (GAMEBLASTER != temp_GAMEBLASTER); i = i || (GUS != temp_GUS); i = i || (opl3_type != temp_opl3_type); + /* Network category */ + i = i || (network_type != temp_net_type); + i = i || strcmp(temp_pcap_dev, pcap_dev); + i = i || (network_card != temp_net_card); + /* Peripherals category */ i = i || (scsi_card_current != temp_scsi_card); - i = i || (network_card != temp_net_card); i = i || strncmp(temp_hdc_name, hdd_controller_name, sizeof(temp_hdc_name) - 1); i = i || (temp_ide_ter != ide_enable[2]); i = i || (temp_ide_ter_irq != ide_irq[2]); @@ -252,14 +268,20 @@ static void win_settings_save() /* Sound category */ sound_card_current = temp_sound_card; + midi_id = temp_midi_id; SSI2001 = temp_SSI2001; GAMEBLASTER = temp_GAMEBLASTER; GUS = temp_GUS; opl3_type = temp_opl3_type; + /* Network category */ + network_type = temp_net_type; + memset(pcap_dev, 0, 512); + strcpy(pcap_dev, temp_pcap_dev); + network_card = temp_net_card; + /* Peripherals category */ scsi_card_current = temp_scsi_card; - network_card = temp_net_card; strncpy(hdd_controller_name, temp_hdc_name, sizeof(temp_hdc_name) - 1); ide_enable[2] = temp_ide_ter; ide_irq[2] = temp_ide_ter_irq; @@ -1061,6 +1083,8 @@ int find_irq_in_array(int irq, int def) return 7 + def; } +static char midi_dev_name_buf[512]; + static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; @@ -1068,6 +1092,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa int d = 0; LPTSTR lptsTemp; device_t *sound_dev; + int num = 0; switch (message) { @@ -1121,6 +1146,18 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa EnableWindow(h, FALSE); } + h = GetDlgItem(hdlg, IDC_COMBO_MIDI); + num = midi_get_num_devs(); + for (c = 0; c < num; c++) + { + memset(midi_dev_name_buf, 0, 512); + midi_get_dev_name(c, midi_dev_name_buf); + mbstowcs(lptsTemp, midi_dev_name_buf, strlen(midi_dev_name_buf) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + if (c == temp_midi_id) + SendMessage(h, CB_SETCURSEL, c, 0); + } + h=GetDlgItem(hdlg, IDC_CHECKCMS); SendMessage(h, BM_SETCHECK, temp_GAMEBLASTER, 0); @@ -1168,6 +1205,9 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa h = GetDlgItem(hdlg, IDC_COMBOSND); temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)]; + h = GetDlgItem(hdlg, IDC_COMBO_MIDI); + temp_midi_id = SendMessage(h, CB_GETCURSEL, 0, 0); + h = GetDlgItem(hdlg, IDC_CHECKCMS); temp_GAMEBLASTER = SendMessage(h, BM_GETCHECK, 0, 0); @@ -1199,7 +1239,7 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR case WM_INITDIALOG: lptsTemp = (LPTSTR) malloc(512); - /*NIC config*/ + /*SCSI config*/ h = GetDlgItem(hdlg, IDC_COMBO_SCSI); c = d = 0; while (1) @@ -1249,49 +1289,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR recalc_hdd_list(hdlg, temp_model, 0); - /*NIC config*/ - h = GetDlgItem(hdlg, IDC_COMBONET); - c = d = 0; - while (1) - { - char *s = network_card_getname(c); - - if (!s[0]) - { - break; - } - - settings_network_to_list[c] = d; - - if (network_card_available(c)) - { - if (c == 0) - { - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152)); - } - else - { - mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); - } - settings_list_to_network[d] = c; - d++; - } - - c++; - } - SendMessage(h, CB_SETCURSEL, settings_network_to_list[temp_net_card], 0); - - h = GetDlgItem(hdlg, IDC_CONFIGURENET); - if (network_card_has_config(temp_net_card)) - { - EnableWindow(h, TRUE); - } - else - { - EnableWindow(h, FALSE); - } - h=GetDlgItem(hdlg, IDC_COMBO_IDE_TER); SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2151)); @@ -1347,28 +1344,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR case WM_COMMAND: switch (LOWORD(wParam)) { - case IDC_CONFIGURENET: - h = GetDlgItem(hdlg, IDC_COMBONET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; - - deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_net_card)); - break; - - case IDC_COMBONET: - h = GetDlgItem(hdlg, IDC_COMBONET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; - - h = GetDlgItem(hdlg, IDC_CONFIGURENET); - if (network_card_has_config(temp_net_card)) - { - EnableWindow(h, TRUE); - } - else - { - EnableWindow(h, FALSE); - } - break; - case IDC_CONFIGURE_SCSI: h = GetDlgItem(hdlg, IDC_COMBO_SCSI); temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; @@ -1415,9 +1390,6 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR h = GetDlgItem(hdlg, IDC_COMBO_SCSI); temp_scsi_card = settings_list_to_scsi[SendMessage(h, CB_GETCURSEL, 0, 0)]; - h = GetDlgItem(hdlg, IDC_COMBONET); - temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; - h = GetDlgItem(hdlg, IDC_COMBO_IDE_TER); temp_ide_ter = SendMessage(h, CB_GETCURSEL, 0, 0); if (temp_ide_ter > 1) @@ -1452,6 +1424,203 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR return FALSE; } +int net_ignore_message = 0; + +static void network_recalc_combos(HWND hdlg) +{ + HWND h; + + net_ignore_message = 1; + + h = GetDlgItem(hdlg, IDC_COMBOPCAP); + if (temp_net_type == 1) + { + EnableWindow(h, TRUE); + } + else + { + EnableWindow(h, FALSE); + } + + h = GetDlgItem(hdlg, IDC_COMBONET); + if (temp_net_type == 0) + { + EnableWindow(h, TRUE); + } + else if ((temp_net_type == 1) && (network_dev_to_id(temp_pcap_dev) > 0)) + { + EnableWindow(h, TRUE); + } + else + { + EnableWindow(h, FALSE); + } + + h = GetDlgItem(hdlg, IDC_CONFIGURENET); + if (network_card_has_config(temp_net_card) && (temp_net_type == 0)) + { + EnableWindow(h, TRUE); + } + else if (network_card_has_config(temp_net_card) && (temp_net_type == 1) && (network_dev_to_id(temp_pcap_dev) > 0)) + { + EnableWindow(h, TRUE); + } + else + { + EnableWindow(h, FALSE); + } + + net_ignore_message = 0; +} + +static BOOL CALLBACK win_settings_network_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + HWND h; + int c = 0; + int d = 0; + LPTSTR lptsTemp; + device_t *scsi_dev; + + switch (message) + { + case WM_INITDIALOG: + lptsTemp = (LPTSTR) malloc(512); + + h = GetDlgItem(hdlg, IDC_COMBONETTYPE); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) L"None"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) L"PCap"); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) L"SLiRP"); + SendMessage(h, CB_SETCURSEL, temp_net_type + 1, 0); + + h = GetDlgItem(hdlg, IDC_COMBOPCAP); + if (temp_net_type == 0) + { + EnableWindow(h, TRUE); + } + else + { + EnableWindow(h, FALSE); + } + + h = GetDlgItem(hdlg, IDC_COMBOPCAP); + for (c = 0; c < netdev_num; c++) + { + mbstowcs(lptsTemp, netdev_list[c].description, strlen(netdev_list[c].description) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + SendMessage(h, CB_SETCURSEL, network_dev_to_id(temp_pcap_dev), 0); + + /*NIC config*/ + h = GetDlgItem(hdlg, IDC_COMBONET); + c = d = 0; + while (1) + { + char *s = network_card_getname(c); + + if (!s[0]) + { + break; + } + + settings_network_to_list[c] = d; + + if (network_card_available(c)) + { + if (c == 0) + { + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152)); + } + else + { + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + } + settings_list_to_network[d] = c; + d++; + } + + c++; + } + SendMessage(h, CB_SETCURSEL, settings_network_to_list[temp_net_card], 0); + + network_recalc_combos(hdlg); + + free(lptsTemp); + + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDC_COMBONETTYPE: + if (net_ignore_message) + { + return FALSE; + } + + h = GetDlgItem(hdlg, IDC_COMBONETTYPE); + temp_net_type = SendMessage(h, CB_GETCURSEL, 0, 0) - 1; + + network_recalc_combos(hdlg); + break; + + case IDC_COMBOPCAP: + if (net_ignore_message) + { + return FALSE; + } + + h = GetDlgItem(hdlg, IDC_COMBOPCAP); + memset(temp_pcap_dev, 0, 520); + strcpy(temp_pcap_dev, netdev_list[SendMessage(h, CB_GETCURSEL, 0, 0)].device); + + network_recalc_combos(hdlg); + break; + + case IDC_COMBONET: + if (net_ignore_message) + { + return FALSE; + } + + h = GetDlgItem(hdlg, IDC_COMBONET); + temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + + network_recalc_combos(hdlg); + break; + + case IDC_CONFIGURENET: + if (net_ignore_message) + { + return FALSE; + } + + h = GetDlgItem(hdlg, IDC_COMBONET); + temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + + deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_net_card)); + break; + } + return FALSE; + + case WM_SAVESETTINGS: + h = GetDlgItem(hdlg, IDC_COMBONETTYPE); + temp_net_type = SendMessage(h, CB_GETCURSEL, 0, 0) - 1; + + h = GetDlgItem(hdlg, IDC_COMBOPCAP); + memset(temp_pcap_dev, 0, 520); + strcpy(temp_pcap_dev, netdev_list[SendMessage(h, CB_GETCURSEL, 0, 0)].device); + + h = GetDlgItem(hdlg, IDC_COMBONET); + temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)]; + + default: + return FALSE; + } + + return FALSE; +} + static BOOL win_settings_hard_disks_image_list_init(HWND hwndList) { HICON hiconItem; @@ -2687,32 +2856,6 @@ static BOOL CALLBACK win_settings_hard_disks_proc(HWND hdlg, UINT message, WPARA int fdlv_current_sel; int cdlv_current_sel; -static void combo_id_to_bus(int combo_id) -{ - switch (combo_id) - { - case 0: /* Disabled */ - default: - temp_cdrom_drives[cdlv_current_sel].enabled = 0; - break; - case 1: /* Atapi (PIO-only) */ - temp_cdrom_drives[cdlv_current_sel].enabled = 1; - temp_cdrom_drives[cdlv_current_sel].bus_type = 0; - temp_cdrom_drives[cdlv_current_sel].atapi_dma = 0; - break; - case 2: /* Atapi (PIA and DMA) */ - temp_cdrom_drives[cdlv_current_sel].enabled = 1; - temp_cdrom_drives[cdlv_current_sel].bus_type = 0; - temp_cdrom_drives[cdlv_current_sel].atapi_dma = 1; - break; - case 3: /* SCSI */ - temp_cdrom_drives[cdlv_current_sel].enabled = 1; - temp_cdrom_drives[cdlv_current_sel].bus_type = 1; - temp_cdrom_drives[cdlv_current_sel].atapi_dma = 0; - break; - } -} - static int combo_id_to_string_id(int combo_id) { switch (combo_id) @@ -2721,13 +2864,13 @@ static int combo_id_to_string_id(int combo_id) default: return 2151; break; - case 1: /* Atapi (PIO-only) */ + case 2: /* Atapi (PIO-only) */ return 2189; break; - case 2: /* Atapi (PIA and DMA) */ + case 3: /* Atapi (PIA and DMA) */ return 2190; break; - case 3: /* SCSI */ + case 4: /* SCSI */ return 2168; break; } @@ -2741,46 +2884,18 @@ static int combo_id_to_format_string_id(int combo_id) default: return 2151; break; - case 1: /* Atapi (PIO-only) */ + case 2: /* Atapi (PIO-only) */ return 2191; break; - case 2: /* Atapi (PIA and DMA) */ + case 3: /* Atapi (PIA and DMA) */ return 2192; break; - case 3: /* SCSI */ + case 4: /* SCSI */ return 2158; break; } } -static int bus_to_combo_id(int id) -{ - if (temp_cdrom_drives[id].enabled) - { - if (temp_cdrom_drives[id].bus_type) - { - return 3; - } - else - { - if (temp_cdrom_drives[id].atapi_dma) - { - return 2; - } - else - { - return 1; - } - } - } - else - { - return 0; - } - - return 0; -} - static BOOL win_settings_floppy_drives_image_list_init(HWND hwndList) { HICON hiconItem; @@ -2883,28 +2998,35 @@ static BOOL win_settings_cdrom_drives_recalc_list(HWND hwndList) for (i = 0; i < 4; i++) { - bid = bus_to_combo_id(i); - fsid = combo_id_to_format_string_id(bid); + fsid = combo_id_to_format_string_id(temp_cdrom_drives[i].bus_type); - switch (bid) + switch (temp_cdrom_drives[i].bus_type) { case 0: default: lvI.pszText = win_language_get_string_from_id(fsid); break; - case 1: case 2: + case 3: wsprintf(szText, win_language_get_string_from_id(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1); lvI.pszText = szText; break; - case 3: + case 4: wsprintf(szText, win_language_get_string_from_id(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun); lvI.pszText = szText; break; } lvI.iItem = i; - lvI.iImage = bid; + + if (temp_cdrom_drives[i].bus_type) + { + lvI.iImage = temp_cdrom_drives[i].bus_type - 1; + } + else + { + lvI.iImage = 0; + } if (ListView_InsertItem(hwndList, &lvI) == -1) return FALSE; @@ -3035,27 +3157,33 @@ static void win_settings_cdrom_drives_update_item(HWND hwndList, int i) lvI.iSubItem = 0; lvI.iItem = i; - bid = bus_to_combo_id(i); - fsid = combo_id_to_format_string_id(bid); + fsid = combo_id_to_format_string_id(temp_cdrom_drives[i].bus_type); - switch (bid) + switch (temp_cdrom_drives[i].bus_type) { case 0: default: lvI.pszText = win_language_get_string_from_id(fsid); break; - case 1: case 2: + case 3: wsprintf(szText, win_language_get_string_from_id(fsid), temp_cdrom_drives[i].ide_channel >> 1, temp_cdrom_drives[i].ide_channel & 1); lvI.pszText = szText; break; - case 3: + case 4: wsprintf(szText, win_language_get_string_from_id(fsid), temp_cdrom_drives[i].scsi_device_id, temp_cdrom_drives[i].scsi_device_lun); lvI.pszText = szText; break; } - lvI.iImage = bid; + if (temp_cdrom_drives[i].bus_type) + { + lvI.iImage = temp_cdrom_drives[i].bus_type - 1; + } + else + { + lvI.iImage = 0; + } if (ListView_SetItem(hwndList, &lvI) == -1) { @@ -3072,7 +3200,7 @@ static void cdrom_add_locations(HWND hdlg) lptsTemp = (LPTSTR) malloc(512); h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); - for (i = 0; i < 4; i++) + for (i = 1; i < 5; i++) { SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(combo_id_to_string_id(i))); } @@ -3105,7 +3233,7 @@ static void cdrom_recalc_location_controls(HWND hdlg) int i = 0; HWND h; - int bus = bus_to_combo_id(cdlv_current_sel); + int bus = temp_cdrom_drives[cdlv_current_sel].bus_type; for (i = 1800; i < 1803; i++) { @@ -3128,8 +3256,8 @@ static void cdrom_recalc_location_controls(HWND hdlg) switch(bus) { - case 1: /* ATAPI (PIO-only) */ - case 2: /* ATAPI (PIO and DMA) */ + case 2: /* ATAPI (PIO-only) */ + case 3: /* ATAPI (PIO and DMA) */ h = GetDlgItem(hdlg, 1802); ShowWindow(h, SW_SHOW); EnableWindow(h, TRUE); @@ -3139,7 +3267,7 @@ static void cdrom_recalc_location_controls(HWND hdlg) EnableWindow(h, TRUE); SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].ide_channel, 0); break; - case 3: /* SCSI */ + case 4: /* SCSI */ h = GetDlgItem(hdlg, 1800); ShowWindow(h, SW_SHOW); EnableWindow(h, TRUE); @@ -3205,7 +3333,14 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message ListView_SetItemState(h, 0, LVIS_FOCUSED | LVIS_SELECTED, 0x000F); cdrom_add_locations(hdlg); h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); - SendMessage(h, CB_SETCURSEL, bus_to_combo_id(cdlv_current_sel), 0); + if (temp_cdrom_drives[cdlv_current_sel].bus_type > 1) + { + SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type, 0); + } + else + { + SendMessage(h, CB_SETCURSEL, 0, 0); + } cdrom_recalc_location_controls(hdlg); rd_ignore_change = 0; @@ -3256,7 +3391,14 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message } rd_ignore_change = 1; h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); - SendMessage(h, CB_SETCURSEL, bus_to_combo_id(cdlv_current_sel), 0); + if (temp_cdrom_drives[cdlv_current_sel].bus_type > 1) + { + SendMessage(h, CB_SETCURSEL, temp_cdrom_drives[cdlv_current_sel].bus_type, 0); + } + else + { + SendMessage(h, CB_SETCURSEL, 0, 0); + } cdrom_recalc_location_controls(hdlg); rd_ignore_change = 0; } @@ -3287,8 +3429,11 @@ static BOOL CALLBACK win_settings_removable_devices_proc(HWND hdlg, UINT message rd_ignore_change = 1; h = GetDlgItem(hdlg, IDC_COMBO_CD_BUS); - cid = SendMessage(h, CB_GETCURSEL, 0, 0); - combo_id_to_bus(cid); + temp_cdrom_drives[cdlv_current_sel].bus_type = SendMessage(h, CB_GETCURSEL, 0, 0) + 1; + if (temp_cdrom_drives[cdlv_current_sel].bus_type == 1) + { + temp_cdrom_drives[cdlv_current_sel].bus_type = 0; + } cdrom_recalc_location_controls(hdlg); h = GetDlgItem(hdlg, IDC_LIST_CDROM_DRIVES); win_settings_cdrom_drives_update_item(h, cdlv_current_sel); @@ -3375,12 +3520,15 @@ void win_settings_show_child(HWND hwndParent, DWORD child_id) hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_SOUND, hwndParent, win_settings_sound_proc); break; case 4: - hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_PERIPHERALS, hwndParent, win_settings_peripherals_proc); + hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_NETWORK, hwndParent, win_settings_network_proc); break; case 5: - hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_HARD_DISKS, hwndParent, win_settings_hard_disks_proc); + hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_PERIPHERALS, hwndParent, win_settings_peripherals_proc); break; case 6: + hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_HARD_DISKS, hwndParent, win_settings_hard_disks_proc); + break; + case 7: hwndChildDialog = CreateDialog(hinstance, (LPCWSTR) CONFIGUREDLG_REMOVABLE_DEVICES, hwndParent, win_settings_removable_devices_proc); break; default: @@ -3402,7 +3550,7 @@ static BOOL win_settings_main_image_list_init(HWND hwndList) GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, 1, 1); - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) { hiconItem = LoadIcon(hinstance, (LPCWSTR) (256 + i)); ImageList_AddIcon(hSmall, hiconItem); @@ -3422,7 +3570,7 @@ static BOOL win_settings_main_insert_categories(HWND hwndList) lvI.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE; lvI.stateMask = lvI.iSubItem = lvI.state = 0; - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) { lvI.pszText = win_language_get_settings_category(i); lvI.iItem = i; @@ -3465,7 +3613,7 @@ static BOOL CALLBACK win_settings_main_proc(HWND hdlg, UINT message, WPARAM wPar if ((((LPNMHDR)lParam)->code == LVN_ITEMCHANGED) && (((LPNMHDR)lParam)->idFrom == IDC_SETTINGSCATLIST)) { category = -1; - for (i = 0; i < 7; i++) + for (i = 0; i < 8; i++) { h = GetDlgItem(hdlg, IDC_SETTINGSCATLIST); j = ListView_GetItemState(h, i, LVIS_SELECTED); diff --git a/src/win.c b/src/win.c index 354ba252e..4aacef80f 100644 --- a/src/win.c +++ b/src/win.c @@ -941,7 +941,7 @@ void update_status_bar_panes(HWND hwnds) } for (i = 0; i < 4; i++) { - if (cdrom_drives[i].enabled != 0) + if (cdrom_drives[i].bus_type != 0) { edge += sb_icon_width; iStatusWidths[sb_parts] = edge; @@ -1015,13 +1015,17 @@ void update_status_bar_panes(HWND hwnds) sb_icon_flags[i] = 0; } } - if (cdrom_drives[id].bus_type == 1) + if (cdrom_drives[id].bus_type == 4) { j = 164; } + else if (cdrom_drives[id].bus_type == 3) + { + j = 162; + } else { - j = (cdrom_drives[id].atapi_dma) ? 162 : 160; + j = 160; } sb_part_icons[i] = j | sb_icon_flags[i]; create_cdrom_tip(i); @@ -1606,7 +1610,7 @@ void win_cdrom_eject(uint8_t id) cdrom_drives[id].handler->exit(id); cdrom_close(id); cdrom_null_open(id, 0); - if (cdrom_drives[id].enabled) + if (cdrom_drives[id].bus_type) { /* Signal disc change to the emulated machine. */ cdrom_insert(id); @@ -1638,7 +1642,7 @@ void win_cdrom_reload(uint8_t id) if (cdrom_drives[id].prev_host_drive == 200) { image_open(id, cdrom_image[id].image_path); - if (cdrom_drives[id].enabled) + if (cdrom_drives[id].bus_type) { /* Signal disc change to the emulated machine. */ cdrom_insert(id); @@ -1651,7 +1655,7 @@ void win_cdrom_reload(uint8_t id) { new_cdrom_drive = cdrom_drives[id].prev_host_drive; ioctl_open(id, new_cdrom_drive); - if (cdrom_drives[id].enabled) + if (cdrom_drives[id].bus_type) { /* Signal disc change to the emulated machine. */ cdrom_insert(id); @@ -2347,7 +2351,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR cdrom_drives[cdrom_id].handler->exit(cdrom_id); cdrom_close(cdrom_id); image_open(cdrom_id, temp_image_path); - if (cdrom_drives[cdrom_id].enabled) + if (cdrom_drives[cdrom_id].bus_type) { /* Signal disc change to the emulated machine. */ cdrom_insert(cdrom_id); @@ -2381,7 +2385,7 @@ LRESULT CALLBACK StatusBarProcedure(HWND hwnd, UINT message, WPARAM wParam, LPAR cdrom_drives[cdrom_id].handler->exit(cdrom_id); cdrom_close(cdrom_id); ioctl_open(cdrom_id, new_cdrom_drive); - if (cdrom_drives[cdrom_id].enabled) + if (cdrom_drives[cdrom_id].bus_type) { /* Signal disc change to the emulated machine. */ cdrom_insert(cdrom_id);