Reworked network and SCSI thread initialization and termination;

Hard disk controller name and other related strings are now char * instead of fixed-size arrays.
This commit is contained in:
OBattler
2017-10-19 23:55:51 +02:00
parent 1d60a99ea3
commit b755b27304
18 changed files with 262 additions and 113 deletions

View File

@@ -8,7 +8,7 @@
*
* Platform support defintions for Win32.
*
* Version: @(#)win.h 1.0.6 2017/10/18
* Version: @(#)win.h 1.0.7 2017/10/19
*
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -78,7 +78,7 @@ extern void set_language(int id);
extern int get_vidpause(void);
#ifdef EMU_DEVICE_H
extern void deviceconfig_open(HWND hwnd, device_t *device);
extern uint8_t deviceconfig_open(HWND hwnd, device_t *device);
#endif
extern void joystickconfig_open(HWND hwnd, int joy_nr, int type);

View File

@@ -32,6 +32,8 @@
static device_t *config_device;
static uint8_t deviceconfig_changed = 0;
static BOOL CALLBACK
deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
@@ -39,7 +41,6 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
HWND h;
int val_int;
int ret;
int id;
int c;
int num;
@@ -278,21 +279,12 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
if (!changed)
{
deviceconfig_changed = 0;
EndDialog(hdlg, 0);
return TRUE;
}
ret = ui_msgbox(MBX_QUESTION, (wchar_t *)IDS_2051);
switch(ret)
{
case 1:
EndDialog(hdlg, 0);
return TRUE;
case -1:
return FALSE;
default:
break;
}
deviceconfig_changed = 1;
id = IDC_CONFIG_BASE;
config = config_device->config;
@@ -367,15 +359,12 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
config++;
}
config_save();
pc_reset_hard();
EndDialog(hdlg, 0);
return TRUE;
}
else if (cid == IDCANCEL)
{
deviceconfig_changed = 0;
EndDialog(hdlg, 0);
return TRUE;
}
@@ -462,7 +451,7 @@ deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
}
void deviceconfig_open(HWND hwnd, device_t *device)
uint8_t deviceconfig_open(HWND hwnd, device_t *device)
{
device_config_t *config = device->config;
uint16_t *data_block = malloc(16384);
@@ -472,6 +461,8 @@ void deviceconfig_open(HWND hwnd, device_t *device)
int y = 10;
int id = IDC_CONFIG_BASE;
deviceconfig_changed = 0;
memset(data_block, 0, 4096);
dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU;
@@ -731,4 +722,6 @@ void deviceconfig_open(HWND hwnd, device_t *device)
DialogBoxIndirect(hinstance, dlg, hwnd, deviceconfig_dlgproc);
free(data_block);
return deviceconfig_changed;
}

View File

@@ -87,6 +87,8 @@ static char temp_hdc_name[16];
static char *hdc_names[16];
static int temp_bugger;
static uint8_t temp_deviceconfig;
/* Hard disks category */
static hard_disk_t temp_hdd[HDD_NUM];
@@ -196,6 +198,8 @@ static void win_settings_init(void)
temp_fdd_check_bpb[i] = fdd_get_check_bpb(i);
}
memcpy(temp_cdrom_drives, cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t));
temp_deviceconfig = 0;
}
@@ -268,6 +272,8 @@ static int win_settings_changed(void)
}
i = i || memcmp(cdrom_drives, temp_cdrom_drives, CDROM_NUM * sizeof(cdrom_drive_t));
i = i || !!temp_deviceconfig;
return i;
}
@@ -347,6 +353,11 @@ static void win_settings_save(void)
/* Peripherals category */
scsi_card_current = temp_scsi_card;
if (hdc_name) {
free(hdc_name);
hdc_name = NULL;
}
hdc_name = (char *) malloc(sizeof(temp_hdc_name));
strncpy(hdc_name, temp_hdc_name, sizeof(temp_hdc_name) - 1);
hdc_init(hdc_name);
ide_enable[2] = temp_ide_ter;
@@ -660,7 +671,7 @@ static BOOL CALLBACK win_settings_machine_proc(HWND hdlg, UINT message, WPARAM w
h = GetDlgItem(hdlg, IDC_COMBO_MACHINE);
temp_machine = listtomachine[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)machine_getdevice(temp_machine));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)machine_getdevice(temp_machine));
break;
}
@@ -842,7 +853,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
break;
case IDC_BUTTON_VOODOO:
deviceconfig_open(hdlg, (void *)&voodoo_device);
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)&voodoo_device);
break;
case IDC_CONFIGURE_VID:
@@ -852,7 +863,7 @@ static BOOL CALLBACK win_settings_video_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_VIDEO);
SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM) lptsTemp);
wcstombs(stransi, lptsTemp, 512);
deviceconfig_open(hdlg, (void *)video_card_getdevice(video_card_getid(stransi)));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)video_card_getdevice(video_card_getid(stransi)));
free(stransi);
free(lptsTemp);
@@ -1218,7 +1229,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_SOUND);
temp_sound_card = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)sound_card_getdevice(temp_sound_card));
break;
case IDC_COMBO_MIDI:
@@ -1247,7 +1258,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
h = GetDlgItem(hdlg, IDC_COMBO_MIDI);
temp_midi_device = settings_list_to_midi[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)midi_device_getdevice(temp_midi_device));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)midi_device_getdevice(temp_midi_device));
break;
case IDC_CHECK_MPU401:
@@ -1259,7 +1270,7 @@ static BOOL CALLBACK win_settings_sound_proc(HWND hdlg, UINT message, WPARAM wPa
break;
case IDC_CONFIGURE_MPU401:
deviceconfig_open(hdlg, (void *)&mpu401_device);
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)&mpu401_device);
break;
}
return FALSE;
@@ -1587,7 +1598,7 @@ 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)];
deviceconfig_open(hdlg, (void *)scsi_card_getdevice(temp_scsi_card));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)scsi_card_getdevice(temp_scsi_card));
break;
case IDC_COMBO_SCSI:
@@ -1827,7 +1838,7 @@ static BOOL CALLBACK win_settings_network_proc(HWND hdlg, UINT message, WPARAM w
h = GetDlgItem(hdlg, IDC_COMBO_NET);
temp_net_card = settings_list_to_network[SendMessage(h, CB_GETCURSEL, 0, 0)];
deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_net_card));
temp_deviceconfig |= deviceconfig_open(hdlg, (void *)network_card_getdevice(temp_net_card));
break;
}
return FALSE;

View File

@@ -59,6 +59,20 @@ thread_sleep(int t)
}
int
thread_wait(thread_t *arg, int timeout)
{
if (arg == NULL) return(0);
if (timeout == -1)
timeout = INFINITE;
if (WaitForSingleObject(arg, timeout)) return(1);
return(0);
}
event_t *
thread_create_event(void)
{
@@ -99,6 +113,8 @@ thread_wait_event(event_t *arg, int timeout)
if (arg == NULL) return(0);
if (ev->handle == NULL) return(0);
if (timeout == -1)
timeout = INFINITE;