2017-05-30 03:38:38 +02:00
/*
* 86 Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus .
*
* This file is part of the 86 Box distribution .
*
* Windows 86 Box Settings dialog handler .
*
2018-01-26 22:17:09 +01:00
* Version : @ ( # ) win_settings . c 1.0 .35 2018 / 01 / 26
2017-05-30 03:38:38 +02:00
*
* Author : Miran Grca , < mgrca8 @ gmail . com >
2017-10-08 19:14:46 -04:00
*
2018-01-17 18:43:36 +01:00
* Copyright 2016 - 2018 Miran Grca .
2017-05-30 03:38:38 +02:00
*/
2017-05-18 14:03:43 -04:00
# define UNICODE
# define BITMAP WINDOWS_BITMAP
# include <windows.h>
# include <windowsx.h>
# undef BITMAP
# include <commctrl.h>
# include <inttypes.h>
2017-09-25 04:31:20 -04:00
# include <stdio.h>
# include <stdint.h>
# include <string.h>
# include <wchar.h>
2017-10-17 01:59:09 -04:00
# include "../86box.h"
2017-09-23 21:12:26 -04:00
# include "../config.h"
2017-08-27 04:33:47 +01:00
# include "../cpu/cpu.h"
2017-09-04 01:52:29 -04:00
# include "../mem.h"
2017-09-25 04:31:20 -04:00
# include "../rom.h"
2017-05-18 14:03:43 -04:00
# include "../device.h"
2017-09-04 01:52:29 -04:00
# include "../nvr.h"
2017-09-02 20:39:57 +02:00
# include "../machine/machine.h"
2017-10-01 17:30:02 -04:00
# include "../game/gameport.h"
2017-09-02 23:39:26 +02:00
# include "../lpt.h"
2017-09-04 01:52:29 -04:00
# include "../mouse.h"
# include "../cdrom/cdrom.h"
2018-01-26 22:17:09 +01:00
# include "../zip.h"
2017-10-02 02:15:35 -04:00
# include "../disk/hdd.h"
# include "../disk/hdc.h"
# include "../disk/hdc_ide.h"
2017-09-04 01:52:29 -04:00
# include "../floppy/fdd.h"
2017-08-27 04:33:47 +01:00
# include "../scsi/scsi.h"
# include "../network/network.h"
# include "../sound/sound.h"
# include "../sound/midi.h"
# include "../sound/snd_dbopl.h"
# include "../sound/snd_mpu401.h"
# include "../video/video.h"
# include "../video/vid_voodoo.h"
2017-10-10 03:07:29 -04:00
# include "../plat.h"
2017-10-11 05:40:44 -04:00
# include "../plat_midi.h"
2017-10-10 03:07:29 -04:00
# include "../ui.h"
2017-05-18 14:03:43 -04:00
# include "win.h"
/* Machine category */
2017-10-15 02:43:13 +02:00
static int temp_machine , temp_cpu_m , temp_cpu , temp_wait_states , temp_mem_size , temp_fpu , temp_sync ;
# ifdef USE_DYNAREC
static int temp_dynarec ;
# endif
2017-05-18 14:03:43 -04:00
/* Video category */
2017-05-18 21:22:15 +02:00
static int temp_gfxcard , temp_video_speed , temp_voodoo ;
2017-05-18 14:03:43 -04:00
/* Input devices category */
2017-05-18 21:22:15 +02:00
static int temp_mouse , temp_joystick ;
2017-05-18 14:03:43 -04:00
/* Sound category */
2017-06-19 06:46:08 +02:00
static int temp_sound_card , temp_midi_device , temp_mpu401 , temp_SSI2001 , temp_GAMEBLASTER , temp_GUS , temp_opl3_type ;
2017-06-14 07:21:01 +02:00
static int temp_float ;
2017-05-18 14:03:43 -04:00
/* Network category */
2017-05-18 21:22:15 +02:00
static int temp_net_type , temp_net_card ;
static char temp_pcap_dev [ 520 ] ;
2017-05-18 14:03:43 -04:00
2017-09-02 23:39:26 +02:00
/* Ports category */
static char temp_lpt1_device_name [ 16 ] ;
static int temp_serial [ 2 ] , temp_lpt ;
2018-01-26 22:17:09 +01:00
/* Other peripherals category */
2017-10-02 02:15:35 -04:00
static int temp_scsi_card , temp_ide_ter , temp_ide_ter_irq , temp_ide_qua , temp_ide_qua_irq ;
2017-05-18 21:22:15 +02:00
static char temp_hdc_name [ 16 ] ;
2017-10-01 16:29:15 -04:00
static char * hdc_names [ 16 ] ;
static int temp_bugger ;
2017-05-18 14:03:43 -04:00
2017-10-19 23:55:51 +02:00
static uint8_t temp_deviceconfig ;
2017-05-18 14:03:43 -04:00
/* Hard disks category */
2017-09-30 16:56:38 -04:00
static hard_disk_t temp_hdd [ HDD_NUM ] ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
/* Floppy drives category */
2017-05-18 21:22:15 +02:00
static int temp_fdd_types [ FDD_NUM ] ;
2017-06-04 02:14:27 +02:00
static int temp_fdd_turbo [ FDD_NUM ] ;
2017-07-27 17:14:52 +02:00
static int temp_fdd_check_bpb [ FDD_NUM ] ;
2018-01-26 22:17:09 +01:00
/* Other removable devices category */
2017-05-18 21:22:15 +02:00
static cdrom_drive_t temp_cdrom_drives [ CDROM_NUM ] ;
2018-01-26 22:17:09 +01:00
static zip_drive_t temp_zip_drives [ ZIP_NUM ] ;
2017-05-18 14:03:43 -04:00
static HWND hwndParentDialog , hwndChildDialog ;
2017-05-18 21:22:15 +02:00
static int displayed_category = 0 ;
2017-05-18 14:03:43 -04:00
extern int is486 ;
2017-09-02 20:39:57 +02:00
static int romstolist [ ROM_MAX ] , listtomachine [ ROM_MAX ] , romstomachine [ ROM_MAX ] , machinetolist [ ROM_MAX ] ;
2017-05-18 14:03:43 -04:00
static int settings_sound_to_list [ 20 ] , settings_list_to_sound [ 20 ] ;
2017-06-19 06:46:08 +02:00
static int settings_midi_to_list [ 20 ] , settings_list_to_midi [ 20 ] ;
2017-05-18 14:03:43 -04:00
static int settings_mouse_to_list [ 20 ] , settings_list_to_mouse [ 20 ] ;
static int settings_scsi_to_list [ 20 ] , settings_list_to_scsi [ 20 ] ;
static int settings_network_to_list [ 20 ] , settings_list_to_network [ 20 ] ;
2018-01-27 02:38:52 +01:00
static uint64_t mfm_tracking , esdi_tracking , xtide_tracking , ide_tracking , scsi_tracking [ 16 ] ;
2018-01-19 15:39:13 +01:00
2017-05-18 14:03:43 -04:00
2017-10-10 03:07:29 -04:00
/* Show a MessageBox dialog. This is nasty, I know. --FvK */
static int
settings_msgbox ( int type , void * arg )
{
HWND h ;
int i ;
h = hwndMain ;
hwndMain = hwndParentDialog ;
i = ui_msgbox ( type , arg ) ;
hwndMain = h ;
return ( i ) ;
}
2017-05-18 14:03:43 -04:00
/* This does the initial read of global variables into the temporary ones. */
static void win_settings_init ( void )
{
int i = 0 ;
/* Machine category */
2017-09-02 20:39:57 +02:00
temp_machine = machine ;
2017-05-18 14:03:43 -04:00
temp_cpu_m = cpu_manufacturer ;
2017-05-29 01:18:32 +02:00
temp_wait_states = cpu_waitstates ;
2017-05-18 14:03:43 -04:00
temp_cpu = cpu ;
temp_mem_size = mem_size ;
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
temp_dynarec = cpu_use_dynarec ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
temp_fpu = enable_external_fpu ;
temp_sync = enable_sync ;
/* Video category */
temp_gfxcard = gfxcard ;
temp_video_speed = video_speed ;
temp_voodoo = voodoo_enabled ;
/* Input devices category */
temp_mouse = mouse_type ;
temp_joystick = joystick_type ;
/* Sound category */
temp_sound_card = sound_card_current ;
2017-06-19 06:46:08 +02:00
temp_midi_device = midi_device_current ;
2017-06-03 20:32:58 +02:00
temp_mpu401 = mpu401_standalone_enable ;
2017-05-18 14:03:43 -04:00
temp_SSI2001 = SSI2001 ;
temp_GAMEBLASTER = GAMEBLASTER ;
temp_GUS = GUS ;
temp_opl3_type = opl3_type ;
2017-06-14 07:21:01 +02:00
temp_float = sound_is_float ;
2017-05-18 14:03:43 -04:00
/* Network category */
temp_net_type = network_type ;
2017-09-02 23:39:26 +02:00
memset ( temp_pcap_dev , 0 , sizeof ( temp_pcap_dev ) ) ;
2017-05-18 14:03:43 -04:00
strcpy ( temp_pcap_dev , network_pcap ) ;
temp_net_card = network_card ;
2017-09-02 23:39:26 +02:00
/* Ports category */
strncpy ( temp_lpt1_device_name , lpt1_device_name , sizeof ( temp_lpt1_device_name ) - 1 ) ;
temp_serial [ 0 ] = serial_enabled [ 0 ] ;
temp_serial [ 1 ] = serial_enabled [ 1 ] ;
temp_lpt = lpt_enabled ;
2018-01-26 22:17:09 +01:00
/* Other peripherals category */
2017-05-18 14:03:43 -04:00
temp_scsi_card = scsi_card_current ;
2017-09-30 16:56:38 -04:00
strncpy ( temp_hdc_name , hdc_name , sizeof ( temp_hdc_name ) - 1 ) ;
2017-05-18 14:03:43 -04:00
temp_ide_ter = ide_enable [ 2 ] ;
temp_ide_ter_irq = ide_irq [ 2 ] ;
temp_ide_qua = ide_enable [ 3 ] ;
temp_ide_qua_irq = ide_irq [ 3 ] ;
temp_bugger = bugger_enabled ;
2018-01-19 15:39:13 +01:00
mfm_tracking = xtide_tracking = esdi_tracking = ide_tracking = 0 ;
for ( i = 0 ; i < 16 ; i + + )
scsi_tracking [ i ] = 0 ;
2017-05-18 14:03:43 -04:00
/* Hard disks category */
2017-09-30 16:56:38 -04:00
memcpy ( temp_hdd , hdd , HDD_NUM * sizeof ( hard_disk_t ) ) ;
2018-01-19 15:39:13 +01:00
for ( i = 0 ; i < HDD_NUM ; i + + )
{
if ( hdd [ i ] . bus = = HDD_BUS_MFM )
2018-01-27 02:38:52 +01:00
mfm_tracking | = ( 1 < < ( hdd [ i ] . mfm_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_XTIDE )
2018-01-27 02:38:52 +01:00
xtide_tracking | = ( 1 < < ( hdd [ i ] . xtide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_ESDI )
2018-01-27 02:38:52 +01:00
esdi_tracking | = ( 1 < < ( hdd [ i ] . esdi_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_IDE_PIO_ONLY )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 1 < < ( hdd [ i ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_IDE_PIO_AND_DMA )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 1 < < ( hdd [ i ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_SCSI )
2018-01-27 02:38:52 +01:00
scsi_tracking [ hdd [ i ] . scsi_id ] | = ( 1 < < ( hdd [ i ] . scsi_lun < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( hdd [ i ] . bus = = HDD_BUS_SCSI_REMOVABLE )
2018-01-27 02:38:52 +01:00
scsi_tracking [ hdd [ i ] . scsi_id ] | = ( 1 < < ( hdd [ i ] . scsi_lun < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
}
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
/* Floppy drives category */
2017-05-18 14:03:43 -04:00
for ( i = 0 ; i < FDD_NUM ; i + + )
{
temp_fdd_types [ i ] = fdd_get_type ( i ) ;
2017-06-04 02:14:27 +02:00
temp_fdd_turbo [ i ] = fdd_get_turbo ( i ) ;
2017-07-27 17:14:52 +02:00
temp_fdd_check_bpb [ i ] = fdd_get_check_bpb ( i ) ;
2017-05-18 14:03:43 -04:00
}
2018-01-26 22:17:09 +01:00
/* Other removable devices category */
2017-05-18 14:03:43 -04:00
memcpy ( temp_cdrom_drives , cdrom_drives , CDROM_NUM * sizeof ( cdrom_drive_t ) ) ;
2018-01-19 15:39:13 +01:00
for ( i = 0 ; i < CDROM_NUM ; i + + )
{
if ( cdrom_drives [ i ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 2 < < ( cdrom_drives [ i ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( cdrom_drives [ i ] . bus_type = = CDROM_BUS_ATAPI_PIO_AND_DMA )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 2 < < ( cdrom_drives [ i ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( cdrom_drives [ i ] . bus_type = = CDROM_BUS_SCSI )
2018-01-27 02:38:52 +01:00
scsi_tracking [ cdrom_drives [ i ] . scsi_device_id ] | = ( 2 < < ( cdrom_drives [ i ] . scsi_device_lun < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
}
2018-01-26 22:17:09 +01:00
memcpy ( temp_zip_drives , zip_drives , ZIP_NUM * sizeof ( zip_drive_t ) ) ;
for ( i = 0 ; i < ZIP_NUM ; i + + )
{
if ( zip_drives [ i ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 4 < < ( zip_drives [ i ] . ide_channel < < 3 ) ) ;
2018-01-26 22:17:09 +01:00
else if ( zip_drives [ i ] . bus_type = = ZIP_BUS_ATAPI_PIO_AND_DMA )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 4 < < ( zip_drives [ i ] . ide_channel < < 3 ) ) ;
2018-01-26 22:17:09 +01:00
else if ( zip_drives [ i ] . bus_type = = ZIP_BUS_SCSI )
2018-01-27 02:38:52 +01:00
scsi_tracking [ zip_drives [ i ] . scsi_device_id ] | = ( 4 < < ( zip_drives [ i ] . scsi_device_lun < < 3 ) ) ;
2018-01-26 22:17:09 +01:00
}
2017-10-19 23:55:51 +02:00
temp_deviceconfig = 0 ;
2017-05-18 14:03:43 -04:00
}
/* This returns 1 if any variable has changed, 0 if not. */
static int win_settings_changed ( void )
{
int i = 0 ;
int j = 0 ;
/* Machine category */
2017-09-02 20:39:57 +02:00
i = i | | ( machine ! = temp_machine ) ;
2017-05-18 14:03:43 -04:00
i = i | | ( cpu_manufacturer ! = temp_cpu_m ) ;
2017-05-29 01:18:32 +02:00
i = i | | ( cpu_waitstates ! = temp_wait_states ) ;
2017-05-18 14:03:43 -04:00
i = i | | ( cpu ! = temp_cpu ) ;
i = i | | ( mem_size ! = temp_mem_size ) ;
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
i = i | | ( temp_dynarec ! = cpu_use_dynarec ) ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
i = i | | ( temp_fpu ! = enable_external_fpu ) ;
i = i | | ( temp_sync ! = enable_sync ) ;
/* Video category */
i = i | | ( gfxcard ! = temp_gfxcard ) ;
i = i | | ( video_speed ! = temp_video_speed ) ;
i = i | | ( voodoo_enabled ! = temp_voodoo ) ;
/* Input devices category */
i = i | | ( mouse_type ! = temp_mouse ) ;
i = i | | ( joystick_type ! = temp_joystick ) ;
/* Sound category */
i = i | | ( sound_card_current ! = temp_sound_card ) ;
2017-06-19 06:46:08 +02:00
i = i | | ( midi_device_current ! = temp_midi_device ) ;
2017-06-03 20:32:58 +02:00
i = i | | ( mpu401_standalone_enable ! = temp_mpu401 ) ;
2017-05-18 14:03:43 -04:00
i = i | | ( SSI2001 ! = temp_SSI2001 ) ;
i = i | | ( GAMEBLASTER ! = temp_GAMEBLASTER ) ;
i = i | | ( GUS ! = temp_GUS ) ;
i = i | | ( opl3_type ! = temp_opl3_type ) ;
2017-06-14 07:21:01 +02:00
i = i | | ( sound_is_float ! = temp_float ) ;
2017-05-18 14:03:43 -04:00
/* Network category */
i = i | | ( network_type ! = temp_net_type ) ;
i = i | | strcmp ( temp_pcap_dev , network_pcap ) ;
i = i | | ( network_card ! = temp_net_card ) ;
2017-09-02 23:39:26 +02:00
/* Ports category */
i = i | | strncmp ( temp_lpt1_device_name , lpt1_device_name , sizeof ( temp_lpt1_device_name ) - 1 ) ;
i = i | | ( temp_serial [ 0 ] ! = serial_enabled [ 0 ] ) ;
i = i | | ( temp_serial [ 1 ] ! = serial_enabled [ 1 ] ) ;
i = i | | ( temp_lpt ! = lpt_enabled ) ;
2017-05-18 14:03:43 -04:00
/* Peripherals category */
i = i | | ( scsi_card_current ! = temp_scsi_card ) ;
2017-09-30 16:56:38 -04:00
i = i | | strncmp ( temp_hdc_name , hdc_name , sizeof ( temp_hdc_name ) - 1 ) ;
2017-05-18 14:03:43 -04:00
i = i | | ( temp_ide_ter ! = ide_enable [ 2 ] ) ;
i = i | | ( temp_ide_ter_irq ! = ide_irq [ 2 ] ) ;
i = i | | ( temp_ide_qua ! = ide_enable [ 3 ] ) ;
i = i | | ( temp_ide_qua_irq ! = ide_irq [ 3 ] ) ;
i = i | | ( temp_bugger ! = bugger_enabled ) ;
/* Hard disks category */
2017-09-30 16:56:38 -04:00
i = i | | memcmp ( hdd , temp_hdd , HDD_NUM * sizeof ( hard_disk_t ) ) ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
/* Floppy drives category */
2017-05-18 14:03:43 -04:00
for ( j = 0 ; j < FDD_NUM ; j + + )
{
i = i | | ( temp_fdd_types [ j ] ! = fdd_get_type ( j ) ) ;
2017-06-04 02:14:27 +02:00
i = i | | ( temp_fdd_turbo [ j ] ! = fdd_get_turbo ( j ) ) ;
2017-07-27 17:14:52 +02:00
i = i | | ( temp_fdd_check_bpb [ j ] ! = fdd_get_check_bpb ( j ) ) ;
2017-05-18 14:03:43 -04:00
}
2018-01-26 22:17:09 +01:00
/* Other removable devices category */
2017-05-18 14:03:43 -04:00
i = i | | memcmp ( cdrom_drives , temp_cdrom_drives , CDROM_NUM * sizeof ( cdrom_drive_t ) ) ;
2018-01-26 22:17:09 +01:00
i = i | | memcmp ( zip_drives , temp_zip_drives , ZIP_NUM * sizeof ( zip_drive_t ) ) ;
2017-05-18 14:03:43 -04:00
2017-10-19 23:55:51 +02:00
i = i | | ! ! temp_deviceconfig ;
2017-05-18 14:03:43 -04:00
return i ;
}
static int settings_msgbox_reset ( void )
{
int i = 0 ;
int changed = 0 ;
changed = win_settings_changed ( ) ;
if ( changed )
{
2017-10-10 03:07:29 -04:00
i = settings_msgbox ( MBX_QUESTION , ( wchar_t * ) IDS_2051 ) ;
2017-05-18 14:03:43 -04:00
2017-10-10 03:07:29 -04:00
if ( i = = 1 ) return ( 1 ) ; /* no */
if ( i < 0 ) return ( 0 ) ; /* cancel */
return ( 2 ) ; /* yes */
} else {
return ( 1 ) ;
2017-05-18 14:03:43 -04:00
}
}
/* This saves the settings back to the global variables. */
static void win_settings_save ( void )
{
int i = 0 ;
2017-10-07 00:46:54 -04:00
pc_reset_hard_close ( ) ;
2017-06-19 06:46:08 +02:00
2017-05-18 14:03:43 -04:00
/* Machine category */
2017-09-02 20:39:57 +02:00
machine = temp_machine ;
romset = machine_getromset ( ) ;
2017-05-18 14:03:43 -04:00
cpu_manufacturer = temp_cpu_m ;
2017-05-29 01:18:32 +02:00
cpu_waitstates = temp_wait_states ;
2017-05-18 14:03:43 -04:00
cpu = temp_cpu ;
mem_size = temp_mem_size ;
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
cpu_use_dynarec = temp_dynarec ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
enable_external_fpu = temp_fpu ;
enable_sync = temp_sync ;
/* Video category */
gfxcard = temp_gfxcard ;
video_speed = temp_video_speed ;
voodoo_enabled = temp_voodoo ;
/* Input devices category */
mouse_type = temp_mouse ;
joystick_type = temp_joystick ;
/* Sound category */
sound_card_current = temp_sound_card ;
2017-06-19 06:46:08 +02:00
midi_device_current = temp_midi_device ;
2017-06-03 20:32:58 +02:00
mpu401_standalone_enable = temp_mpu401 ;
2017-05-18 14:03:43 -04:00
SSI2001 = temp_SSI2001 ;
GAMEBLASTER = temp_GAMEBLASTER ;
GUS = temp_GUS ;
opl3_type = temp_opl3_type ;
2017-06-14 07:21:01 +02:00
sound_is_float = temp_float ;
2017-05-18 14:03:43 -04:00
/* Network category */
network_type = temp_net_type ;
memset ( network_pcap , ' \0 ' , sizeof ( network_pcap ) ) ;
strcpy ( network_pcap , temp_pcap_dev ) ;
network_card = temp_net_card ;
2017-09-02 23:39:26 +02:00
/* Ports category */
strncpy ( lpt1_device_name , temp_lpt1_device_name , sizeof ( temp_lpt1_device_name ) - 1 ) ;
serial_enabled [ 0 ] = temp_serial [ 0 ] ;
serial_enabled [ 1 ] = temp_serial [ 1 ] ;
lpt_enabled = temp_lpt ;
2017-05-18 14:03:43 -04:00
/* Peripherals category */
scsi_card_current = temp_scsi_card ;
2017-10-19 23:55:51 +02:00
if ( hdc_name ) {
free ( hdc_name ) ;
hdc_name = NULL ;
}
hdc_name = ( char * ) malloc ( sizeof ( temp_hdc_name ) ) ;
2017-09-30 16:56:38 -04:00
strncpy ( hdc_name , temp_hdc_name , sizeof ( temp_hdc_name ) - 1 ) ;
2017-10-02 02:15:35 -04:00
hdc_init ( hdc_name ) ;
2017-05-18 14:03:43 -04:00
ide_enable [ 2 ] = temp_ide_ter ;
ide_irq [ 2 ] = temp_ide_ter_irq ;
ide_enable [ 3 ] = temp_ide_qua ;
ide_irq [ 3 ] = temp_ide_qua_irq ;
bugger_enabled = temp_bugger ;
/* Hard disks category */
2017-09-30 16:56:38 -04:00
memcpy ( hdd , temp_hdd , HDD_NUM * sizeof ( hard_disk_t ) ) ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
/* Floppy drives category */
2017-05-18 14:03:43 -04:00
for ( i = 0 ; i < FDD_NUM ; i + + )
{
fdd_set_type ( i , temp_fdd_types [ i ] ) ;
2017-06-04 02:14:27 +02:00
fdd_set_turbo ( i , temp_fdd_turbo [ i ] ) ;
2017-07-27 17:14:52 +02:00
fdd_set_check_bpb ( i , temp_fdd_check_bpb [ i ] ) ;
2017-05-18 14:03:43 -04:00
}
2018-01-26 22:17:09 +01:00
/* Removable devices category */
2017-05-18 14:03:43 -04:00
memcpy ( cdrom_drives , temp_cdrom_drives , CDROM_NUM * sizeof ( cdrom_drive_t ) ) ;
2018-01-26 22:17:09 +01:00
memcpy ( zip_drives , temp_zip_drives , ZIP_NUM * sizeof ( zip_drive_t ) ) ;
2017-05-18 14:03:43 -04:00
2017-10-29 04:20:20 -05:00
/* Mark configuration as changed. */
config_changed = 1 ;
# if 1
pc_reset_hard_init ( ) ;
# else
2017-05-18 14:03:43 -04:00
mem_resize ( ) ;
2017-09-25 04:31:20 -04:00
rom_load_bios ( romset ) ;
2017-05-18 14:03:43 -04:00
2017-10-10 03:07:29 -04:00
ui_sb_update_panes ( ) ;
2017-05-29 01:18:32 +02:00
2017-06-22 18:17:41 -04:00
sound_realloc_buffers ( ) ;
2017-10-07 00:46:54 -04:00
pc_reset_hard_init ( ) ;
2017-05-18 14:03:43 -04:00
cpu_set ( ) ;
cpu_update_waitstates ( ) ;
2017-09-23 21:12:26 -04:00
config_save ( ) ;
2017-05-18 14:03:43 -04:00
2017-10-02 02:15:35 -04:00
pc_speed_changed ( ) ;
2017-05-18 14:03:43 -04:00
if ( joystick_type ! = 7 ) gameport_update_joystick_type ( ) ;
2017-10-29 04:20:20 -05:00
# endif
2017-05-18 14:03:43 -04:00
}
static void win_settings_machine_recalc_cpu ( HWND hdlg )
{
HWND h ;
int temp_romset = 0 ;
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
int cpu_flags ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
int cpu_type ;
2017-09-02 20:39:57 +02:00
temp_romset = machine_getromset_ex ( temp_machine ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_WS ) ;
2017-09-02 20:39:57 +02:00
cpu_type = machines [ romstomachine [ temp_romset ] ] . cpu [ temp_cpu_m ] . cpus [ temp_cpu ] . cpu_type ;
2017-05-18 14:03:43 -04:00
if ( ( cpu_type > = CPU_286 ) & & ( cpu_type < = CPU_386DX ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_DYNAREC ) ;
2017-09-02 20:39:57 +02:00
cpu_flags = machines [ romstomachine [ temp_romset ] ] . cpu [ temp_cpu_m ] . cpus [ temp_cpu ] . cpu_flags ;
2017-05-18 14:03:43 -04:00
if ( ! ( cpu_flags & CPU_SUPPORTS_DYNAREC ) & & ( cpu_flags & CPU_REQUIRES_DYNAREC ) )
{
fatal ( " Attempting to select a CPU that requires the recompiler and does not support it at the same time \n " ) ;
}
if ( ! ( cpu_flags & CPU_SUPPORTS_DYNAREC ) | | ( cpu_flags & CPU_REQUIRES_DYNAREC ) )
{
if ( ! ( cpu_flags & CPU_SUPPORTS_DYNAREC ) )
{
temp_dynarec = 0 ;
}
if ( cpu_flags & CPU_REQUIRES_DYNAREC )
{
temp_dynarec = 1 ;
}
SendMessage ( h , BM_SETCHECK , temp_dynarec , 0 ) ;
EnableWindow ( h , FALSE ) ;
}
else
{
EnableWindow ( h , TRUE ) ;
}
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_FPU ) ;
2017-09-02 20:39:57 +02:00
cpu_type = machines [ romstomachine [ temp_romset ] ] . cpu [ temp_cpu_m ] . cpus [ temp_cpu ] . cpu_type ;
2017-05-18 14:03:43 -04:00
if ( ( cpu_type < CPU_i486DX ) & & ( cpu_type > = CPU_286 ) )
{
EnableWindow ( h , TRUE ) ;
}
else if ( cpu_type < CPU_286 )
{
temp_fpu = 0 ;
EnableWindow ( h , FALSE ) ;
}
else
{
temp_fpu = 1 ;
EnableWindow ( h , FALSE ) ;
}
SendMessage ( h , BM_SETCHECK , temp_fpu , 0 ) ;
}
static void win_settings_machine_recalc_cpu_m ( HWND hdlg )
{
HWND h ;
int c = 0 ;
int temp_romset = 0 ;
LPTSTR lptsTemp ;
char * stransi ;
2017-09-02 20:39:57 +02:00
temp_romset = machine_getromset_ex ( temp_machine ) ;
2017-05-18 14:03:43 -04:00
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_CPU ) ;
SendMessage ( h , CB_RESETCONTENT , 0 , 0 ) ;
c = 0 ;
2017-09-02 20:39:57 +02:00
while ( machines [ romstomachine [ temp_romset ] ] . cpu [ temp_cpu_m ] . cpus [ c ] . cpu_type ! = - 1 )
2017-05-18 14:03:43 -04:00
{
2017-09-02 20:39:57 +02:00
stransi = machines [ romstomachine [ temp_romset ] ] . cpu [ temp_cpu_m ] . cpus [ c ] . name ;
2017-05-18 14:03:43 -04:00
mbstowcs ( lptsTemp , stransi , strlen ( stransi ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) ( LPCSTR ) lptsTemp ) ;
c + + ;
}
EnableWindow ( h , TRUE ) ;
2017-06-20 06:23:05 +02:00
if ( temp_cpu > = c )
2017-05-29 01:18:32 +02:00
{
2017-06-20 06:23:05 +02:00
temp_cpu = ( c - 1 ) ;
2017-05-29 01:18:32 +02:00
}
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_SETCURSEL , temp_cpu , 0 ) ;
win_settings_machine_recalc_cpu ( hdlg ) ;
free ( lptsTemp ) ;
}
2017-09-02 20:39:57 +02:00
static void win_settings_machine_recalc_machine ( HWND hdlg )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int c = 0 ;
int temp_romset = 0 ;
LPTSTR lptsTemp ;
2017-11-08 16:27:10 -05:00
const char * stransi ;
2017-05-18 14:03:43 -04:00
UDACCEL accel ;
2017-09-02 20:39:57 +02:00
temp_romset = machine_getromset_ex ( temp_machine ) ;
2017-05-18 14:03:43 -04:00
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MACHINE ) ;
2017-09-02 20:39:57 +02:00
if ( machine_getdevice ( temp_machine ) )
2017-05-18 14:03:43 -04:00
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_CPU_TYPE ) ;
SendMessage ( h , CB_RESETCONTENT , 0 , 0 ) ;
c = 0 ;
2017-09-02 20:39:57 +02:00
while ( machines [ romstomachine [ temp_romset ] ] . cpu [ c ] . cpus ! = NULL & & c < 4 )
2017-05-18 14:03:43 -04:00
{
2017-09-02 20:39:57 +02:00
stransi = machines [ romstomachine [ temp_romset ] ] . cpu [ c ] . name ;
2017-05-18 14:03:43 -04:00
mbstowcs ( lptsTemp , stransi , strlen ( stransi ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) ( LPCSTR ) lptsTemp ) ;
c + + ;
}
EnableWindow ( h , TRUE ) ;
2017-06-20 06:23:05 +02:00
if ( temp_cpu_m > = c )
2017-05-29 01:18:32 +02:00
{
2017-06-20 06:23:05 +02:00
temp_cpu_m = ( c - 1 ) ;
2017-05-29 01:18:32 +02:00
}
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_SETCURSEL , temp_cpu_m , 0 ) ;
if ( c = = 1 )
{
EnableWindow ( h , FALSE ) ;
}
else
{
EnableWindow ( h , TRUE ) ;
}
win_settings_machine_recalc_cpu_m ( hdlg ) ;
h = GetDlgItem ( hdlg , IDC_MEMSPIN ) ;
2017-09-02 20:39:57 +02:00
SendMessage ( h , UDM_SETRANGE , 0 , ( machines [ romstomachine [ temp_romset ] ] . min_ram < < 16 ) | machines [ romstomachine [ temp_romset ] ] . max_ram ) ;
2017-05-18 14:03:43 -04:00
accel . nSec = 0 ;
2017-09-02 20:39:57 +02:00
accel . nInc = machines [ romstomachine [ temp_romset ] ] . ram_granularity ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , UDM_SETACCEL , 1 , ( LPARAM ) & accel ) ;
2017-09-02 20:39:57 +02:00
if ( ! ( machines [ romstomachine [ temp_romset ] ] . flags & MACHINE_AT ) | | ( machines [ romstomachine [ temp_romset ] ] . ram_granularity > = 128 ) )
2017-05-18 14:03:43 -04:00
{
SendMessage ( h , UDM_SETPOS , 0 , temp_mem_size ) ;
h = GetDlgItem ( hdlg , IDC_TEXT_MB ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , WM_SETTEXT , 0 , ( LPARAM ) plat_get_string ( IDS_2094 ) ) ;
2017-05-18 14:03:43 -04:00
}
else
{
SendMessage ( h , UDM_SETPOS , 0 , temp_mem_size / 1024 ) ;
h = GetDlgItem ( hdlg , IDC_TEXT_MB ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , WM_SETTEXT , 0 , ( LPARAM ) plat_get_string ( IDS_2087 ) ) ;
2017-05-18 14:03:43 -04:00
}
free ( lptsTemp ) ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_machine_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int c = 0 ;
int d = 0 ;
LPTSTR lptsTemp ;
char * stransi ;
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_MACHINE ) ;
for ( c = 0 ; c < ROM_MAX ; c + + )
{
romstolist [ c ] = 0 ;
}
c = d = 0 ;
2017-09-02 20:39:57 +02:00
while ( machines [ c ] . id ! = - 1 )
2017-05-18 14:03:43 -04:00
{
2017-09-02 20:39:57 +02:00
if ( romspresent [ machines [ c ] . id ] )
2017-05-18 14:03:43 -04:00
{
2017-11-08 16:27:10 -05:00
stransi = ( char * ) machines [ c ] . name ;
2017-05-18 14:03:43 -04:00
mbstowcs ( lptsTemp , stransi , strlen ( stransi ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
2017-09-02 20:39:57 +02:00
machinetolist [ c ] = d ;
listtomachine [ d ] = c ;
romstolist [ machines [ c ] . id ] = d ;
romstomachine [ machines [ c ] . id ] = c ;
2017-05-18 14:03:43 -04:00
d + + ;
}
c + + ;
}
2017-09-02 20:39:57 +02:00
SendMessage ( h , CB_SETCURSEL , machinetolist [ temp_machine ] , 0 ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_WS ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2131 ) ) ;
2017-05-18 14:03:43 -04:00
for ( c = 0 ; c < 8 ; c + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( 2132 ) , c ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
2017-05-29 01:18:32 +02:00
SendMessage ( h , CB_SETCURSEL , temp_wait_states , 0 ) ;
2017-05-18 14:03:43 -04:00
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_DYNAREC ) ;
SendMessage ( h , BM_SETCHECK , temp_dynarec , 0 ) ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_MEMSPIN ) ;
SendMessage ( h , UDM_SETBUDDY , ( WPARAM ) GetDlgItem ( hdlg , IDC_MEMTEXT ) , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_SYNC ) ;
SendMessage ( h , BM_SETCHECK , temp_sync , 0 ) ;
2017-09-02 20:39:57 +02:00
win_settings_machine_recalc_machine ( hdlg ) ;
2017-05-18 14:03:43 -04:00
free ( lptsTemp ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDC_COMBO_MACHINE :
if ( HIWORD ( wParam ) = = CBN_SELCHANGE )
{
h = GetDlgItem ( hdlg , IDC_COMBO_MACHINE ) ;
2017-09-02 20:39:57 +02:00
temp_machine = listtomachine [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-05-18 14:03:43 -04:00
2017-09-02 20:39:57 +02:00
win_settings_machine_recalc_machine ( hdlg ) ;
2017-05-18 14:03:43 -04:00
}
break ;
case IDC_COMBO_CPU_TYPE :
if ( HIWORD ( wParam ) = = CBN_SELCHANGE )
{
h = GetDlgItem ( hdlg , IDC_COMBO_CPU_TYPE ) ;
temp_cpu_m = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
temp_cpu = 0 ;
win_settings_machine_recalc_cpu_m ( hdlg ) ;
}
break ;
case IDC_COMBO_CPU :
if ( HIWORD ( wParam ) = = CBN_SELCHANGE )
{
h = GetDlgItem ( hdlg , IDC_COMBO_CPU ) ;
temp_cpu = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
win_settings_machine_recalc_cpu ( hdlg ) ;
}
break ;
case IDC_CONFIGURE_MACHINE :
h = GetDlgItem ( hdlg , IDC_COMBO_MACHINE ) ;
2017-09-02 20:39:57 +02:00
temp_machine = listtomachine [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-05-18 14:03:43 -04:00
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) machine_getdevice ( temp_machine ) ) ;
2017-05-18 14:03:43 -04:00
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
2017-11-08 16:27:10 -05:00
stransi = ( char * ) malloc ( 512 ) ;
2017-05-18 14:03:43 -04:00
2017-10-15 02:43:13 +02:00
# ifdef USE_DYNAREC
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_DYNAREC ) ;
temp_dynarec = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-10-15 02:43:13 +02:00
# endif
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_SYNC ) ;
temp_sync = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_FPU ) ;
temp_fpu = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_WS ) ;
temp_wait_states = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_MEMTEXT ) ;
SendMessage ( h , WM_GETTEXT , 255 , ( LPARAM ) lptsTemp ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , lptsTemp , 512 ) ;
2017-05-18 14:03:43 -04:00
sscanf ( stransi , " %i " , & temp_mem_size ) ;
2017-09-02 20:39:57 +02:00
temp_mem_size & = ~ ( machines [ temp_machine ] . ram_granularity - 1 ) ;
if ( temp_mem_size < machines [ temp_machine ] . min_ram )
2017-05-18 14:03:43 -04:00
{
2017-09-02 20:39:57 +02:00
temp_mem_size = machines [ temp_machine ] . min_ram ;
2017-05-18 14:03:43 -04:00
}
2017-09-02 20:39:57 +02:00
else if ( temp_mem_size > machines [ temp_machine ] . max_ram )
2017-05-18 14:03:43 -04:00
{
2017-09-02 20:39:57 +02:00
temp_mem_size = machines [ temp_machine ] . max_ram ;
2017-05-18 14:03:43 -04:00
}
2017-09-02 20:39:57 +02:00
if ( ( machines [ temp_machine ] . flags & MACHINE_AT ) & & ( machines [ temp_machine ] . ram_granularity < 128 ) )
2017-05-18 14:03:43 -04:00
{
temp_mem_size * = 1024 ;
}
2017-11-05 01:57:04 -05:00
if ( machines [ temp_machine ] . flags & MACHINE_VIDEO )
{
gfxcard = GFX_INTERNAL ;
}
2017-05-18 14:03:43 -04:00
free ( stransi ) ;
free ( lptsTemp ) ;
default :
return FALSE ;
}
return FALSE ;
}
static void recalc_vid_list ( HWND hdlg )
{
HWND h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO ) ;
int c = 0 , d = 0 ;
int found_card = 0 ;
WCHAR szText [ 512 ] ;
SendMessage ( h , CB_RESETCONTENT , 0 , 0 ) ;
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
while ( 1 )
{
2017-11-05 01:57:04 -05:00
/* Skip "internal" if machine doesn't have it. */
if ( c = = 1 & & ! ( machines [ temp_machine ] . flags & MACHINE_VIDEO ) ) {
c + + ;
continue ;
}
2017-05-18 14:03:43 -04:00
char * s = video_card_getname ( c ) ;
if ( ! s [ 0 ] )
break ;
if ( video_card_available ( c ) & & gfx_present [ video_new_to_old ( c ) ] & &
2017-10-10 00:14:15 +02:00
device_is_valid ( video_card_getdevice ( c ) , machines [ temp_machine ] . flags ) )
2017-05-18 14:03:43 -04:00
{
mbstowcs ( szText , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) szText ) ;
2017-05-29 01:18:32 +02:00
if ( video_new_to_old ( c ) = = temp_gfxcard )
2017-05-18 14:03:43 -04:00
{
SendMessage ( h , CB_SETCURSEL , d , 0 ) ;
found_card = 1 ;
}
d + + ;
}
c + + ;
}
if ( ! found_card )
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
2017-09-02 20:39:57 +02:00
EnableWindow ( h , machines [ temp_machine ] . fixed_gfxcard ? FALSE : TRUE ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_VOODOO ) ;
2017-09-02 20:39:57 +02:00
EnableWindow ( h , ( machines [ temp_machine ] . flags & MACHINE_PCI ) ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_BUTTON_VOODOO ) ;
2017-09-02 20:39:57 +02:00
EnableWindow ( h , ( ( machines [ temp_machine ] . flags & MACHINE_PCI ) & & temp_voodoo ) ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_video_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
LPTSTR lptsTemp ;
char * stransi ;
int gfx = 0 ;
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
stransi = ( char * ) malloc ( 512 ) ;
recalc_vid_list ( hdlg ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO_SPEED ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2133 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2134 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2135 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2136 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2137 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2138 ) ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_SETCURSEL , temp_video_speed , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_VOODOO ) ;
SendMessage ( h , BM_SETCHECK , temp_voodoo , 0 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO ) ;
SendMessage ( h , CB_GETLBTEXT , SendMessage ( h , CB_GETCURSEL , 0 , 0 ) , ( LPARAM ) lptsTemp ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , lptsTemp , 512 ) ;
2017-05-18 14:03:43 -04:00
gfx = video_card_getid ( stransi ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_VID ) ;
2018-01-26 22:17:09 +01:00
if ( video_card_has_config ( gfx ) )
2017-05-18 14:03:43 -04:00
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
free ( stransi ) ;
free ( lptsTemp ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDC_COMBO_VIDEO :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
stransi = ( char * ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO ) ;
SendMessage ( h , CB_GETLBTEXT , SendMessage ( h , CB_GETCURSEL , 0 , 0 ) , ( LPARAM ) lptsTemp ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , lptsTemp , 512 ) ;
2017-05-18 14:03:43 -04:00
gfx = video_card_getid ( stransi ) ;
temp_gfxcard = video_new_to_old ( gfx ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_VID ) ;
2017-05-18 14:03:43 -04:00
if ( video_card_has_config ( gfx ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
free ( stransi ) ;
free ( lptsTemp ) ;
break ;
case IDC_CHECK_VOODOO :
h = GetDlgItem ( hdlg , IDC_CHECK_VOODOO ) ;
temp_voodoo = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_BUTTON_VOODOO ) ;
2017-05-18 14:03:43 -04:00
EnableWindow ( h , temp_voodoo ? TRUE : FALSE ) ;
break ;
2017-06-04 22:18:41 -04:00
case IDC_BUTTON_VOODOO :
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) & voodoo_device ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-06-04 22:18:41 -04:00
case IDC_CONFIGURE_VID :
2017-05-18 14:03:43 -04:00
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
stransi = ( char * ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO ) ;
SendMessage ( h , CB_GETLBTEXT , SendMessage ( h , CB_GETCURSEL , 0 , 0 ) , ( LPARAM ) lptsTemp ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , lptsTemp , 512 ) ;
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) video_card_getdevice ( video_card_getid ( stransi ) ) ) ;
2017-05-18 14:03:43 -04:00
free ( stransi ) ;
free ( lptsTemp ) ;
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
stransi = ( char * ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO ) ;
SendMessage ( h , CB_GETLBTEXT , SendMessage ( h , CB_GETCURSEL , 0 , 0 ) , ( LPARAM ) lptsTemp ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , lptsTemp , 512 ) ;
2017-05-18 14:03:43 -04:00
temp_gfxcard = video_new_to_old ( video_card_getid ( stransi ) ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_VIDEO_SPEED ) ;
temp_video_speed = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_VOODOO ) ;
temp_voodoo = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
free ( stransi ) ;
free ( lptsTemp ) ;
default :
return FALSE ;
}
return FALSE ;
}
2017-12-10 02:08:37 -05:00
static int mouse_valid ( int num , int m )
2017-05-18 14:03:43 -04:00
{
2017-12-10 02:08:37 -05:00
device_t * dev ;
2017-05-18 14:03:43 -04:00
2017-12-10 02:08:37 -05:00
if ( ( num = = MOUSE_TYPE_INTERNAL ) & &
! ( machines [ m ] . flags & MACHINE_MOUSE ) ) return ( 0 ) ;
2017-11-05 01:57:04 -05:00
2017-12-10 02:08:37 -05:00
dev = mouse_get_device ( num ) ;
return ( device_is_valid ( dev , machines [ m ] . flags ) ) ;
2017-05-18 14:03:43 -04:00
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_input_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
2017-12-04 11:59:26 -05:00
wchar_t str [ 128 ] ;
2017-05-18 14:03:43 -04:00
HWND h ;
int c = 0 ;
int d = 0 ;
switch ( message )
{
case WM_INITDIALOG :
h = GetDlgItem ( hdlg , IDC_COMBO_MOUSE ) ;
c = d = 0 ;
for ( c = 0 ; c < mouse_get_ndev ( ) ; c + + )
{
settings_mouse_to_list [ c ] = d ;
2017-12-10 02:08:37 -05:00
if ( mouse_valid ( c , temp_machine ) )
2017-05-18 14:03:43 -04:00
{
2017-12-04 11:59:26 -05:00
mbstowcs ( str , mouse_get_name ( c ) , sizeof_w ( str ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) str ) ;
2017-05-18 14:03:43 -04:00
settings_list_to_mouse [ d ] = c ;
d + + ;
}
}
SendMessage ( h , CB_SETCURSEL , settings_mouse_to_list [ temp_mouse ] , 0 ) ;
2018-01-26 13:35:50 +01:00
2017-12-10 02:08:37 -05:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MOUSE ) ;
2018-01-26 13:35:50 +01:00
if ( mouse_has_config ( temp_mouse ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
c = 0 ;
while ( joystick_get_name ( c ) )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( 2144 + c ) ) ;
2017-05-18 14:03:43 -04:00
c + + ;
}
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_joystick , 0 ) ;
h = GetDlgItem ( hdlg , IDC_JOY1 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 1 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY2 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 2 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY3 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 3 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY4 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 4 ) ? TRUE : FALSE ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
2018-01-26 13:35:50 +01:00
case IDC_COMBO_MOUSE :
h = GetDlgItem ( hdlg , IDC_COMBO_MOUSE ) ;
temp_mouse = settings_list_to_mouse [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MOUSE ) ;
if ( mouse_has_config ( temp_mouse ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
break ;
2017-12-10 02:08:37 -05:00
case IDC_CONFIGURE_MOUSE :
h = GetDlgItem ( hdlg , IDC_COMBO_MOUSE ) ;
temp_mouse = settings_list_to_mouse [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) mouse_get_device ( temp_mouse ) ) ;
break ;
2017-05-18 14:03:43 -04:00
case IDC_COMBO_JOYSTICK :
2018-01-21 21:39:52 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_JOY1 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 1 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY2 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 2 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY3 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 3 ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_JOY4 ) ;
EnableWindow ( h , ( joystick_get_max_joysticks ( temp_joystick ) > = 4 ) ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
break ;
case IDC_JOY1 :
2018-01-21 23:01:26 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
2017-05-18 14:03:43 -04:00
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-21 21:39:52 +01:00
temp_deviceconfig | = joystickconfig_open ( hdlg , 0 , temp_joystick ) ;
2017-05-18 14:03:43 -04:00
break ;
case IDC_JOY2 :
2018-01-21 23:01:26 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
2017-05-18 14:03:43 -04:00
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-21 21:39:52 +01:00
temp_deviceconfig | = joystickconfig_open ( hdlg , 1 , temp_joystick ) ;
2017-05-18 14:03:43 -04:00
break ;
case IDC_JOY3 :
2018-01-21 23:01:26 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
2017-05-18 14:03:43 -04:00
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-21 21:39:52 +01:00
temp_deviceconfig | = joystickconfig_open ( hdlg , 2 , temp_joystick ) ;
2017-05-18 14:03:43 -04:00
break ;
case IDC_JOY4 :
2018-01-21 23:01:26 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
2017-05-18 14:03:43 -04:00
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-21 21:39:52 +01:00
temp_deviceconfig | = joystickconfig_open ( hdlg , 3 , temp_joystick ) ;
2017-05-18 14:03:43 -04:00
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
h = GetDlgItem ( hdlg , IDC_COMBO_MOUSE ) ;
temp_mouse = settings_list_to_mouse [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
h = GetDlgItem ( hdlg , IDC_COMBO_JOYSTICK ) ;
temp_joystick = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
default :
return FALSE ;
}
return FALSE ;
}
2017-06-03 20:32:58 +02:00
int mpu401_present ( void )
{
char * n ;
2017-06-04 02:41:16 +02:00
n = sound_card_get_internal_name ( temp_sound_card ) ;
2017-06-03 20:32:58 +02:00
if ( n ! = NULL )
{
if ( ! strcmp ( n , " sb16 " ) | | ! strcmp ( n , " sbawe32 " ) )
{
return 1 ;
}
}
return temp_mpu401 ? 1 : 0 ;
}
int mpu401_standalone_allow ( void )
{
2017-06-19 06:46:08 +02:00
char * n , * md ;
2017-06-03 20:32:58 +02:00
2017-06-04 02:41:16 +02:00
n = sound_card_get_internal_name ( temp_sound_card ) ;
2017-06-19 06:46:08 +02:00
md = midi_device_get_internal_name ( temp_midi_device ) ;
2017-06-03 20:32:58 +02:00
if ( n ! = NULL )
{
if ( ! strcmp ( n , " sb16 " ) | | ! strcmp ( n , " sbawe32 " ) )
{
return 0 ;
}
}
2017-06-19 06:46:08 +02:00
if ( md ! = NULL )
{
if ( ! strcmp ( md , " none " ) )
{
return 0 ;
}
}
2017-06-03 20:32:58 +02:00
return 1 ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_sound_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int c = 0 ;
int d = 0 ;
LPTSTR lptsTemp ;
2017-10-11 01:17:41 +02:00
device_t * sound_dev /*, *midi_dev*/ ;
2017-06-19 06:46:08 +02:00
char * s ;
2017-05-18 14:03:43 -04:00
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_SOUND ) ;
2017-05-18 14:03:43 -04:00
c = d = 0 ;
while ( 1 )
{
2017-06-19 06:46:08 +02:00
s = sound_card_getname ( c ) ;
2017-05-18 14:03:43 -04:00
if ( ! s [ 0 ] )
{
break ;
}
settings_sound_to_list [ c ] = d ;
if ( sound_card_available ( c ) )
{
sound_dev = sound_card_getdevice ( c ) ;
2017-10-10 00:14:15 +02:00
if ( device_is_valid ( sound_dev , machines [ temp_machine ] . flags ) )
2017-05-18 14:03:43 -04:00
{
if ( c = = 0 )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2152 ) ) ;
2017-05-18 14:03:43 -04:00
}
else
{
mbstowcs ( lptsTemp , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
settings_list_to_sound [ d ] = c ;
d + + ;
}
}
c + + ;
}
SendMessage ( h , CB_SETCURSEL , settings_sound_to_list [ temp_sound_card ] , 0 ) ;
2017-10-10 00:14:15 +02:00
EnableWindow ( h , d ? TRUE : FALSE ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_SND ) ;
2017-05-18 14:03:43 -04:00
if ( sound_card_has_config ( temp_sound_card ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_MIDI ) ;
2017-06-19 06:46:08 +02:00
c = d = 0 ;
while ( 1 )
2017-05-18 14:03:43 -04:00
{
2017-06-19 06:46:08 +02:00
s = midi_device_getname ( c ) ;
if ( ! s [ 0 ] )
{
break ;
}
settings_midi_to_list [ c ] = d ;
if ( midi_device_available ( c ) )
{
2017-10-11 01:17:41 +02:00
/* midi_dev = midi_device_getdevice(c); */
2017-06-19 06:46:08 +02:00
2017-10-11 01:17:41 +02:00
if ( c = = 0 )
2017-06-19 06:46:08 +02:00
{
2017-10-11 01:17:41 +02:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2152 ) ) ;
}
else
{
mbstowcs ( lptsTemp , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
2017-06-19 06:46:08 +02:00
}
2017-10-11 01:17:41 +02:00
settings_list_to_midi [ d ] = c ;
d + + ;
2017-06-19 06:46:08 +02:00
}
c + + ;
}
2017-08-16 01:48:24 +02:00
SendMessage ( h , CB_SETCURSEL , settings_midi_to_list [ temp_midi_device ] , 0 ) ;
2017-06-19 06:46:08 +02:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MIDI ) ;
if ( midi_device_has_config ( temp_midi_device ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
2017-05-18 14:03:43 -04:00
}
2017-06-03 20:32:58 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_MPU401 ) ;
2017-06-04 16:22:21 +02:00
SendMessage ( h , BM_SETCHECK , temp_mpu401 , 0 ) ;
2017-06-03 20:32:58 +02:00
EnableWindow ( h , mpu401_standalone_allow ( ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MPU401 ) ;
EnableWindow ( h , ( mpu401_standalone_allow ( ) & & temp_mpu401 ) ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_CMS ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , BM_SETCHECK , temp_GAMEBLASTER , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_GUS ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , BM_SETCHECK , temp_GUS , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_SSI ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , BM_SETCHECK , temp_SSI2001 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_NUKEDOPL ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , BM_SETCHECK , temp_opl3_type , 0 ) ;
2017-06-14 07:21:01 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_FLOAT ) ;
SendMessage ( h , BM_SETCHECK , temp_float , 0 ) ;
2017-05-18 14:03:43 -04:00
free ( lptsTemp ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
2017-06-19 06:46:08 +02:00
case IDC_COMBO_SOUND :
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_SOUND ) ;
2017-05-18 14:03:43 -04:00
temp_sound_card = settings_list_to_sound [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-06-19 06:46:08 +02:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_SND ) ;
if ( sound_card_has_config ( temp_sound_card ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-06-20 23:19:00 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_MPU401 ) ;
SendMessage ( h , BM_SETCHECK , temp_mpu401 , 0 ) ;
EnableWindow ( h , mpu401_standalone_allow ( ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MPU401 ) ;
EnableWindow ( h , ( mpu401_standalone_allow ( ) & & temp_mpu401 ) ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-06-19 06:46:08 +02:00
case IDC_CONFIGURE_SND :
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_SOUND ) ;
2017-05-18 14:03:43 -04:00
temp_sound_card = settings_list_to_sound [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) sound_card_getdevice ( temp_sound_card ) ) ;
2017-06-19 06:46:08 +02:00
break ;
case IDC_COMBO_MIDI :
h = GetDlgItem ( hdlg , IDC_COMBO_MIDI ) ;
temp_midi_device = settings_list_to_midi [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MIDI ) ;
if ( midi_device_has_config ( temp_midi_device ) )
2017-05-18 14:03:43 -04:00
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-06-03 20:32:58 +02:00
2017-06-20 23:19:00 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_MPU401 ) ;
SendMessage ( h , BM_SETCHECK , temp_mpu401 , 0 ) ;
EnableWindow ( h , mpu401_standalone_allow ( ) ? TRUE : FALSE ) ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MPU401 ) ;
EnableWindow ( h , ( mpu401_standalone_allow ( ) & & temp_mpu401 ) ? TRUE : FALSE ) ;
2017-06-03 20:32:58 +02:00
break ;
2017-06-19 06:46:08 +02:00
case IDC_CONFIGURE_MIDI :
h = GetDlgItem ( hdlg , IDC_COMBO_MIDI ) ;
temp_midi_device = settings_list_to_midi [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) midi_device_getdevice ( temp_midi_device ) ) ;
2017-06-19 06:46:08 +02:00
break ;
2017-06-03 20:32:58 +02:00
case IDC_CHECK_MPU401 :
h = GetDlgItem ( hdlg , IDC_CHECK_MPU401 ) ;
temp_mpu401 = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_MPU401 ) ;
EnableWindow ( h , mpu401_present ( ) ? TRUE : FALSE ) ;
break ;
case IDC_CONFIGURE_MPU401 :
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) & mpu401_device ) ;
2017-05-18 14:03:43 -04:00
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_SOUND ) ;
2017-05-18 14:03:43 -04:00
temp_sound_card = settings_list_to_sound [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
h = GetDlgItem ( hdlg , IDC_COMBO_MIDI ) ;
2017-06-19 06:46:08 +02:00
temp_midi_device = settings_list_to_midi [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-05-18 14:03:43 -04:00
2017-06-03 20:32:58 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_MPU401 ) ;
temp_mpu401 = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_CMS ) ;
2017-05-18 14:03:43 -04:00
temp_GAMEBLASTER = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_GUS ) ;
2017-05-18 14:03:43 -04:00
temp_GUS = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_SSI ) ;
2017-05-18 14:03:43 -04:00
temp_SSI2001 = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_NUKEDOPL ) ;
2017-05-18 14:03:43 -04:00
temp_opl3_type = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-06-14 07:21:01 +02:00
h = GetDlgItem ( hdlg , IDC_CHECK_FLOAT ) ;
temp_float = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
2017-05-18 14:03:43 -04:00
default :
return FALSE ;
}
return FALSE ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_ports_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-09-02 23:39:26 +02:00
{
HWND h ;
int c = 0 ;
int d = 0 ;
char * s ;
LPTSTR lptsTemp ;
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_LPT1 ) ;
c = d = 0 ;
while ( 1 )
{
s = lpt_device_get_name ( c ) ;
if ( ! s )
{
break ;
}
if ( c = = 0 )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2152 ) ) ;
2017-09-02 23:39:26 +02:00
}
else
{
mbstowcs ( lptsTemp , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
if ( ! strcmp ( temp_lpt1_device_name , lpt_device_get_internal_name ( c ) ) )
{
d = c ;
}
c + + ;
}
SendMessage ( h , CB_SETCURSEL , d , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_SERIAL1 ) ;
SendMessage ( h , BM_SETCHECK , temp_serial [ 0 ] , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_SERIAL2 ) ;
SendMessage ( h , BM_SETCHECK , temp_serial [ 1 ] , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_PARALLEL ) ;
SendMessage ( h , BM_SETCHECK , temp_lpt , 0 ) ;
free ( lptsTemp ) ;
return TRUE ;
case WM_SAVESETTINGS :
h = GetDlgItem ( hdlg , IDC_COMBO_LPT1 ) ;
c = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
strcpy ( temp_lpt1_device_name , lpt_device_get_internal_name ( c ) ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_SERIAL1 ) ;
temp_serial [ 0 ] = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_SERIAL2 ) ;
temp_serial [ 1 ] = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK_PARALLEL ) ;
temp_lpt = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
default :
return FALSE ;
}
return FALSE ;
}
2017-10-01 16:29:15 -04:00
static void recalc_hdc_list ( HWND hdlg , int machine , int use_selected_hdc )
2017-09-02 23:39:26 +02:00
{
HWND h ;
char * s ;
int valid = 0 ;
char old_name [ 16 ] ;
int c , d ;
LPTSTR lptsTemp ;
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HDC ) ;
2017-10-02 02:15:35 -04:00
valid = 0 ;
if ( use_selected_hdc )
2017-09-02 23:39:26 +02:00
{
2017-10-02 02:15:35 -04:00
c = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-09-02 23:39:26 +02:00
2017-10-02 02:15:35 -04:00
if ( c ! = - 1 & & hdc_names [ c ] )
{
strncpy ( old_name , hdc_names [ c ] , sizeof ( old_name ) - 1 ) ;
}
else
{
strcpy ( old_name , " none " ) ;
}
2017-09-02 23:39:26 +02:00
}
else
{
2017-10-02 02:15:35 -04:00
strncpy ( old_name , temp_hdc_name , sizeof ( old_name ) - 1 ) ;
}
2017-09-02 23:39:26 +02:00
2017-10-02 02:15:35 -04:00
SendMessage ( h , CB_RESETCONTENT , 0 , 0 ) ;
c = d = 0 ;
while ( 1 )
{
s = hdc_get_name ( c ) ;
if ( s [ 0 ] = = 0 )
2017-09-02 23:39:26 +02:00
{
2017-10-02 02:15:35 -04:00
break ;
2017-09-02 23:39:26 +02:00
}
2017-11-05 01:57:04 -05:00
if ( c = = 1 & & ! ( machines [ temp_machine ] . flags & MACHINE_HDC ) )
2017-09-02 23:39:26 +02:00
{
2017-10-02 02:15:35 -04:00
/* Skip "Internal" if machine doesn't have one. */
c + + ;
continue ;
2017-09-02 23:39:26 +02:00
}
2017-10-10 00:14:15 +02:00
if ( ! hdc_available ( c ) | | ! device_is_valid ( hdc_get_device ( c ) , machines [ temp_machine ] . flags ) )
2017-10-02 02:15:35 -04:00
{
c + + ;
continue ;
}
mbstowcs ( lptsTemp , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
2017-09-02 23:39:26 +02:00
2017-10-02 02:15:35 -04:00
hdc_names [ d ] = hdc_get_internal_name ( c ) ;
if ( ! strcmp ( old_name , hdc_names [ d ] ) )
2017-09-02 23:39:26 +02:00
{
2017-10-02 02:15:35 -04:00
SendMessage ( h , CB_SETCURSEL , d , 0 ) ;
valid = 1 ;
2017-09-02 23:39:26 +02:00
}
2017-10-02 02:15:35 -04:00
c + + ;
d + + ;
}
2017-09-02 23:39:26 +02:00
2017-10-02 02:15:35 -04:00
if ( ! valid )
{
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
2017-09-02 23:39:26 +02:00
}
2017-10-02 02:15:35 -04:00
2017-10-10 00:14:15 +02:00
EnableWindow ( h , d ? TRUE : FALSE ) ;
2017-09-02 23:39:26 +02:00
free ( lptsTemp ) ;
}
int valid_ide_irqs [ 11 ] = { 2 , 3 , 4 , 5 , 7 , 9 , 10 , 11 , 12 , 14 , 15 } ;
int find_irq_in_array ( int irq , int def )
{
int i = 0 ;
for ( i = 0 ; i < 11 ; i + + )
{
if ( valid_ide_irqs [ i ] = = irq )
{
return i + 1 ;
}
}
return 7 + def ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_peripherals_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int c = 0 ;
int d = 0 ;
LPTSTR lptsTemp ;
device_t * scsi_dev ;
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
/*SCSI config*/
h = GetDlgItem ( hdlg , IDC_COMBO_SCSI ) ;
c = d = 0 ;
while ( 1 )
{
char * s = scsi_card_getname ( c ) ;
if ( ! s [ 0 ] )
{
break ;
}
settings_scsi_to_list [ c ] = d ;
if ( scsi_card_available ( c ) )
{
scsi_dev = scsi_card_getdevice ( c ) ;
2017-10-10 00:14:15 +02:00
2017-10-10 03:07:29 -04:00
2017-10-10 00:14:15 +02:00
if ( device_is_valid ( scsi_dev , machines [ temp_machine ] . flags ) )
2017-05-18 14:03:43 -04:00
{
if ( c = = 0 )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_2152 ) ) ;
2017-05-18 14:03:43 -04:00
}
else
{
mbstowcs ( lptsTemp , s , strlen ( s ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
settings_list_to_scsi [ d ] = c ;
d + + ;
}
}
c + + ;
}
SendMessage ( h , CB_SETCURSEL , settings_scsi_to_list [ temp_scsi_card ] , 0 ) ;
2017-10-10 00:14:15 +02:00
EnableWindow ( h , d ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_SCSI ) ;
if ( scsi_card_has_config ( temp_scsi_card ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-10-01 16:29:15 -04:00
recalc_hdc_list ( hdlg , temp_machine , 0 ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_IDE_TER ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_5376 ) ) ;
2017-05-18 14:03:43 -04:00
for ( c = 0 ; c < 11 ; c + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_2155 ) , valid_ide_irqs [ c ] ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
if ( temp_ide_ter )
{
SendMessage ( h , CB_SETCURSEL , find_irq_in_array ( temp_ide_ter_irq , 0 ) , 0 ) ;
}
else
{
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_IDE_QUA ) ;
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_5376 ) ) ;
2017-05-18 14:03:43 -04:00
for ( c = 0 ; c < 11 ; c + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_2155 ) , valid_ide_irqs [ c ] ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
if ( temp_ide_qua )
{
SendMessage ( h , CB_SETCURSEL , find_irq_in_array ( temp_ide_qua_irq , 1 ) , 0 ) ;
}
else
{
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_BUGGER ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , BM_SETCHECK , temp_bugger , 0 ) ;
free ( lptsTemp ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDC_CONFIGURE_SCSI :
h = GetDlgItem ( hdlg , IDC_COMBO_SCSI ) ;
temp_scsi_card = settings_list_to_scsi [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) scsi_card_getdevice ( temp_scsi_card ) ) ;
2017-05-18 14:03:43 -04:00
break ;
case IDC_COMBO_SCSI :
h = GetDlgItem ( hdlg , IDC_COMBO_SCSI ) ;
temp_scsi_card = settings_list_to_scsi [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
h = GetDlgItem ( hdlg , IDC_CONFIGURE_SCSI ) ;
if ( scsi_card_has_config ( temp_scsi_card ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
2017-10-02 02:15:35 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_HDC ) ;
c = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
if ( hdc_names [ c ] )
2017-05-18 14:03:43 -04:00
{
2017-10-02 02:15:35 -04:00
strncpy ( temp_hdc_name , hdc_names [ c ] , sizeof ( temp_hdc_name ) - 1 ) ;
2017-05-18 14:03:43 -04:00
}
else
{
strcpy ( temp_hdc_name , " none " ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_SCSI ) ;
temp_scsi_card = settings_list_to_scsi [ 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 )
{
temp_ide_ter_irq = valid_ide_irqs [ temp_ide_ter - 1 ] ;
temp_ide_ter = 1 ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_IDE_QUA ) ;
temp_ide_qua = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
if ( temp_ide_qua > 1 )
{
temp_ide_qua_irq = valid_ide_irqs [ temp_ide_qua - 1 ] ;
temp_ide_qua = 1 ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CHECK_BUGGER ) ;
2017-05-18 14:03:43 -04:00
temp_bugger = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
default :
return FALSE ;
}
return FALSE ;
}
int net_ignore_message = 0 ;
static void network_recalc_combos ( HWND hdlg )
{
HWND h ;
net_ignore_message = 1 ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_PCAP ) ;
2017-05-18 14:03:43 -04:00
if ( temp_net_type = = NET_TYPE_PCAP )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET ) ;
2017-05-18 14:03:43 -04:00
if ( temp_net_type = = NET_TYPE_SLIRP )
{
EnableWindow ( h , TRUE ) ;
}
else if ( ( temp_net_type = = NET_TYPE_PCAP ) & &
( network_dev_to_id ( temp_pcap_dev ) > 0 ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_CONFIGURE_NET ) ;
2017-05-18 14:03:43 -04:00
if ( network_card_has_config ( temp_net_card ) & &
( temp_net_type = = NET_TYPE_SLIRP ) )
{
EnableWindow ( h , TRUE ) ;
}
else if ( network_card_has_config ( temp_net_card ) & &
( temp_net_type = = NET_TYPE_PCAP ) & &
( network_dev_to_id ( temp_pcap_dev ) > 0 ) )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
net_ignore_message = 0 ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_network_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int c = 0 ;
int d = 0 ;
LPTSTR lptsTemp ;
switch ( message )
{
case WM_INITDIALOG :
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET_TYPE ) ;
2017-05-18 14:03:43 -04:00
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 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_PCAP ) ;
2017-05-18 14:03:43 -04:00
if ( temp_net_type = = NET_TYPE_PCAP )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_PCAP ) ;
2017-05-18 14:03:43 -04:00
for ( c = 0 ; c < network_ndev ; c + + )
{
mbstowcs ( lptsTemp , network_devs [ c ] . description , strlen ( network_devs [ c ] . description ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
SendMessage ( h , CB_SETCURSEL , network_dev_to_id ( temp_pcap_dev ) , 0 ) ;
/*NIC config*/
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET ) ;
2017-05-18 14:03:43 -04:00
c = d = 0 ;
while ( 1 )
{
char * s = network_card_getname ( c ) ;
if ( s [ 0 ] = = ' \0 ' )
{
break ;
}
settings_network_to_list [ c ] = d ;
2017-10-10 00:14:15 +02:00
if ( network_card_available ( c ) & & device_is_valid ( network_card_getdevice ( c ) , machines [ temp_machine ] . flags ) )
2017-05-18 14:03:43 -04:00
{
if ( c = = 0 )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( 2152 ) ) ;
2017-05-18 14:03:43 -04:00
}
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 ) ;
2017-10-10 00:14:15 +02:00
EnableWindow ( h , d ? TRUE : FALSE ) ;
2017-05-18 14:03:43 -04:00
network_recalc_combos ( hdlg ) ;
free ( lptsTemp ) ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
2017-06-04 22:18:41 -04:00
case IDC_COMBO_NET_TYPE :
2017-05-18 14:03:43 -04:00
if ( net_ignore_message )
{
return FALSE ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET_TYPE ) ;
2017-05-18 14:03:43 -04:00
temp_net_type = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
network_recalc_combos ( hdlg ) ;
break ;
2017-06-04 22:18:41 -04:00
case IDC_COMBO_PCAP :
2017-05-18 14:03:43 -04:00
if ( net_ignore_message )
{
return FALSE ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_PCAP ) ;
2017-05-18 14:03:43 -04:00
memset ( temp_pcap_dev , ' \0 ' , sizeof ( temp_pcap_dev ) ) ;
strcpy ( temp_pcap_dev , network_devs [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] . device ) ;
network_recalc_combos ( hdlg ) ;
break ;
2017-06-04 22:18:41 -04:00
case IDC_COMBO_NET :
2017-05-18 14:03:43 -04:00
if ( net_ignore_message )
{
return FALSE ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET ) ;
2017-05-18 14:03:43 -04:00
temp_net_card = settings_list_to_network [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
network_recalc_combos ( hdlg ) ;
break ;
2017-06-04 22:18:41 -04:00
case IDC_CONFIGURE_NET :
2017-05-18 14:03:43 -04:00
if ( net_ignore_message )
{
return FALSE ;
}
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET ) ;
2017-05-18 14:03:43 -04:00
temp_net_card = settings_list_to_network [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] ;
2017-10-19 23:55:51 +02:00
temp_deviceconfig | = deviceconfig_open ( hdlg , ( void * ) network_card_getdevice ( temp_net_card ) ) ;
2017-05-18 14:03:43 -04:00
break ;
}
return FALSE ;
case WM_SAVESETTINGS :
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET_TYPE ) ;
2017-05-18 14:03:43 -04:00
temp_net_type = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_PCAP ) ;
2017-05-18 14:03:43 -04:00
memset ( temp_pcap_dev , ' \0 ' , sizeof ( temp_pcap_dev ) ) ;
strcpy ( temp_pcap_dev , network_devs [ SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ] . device ) ;
2017-06-04 22:18:41 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_NET ) ;
2017-05-18 14:03:43 -04:00
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 ;
HIMAGELIST hSmall ;
hSmall = ImageList_Create ( GetSystemMetrics ( SM_CXSMICON ) ,
GetSystemMetrics ( SM_CYSMICON ) ,
ILC_MASK | ILC_COLOR32 , 1 , 1 ) ;
2018-01-26 22:17:09 +01:00
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 208 ) ;
2017-08-22 22:32:41 +02:00
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 192 ) ;
2017-05-27 03:53:32 +02:00
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
2017-05-18 14:03:43 -04:00
ListView_SetImageList ( hwndList , hSmall , LVSIL_SMALL ) ;
return TRUE ;
}
int next_free_id = 0 ;
static void normalize_hd_list ( )
{
2017-09-30 16:56:38 -04:00
hard_disk_t ihdd [ HDD_NUM ] ;
2017-05-18 14:03:43 -04:00
int i , j ;
j = 0 ;
2017-10-01 16:29:15 -04:00
memset ( ihdd , 0x00 , HDD_NUM * sizeof ( hard_disk_t ) ) ;
2017-05-27 03:53:32 +02:00
2017-09-30 16:56:38 -04:00
for ( i = 0 ; i < HDD_NUM ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
if ( temp_hdd [ i ] . bus ! = HDD_BUS_DISABLED )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
memcpy ( & ( ihdd [ j ] ) , & ( temp_hdd [ i ] ) , sizeof ( hard_disk_t ) ) ;
2017-05-18 14:03:43 -04:00
j + + ;
}
}
2017-09-30 16:56:38 -04:00
memcpy ( temp_hdd , ihdd , HDD_NUM * sizeof ( hard_disk_t ) ) ;
2017-05-18 14:03:43 -04:00
}
2017-09-30 16:56:38 -04:00
int hdc_id_to_listview_index [ HDD_NUM ] ;
2017-05-18 14:03:43 -04:00
int hd_listview_items ;
2017-09-30 16:56:38 -04:00
hard_disk_t new_hdd ;
2017-05-18 14:03:43 -04:00
int hdlv_current_sel ;
static int get_selected_hard_disk ( HWND hdlg )
{
int hard_disk = - 1 ;
int i , j = 0 ;
HWND h ;
2017-05-29 01:18:32 +02:00
if ( hd_listview_items = = 0 )
{
return 0 ;
}
for ( i = 0 ; i < hd_listview_items ; i + + )
2017-05-18 14:03:43 -04:00
{
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
j = ListView_GetItemState ( h , i , LVIS_SELECTED ) ;
if ( j )
{
hard_disk = i ;
}
}
return hard_disk ;
}
static void add_locations ( HWND hdlg )
{
LPTSTR lptsTemp ;
HWND h ;
int i = 0 ;
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-07-24 12:04:39 +02:00
for ( i = 0 ; i < 7 ; i + + )
2017-05-27 03:53:32 +02:00
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_4352 + i ) ) ;
2017-05-27 03:53:32 +02:00
}
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
for ( i = 0 ; i < 8 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4097 ) , i > > 1 , i & 1 ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
for ( i = 0 ; i < 16 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
for ( i = 0 ; i < 8 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
for ( i = 0 ; i < 8 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4097 ) , i > > 1 , i & 1 ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
free ( lptsTemp ) ;
}
2018-01-27 02:38:52 +01:00
static uint8_t next_free_binary_channel ( uint64_t * tracking )
2018-01-19 15:39:13 +01:00
{
2018-01-27 02:38:52 +01:00
int64_t i ;
2018-01-19 15:39:13 +01:00
for ( i = 0 ; i < 2 ; i + + ) {
2018-01-27 02:38:52 +01:00
if ( ! ( * tracking & ( 0xffLL < < ( i < < 3LL ) ) ) )
2018-01-19 15:39:13 +01:00
return i ;
}
return 2 ;
}
static uint8_t next_free_ide_channel ( void )
{
2018-01-27 02:38:52 +01:00
int64_t i ;
2018-01-19 15:39:13 +01:00
for ( i = 0 ; i < 8 ; i + + ) {
2018-01-27 02:38:52 +01:00
if ( ! ( ide_tracking & ( 0xffLL < < ( i < < 3LL ) ) ) )
2018-01-19 15:39:13 +01:00
return i ;
}
return 7 ;
}
static void next_free_scsi_id_and_lun ( uint8_t * id , uint8_t * lun )
{
2018-01-27 02:38:52 +01:00
int64_t i , j ;
2018-01-19 15:39:13 +01:00
for ( j = 0 ; j < 8 ; j + + ) {
for ( i = 0 ; i < 16 ; i + + ) {
2018-01-27 02:38:52 +01:00
if ( ! ( scsi_tracking [ i ] & ( 0xffLL < < ( j < < 3LL ) ) ) ) {
2018-01-19 15:39:13 +01:00
* id = i ;
* lun = j ;
return ;
}
}
}
* id = 6 ;
* lun = 7 ;
}
static void recalc_location_controls ( HWND hdlg , int is_add_dlg , int assign_id )
2017-05-18 14:03:43 -04:00
{
int i = 0 ;
HWND h ;
int bus = 0 ;
2017-06-15 22:40:43 -04:00
for ( i = IDT_1722 ; i < = IDT_1724 ; i + + )
2017-05-18 14:03:43 -04:00
{
h = GetDlgItem ( hdlg , i ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
if ( ( hd_listview_items > 0 ) | | is_add_dlg )
{
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
bus = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
bus + + ;
2017-05-18 14:03:43 -04:00
switch ( bus )
{
2017-05-27 03:53:32 +02:00
case HDD_BUS_MFM : /* MFM */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1722 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-27 02:38:52 +01:00
if ( assign_id )
2018-01-19 15:39:13 +01:00
temp_hdd [ hdlv_current_sel ] . mfm_channel = next_free_binary_channel ( & mfm_tracking ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . mfm_channel : temp_hdd [ hdlv_current_sel ] . mfm_channel , 0 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-07-24 12:04:39 +02:00
case HDD_BUS_XTIDE : /* XT IDE */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1722 ) ;
2017-05-27 03:53:32 +02:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-27 02:38:52 +01:00
if ( assign_id )
2018-01-19 15:39:13 +01:00
temp_hdd [ hdlv_current_sel ] . xtide_channel = next_free_binary_channel ( & xtide_tracking ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . xtide_channel : temp_hdd [ hdlv_current_sel ] . xtide_channel , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
2017-08-25 02:21:26 -04:00
case HDD_BUS_ESDI : /* ESDI */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1722 ) ;
2017-05-27 03:53:32 +02:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-27 02:38:52 +01:00
if ( assign_id )
2018-01-19 15:39:13 +01:00
temp_hdd [ hdlv_current_sel ] . esdi_channel = next_free_binary_channel ( & esdi_tracking ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . esdi_channel : temp_hdd [ hdlv_current_sel ] . esdi_channel , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_IDE_PIO_ONLY : /* IDE (PIO-only) */
case HDD_BUS_IDE_PIO_AND_DMA : /* IDE (PIO and DMA) */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1722 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-27 02:38:52 +01:00
if ( assign_id )
2018-01-19 15:39:13 +01:00
temp_hdd [ hdlv_current_sel ] . ide_channel = next_free_ide_channel ( ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . ide_channel : temp_hdd [ hdlv_current_sel ] . ide_channel , 0 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_SCSI : /* SCSI */
case HDD_BUS_SCSI_REMOVABLE : /* SCSI (removable) */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1723 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1724 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-27 02:38:52 +01:00
if ( assign_id )
2018-01-19 15:39:13 +01:00
next_free_scsi_id_and_lun ( ( uint8_t * ) & temp_hdd [ hdlv_current_sel ] . scsi_id , ( uint8_t * ) & temp_hdd [ hdlv_current_sel ] . scsi_lun ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . scsi_id : temp_hdd [ hdlv_current_sel ] . scsi_id , 0 ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , is_add_dlg ? new_hdd . scsi_lun : temp_hdd [ hdlv_current_sel ] . scsi_lun , 0 ) ;
2017-05-18 14:03:43 -04:00
break ;
}
}
if ( ( hd_listview_items = = 0 ) & & ! is_add_dlg )
{
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1721 ) ;
2017-05-18 14:03:43 -04:00
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
EnableWindow ( h , FALSE ) ; ShowWindow ( h , SW_HIDE ) ;
}
else
{
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1721 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
}
}
2018-01-27 02:38:52 +01:00
static int bus_full ( uint64_t * tracking , int count )
{
int full = 0 ;
switch ( count ) {
case 2 :
default :
full = ( * tracking & 0xFF00LL ) ;
full = full & & ( * tracking & 0x00FFLL ) ;
return full ;
case 8 :
full = ( * tracking & 0xFF00000000000000LL ) ;
full = full & & ( * tracking & 0x00FF000000000000LL ) ;
full = full & & ( * tracking & 0x0000FF0000000000LL ) ;
full = full & & ( * tracking & 0x000000FF00000000LL ) ;
full = full & & ( * tracking & 0x00000000FF000000LL ) ;
full = full & & ( * tracking & 0x0000000000FF0000LL ) ;
full = full & & ( * tracking & 0x000000000000FF00LL ) ;
full = full & & ( * tracking & 0x00000000000000FFLL ) ;
return full ;
}
}
2017-05-18 14:03:43 -04:00
static void recalc_next_free_id ( HWND hdlg )
{
HWND h ;
int i ;
int c_mfm = 0 ;
2017-08-25 02:21:26 -04:00
int c_esdi = 0 ;
2017-05-27 03:53:32 +02:00
int c_xtide = 0 ;
2017-05-18 14:03:43 -04:00
int c_ide_pio = 0 ;
int c_ide_dma = 0 ;
int c_scsi = 0 ;
int enable_add = 0 ;
next_free_id = - 1 ;
2017-09-30 16:56:38 -04:00
for ( i = 0 ; i < HDD_NUM ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
if ( temp_hdd [ i ] . bus = = HDD_BUS_MFM )
2017-05-18 14:03:43 -04:00
{
c_mfm + + ;
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_ESDI )
2017-05-27 03:53:32 +02:00
{
2017-08-25 02:21:26 -04:00
c_esdi + + ;
2017-05-27 03:53:32 +02:00
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_XTIDE )
2017-05-27 03:53:32 +02:00
{
c_xtide + + ;
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_IDE_PIO_ONLY )
2017-05-18 14:03:43 -04:00
{
c_ide_pio + + ;
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_IDE_PIO_AND_DMA )
2017-05-18 14:03:43 -04:00
{
c_ide_dma + + ;
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_SCSI )
2017-05-27 03:53:32 +02:00
{
c_scsi + + ;
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ i ] . bus = = HDD_BUS_SCSI_REMOVABLE )
2017-05-18 14:03:43 -04:00
{
c_scsi + + ;
}
}
2017-09-30 16:56:38 -04:00
for ( i = 0 ; i < HDD_NUM ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
if ( temp_hdd [ i ] . bus = = HDD_BUS_DISABLED )
2017-05-18 14:03:43 -04:00
{
next_free_id = i ;
break ;
}
}
enable_add = enable_add | | ( next_free_id > = 0 ) ;
2017-08-25 02:21:26 -04:00
enable_add = enable_add & & ( ( c_mfm < MFM_NUM ) | | ( c_esdi < ESDI_NUM ) | | ( c_xtide < XTIDE_NUM ) | | ( c_ide_pio < IDE_NUM ) | | ( c_ide_dma < IDE_NUM ) | | ( c_scsi < SCSI_NUM ) ) ;
2018-01-27 02:38:52 +01:00
enable_add = enable_add & & ! bus_full ( & mfm_tracking , 2 ) ;
enable_add = enable_add & & ! bus_full ( & esdi_tracking , 2 ) ;
enable_add = enable_add & & ! bus_full ( & xtide_tracking , 2 ) ;
enable_add = enable_add & & ! bus_full ( & ide_tracking , 8 ) ;
2018-01-19 15:39:13 +01:00
for ( i = 0 ; i < 16 ; i + + )
2018-01-27 02:38:52 +01:00
enable_add = enable_add & & ! bus_full ( & ( scsi_tracking [ i ] ) , 8 ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_BUTTON_HDD_ADD_NEW ) ;
if ( enable_add )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
h = GetDlgItem ( hdlg , IDC_BUTTON_HDD_ADD ) ;
if ( enable_add )
{
EnableWindow ( h , TRUE ) ;
}
else
{
EnableWindow ( h , FALSE ) ;
}
h = GetDlgItem ( hdlg , IDC_BUTTON_HDD_REMOVE ) ;
2017-08-25 02:21:26 -04:00
if ( ( c_mfm = = 0 ) & & ( c_esdi = = 0 ) & & ( c_xtide = = 0 ) & & ( c_ide_pio = = 0 ) & & ( c_ide_dma = = 0 ) & & ( c_scsi = = 0 ) )
2017-05-18 14:03:43 -04:00
{
EnableWindow ( h , FALSE ) ;
}
else
{
EnableWindow ( h , TRUE ) ;
}
}
static void win_settings_hard_disks_update_item ( HWND hwndList , int i , int column )
{
LVITEM lvI ;
WCHAR szText [ 256 ] ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
lvI . iSubItem = column ;
lvI . iItem = i ;
if ( column = = 0 )
{
2017-09-30 16:56:38 -04:00
switch ( temp_hdd [ i ] . bus )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
case HDD_BUS_MFM :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4608 ) , temp_hdd [ i ] . mfm_channel > > 1 , temp_hdd [ i ] . mfm_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_XTIDE :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4609 ) , temp_hdd [ i ] . xtide_channel > > 1 , temp_hdd [ i ] . xtide_channel & 1 ) ;
2017-07-24 12:04:39 +02:00
break ;
2017-08-25 02:21:26 -04:00
case HDD_BUS_ESDI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4610 ) , temp_hdd [ i ] . esdi_channel > > 1 , temp_hdd [ i ] . esdi_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_IDE_PIO_ONLY :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4611 ) , temp_hdd [ i ] . ide_channel > > 1 , temp_hdd [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_IDE_PIO_AND_DMA :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4612 ) , temp_hdd [ i ] . ide_channel > > 1 , temp_hdd [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_SCSI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4613 ) , temp_hdd [ i ] . scsi_id , temp_hdd [ i ] . scsi_lun ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_SCSI_REMOVABLE :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4614 ) , temp_hdd [ i ] . scsi_id , temp_hdd [ i ] . scsi_lun ) ;
2017-05-27 03:53:32 +02:00
break ;
2017-05-18 14:03:43 -04:00
}
lvI . pszText = szText ;
2017-09-30 16:56:38 -04:00
lvI . iImage = ( temp_hdd [ i ] . bus = = HDD_BUS_SCSI_REMOVABLE ) ? 1 : 0 ;
2017-05-18 14:03:43 -04:00
}
else if ( column = = 1 )
{
2017-09-30 16:56:38 -04:00
lvI . pszText = temp_hdd [ i ] . fn ;
2017-05-18 14:03:43 -04:00
lvI . iImage = 0 ;
}
else if ( column = = 2 )
{
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . tracks ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iImage = 0 ;
}
else if ( column = = 3 )
{
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . hpc ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iImage = 0 ;
}
else if ( column = = 4 )
{
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . spt ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iImage = 0 ;
}
else if ( column = = 5 )
{
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , ( temp_hdd [ i ] . tracks * temp_hdd [ i ] . hpc * temp_hdd [ i ] . spt ) > > 11 ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iImage = 0 ;
}
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
}
static BOOL win_settings_hard_disks_recalc_list ( HWND hwndList )
{
LVITEM lvI ;
int i = 0 ;
int j = 0 ;
WCHAR szText [ 256 ] ;
hd_listview_items = 0 ;
hdlv_current_sel = - 1 ;
ListView_DeleteAllItems ( hwndList ) ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
2017-09-30 16:56:38 -04:00
for ( i = 0 ; i < HDD_NUM ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
if ( temp_hdd [ i ] . bus > 0 )
2017-05-18 14:03:43 -04:00
{
hdc_id_to_listview_index [ i ] = j ;
lvI . iSubItem = 0 ;
2017-09-30 16:56:38 -04:00
switch ( temp_hdd [ i ] . bus )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
case HDD_BUS_MFM :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4608 ) , temp_hdd [ i ] . mfm_channel > > 1 , temp_hdd [ i ] . mfm_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_XTIDE :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4609 ) , temp_hdd [ i ] . xtide_channel > > 1 , temp_hdd [ i ] . xtide_channel & 1 ) ;
2017-07-24 12:04:39 +02:00
break ;
2017-08-25 02:21:26 -04:00
case HDD_BUS_ESDI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4610 ) , temp_hdd [ i ] . esdi_channel > > 1 , temp_hdd [ i ] . esdi_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_IDE_PIO_ONLY :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4611 ) , temp_hdd [ i ] . ide_channel > > 1 , temp_hdd [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_IDE_PIO_AND_DMA :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4612 ) , temp_hdd [ i ] . ide_channel > > 1 , temp_hdd [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_SCSI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4613 ) , temp_hdd [ i ] . scsi_id , temp_hdd [ i ] . scsi_lun ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case HDD_BUS_SCSI_REMOVABLE :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4614 ) , temp_hdd [ i ] . scsi_id , temp_hdd [ i ] . scsi_lun ) ;
2017-05-27 03:53:32 +02:00
break ;
2017-05-18 14:03:43 -04:00
}
lvI . pszText = szText ;
lvI . iItem = j ;
2017-09-30 16:56:38 -04:00
lvI . iImage = ( temp_hdd [ i ] . bus = = HDD_BUS_SCSI_REMOVABLE ) ? 1 : 0 ;
2017-05-18 14:03:43 -04:00
if ( ListView_InsertItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
lvI . iSubItem = 1 ;
2017-09-30 16:56:38 -04:00
lvI . pszText = temp_hdd [ i ] . fn ;
2017-05-18 14:03:43 -04:00
lvI . iItem = j ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
lvI . iSubItem = 2 ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . tracks ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iItem = j ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
lvI . iSubItem = 3 ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . hpc ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iItem = j ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
lvI . iSubItem = 4 ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , temp_hdd [ i ] . spt ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iItem = j ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
lvI . iSubItem = 5 ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_4098 ) , ( temp_hdd [ i ] . tracks * temp_hdd [ i ] . hpc * temp_hdd [ i ] . spt ) > > 11 ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
lvI . iItem = j ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
j + + ;
}
else
{
hdc_id_to_listview_index [ i ] = - 1 ;
}
}
hd_listview_items = j ;
return TRUE ;
}
/* Icon, Bus, File, C, H, S, Size */
# define C_COLUMNS_HARD_DISKS 6
static BOOL win_settings_hard_disks_init_columns ( HWND hwndList )
{
LVCOLUMN lvc ;
int iCol ;
lvc . mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
for ( iCol = 0 ; iCol < C_COLUMNS_HARD_DISKS ; iCol + + )
{
lvc . iSubItem = iCol ;
2017-10-10 03:07:29 -04:00
lvc . pszText = plat_get_string ( 2082 + iCol ) ;
2017-05-18 14:03:43 -04:00
switch ( iCol )
{
case 0 : /* Bus */
lvc . cx = 135 ;
lvc . fmt = LVCFMT_LEFT ;
break ;
case 2 : /* Cylinders */
lvc . cx = 41 ;
lvc . fmt = LVCFMT_RIGHT ;
break ;
case 3 : /* Heads */
case 4 : /* Sectors */
lvc . cx = 25 ;
lvc . fmt = LVCFMT_RIGHT ;
break ;
case 1 : /* File */
lvc . cx = 150 ;
lvc . fmt = LVCFMT_LEFT ;
break ;
case 5 : /* Size (MB) 8 */
lvc . cx = 41 ;
lvc . fmt = LVCFMT_RIGHT ;
break ;
}
if ( ListView_InsertColumn ( hwndList , iCol , & lvc ) = = - 1 )
{
return FALSE ;
}
}
return TRUE ;
}
static void get_edit_box_contents ( HWND hdlg , int id , uint64_t * val )
{
HWND h ;
WCHAR szText [ 256 ] ;
char stransi [ 256 ] ;
h = GetDlgItem ( hdlg , id ) ;
SendMessage ( h , WM_GETTEXT , 255 , ( LPARAM ) szText ) ;
2017-07-20 15:22:21 +02:00
wcstombs ( stransi , szText , 256 ) ;
2017-05-18 14:03:43 -04:00
sscanf ( stransi , " % " PRIu64 , val ) ;
}
static void get_combo_box_selection ( HWND hdlg , int id , uint64_t * val )
{
HWND h ;
h = GetDlgItem ( hdlg , id ) ;
* val = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
}
static void set_edit_box_contents ( HWND hdlg , int id , uint64_t val )
{
HWND h ;
WCHAR szText [ 256 ] ;
h = GetDlgItem ( hdlg , id ) ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_2156 ) , val ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , WM_SETTEXT , ( WPARAM ) wcslen ( szText ) , ( LPARAM ) szText ) ;
}
int hard_disk_added = 0 ;
int max_spt = 63 ;
2017-05-27 03:53:32 +02:00
int max_hpc = 255 ;
int max_tracks = 266305 ;
2017-05-18 14:03:43 -04:00
int no_update = 0 ;
int existing = 0 ;
uint64_t selection = 127 ;
uint64_t spt , hpc , tracks , size ;
wchar_t hd_file_name [ 512 ] ;
2017-09-30 16:56:38 -04:00
static hard_disk_t * hdd_ptr ;
2017-05-19 04:35:59 +02:00
2017-05-18 14:03:43 -04:00
static int hdconf_initialize_hdt_combo ( HWND hdlg )
{
HWND h ;
int i = 0 ;
uint64_t temp_size = 0 ;
uint64_t size_mb = 0 ;
WCHAR szText [ 256 ] ;
selection = 127 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
for ( i = 0 ; i < 127 ; i + + )
{
2017-09-30 16:56:38 -04:00
temp_size = hdd_table [ i ] [ 0 ] * hdd_table [ i ] [ 1 ] * hdd_table [ i ] [ 2 ] ;
2017-05-18 14:03:43 -04:00
size_mb = temp_size > > 11 ;
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( IDS_2157 ) , size_mb , hdd_table [ i ] [ 0 ] , hdd_table [ i ] [ 1 ] , hdd_table [ i ] [ 2 ] ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) szText ) ;
2017-09-30 16:56:38 -04:00
if ( ( tracks = = hdd_table [ i ] [ 0 ] ) & & ( hpc = = hdd_table [ i ] [ 1 ] ) & & ( spt = = hdd_table [ i ] [ 2 ] ) )
2017-05-18 14:03:43 -04:00
{
selection = i ;
}
}
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_4100 ) ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_4101 ) ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_SETCURSEL , selection , 0 ) ;
return selection ;
}
static void recalc_selection ( HWND hdlg )
{
HWND h ;
int i = 0 ;
selection = 127 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
for ( i = 0 ; i < 127 ; i + + )
{
2017-09-30 16:56:38 -04:00
if ( ( tracks = = hdd_table [ i ] [ 0 ] ) & & ( hpc = = hdd_table [ i ] [ 1 ] ) & & ( spt = = hdd_table [ i ] [ 2 ] ) )
2017-05-18 14:03:43 -04:00
{
selection = i ;
}
}
if ( ( selection = = 127 ) & & ( hpc = = 16 ) & & ( spt = = 63 ) )
{
selection = 128 ;
}
SendMessage ( h , CB_SETCURSEL , selection , 0 ) ;
}
2017-05-27 03:53:32 +02:00
static int chs_enabled = 0 ;
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_hard_disks_add_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int64_t i = 0 ;
uint64_t temp ;
FILE * f ;
uint32_t sector_size = 512 ;
uint32_t zero = 0 ;
uint32_t base = 0x1000 ;
uint64_t signature = 0xD778A82044445459ll ;
char buf [ 512 ] ;
2017-05-29 01:18:32 +02:00
char * big_buf ;
2017-05-27 04:17:18 +02:00
int b = 0 ;
2017-05-29 01:18:32 +02:00
uint64_t r = 0 ;
2018-01-19 15:39:13 +01:00
uint8_t channel = 0 ;
uint8_t id = 0 , lun = 0 ;
2017-05-18 14:03:43 -04:00
switch ( message )
{
case WM_INITDIALOG :
2017-05-27 03:53:32 +02:00
memset ( hd_file_name , 0 , sizeof ( hd_file_name ) ) ;
2017-05-19 04:35:59 +02:00
if ( existing & 2 )
{
2017-05-27 03:53:32 +02:00
next_free_id = ( existing > > 3 ) & 0x1f ;
2017-09-30 16:56:38 -04:00
hdd_ptr = & ( hdd [ next_free_id ] ) ;
2017-05-27 03:53:32 +02:00
}
else
{
2017-09-30 16:56:38 -04:00
hdd_ptr = & ( temp_hdd [ next_free_id ] ) ;
2017-05-19 04:35:59 +02:00
}
2017-10-10 03:07:29 -04:00
SetWindowText ( hdlg , plat_get_string ( ( existing & 1 ) ? IDS_4103 : IDS_4102 ) ) ;
2017-05-18 14:03:43 -04:00
no_update = 1 ;
2017-05-19 04:35:59 +02:00
spt = ( existing & 1 ) ? 0 : 17 ;
2017-05-18 14:03:43 -04:00
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
2017-05-19 04:35:59 +02:00
hpc = ( existing & 1 ) ? 0 : 15 ;
2017-05-18 14:03:43 -04:00
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
2017-05-19 04:35:59 +02:00
tracks = ( existing & 1 ) ? 0 : 1023 ;
2017-05-18 14:03:43 -04:00
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
hdconf_initialize_hdt_combo ( hdlg ) ;
2017-05-19 04:35:59 +02:00
if ( existing & 1 )
2017-05-18 14:03:43 -04:00
{
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SPT ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_HPC ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_CYL ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SIZE ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
EnableWindow ( h , FALSE ) ;
2017-05-27 03:53:32 +02:00
chs_enabled = 0 ;
}
else
{
chs_enabled = 1 ;
2017-05-18 14:03:43 -04:00
}
add_locations ( hdlg ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-05-27 03:53:32 +02:00
if ( existing & 2 )
{
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = HDD_BUS_SCSI_REMOVABLE ;
2017-05-27 03:53:32 +02:00
max_spt = 99 ;
max_hpc = 255 ;
}
else
{
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = HDD_BUS_IDE_PIO_ONLY ;
2017-05-27 03:53:32 +02:00
max_spt = 63 ;
2017-10-24 04:15:05 +02:00
max_hpc = 255 ;
2017-05-27 03:53:32 +02:00
}
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , hdd_ptr - > bus , 0 ) ;
2017-05-27 03:53:32 +02:00
max_tracks = 266305 ;
2018-01-19 15:39:13 +01:00
recalc_location_controls ( hdlg , 1 , 0 ) ;
2017-05-27 03:53:32 +02:00
if ( existing & 2 )
{
/* We're functioning as a load image dialog for a removable SCSI hard disk,
called from win . c , so let ' s hide the bus selection as we should not
allow it at this point . */
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , 1798 ) ;
ShowWindow ( h , SW_HIDE ) ;
/* Disable and hide the SCSI ID and LUN combo boxes. */
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
/* Set the file name edit box contents to our existing parameters. */
h = GetDlgItem ( hdlg , IDC_EDIT_HD_FILE_NAME ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , WM_SETTEXT , 0 , ( LPARAM ) hdd [ next_free_id ] . fn ) ;
2017-05-27 03:53:32 +02:00
}
else
{
2018-01-19 15:39:13 +01:00
channel = next_free_ide_channel ( ) ;
next_free_scsi_id_and_lun ( & id , & lun ) ;
2017-05-27 03:53:32 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
SendMessage ( h , CB_SETCURSEL , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
2018-01-27 02:38:52 +01:00
SendMessage ( h , CB_SETCURSEL , id , 0 ) ;
2017-05-27 03:53:32 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
2018-01-27 02:38:52 +01:00
SendMessage ( h , CB_SETCURSEL , lun , 0 ) ;
2017-05-27 03:53:32 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
2018-01-27 02:38:52 +01:00
SendMessage ( h , CB_SETCURSEL , channel , 0 ) ;
2018-01-19 15:39:13 +01:00
new_hdd . mfm_channel = next_free_binary_channel ( & mfm_tracking ) ;
new_hdd . esdi_channel = next_free_binary_channel ( & esdi_tracking ) ;
new_hdd . xtide_channel = next_free_binary_channel ( & xtide_tracking ) ;
new_hdd . ide_channel = channel ;
new_hdd . scsi_id = id ;
new_hdd . scsi_lun = lun ;
2017-05-27 03:53:32 +02:00
}
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_EDIT_HD_FILE_NAME ) ;
EnableWindow ( h , FALSE ) ;
2018-01-24 20:58:39 +01:00
h = GetDlgItem ( hdlg , IDT_1752 ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_PBAR_IMG_CREATE ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
2017-05-18 14:03:43 -04:00
no_update = 0 ;
return TRUE ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDOK :
2017-05-27 03:53:32 +02:00
if ( ! ( existing & 2 ) )
{
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) + 1 ;
2017-05-27 03:53:32 +02:00
}
/* Make sure no file name is allowed with removable SCSI hard disks. */
2017-09-30 16:56:38 -04:00
if ( ( wcslen ( hd_file_name ) = = 0 ) & & ( hdd_ptr - > bus ! = HDD_BUS_SCSI_REMOVABLE ) )
2017-05-18 14:03:43 -04:00
{
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = HDD_BUS_DISABLED ;
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_ERROR , ( wchar_t * ) IDS_4112 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
2017-09-30 16:56:38 -04:00
else if ( ( wcslen ( hd_file_name ) = = 0 ) & & ( hdd_ptr - > bus = = HDD_BUS_SCSI_REMOVABLE ) )
2017-05-27 03:53:32 +02:00
{
/* Mark hard disk added but return empty - it will signify the disk was ejected. */
2017-09-30 16:56:38 -04:00
hdd_ptr - > spt = hdd_ptr - > hpc = hdd_ptr - > tracks = 0 ;
memset ( hdd_ptr - > fn , 0 , sizeof ( hdd_ptr - > fn ) ) ;
2017-05-27 03:53:32 +02:00
goto hd_add_ok_common ;
}
2017-09-30 16:56:38 -04:00
get_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , & ( hdd_ptr - > spt ) ) ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , & ( hdd_ptr - > hpc ) ) ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , & ( hdd_ptr - > tracks ) ) ;
spt = hdd_ptr - > spt ;
hpc = hdd_ptr - > hpc ;
tracks = hdd_ptr - > tracks ;
2017-05-18 14:03:43 -04:00
2017-05-19 04:35:59 +02:00
if ( existing & 2 )
{
2017-09-30 16:56:38 -04:00
if ( hdd_ptr - > bus = = HDD_BUS_SCSI_REMOVABLE )
2017-05-19 04:35:59 +02:00
{
2017-09-30 16:56:38 -04:00
memset ( hdd_ptr - > prev_fn , 0 , sizeof ( hdd_ptr - > prev_fn ) ) ;
wcscpy ( hdd_ptr - > prev_fn , hdd_ptr - > fn ) ;
2017-05-19 04:35:59 +02:00
}
}
else
{
2017-09-30 16:56:38 -04:00
switch ( hdd_ptr - > bus )
2017-05-27 03:53:32 +02:00
{
case HDD_BUS_MFM :
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > mfm_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
2017-08-25 02:21:26 -04:00
case HDD_BUS_ESDI :
2017-05-27 03:53:32 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > esdi_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_XTIDE :
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > xtide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_IDE_PIO_ONLY :
case HDD_BUS_IDE_PIO_AND_DMA :
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > ide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
case HDD_BUS_SCSI :
case HDD_BUS_SCSI_REMOVABLE :
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > scsi_id = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
2017-09-30 16:56:38 -04:00
hdd_ptr - > scsi_lun = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
break ;
}
2017-05-19 04:35:59 +02:00
}
2017-05-18 14:03:43 -04:00
2017-09-30 16:56:38 -04:00
memset ( hdd_ptr - > fn , 0 , sizeof ( hdd_ptr - > fn ) ) ;
wcscpy ( hdd_ptr - > fn , hd_file_name ) ;
2017-05-27 03:53:32 +02:00
2017-05-18 14:03:43 -04:00
sector_size = 512 ;
2017-05-19 04:35:59 +02:00
if ( ! ( existing & 1 ) & & ( wcslen ( hd_file_name ) > 0 ) )
2017-05-18 14:03:43 -04:00
{
f = _wfopen ( hd_file_name , L " wb " ) ;
if ( image_is_hdi ( hd_file_name ) )
{
if ( size > = 0x100000000ll )
{
fclose ( f ) ;
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_ERROR , ( wchar_t * ) IDS_4104 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
fwrite ( & zero , 1 , 4 , f ) ; /* 00000000: Zero/unknown */
fwrite ( & zero , 1 , 4 , f ) ; /* 00000004: Zero/unknown */
fwrite ( & base , 1 , 4 , f ) ; /* 00000008: Offset at which data starts */
fwrite ( & size , 1 , 4 , f ) ; /* 0000000C: Full size of the data (32-bit) */
fwrite ( & sector_size , 1 , 4 , f ) ; /* 00000010: Sector size in bytes */
fwrite ( & spt , 1 , 4 , f ) ; /* 00000014: Sectors per cylinder */
fwrite ( & hpc , 1 , 4 , f ) ; /* 00000018: Heads per cylinder */
fwrite ( & tracks , 1 , 4 , f ) ; /* 0000001C: Cylinders */
for ( i = 0 ; i < 0x3f8 ; i + + )
{
fwrite ( & zero , 1 , 4 , f ) ;
}
}
else if ( image_is_hdx ( hd_file_name , 0 ) )
{
if ( size > 0xffffffffffffffffll )
{
fclose ( f ) ;
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_ERROR , ( wchar_t * ) IDS_4105 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
fwrite ( & signature , 1 , 8 , f ) ; /* 00000000: Signature */
fwrite ( & size , 1 , 8 , f ) ; /* 00000008: Full size of the data (64-bit) */
fwrite ( & sector_size , 1 , 4 , f ) ; /* 00000010: Sector size in bytes */
fwrite ( & spt , 1 , 4 , f ) ; /* 00000014: Sectors per cylinder */
fwrite ( & hpc , 1 , 4 , f ) ; /* 00000018: Heads per cylinder */
fwrite ( & tracks , 1 , 4 , f ) ; /* 0000001C: Cylinders */
fwrite ( & zero , 1 , 4 , f ) ; /* 00000020: [Translation] Sectors per cylinder */
fwrite ( & zero , 1 , 4 , f ) ; /* 00000004: [Translation] Heads per cylinder */
}
memset ( buf , 0 , 512 ) ;
size > > = 9 ;
2017-05-29 01:18:32 +02:00
r = ( size > > 11 ) < < 11 ;
size - = r ;
r > > = 11 ;
2018-01-24 20:58:39 +01:00
if ( size | | r ) {
h = GetDlgItem ( hdlg , IDT_1731 ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_FILE_NAME ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_CFILE ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_PBAR_IMG_CREATE ) ;
SendMessage ( h , PBM_SETRANGE32 , ( WPARAM ) 0 , ( LPARAM ) ( size + r - 1 ) ) ;
SendMessage ( h , PBM_SETPOS , ( WPARAM ) 0 , ( LPARAM ) 0 ) ;
EnableWindow ( h , TRUE ) ;
ShowWindow ( h , SW_SHOW ) ;
h = GetDlgItem ( hdlg , IDT_1752 ) ;
EnableWindow ( h , TRUE ) ;
ShowWindow ( h , SW_SHOW ) ;
}
2017-05-29 01:18:32 +02:00
if ( size )
2017-05-18 14:03:43 -04:00
{
2017-05-29 01:18:32 +02:00
for ( i = 0 ; i < size ; i + + )
{
fwrite ( buf , 1 , 512 , f ) ;
2018-01-24 20:58:39 +01:00
SendMessage ( h , PBM_SETPOS , ( WPARAM ) i , ( LPARAM ) 0 ) ;
2017-05-29 01:18:32 +02:00
}
}
if ( r )
{
big_buf = ( char * ) malloc ( 1048576 ) ;
memset ( big_buf , 0 , 1048576 ) ;
for ( i = 0 ; i < r ; i + + )
{
fwrite ( big_buf , 1 , 1048576 , f ) ;
2018-01-24 20:58:39 +01:00
SendMessage ( h , PBM_SETPOS , ( WPARAM ) ( size + i ) , ( LPARAM ) 0 ) ;
2017-05-29 01:18:32 +02:00
}
free ( big_buf ) ;
2017-05-18 14:03:43 -04:00
}
fclose ( f ) ;
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_INFO , ( wchar_t * ) IDS_4113 ) ;
2017-05-18 14:03:43 -04:00
}
2017-05-27 03:53:32 +02:00
hd_add_ok_common :
2017-05-18 14:03:43 -04:00
hard_disk_added = 1 ;
EndDialog ( hdlg , 0 ) ;
return TRUE ;
case IDCANCEL :
hard_disk_added = 0 ;
2017-05-27 03:53:32 +02:00
if ( ! ( existing & 2 ) )
{
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = HDD_BUS_DISABLED ;
2017-05-27 03:53:32 +02:00
}
2017-05-18 14:03:43 -04:00
EndDialog ( hdlg , 0 ) ;
return TRUE ;
case IDC_CFILE :
2017-10-10 03:07:29 -04:00
if ( ! file_dlg_w ( hdlg , plat_get_string ( IDS_4106 ) , L " " , ! ( existing & 1 ) ) )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
if ( ! ( existing & 1 ) )
2017-05-18 14:03:43 -04:00
{
f = _wfopen ( wopenfilestring , L " rb " ) ;
if ( f ! = NULL )
{
fclose ( f ) ;
2017-10-10 03:07:29 -04:00
if ( settings_msgbox ( MBX_QUESTION , ( wchar_t * ) IDS_4111 ) ! = 0 ) /* yes */
2017-05-18 14:03:43 -04:00
{
return FALSE ;
}
}
}
2017-05-19 04:35:59 +02:00
f = _wfopen ( wopenfilestring , ( existing & 1 ) ? L " rb " : L " wb " ) ;
2017-05-18 14:03:43 -04:00
if ( f = = NULL )
{
2017-05-27 03:53:32 +02:00
hdd_add_file_open_error :
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_ERROR , ( existing & 1 ) ? ( wchar_t * ) IDS_4107 : ( wchar_t * ) IDS_4108 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
2017-05-19 04:35:59 +02:00
if ( existing & 1 )
2017-05-18 14:03:43 -04:00
{
if ( image_is_hdi ( wopenfilestring ) | | image_is_hdx ( wopenfilestring , 1 ) )
{
fseeko64 ( f , 0x10 , SEEK_SET ) ;
fread ( & sector_size , 1 , 4 , f ) ;
if ( sector_size ! = 512 )
{
2017-10-10 03:07:29 -04:00
settings_msgbox ( MBX_ERROR , ( wchar_t * ) IDS_4109 ) ;
2017-05-18 14:03:43 -04:00
fclose ( f ) ;
return TRUE ;
}
spt = hpc = tracks = 0 ;
fread ( & spt , 1 , 4 , f ) ;
fread ( & hpc , 1 , 4 , f ) ;
fread ( & tracks , 1 , 4 , f ) ;
}
else
{
fseeko64 ( f , 0 , SEEK_END ) ;
size = ftello64 ( f ) ;
fclose ( f ) ;
2017-07-15 12:46:44 +02:00
if ( ( ( size % 17 ) = = 0 ) & & ( size < = 142606336 ) )
2017-05-18 14:03:43 -04:00
{
spt = 17 ;
if ( size < = 26738688 )
{
hpc = 4 ;
}
2017-07-15 12:46:44 +02:00
else if ( ( ( size % 3072 ) = = 0 ) & & ( size < = 53477376 ) )
2017-05-18 14:03:43 -04:00
{
hpc = 6 ;
}
else
{
2017-07-26 15:02:03 +02:00
for ( i = 5 ; i < 16 ; i + + )
2017-07-15 12:46:44 +02:00
{
if ( ( ( size % ( i < < 9 ) ) = = 0 ) & & ( size < = ( ( i * 17 ) < < 19 ) ) )
{
break ;
}
if ( i = = 5 )
{
i + + ;
}
}
hpc = i ;
2017-05-18 14:03:43 -04:00
}
}
else
{
spt = 63 ;
hpc = 16 ;
}
tracks = ( ( size > > 9 ) / hpc ) / spt ;
}
2017-05-27 03:53:32 +02:00
if ( ( spt > max_spt ) | | ( hpc > max_hpc ) | | ( tracks > max_tracks ) )
{
goto hdd_add_file_open_error ;
}
2017-05-18 14:03:43 -04:00
no_update = 1 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
recalc_selection ( hdlg ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SPT ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_HPC ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_CYL ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SIZE ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
EnableWindow ( h , TRUE ) ;
2017-05-27 03:53:32 +02:00
chs_enabled = 1 ;
2017-05-18 14:03:43 -04:00
no_update = 0 ;
2017-07-15 12:46:44 +02:00
}
2017-05-18 14:03:43 -04:00
else
{
fclose ( f ) ;
}
}
h = GetDlgItem ( hdlg , IDC_EDIT_HD_FILE_NAME ) ;
SendMessage ( h , WM_SETTEXT , 0 , ( LPARAM ) wopenfilestring ) ;
2017-05-27 03:53:32 +02:00
memset ( hd_file_name , 0 , sizeof ( hd_file_name ) ) ;
wcscpy ( hd_file_name , wopenfilestring ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
case IDC_EDIT_HD_CYL :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , & temp ) ;
if ( temp ! = tracks )
{
tracks = temp ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
recalc_selection ( hdlg ) ;
}
2017-05-27 03:53:32 +02:00
if ( tracks > max_tracks )
{
tracks = max_tracks ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
case IDC_EDIT_HD_HPC :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , & temp ) ;
if ( temp ! = hpc )
{
hpc = temp ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
recalc_selection ( hdlg ) ;
}
2017-05-27 03:53:32 +02:00
if ( hpc > max_hpc )
{
hpc = max_hpc ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
case IDC_EDIT_HD_SPT :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , & temp ) ;
if ( temp ! = spt )
{
spt = temp ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
recalc_selection ( hdlg ) ;
}
2017-05-27 03:53:32 +02:00
if ( spt > max_spt )
{
spt = max_spt ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
case IDC_EDIT_HD_SIZE :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
get_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , & temp ) ;
if ( temp ! = ( size > > 20 ) )
{
size = temp < < 20 ;
tracks = ( ( size > > 9 ) / hpc ) / spt ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
recalc_selection ( hdlg ) ;
}
2017-05-27 03:53:32 +02:00
if ( tracks > max_tracks )
{
tracks = max_tracks ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
case IDC_COMBO_HD_TYPE :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
get_combo_box_selection ( hdlg , IDC_COMBO_HD_TYPE , & temp ) ;
if ( ( temp ! = selection ) & & ( temp ! = 127 ) & & ( temp ! = 128 ) )
{
selection = temp ;
2017-09-30 16:56:38 -04:00
tracks = hdd_table [ selection ] [ 0 ] ;
hpc = hdd_table [ selection ] [ 1 ] ;
spt = hdd_table [ selection ] [ 2 ] ;
2017-05-18 14:03:43 -04:00
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
}
else if ( ( temp ! = selection ) & & ( temp = = 127 ) )
{
selection = temp ;
}
else if ( ( temp ! = selection ) & & ( temp = = 128 ) )
{
selection = temp ;
hpc = 16 ;
spt = 63 ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , size > > 20 ) ;
}
2017-05-27 03:53:32 +02:00
if ( spt > max_spt )
{
spt = max_spt ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
if ( hpc > max_hpc )
{
hpc = max_hpc ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
if ( tracks > max_tracks )
{
tracks = max_tracks ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
case IDC_COMBO_HD_BUS :
if ( no_update )
{
return FALSE ;
}
no_update = 1 ;
2018-01-19 15:39:13 +01:00
recalc_location_controls ( hdlg , 1 , 0 ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-05-27 04:17:18 +02:00
b = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) + 1 ;
2017-09-30 16:56:38 -04:00
if ( b = = hdd_ptr - > bus )
2017-05-27 04:17:18 +02:00
{
goto hd_add_bus_skip ;
}
2017-09-30 16:56:38 -04:00
hdd_ptr - > bus = b ;
2017-05-27 03:53:32 +02:00
2017-09-30 16:56:38 -04:00
switch ( hdd_ptr - > bus )
2017-05-27 03:53:32 +02:00
{
case HDD_BUS_DISABLED :
default :
max_spt = max_hpc = max_tracks = 0 ;
break ;
case HDD_BUS_MFM :
max_spt = 17 ;
max_hpc = 15 ;
max_tracks = 1023 ;
break ;
2017-08-25 02:21:26 -04:00
case HDD_BUS_ESDI :
2017-05-27 03:53:32 +02:00
case HDD_BUS_XTIDE :
max_spt = 63 ;
max_hpc = 16 ;
max_tracks = 1023 ;
break ;
case HDD_BUS_IDE_PIO_ONLY :
case HDD_BUS_IDE_PIO_AND_DMA :
max_spt = 63 ;
2017-10-24 04:15:05 +02:00
max_hpc = 255 ;
2017-05-27 03:53:32 +02:00
max_tracks = 266305 ;
break ;
case HDD_BUS_SCSI_REMOVABLE :
if ( spt = = 0 )
{
spt = 63 ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
}
if ( hpc = = 0 )
{
hpc = 16 ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
}
if ( tracks = = 0 )
{
tracks = 1023 ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
}
case HDD_BUS_SCSI :
max_spt = 99 ;
max_hpc = 255 ;
max_tracks = 266305 ;
break ;
}
2017-09-30 16:56:38 -04:00
if ( ( hdd_ptr - > bus = = HDD_BUS_SCSI_REMOVABLE ) & & ! chs_enabled )
2017-05-27 03:53:32 +02:00
{
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SPT ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_HPC ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_CYL ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SIZE ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
EnableWindow ( h , TRUE ) ;
}
2017-09-30 16:56:38 -04:00
else if ( ( hdd_ptr - > bus ! = HDD_BUS_SCSI_REMOVABLE ) & & ! chs_enabled )
2017-05-27 03:53:32 +02:00
{
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SPT ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_HPC ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_CYL ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_EDIT_HD_SIZE ) ;
EnableWindow ( h , FALSE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_TYPE ) ;
EnableWindow ( h , FALSE ) ;
}
2017-05-18 14:03:43 -04:00
if ( spt > max_spt )
{
spt = max_spt ;
size = ( tracks * hpc * spt ) < < 9 ;
2017-05-27 03:53:32 +02:00
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SPT , spt ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
if ( hpc > max_hpc )
{
hpc = max_hpc ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_HPC , hpc ) ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
if ( tracks > max_tracks )
{
tracks = max_tracks ;
size = ( tracks * hpc * spt ) < < 9 ;
set_edit_box_contents ( hdlg , IDC_EDIT_HD_CYL , tracks ) ;
2017-05-18 14:03:43 -04:00
set_edit_box_contents ( hdlg , IDC_EDIT_HD_SIZE , ( size > > 20 ) ) ;
recalc_selection ( hdlg ) ;
}
2017-05-27 03:53:32 +02:00
2017-05-27 04:17:18 +02:00
hd_add_bus_skip :
2017-05-18 14:03:43 -04:00
no_update = 0 ;
break ;
}
return FALSE ;
}
return FALSE ;
}
2017-05-27 03:53:32 +02:00
int hard_disk_was_added ( void )
{
return hard_disk_added ;
}
2017-05-18 14:03:43 -04:00
void hard_disk_add_open ( HWND hwnd , int is_existing )
{
2017-05-19 04:35:59 +02:00
existing = is_existing ;
2017-05-18 14:03:43 -04:00
hard_disk_added = 0 ;
2017-06-16 06:44:11 +02:00
DialogBox ( hinstance , ( LPCWSTR ) DLG_CFG_HARD_DISKS_ADD , hwnd , win_settings_hard_disks_add_proc ) ;
2017-05-18 14:03:43 -04:00
}
2018-01-19 15:39:13 +01:00
static void hard_disk_track ( uint8_t id )
{
switch ( temp_hdd [ id ] . bus ) {
case HDD_BUS_MFM :
2018-01-27 02:38:52 +01:00
mfm_tracking | = ( 1 < < ( temp_hdd [ id ] . mfm_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_ESDI :
2018-01-27 02:38:52 +01:00
esdi_tracking | = ( 1 < < ( temp_hdd [ id ] . esdi_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_XTIDE :
2018-01-27 02:38:52 +01:00
xtide_tracking | = ( 1 < < ( temp_hdd [ id ] . xtide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_IDE_PIO_ONLY :
case HDD_BUS_IDE_PIO_AND_DMA :
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 1 < < ( temp_hdd [ id ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_SCSI :
case HDD_BUS_SCSI_REMOVABLE :
2018-01-27 02:38:52 +01:00
scsi_tracking [ temp_hdd [ id ] . scsi_id ] | = ( 1 < < ( temp_hdd [ id ] . scsi_lun < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
}
}
static void hard_disk_untrack ( uint8_t id )
{
switch ( temp_hdd [ id ] . bus ) {
case HDD_BUS_MFM :
2018-01-27 02:38:52 +01:00
mfm_tracking & = ~ ( 1 < < ( temp_hdd [ id ] . mfm_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_ESDI :
2018-01-27 02:38:52 +01:00
esdi_tracking & = ~ ( 1 < < ( temp_hdd [ id ] . esdi_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_XTIDE :
2018-01-27 02:38:52 +01:00
xtide_tracking & = ~ ( 1 < < ( temp_hdd [ id ] . xtide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_IDE_PIO_ONLY :
case HDD_BUS_IDE_PIO_AND_DMA :
2018-01-27 02:38:52 +01:00
ide_tracking & = ~ ( 1 < < ( temp_hdd [ id ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
case HDD_BUS_SCSI :
case HDD_BUS_SCSI_REMOVABLE :
2018-01-27 02:38:52 +01:00
scsi_tracking [ temp_hdd [ id ] . scsi_id ] & = ~ ( 1 < < ( temp_hdd [ id ] . scsi_lun < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
break ;
}
}
2018-01-27 02:38:52 +01:00
static void hard_disk_track_all ( void )
{
int i ;
for ( i = 0 ; i < HDD_NUM ; i + + )
hard_disk_track ( i ) ;
}
int ignore_change = 0 ;
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_hard_disks_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int old_sel = 0 ;
2018-01-27 02:38:52 +01:00
int b = 0 ;
2018-01-24 18:38:43 +01:00
int assign = 0 ;
2017-05-18 14:03:43 -04:00
switch ( message )
{
case WM_INITDIALOG :
ignore_change = 1 ;
normalize_hd_list ( ) ; /* Normalize the hard disks so that non-disabled hard disks start from index 0, and so they are contiguous.
This will cause an emulator reset prompt on the first opening of this category with a messy hard disk list
( which can only happen by manually editing the configuration file ) . */
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_init_columns ( h ) ;
win_settings_hard_disks_image_list_init ( h ) ;
win_settings_hard_disks_recalc_list ( h ) ;
recalc_next_free_id ( hdlg ) ;
add_locations ( hdlg ) ;
if ( hd_listview_items > 0 )
{
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
hdlv_current_sel = 0 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , temp_hdd [ 0 ] . bus - 1 , 0 ) ;
2017-05-18 14:03:43 -04:00
}
else
{
hdlv_current_sel = - 1 ;
}
2018-01-19 15:39:13 +01:00
recalc_location_controls ( hdlg , 0 , 0 ) ;
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
return TRUE ;
case WM_NOTIFY :
if ( ( hd_listview_items = = 0 ) | | ignore_change )
{
return FALSE ;
}
if ( ( ( ( LPNMHDR ) lParam ) - > code = = LVN_ITEMCHANGED ) & & ( ( ( LPNMHDR ) lParam ) - > idFrom = = IDC_LIST_HARD_DISKS ) )
{
old_sel = hdlv_current_sel ;
hdlv_current_sel = get_selected_hard_disk ( hdlg ) ;
if ( hdlv_current_sel = = old_sel )
{
return FALSE ;
}
else if ( hdlv_current_sel = = - 1 )
{
ignore_change = 1 ;
hdlv_current_sel = old_sel ;
ListView_SetItemState ( h , hdlv_current_sel , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
ignore_change = 0 ;
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , temp_hdd [ hdlv_current_sel ] . bus - 1 , 0 ) ;
2018-01-19 15:39:13 +01:00
recalc_location_controls ( hdlg , 0 , 0 ) ;
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
}
break ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDC_COMBO_HD_BUS :
if ( ignore_change )
{
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-05-27 04:17:18 +02:00
b = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) + 1 ;
2017-09-30 16:56:38 -04:00
if ( b = = temp_hdd [ hdlv_current_sel ] . bus )
2017-05-27 04:17:18 +02:00
{
goto hd_bus_skip ;
}
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2018-01-24 18:38:43 +01:00
assign = ( temp_hdd [ hdlv_current_sel ] . bus = = b ) ? 0 : 1 ;
if ( ( b = = HDD_BUS_IDE_PIO_ONLY ) & & ( temp_hdd [ hdlv_current_sel ] . bus = = HDD_BUS_IDE_PIO_AND_DMA ) )
assign = 0 ;
else if ( ( b = = HDD_BUS_IDE_PIO_AND_DMA ) & & ( temp_hdd [ hdlv_current_sel ] . bus = = HDD_BUS_IDE_PIO_ONLY ) )
assign = 0 ;
temp_hdd [ hdlv_current_sel ] . bus = b ;
recalc_location_controls ( hdlg , 0 , assign ) ;
hard_disk_track ( hdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_update_item ( h , hdlv_current_sel , 0 ) ;
2017-05-27 04:17:18 +02:00
hd_bus_skip :
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_HD_CHANNEL :
if ( ignore_change )
{
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL ) ;
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2017-09-30 16:56:38 -04:00
if ( temp_hdd [ hdlv_current_sel ] . bus = = HDD_BUS_MFM )
2017-05-27 03:53:32 +02:00
{
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . mfm_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ hdlv_current_sel ] . bus = = HDD_BUS_ESDI )
2017-05-27 03:53:32 +02:00
{
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . esdi_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
}
2017-09-30 16:56:38 -04:00
else if ( temp_hdd [ hdlv_current_sel ] . bus = = HDD_BUS_XTIDE )
2017-05-27 03:53:32 +02:00
{
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . xtide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2017-05-27 03:53:32 +02:00
}
2018-01-19 15:39:13 +01:00
hard_disk_track ( hdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_update_item ( h , hdlv_current_sel , 0 ) ;
ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_HD_CHANNEL_IDE :
if ( ignore_change )
{
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_CHANNEL_IDE ) ;
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . ide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-19 15:39:13 +01:00
hard_disk_track ( hdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_update_item ( h , hdlv_current_sel , 0 ) ;
ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_HD_ID :
if ( ignore_change )
{
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_ID ) ;
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . scsi_id = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-19 15:39:13 +01:00
hard_disk_track ( hdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_update_item ( h , hdlv_current_sel , 0 ) ;
ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_HD_LUN :
if ( ignore_change )
{
return FALSE ;
}
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_LUN ) ;
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . scsi_lun = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-19 15:39:13 +01:00
hard_disk_track ( hdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_update_item ( h , hdlv_current_sel , 0 ) ;
ignore_change = 0 ;
return FALSE ;
case IDC_BUTTON_HDD_ADD :
hard_disk_add_open ( hdlg , 1 ) ;
if ( hard_disk_added )
{
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_recalc_list ( h ) ;
recalc_next_free_id ( hdlg ) ;
2018-01-27 02:38:52 +01:00
hard_disk_track_all ( ) ;
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
}
return FALSE ;
case IDC_BUTTON_HDD_ADD_NEW :
hard_disk_add_open ( hdlg , 0 ) ;
if ( hard_disk_added )
{
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_recalc_list ( h ) ;
recalc_next_free_id ( hdlg ) ;
2018-01-27 02:38:52 +01:00
hard_disk_track_all ( ) ;
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
}
return FALSE ;
case IDC_BUTTON_HDD_REMOVE :
2017-09-30 16:56:38 -04:00
memcpy ( temp_hdd [ hdlv_current_sel ] . fn , L " " , 4 ) ;
2018-01-19 15:39:13 +01:00
hard_disk_untrack ( hdlv_current_sel ) ;
2017-09-30 16:56:38 -04:00
temp_hdd [ hdlv_current_sel ] . bus = HDD_BUS_DISABLED ; /* Only set the bus to zero, the list normalize code below will take care of turning this entire entry to a complete zero. */
2017-05-18 14:03:43 -04:00
normalize_hd_list ( ) ; /* Normalize the hard disks so that non-disabled hard disks start from index 0, and so they are contiguous. */
ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_LIST_HARD_DISKS ) ;
win_settings_hard_disks_recalc_list ( h ) ;
recalc_next_free_id ( hdlg ) ;
if ( hd_listview_items > 0 )
{
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
hdlv_current_sel = 0 ;
h = GetDlgItem ( hdlg , IDC_COMBO_HD_BUS ) ;
2017-09-30 16:56:38 -04:00
SendMessage ( h , CB_SETCURSEL , temp_hdd [ 0 ] . bus - 1 , 0 ) ;
2017-05-18 14:03:43 -04:00
}
else
{
hdlv_current_sel = - 1 ;
}
2018-01-24 18:38:43 +01:00
recalc_location_controls ( hdlg , 0 , 0 ) ;
2017-05-18 14:03:43 -04:00
ignore_change = 0 ;
return FALSE ;
}
default :
return FALSE ;
}
return FALSE ;
}
2018-01-26 22:17:09 +01:00
static int fdlv_current_sel ;
static int cdlv_current_sel ;
static int zdlv_current_sel ;
2017-05-18 14:03:43 -04:00
static int combo_id_to_string_id ( int combo_id )
{
2017-07-24 12:04:39 +02:00
return IDS_5376 + combo_id ;
2017-05-18 14:03:43 -04:00
}
static int combo_id_to_format_string_id ( int combo_id )
{
2017-07-24 12:04:39 +02:00
return IDS_5632 + combo_id ;
2017-05-18 14:03:43 -04:00
}
static BOOL win_settings_floppy_drives_image_list_init ( HWND hwndList )
{
HICON hiconItem ;
HIMAGELIST hSmall ;
int i = 0 ;
hSmall = ImageList_Create ( GetSystemMetrics ( SM_CXSMICON ) ,
GetSystemMetrics ( SM_CYSMICON ) ,
ILC_MASK | ILC_COLOR32 , 1 , 1 ) ;
for ( i = 0 ; i < 14 ; i + + )
{
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) fdd_type_to_icon ( i ) ) ;
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
}
ListView_SetImageList ( hwndList , hSmall , LVSIL_SMALL ) ;
return TRUE ;
}
static BOOL win_settings_cdrom_drives_image_list_init ( HWND hwndList )
{
HICON hiconItem ;
HIMAGELIST hSmall ;
hSmall = ImageList_Create ( GetSystemMetrics ( SM_CXSMICON ) ,
GetSystemMetrics ( SM_CYSMICON ) ,
ILC_MASK | ILC_COLOR32 , 1 , 1 ) ;
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 514 ) ;
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 160 ) ;
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
ListView_SetImageList ( hwndList , hSmall , LVSIL_SMALL ) ;
return TRUE ;
}
2018-01-26 22:17:09 +01:00
static BOOL win_settings_zip_drives_image_list_init ( HWND hwndList )
{
HICON hiconItem ;
HIMAGELIST hSmall ;
hSmall = ImageList_Create ( GetSystemMetrics ( SM_CXSMICON ) ,
GetSystemMetrics ( SM_CYSMICON ) ,
ILC_MASK | ILC_COLOR32 , 1 , 1 ) ;
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 515 ) ;
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) 176 ) ;
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
ListView_SetImageList ( hwndList , hSmall , LVSIL_SMALL ) ;
return TRUE ;
}
2017-05-18 14:03:43 -04:00
static BOOL win_settings_floppy_drives_recalc_list ( HWND hwndList )
{
LVITEM lvI ;
int i = 0 ;
char s [ 256 ] ;
WCHAR szText [ 256 ] ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
2017-06-04 02:34:44 +02:00
lvI . stateMask = lvI . state = 0 ;
2017-05-18 14:03:43 -04:00
for ( i = 0 ; i < 4 ; i + + )
{
2017-06-04 02:34:44 +02:00
lvI . iSubItem = 0 ;
2017-05-18 14:03:43 -04:00
if ( temp_fdd_types [ i ] > 0 )
{
strcpy ( s , fdd_getname ( temp_fdd_types [ i ] ) ) ;
mbstowcs ( szText , s , strlen ( s ) + 1 ) ;
lvI . pszText = szText ;
}
else
{
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( IDS_5376 ) ;
2017-05-18 14:03:43 -04:00
}
lvI . iItem = i ;
lvI . iImage = temp_fdd_types [ i ] ;
if ( ListView_InsertItem ( hwndList , & lvI ) = = - 1 )
return FALSE ;
2017-06-04 02:14:27 +02:00
lvI . iSubItem = 1 ;
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( temp_fdd_turbo [ i ] ? IDS_2060 : IDS_2061 ) ;
2017-06-04 02:14:27 +02:00
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
2017-07-27 17:14:52 +02:00
lvI . iSubItem = 2 ;
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( temp_fdd_check_bpb [ i ] ? IDS_2060 : IDS_2061 ) ;
2017-07-27 17:14:52 +02:00
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
2017-05-18 14:03:43 -04:00
}
return TRUE ;
}
static BOOL win_settings_cdrom_drives_recalc_list ( HWND hwndList )
{
LVITEM lvI ;
int i = 0 ;
WCHAR szText [ 256 ] ;
int fsid = 0 ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
for ( i = 0 ; i < 4 ; i + + )
{
fsid = combo_id_to_format_string_id ( temp_cdrom_drives [ i ] . bus_type ) ;
switch ( temp_cdrom_drives [ i ] . bus_type )
{
2017-05-27 03:53:32 +02:00
case CDROM_BUS_DISABLED :
2017-05-18 14:03:43 -04:00
default :
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( fsid ) ;
2017-05-27 03:53:32 +02:00
lvI . iImage = 0 ;
break ;
case CDROM_BUS_ATAPI_PIO_ONLY :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . ide_channel > > 1 , temp_cdrom_drives [ i ] . ide_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
lvI . pszText = szText ;
lvI . iImage = 1 ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case CDROM_BUS_ATAPI_PIO_AND_DMA :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . ide_channel > > 1 , temp_cdrom_drives [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
2017-08-22 02:16:15 +02:00
lvI . iImage = 1 ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case CDROM_BUS_SCSI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . scsi_device_id , temp_cdrom_drives [ i ] . scsi_device_lun ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
2017-08-22 02:16:15 +02:00
lvI . iImage = 1 ;
2017-05-18 14:03:43 -04:00
break ;
}
lvI . iItem = i ;
if ( ListView_InsertItem ( hwndList , & lvI ) = = - 1 )
return FALSE ;
}
return TRUE ;
}
2018-01-26 22:17:09 +01:00
static BOOL win_settings_zip_drives_recalc_list ( HWND hwndList )
{
LVITEM lvI ;
int i = 0 ;
WCHAR szText [ 256 ] ;
int fsid = 0 ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
for ( i = 0 ; i < 4 ; i + + )
{
fsid = combo_id_to_format_string_id ( temp_zip_drives [ i ] . bus_type ) ;
lvI . iSubItem = 0 ;
switch ( temp_zip_drives [ i ] . bus_type )
{
case ZIP_BUS_DISABLED :
default :
lvI . pszText = plat_get_string ( fsid ) ;
lvI . iImage = 0 ;
break ;
case ZIP_BUS_ATAPI_PIO_ONLY :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . ide_channel > > 1 , temp_zip_drives [ i ] . ide_channel & 1 ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
case ZIP_BUS_ATAPI_PIO_AND_DMA :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . ide_channel > > 1 , temp_zip_drives [ i ] . ide_channel & 1 ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
case ZIP_BUS_SCSI :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . scsi_device_id , temp_zip_drives [ i ] . scsi_device_lun ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
}
lvI . iItem = i ;
if ( ListView_InsertItem ( hwndList , & lvI ) = = - 1 )
return FALSE ;
lvI . iSubItem = 1 ;
lvI . pszText = plat_get_string ( temp_zip_drives [ i ] . is_250 ? IDS_5901 : IDS_5900 ) ;
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return FALSE ;
}
}
return TRUE ;
}
2017-05-18 14:03:43 -04:00
static BOOL win_settings_floppy_drives_init_columns ( HWND hwndList )
{
LVCOLUMN lvc ;
lvc . mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
lvc . iSubItem = 0 ;
2017-10-10 03:07:29 -04:00
lvc . pszText = plat_get_string ( IDS_2143 ) ;
2017-05-18 14:03:43 -04:00
2017-06-04 02:14:27 +02:00
lvc . cx = 292 ;
2017-05-18 14:03:43 -04:00
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 0 , & lvc ) = = - 1 )
{
return FALSE ;
}
2017-06-04 02:14:27 +02:00
lvc . iSubItem = 1 ;
2017-10-10 03:07:29 -04:00
lvc . pszText = plat_get_string ( IDS_2059 ) ;
2017-06-04 02:14:27 +02:00
2017-07-27 17:14:52 +02:00
lvc . cx = 50 ;
2017-06-04 02:14:27 +02:00
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 1 , & lvc ) = = - 1 )
{
return FALSE ;
}
2017-07-27 17:14:52 +02:00
lvc . iSubItem = 2 ;
2017-10-10 03:07:29 -04:00
lvc . pszText = plat_get_string ( IDS_2170 ) ;
2017-07-27 17:14:52 +02:00
lvc . cx = 75 ;
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 2 , & lvc ) = = - 1 )
{
return FALSE ;
}
2017-05-18 14:03:43 -04:00
return TRUE ;
}
static BOOL win_settings_cdrom_drives_init_columns ( HWND hwndList )
{
LVCOLUMN lvc ;
lvc . mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
lvc . iSubItem = 0 ;
2017-10-10 03:07:29 -04:00
lvc . pszText = plat_get_string ( IDS_2082 ) ;
2017-05-18 14:03:43 -04:00
lvc . cx = 392 ;
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 0 , & lvc ) = = - 1 )
{
return FALSE ;
}
return TRUE ;
}
2018-01-26 22:17:09 +01:00
static BOOL win_settings_zip_drives_init_columns ( HWND hwndList )
{
LVCOLUMN lvc ;
lvc . mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM ;
lvc . iSubItem = 0 ;
lvc . pszText = plat_get_string ( IDS_2082 ) ;
lvc . cx = 342 ;
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 0 , & lvc ) = = - 1 )
{
return FALSE ;
}
lvc . iSubItem = 1 ;
lvc . pszText = plat_get_string ( IDS_2143 ) ;
lvc . cx = 50 ;
lvc . fmt = LVCFMT_LEFT ;
if ( ListView_InsertColumn ( hwndList , 1 , & lvc ) = = - 1 )
{
return FALSE ;
}
return TRUE ;
}
2017-05-18 14:03:43 -04:00
static int get_selected_floppy_drive ( HWND hdlg )
{
int floppy_drive = - 1 ;
int i , j = 0 ;
HWND h ;
for ( i = 0 ; i < 6 ; i + + )
{
h = GetDlgItem ( hdlg , IDC_LIST_FLOPPY_DRIVES ) ;
j = ListView_GetItemState ( h , i , LVIS_SELECTED ) ;
if ( j )
{
floppy_drive = i ;
}
}
return floppy_drive ;
}
static int get_selected_cdrom_drive ( HWND hdlg )
{
int cd_drive = - 1 ;
int i , j = 0 ;
HWND h ;
for ( i = 0 ; i < 6 ; i + + )
{
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
j = ListView_GetItemState ( h , i , LVIS_SELECTED ) ;
if ( j )
{
cd_drive = i ;
}
}
return cd_drive ;
}
2018-01-26 22:17:09 +01:00
static int get_selected_zip_drive ( HWND hdlg )
{
int zip_disk_drive = - 1 ;
int i , j = 0 ;
HWND h ;
for ( i = 0 ; i < 6 ; i + + )
{
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
j = ListView_GetItemState ( h , i , LVIS_SELECTED ) ;
if ( j )
{
zip_disk_drive = i ;
}
}
return zip_disk_drive ;
}
2017-05-18 14:03:43 -04:00
static void win_settings_floppy_drives_update_item ( HWND hwndList , int i )
{
LVITEM lvI ;
char s [ 256 ] ;
WCHAR szText [ 256 ] ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
lvI . iSubItem = 0 ;
lvI . iItem = i ;
if ( temp_fdd_types [ i ] > 0 )
{
strcpy ( s , fdd_getname ( temp_fdd_types [ i ] ) ) ;
mbstowcs ( szText , s , strlen ( s ) + 1 ) ;
lvI . pszText = szText ;
}
else
{
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( IDS_5376 ) ;
2017-05-18 14:03:43 -04:00
}
lvI . iImage = temp_fdd_types [ i ] ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
2017-06-04 02:14:27 +02:00
lvI . iSubItem = 1 ;
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( temp_fdd_turbo [ i ] ? IDS_2060 : IDS_2061 ) ;
2017-06-04 02:14:27 +02:00
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
2017-07-27 17:14:52 +02:00
lvI . iSubItem = 2 ;
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( temp_fdd_check_bpb [ i ] ? IDS_2060 : IDS_2061 ) ;
2017-07-27 17:14:52 +02:00
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
2017-05-18 14:03:43 -04:00
}
static void win_settings_cdrom_drives_update_item ( HWND hwndList , int i )
{
LVITEM lvI ;
WCHAR szText [ 256 ] ;
int fsid ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
lvI . iSubItem = 0 ;
lvI . iItem = i ;
fsid = combo_id_to_format_string_id ( temp_cdrom_drives [ i ] . bus_type ) ;
switch ( temp_cdrom_drives [ i ] . bus_type )
{
2017-05-27 03:53:32 +02:00
case CDROM_BUS_DISABLED :
2017-05-18 14:03:43 -04:00
default :
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( fsid ) ;
2017-05-27 03:53:32 +02:00
lvI . iImage = 0 ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case CDROM_BUS_ATAPI_PIO_ONLY :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . ide_channel > > 1 , temp_cdrom_drives [ i ] . ide_channel & 1 ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
2017-05-27 03:53:32 +02:00
lvI . iImage = 1 ;
2017-05-18 14:03:43 -04:00
break ;
2017-05-27 03:53:32 +02:00
case CDROM_BUS_ATAPI_PIO_AND_DMA :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . ide_channel > > 1 , temp_cdrom_drives [ i ] . ide_channel & 1 ) ;
2017-05-27 03:53:32 +02:00
lvI . pszText = szText ;
2017-08-22 02:16:15 +02:00
lvI . iImage = 1 ;
2017-05-27 03:53:32 +02:00
break ;
case CDROM_BUS_SCSI :
2017-10-10 03:07:29 -04:00
wsprintf ( szText , plat_get_string ( fsid ) , temp_cdrom_drives [ i ] . scsi_device_id , temp_cdrom_drives [ i ] . scsi_device_lun ) ;
2017-05-18 14:03:43 -04:00
lvI . pszText = szText ;
2017-08-22 02:16:15 +02:00
lvI . iImage = 1 ;
2017-05-18 14:03:43 -04:00
break ;
}
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
}
2018-01-26 22:17:09 +01:00
static void win_settings_zip_drives_update_item ( HWND hwndList , int i )
{
LVITEM lvI ;
WCHAR szText [ 256 ] ;
int fsid ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
lvI . iSubItem = 0 ;
lvI . iItem = i ;
fsid = combo_id_to_format_string_id ( temp_zip_drives [ i ] . bus_type ) ;
switch ( temp_zip_drives [ i ] . bus_type )
{
case ZIP_BUS_DISABLED :
default :
lvI . pszText = plat_get_string ( fsid ) ;
lvI . iImage = 0 ;
break ;
case ZIP_BUS_ATAPI_PIO_ONLY :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . ide_channel > > 1 , temp_zip_drives [ i ] . ide_channel & 1 ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
case ZIP_BUS_ATAPI_PIO_AND_DMA :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . ide_channel > > 1 , temp_zip_drives [ i ] . ide_channel & 1 ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
case ZIP_BUS_SCSI :
wsprintf ( szText , plat_get_string ( fsid ) , temp_zip_drives [ i ] . scsi_device_id , temp_zip_drives [ i ] . scsi_device_lun ) ;
lvI . pszText = szText ;
lvI . iImage = 1 ;
break ;
}
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
lvI . iSubItem = 1 ;
lvI . pszText = plat_get_string ( temp_zip_drives [ i ] . is_250 ? IDS_5901 : IDS_5900 ) ;
lvI . iItem = i ;
lvI . iImage = 0 ;
if ( ListView_SetItem ( hwndList , & lvI ) = = - 1 )
{
return ;
}
}
2017-05-18 14:03:43 -04:00
static void cdrom_add_locations ( HWND hdlg )
{
LPTSTR lptsTemp ;
HWND h ;
int i = 0 ;
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_BUS ) ;
2017-05-27 04:17:18 +02:00
for ( i = CDROM_BUS_DISABLED ; i < = CDROM_BUS_SCSI ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
if ( ( i = = CDROM_BUS_DISABLED ) | | ( i > = CDROM_BUS_ATAPI_PIO_ONLY ) )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( combo_id_to_string_id ( i ) ) ) ;
2017-05-27 03:53:32 +02:00
}
2017-05-18 14:03:43 -04:00
}
h = GetDlgItem ( hdlg , IDC_COMBO_CD_ID ) ;
for ( i = 0 ; i < 16 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_CD_LUN ) ;
for ( i = 0 ; i < 8 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_CD_CHANNEL_IDE ) ;
for ( i = 0 ; i < 8 ; i + + )
{
2017-10-10 03:07:29 -04:00
wsprintf ( lptsTemp , plat_get_string ( IDS_4097 ) , i > > 1 , i & 1 ) ;
2017-05-18 14:03:43 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
free ( lptsTemp ) ;
}
2018-01-19 15:39:13 +01:00
static void cdrom_recalc_location_controls ( HWND hdlg , int assign_id )
2017-05-18 14:03:43 -04:00
{
int i = 0 ;
HWND h ;
int bus = temp_cdrom_drives [ cdlv_current_sel ] . bus_type ;
2017-06-16 03:40:18 +02:00
for ( i = IDT_1741 ; i < ( IDT_1743 + 1 ) ; i + + )
2017-05-18 14:03:43 -04:00
{
h = GetDlgItem ( hdlg , i ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_CD_ID ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_LUN ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_CHANNEL_IDE ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
switch ( bus )
{
2017-06-16 03:40:18 +02:00
case CDROM_BUS_ATAPI_PIO_ONLY : /* ATAPI (PIO-only) */
2017-05-27 03:53:32 +02:00
case CDROM_BUS_ATAPI_PIO_AND_DMA : /* ATAPI (PIO and DMA) */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1743 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-19 15:39:13 +01:00
if ( assign_id )
temp_cdrom_drives [ cdlv_current_sel ] . ide_channel = next_free_ide_channel ( ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_CD_CHANNEL_IDE ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_cdrom_drives [ cdlv_current_sel ] . ide_channel , 0 ) ;
break ;
2017-05-27 03:53:32 +02:00
case CDROM_BUS_SCSI : /* SCSI */
2017-06-16 03:40:18 +02:00
h = GetDlgItem ( hdlg , IDT_1741 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2017-06-16 04:14:50 +02:00
h = GetDlgItem ( hdlg , IDT_1742 ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
2018-01-19 15:39:13 +01:00
if ( assign_id )
next_free_scsi_id_and_lun ( ( uint8_t * ) & temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_id , ( uint8_t * ) & temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_lun ) ;
2017-06-16 04:14:50 +02:00
h = GetDlgItem ( hdlg , IDC_COMBO_CD_ID ) ;
2017-05-18 14:03:43 -04:00
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_id , 0 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_LUN ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_lun , 0 ) ;
break ;
}
}
2018-01-26 22:17:09 +01:00
static void zip_add_locations ( HWND hdlg )
{
LPTSTR lptsTemp ;
HWND h ;
int i = 0 ;
lptsTemp = ( LPTSTR ) malloc ( 512 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_BUS ) ;
for ( i = ZIP_BUS_DISABLED ; i < = ZIP_BUS_SCSI ; i + + )
{
if ( ( i = = ZIP_BUS_DISABLED ) | | ( i > = ZIP_BUS_ATAPI_PIO_ONLY ) )
{
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( combo_id_to_string_id ( i ) ) ) ;
}
}
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_ID ) ;
for ( i = 0 ; i < 16 ; i + + )
{
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_LUN ) ;
for ( i = 0 ; i < 8 ; i + + )
{
wsprintf ( lptsTemp , plat_get_string ( IDS_4098 ) , i ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_CHANNEL_IDE ) ;
for ( i = 0 ; i < 8 ; i + + )
{
wsprintf ( lptsTemp , plat_get_string ( IDS_4097 ) , i > > 1 , i & 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) lptsTemp ) ;
}
free ( lptsTemp ) ;
}
static void zip_recalc_location_controls ( HWND hdlg , int assign_id )
{
int i = 0 ;
HWND h ;
int bus = temp_zip_drives [ zdlv_current_sel ] . bus_type ;
for ( i = IDT_1754 ; i < ( IDT_1756 + 1 ) ; i + + )
{
h = GetDlgItem ( hdlg , i ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
}
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_ID ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_LUN ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_CHANNEL_IDE ) ;
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
switch ( bus )
{
case ZIP_BUS_ATAPI_PIO_ONLY : /* ATAPI (PIO-only) */
case ZIP_BUS_ATAPI_PIO_AND_DMA : /* ATAPI (PIO and DMA) */
h = GetDlgItem ( hdlg , IDT_1756 ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
if ( assign_id )
temp_zip_drives [ zdlv_current_sel ] . ide_channel = next_free_ide_channel ( ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_CHANNEL_IDE ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_zip_drives [ zdlv_current_sel ] . ide_channel , 0 ) ;
break ;
case ZIP_BUS_SCSI : /* SCSI */
h = GetDlgItem ( hdlg , IDT_1754 ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
h = GetDlgItem ( hdlg , IDT_1755 ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
if ( assign_id )
next_free_scsi_id_and_lun ( ( uint8_t * ) & temp_zip_drives [ zdlv_current_sel ] . scsi_device_id , ( uint8_t * ) & temp_zip_drives [ zdlv_current_sel ] . scsi_device_lun ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_ID ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_zip_drives [ zdlv_current_sel ] . scsi_device_id , 0 ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_LUN ) ;
ShowWindow ( h , SW_SHOW ) ;
EnableWindow ( h , TRUE ) ;
SendMessage ( h , CB_SETCURSEL , temp_zip_drives [ zdlv_current_sel ] . scsi_device_lun , 0 ) ;
break ;
}
}
2017-05-18 14:03:43 -04:00
2018-01-19 15:39:13 +01:00
static void cdrom_track ( uint8_t id )
{
if ( ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY ) | | ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY ) )
2018-01-27 02:38:52 +01:00
ide_tracking | = ( 2 < < ( temp_cdrom_drives [ id ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_SCSI )
scsi_tracking [ temp_cdrom_drives [ id ] . scsi_device_id ] | = ( 1 < < temp_cdrom_drives [ id ] . scsi_device_lun ) ;
}
static void cdrom_untrack ( uint8_t id )
{
if ( ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY ) | | ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY ) )
2018-01-27 02:38:52 +01:00
ide_tracking & = ~ ( 2 < < ( temp_cdrom_drives [ id ] . ide_channel < < 3 ) ) ;
2018-01-19 15:39:13 +01:00
else if ( temp_cdrom_drives [ id ] . bus_type = = CDROM_BUS_SCSI )
scsi_tracking [ temp_cdrom_drives [ id ] . scsi_device_id ] & = ~ ( 1 < < temp_cdrom_drives [ id ] . scsi_device_lun ) ;
}
2018-01-27 02:38:52 +01:00
#if 0
2018-01-26 22:17:09 +01:00
static void cdrom_track_all ( void )
{
int i ;
2018-01-19 15:39:13 +01:00
2018-01-26 22:17:09 +01:00
for ( i = 0 ; i < CDROM_NUM ; i + + )
cdrom_track ( i ) ;
}
2018-01-27 02:38:52 +01:00
# endif
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
static void zip_track ( uint8_t id )
{
if ( ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY ) | | ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY ) )
ide_tracking | = ( 1 < < temp_zip_drives [ id ] . ide_channel ) ;
else if ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_SCSI )
scsi_tracking [ temp_zip_drives [ id ] . scsi_device_id ] | = ( 1 < < temp_zip_drives [ id ] . scsi_device_lun ) ;
}
static void zip_untrack ( uint8_t id )
{
if ( ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY ) | | ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY ) )
ide_tracking & = ~ ( 1 < < temp_zip_drives [ id ] . ide_channel ) ;
else if ( temp_zip_drives [ id ] . bus_type = = ZIP_BUS_SCSI )
scsi_tracking [ temp_zip_drives [ id ] . scsi_device_id ] & = ~ ( 1 < < temp_zip_drives [ id ] . scsi_device_lun ) ;
}
2018-01-27 02:38:52 +01:00
#if 0
2018-01-26 22:17:09 +01:00
static void zip_track_all ( void )
{
int i ;
for ( i = 0 ; i < ZIP_NUM ; i + + )
zip_track ( i ) ;
}
2018-01-27 02:38:52 +01:00
# endif
2018-01-26 22:17:09 +01:00
int fd_ignore_change = 0 ;
# ifdef __amd64__
static LRESULT CALLBACK
# else
2017-12-13 22:39:41 +01:00
static BOOL CALLBACK
# endif
2018-01-26 22:17:09 +01:00
win_settings_floppy_drives_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int i = 0 ;
int old_sel = 0 ;
WCHAR szText [ 256 ] ;
switch ( message )
{
case WM_INITDIALOG :
2018-01-26 22:17:09 +01:00
fd_ignore_change = 1 ;
2018-01-19 15:39:13 +01:00
2017-05-18 14:03:43 -04:00
fdlv_current_sel = 0 ;
h = GetDlgItem ( hdlg , IDC_LIST_FLOPPY_DRIVES ) ;
win_settings_floppy_drives_init_columns ( h ) ;
win_settings_floppy_drives_image_list_init ( h ) ;
win_settings_floppy_drives_recalc_list ( h ) ;
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_FD_TYPE ) ;
for ( i = 0 ; i < 14 ; i + + )
{
if ( i = = 0 )
{
2017-10-10 03:07:29 -04:00
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) plat_get_string ( IDS_5376 ) ) ;
2017-05-18 14:03:43 -04:00
}
else
{
mbstowcs ( szText , fdd_getname ( i ) , strlen ( fdd_getname ( i ) ) + 1 ) ;
SendMessage ( h , CB_ADDSTRING , 0 , ( LPARAM ) szText ) ;
}
}
SendMessage ( h , CB_SETCURSEL , temp_fdd_types [ fdlv_current_sel ] , 0 ) ;
2017-06-04 02:14:27 +02:00
h = GetDlgItem ( hdlg , IDC_CHECKTURBO ) ;
SendMessage ( h , BM_SETCHECK , temp_fdd_turbo [ fdlv_current_sel ] , 0 ) ;
2017-07-27 17:14:52 +02:00
h = GetDlgItem ( hdlg , IDC_CHECKBPB ) ;
SendMessage ( h , BM_SETCHECK , temp_fdd_check_bpb [ fdlv_current_sel ] , 0 ) ;
2018-01-26 22:17:09 +01:00
fd_ignore_change = 0 ;
return TRUE ;
case WM_NOTIFY :
if ( fd_ignore_change )
{
return FALSE ;
}
if ( ( ( ( LPNMHDR ) lParam ) - > code = = LVN_ITEMCHANGED ) & & ( ( ( LPNMHDR ) lParam ) - > idFrom = = IDC_LIST_FLOPPY_DRIVES ) )
{
old_sel = fdlv_current_sel ;
fdlv_current_sel = get_selected_floppy_drive ( hdlg ) ;
if ( fdlv_current_sel = = old_sel )
{
return FALSE ;
}
else if ( fdlv_current_sel = = - 1 )
{
fd_ignore_change = 1 ;
fdlv_current_sel = old_sel ;
ListView_SetItemState ( h , fdlv_current_sel , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
fd_ignore_change = 0 ;
return FALSE ;
}
fd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_FD_TYPE ) ;
SendMessage ( h , CB_SETCURSEL , temp_fdd_types [ fdlv_current_sel ] , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECKTURBO ) ;
SendMessage ( h , BM_SETCHECK , temp_fdd_turbo [ fdlv_current_sel ] , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECKBPB ) ;
SendMessage ( h , BM_SETCHECK , temp_fdd_check_bpb [ fdlv_current_sel ] , 0 ) ;
fd_ignore_change = 0 ;
}
break ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDC_COMBO_FD_TYPE :
if ( fd_ignore_change )
{
return FALSE ;
}
fd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_FD_TYPE ) ;
temp_fdd_types [ fdlv_current_sel ] = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_LIST_FLOPPY_DRIVES ) ;
win_settings_floppy_drives_update_item ( h , fdlv_current_sel ) ;
fd_ignore_change = 0 ;
return FALSE ;
case IDC_CHECKTURBO :
if ( fd_ignore_change )
{
return FALSE ;
}
fd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_CHECKTURBO ) ;
temp_fdd_turbo [ fdlv_current_sel ] = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_LIST_FLOPPY_DRIVES ) ;
win_settings_floppy_drives_update_item ( h , fdlv_current_sel ) ;
fd_ignore_change = 0 ;
return FALSE ;
case IDC_CHECKBPB :
if ( fd_ignore_change )
{
return FALSE ;
}
fd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_CHECKBPB ) ;
temp_fdd_check_bpb [ fdlv_current_sel ] = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_LIST_FLOPPY_DRIVES ) ;
win_settings_floppy_drives_update_item ( h , fdlv_current_sel ) ;
fd_ignore_change = 0 ;
return FALSE ;
}
default :
return FALSE ;
}
return FALSE ;
}
int rd_ignore_change = 0 ;
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_other_removable_devices_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
{
HWND h ;
int old_sel = 0 ;
int b = 0 ;
int b2 = 0 ;
int assign = 0 ;
switch ( message )
{
case WM_INITDIALOG :
rd_ignore_change = 1 ;
2017-05-18 14:03:43 -04:00
cdlv_current_sel = 0 ;
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
win_settings_cdrom_drives_init_columns ( h ) ;
win_settings_cdrom_drives_image_list_init ( h ) ;
win_settings_cdrom_drives_recalc_list ( h ) ;
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
cdrom_add_locations ( hdlg ) ;
2017-05-27 03:53:32 +02:00
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_CD_BUS ) ;
2017-05-27 03:53:32 +02:00
switch ( temp_cdrom_drives [ cdlv_current_sel ] . bus_type )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
case CDROM_BUS_DISABLED :
default :
b = 0 ;
break ;
case CDROM_BUS_ATAPI_PIO_ONLY :
b = 1 ;
break ;
case CDROM_BUS_ATAPI_PIO_AND_DMA :
b = 2 ;
break ;
case CDROM_BUS_SCSI :
b = 3 ;
break ;
2017-05-18 14:03:43 -04:00
}
2017-05-27 03:53:32 +02:00
SendMessage ( h , CB_SETCURSEL , b , 0 ) ;
2018-01-19 15:39:13 +01:00
cdrom_recalc_location_controls ( hdlg , 0 ) ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
zdlv_current_sel = 0 ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_init_columns ( h ) ;
win_settings_zip_drives_image_list_init ( h ) ;
win_settings_zip_drives_recalc_list ( h ) ;
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
zip_add_locations ( hdlg ) ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_BUS ) ;
switch ( temp_zip_drives [ zdlv_current_sel ] . bus_type )
{
case ZIP_BUS_DISABLED :
default :
b = 0 ;
break ;
case ZIP_BUS_ATAPI_PIO_ONLY :
b = 1 ;
break ;
case ZIP_BUS_ATAPI_PIO_AND_DMA :
b = 2 ;
break ;
case ZIP_BUS_SCSI :
b = 3 ;
break ;
}
SendMessage ( h , CB_SETCURSEL , b , 0 ) ;
zip_recalc_location_controls ( hdlg , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK250 ) ;
SendMessage ( h , BM_SETCHECK , temp_zip_drives [ zdlv_current_sel ] . is_250 , 0 ) ;
2017-05-18 14:03:43 -04:00
rd_ignore_change = 0 ;
return TRUE ;
case WM_NOTIFY :
if ( rd_ignore_change )
{
return FALSE ;
}
2018-01-26 22:17:09 +01:00
if ( ( ( ( LPNMHDR ) lParam ) - > code = = LVN_ITEMCHANGED ) & & ( ( ( LPNMHDR ) lParam ) - > idFrom = = IDC_LIST_CDROM_DRIVES ) )
2017-05-18 14:03:43 -04:00
{
old_sel = cdlv_current_sel ;
cdlv_current_sel = get_selected_cdrom_drive ( hdlg ) ;
if ( cdlv_current_sel = = old_sel )
{
return FALSE ;
}
else if ( cdlv_current_sel = = - 1 )
{
rd_ignore_change = 1 ;
cdlv_current_sel = old_sel ;
ListView_SetItemState ( h , cdlv_current_sel , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
rd_ignore_change = 0 ;
return FALSE ;
}
rd_ignore_change = 1 ;
2017-05-27 03:53:32 +02:00
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_CD_BUS ) ;
2017-05-27 03:53:32 +02:00
switch ( temp_cdrom_drives [ cdlv_current_sel ] . bus_type )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
case CDROM_BUS_DISABLED :
default :
b = 0 ;
break ;
case CDROM_BUS_ATAPI_PIO_ONLY :
b = 1 ;
break ;
case CDROM_BUS_ATAPI_PIO_AND_DMA :
b = 2 ;
break ;
case CDROM_BUS_SCSI :
b = 3 ;
break ;
2017-05-18 14:03:43 -04:00
}
2017-05-27 03:53:32 +02:00
SendMessage ( h , CB_SETCURSEL , b , 0 ) ;
2018-01-19 15:39:13 +01:00
cdrom_recalc_location_controls ( hdlg , 0 ) ;
2017-05-18 14:03:43 -04:00
rd_ignore_change = 0 ;
}
2018-01-26 22:17:09 +01:00
else if ( ( ( ( LPNMHDR ) lParam ) - > code = = LVN_ITEMCHANGED ) & & ( ( ( LPNMHDR ) lParam ) - > idFrom = = IDC_LIST_ZIP_DRIVES ) )
{
old_sel = zdlv_current_sel ;
zdlv_current_sel = get_selected_zip_drive ( hdlg ) ;
if ( zdlv_current_sel = = old_sel )
{
return FALSE ;
}
else if ( zdlv_current_sel = = - 1 )
{
2017-05-18 14:03:43 -04:00
rd_ignore_change = 1 ;
2018-01-26 22:17:09 +01:00
zdlv_current_sel = old_sel ;
ListView_SetItemState ( h , zdlv_current_sel , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
2017-05-18 14:03:43 -04:00
rd_ignore_change = 0 ;
return FALSE ;
2018-01-26 22:17:09 +01:00
}
rd_ignore_change = 1 ;
2017-05-18 14:03:43 -04:00
2018-01-26 22:17:09 +01:00
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_BUS ) ;
2017-06-04 02:14:27 +02:00
2018-01-26 22:17:09 +01:00
switch ( temp_zip_drives [ zdlv_current_sel ] . bus_type )
{
case ZIP_BUS_DISABLED :
default :
b = 0 ;
break ;
case ZIP_BUS_ATAPI_PIO_ONLY :
b = 1 ;
break ;
case ZIP_BUS_ATAPI_PIO_AND_DMA :
b = 2 ;
break ;
case ZIP_BUS_SCSI :
b = 3 ;
break ;
}
2017-07-27 17:14:52 +02:00
2018-01-26 22:17:09 +01:00
SendMessage ( h , CB_SETCURSEL , b , 0 ) ;
2017-07-27 17:14:52 +02:00
2018-01-26 22:17:09 +01:00
zip_recalc_location_controls ( hdlg , 0 ) ;
h = GetDlgItem ( hdlg , IDC_CHECK250 ) ;
SendMessage ( h , BM_SETCHECK , temp_zip_drives [ zdlv_current_sel ] . is_250 , 0 ) ;
2017-06-04 02:14:27 +02:00
2018-01-26 22:17:09 +01:00
rd_ignore_change = 0 ;
}
break ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
2017-05-18 14:03:43 -04:00
case IDC_COMBO_CD_BUS :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_BUS ) ;
2017-05-27 03:53:32 +02:00
b = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
switch ( b )
2017-05-18 14:03:43 -04:00
{
2017-05-27 03:53:32 +02:00
case 0 :
2017-05-27 04:17:18 +02:00
b2 = CDROM_BUS_DISABLED ;
2017-05-27 03:53:32 +02:00
break ;
case 1 :
2017-05-27 04:17:18 +02:00
b2 = CDROM_BUS_ATAPI_PIO_ONLY ;
2017-05-27 03:53:32 +02:00
break ;
case 2 :
2017-05-27 04:17:18 +02:00
b2 = CDROM_BUS_ATAPI_PIO_AND_DMA ;
2017-05-27 03:53:32 +02:00
break ;
case 3 :
2017-05-27 04:17:18 +02:00
b2 = CDROM_BUS_SCSI ;
2017-05-27 03:53:32 +02:00
break ;
2017-05-18 14:03:43 -04:00
}
2017-05-27 04:17:18 +02:00
if ( b2 = = temp_cdrom_drives [ cdlv_current_sel ] . bus_type )
{
goto cdrom_bus_skip ;
}
2018-01-19 15:39:13 +01:00
cdrom_untrack ( cdlv_current_sel ) ;
2018-01-24 18:38:43 +01:00
assign = ( temp_cdrom_drives [ cdlv_current_sel ] . bus_type = = b2 ) ? 0 : 1 ;
if ( ( b2 = = CDROM_BUS_ATAPI_PIO_ONLY ) & & ( temp_cdrom_drives [ cdlv_current_sel ] . bus_type = = CDROM_BUS_ATAPI_PIO_AND_DMA ) )
assign = 0 ;
else if ( ( b2 = = CDROM_BUS_ATAPI_PIO_AND_DMA ) & & ( temp_cdrom_drives [ cdlv_current_sel ] . bus_type = = CDROM_BUS_ATAPI_PIO_ONLY ) )
assign = 0 ;
2017-05-27 04:17:18 +02:00
temp_cdrom_drives [ cdlv_current_sel ] . bus_type = b2 ;
2018-01-24 18:38:43 +01:00
cdrom_recalc_location_controls ( hdlg , assign ) ;
2018-01-19 15:39:13 +01:00
cdrom_track ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
win_settings_cdrom_drives_update_item ( h , cdlv_current_sel ) ;
2017-05-27 04:17:18 +02:00
cdrom_bus_skip :
2017-05-18 14:03:43 -04:00
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_CD_ID :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_ID ) ;
2018-01-24 18:38:43 +01:00
cdrom_untrack ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_id = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-24 18:38:43 +01:00
cdrom_track ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
win_settings_cdrom_drives_update_item ( h , cdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_CD_LUN :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_LUN ) ;
2018-01-19 15:39:13 +01:00
cdrom_untrack ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
temp_cdrom_drives [ cdlv_current_sel ] . scsi_device_lun = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-19 15:39:13 +01:00
cdrom_track ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
win_settings_cdrom_drives_update_item ( h , cdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_CD_CHANNEL_IDE :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_CD_CHANNEL_IDE ) ;
2018-01-19 15:39:13 +01:00
cdrom_untrack ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
temp_cdrom_drives [ cdlv_current_sel ] . ide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
2018-01-19 15:39:13 +01:00
cdrom_track ( cdlv_current_sel ) ;
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_LIST_CDROM_DRIVES ) ;
win_settings_cdrom_drives_update_item ( h , cdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
2018-01-26 22:17:09 +01:00
case IDC_COMBO_ZIP_BUS :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_BUS ) ;
b = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
switch ( b )
{
case 0 :
b2 = ZIP_BUS_DISABLED ;
break ;
case 1 :
b2 = ZIP_BUS_ATAPI_PIO_ONLY ;
break ;
case 2 :
b2 = ZIP_BUS_ATAPI_PIO_AND_DMA ;
break ;
case 3 :
b2 = ZIP_BUS_SCSI ;
break ;
}
if ( b2 = = temp_zip_drives [ zdlv_current_sel ] . bus_type )
{
goto zip_bus_skip ;
}
zip_untrack ( zdlv_current_sel ) ;
assign = ( temp_zip_drives [ zdlv_current_sel ] . bus_type = = b2 ) ? 0 : 1 ;
if ( ( b2 = = ZIP_BUS_ATAPI_PIO_ONLY ) & & ( temp_zip_drives [ zdlv_current_sel ] . bus_type = = ZIP_BUS_ATAPI_PIO_AND_DMA ) )
assign = 0 ;
else if ( ( b2 = = ZIP_BUS_ATAPI_PIO_AND_DMA ) & & ( temp_zip_drives [ cdlv_current_sel ] . bus_type = = ZIP_BUS_ATAPI_PIO_ONLY ) )
assign = 0 ;
temp_zip_drives [ zdlv_current_sel ] . bus_type = b2 ;
zip_recalc_location_controls ( hdlg , assign ) ;
zip_track ( zdlv_current_sel ) ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_update_item ( h , zdlv_current_sel ) ;
zip_bus_skip :
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_ZIP_ID :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_ID ) ;
zip_untrack ( zdlv_current_sel ) ;
temp_zip_drives [ zdlv_current_sel ] . scsi_device_id = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
zip_track ( zdlv_current_sel ) ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_update_item ( h , zdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_ZIP_LUN :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_LUN ) ;
zip_untrack ( zdlv_current_sel ) ;
temp_zip_drives [ zdlv_current_sel ] . scsi_device_lun = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
zip_track ( zdlv_current_sel ) ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_update_item ( h , zdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
case IDC_COMBO_ZIP_CHANNEL_IDE :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_COMBO_ZIP_CHANNEL_IDE ) ;
zip_untrack ( zdlv_current_sel ) ;
temp_zip_drives [ zdlv_current_sel ] . ide_channel = SendMessage ( h , CB_GETCURSEL , 0 , 0 ) ;
zip_track ( zdlv_current_sel ) ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_update_item ( h , zdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
case IDC_CHECK250 :
if ( rd_ignore_change )
{
return FALSE ;
}
rd_ignore_change = 1 ;
h = GetDlgItem ( hdlg , IDC_CHECK250 ) ;
temp_zip_drives [ zdlv_current_sel ] . is_250 = SendMessage ( h , BM_GETCHECK , 0 , 0 ) ;
h = GetDlgItem ( hdlg , IDC_LIST_ZIP_DRIVES ) ;
win_settings_zip_drives_update_item ( h , zdlv_current_sel ) ;
rd_ignore_change = 0 ;
return FALSE ;
2017-05-18 14:03:43 -04:00
}
default :
return FALSE ;
}
return FALSE ;
}
2017-08-27 00:58:44 +02:00
# define SETTINGS_PAGE_MACHINE 0
# define SETTINGS_PAGE_VIDEO 1
# define SETTINGS_PAGE_INPUT 2
# define SETTINGS_PAGE_SOUND 3
# define SETTINGS_PAGE_NETWORK 4
2017-09-02 23:39:26 +02:00
# define SETTINGS_PAGE_PORTS 5
# define SETTINGS_PAGE_PERIPHERALS 6
# define SETTINGS_PAGE_HARD_DISKS 7
2018-01-26 22:17:09 +01:00
# define SETTINGS_PAGE_FLOPPY_DRIVES 8
# define SETTINGS_PAGE_OTHER_REMOVABLE_DEVICES 9
2017-08-27 00:58:44 +02:00
2017-05-18 14:03:43 -04:00
void win_settings_show_child ( HWND hwndParent , DWORD child_id )
{
if ( child_id = = displayed_category )
{
return ;
}
else
{
displayed_category = child_id ;
}
SendMessage ( hwndChildDialog , WM_SAVESETTINGS , 0 , 0 ) ;
DestroyWindow ( hwndChildDialog ) ;
switch ( child_id )
{
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_MACHINE :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_MACHINE , hwndParent , win_settings_machine_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_VIDEO :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_VIDEO , hwndParent , win_settings_video_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_INPUT :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_INPUT , hwndParent , win_settings_input_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_SOUND :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_SOUND , hwndParent , win_settings_sound_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_NETWORK :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_NETWORK , hwndParent , win_settings_network_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-09-02 23:39:26 +02:00
case SETTINGS_PAGE_PORTS :
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_PORTS , hwndParent , win_settings_ports_proc ) ;
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_PERIPHERALS :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_PERIPHERALS , hwndParent , win_settings_peripherals_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2017-08-27 00:58:44 +02:00
case SETTINGS_PAGE_HARD_DISKS :
2017-06-04 02:11:19 -04:00
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_HARD_DISKS , hwndParent , win_settings_hard_disks_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
2018-01-26 22:17:09 +01:00
case SETTINGS_PAGE_FLOPPY_DRIVES :
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_FLOPPY_DRIVES , hwndParent , win_settings_floppy_drives_proc ) ;
break ;
case SETTINGS_PAGE_OTHER_REMOVABLE_DEVICES :
hwndChildDialog = CreateDialog ( hinstance , ( LPCWSTR ) DLG_CFG_OTHER_REMOVABLE_DEVICES , hwndParent , win_settings_other_removable_devices_proc ) ;
2017-05-18 14:03:43 -04:00
break ;
default :
fatal ( " Invalid child dialog ID \n " ) ;
return ;
}
ShowWindow ( hwndChildDialog , SW_SHOWNORMAL ) ;
}
static BOOL win_settings_main_image_list_init ( HWND hwndList )
{
HICON hiconItem ;
HIMAGELIST hSmall ;
int i = 0 ;
hSmall = ImageList_Create ( GetSystemMetrics ( SM_CXSMICON ) ,
GetSystemMetrics ( SM_CYSMICON ) ,
ILC_MASK | ILC_COLOR32 , 1 , 1 ) ;
2018-01-26 22:17:09 +01:00
for ( i = 0 ; i < 10 ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-12-13 22:39:41 +01:00
hiconItem = LoadIcon ( hinstance , ( LPCWSTR ) ( 256 + ( uintptr_t ) i ) ) ;
2017-05-18 14:03:43 -04:00
ImageList_AddIcon ( hSmall , hiconItem ) ;
DestroyIcon ( hiconItem ) ;
}
ListView_SetImageList ( hwndList , hSmall , LVSIL_SMALL ) ;
return TRUE ;
}
static BOOL win_settings_main_insert_categories ( HWND hwndList )
{
LVITEM lvI ;
int i = 0 ;
lvI . mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE ;
lvI . stateMask = lvI . iSubItem = lvI . state = 0 ;
2018-01-26 22:17:09 +01:00
for ( i = 0 ; i < 10 ; i + + )
2017-05-18 14:03:43 -04:00
{
2017-10-10 03:07:29 -04:00
lvI . pszText = plat_get_string ( IDS_2065 + i ) ;
2017-05-18 14:03:43 -04:00
lvI . iItem = i ;
lvI . iImage = i ;
if ( ListView_InsertItem ( hwndList , & lvI ) = = - 1 )
return FALSE ;
}
return TRUE ;
}
2017-12-13 22:39:41 +01:00
# ifdef __amd64__
static LRESULT CALLBACK
# else
static BOOL CALLBACK
# endif
win_settings_main_proc ( HWND hdlg , UINT message , WPARAM wParam , LPARAM lParam )
2017-05-18 14:03:43 -04:00
{
HWND h ;
int category ;
int i = 0 ;
int j = 0 ;
hwndParentDialog = hdlg ;
switch ( message )
{
case WM_INITDIALOG :
2017-10-14 00:49:08 -04:00
plat_pause ( 1 ) ;
2017-05-18 14:03:43 -04:00
win_settings_init ( ) ;
displayed_category = - 1 ;
h = GetDlgItem ( hdlg , IDC_SETTINGSCATLIST ) ;
win_settings_main_image_list_init ( h ) ;
win_settings_main_insert_categories ( h ) ;
ListView_SetItemState ( h , 0 , LVIS_FOCUSED | LVIS_SELECTED , 0x000F ) ;
2017-06-19 06:46:08 +02:00
/* Leave this commented out until we do localization. */
#if 0
2017-05-18 14:03:43 -04:00
h = GetDlgItem ( hdlg , IDC_COMBO_LANG ) ; /* This is currently disabled, I am going to add localization options in the future. */
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
2017-05-29 21:57:31 -04:00
h = GetDlgItem ( hdlg , IDS_LANG_ENUS ) ; /*was:2047 !*/
2017-05-18 14:03:43 -04:00
EnableWindow ( h , FALSE ) ;
ShowWindow ( h , SW_HIDE ) ;
2017-06-19 06:46:08 +02:00
# endif
2017-05-18 14:03:43 -04:00
return TRUE ;
case WM_NOTIFY :
if ( ( ( ( LPNMHDR ) lParam ) - > code = = LVN_ITEMCHANGED ) & & ( ( ( LPNMHDR ) lParam ) - > idFrom = = IDC_SETTINGSCATLIST ) )
{
category = - 1 ;
2018-01-26 22:17:09 +01:00
for ( i = 0 ; i < 10 ; i + + )
2017-05-18 14:03:43 -04:00
{
h = GetDlgItem ( hdlg , IDC_SETTINGSCATLIST ) ;
j = ListView_GetItemState ( h , i , LVIS_SELECTED ) ;
if ( j )
{
category = i ;
/* pclog("Category %i selected\n", i); */
}
}
if ( category ! = - 1 )
{
/* pclog("Showing child: %i\n", category); */
win_settings_show_child ( hdlg , category ) ;
}
}
break ;
case WM_COMMAND :
switch ( LOWORD ( wParam ) )
{
case IDOK :
/* pclog("Saving settings...\n"); */
SendMessage ( hwndChildDialog , WM_SAVESETTINGS , 0 , 0 ) ;
i = settings_msgbox_reset ( ) ;
if ( i > 0 )
{
if ( i = = 2 )
{
win_settings_save ( ) ;
}
/* pclog("Destroying window...\n"); */
DestroyWindow ( hwndChildDialog ) ;
EndDialog ( hdlg , 0 ) ;
2017-10-14 00:49:08 -04:00
plat_pause ( 0 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
else
{
return FALSE ;
}
case IDCANCEL :
DestroyWindow ( hwndChildDialog ) ;
EndDialog ( hdlg , 0 ) ;
2017-10-14 00:49:08 -04:00
plat_pause ( 0 ) ;
2017-05-18 14:03:43 -04:00
return TRUE ;
}
break ;
default :
return FALSE ;
}
return FALSE ;
}
void win_settings_open ( HWND hwnd )
{
2017-06-04 22:18:41 -04:00
DialogBox ( hinstance , ( LPCWSTR ) DLG_CONFIG , hwnd , win_settings_main_proc ) ;
2017-05-18 14:03:43 -04:00
}