diff --git a/src/Makefile.local b/src/Makefile.local index 7cd4aca..7fdea7d 100644 --- a/src/Makefile.local +++ b/src/Makefile.local @@ -10,7 +10,7 @@ # settings, so we can avoid changing the main one for all of # our local setups. # -# Version: @(#)Makefile.local 1.0.6 2018/04/18 +# Version: @(#)Makefile.local 1.0.7 2018/04/18 # # Author: Fred N. van Kempen, # @@ -55,7 +55,7 @@ #PROG := yourexe # Build Platform. -BUILD := mingw/Makefile.MinGW +SCRIPT := mingw/Makefile.MinGW # Various compile-time options. # -DROM_TRACE=0xc800 traces ROM access from segment C800 @@ -112,7 +112,7 @@ DYNAREC := y ######################################################################### # Include the master Makefile.MinGW for the rest. # ######################################################################### -include win/$(BUILD) +include win/$(SCRIPT) # End of Makefile.local. diff --git a/src/config.c b/src/config.c index 03e46c2..eeec82e 100644 --- a/src/config.c +++ b/src/config.c @@ -12,7 +12,7 @@ * it on Windows XP, and possibly also Vista. Use the * -DANSI_CFG for use on these systems. * - * Version: @(#)config.c 1.0.13 2018/04/10 + * Version: @(#)config.c 1.0.15 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -434,9 +434,9 @@ load_general(void) p = config_get_string(cat, "vid_renderer", "default"); vid_api = plat_vidapi(p); - video_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0); + vid_fullscreen_scale = config_get_int(cat, "video_fullscreen_scale", 0); - video_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0); + vid_fullscreen_first = config_get_int(cat, "video_fullscreen_first", 0); force_43 = !!config_get_int(cat, "force_43", 0); scale = config_get_int(cat, "scale", 1); @@ -445,8 +445,8 @@ load_general(void) enable_overscan = !!config_get_int(cat, "enable_overscan", 0); vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0); - video_grayscale = config_get_int(cat, "video_grayscale", 0); - video_graytype = config_get_int(cat, "video_graytype", 0); + vid_grayscale = config_get_int(cat, "video_grayscale", 0); + vid_graytype = config_get_int(cat, "video_graytype", 0); rctrl_is_lalt = config_get_int(cat, "rctrl_is_lalt", 0); @@ -518,7 +518,7 @@ load_video(void) if (machines[machine].fixed_vidcard) { config_delete_var(cat, "video_card"); config_delete_var(cat, "voodoo"); - vid_card = VID_INTERNAL; + video_card = VID_INTERNAL; } else { p = config_get_string(cat, "video_card", NULL); @@ -534,7 +534,7 @@ load_video(void) else p = "none"; } - vid_card = video_get_video_from_internal_name(p); + video_card = video_get_video_from_internal_name(p); video_speed = config_get_int(cat, "video_speed", -1); @@ -597,12 +597,12 @@ load_sound(void) config_delete_var(cat, "sndcard"); } - if (p == NULL) - p = "none"; - sound_card_current = sound_card_get_from_internal_name(p); + if (p == NULL) + p = "none"; + sound_card = sound_card_get_from_internal_name(p); p = config_get_string(cat, "midi_device", "none"); - midi_device_current = midi_device_get_from_internal_name(p); + midi_device = midi_device_get_from_internal_name(p); mpu401_standalone_enable = !!config_get_int(cat, "mpu401_standalone", 0); @@ -707,9 +707,9 @@ load_other_peripherals(void) config_delete_var(cat, "scsicard"); } - if (p == NULL) - p = "none"; - scsi_card_current = scsi_card_get_from_internal_name(p); + if (p == NULL) + p = "none"; + scsi_card = scsi_card_get_from_internal_name(p); p = config_get_string(cat, "hdc", NULL); if (p == NULL) { @@ -1147,7 +1147,7 @@ config_load(void) plat_langid = 0x0409; #endif scale = 1; - vid_card = VID_CGA; + video_card = VID_CGA; vid_api = plat_vidapi("default");; enable_sync = 1; joystick_type = 0; @@ -1204,15 +1204,15 @@ save_general(void) config_set_string(cat, "vid_renderer", str); } - if (video_fullscreen_scale == 0) + if (vid_fullscreen_scale == 0) config_delete_var(cat, "video_fullscreen_scale"); else - config_set_int(cat, "video_fullscreen_scale", video_fullscreen_scale); + config_set_int(cat, "video_fullscreen_scale", vid_fullscreen_scale); - if (video_fullscreen_first == 0) + if (vid_fullscreen_first == 0) config_delete_var(cat, "video_fullscreen_first"); else - config_set_int(cat, "video_fullscreen_first", video_fullscreen_first); + config_set_int(cat, "video_fullscreen_first", vid_fullscreen_first); if (force_43 == 0) config_delete_var(cat, "force_43"); @@ -1234,15 +1234,15 @@ save_general(void) else config_set_int(cat, "vid_cga_contrast", vid_cga_contrast); - if (video_grayscale == 0) + if (vid_grayscale == 0) config_delete_var(cat, "video_grayscale"); else - config_set_int(cat, "video_grayscale", video_grayscale); + config_set_int(cat, "video_grayscale", vid_grayscale); - if (video_graytype == 0) + if (vid_graytype == 0) config_delete_var(cat, "video_graytype"); else - config_set_int(cat, "video_graytype", video_graytype); + config_set_int(cat, "video_graytype", vid_graytype); if (rctrl_is_lalt == 0) config_delete_var(cat, "rctrl_is_lalt"); @@ -1331,7 +1331,7 @@ save_video(void) const char *cat = "Video"; config_set_string(cat, "video_card", - video_get_internal_name(video_old_to_new(vid_card))); + video_get_internal_name(video_old_to_new(video_card))); if (video_speed == 3) config_delete_var(cat, "video_speed"); @@ -1412,17 +1412,17 @@ save_sound(void) { const char *cat = "Sound"; - if (sound_card_current == 0) + if (sound_card == 0) config_delete_var(cat, "sound_card"); else config_set_string(cat, "sound_card", - sound_card_get_internal_name(sound_card_current)); + sound_card_get_internal_name(sound_card)); - if (!strcmp(midi_device_get_internal_name(midi_device_current), "none")) + if (!strcmp(midi_device_get_internal_name(midi_device), "none")) config_delete_var(cat, "midi_device"); else config_set_string(cat, "midi_device", - midi_device_get_internal_name(midi_device_current)); + midi_device_get_internal_name(midi_device)); if (mpu401_standalone_enable == 0) config_delete_var(cat, "mpu401_standalone"); @@ -1483,8 +1483,8 @@ save_ports(void) int i; for (i = 0; i < SERIAL_MAX; i++) { + sprintf(temp, "serial%i_enabled", i); if (serial_enabled[i]) { - sprintf(temp, "serial%i_enabled", i); config_set_int(cat, temp, 1); } else config_delete_var(cat, temp); @@ -1517,11 +1517,11 @@ save_other_peripherals(void) char temp[512], tmp2[512]; int c; - if (scsi_card_current == 0) + if (scsi_card == 0) config_delete_var(cat, "scsi_card"); else config_set_string(cat, "scsi_card", - scsi_card_get_internal_name(scsi_card_current)); + scsi_card_get_internal_name(scsi_card)); config_set_string(cat, "hdc", hdc_get_internal_name(hdc_type)); diff --git a/src/disk/hdc.c b/src/disk/hdc.c index 73ddcd9..7210c09 100644 --- a/src/disk/hdc.c +++ b/src/disk/hdc.c @@ -8,7 +8,7 @@ * * Common code to handle all sorts of disk controllers. * - * Version: @(#)hdc.c 1.0.6 2018/04/10 + * Version: @(#)hdc.c 1.0.8 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -115,7 +115,18 @@ static const struct { { "[ISA] [ESDI] PC/AT ESDI Fixed Disk Adapter", "esdi_at", &esdi_at_wd1007vse1_device, 0 }, - { "[ISA] [IDE] PC/AT IDE Adapter", "ide_isa", +#ifdef USE_XTA + { "[ISA] [IDE] PC/XT IDE (XTA) Adapter", "xta_isa", + &xta_isa_device, 0, }, +#endif + + { "[ISA] [IDE] PC/XT XTIDE (ATA)", "xtide", + &xtide_device, 0 }, + + { "[ISA] [IDE] PC/XT Acculogic XT IDE", "xtide_acculogic", + &xtide_acculogic_device, 0 }, + + { "[ISA] [IDE] PC/AT IDE (ATA) Adapter", "ide_isa", &ide_isa_device, 0 }, { "[ISA] [IDE] PC/AT IDE Adapter (Dual-Channel)", "ide_isa_2ch", @@ -127,12 +138,6 @@ static const struct { { "[ISA] [IDE] PS/2 AT XTIDE (1.1.5)", "xtide_at_ps2", &xtide_at_ps2_device, 0 }, - { "[ISA] [XT IDE] Acculogic XT IDE", "xtide_acculogic", - &xtide_acculogic_device, 0 }, - - { "[ISA] [XT IDE] PC/XT XTIDE", "xtide", - &xtide_device , 0 }, - { "[MCA] [ESDI] IBM PS/2 ESDI Fixed Disk Adapter","esdi_mca", &esdi_ps2_device, 1 }, diff --git a/src/disk/hdc.h b/src/disk/hdc.h index 6dca973..542b45b 100644 --- a/src/disk/hdc.h +++ b/src/disk/hdc.h @@ -8,7 +8,7 @@ * * Definitions for the common disk controller handler. * - * Version: @(#)hdc.h 1.0.6 2018/04/10 + * Version: @(#)hdc.h 1.0.8 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -46,6 +46,10 @@ * least 7 devices, with each device being * able to support 8 units, but hey... */ +#define HDC_NONE 0 +#define HDC_INTERNAL 1 + + #ifdef __cplusplus extern "C" { #endif @@ -58,6 +62,11 @@ extern const device_t mfm_at_wd1003_device; /* mfm_at_wd1003 */ extern const device_t esdi_at_wd1007vse1_device; /* esdi_at */ extern const device_t esdi_ps2_device; /* esdi_mca */ +extern const device_t xta_isa_device; /* xta_isa */ + +extern const device_t xtide_device; /* xtide_xt */ +extern const device_t xtide_acculogic_device; /* xtide_ps2 */ + extern const device_t ide_isa_device; /* isa_ide */ extern const device_t ide_isa_2ch_device; /* isa_ide_2ch */ extern const device_t ide_isa_2ch_opt_device; /* isa_ide_2ch_opt */ @@ -66,9 +75,7 @@ extern const device_t ide_vlb_2ch_device; /* vlb_ide_2ch */ extern const device_t ide_pci_device; /* pci_ide */ extern const device_t ide_pci_2ch_device; /* pci_ide_2ch */ -extern const device_t xtide_device; /* xtide_xt */ extern const device_t xtide_at_device; /* xtide_at */ -extern const device_t xtide_acculogic_device; /* xtide_ps2 */ extern const device_t xtide_at_ps2_device; /* xtide_at_ps2 */ #endif diff --git a/src/disk/hdc_mfm_xt.c b/src/disk/hdc_mfm_xt.c index c5c5363..6ae12a2 100644 --- a/src/disk/hdc_mfm_xt.c +++ b/src/disk/hdc_mfm_xt.c @@ -41,7 +41,7 @@ * Since all controllers (including the ones made by DTC) use * (mostly) the same API, we keep them all in this module. * - * Version: @(#)hdc_mfm_xt.c 1.0.5 2018/04/02 + * Version: @(#)hdc_mfm_xt.c 1.0.6 2018/04/18 * * Authors: Fred N. van Kempen, * Sarah Walker, @@ -806,10 +806,10 @@ loadhd(mfm_t *dev, int c, int d, const wchar_t *fn) return; } - drive->spt = (uint8_t)hdd[c].spt; - drive->hpc = (uint8_t)hdd[c].hpc; - drive->tracks = (uint16_t)hdd[c].tracks; - drive->hdd_num = c; + drive->spt = (uint8_t)hdd[d].spt; + drive->hpc = (uint8_t)hdd[d].hpc; + drive->tracks = (uint16_t)hdd[d].tracks; + drive->hdd_num = d; drive->present = 1; } @@ -874,7 +874,7 @@ mfm_init(const device_t *info) #ifdef ENABLE_HDC_LOG hdc_log("Found MFM hard disk on channel %i\n", hdd[i].mfm_channel); #endif - loadhd(dev, i, hdd[i].mfm_channel, hdd[i].fn); + loadhd(dev, hdd[i].mfm_channel, i, hdd[i].fn); if (++c > MFM_NUM) break; } diff --git a/src/disk/hdd.h b/src/disk/hdd.h index 5134999..5fb96d1 100644 --- a/src/disk/hdd.h +++ b/src/disk/hdd.h @@ -8,7 +8,7 @@ * * Definitions for the hard disk image handler. * - * Version: @(#)hdd.h 1.0.4 2018/04/02 + * Version: @(#)hdd.h 1.0.5 2018/04/12 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -53,6 +53,8 @@ enum { HDD_BUS_SCSI_REMOVABLE, HDD_BUS_USB }; +#define HDD_BUS_IDE HDD_BUS_IDE_PIO_ONLY +#define HDD_BUS_EIDE HDD_BUS_IDE_PIO_AND_DMA /* Define a hard disk table entry. */ diff --git a/src/emu.h b/src/emu.h index 78cf473..8b58bea 100644 --- a/src/emu.h +++ b/src/emu.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)emu.h 1.0.17 2018/04/10 + * Version: @(#)emu.h 1.0.18 2018/04/14 * * Author: Fred N. van Kempen, * @@ -91,20 +91,24 @@ extern wchar_t log_path[1024]; /* (O) full path of logfile */ /* Configuration variables. */ extern int window_w, window_h, /* (C) window size and */ window_x, window_y, /* position info */ - window_remember, + window_remember; +extern int vid_api, /* (C) video renderer */ vid_resize, /* (C) allow resizing */ + vid_cga_contrast, /* (C) video */ + vid_fullscreen, /* (C) video */ + vid_fullscreen_first, /* (C) video */ + vid_fullscreen_scale, /* (C) video */ + vid_grayscale, /* (C) video */ + vid_graytype, /* (C) video */ invert_display, /* (C) invert the display */ - suppress_overscan; /* (C) suppress overscans */ -extern int scale; /* (C) screen scale factor */ -extern int vid_api; /* (C) video renderer */ -extern int vid_cga_contrast, /* (C) video */ - video_fullscreen, /* (C) video */ - video_fullscreen_first, /* (C) video */ - video_fullscreen_scale, /* (C) video */ + suppress_overscan, /* (C) suppress overscans */ + scale, /* (C) screen scale factor */ enable_overscan, /* (C) video */ - force_43, /* (C) video */ - vid_card, /* (C) graphics/video card */ - video_speed; /* (C) video */ + force_43; /* (C) video */ +extern int video_card, /* (C) graphics/video card */ + video_speed, /* (C) video option */ + voodoo_enabled; /* (C) video option */ +extern int mouse_type; /* (C) selected mouse type */ extern int enable_sync; /* (C) enable time sync */ extern int serial_enabled[], /* (C) enable serial ports */ parallel_enabled[], /* (C) enable LPT ports */ @@ -116,10 +120,13 @@ extern int update_icons; /* (C) enable icons updates */ extern int romdos_enabled; /* (C) enable ROM DOS */ #endif extern int hdc_type; /* (C) HDC type */ -extern int sound_is_float, /* (C) sound uses FP values */ +extern int scsi_card; /* (C) selected SCSI card */ +extern int sound_card, /* (C) selected sound card */ + sound_is_float, /* (C) sound uses FP values */ + sound_gain, /* (C) sound volume gain */ mpu401_standalone_enable, /* (C) sound option */ opl3_type, /* (C) sound option */ - voodoo_enabled; /* (C) video option */ + midi_device; /* (C) selected midi device */ extern int joystick_type; /* (C) joystick type */ extern int mem_size; /* (C) memory size */ extern int cpu_manufacturer, /* (C) cpu manufacturer */ diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index eb12382..0394ee1 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.5 2018/03/16 + * Version: @(#)fdc.c 1.0.7 2018/04/12 * * Authors: Miran Grca, * Sarah Walker, @@ -60,58 +60,57 @@ extern int64_t motoron[FDD_NUM]; -const int command_has_drivesel[256] = { - 0, 0, - 1, /* READ TRACK */ - 0, - 1, /* SENSE DRIVE STATUS */ - 1, /* WRITE DATA */ - 1, /* READ DATA */ - 1, /* RECALIBRATE */ - 0, - 1, /* WRITE DELETED DATA */ - 1, /* READ ID */ - 0, - 1, /* READ DELETED DATA */ - 1, /* FORMAT TRACK */ - 0, - 1, /* SEEK, RELATIVE SEEK */ - 0, - 1, /* SCAN EQUAL */ - 0, 0, 0, 0, - 1, /* VERIFY */ - 0, 0, 0, - 1, /* SCAN LOW OR EQUAL */ - 0, 0, 0, - 1, /* SCAN HIGH OR EQUAL */ - 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +static const int command_has_drivesel[256] = { + 0, 0, + 1, /* READ TRACK */ + 0, + 1, /* SENSE DRIVE STATUS */ + 1, /* WRITE DATA */ + 1, /* READ DATA */ + 1, /* RECALIBRATE */ + 0, + 1, /* WRITE DELETED DATA */ + 1, /* READ ID */ + 0, + 1, /* READ DELETED DATA */ + 1, /* FORMAT TRACK */ + 0, + 1, /* SEEK, RELATIVE SEEK */ + 0, + 1, /* SCAN EQUAL */ + 0, 0, 0, 0, + 1, /* VERIFY */ + 0, 0, 0, + 1, /* SCAN LOW OR EQUAL */ + 0, 0, 0, + 1, /* SCAN HIGH OR EQUAL */ + 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -uint8_t current_drive = 0; +uint8_t current_drive = 0; +//int timetolive; +int lastbyte = 0; +int floppymodified[FDD_NUM]; +int floppyrate[FDD_NUM]; +#ifdef ENABLE_FDC_LOG +int fdc_do_log = ENABLE_FDC_LOG; +#endif + static void fdc_callback(void *priv); -int timetolive; -int lastbyte=0; - -int floppymodified[4]; -int floppyrate[4]; - -#ifdef ENABLE_FDC_LOG -int fdc_do_log = ENABLE_FDC_LOG; -#endif static void @@ -134,24 +133,24 @@ uint8_t fdc_ps1_525(void) { if ((romset == ROM_IBMPS1_2011) && fdd_is_525(current_drive)) - return 0x40; - else - return 0; + return(0x40); + + return(0); } void -fdc_ctrl_reset(void *p) +fdc_ctrl_reset(void *priv) { - fdc_t *fdc = (fdc_t *) p; + fdc_t *fdc = (fdc_t *)priv; fdc->stat = 0x80; - fdc->pnum = fdc->ptot=0; + fdc->pnum = fdc->ptot = 0; fdc->st0 = 0; fdc->lock = 0; fdc->head = 0; fdc->abort = 0; - if (!(fdc->flags & FDC_FLAG_AT)) + if (! (fdc->flags & FDC_FLAG_AT)) fdc->rate = 2; } @@ -159,7 +158,7 @@ fdc_ctrl_reset(void *p) sector_id_t fdc_get_read_track_sector(fdc_t *fdc) { - return fdc->read_track_sector; + return(fdc->read_track_sector); } @@ -169,11 +168,13 @@ fdc_get_compare_condition(fdc_t *fdc) switch (fdc->interrupt) { case 0x11: default: - return 0; + return(0); + case 0x19: - return 1; + return(1); + case 0x1D: - return 2; + return(2); } } @@ -181,14 +182,14 @@ fdc_get_compare_condition(fdc_t *fdc) int fdc_is_deleted(fdc_t *fdc) { - return fdc->deleted & 1; + return(fdc->deleted & 1); } int fdc_is_sk(fdc_t *fdc) { - return (fdc->deleted & 0x20) ? 1 : 0; + return((fdc->deleted & 0x20) ? 1 : 0); } @@ -202,7 +203,7 @@ fdc_set_wrong_am(fdc_t *fdc) int fdc_get_drive(fdc_t *fdc) { - return fdc->drive; + return(fdc->drive); } @@ -214,10 +215,10 @@ static void fdc_rate(fdc_t *fdc, int drive); int fdc_get_perp(fdc_t *fdc) { - if (!(fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_PCJR) || (fdc->flags & FDC_FLAG_PS1)) - return 0; + if (!(fdc->flags & FDC_FLAG_AT) || + (fdc->flags & FDC_FLAG_PCJR) || (fdc->flags & FDC_FLAG_PS1)) return(0); - return fdc->perp; + return(fdc->perp); } @@ -226,29 +227,29 @@ fdc_get_gap2(fdc_t *fdc, int drive) { int auto_gap2 = 22; - if (!(fdc->flags & FDC_FLAG_AT) || (fdc->flags & FDC_FLAG_PCJR) || (fdc->flags & FDC_FLAG_PS1)) - return 22; + if (!(fdc->flags & FDC_FLAG_AT) || + (fdc->flags & FDC_FLAG_PCJR) || (fdc->flags & FDC_FLAG_PS1)) return(22); if (fdc->perp & 3) - return ((fdc->perp & 3) == 3) ? 41 : 22; - else { - auto_gap2 = (fdc_get_bit_rate(fdc) >= 3) ? 41 : 22; - return (fdc->perp & (4 << drive)) ? auto_gap2 : 22; - } + return(((fdc->perp & 3) == 3) ? 41 : 22); + + auto_gap2 = (fdc_get_bit_rate(fdc) >= 3) ? 41 : 22; + + return((fdc->perp & (4 << drive)) ? auto_gap2 : 22); } int fdc_get_format_n(fdc_t *fdc) { - return fdc->format_n; + return(fdc->format_n); } int fdc_is_mfm(fdc_t *fdc) { - return fdc->mfm ? 1 : 0; + return(fdc->mfm ? 1 : 0); } @@ -272,28 +273,29 @@ fdc_stop_id_request(fdc_t *fdc) int fdc_get_gap(fdc_t *fdc) { - return fdc->gap; + return(fdc->gap); } int fdc_get_dtl(fdc_t *fdc) { - return fdc->dtl; + return(fdc->dtl); } int fdc_get_format_sectors(fdc_t *fdc) { - return fdc->format_sectors; + return(fdc->format_sectors); } static void fdc_reset_fifo_buf(fdc_t *fdc) { - memset(fdc->fifobuf, 0, 16); + memset(fdc->fifobuf, 0x00, 16); + fdc->fifobufpos = 0; } @@ -319,16 +321,18 @@ fdc_fifo_buf_write(fdc_t *fdc, uint8_t val) static int fdc_fifo_buf_read(fdc_t *fdc) { - int temp = fdc->fifobuf[fdc->fifobufpos]; + int ret = fdc->fifobuf[fdc->fifobufpos]; + fdc_fifo_buf_advance(fdc); - if (!fdc->fifobufpos) + if (fdc->fifobufpos == 0) fdc->data_ready = 0; - return temp; + + return(ret); } -static -void fdc_int(fdc_t *fdc) +static void +fdc_int(fdc_t *fdc) { int ienable = 0; @@ -345,7 +349,7 @@ void fdc_int(fdc_t *fdc) static void fdc_watchdog_poll(void *priv) { - fdc_t *fdc = (fdc_t *) priv; + fdc_t *fdc = (fdc_t *)priv; fdc->watchdog_count--; if (fdc->watchdog_count) @@ -358,16 +362,18 @@ fdc_watchdog_poll(void *priv) } -/* fdc->rwc per Winbond W83877F datasheet: - 0 = normal; - 1 = 500 kbps, 360 rpm; - 2 = 500 kbps, 300 rpm; - 3 = 250 kbps - - Drive is only aware of selected rate and densel, so on real hardware, the rate expected by fdc_t and the rate actually being - processed by drive can mismatch, in which case the fdc_t won't receive the correct data. -*/ - +/* + * fdc->rwc per Winbond W83877F datasheet: + * + * 0 = normal; + * 1 = 500 kbps, 360 rpm; + * 2 = 500 kbps, 300 rpm; + * 3 = 250 kbps + * + * Drive is only aware of selected rate and densel, so on real hardware, the + * rate expected by fdc_t and the rate actually being processed by drive + * can mismatch, in which case the fdc_t won't receive the correct data. + */ void fdc_update_rates(fdc_t *fdc) { @@ -382,12 +388,15 @@ void fdc_update_is_nsc(fdc_t *fdc, int is_nsc) { int old_is_nsc = fdc->flags & FDC_FLAG_NSC; + if (is_nsc) fdc->flags |= FDC_FLAG_NSC; - else + else fdc->flags &= ~FDC_FLAG_NSC; + if ((old_is_nsc ^ fdc->flags) & FDC_FLAG_NSC) fdc->densel_force = fdc->densel_force ^ 3; + fdc_update_rates(fdc); } @@ -410,7 +419,7 @@ fdc_update_enh_mode(fdc_t *fdc, int enh_mode) int fdc_get_rwc(fdc_t *fdc, int drive) { - return fdc->rwc[drive]; + return(fdc->rwc[drive]); } @@ -426,7 +435,7 @@ fdc_update_rwc(fdc_t *fdc, int drive, int rwc) int fdc_get_boot_drive(fdc_t *fdc) { - return fdc->boot_drive; + return(fdc->boot_drive); } @@ -449,7 +458,7 @@ fdc_update_densel_polarity(fdc_t *fdc, int densel_polarity) uint8_t fdc_get_densel_polarity(fdc_t *fdc) { - return fdc->densel_polarity; + return(fdc->densel_polarity); } @@ -489,56 +498,75 @@ fdc_update_rate(fdc_t *fdc, int drive) case 0: /*High density*/ fdc->bit_rate = 500; break; + case 1: /*Double density (360 rpm)*/ switch(fdc->drvrate[drive]) { case 0: fdc->bit_rate = 300; break; + case 1: fdc->bit_rate = 500; break; + case 2: fdc->bit_rate = 2000; break; } break; + case 2: /*Double density*/ fdc->bit_rate = 250; break; + case 3: /*Extended density*/ fdc->bit_rate = 1000; break; } - fdc->bitcell_period = 1000000 / fdc->bit_rate * 2; /*Bitcell period in ns*/ + /*Bitcell period in ns*/ + fdc->bitcell_period = 1000000 / fdc->bit_rate * 2; } int fdc_get_bit_rate(fdc_t *fdc) { + int ret = 2; + switch(fdc->bit_rate) { case 500: - return 0; + ret = 0; + break; + case 300: - return 1; + ret = 1; + break; + case 2000: - return 1 | 4; + ret = 1 | 4; + break; + case 250: - return 2; + ret = 2; + break; + case 1000: - return 3; + ret = 3; + break; + default: - return 2; + break; } - return 2; + + return(ret); } int fdc_get_bitcell_period(fdc_t *fdc) { - return fdc->bitcell_period; + return(fdc->bitcell_period); } @@ -549,38 +577,42 @@ fdc_get_densel(fdc_t *fdc, int drive) switch (fdc->rwc[drive]) { case 1: case 3: - return 0; + return(0); + case 2: - return 1; + return(1); } } if (!(fdc->flags & FDC_FLAG_NSC)) { switch (fdc->densel_force) { case 2: - return 1; + return(1); + case 3: - return 0; + return(0); } } else { switch (fdc->densel_force) { case 0: - return 0; + return(0); + case 1: - return 1; + return(1); } } switch (fdc->rate) { case 0: case 3: - return fdc->densel_polarity ? 1 : 0; + return(fdc->densel_polarity ? 1 : 0); + case 1: case 2: - return fdc->densel_polarity ? 0 : 1; + return(fdc->densel_polarity ? 0 : 1); } - return 0; + return(0); } @@ -588,8 +620,14 @@ static void fdc_rate(fdc_t *fdc, int drive) { fdc_update_rate(fdc, drive); + fdd_set_rate(drive, fdc->drvrate[drive], fdc->rate); - fdc_log("FDD %c: Setting rate: %i, %i, %i (%i, %i)\n", 0x41 + drive, fdc->drvrate[drive], fdc->rate, fdc_get_densel(fdc, drive), fdc->rwc[drive], fdc->densel_force); + + fdc_log("FDD %c: Setting rate: %i, %i, %i (%i, %i)\n", + 0x41 + drive, fdc->drvrate[drive], fdc->rate, + fdc_get_densel(fdc, drive), + fdc->rwc[drive], fdc->densel_force); + fdd_set_densel(fdc_get_densel(fdc, drive)); } @@ -598,9 +636,9 @@ int real_drive(fdc_t *fdc, int drive) { if (drive < 2) - return drive ^ fdc->swap; - else - return drive; + return(drive ^ fdc->swap); + + return(drive); } @@ -668,7 +706,7 @@ fdc_sis(fdc_t *fdc) { int drive_num; - fdc->stat = (fdc->stat & 0xf) | 0xd0; + fdc->stat = (fdc->stat & 0xf) | 0xd0; if (fdc->reset_stat) { drive_num = real_drive(fdc, 4 - fdc->reset_stat); @@ -709,11 +747,11 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) cycles -= ISA_CYCLES(8); - switch (addr&7) { - case 0: - return; - case 1: + switch (addr & 7) { + case 0: /*STA*/ + case 1: /*STB*/ return; + case 2: /*DOR*/ if ((fdc->flags & FDC_FLAG_PCJR)) { if ((fdc->dor & 0x40) && !(val & 0x40)) { @@ -739,16 +777,16 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->tc = 1; fdc_int(fdc); } - if (!(val&4)) { + if (! (val & 4)) { fdd_stop(real_drive(fdc, val & 3)); fdc->stat = 0x00; fdc->pnum = fdc->ptot = 0; } - if (val&4) { + if (val & 4) { fdc->stat = 0x80; fdc->pnum = fdc->ptot = 0; } - if ((val&4) && !(fdc->dor&4)) { + if ((val & 4) && !(fdc->dor & 4)) { timer_clock(); fdc->time = 128LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); @@ -762,7 +800,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } timer_clock(); timer_update_outstanding(); - /* We can now simplify this since each motor now spins separately. */ + /* We simplify this since each motor now spins separately. */ for (i = 0; i < FDD_NUM; i++) { drive_num = real_drive(fdc, i); if ((!fdd_get_flags(drive_num)) || (drive_num >= FDD_NUM)) @@ -776,14 +814,16 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->st0 |= real_drive(fdc, drive_num); fdc->st0 |= (fdd_get_head(drive_num) ? 4 : 0); } - fdc->dor=val; + fdc->dor = val; return; + case 3: /* TDR */ if (fdc->enh_mode) { drive = real_drive(fdc, fdc->dor & 3); fdc_update_rwc(fdc, drive, (val & 0x30) >> 4); } return; + case 4: if (val & 0x80) { timer_clock(); @@ -794,6 +834,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_ctrl_reset(fdc); } return; + case 5: /*Command register*/ if ((fdc->stat & 0xf0) == 0xb0) { if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo) { @@ -834,6 +875,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } else fdc_bad_command(fdc); break; + case 0x02: /*Read track*/ fdc->satisfying_sectors = 0; fdc->sc = 0; @@ -844,16 +886,19 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->pos = 0; fdc->mfm = (fdc->command & 0x40) ? 1:0; break; + case 0x03: /*Specify*/ fdc->pnum = 0; fdc->ptot = 2; fdc->stat |= 0x90; break; + case 0x04: /*Sense drive status*/ fdc->pnum = 0; fdc->ptot = 1; fdc->stat |= 0x90; break; + case 0x05: /*Write data*/ case 0x09: /*Write deleted data*/ fdc->satisfying_sectors = 0; @@ -866,6 +911,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->pos = 0; fdc->mfm = (fdc->command & 0x40) ? 1 : 0; break; + case 0x06: /*Read data*/ case 0x0c: /*Read deleted data*/ case 0x11: /*Scan equal*/ @@ -885,16 +931,18 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->mfm = (fdc->command&0x40)?1:0; break; case 0x07: /*Recalibrate*/ - fdc->pnum=0; - fdc->ptot=1; + fdc->pnum = 0; + fdc->ptot = 1; fdc->stat |= 0x90; break; + case 0x08: /*Sense interrupt status*/ fdc_log("fdc->fintr = %i, fdc->reset_stat = %i\n", fdc->fintr, fdc->reset_stat); fdc->lastdrive = fdc->drive; fdc->pos = 0; fdc_sis(fdc); break; + case 0x0a: /*Read sector ID*/ fdc->pnum = 0; fdc->ptot = 1; @@ -902,6 +950,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->pos = 0; fdc->mfm = (fdc->command & 0x40) ? 1 : 0; break; + case 0x0d: /*Format track*/ fdc->pnum = 0; fdc->ptot = 5; @@ -910,22 +959,26 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->mfm = (fdc->command & 0x40) ? 1:0; fdc->format_state = 0; break; + case 0x0e: /*Dump registers*/ fdc->lastdrive = fdc->drive; fdc->interrupt = 0x0e; fdc->pos = 0; fdc_callback(fdc); break; + case 0x0f: /*Seek*/ fdc->pnum = 0; fdc->ptot = 2; fdc->stat |= 0x90; break; + case 0x18: /*NSC*/ if (!(fdc->flags & FDC_FLAG_NSC)) { fdc_bad_command(fdc); break; } + case 0x10: /*Get version*/ case 0x14: /*Unlock*/ case 0x94: /*Lock*/ @@ -934,21 +987,24 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->pos = 0; fdc_callback(fdc); break; + case 0x12: /*Set perpendicular mode*/ if ((fdc->flags & FDC_FLAG_AT) && !(fdc->flags & FDC_FLAG_PCJR) && !(fdc->flags & FDC_FLAG_PS1)) { - fdc->pnum=0; - fdc->ptot=1; + fdc->pnum = 0; + fdc->ptot = 1; fdc->stat |= 0x90; - fdc->pos=0; + fdc->pos = 0; } else fdc_bad_command(fdc); break; + case 0x13: /*Configure*/ - fdc->pnum=0; - fdc->ptot=3; + fdc->pnum = 0; + fdc->ptot = 3; fdc->stat |= 0x90; - fdc->pos=0; + fdc->pos = 0; break; + default: fdc_bad_command(fdc); break; @@ -960,14 +1016,14 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) if (command_has_drivesel[fdc->command & 0x1F]) { if (fdc->flags & FDC_FLAG_PCJR) fdc->drive = 0; - else + else fdc->drive = fdc->dor & 3; fdc->rw_drive = fdc->params[0] & 3; if (((fdc->command & 0x1F) == 7) || ((fdc->command & 0x1F) == 15)) fdc->stat |= (1 << real_drive(fdc, fdc->drive)); } } - if (fdc->pnum==fdc->ptot) { + if (fdc->pnum == fdc->ptot) { fdc_log("Got all params %02X\n", fdc->command); fdc->interrupt = fdc->command & 0x1F; timer_clock(); @@ -983,6 +1039,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->read_track_sector.id.n = fdc->params[4]; fdd_readsector(real_drive(fdc, fdc->drive), SECTOR_FIRST, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]); break; + case 3: /*Specify*/ fdc->stat=0x80; fdc->specify[0] = fdc->params[0]; @@ -990,6 +1047,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->dma = (fdc->specify[1] & 1) ^ 1; fdc->time = 0LL; break; + case 0x12: fdc->stat=0x80; if (fdc->params[0] & 0x80) @@ -1000,20 +1058,24 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } fdc->time = 0LL; return; + case 4: fdd_set_head(real_drive(fdc, fdc->drive), (fdc->params[0] & 4) ? 1 : 0); break; + case 5: /*Write data*/ case 9: /*Write deleted data*/ fdc_io_command_phase1(fdc, 1); fdd_writesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]); break; + case 0x11: /*Scan equal*/ case 0x19: /*Scan low or equal*/ case 0x1D: /*Scan high or equal*/ fdc_io_command_phase1(fdc, 1); fdd_comparesector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]); break; + case 0x16: /*Verify*/ if (fdc->params[0] & 0x80) fdc->sc = fdc->params[7]; @@ -1029,7 +1091,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) } fdd_readsector(real_drive(fdc, fdc->drive), fdc->sector, fdc->params[1], fdc->head, fdc->rate, fdc->params[4]); break; - + case 7: /*Recalibrate*/ fdc->stat = (1 << real_drive(fdc, fdc->drive)) | 0x80; fdc->st0 = fdc->drive & 0x03; @@ -1056,6 +1118,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_log("Recalibrating...\n"); fdc->time = 5000LL; break; + case 0x0d: /*Format*/ fdc_rate(fdc, fdc->drive); fdc->head = (fdc->params[0] & 4) ? 1 : 0; @@ -1068,6 +1131,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->pos = 0; fdc->stat = 0x10; break; + case 0xf: /*Seek*/ fdc->stat = (1 << fdc->drive) | 0x80; fdc->head = (fdc->params[0] & 4) ? 1 : 0; @@ -1131,6 +1195,7 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_log("fdc->time = %i\n", fdc->time); } break; + case 10: /*Read sector ID*/ fdc_rate(fdc, fdc->drive); fdc->time = 0LL; @@ -1151,10 +1216,11 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) fdc->stat = 0x90 | (fdc->stat & 0xf); } return; + case 7: - if (!(fdc->flags & FDC_FLAG_AT)) + if (! (fdc->flags & FDC_FLAG_AT)) return; - fdc->rate=val&3; + fdc->rate = val & 3; return; } } @@ -1163,26 +1229,29 @@ fdc_write(uint16_t addr, uint8_t val, void *priv) uint8_t fdc_read(uint16_t addr, void *priv) { - fdc_t *fdc = (fdc_t *) priv; - uint8_t ret; + fdc_t *fdc = (fdc_t *)priv; + uint8_t ret = 0xff; int drive; cycles -= ISA_CYCLES(8); switch (addr&7) { case 0: /* STA */ - ret = 0xff; + ret = 0x7f; + if (fdc->fintr || fdc->reset_stat) + ret |= 0x80; break; + case 1: /* STB */ if (is486) - return 0xff; + break; drive = real_drive(fdc, fdc->dor & 3); - if (!fdc->enable_3f1) - ret = 0xff; + if (! fdc->enable_3f1) + break; ret = 0x70; if (drive) ret &= ~0x40; - else + else ret &= ~0x20; if (fdc->dor & 0x10) @@ -1190,13 +1259,15 @@ fdc_read(uint16_t addr, void *priv) if (fdc->dor & 0x20) ret |= 2; break; + case 2: ret = fdc->dor; break; + case 3: drive = real_drive(fdc, fdc->dor & 3); if (fdc->flags & FDC_FLAG_PS1) { - /* PS/1 Model 2121 seems return drive type in port + /* PS/1 Model 2121 seems to return drive type in port * 0x3f3, despite the 82077AA fdc_t not implementing * this. This is presumably implemented outside the * fdc_t on one of the motherboard's support chips. @@ -1204,24 +1275,26 @@ fdc_read(uint16_t addr, void *priv) * Confirmed: 00=1.44M 3.5 * 10=2.88M 3.5 * 20=1.2M 5.25 - * 30=1.2M 5.25 + * 30=360K 5.25 ? sometimes works... * * as reported by Configur.exe. */ - if (fdd_is_525(drive)) - ret = 0x20; - else if (fdd_is_ed(drive)) - ret = 0x10; - else - ret = 0x00; + if (fdd_is_525(drive)) { + ret = 0x20; /* 5.25 360/1.2 */ + } else if (fdd_is_ed(drive)) + ret = 0x10; /* 3.5 2.88M ED */ + else + ret = 0x00; /* 3.5 1.44M HD */ } else if (!fdc->enh_mode) ret = 0x20; - else + else ret = fdc->rwc[drive] << 4; break; + case 4: /*Status*/ ret = fdc->stat; break; + case 5: /*Data*/ if ((fdc->stat & 0xf0) == 0xf0) { fdc->stat &= ~0x80; @@ -1250,27 +1323,32 @@ fdc_read(uint16_t addr, void *priv) } fdc->stat &= 0xf0; break; + case 7: /*Disk change*/ drive = real_drive(fdc, fdc->dor & 3); if (fdc->dor & (0x10 << drive)) ret = (fdd_changed[drive] || drive_empty[drive])?0x80:0; - else + else ret = 0; - if (fdc->flags & FDC_FLAG_DISKCHG_ACTLOW) /*PC2086/3086 seem to reverse this bit*/ + if (fdc->flags & FDC_FLAG_DISKCHG_ACTLOW) ret ^= 0x80; ret |= 0x01; break; + default: - ret = 0xFF; + break; } fdc_log("Read FDC %04X %02X\n", addr, ret); - return ret; + + return(ret); } + static void fdc_poll_common_finish(fdc_t *fdc, int compare, int st5) { fdc_int(fdc); + fdc->fintr = 0; fdc->stat = 0xD0; fdc->st0 = fdc->res[4] = (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->rw_drive; @@ -1280,6 +1358,7 @@ fdc_poll_common_finish(fdc_t *fdc, int compare, int st5) fdc->res[6] |= 0x40; fdc->wrong_am = 0; } + if (compare == 1) { if (!fdc->satisfying_sectors) fdc->res[6] |= 4; @@ -1335,30 +1414,35 @@ fdc_no_dma_end(fdc_t *fdc, int compare) static void fdc_callback(void *priv) { - fdc_t *fdc = (fdc_t *) priv; + fdc_t *fdc = (fdc_t *)priv; int compare = 0; int drive_num = 0; int old_sector = 0; fdc->time = 0LL; + fdc_log("fdc_callback(): %i\n", fdc->interrupt); switch (fdc->interrupt) { case -3: /*End of command with interrupt*/ fdc_int(fdc); fdc->stat = (fdc->stat & 0xf) | 0x80; return; + case -2: /*End of command*/ fdc->stat = (fdc->stat & 0xf) | 0x80; return; + case -1: /*Reset*/ fdc_int(fdc); fdc->fintr = 0; memset(fdc->pcn, 0, 4 * sizeof(int)); fdc->reset_stat = 4; return; + case 1: /*Mode*/ fdc->stat=0x80; fdc->densel_force = (fdc->params[2] & 0xC0) >> 6; return; + case 2: /*Read track*/ ui_sb_update_icon(SB_FLOPPY | fdc->drive, 1); fdc->eot[fdc->drive]--; @@ -1375,6 +1459,7 @@ fdc_callback(void *priv) } fdc->inread = 1; return; + case 4: /*Sense drive status*/ fdc->res[10] = (fdc->params[0] & 7) | 0x28; if ((real_drive(fdc, fdc->drive) != 1) || fdc->drv2en) { @@ -1389,6 +1474,7 @@ fdc_callback(void *priv) fdc->interrupt = 0; fdc->time = 0LL; return; + case 5: /*Write data*/ case 9: /*Write deleted data*/ case 6: /*Read data*/ @@ -1506,6 +1592,7 @@ fdc_callback(void *priv) } fdc->inread = 1; return; + case 7: /*Recalibrate*/ fdc->pcn[fdc->params[0] & 3] = 0; drive_num = real_drive(fdc, fdc->rw_drive); @@ -1518,6 +1605,7 @@ fdc_callback(void *priv) timer_update_outstanding(); fdc->stat = 0x80 | (1 << fdc->drive); return; + case 0x0d: /*Format track*/ if (fdc->format_state == 1) { fdc->format_state = 2; @@ -1543,6 +1631,7 @@ fdc_callback(void *priv) return; } return; + case 0x0e: /*Dump registers*/ fdc->stat = (fdc->stat & 0xf) | 0xd0; fdc->res[1] = fdc->pcn[0]; @@ -1559,6 +1648,7 @@ fdc_callback(void *priv) fdc->interrupt = 0; fdc->time = 0LL; return; + case 0x0f: /*Seek*/ drive_num = real_drive(fdc, fdc->rw_drive); fdc->st0 = 0x20 | (fdc->params[0] & 7); @@ -1569,6 +1659,7 @@ fdc_callback(void *priv) fdc->stat = 0x80 | (1 << fdc->drive); fdc_callback(fdc); return; + case 0x10: /*Version*/ case 0x18: /*NSC*/ fdc->stat = (fdc->stat & 0xf) | 0xd0; @@ -1577,6 +1668,7 @@ fdc_callback(void *priv) fdc->interrupt = 0; fdc->time = 0LL; return; + case 0x13: /*Configure*/ fdc->config = fdc->params[1]; fdc->pretrk = fdc->params[2]; @@ -1585,6 +1677,7 @@ fdc_callback(void *priv) fdc->stat = 0x80; fdc->time = 0LL; return; + case 0x14: /*Unlock*/ case 0x94: /*Lock*/ fdc->lock = (fdc->interrupt & 0x80) ? 1 : 0; @@ -1594,6 +1687,7 @@ fdc_callback(void *priv) fdc->interrupt = 0; fdc->time = 0LL; return; + case 0xfc: /*Invalid*/ fdc->dat = fdc->st0 = 0x80; fdc->stat = (fdc->stat & 0xf) | 0xd0; @@ -1612,11 +1706,13 @@ fdc_error(fdc_t *fdc, int st5, int st6) fdc->time = 0LL; fdc_int(fdc); + fdc->fintr = 0; fdc->stat = 0xD0; fdc->st0 = fdc->res[4] = 0x40 | (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->rw_drive; fdc->res[5] = st5; fdc->res[6] = st6; + fdc_log("FDC Error: %02X %02X %02X\n", fdc->res[4], fdc->res[5], fdc->res[6]); switch(fdc->interrupt) { case 0x02: @@ -1633,6 +1729,7 @@ fdc_error(fdc_t *fdc, int st5, int st6) fdc->res[9]=fdc->sector; fdc->res[10]=fdc->params[4]; break; + default: fdc->res[7]=0; fdc->res[8]=0; @@ -1640,8 +1737,9 @@ fdc_error(fdc_t *fdc, int st5, int st6) fdc->res[10]=0; break; } - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); fdc->paramstogo = 7; + + ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); } @@ -1657,7 +1755,7 @@ fdc_overrun(fdc_t *fdc) int fdc_is_verify(fdc_t *fdc) { - return (fdc->deleted & 2) ? 1 : 0; + return((fdc->deleted & 2) ? 1 : 0); } @@ -1668,16 +1766,16 @@ fdc_data(fdc_t *fdc, uint8_t data) if (fdc->deleted & 2) { /* We're in a VERIFY command, so return with 0. */ - return 0; + return(0); } if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) { if (fdc->tc) - return 0; + return(0); if (fdc->data_ready) { fdc_overrun(fdc); - return -1; + return(-1); } if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo || (fdc->tfifo < 1)) { @@ -1697,13 +1795,13 @@ fdc_data(fdc_t *fdc, uint8_t data) result = dma_channel_write(fdc->dma_ch, data); if (fdc->tc) - return -1; + return(-1); if (result & DMA_OVER) { fdc->data_ready = 1; fdc->stat = 0xd0; fdc->tc = 1; - return -1; + return(-1); } if (!fdc->fifo || (fdc->tfifo < 1)) { @@ -1719,14 +1817,14 @@ fdc_data(fdc_t *fdc, uint8_t data) } } - return 0; + return(0); } void fdc_finishread(fdc_t *fdc) { - fdc->inread = 0; + fdc->inread = 0; } @@ -1736,6 +1834,7 @@ fdc_track_finishread(fdc_t *fdc, int condition) fdc->stat = 0x10; fdc->satisfying_sectors |= condition; fdc->inread = 0; + fdc_callback(fdc); } @@ -1746,6 +1845,7 @@ fdc_sector_finishcompare(fdc_t *fdc, int satisfying) fdc->stat = 0x10; fdc->satisfying_sectors++; fdc->inread = 0; + fdc_callback(fdc); } @@ -1755,6 +1855,7 @@ fdc_sector_finishread(fdc_t *fdc) { fdc->stat = 0x10; fdc->inread = 0; + fdc_callback(fdc); } @@ -1768,22 +1869,27 @@ fdc_noidam(fdc_t *fdc) /* Sector ID's are there, but there is no sector. */ -void fdc_nosector(fdc_t *fdc) +void +fdc_nosector(fdc_t *fdc) { fdc_error(fdc, 4, 0); } /* There is no sector data. */ -void fdc_nodataam(fdc_t *fdc) +void +fdc_nodataam(fdc_t *fdc) { fdc_error(fdc, 1, 1); } -/* Abnormal termination with both status 1 and 2 set to 0, used when abnormally - terminating the fdc_t FORMAT TRACK command. */ -void fdc_cannotformat(fdc_t *fdc) +/* + * Abnormal termination with both status 1 and 2 set to 0, used + * when abnormally terminating the fdc_t FORMAT TRACK command. + */ +void +fdc_cannotformat(fdc_t *fdc) { fdc_error(fdc, 0, 0); } @@ -1824,14 +1930,15 @@ fdc_writeprotect(fdc_t *fdc) } -int fdc_getdata(fdc_t *fdc, int last) +int +fdc_getdata(fdc_t *fdc, int last) { int data; if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->dma) { if (fdc->written) { fdc_overrun(fdc); - return -1; + return(-1); } if ((fdc->flags & FDC_FLAG_PCJR) || !fdc->fifo) { data = fdc->dat; @@ -1860,9 +1967,9 @@ int fdc_getdata(fdc_t *fdc, int last) if (data & DMA_OVER) fdc->tc = 1; } - fdc->written = 0; - return data & 0xff; + + return(data & 0xff); } @@ -1870,6 +1977,7 @@ void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t size, uint8_t crc1, uint8_t crc2) { fdc_int(fdc); + fdc->stat = 0xD0; fdc->st0 = fdc->res[4] = (fdd_get_head(real_drive(fdc, fdc->drive)) ? 4 : 0) | fdc->drive; fdc->res[5] = 0; @@ -1878,15 +1986,16 @@ fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t si fdc->res[8] = side; fdc->res[9] = sector; fdc->res[10] = size; - ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); fdc->paramstogo = 7; + + ui_sb_update_icon(SB_FLOPPY | fdc->drive, 0); } uint8_t fdc_get_swwp(fdc_t *fdc) { - return fdc->swwp; + return(fdc->swwp); } @@ -1900,10 +2009,10 @@ fdc_set_swwp(fdc_t *fdc, uint8_t swwp) uint8_t fdc_get_diswr(fdc_t *fdc) { - if (!fdc) - return 0; + if (fdc == NULL) + return(0); - return fdc->disable_write; + return(fdc->disable_write); } @@ -1917,7 +2026,7 @@ fdc_set_diswr(fdc_t *fdc, uint8_t diswr) uint8_t fdc_get_swap(fdc_t *fdc) { - return fdc->swap; + return(fdc->swap); } @@ -1934,15 +2043,19 @@ fdc_set_base(fdc_t *fdc, int base) int super_io = (fdc->flags & FDC_FLAG_SUPERIO); if (fdc->flags & FDC_FLAG_AT) { - io_sethandler(base + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); - io_sethandler(base + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); + io_sethandler(base + (super_io ? 2 : 0), super_io ? 4 : 6, + fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); + io_sethandler(base+7, 1, + fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); } else { - io_sethandler(base + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc); - io_sethandler(base + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); - io_sethandler(base + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); + io_sethandler(base+2, 1, NULL,NULL,NULL, fdc_write,NULL,NULL, fdc); + io_sethandler(base+4, 1, fdc_read,NULL,NULL, NULL,NULL,NULL, fdc); + io_sethandler(base+5, 1, fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); } + fdc->base_address = base; - fdc_log("fdc_t Base address set%s (%04X)\n", super_io ? " for Super I/O" : "", fdc->base_address); + fdc_log("FDC: base address set%s (%04X)\n", + super_io ? " for Super I/O" : "", fdc->base_address); } @@ -1951,25 +2064,30 @@ fdc_remove(fdc_t *fdc) { int super_io = (fdc->flags & FDC_FLAG_SUPERIO); - fdc_log("fdc_t Removed (%04X)\n", fdc->base_address); if (fdc->flags & FDC_FLAG_AT) { - io_removehandler(fdc->base_address + (super_io ? 2 : 0), super_io ? 0x0004 : 0x0006, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); - io_removehandler(fdc->base_address + 7, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); + io_removehandler(fdc->base_address + (super_io?2:0), super_io?4:6, + fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); + io_removehandler(fdc->base_address+7, 1, + fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); } else { - io_removehandler(fdc->base_address + 0x0002, 0x0001, NULL, NULL, NULL, fdc_write, NULL, NULL, fdc); - io_removehandler(fdc->base_address + 0x0004, 0x0001, fdc_read, NULL, NULL, NULL, NULL, NULL, fdc); - io_removehandler(fdc->base_address + 0x0005, 0x0001, fdc_read, NULL, NULL, fdc_write, NULL, NULL, fdc); + io_removehandler(fdc->base_address+2, 1, + NULL,NULL,NULL, fdc_write,NULL,NULL, fdc); + io_removehandler(fdc->base_address+4, 1, + fdc_read,NULL,NULL, NULL,NULL,NULL, fdc); + io_removehandler(fdc->base_address+5, 1, + fdc_read,NULL,NULL, fdc_write,NULL,NULL, fdc); } + + fdc_log("FDC: removed (%04X)\n", fdc->base_address); } void fdc_reset(void *priv) { - int i = 0; + fdc_t *fdc = (fdc_t *)priv; uint8_t default_rwc; - - fdc_t *fdc = (fdc_t *) priv; + int i; default_rwc = (fdc->flags & FDC_FLAG_START_RWC_1) ? 1 : 0; @@ -2022,7 +2140,7 @@ fdc_reset(void *priv) static void fdc_close(void *priv) { - fdc_t *fdc = (fdc_t *) priv; + fdc_t *fdc = (fdc_t *)priv; fdc_reset(fdc); @@ -2039,8 +2157,9 @@ fdc_close(void *priv) static void * fdc_init(const device_t *info) { - fdc_t *fdc = (fdc_t *) malloc(sizeof(fdc_t)); - memset(fdc, 0, sizeof(fdc_t)); + fdc_t *fdc = (fdc_t *)malloc(sizeof(fdc_t)); + + memset(fdc, 0x00, sizeof(fdc_t)); fdc->flags = info->local; fdc_reset(fdc); @@ -2056,6 +2175,7 @@ fdc_init(const device_t *info) timer_add(fdc_callback, &fdc->time, &fdc->time, fdc); + /* FIXME: should be handled through table. */ d86f_set_fdc(fdc); fdi_set_fdc(fdc); fdd_set_fdc(fdc); @@ -2064,7 +2184,7 @@ fdc_init(const device_t *info) fdc_reset(fdc); - return fdc; + return(fdc); } @@ -2079,78 +2199,72 @@ const device_t fdc_xt_device = { "PC/XT Floppy Drive Controller", 0, 0, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_pcjr_device = { "PCjr Floppy Drive Controller", 0, FDC_FLAG_PCJR, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_device = { "PC/AT Floppy Drive Controller", 0, FDC_FLAG_AT, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_actlow_device = { "PC/AT Floppy Drive Controller (Active low)", 0, - FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + FDC_FLAG_AT|FDC_FLAG_DISKCHG_ACTLOW, + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_ps1_device = { "PC/AT Floppy Drive Controller (PS/1, PS/2 ISA)", 0, - FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT | FDC_FLAG_PS1, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + FDC_FLAG_AT|FDC_FLAG_PS1|FDC_FLAG_DISKCHG_ACTLOW, + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_smc_device = { "PC/AT Floppy Drive Controller (SM(s)C FDC37Cxxx)", 0, - FDC_FLAG_AT | FDC_FLAG_SUPERIO, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + FDC_FLAG_AT|FDC_FLAG_SUPERIO, + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_winbond_device = { "PC/AT Floppy Drive Controller (Winbond W83x77F)", 0, - FDC_FLAG_AT | FDC_FLAG_SUPERIO | FDC_FLAG_START_RWC_1 | FDC_FLAG_MORE_TRACKS, + FDC_FLAG_AT|FDC_FLAG_SUPERIO|FDC_FLAG_START_RWC_1|FDC_FLAG_MORE_TRACKS, fdc_init, fdc_close, fdc_reset, - NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, + NULL }; const device_t fdc_at_nsc_device = { "PC/AT Floppy Drive Controller (NSC PC8730x)", 0, - FDC_FLAG_AT | FDC_FLAG_MORE_TRACKS | FDC_FLAG_NSC, - fdc_init, - fdc_close, - fdc_reset, - NULL, NULL, NULL, NULL + FDC_FLAG_AT|FDC_FLAG_MORE_TRACKS|FDC_FLAG_NSC, + fdc_init, fdc_close, fdc_reset, + NULL, NULL, NULL, NULL, + NULL }; diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c index cd39169..3c28636 100644 --- a/src/machine/m_amstrad.c +++ b/src/machine/m_amstrad.c @@ -32,7 +32,7 @@ * BIOSES: I need to re-do the bios.txt format so we can load non-BIOS * ROM files for a given machine, such as font roms here.. * - * Version: @(#)m_amstrad.c 1.0.11 2018/04/09 + * Version: @(#)m_amstrad.c 1.0.12 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -1252,7 +1252,7 @@ machine_amstrad_init(const machine_t *model, void *arg) switch(model->id) { case ROM_PC1512: device_add(&fdc_xt_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { /* Load the PC1512 CGA Character Set ROM. */ loadfont(roms->fontfn, roms->fontnum); @@ -1264,7 +1264,7 @@ machine_amstrad_init(const machine_t *model, void *arg) case ROM_PC1640: device_add(&fdc_xt_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { /* Load the BIOS for the internal CGA/EGA. */ vid_init_1640(ams, roms->vidfn, roms->vidsz); device_add_ex(&vid_1640_device, ams->vid); @@ -1273,7 +1273,7 @@ machine_amstrad_init(const machine_t *model, void *arg) case ROM_PC200: device_add(&fdc_xt_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { /* Load the PC200 CGA Character Set ROM. */ loadfont(roms->fontfn, roms->fontnum); @@ -1284,21 +1284,21 @@ machine_amstrad_init(const machine_t *model, void *arg) case ROM_PC2086: device_add(&fdc_at_actlow_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { device_add(¶dise_pvga1a_pc2086_device); } break; case ROM_PC3086: device_add(&fdc_at_actlow_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { device_add(¶dise_pvga1a_pc3086_device); } break; case ROM_MEGAPC: device_add(&fdc_at_actlow_device); - if (vid_card == VID_INTERNAL) { + if (video_card == VID_INTERNAL) { device_add(¶dise_wd90c11_megapc_device); } break; @@ -1314,7 +1314,7 @@ machine_amstrad_init(const machine_t *model, void *arg) keyboard_scan = 1; /* Tell mouse driver about our internal mouse. */ - if (mouse_type == MOUSE_TYPE_INTERNAL) { + if (mouse_type == MOUSE_INTERNAL) { mouse_reset(); mouse_set_poll(ms_poll, ams); } diff --git a/src/machine/m_at_430fx.c b/src/machine/m_at_430fx.c index 84e54f6..da97402 100644 --- a/src/machine/m_at_430fx.c +++ b/src/machine/m_at_430fx.c @@ -8,7 +8,7 @@ * * Implementation of the Intel 430FX PCISet chip. * - * Version: @(#)m_at_430fx.c 1.0.8 2018/04/09 + * Version: @(#)m_at_430fx.c 1.0.9 2018/04/15 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -270,7 +270,7 @@ machine_at_endeavor_init(const machine_t *model, void *arg) device_add(&intel_flash_bxt_ami_device); - if (vid_card == VID_INTERNAL) + if (video_card == VID_INTERNAL) device_add(&s3_phoenix_trio64_onboard_pci_device); } diff --git a/src/machine/m_at_sis_85c471.c b/src/machine/m_at_sis_85c471.c index b99c67b..d421664 100644 --- a/src/machine/m_at_sis_85c471.c +++ b/src/machine/m_at_sis_85c471.c @@ -12,7 +12,7 @@ * * Used by DTK PKM-0038S E-2 * - * Version: @(#)m_at_sis85c471.c 1.0.6 2018/04/07 + * Version: @(#)m_at_sis85c471.c 1.0.7 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -93,8 +93,10 @@ sis_write(uint16_t port, uint8_t val, void *priv) serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); } else { +#if 0 serial_remove(1); serial_remove(2); +#endif } } diff --git a/src/machine/m_at_wd76c10.c b/src/machine/m_at_wd76c10.c index a9e5ba0..1bdf60d 100644 --- a/src/machine/m_at_wd76c10.c +++ b/src/machine/m_at_wd76c10.c @@ -8,7 +8,7 @@ * * Implementation of the WD76C10 system controller. * - * Version: @(#)m_at_wd76c10.c 1.0.4 2018/04/09 + * Version: @(#)m_at_wd76c10.c 1.0.5 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -101,24 +101,36 @@ wd76c10_write(uint16_t port, uint16_t val, void *priv) case 0x2072: wd76c10_2072 = val; +#if 0 serial_remove(1); +#endif if (! (val & 0x10)) { switch ((val >> 5) & 7) { case 1: serial_setup(1, 0x3f8, 4); break; case 2: serial_setup(1, 0x2f8, 4); break; case 3: serial_setup(1, 0x3e8, 4); break; case 4: serial_setup(1, 0x2e8, 4); break; - default: serial_remove(1); break; + default: +#if 0 + serial_remove(1); +#endif + break; } } +#if 0 serial_remove(2); +#endif if (! (val & 0x01)) { switch ((val >> 1) & 7) { case 1: serial_setup(2, 0x3f8, 3); break; case 2: serial_setup(2, 0x2f8, 3); break; case 3: serial_setup(2, 0x3e8, 3); break; case 4: serial_setup(2, 0x2e8, 3); break; - default: serial_remove(1); break; + default: +#if 0 + serial_remove(1); +#endif + break; } } break; diff --git a/src/machine/m_europc.c b/src/machine/m_europc.c index 669fe32..cffbf48 100644 --- a/src/machine/m_europc.c +++ b/src/machine/m_europc.c @@ -66,7 +66,7 @@ * bit 1: b8000 memory available * 0000:046a: 00 jim 250 01 jim 350 * - * Version: @(#)m_europc.c 1.0.6 2018/04/05 + * Version: @(#)m_europc.c 1.0.7 2018/04/14 * * Author: Fred N. van Kempen, * @@ -566,7 +566,7 @@ europc_boot(const device_t *info) * with values set by the user. */ b = (sys->nvr.regs[MRTC_CONF_D] & ~0x17); - switch(vid_card) { + switch(video_card) { case VID_CGA: /* Color, CGA */ case VID_COLORPLUS: /* Color, Hercules ColorPlus */ b |= 0x12; /* external video, CGA80 */ @@ -620,7 +620,7 @@ europc_boot(const device_t *info) /* Set up game port. */ b = (sys->nvr.regs[MRTC_CONF_C] & 0xfc); - if (mouse_type == MOUSE_TYPE_LOGIBUS) { + if (mouse_type == MOUSE_INTERNAL) { b |= 0x01; /* enable port as MOUSE */ } else if (joystick_type != JOYSTICK_TYPE_NONE) { b |= 0x02; /* enable port as joysticks */ diff --git a/src/machine/m_ps1.c b/src/machine/m_ps1.c index b967635..4b16d02 100644 --- a/src/machine/m_ps1.c +++ b/src/machine/m_ps1.c @@ -22,13 +22,7 @@ * The reserved 384K is remapped to the top of extended memory. * If this is not done then you get an error on startup. * - * NOTES: Floppy does not seem to work. --FvK - * The "ROM DOS" shell does not seem to work. We do have the - * correct BIOS images now, and they do load, but they do not - * boot. Sometimes, they do, and then it shows an "Incorrect - * DOS" error message?? --FvK - * - * Version: @(#)m_ps1.c 1.0.11 2018/04/09 + * Version: @(#)m_ps1.c 1.0.12 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -73,14 +67,15 @@ #include "../timer.h" #include "../device.h" #include "../nvr.h" -#include "../game/gameport.h" +#include "../keyboard.h" #include "../parallel.h" #include "../serial.h" -#include "../keyboard.h" -#include "../disk/hdc.h" -#include "../disk/hdc_ide.h" +#include "../game/gameport.h" +#include "../mouse.h" #include "../floppy/fdd.h" #include "../floppy/fdc.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../sound/sound.h" #include "../sound/snd_sn76489.h" #include "../video/video.h" @@ -128,7 +123,7 @@ extern const device_t ibm_ps1_2121_device; static void -update_irq_status(ps1snd_t *snd) +snd_update_irq(ps1snd_t *snd) { if (((snd->status & snd->ctrl) & 0x12) && (snd->ctrl & 0x01)) picint(1 << 7); @@ -146,7 +141,7 @@ snd_read(uint16_t port, void *priv) switch (port & 7) { case 0: /* ADC data */ snd->status &= ~0x10; - update_irq_status(snd); + snd_update_irq(snd); ret = 0; break; @@ -196,7 +191,7 @@ snd_write(uint16_t port, uint8_t val, void *priv) snd->ctrl = val; if (! (val & 0x02)) snd->status &= ~0x02; - update_irq_status(snd); + snd_update_irq(snd); break; case 3: /* timer reload value */ @@ -236,7 +231,7 @@ snd_callback(void *priv) snd->status |= 0x02; /*FIFO almost empty*/ snd->status |= 0x10; /*ADC data ready*/ - update_irq_status(snd); + snd_update_irq(snd); snd->timer_count += snd->timer_latch * TIMER_USEC; } @@ -267,8 +262,10 @@ snd_init(const device_t *info) sn76489_init(&snd->sn76489, 0x0205, 0x0001, SN76496, 4000000); - io_sethandler(0x0200, 1, snd_read,NULL,NULL, snd_write,NULL,NULL, snd); - io_sethandler(0x0202, 6, snd_read,NULL,NULL, snd_write,NULL,NULL, snd); + io_sethandler(0x0200, 1, + snd_read,NULL,NULL, snd_write,NULL,NULL, snd); + io_sethandler(0x0202, 6, + snd_read,NULL,NULL, snd_write,NULL,NULL, snd); timer_add(snd_callback, &snd->timer_count, &snd->timer_enable, snd); @@ -291,9 +288,7 @@ static const device_t snd_device = { "PS/1 Audio Card", 0, 0, snd_init, snd_close, NULL, - NULL, - NULL, - NULL, + NULL, NULL, NULL, NULL, NULL }; @@ -355,8 +350,6 @@ ps1_write(uint16_t port, uint8_t val, void *priv) case 0x0102: if (val & 0x04) serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); - else - serial_remove(1); if (val & 0x10) { switch ((val >> 5) & 3) { case 0: @@ -481,7 +474,7 @@ ps1_read(uint16_t port, void *priv) static void -ps1_setup(int model) +ps1_setup(int model, romdef_t *bios) { ps1_t *ps; @@ -500,54 +493,92 @@ ps1_setup(int model) io_sethandler(0x0190, 1, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); + /* Set up the parallel port. */ + parallel_setup(1, 0x03bc); + if (model == 2011) { + /* Force some configuration settings. */ + video_card = VID_INTERNAL; + sound_card = SOUND_INTERNAL; + hdc_type = HDC_INTERNAL; + mouse_type = MOUSE_PS2; + +#if 0 +#if 1 io_sethandler(0x0320, 1, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); io_sethandler(0x0322, 1, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); io_sethandler(0x0324, 1, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); - -#if 0 - rom_init(&ps->high_rom, - L"machines/ibm/ps1_2011/f80000_shell.bin", - 0xf80000, 0x80000, 0x7ffff, 0, MEM_MAPPING_EXTERNAL); +#else + device_add(&xta_ps1_device); +#endif #endif - parallel_setup(1, 0x03bc); - - serial_remove(1); - serial_remove(2); + if (machine_get_config_int("rom_shell")) { + pclog("PS1: loading ROM Shell..\n"); + if (! rom_init(&ps->high_rom, + L"machines/ibm/ps1_2011/fc0000_105775_us.bin", + 0xfc0000, 0x20000, 0x01ffff, 0, MEM_MAPPING_EXTERNAL)) { + pclog("PS1: unable to load ROM Shell !\n"); + } + } /* Enable the PS/1 VGA controller. */ - if (model == 2011) + if (video_card == VID_INTERNAL) device_add(&ps1vga_device); - else - device_add(&ibm_ps1_2121_device); + + /* Enable the builtin sound chip. */ + device_add(&snd_device); + + /* Enable the builtin FDC. */ + device_add(&fdc_at_actlow_device); } if (model == 2121) { + /* Force some configuration settings. */ + video_card = VID_INTERNAL; + sound_card = SOUND_INTERNAL; + hdc_type = HDC_INTERNAL; + mouse_type = MOUSE_PS2; + io_sethandler(0x00e0, 2, ps1_read, NULL, NULL, ps1_write, NULL, NULL, ps); - rom_init(&ps->high_rom, - L"machines/ibm/ps1_2121/rom_shell.bin", - 0xfc0000, 0x20000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL); -#if 0 - rom_init(&ps->high_rom, - L"machines/ibmps1_2121/fc0000_shell.bin", - 0xfc0000, 0x40000, 0x3ffff, 0, MEM_MAPPING_EXTERNAL); -#endif - - parallel_setup(1, 0x03bc); + if (machine_get_config_int("rom_shell")) { + pclog("PS1: loading ROM Shell..\n"); + if (! rom_init(&ps->high_rom, + L"machines/ibm/ps1_2121/fc0000_92f9674.bin", + 0xfc0000, 0x20000, 0x1ffff, 0, MEM_MAPPING_EXTERNAL)) { + pclog("PS1: unable to load ROM Shell !\n"); + } + } /* Initialize the video controller. */ - if (vid_card == VID_INTERNAL) + if (video_card == VID_INTERNAL) device_add(&ibm_ps1_2121_device); + + /* Enable the builtin sound chip. */ + device_add(&snd_device); + + /* Enable the builtin FDC. */ + device_add(&fdc_at_ps1_device); + + /* Enable the builtin IDE port. */ + device_add(&ide_isa_device); } if (model == 2133) { - parallel_setup(1, 0x03bc); + /* Force some configuration settings. */ + hdc_type = HDC_INTERNAL; + mouse_type = MOUSE_PS2; + + /* Enable the builtin FDC. */ + device_add(&fdc_at_device); + + /* Enable the builtin IDE port. */ + device_add(&ide_isa_device); } } @@ -566,33 +597,52 @@ ps1_common_init(const machine_t *model, void *arg) device_add(&ps_nvr_device); - if (romset != ROM_IBMPS1_2011) - device_add(&ide_isa_device); - device_add(&keyboard_ps2_device); - if (romset == ROM_IBMPS1_2133) - device_add(&fdc_at_device); - else { - if ((romset == ROM_IBMPS1_2121) || (romset == ROM_IBMPS1_2121_ISA)) - device_add(&fdc_at_ps1_device); - else - device_add(&fdc_at_actlow_device); - device_add(&snd_device); - } + device_add(&mouse_ps2_device); - /* Audio uses ports 200h and 202-207h, so only initialize gameport on 201h. */ + /* Audio uses ports 200h,202-207h, so only initialize gameport on 201h. */ if (joystick_type != JOYSTICK_TYPE_NONE) device_add(&gameport_201_device); } +static const device_config_t ps1_config[] = { + { + "rom_shell", "ROM Shell", CONFIG_SELECTION, "", 1, + { + { + "Disabled", 0 + }, + { + "Enabled", 1 + }, + { + "" + } + } + }, + { + "", "", -1 + } +}; + + +const device_t m_ps1_device = { + "PS/1", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + ps1_config +}; + + void machine_ps1_m2011_init(const machine_t *model, void *arg) { ps1_common_init(model, arg); - ps1_setup(2011); + ps1_setup(2011, (romdef_t *)arg); } @@ -601,7 +651,7 @@ machine_ps1_m2121_init(const machine_t *model, void *arg) { ps1_common_init(model, arg); - ps1_setup(2121); + ps1_setup(2121, (romdef_t *)arg); } @@ -610,7 +660,7 @@ machine_ps1_m2133_init(const machine_t *model, void *arg) { ps1_common_init(model, arg); - ps1_setup(2133); + ps1_setup(2133, (romdef_t *)arg); nmi_mask = 0x80; } diff --git a/src/machine/m_ps2_isa.c b/src/machine/m_ps2_isa.c index 1306d8f..2830b41 100644 --- a/src/machine/m_ps2_isa.c +++ b/src/machine/m_ps2_isa.c @@ -8,7 +8,7 @@ * * Implementation of ISA-based PS/2 machines. * - * Version: @(#)m_ps2_isa.c 1.0.8 2018/04/10 + * Version: @(#)m_ps2_isa.c 1.0.9 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -119,8 +119,10 @@ static void ps2_write(uint16_t port, uint8_t val, void *p) case 0x102: if (val & 0x04) serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); +#if 0 else serial_remove(1); +#endif if (val & 0x10) { switch ((val >> 5) & 3) { diff --git a/src/machine/m_ps2_mca.c b/src/machine/m_ps2_mca.c index 9e89073..91b535a 100644 --- a/src/machine/m_ps2_mca.c +++ b/src/machine/m_ps2_mca.c @@ -8,7 +8,7 @@ * * Implementation of MCA-based PS/2 machines. * - * Version: @(#)m_ps2_mca.c 1.0.10 2018/04/09 + * Version: @(#)m_ps2_mca.c 1.0.11 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -360,7 +360,9 @@ static void model_50_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: +#if 0 serial_remove(1); +#endif if (val & 0x04) { if (val & 0x08) @@ -368,8 +370,10 @@ static void model_50_write(uint16_t port, uint8_t val) else serial_setup(1, SERIAL2_ADDR, SERIAL2_IRQ); } +#if 0 else serial_remove(1); +#endif if (val & 0x10) { switch ((val >> 5) & 3) @@ -415,7 +419,9 @@ static void model_55sx_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: +#if 0 serial_remove(1); +#endif if (val & 0x04) { if (val & 0x08) @@ -423,8 +429,10 @@ static void model_55sx_write(uint16_t port, uint8_t val) else serial_setup(1, SERIAL2_ADDR, SERIAL2_IRQ); } +#if 0 else serial_remove(1); +#endif if (val & 0x10) { switch ((val >> 5) & 3) @@ -490,7 +498,9 @@ static void model_70_type3_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: +#if 0 serial_remove(1); +#endif if (val & 0x04) { if (val & 0x08) @@ -498,8 +508,10 @@ static void model_70_type3_write(uint16_t port, uint8_t val) else serial_setup(1, SERIAL2_ADDR, SERIAL2_IRQ); } +#if 0 else serial_remove(1); +#endif if (val & 0x10) { switch ((val >> 5) & 3) @@ -539,7 +551,9 @@ static void model_80_write(uint16_t port, uint8_t val) case 0x101: break; case 0x102: +#if 0 serial_remove(1); +#endif if (val & 0x04) { if (val & 0x08) @@ -547,8 +561,10 @@ static void model_80_write(uint16_t port, uint8_t val) else serial_setup(1, SERIAL2_ADDR, SERIAL2_IRQ); } +#if 0 else serial_remove(1); +#endif if (val & 0x10) { switch ((val >> 5) & 3) diff --git a/src/machine/m_xt.c b/src/machine/m_xt.c index 060d505..d6ce5a3 100644 --- a/src/machine/m_xt.c +++ b/src/machine/m_xt.c @@ -104,10 +104,8 @@ machine_xt_init(const machine_t *model, void *arg) const device_t m_xt_device = { "PC/XT", - MACHINE_ISA, - 0, - NULL, NULL, NULL, - NULL, + 0, 0, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, xt_config }; diff --git a/src/machine/machine.c b/src/machine/machine.c index f73a885..1a1e524 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.c 1.0.12 2018/04/07 + * Version: @(#)machine.c 1.0.13 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -161,8 +161,7 @@ machine_common_init(const machine_t *model, UNUSED(void *arg)) device_add(¶llel_3_device); if (serial_enabled[0]) - serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); - + device_add(&serial_1_device); if (serial_enabled[1]) - serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); + device_add(&serial_2_device); } diff --git a/src/machine/machine.h b/src/machine/machine.h index dd9f3c8..8f35f78 100644 --- a/src/machine/machine.h +++ b/src/machine/machine.h @@ -8,7 +8,7 @@ * * Handling of the emulated machines. * - * Version: @(#)machine.h 1.0.15 2018/04/10 + * Version: @(#)machine.h 1.0.17 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -188,10 +188,11 @@ enum { #define MACHINE_MCA 0x000100 /* sys has MCA bus */ #define MACHINE_PCI 0x000200 /* sys has PCI bus */ #define MACHINE_AGP 0x000400 /* sys has AGP bus */ -#define MACHINE_HDC 0x001000 /* sys has int HDC */ -#define MACHINE_HDC_PS2 0x002000 /* sys has int PS/2 HDC */ -#define MACHINE_MOUSE 0x004000 /* sys has int mouse */ -#define MACHINE_VIDEO 0x008000 /* sys has int video */ +#define MACHINE_HDC 0x011000 /* sys has int HDC */ +#define MACHINE_HDC_PS2 0x022000 /* sys has int PS/2 HDC */ +#define MACHINE_MOUSE 0x044000 /* sys has int mouse */ +#define MACHINE_SOUND 0x080000 /* sys has int sound */ +#define MACHINE_VIDEO 0x100000 /* sys has int video */ #define IS_ARCH(m, a) (machines[(m)].flags & (a)) ? 1 : 0; @@ -324,6 +325,9 @@ extern const device_t m_pcjr_device; extern void machine_ps1_m2011_init(const machine_t *, void *); extern void machine_ps1_m2121_init(const machine_t *, void *); extern void machine_ps1_m2133_init(const machine_t *, void *); +#ifdef EMU_DEVICE_H +extern const device_t m_ps1_device; +#endif extern void machine_ps2_m30_286_init(const machine_t *, void *); extern void machine_ps2_model_50_init(const machine_t *, void *); diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index b0e4168..00087a4 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -11,7 +11,7 @@ * NOTES: OpenAT wip for 286-class machine with open BIOS. * PS2_M80-486 wip, pending receipt of TRM's for machine. * - * Version: @(#)machine_table.c 1.0.17 2018/04/10 + * Version: @(#)machine_table.c 1.0.18 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -93,7 +93,7 @@ const machine_t machines[] = { { "[286 ISA] GW-286CT GEAR", ROM_GW286CT, "gw286ct", L"unknown/gw286ct", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,16384, 128, 128, machine_at_scat_init, NULL, NULL }, { "[286 ISA] Hyundai Super-286TR", ROM_SUPER286TR, "hyundai_super286tr", L"hyundai/super286tr", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,16384, 128, 128, machine_at_scat_init, NULL, NULL }, { "[286 ISA] IBM AT", ROM_IBMAT, "ibm_at", L"ibm/at", {{"", cpus_ibmat}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 256,15872, 128, 64, machine_at_ibm_init, NULL, NULL }, - { "[286 ISA] IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibm_ps1_2011", L"ibm/ps1_2011", {{"", cpus_ps1_m2011}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 512,16384, 512, 64, machine_ps1_m2011_init, NULL, NULL }, + { "[286 ISA] IBM PS/1 model 2011", ROM_IBMPS1_2011, "ibm_ps1_2011", L"ibm/ps1_2011", {{"", cpus_ps1_m2011}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO | MACHINE_MOUSE | MACHINE_HDC, 512, 6144, 512, 64, machine_ps1_m2011_init, &m_ps1_device, NULL }, { "[286 ISA] IBM PS/2 model 30-286", ROM_IBMPS2_M30_286, "ibm_ps2_m30_286", L"ibm/ps2_m30_286", {{"", cpus_ps2_m30_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 16, 1, 64, machine_ps2_m30_286_init, NULL, NULL }, { "[286 ISA] IBM XT Model 286", ROM_IBMXT286, "ibm_xt286", L"ibm/xt286", {{"", cpus_ibmxt286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 256,15872, 128, 128, machine_at_ibm_init, NULL, NULL }, { "[286 ISA] Samsung SPC-4200P", ROM_SPC4200P, "samsung_spc4200p", L"samsung/spc4200p", {{"", cpus_286}, {"", NULL}, {"", NULL}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2, 512, 2048, 128, 128, machine_at_scat_init, NULL, NULL }, @@ -104,10 +104,10 @@ const machine_t machines[] = { { "[386SX ISA] AMI 386SX clone", ROM_AMI386SX, "ami_386", L"generic/ami/386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 128, machine_at_headland_init, NULL, NULL }, { "[386SX ISA] Amstrad MegaPC", ROM_MEGAPC, "amstrad_megapc", L"amstrad/megapc", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_VIDEO | MACHINE_HDC, 1, 16, 1, 128, machine_at_wd76c10_init, NULL, NULL }, - { "[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award_386sx", L"generic/award/opti495", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 128, machine_at_opti495_init, NULL, NULL }, + { "[386SX ISA] Award 386SX clone", ROM_AWARD386SX_OPTI495, "award_386sx", L"generic/award/opti495", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 1, 64, 1, 128, machine_at_opti495_init, NULL, NULL }, { "[386SX ISA] DTK 386SX clone", ROM_DTK386, "dtk_386", L"dtk/386", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_HDC, 512,16384, 128, 128, machine_at_neat_init, NULL, NULL }, - { "[386SX ISA] IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibm_ps1_2121", L"ibm/ps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 64, machine_ps1_m2121_init, NULL, NULL }, - { "[386SX ISA] IBM PS/1 m.2121+ISA", ROM_IBMPS1_2121_ISA, "ibm_ps1_2121_isa", L"ibm/ps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 64, machine_ps1_m2121_init, NULL, NULL }, + { "[386SX ISA] IBM PS/1 model 2121", ROM_IBMPS1_2121, "ibm_ps1_2121", L"ibm/ps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 64, machine_ps1_m2121_init, &m_ps1_device, NULL }, + { "[386SX ISA] IBM PS/1 m.2121+ISA", ROM_IBMPS1_2121_ISA, "ibm_ps1_2121_isa", L"ibm/ps1_2121", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC | MACHINE_VIDEO, 1, 6, 1, 64, machine_ps1_m2121_init, &m_ps1_device, NULL }, { "[386SX MCA] IBM PS/2 model 55SX", ROM_IBMPS2_M55SX, "ibm_ps2_m55sx", L"ibm/ps2_m55sx", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 1, MACHINE_MCA | MACHINE_AT | MACHINE_PS2 | MACHINE_HDC_PS2, 1, 8, 1, 64, machine_ps2_model_55sx_init, NULL, NULL }, { "[386SX ISA] KMX-C-02", ROM_KMXC02, "kmxc02", L"unknown/kmxc02", {{"Intel", cpus_i386SX}, {"AMD", cpus_Am386SX}, {"Cyrix", cpus_486SLC}, {"", NULL}, {"", NULL}}, 0, MACHINE_ISA | MACHINE_AT, 512,16384, 512, 128, machine_at_scatsx_init, NULL, NULL }, diff --git a/src/mouse.c b/src/mouse.c index 3b92977..af69745 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -9,9 +9,8 @@ * Common driver module for MOUSE devices. * * TODO: Add the Genius bus- and serial mouse. - * Remove the '3-button' flag from mouse types. * - * Version: @(#)mouse.c 1.0.6 2018/04/10 + * Version: @(#)mouse.c 1.0.8 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -64,7 +63,6 @@ typedef struct { } mouse_t; -int mouse_type = 0; int mouse_x, mouse_y, mouse_z, @@ -73,14 +71,14 @@ int mouse_x, static const device_t mouse_none_device = { "Disabled", - 0, MOUSE_TYPE_NONE, + 0, MOUSE_NONE, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; static const device_t mouse_internal_device = { - "Internal Mouse", - 0, MOUSE_TYPE_INTERNAL, + "Internal", + 0, MOUSE_INTERNAL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -88,17 +86,19 @@ static const device_t mouse_internal_device = { static const mouse_t mouse_devices[] = { - { "none", &mouse_none_device }, - { "internal", &mouse_internal_device }, - { "logibus", &mouse_logibus_device }, - { "msbus", &mouse_msinport_device }, + { "none", &mouse_none_device }, + { "internal", &mouse_internal_device }, + { "logibus", &mouse_logibus_device }, + { "msbus", &mouse_msinport_device }, #if 0 - { "genibus", &mouse_genibus_device }, + { "genibus", &mouse_genibus_device }, #endif - { "mssystems", &mouse_mssystems_device }, - { "msserial", &mouse_msserial_device }, - { "ps2", &mouse_ps2_device }, - { NULL, NULL } + { "mssystems", &mouse_mssystems_device }, + { "msserial", &mouse_msserial_device }, + { "logiserial", &mouse_logiserial_device }, + { "mswhserial", &mouse_mswhserial_device }, + { "ps2", &mouse_ps2_device }, + { NULL, NULL } }; @@ -115,9 +115,9 @@ mouse_init(void) mouse_x = mouse_y = mouse_z = 0; mouse_buttons = 0x00; - mouse_type = MOUSE_TYPE_NONE; - mouse_priv = NULL; - mouse_nbut = 0; + mouse_type = MOUSE_NONE; + + mouse_close(); } @@ -133,7 +133,7 @@ void mouse_reset(void) { /* Nothing to do if no mouse, or a machine-internal one. */ - if (mouse_type <= MOUSE_TYPE_INTERNAL) return; + if (mouse_type <= MOUSE_INTERNAL) return; pclog("MOUSE: reset(type=%d, '%s')\n", mouse_type, mouse_devices[mouse_type].device->name); @@ -164,14 +164,22 @@ mouse_process(void) { static int poll_delay = 2; - if (mouse_type == MOUSE_TYPE_NONE) return; + if ((mouse_priv == NULL) || /* no or no active device */ + (mouse_type == MOUSE_NONE)) return; if (--poll_delay) return; mouse_poll(); if (mouse_dev.available != NULL) { - mouse_dev.available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv); + if (! mouse_dev.available(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv)) { + /* Poll failed, maybe port closed? */ + mouse_close(); + + pclog("MOUSE: device closed, mouse disabled!\n"); + + return; + } /* Reset mouse deltas. */ mouse_x = mouse_y = mouse_z = 0; @@ -184,7 +192,7 @@ mouse_process(void) void mouse_set_poll(int (*func)(int,int,int,int,void *), void *arg) { - if (mouse_type != MOUSE_TYPE_INTERNAL) return; + if (mouse_type != MOUSE_INTERNAL) return; mouse_dev.available = func; mouse_priv = arg; diff --git a/src/mouse.h b/src/mouse.h index a7671e4..7394799 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -8,7 +8,7 @@ * * Definitions for the mouse driver. * - * Version: @(#)mouse.h 1.0.3 2018/04/10 + * Version: @(#)mouse.h 1.0.5 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -50,25 +50,27 @@ # define EMU_MOUSE_H -#define MOUSE_TYPE_NONE 0 /* no mouse configured */ -#define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */ -#define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */ -#define MOUSE_TYPE_INPORT 3 /* Microsoft InPort Mouse */ +#define MOUSE_NONE 0 /* no mouse configured */ +#define MOUSE_INTERNAL 1 /* machine has internal mouse */ +#define MOUSE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */ +#define MOUSE_INPORT 3 /* Microsoft InPort Mouse */ #if 0 -# define MOUSE_TYPE_GENIBUS 4 /* Genius Bus Mouse */ +# define MOUSE_GENIBUS 4 /* Genius Bus Mouse */ +# define MOUSE_NEXT 5 +#else +# define MOUSE_NEXT 4 #endif -#define MOUSE_TYPE_MSYSTEMS 5 /* Mouse Systems mouse */ -#define MOUSE_TYPE_MICROSOFT 6 /* Microsoft Serial Mouse */ -#define MOUSE_TYPE_LOGITECH 7 /* Logitech Serial Mouse */ -#define MOUSE_TYPE_MSWHEEL 8 /* Serial Wheel Mouse */ -#define MOUSE_TYPE_PS2 9 /* PS/2 series Bus Mouse */ +#define MOUSE_MSYSTEMS MOUSE_NEXT+0 /* Mouse Systems mouse */ +#define MOUSE_MICROSOFT MOUSE_NEXT+1 /* Microsoft Serial Mouse */ +#define MOUSE_LOGITECH MOUSE_NEXT+2 /* Logitech Serial Mouse */ +#define MOUSE_MSWHEEL MOUSE_NEXT+3 /* Serial Wheel Mouse */ +#define MOUSE_PS2 MOUSE_NEXT+4 /* PS/2 series Bus Mouse */ #ifdef __cplusplus extern "C" { #endif -extern int mouse_type; extern int mouse_x, mouse_y, mouse_z; extern int mouse_buttons; @@ -84,6 +86,8 @@ extern const device_t mouse_genibus_device; #endif extern const device_t mouse_mssystems_device; extern const device_t mouse_msserial_device; +extern const device_t mouse_logiserial_device; +extern const device_t mouse_mswhserial_device; extern const device_t mouse_ps2_device; #endif diff --git a/src/mouse_bus.c b/src/mouse_bus.c index c3af8ca..0aeeb2f 100644 --- a/src/mouse_bus.c +++ b/src/mouse_bus.c @@ -49,7 +49,7 @@ * * Based on an early driver for MINIX 1.5. * - * Version: @(#)mouse_bus.c 1.0.2 2018/03/15 + * Version: @(#)mouse_bus.c 1.0.4 2018/04/19 * * Author: Fred N. van Kempen, * @@ -713,11 +713,11 @@ bm_init(const device_t *info) if (i > 2) dev->flags |= FLAG_3BTN; - pclog("%s: I/O=%04x, IRQ=%d, buttons=%d\n", - dev->name, MOUSE_PORT, dev->irq, i); + pclog("MOUSE: %s (I/O=%04x, IRQ=%d, buttons=%d)\n", + dev->name, MOUSE_PORT, dev->irq, i); switch(dev->type) { - case MOUSE_TYPE_LOGIBUS: + case MOUSE_LOGIBUS: lt_reset(dev); /* Initialize I/O handlers. */ @@ -728,7 +728,7 @@ bm_init(const device_t *info) timer_add(bm_timer, &dev->timer, &dev->timer, dev); break; - case MOUSE_TYPE_INPORT: + case MOUSE_INPORT: dev->flags |= FLAG_INPORT; ms_reset(dev); @@ -795,7 +795,7 @@ static const device_config_t bm_config[] = { const device_t mouse_logibus_device = { "Logitech Bus Mouse", DEVICE_ISA, - MOUSE_TYPE_LOGIBUS, + MOUSE_LOGIBUS, bm_init, bm_close, NULL, bm_poll, NULL, NULL, NULL, bm_config @@ -804,7 +804,7 @@ const device_t mouse_logibus_device = { const device_t mouse_msinport_device = { "Microsoft Bus Mouse (InPort)", DEVICE_ISA, - MOUSE_TYPE_INPORT, + MOUSE_INPORT, bm_init, bm_close, NULL, bm_poll, NULL, NULL, NULL, bm_config diff --git a/src/mouse_ps2.c b/src/mouse_ps2.c index ea7892d..9578aa2 100644 --- a/src/mouse_ps2.c +++ b/src/mouse_ps2.c @@ -8,7 +8,7 @@ * * Implementation of PS/2 series Mouse devices. * - * Version: @(#)mouse_ps2.c 1.0.2 2018/03/15 + * Version: @(#)mouse_ps2.c 1.0.4 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -266,7 +266,8 @@ mouse_ps2_init(const device_t *info) /* Hook into the general AT Keyboard driver. */ keyboard_at_set_mouse(ps2_write, dev); - pclog("%s: buttons=%d\n", dev->name, (dev->flags & FLAG_INTELLI)? 3 : 2); + pclog("MOUSE: %s (buttons=%d)\n", + dev->name, (dev->flags & FLAG_INTELLI)? 3 : 2); /* Tell them how many buttons we have. */ mouse_set_buttons((dev->flags & FLAG_INTELLI) ? 3 : 2); @@ -314,7 +315,7 @@ static const device_config_t ps2_config[] = { const device_t mouse_ps2_device = { "Standard PS/2 Mouse", 0, - MOUSE_TYPE_PS2, + MOUSE_PS2, mouse_ps2_init, ps2_close, NULL, ps2_poll, NULL, NULL, NULL, ps2_config diff --git a/src/mouse_serial.c b/src/mouse_serial.c index 91ace91..c744139 100644 --- a/src/mouse_serial.c +++ b/src/mouse_serial.c @@ -10,7 +10,7 @@ * * TODO: Add the Genius Serial Mouse. * - * Version: @(#)mouse_serial.c 1.0.2 2018/03/15 + * Version: @(#)mouse_serial.c 1.0.4 2018/04/19 * * Author: Fred N. van Kempen, * @@ -59,9 +59,6 @@ #include "mouse.h" -#define SERMOUSE_PORT 0 /* attach to Serial0 */ - - typedef struct { const char *name; /* name of this device */ int8_t type, /* type of this device */ @@ -84,20 +81,20 @@ typedef struct { /* Callback from serial driver: RTS was toggled. */ static void -sermouse_callback(struct SERIAL *serial, void *priv) +ser_callback(struct SERIAL *serial, void *priv) { mouse_t *dev = (mouse_t *)priv; /* Start a timer to wake us up in a little while. */ dev->pos = -1; - serial_clear_fifo((SERIAL *) serial); + dev->serial->clear_fifo(serial); dev->delay = 5000LL * (1LL << TIMER_SHIFT); } /* Callback timer expired, now send our "mouse ID" to the serial port. */ static void -sermouse_timer(void *priv) +ser_timer(void *priv) { mouse_t *dev = (mouse_t *)priv; @@ -107,26 +104,29 @@ sermouse_timer(void *priv) dev->pos = 0; switch(dev->type) { - case MOUSE_TYPE_MSYSTEMS: + case MOUSE_MSYSTEMS: /* Identifies Mouse Systems serial mouse. */ - serial_write_fifo(dev->serial, 'H'); + dev->serial->write_fifo(dev->serial, 'H'); break; - case MOUSE_TYPE_MICROSOFT: - /* Identifies a two-button Microsoft Serial mouse. */ - serial_write_fifo(dev->serial, 'M'); + case MOUSE_MICROSOFT: + /* Identifies a Microsoft Serial mouse. */ + dev->serial->write_fifo(dev->serial, 'M'); + if (dev->flags & FLAG_3BTN) + dev->serial->write_fifo(dev->serial, '3'); break; - case MOUSE_TYPE_LOGITECH: - /* Identifies a two-button Logitech Serial mouse. */ - serial_write_fifo(dev->serial, 'M'); - serial_write_fifo(dev->serial, '3'); + case MOUSE_LOGITECH: + /* Identifies a Logitech Serial mouse. */ + dev->serial->write_fifo(dev->serial, 'M'); + if (dev->flags & FLAG_3BTN) + dev->serial->write_fifo(dev->serial, '3'); break; - case MOUSE_TYPE_MSWHEEL: + case MOUSE_MSWHEEL: /* Identifies multi-button Microsoft Wheel Mouse. */ - serial_write_fifo(dev->serial, 'M'); - serial_write_fifo(dev->serial, 'Z'); + dev->serial->write_fifo(dev->serial, 'M'); + dev->serial->write_fifo(dev->serial, 'Z'); break; default: @@ -136,7 +136,7 @@ sermouse_timer(void *priv) static int -sermouse_poll(int x, int y, int z, int b, void *priv) +ser_poll(int x, int y, int z, int b, void *priv) { mouse_t *dev = (mouse_t *)priv; uint8_t buff[16]; @@ -157,7 +157,7 @@ sermouse_poll(int x, int y, int z, int b, void *priv) len = 0; switch(dev->type) { - case MOUSE_TYPE_MSYSTEMS: + case MOUSE_MSYSTEMS: buff[0] = 0x80; buff[0] |= (b & 0x01) ? 0x00 : 0x04; /* left button */ buff[0] |= (b & 0x02) ? 0x00 : 0x01; /* middle button */ @@ -169,25 +169,25 @@ sermouse_poll(int x, int y, int z, int b, void *priv) len = 5; break; - case MOUSE_TYPE_MICROSOFT: - case MOUSE_TYPE_LOGITECH: - case MOUSE_TYPE_MSWHEEL: + case MOUSE_MICROSOFT: + case MOUSE_LOGITECH: + case MOUSE_MSWHEEL: buff[0] = 0x40; buff[0] |= (((y >> 6) & 0x03) << 2); buff[0] |= ((x >> 6) & 0x03); if (b & 0x01) buff[0] |= 0x20; if (b & 0x02) buff[0] |= 0x10; - buff[1] = x & 0x3F; - buff[2] = y & 0x3F; - if (dev->type == MOUSE_TYPE_LOGITECH) { + buff[1] = x & 0x3f; + buff[2] = y & 0x3f; + if (dev->flags & FLAG_3BTN) { len = 3; if (b & 0x04) { buff[3] = 0x20; len++; } - } else if (dev->type == MOUSE_TYPE_MSWHEEL) { + } else if (dev->type == MOUSE_MSWHEEL) { len = 4; - buff[3] = z & 0x0F; + buff[3] = z & 0x0f; if (b & 0x04) buff[3] |= 0x10; } else @@ -195,16 +195,10 @@ sermouse_poll(int x, int y, int z, int b, void *priv) break; } -#if 0 - pclog("%s: [", dev->name); - for (b=0; bserial != NULL) { - for (b=0; bserial, buff[b]); + for (b = 0; b < len; b++) + dev->serial->write_fifo(dev->serial, buff[b]); } return(0); @@ -212,14 +206,14 @@ sermouse_poll(int x, int y, int z, int b, void *priv) static void -sermouse_close(void *priv) +ser_close(void *priv) { mouse_t *dev = (mouse_t *)priv; /* Detach serial port from the mouse. */ if ((dev != NULL) && (dev->serial != NULL)) { - dev->serial->rcr_callback = NULL; - dev->serial->rcr_callback_p = NULL; + dev->serial->rts_callback = NULL; + dev->serial->rts_callback_p = NULL; } free(dev); @@ -228,7 +222,7 @@ sermouse_close(void *priv) /* Initialize the device for use by the user. */ static void * -sermouse_init(const device_t *info) +ser_init(const device_t *info) { mouse_t *dev; int i; @@ -236,40 +230,26 @@ sermouse_init(const device_t *info) dev = (mouse_t *)malloc(sizeof(mouse_t)); memset(dev, 0x00, sizeof(mouse_t)); dev->name = info->name; + dev->type = info->local; + + dev->port = device_get_config_int("port"); + i = device_get_config_int("buttons"); if (i > 2) dev->flags |= FLAG_3BTN; - if (info->local == MOUSE_TYPE_MSYSTEMS) - dev->type = info->local; - else { - switch(i) { - case 2: - default: - dev->type = MOUSE_TYPE_MICROSOFT; - break; - case 3: - dev->type = MOUSE_TYPE_LOGITECH; - break; - case 4: - dev->type = MOUSE_TYPE_MSWHEEL; - break; - } + /* Attach a serial port to the mouse. */ + dev->serial = serial_attach(dev->port + 1, ser_callback, dev); + if (dev->serial == NULL) { + pclog("MOUSE: %s (port=COM%d, butons=%d) port disabled!\n", + dev->name, dev->port+1, i); + free(dev); + return(NULL); } - dev->port = device_get_config_int("port"); + pclog("MOUSE: %s (port=COM%d, butons=%d)\n", dev->name, dev->port+1, i); - /* Attach a serial port to the mouse. */ - if (dev->port == 0) - dev->serial = &serial1; - else - dev->serial = &serial2; - dev->serial->rcr_callback = sermouse_callback; - dev->serial->rcr_callback_p = dev; - - pclog("%s: port=COM%d\n", dev->name, dev->port+1); - - timer_add(sermouse_timer, &dev->delay, &dev->delay, dev); + timer_add(ser_timer, &dev->delay, &dev->delay, dev); /* Tell them how many buttons we have. */ mouse_set_buttons((dev->flags & FLAG_3BTN) ? 3 : 2); @@ -279,7 +259,7 @@ sermouse_init(const device_t *info) } -static const device_config_t sermouse_config[] = { +static const device_config_t ser_config[] = { { "port", "Serial Port", CONFIG_SELECTION, "", 0, { { @@ -318,17 +298,36 @@ static const device_config_t sermouse_config[] = { const device_t mouse_mssystems_device = { "Mouse Systems Serial Mouse", 0, - MOUSE_TYPE_MSYSTEMS, - sermouse_init, sermouse_close, NULL, - sermouse_poll, NULL, NULL, NULL, - sermouse_config + MOUSE_MSYSTEMS, + ser_init, ser_close, NULL, + ser_poll, NULL, NULL, NULL, + ser_config }; const device_t mouse_msserial_device = { - "Microsoft/Logitech Serial Mouse", + "Microsoft Serial Mouse", 0, - 0, - sermouse_init, sermouse_close, NULL, - sermouse_poll, NULL, NULL, NULL, - sermouse_config + MOUSE_MICROSOFT, + ser_init, ser_close, NULL, + ser_poll, NULL, NULL, NULL, + ser_config +}; + +const device_t mouse_logiserial_device = { + "Logitech Serial Mouse", + 0, + MOUSE_LOGITECH, + ser_init, ser_close, NULL, + ser_poll, NULL, NULL, NULL, + ser_config +}; + + +const device_t mouse_mswhserial_device = { + "Microsoft Serial Wheel Mouse", + 0, + MOUSE_MSWHEEL, + ser_init, ser_close, NULL, + ser_poll, NULL, NULL, NULL, + ser_config }; diff --git a/src/nvr.c b/src/nvr.c index 6b54178..43ac1e7 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -148,9 +148,9 @@ nvr_init(nvr_t *nvr) /* Set up the NVR file's name. */ sprintf(temp, "%s.nvr", machine_get_internal_name()); - c = strlen(temp); - nvr->fn = (wchar_t *)malloc(c*sizeof(wchar_t) + 1); - mbstowcs(nvr->fn, temp, c + 1); + c = strlen(temp) + 1; + nvr->fn = (wchar_t *)malloc(c*sizeof(wchar_t)); + mbstowcs(nvr->fn, temp, c); /* Initialize the internal clock as needed. */ memset(&intclk, 0x00, sizeof(intclk)); @@ -227,7 +227,8 @@ nvr_load(void) if (saved_nvr == NULL) return(0); /* Clear out any old data. */ - memset(saved_nvr->regs, 0xff, sizeof(saved_nvr->regs)); +// memset(saved_nvr->regs, 0xff, sizeof(saved_nvr->regs)); + memset(saved_nvr->regs, 0x00, sizeof(saved_nvr->regs)); /* Set the defaults. */ if (saved_nvr->reset != NULL) diff --git a/src/parallel.c b/src/parallel.c index 7656cb2..892084e 100644 --- a/src/parallel.c +++ b/src/parallel.c @@ -8,7 +8,7 @@ * * Implementation of the "LPT" style parallel ports. * - * Version: @(#)parallel.c 1.0.5 2018/04/09 + * Version: @(#)parallel.c 1.0.6 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -78,6 +78,10 @@ parallel_write(uint16_t port, uint8_t val, void *priv) { parallel_t *dev = (parallel_t *)priv; +#ifdef ENABLE_PARALLEL_LOG + pclog("PARALLEL: write(%04X, %02X)\n", port, val); +#endif + switch (port & 3) { case 0: if (dev->dev_ts != NULL) @@ -116,6 +120,9 @@ parallel_read(uint16_t port, void *priv) ret = dev->ctrl; break; } +#ifdef ENABLE_PARALLEL_LOG + pclog("PARALLEL: read(%04X) => %02X\n", port, ret); +#endif return(ret); } @@ -125,10 +132,9 @@ static void * parallel_init(const device_t *info) { parallel_t *dev; - int id = info->local - 1; /* Get the correct device. */ - dev = &ports[id]; + dev = &ports[info->local]; /* Clear port. */ dev->dat = 0x00; @@ -140,12 +146,15 @@ parallel_init(const device_t *info) parallel_write,NULL,NULL, dev); /* If the user configured a device for this port, attach it. */ - if (parallel_device[id] != 0) { - dev->dev_ts = parallel_device_get_device(parallel_device[id]); + if (parallel_device[info->local] != 0) { + dev->dev_ts = parallel_device_get_device(parallel_device[info->local]); if (dev->dev_ts != NULL) dev->dev_ps = dev->dev_ts->init(dev->dev_ts); } + pclog("PARALLEL: LPT%d (I/O=%04X, device=%d)\n", + info->local+1, dev->base, parallel_device[info->local]); + return(dev); } @@ -176,9 +185,9 @@ parallel_close(void *priv) const device_t parallel_1_device = { "LPT1:", 0, - 1, + 0, parallel_init, parallel_close, NULL, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; @@ -186,9 +195,9 @@ const device_t parallel_1_device = { const device_t parallel_2_device = { "LPT2:", 0, - 2, + 1, parallel_init, parallel_close, NULL, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; @@ -196,9 +205,9 @@ const device_t parallel_2_device = { const device_t parallel_3_device = { "LPT3:", 0, - 3, + 2, parallel_init, parallel_close, NULL, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL }; @@ -210,6 +219,9 @@ parallel_reset(void) parallel_t *dev; int i; + pclog("PARALLEL: reset ([%d] [%d] [%d])\n", + parallel_enabled[0], parallel_enabled[1], parallel_enabled[2]); + for (i = 0; i < PARALLEL_MAX; i++) { dev = &ports[i]; diff --git a/src/pc.c b/src/pc.c index 5f91ebc..1b3c98a 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.24 2018/04/10 + * Version: @(#)pc.c 1.0.26 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -105,20 +105,24 @@ wchar_t log_path[1024] = { L'\0'}; /* (O) full path of logfile */ /* Configuration values. */ int window_w, window_h, /* (C) window size and */ window_x, window_y, /* position info */ - window_remember, + window_remember; +int vid_api = 0, /* (C) video renderer */ vid_resize, /* (C) allow resizing */ - invert_display, /* (C) invert the display */ - suppress_overscan = 0; /* (C) suppress overscans */ -int scale = 0; /* (C) screen scale factor */ -int vid_api = 0; /* (C) video renderer */ -int vid_cga_contrast = 0, /* (C) video */ - video_fullscreen = 0, /* (C) video */ - video_fullscreen_scale = 0, /* (C) video */ - video_fullscreen_first = 0, /* (C) video */ + vid_cga_contrast = 0, /* (C) video */ + vid_fullscreen = 0, /* (C) video */ + vid_fullscreen_scale = 0, /* (C) video */ + vid_fullscreen_first = 0, /* (C) video */ + vid_grayscale = 0, /* (C) video */ + vid_graytype = 0, /* (C) video */ + invert_display = 0, /* (C) invert the display */ + suppress_overscan = 0, /* (C) suppress overscans */ + scale = 0, /* (C) screen scale factor */ enable_overscan = 0, /* (C) video */ force_43 = 0, /* (C) video */ - vid_card = 0, /* (C) graphics/video card */ - video_speed = 0; /* (C) video */ + video_card = 0, /* (C) graphics/video card */ + video_speed = 0, /* (C) video */ + voodoo_enabled = 0; /* (C) video option */ +int mouse_type = 0; /* (C) selected mouse type */ int enable_sync = 0; /* (C) enable time sync */ int serial_enabled[] = {0,0}, /* (C) enable serial ports */ parallel_enabled[] = {0,0,0}, /* (C) enable LPT ports */ @@ -130,10 +134,13 @@ int update_icons; /* (C) enable icons updates */ int romdos_enabled = 0; /* (C) enable ROM DOS */ #endif int hdc_type = 0; /* (C) HDC type */ -int sound_is_float = 1, /* (C) sound uses FP values */ +int scsi_card = 0; /* (C) selected SCSI card */ +int sound_card = 0, /* (C) selected sound card */ + sound_is_float = 1, /* (C) sound uses FP values */ + sound_gain = 0, /* (C) sound volume gain */ mpu401_standalone_enable = 0, /* (C) sound option */ opl3_type = 0, /* (C) sound option */ - voodoo_enabled = 0; /* (C) video option */ + midi_device; /* (C) selected midi device */ int joystick_type = 0; /* (C) joystick type */ int mem_size = 0; /* (C) memory size */ int cpu_manufacturer = 0, /* (C) cpu manufacturer */ @@ -712,7 +719,8 @@ pc_init_modules(void) return(2); } - if ((vid_card < 0) || !video_card_available(video_old_to_new(vid_card))) { + if ((video_card < 0) || + !video_card_available(video_old_to_new(video_card))) { /* Whoops, selected video not available. */ str = plat_get_string(IDS_2064); mbstowcs(name, machine_getname(), sizeof_w(name)); @@ -802,13 +810,9 @@ pc_reset_hard_init(void) timer_reset(); device_init(); -#ifndef WALTJE_SERIAL - /* This is needed to initialize the serial timer. */ - serial_init(); -#endif - - /* Reset the parallel ports [before machine!] */ + /* Reset the ports [before machine!] so they can be configured. */ parallel_reset(); + serial_reset(); sound_reset(); speaker_init(); @@ -816,6 +820,9 @@ pc_reset_hard_init(void) /* Initialize the actual machine and its basic modules. */ machine_init(); + /* FIXME: move elsewhere? */ + shadowbios = 0; + fdd_reset(); /* @@ -828,19 +835,8 @@ pc_reset_hard_init(void) */ /* Reset some basic devices. */ - serial_reset(); - - shadowbios = 0; - - /* - * This has to be after the serial initialization so that - * serial_init() doesn't break the serial mouse by resetting - * the RCR callback to NULL. - */ mouse_reset(); - - /* Reset the video card. */ - video_reset(vid_card); + video_reset(); /* FIXME: these, and hdc_reset, should be in disk_reset(). */ cdrom_hard_reset(); @@ -1094,7 +1090,7 @@ pc_thread(void *param) #endif EMU_NAME,emu_version,fps,machine_getname(), machines[machine].cpu[cpu_manufacturer].cpus[cpu_effective].name); - if (mouse_type != MOUSE_TYPE_NONE) { + if (mouse_type != MOUSE_NONE) { wcscat(temp, L" - "); if (!mouse_capture) { wcscat(temp, plat_get_string(IDS_2077)); @@ -1126,7 +1122,7 @@ pc_thread(void *param) } /* If needed, handle a screen resize. */ - if (doresize && !video_fullscreen) { + if (doresize && !vid_fullscreen) { plat_resize(scrnsz_x, scrnsz_y); doresize = 0; diff --git a/src/rom.c b/src/rom.c index f3e49f4..1102c3f 100644 --- a/src/rom.c +++ b/src/rom.c @@ -8,11 +8,7 @@ * * Handling of ROM image files. * - * NOTES: - pc2386 BIOS is corrupt (JMP at F000:FFF0 points to RAM) - * - pc2386 video BIOS is underdumped (16k instead of 24k) - * - c386sx16 BIOS fails checksum - * - * Version: @(#)rom.c 1.0.12 2018/04/10 + * Version: @(#)rom.c 1.0.13 2018/04/12 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -82,8 +78,9 @@ rom_present(const wchar_t *fn) if (f != NULL) { (void)fclose(f); return(1); - } else - pclog("ROM: image for '%ls' not found!\n", fn); + } + + pclog("ROM: image for '%ls' not found!\n", fn); return(0); } @@ -160,39 +157,6 @@ rom_load_linear(const wchar_t *fn, uint32_t addr, int sz, int off, uint8_t *ptr) } -/* Load a ROM BIOS from its chips, linear mode with high bit flipped. */ -int -rom_load_linear_inverted(const wchar_t *fn, uint32_t addr, int sz, int off, uint8_t *ptr) -{ - FILE *f; - - f = plat_fopen(rom_path(fn), L"rb"); - if (f == NULL) { - pclog("ROM: image '%ls' not found\n", fn); - return(0); - } - - /* Make sure we only look at the base-256K offset. */ - if (addr >= 0x40000) - addr = 0; - else - addr &= 0x03ffff; - - (void)fseek(f, 0, SEEK_END); - if (ftell(f) < sz) { - (void)fclose(f); - return(0); - } - - (void)fseek(f, off, SEEK_SET); - (void)fread(ptr+addr+0x10000, sz >> 1, 1, f); - (void)fread(ptr+addr, sz >> 1, 1, f); - (void)fclose(f); - - return(1); -} - - /* Load a ROM BIOS from its chips, interleaved mode. */ int rom_load_interleaved(const wchar_t *fnl, const wchar_t *fnh, uint32_t addr, int sz, int off, uint8_t *ptr) @@ -242,7 +206,7 @@ rom_init(rom_t *rom, const wchar_t *fn, uint32_t addr, int sz, int mask, int off /* Nope.. clean up. */ free(rom->rom); rom->rom = NULL; - return(-1); + return(0); } rom->mask = mask; @@ -253,7 +217,7 @@ rom_init(rom_t *rom, const wchar_t *fn, uint32_t addr, int sz, int mask, int off mem_write_null, mem_write_nullw, mem_write_nulll, rom->rom, flags | MEM_MAPPING_ROM, rom); - return(0); + return(1); } @@ -269,7 +233,7 @@ rom_init_interleaved(rom_t *rom, const wchar_t *fnl, const wchar_t *fnh, uint32_ /* Nope.. clean up. */ free(rom->rom); rom->rom = NULL; - return(-1); + return(0); } rom->mask = mask; @@ -280,5 +244,5 @@ rom_init_interleaved(rom_t *rom, const wchar_t *fnl, const wchar_t *fnh, uint32_ mem_write_null, mem_write_nullw, mem_write_nulll, rom->rom, flags | MEM_MAPPING_ROM, rom); - return(0); + return(1); } diff --git a/src/rom.h b/src/rom.h index 9a73ed7..a30cfab 100644 --- a/src/rom.h +++ b/src/rom.h @@ -8,7 +8,7 @@ * * Definitions for the ROM image handler. * - * Version: @(#)rom.h 1.0.10 2018/04/10 + * Version: @(#)rom.h 1.0.11 2018/04/12 * * Authors: Fred N. van Kempen, * diff --git a/src/rom_load.c b/src/rom_load.c index 23c9ec6..70ae92d 100644 --- a/src/rom_load.c +++ b/src/rom_load.c @@ -406,7 +406,8 @@ rom_load_bios(romdef_t *r, const wchar_t *fn, int test_only) pclog("Mode : %s\n", (r->mode == 1)?"interleaved":"linear"); pclog("Files : %d\n", r->nfiles); for (c=0; cnfiles; c++) { - pclog(" [%d] : '%ls', %i, 0x%06lx, %i\n", c+1, + pclog("%c[%d] : '%ls', %i, 0x%06lx, %i\n", + (r->files[c].offset==0xffffffff)?'*':' ', c+1, r->files[c].path, r->files[c].skip, r->files[c].offset, r->files[c].size); } @@ -420,9 +421,14 @@ rom_load_bios(romdef_t *r, const wchar_t *fn, int test_only) case 0: /* linear file(s) */ /* We loop on all files. */ for (c=0; cnfiles; c++) { + /* If this is a no-load file, skip. */ + if (r->files[c].offset == 0xffffffff) + continue; + wcscpy(script, path); wcscat(script, r->files[c].path); pc_path(script, sizeof_w(script), NULL); + i = rom_load_linear(script, r->files[c].offset, r->files[c].size, @@ -436,12 +442,17 @@ rom_load_bios(romdef_t *r, const wchar_t *fn, int test_only) case 1: /* interleaved file(s) */ /* We loop on all files. */ for (c=0; cnfiles/2; c+=2) { + /* If this is a no-load file, skip. */ + if (r->files[c].offset == 0xffffffff) + continue; + wcscpy(script, path); wcscat(script, r->files[c].path); pc_path(script, sizeof_w(script), NULL); wcscpy(temp, path); wcscat(temp, r->files[c+1].path); pc_path(temp, sizeof_w(temp), NULL); + i = rom_load_interleaved(script, temp, r->files[c].offset, r->files[c].size, diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index ff2e19f..8c72192 100644 --- a/src/scsi/scsi.c +++ b/src/scsi/scsi.c @@ -8,7 +8,7 @@ * * Handling of the SCSI controllers. * - * Version: @(#)scsi.c 1.0.7 2018/04/10 + * Version: @(#)scsi.c 1.0.8 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -73,9 +73,6 @@ uint8_t SCSIStatus = SCSI_STATUS_OK; char scsi_fn[SCSI_NUM][512]; uint16_t scsi_hd_location[SCSI_NUM]; -int scsi_card_current = 0; -int scsi_card_last = 0; - uint32_t SCSI_BufferLength; static volatile mutex_t *scsiMutex; @@ -222,10 +219,8 @@ scsi_card_init(void) } } - if (scsi_cards[scsi_card_current].device) - device_add(scsi_cards[scsi_card_current].device); - - scsi_card_last = scsi_card_current; + if (scsi_cards[scsi_card].device) + device_add(scsi_cards[scsi_card].device); } @@ -234,11 +229,11 @@ scsi_card_reset(void) { void *p = NULL; - if (scsi_cards[scsi_card_current].device) { - p = device_get_priv(scsi_cards[scsi_card_current].device); + if (scsi_cards[scsi_card].device) { + p = device_get_priv(scsi_cards[scsi_card].device); if (p != NULL) { - if (scsi_cards[scsi_card_current].reset) - scsi_cards[scsi_card_current].reset(p); + if (scsi_cards[scsi_card].reset) + scsi_cards[scsi_card].reset(p); } } } diff --git a/src/scsi/scsi.h b/src/scsi/scsi.h index ae146b2..6ce462f 100644 --- a/src/scsi/scsi.h +++ b/src/scsi/scsi.h @@ -8,7 +8,7 @@ * * SCSI controller handler header. * - * Version: @(#)scsi.h 1.0.6 2018/04/10 + * Version: @(#)scsi.h 1.0.7 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -307,7 +307,6 @@ extern int mode_select_init(uint8_t command, uint16_t pl_length, uint8_t do_save extern int mode_select_terminate(int force); extern int mode_select_write(uint8_t val); -extern int scsi_card_current; extern uint8_t scsi_disks[16][8]; extern void scsi_dev_log(const char *fmt, ...); diff --git a/src/serial.c b/src/serial.c index a2d63da..3804564 100644 --- a/src/serial.c +++ b/src/serial.c @@ -8,7 +8,7 @@ * * Implementation of 8250-style serial port. * - * Version: @(#)serial.c 1.0.1 2018/02/14 + * Version: @(#)serial.c 1.0.2 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,9 +47,9 @@ #include "pic.h" #include "mem.h" #include "rom.h" -#include "serial.h" #include "timer.h" -#include "mouse.h" +#include "device.h" +#include "serial.h" enum { @@ -60,332 +60,390 @@ enum { }; -SERIAL serial1, serial2; -int serial_do_log = 0; +#ifdef ENABLE_SERIAL_LOG +int serial_do_log = ENABLE_SERIAL_LOG; +#endif -void -serial_reset(void) -{ - serial1.iir = serial1.ier = serial1.lcr = 0; - serial2.iir = serial2.ier = serial2.lcr = 0; - serial1.fifo_read = serial1.fifo_write = 0; - serial2.fifo_read = serial2.fifo_write = 0; -} +static const struct { + uint16_t addr; + int8_t irq; + int8_t pad; +} addr_list[] = { /* valid port addresses */ + { SERIAL1_ADDR, 4 }, + { SERIAL2_ADDR, 3 } +}; +static SERIAL ports[SERIAL_MAX]; /* the ports */ -void -serial_update_ints(SERIAL *serial) +static void +update_ints(SERIAL *dev) { int stat = 0; - serial->iir = 1; + dev->iir = 1; - if ((serial->ier & 4) && (serial->int_status & SERIAL_INT_LSR)) /*Line status interrupt*/ { + if ((dev->ier & 4) && (dev->int_status & SERIAL_INT_LSR)) { + /*Line status interrupt*/ stat = 1; - serial->iir = 6; - } else if ((serial->ier & 1) && (serial->int_status & SERIAL_INT_RECEIVE)) /*Recieved data available*/ { + dev->iir = 6; + } else if ((dev->ier & 1) && (dev->int_status & SERIAL_INT_RECEIVE)) { + /*Recieved data available*/ stat = 1; - serial->iir = 4; - } else if ((serial->ier & 2) && (serial->int_status & SERIAL_INT_TRANSMIT)) /*Transmit data empty*/ { + dev->iir = 4; + } else if ((dev->ier & 2) && (dev->int_status & SERIAL_INT_TRANSMIT)) { + /*Transmit data empty*/ stat = 1; - serial->iir = 2; - } else if ((serial->ier & 8) && (serial->int_status & SERIAL_INT_MSR)) /*Modem status interrupt*/ { + dev->iir = 2; + } else if ((dev->ier & 8) && (dev->int_status & SERIAL_INT_MSR)) { + /*Modem status interrupt*/ stat = 1; - serial->iir = 0; + dev->iir = 0; } - if (stat && ((serial->mctrl & 8) || PCJR)) - picintlevel(1 << serial->irq); + if (stat && ((dev->mcr & 8) || PCJR)) + picintlevel(1 << dev->irq); else - picintc(1 << serial->irq); + picintc(1 << dev->irq); } -void -serial_clear_fifo(SERIAL *serial) +static void +clear_fifo(SERIAL *dev) { - memset(serial->fifo, 0, 256); - serial->fifo_read = serial->fifo_write = 0; + memset(dev->fifo, 0x00, 256); + dev->fifo_read = dev->fifo_write = 0; } -void -serial_write_fifo(SERIAL *serial, uint8_t dat) +static void +write_fifo(SERIAL *dev, uint8_t dat) { - serial->fifo[serial->fifo_write] = dat; - serial->fifo_write = (serial->fifo_write + 1) & 0xFF; - if (!(serial->lsr & 1)) { - serial->lsr |= 1; - serial->int_status |= SERIAL_INT_RECEIVE; - serial_update_ints(serial); + dev->fifo[dev->fifo_write] = dat; + dev->fifo_write = (dev->fifo_write + 1) & 0xff; + if (! (dev->lsr & 1)) { + dev->lsr |= 1; + dev->int_status |= SERIAL_INT_RECEIVE; + update_ints(dev); } } -uint8_t -serial_read_fifo(SERIAL *serial) +static uint8_t +read_fifo(SERIAL *dev) { - if (serial->fifo_read != serial->fifo_write) { - serial->dat = serial->fifo[serial->fifo_read]; - serial->fifo_read = (serial->fifo_read + 1) & 0xFF; + if (dev->fifo_read != dev->fifo_write) { + dev->dat = dev->fifo[dev->fifo_read]; + dev->fifo_read = (dev->fifo_read + 1) & 0xff; } - return serial->dat; + return(dev->dat); } -void -serial_write(uint16_t addr, uint8_t val, void *p) +static void +receive_callback(void *priv) { - SERIAL *serial = (SERIAL *)p; + SERIAL *dev = (SERIAL *)priv; - switch (addr&7) { + dev->delay = 0; + + if (dev->fifo_read != dev->fifo_write) { + dev->lsr |= 1; + dev->int_status |= SERIAL_INT_RECEIVE; + update_ints(dev); + } +} + + +static void +reset_port(SERIAL *dev) +{ + dev->iir = dev->ier = dev->lcr = 0; + dev->fifo_read = dev->fifo_write = 0; + + dev->int_status = 0x00; +} + + +static void +serial_write(uint16_t addr, uint8_t val, void *priv) +{ + SERIAL *dev = (SERIAL *)priv; + + switch (addr & 7) { case 0: - if (serial->lcr & 0x80) { - serial->dlab1 = val; + if (dev->lcr & 0x80) { + dev->dlab1 = val; return; } - serial->thr = val; - serial->lsr |= 0x20; - serial->int_status |= SERIAL_INT_TRANSMIT; - serial_update_ints(serial); - if (serial->mctrl & 0x10) { - serial_write_fifo(serial, val); - } + dev->thr = val; + dev->lsr |= 0x20; + dev->int_status |= SERIAL_INT_TRANSMIT; + update_ints(dev); + if (dev->mcr & 0x10) + write_fifo(dev, val); break; + case 1: - if (serial->lcr & 0x80) { - serial->dlab2 = val; + if (dev->lcr & 0x80) { + dev->dlab2 = val; return; } - serial->ier = val & 0xf; - serial_update_ints(serial); + dev->ier = val & 0xf; + update_ints(dev); break; + case 2: - serial->fcr = val; + dev->fcr = val; break; + case 3: - serial->lcr = val; + dev->lcr = val; break; + case 4: - if ((val & 2) && !(serial->mctrl & 2)) { - if (serial->rcr_callback) - serial->rcr_callback((struct SERIAL *)serial, serial->rcr_callback_p); + if ((val & 2) && !(dev->mcr & 2)) { + if (dev->rts_callback) + dev->rts_callback(dev, dev->rts_callback_p); } - serial->mctrl = val; + dev->mcr = val; if (val & 0x10) { uint8_t new_msr; - + new_msr = (val & 0x0c) << 4; new_msr |= (val & 0x02) ? 0x10: 0; new_msr |= (val & 0x01) ? 0x20: 0; - - if ((serial->msr ^ new_msr) & 0x10) + + if ((dev->msr ^ new_msr) & 0x10) new_msr |= 0x01; - if ((serial->msr ^ new_msr) & 0x20) + if ((dev->msr ^ new_msr) & 0x20) new_msr |= 0x02; - if ((serial->msr ^ new_msr) & 0x80) + if ((dev->msr ^ new_msr) & 0x80) new_msr |= 0x08; - if ((serial->msr & 0x40) && !(new_msr & 0x40)) + if ((dev->msr & 0x40) && !(new_msr & 0x40)) new_msr |= 0x04; - serial->msr = new_msr; + dev->msr = new_msr; } break; + case 5: - serial->lsr = val; - if (serial->lsr & 0x01) - serial->int_status |= SERIAL_INT_RECEIVE; - if (serial->lsr & 0x1e) - serial->int_status |= SERIAL_INT_LSR; - if (serial->lsr & 0x20) - serial->int_status |= SERIAL_INT_TRANSMIT; - serial_update_ints(serial); + dev->lsr = val; + if (dev->lsr & 0x01) + dev->int_status |= SERIAL_INT_RECEIVE; + if (dev->lsr & 0x1e) + dev->int_status |= SERIAL_INT_LSR; + if (dev->lsr & 0x20) + dev->int_status |= SERIAL_INT_TRANSMIT; + update_ints(dev); break; + case 6: - serial->msr = val; - if (serial->msr & 0x0f) - serial->int_status |= SERIAL_INT_MSR; - serial_update_ints(serial); + dev->msr = val; + if (dev->msr & 0x0f) + dev->int_status |= SERIAL_INT_MSR; + update_ints(dev); break; + case 7: - serial->scratch = val; + dev->scratch = val; break; } } -uint8_t -serial_read(uint16_t addr, void *p) +static uint8_t +serial_read(uint16_t addr, void *priv) { - SERIAL *serial = (SERIAL *)p; - uint8_t temp = 0; + SERIAL *dev = (SERIAL *)priv; + uint8_t ret = 0x00; - switch (addr&7) { + switch (addr & 7) { case 0: - if (serial->lcr & 0x80) { - temp = serial->dlab1; + if (dev->lcr & 0x80) { + ret = dev->dlab1; break; } - serial->lsr &= ~1; - serial->int_status &= ~SERIAL_INT_RECEIVE; - serial_update_ints(serial); - temp = serial_read_fifo(serial); - if (serial->fifo_read != serial->fifo_write) { - serial->recieve_delay = 1000LL * TIMER_USEC; + dev->lsr &= ~1; + dev->int_status &= ~SERIAL_INT_RECEIVE; + update_ints(dev); + ret = read_fifo(dev); + if (dev->fifo_read != dev->fifo_write) { + dev->delay = 1000LL * TIMER_USEC; } break; + case 1: - if (serial->lcr & 0x80) - temp = serial->dlab2; + if (dev->lcr & 0x80) + ret = dev->dlab2; else - temp = serial->ier; + ret = dev->ier; break; + case 2: - temp = serial->iir; - if ((temp & 0xe) == 2) { - serial->int_status &= ~SERIAL_INT_TRANSMIT; - serial_update_ints(serial); + ret = dev->iir; + if ((ret & 0xe) == 2) { + dev->int_status &= ~SERIAL_INT_TRANSMIT; + update_ints(dev); } - if (serial->fcr & 1) - temp |= 0xc0; + if (dev->fcr & 1) + ret |= 0xc0; break; + case 3: - temp = serial->lcr; + ret = dev->lcr; break; + case 4: - temp = serial->mctrl; + ret = dev->mcr; break; + case 5: - if (serial->lsr & 0x20) - serial->lsr |= 0x40; - serial->lsr |= 0x20; - temp = serial->lsr; - if (serial->lsr & 0x1f) - serial->lsr &= ~0x1e; - serial->int_status &= ~SERIAL_INT_LSR; - serial_update_ints(serial); + if (dev->lsr & 0x20) + dev->lsr |= 0x40; + dev->lsr |= 0x20; + ret = dev->lsr; + if (dev->lsr & 0x1f) + dev->lsr &= ~0x1e; + dev->int_status &= ~SERIAL_INT_LSR; + update_ints(dev); break; + case 6: - temp = serial->msr; - serial->msr &= ~0x0f; - serial->int_status &= ~SERIAL_INT_MSR; - serial_update_ints(serial); + ret = dev->msr; + dev->msr &= ~0x0f; + dev->int_status &= ~SERIAL_INT_MSR; + update_ints(dev); break; + case 7: - temp = serial->scratch; + ret = dev->scratch; break; } - return temp; + return(ret); } -void -serial_recieve_callback(void *p) +static void * +serial_init(const device_t *info) { - SERIAL *serial = (SERIAL *)p; - - serial->recieve_delay = 0; - - if (serial->fifo_read != serial->fifo_write) { - serial->lsr |= 1; - serial->int_status |= SERIAL_INT_RECEIVE; - serial_update_ints(serial); - } + SERIAL *dev; + + /* Get the correct device. */ + dev = &ports[info->local - 1]; + + /* Set up callback functions. */ + dev->clear_fifo = clear_fifo; + dev->write_fifo = write_fifo; + + /* Clear port. */ + reset_port(dev); + + /* Enable the I/O handler for this port. */ + io_sethandler(dev->base, 8, + serial_read,NULL,NULL, serial_write,NULL,NULL, dev); + + timer_add(receive_callback, &dev->delay, &dev->delay, dev); + + pclog("SERIAL: COM%d (I/O=%04X, IRQ=%d)\n", + info->local, dev->base, dev->irq); + + return(dev); } -uint16_t base_address[2] = { 0x0000, 0x0000 }; - - -void -serial_remove(int port) +static void +serial_close(void *priv) { - if ((port < 1) || (port > 2)) { - fatal("serial_remove(): Invalid serial port: %i\n", port); - exit(-1); - } + SERIAL *dev = (SERIAL *)priv; - if (! serial_enabled[port - 1]) return; + /* Remove the I/O handler. */ + io_removehandler(dev->base, 8, + serial_read,NULL,NULL, serial_write,NULL,NULL, dev); - if (! base_address[port - 1]) return; - -/* pclog("Removing serial port %i at %04X...\n", port, base_address[port - 1]); */ - - switch(port) { - case 1: - io_removehandler(base_address[0], 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1); - base_address[0] = 0x0000; - break; - case 2: - io_removehandler(base_address[1], 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2); - base_address[1] = 0x0000; - break; - } + /* Clear port. */ + reset_port(dev); } +const device_t serial_1_device = { + "COM1:", + 0, + 1, + serial_init, serial_close, NULL, + NULL, NULL, NULL, NULL, + NULL +}; + + +const device_t serial_2_device = { + "COM2:", + 0, + 2, + serial_init, serial_close, NULL, + NULL, NULL, NULL, NULL, + NULL, +}; + + +/* (Re-)initialize all serial ports. */ void -serial_setup(int port, uint16_t addr, int irq) +serial_reset(void) { - /* pclog("Adding serial port %i at %04X...\n", port, addr); */ + SERIAL *dev; + int i; - switch(port) { - case 1: - if (!serial_enabled[0]) return; + pclog("SERIAL: reset ([%d] [%d])\n", serial_enabled[0], serial_enabled[1]); - if (base_address[0] != 0x0000) - serial_remove(port); - if (addr != 0x0000) { - base_address[0] = addr; - io_sethandler(addr, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1); - } - serial1.irq = irq; - break; + for (i = 0; i < SERIAL_MAX; i++) { + dev = &ports[i]; - case 2: - if (! serial_enabled[1]) return; + memset(dev, 0x00, sizeof(SERIAL)); - if (base_address[1] != 0x0000) - serial_remove(port); - if (addr != 0x0000) { - base_address[1] = addr; - io_sethandler(addr, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2); - } - serial2.irq = irq; - break; + dev->base = addr_list[i].addr; + dev->irq = addr_list[i].irq; - default: - fatal("serial_setup(): Invalid serial port: %i\n", port); - break; + /* Clear port. */ + reset_port(dev); } } +/* Set up (the address/IRQ of) one of the serial ports. */ void -serial_init(void) +serial_setup(int id, uint16_t port, int8_t irq) { - base_address[0] = 0x03f8; - base_address[1] = 0x02f8; + SERIAL *dev = &ports[id-1]; - if (serial_enabled[0]) { - /* pclog("Adding serial port 1...\n"); */ - memset(&serial1, 0, sizeof(serial1)); - io_sethandler(0x3f8, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial1); - serial1.irq = 4; - serial1.rcr_callback = NULL; - timer_add(serial_recieve_callback, &serial1.recieve_delay, &serial1.recieve_delay, &serial1); - } +#ifdef _DEBUG + pclog("SERIAL: setting up COM%d as %04X [enabled=%d]\n", + id, port, serial_enabled[id-1]); +#endif + if (! serial_enabled[id-1]) return; - if (serial_enabled[1]) { - /* pclog("Adding serial port 2...\n"); */ - memset(&serial2, 0, sizeof(serial2)); - io_sethandler(0x2f8, 0x0008, serial_read, NULL, NULL, serial_write, NULL, NULL, &serial2); - serial2.irq = 3; - serial2.rcr_callback = NULL; - timer_add(serial_recieve_callback, &serial2.recieve_delay, &serial2.recieve_delay, &serial2); - } + dev->base = port; + dev->irq = irq; +} + + +/* Attach another device (MOUSE) to a serial port. */ +SERIAL * +serial_attach(int port, void *func, void *arg) +{ + SERIAL *dev; + + /* No can do if port not enabled. */ + if (! serial_enabled[port-1]) return(NULL); + + /* Grab the desired port block. */ + dev = &ports[port-1]; + + /* Set up callback info. */ + dev->rts_callback = func; + dev->rts_callback_p = arg; + + return(dev); } diff --git a/src/serial.h b/src/serial.h index e42a671..ad54a07 100644 --- a/src/serial.h +++ b/src/serial.h @@ -8,7 +8,7 @@ * * Definitions for the SERIAL card. * - * Version: @(#)serial.h 1.0.2 2018/04/05 + * Version: @(#)serial.h 1.0.3 2018/04/19 * * Author: Fred N. van Kempen, * @@ -56,9 +56,6 @@ #define SERIAL2_ADDR 0x02f8 #define SERIAL2_IRQ 3 - -#ifdef WALTJE_SERIAL - /* Supported UART types. */ #define UART_TYPE_8250 0 /* standard NS8250 */ #define UART_TYPE_8250A 1 /* updated NS8250(A) */ @@ -68,14 +65,15 @@ #define UART_TYPE_16670 5 /* 16670 (64b fifo) */ -typedef struct _serial_ { +typedef struct SERIAL { int8_t port; /* port number (1,2,..) */ int8_t irq; /* IRQ channel used */ - uint16_t addr; /* I/O address used */ + uint16_t base; /* I/O address used */ + int8_t type; /* UART type */ uint8_t int_status; - uint8_t lsr, thr, mctrl, rcr, /* UART registers */ + uint8_t lsr, thr, mcr, rcr, /* UART registers */ iir, ier, lcr, msr; uint8_t dlab1, dlab2; uint8_t dat, @@ -83,64 +81,44 @@ typedef struct _serial_ { uint8_t scratch; uint8_t fcr; + /* Access to internal functions. */ + void (*clear_fifo)(struct SERIAL *); +#ifdef WALTJE_SERIAL + void (*write_fifo)(struct SERIAL *, uint8_t, int); +#else + void (*write_fifo)(struct SERIAL *, uint8_t); +#endif + /* Data for the RTS-toggle callback. */ - void (*rts_callback)(void *); + void (*rts_callback)(struct SERIAL *, void *); void *rts_callback_p; - uint8_t fifo[256]; - int fifo_read, fifo_write; - - int64_t receive_delay; + int64_t delay; +#ifdef WALTJE_SERIAL void *bh; /* BottomHalf handler */ +#endif + + int fifo_read, + fifo_write; + uint8_t fifo[256]; } SERIAL; +/* Global variables. */ +#ifdef EMU_DEVICE_H +extern const device_t serial_1_device; +extern const device_t serial_2_device; +#endif + + /* Functions. */ -extern void serial_init(void); extern void serial_reset(void); -extern void serial_setup(int port, uint16_t addr, int irq); -extern void serial_remove(int port); -extern SERIAL *serial_attach(int, void *, void *); -extern int serial_link(int, char *); +extern void serial_setup(int port, uint16_t addr, int8_t irq); +extern SERIAL *serial_attach(int port, void *func, void *priv); -extern void serial_clear_fifo(SERIAL *); -extern void serial_write_fifo(SERIAL *, uint8_t, int); - - -#else - - -void serial_remove(int port); -void serial_setup(int port, uint16_t addr, int irq); -void serial_init(void); -void serial_reset(); - -struct SERIAL; - -typedef struct -{ - uint8_t lsr,thr,mctrl,rcr,iir,ier,lcr,msr; - uint8_t dlab1,dlab2; - uint8_t dat; - uint8_t int_status; - uint8_t scratch; - uint8_t fcr; - - int irq; - - void (*rcr_callback)(struct SERIAL *serial, void *p); - void *rcr_callback_p; - uint8_t fifo[256]; - int fifo_read, fifo_write; - - int64_t recieve_delay; -} SERIAL; - -void serial_clear_fifo(SERIAL *); -void serial_write_fifo(SERIAL *serial, uint8_t dat); - -extern SERIAL serial1, serial2; +#ifdef WALTJE_SERIAL +extern int serial_link(int port, char *name); #endif diff --git a/src/sio/sio_fdc37c669.c b/src/sio/sio_fdc37c669.c index ef468fb..4ca51f7 100644 --- a/src/sio/sio_fdc37c669.c +++ b/src/sio/sio_fdc37c669.c @@ -8,7 +8,7 @@ * * Implementation of the SMC FDC37C669 Super I/O Chip. * - * Version: @(#)sio_fdc37c669.c 1.0.4 2018/04/07 + * Version: @(#)sio_fdc37c669.c 1.0.5 2018/04/19 * * Author: Miran Grca, * @@ -171,8 +171,10 @@ process_value: case 2: if (valxor & 8) { +#if 0 /* pclog("Removing UART1\n"); */ serial_remove(1); +#endif if ((fdc37c669_regs[2] & 8) && (fdc37c669_regs[0x24] >= 0x40)) { /* pclog("UART1 init (%02X, %i)\n", make_port(0x24), (fdc37c669_regs[0x28] & 0xF0) >> 4); */ @@ -181,8 +183,10 @@ process_value: } if (valxor & 0x80) { +#if 0 /* pclog("Removing UART2\n"); */ serial_remove(2); +#endif if ((fdc37c669_regs[2] & 0x80) && (fdc37c669_regs[0x25] >= 0x40)) { /* pclog("UART2 init (%02X, %i)\n", make_port(0x25), fdc37c669_regs[0x28] & 0x0F); */ @@ -240,8 +244,10 @@ process_value: case 0x24: if (valxor & 0xfe) { +#if 0 /* pclog("Removing UART1\n"); */ serial_remove(1); +#endif if ((fdc37c669_regs[2] & 8) && (fdc37c669_regs[0x24] >= 0x40)) { /* pclog("UART1 init (%02X, %i)\n", make_port(0x24), (fdc37c669_regs[0x28] & 0xF0) >> 4); */ @@ -252,8 +258,10 @@ process_value: case 0x25: if (valxor & 0xfe) { +#if 0 /* pclog("Removing UART2\n"); */ serial_remove(2); +#endif if ((fdc37c669_regs[2] & 0x80) && (fdc37c669_regs[0x25] >= 0x40)) { /* pclog("UART2 init (%02X, %i)\n", make_port(0x25), fdc37c669_regs[0x28] & 0x0F); */ @@ -264,8 +272,10 @@ process_value: case 0x28: if (valxor & 0xf) { +#if 0 /* pclog("Removing UART2\n"); */ serial_remove(2); +#endif if ((fdc37c669_regs[2] & 0x80) && (fdc37c669_regs[0x25] >= 0x40)) { /* pclog("UART2 init (%02X, %i)\n", make_port(0x25), fdc37c669_regs[0x28] & 0x0F); */ @@ -274,8 +284,10 @@ process_value: } if (valxor & 0xf0) { +#if 0 /* pclog("Removing UART1\n"); */ serial_remove(1); +#endif if ((fdc37c669_regs[2] & 8) && (fdc37c669_regs[0x24] >= 0x40)) { /* pclog("UART1 init (%02X, %i)\n", make_port(0x24), (fdc37c669_regs[0x28] & 0xF0) >> 4); */ @@ -311,10 +323,14 @@ void fdc37c669_reset(void) { fdc_reset(fdc37c669_fdc); +#if 0 serial_remove(1); +#endif serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); +#if 0 serial_remove(2); +#endif serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); //FIXME: parallel_remove(1); diff --git a/src/sio/sio_fdc37c66x.c b/src/sio/sio_fdc37c66x.c index 34522d6..e90f82c 100644 --- a/src/sio/sio_fdc37c66x.c +++ b/src/sio/sio_fdc37c66x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C663 and FDC37C665 Super * I/O Chips. * - * Version: @(#)sio_fdc37c66x.c 1.0.4 2018/04/07 + * Version: @(#)sio_fdc37c66x.c 1.0.5 2018/04/19 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -234,7 +234,9 @@ static void fdc37c66x_write(uint16_t port, uint8_t val, void *priv) } if (valxor & 0x60) { +#if 0 serial_remove(1); +#endif set_com34_addr(); set_serial1_addr(); set_serial2_addr(); @@ -243,12 +245,16 @@ static void fdc37c66x_write(uint16_t port, uint8_t val, void *priv) case 2: if (valxor & 7) { +#if 0 serial_remove(1); +#endif set_serial1_addr(); } if (valxor & 0x70) { +#if 0 serial_remove(2); +#endif set_serial2_addr(); } break; @@ -297,10 +303,14 @@ static void fdc37c66x_reset(void) com3_addr = 0x338; com4_addr = 0x238; +#if 0 serial_remove(1); +#endif serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); +#if 0 serial_remove(2); +#endif serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); //FIXME: parallel_remove(1); diff --git a/src/sio/sio_fdc37c93x.c b/src/sio/sio_fdc37c93x.c index 9fcdc49..7457b6f 100644 --- a/src/sio/sio_fdc37c93x.c +++ b/src/sio/sio_fdc37c93x.c @@ -9,7 +9,7 @@ * Implementation of the SMC FDC37C932FR and FDC37C935 Super * I/O Chips. * - * Version: @(#)sio_fdc37c93x.c 1.0.6 2018/04/07 + * Version: @(#)sio_fdc37c93x.c 1.0.7 2018/04/19 * * Author: Miran Grca, * @@ -127,7 +127,9 @@ static void fdc37c93x_serial_handler(int uart) uint8_t global_enable = !!(fdc37c93x_regs[0x22] & (1 << uart_no)); uint8_t local_enable = !!fdc37c93x_ld_regs[uart_no][0x30]; +#if 0 serial_remove(uart); +#endif if (global_enable && local_enable) { ld_port = make_port(uart_no); diff --git a/src/sio/sio_pc87306.c b/src/sio/sio_pc87306.c index 995844c..4231ceb 100644 --- a/src/sio/sio_pc87306.c +++ b/src/sio/sio_pc87306.c @@ -8,7 +8,7 @@ * * Emulation of the NatSemi PC87306 Super I/O chip. * - * Version: @(#)sio_pc87306.c 1.0.4 2018/04/07 + * Version: @(#)sio_pc87306.c 1.0.5 2018/04/19 * * Author: Miran Grca, * @@ -238,7 +238,9 @@ process_value: if (valxor & 2) { +#if 0 serial_remove(1); +#endif if (val & 2) { serial1_handler(); @@ -246,7 +248,9 @@ process_value: } if (valxor & 4) { +#if 0 serial_remove(2); +#endif if (val & 4) { serial2_handler(); @@ -298,10 +302,12 @@ process_value: { serial1_handler(); } +#if 0 else { serial_remove(1); } +#endif } if (valxor & 0xf0) @@ -310,10 +316,12 @@ process_value: { serial2_handler(); } +#if 0 else { serial_remove(2); } +#endif } break; case 2: @@ -321,9 +329,11 @@ process_value: { if (val & 1) { +#if 0 //FIXME: parallel_remove(1); serial_remove(1); serial_remove(2); +#endif fdc_remove(pc87306_fdc); } else @@ -479,8 +489,10 @@ void pc87306_reset(void) //FIXME: parallel_remove(1); //FIXME: parallel_remove(2); lpt1_handler(); +#if 0 serial_remove(1); serial_remove(2); +#endif serial1_handler(); serial2_handler(); fdc_reset(pc87306_fdc); diff --git a/src/sio/sio_um8669f.c b/src/sio/sio_um8669f.c index ac4ddc2..0f24d1d 100644 --- a/src/sio/sio_um8669f.c +++ b/src/sio/sio_um8669f.c @@ -29,7 +29,7 @@ * 70 - IRQ * 74 - DMA * - * Version: @(#)sio_um8669f.c 1.0.4 2018/04/07 + * Version: @(#)sio_um8669f.c 1.0.5 2018/04/19 * * Author: Miran Grca, * Sarah Walker, @@ -165,7 +165,9 @@ void um8669f_pnp_write(uint16_t port, uint8_t val, void *p) case DEV_COM1: if ((um8669f->cur_reg == REG_ENABLE) && valxor) { +#if 0 serial_remove(1); +#endif if (um8669f->dev[DEV_COM1].enable & 1) serial_setup(1, um8669f->dev[DEV_COM1].addr, um8669f->dev[DEV_COM1].irq); } @@ -173,7 +175,9 @@ void um8669f_pnp_write(uint16_t port, uint8_t val, void *p) case DEV_COM2: if ((um8669f->cur_reg == REG_ENABLE) && valxor) { +#if 0 serial_remove(2); +#endif if (um8669f->dev[DEV_COM2].enable & 1) serial_setup(2, um8669f->dev[DEV_COM2].addr, um8669f->dev[DEV_COM2].irq); } @@ -283,10 +287,14 @@ void um8669f_reset(void) fdc_reset(um8669f_global.fdc); +#if 0 serial_remove(1); +#endif serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); +#if 0 serial_remove(2); +#endif serial_setup(2, SERIAL2_ADDR, SERIAL2_IRQ); //FIXME: parallel_remove(1); diff --git a/src/sio/sio_w83877f.c b/src/sio/sio_w83877f.c index e3a1e0d..2eeba7c 100644 --- a/src/sio/sio_w83877f.c +++ b/src/sio/sio_w83877f.c @@ -11,7 +11,7 @@ * Winbond W83877F Super I/O Chip * Used by the Award 430HX * - * Version: @(#)sio_w83877f.c 1.0.4 2018/04/07 + * Version: @(#)sio_w83877f.c 1.0.5 2018/04/19 * * Author: Miran Grca, * @@ -323,7 +323,9 @@ void w83877f_serial_handler(int id) if ((w83877f_regs[4] & reg_mask) || !(w83877f_regs[reg_id] & 0xc0)) { +#if 0 serial_remove(id); +#endif } else { diff --git a/src/sound/midi.h b/src/sound/midi.h index 34ff678..a926ace 100644 --- a/src/sound/midi.h +++ b/src/sound/midi.h @@ -8,7 +8,7 @@ * * Definitions for the MIDI module. * - * Version: @(#)midi.h 1.0.4 2018/04/10 + * Version: @(#)midi.h 1.0.5 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -57,9 +57,6 @@ typedef struct { } midi_device_t; -extern int midi_device_current; - - extern int midi_device_available(int card); extern const char *midi_device_getname(int card); #ifdef EMU_DEVICE_H diff --git a/src/sound/openal.c b/src/sound/openal.c index 8d4cdd9..b7c379c 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -8,7 +8,7 @@ * * Interface to the OpenAL sound processing library. * - * Version: @(#)openal.c 1.0.8 2018/04/10 + * Version: @(#)openal.c 1.0.9 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -241,9 +241,9 @@ pclog("SOUND: inital()\n"); * If the current MIDI device is neither "none", nor system MIDI, * initialize the MIDI buffer and source, otherwise, do not. */ - str = midi_device_get_internal_name(midi_device_current); + str = midi_device_get_internal_name(midi_device); if ((str != NULL) && - (!strcmp(str, "none") || !strcmp(str, SYSTEM_MIDI_INT))) init_midi = 1; + (!strcmp(str, "none") || !strcmp(str, SYSTEM_MIDI_INT))) init_midi = 1; #ifdef USE_OPENAL if (sound_is_float) { diff --git a/src/sound/snd_mpu401.c b/src/sound/snd_mpu401.c index f8860ab..e5b1ccb 100644 --- a/src/sound/snd_mpu401.c +++ b/src/sound/snd_mpu401.c @@ -8,7 +8,7 @@ * * Roland MPU-401 emulation. * - * Version: @(#)snd_mpu401.c 1.0.6 2018/04/10 + * Version: @(#)snd_mpu401.c 1.0.7 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -901,7 +901,7 @@ mpu401_device_add(void) if (!mpu401_standalone_enable) return; - n = sound_card_get_internal_name(sound_card_current); + n = sound_card_get_internal_name(sound_card); if (n != NULL) { if (!strcmp(n, "sb16") || !strcmp(n, "sbawe32")) return; } diff --git a/src/sound/sound.c b/src/sound/sound.c index e538d5c..675de0e 100644 --- a/src/sound/sound.c +++ b/src/sound/sound.c @@ -8,7 +8,7 @@ * * Sound emulation core. * - * Version: @(#)sound.c 1.0.9 2018/04/09 + * Version: @(#)sound.c 1.0.10 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -69,7 +69,6 @@ typedef struct { int sound_pos_global = 0; -int sound_gain = 0; volatile int soundon = 1; @@ -295,7 +294,7 @@ sound_reset(void) { int i; - pclog("SOUND: reset (current=%d)\n", sound_card_current); + pclog("SOUND: reset (current=%d)\n", sound_card); /* Kill the CD-Audio thread. */ sound_cd_stop(); diff --git a/src/sound/sound.h b/src/sound/sound.h index f4ed05b..22b860b 100644 --- a/src/sound/sound.h +++ b/src/sound/sound.h @@ -8,7 +8,7 @@ * * Definitions for the Sound Emulation core. * - * Version: @(#)sound.h 1.0.6 2018/04/10 + * Version: @(#)sound.h 1.0.7 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -45,6 +45,9 @@ #define CD_FREQ 44100 #define CD_BUFLEN (CD_FREQ / 10) +#define SOUND_NONE 0 +#define SOUND_INTERNAL 1 + #ifdef __cplusplus extern "C" { @@ -58,8 +61,6 @@ extern int gated, speakon; extern int sound_pos_global; -extern int sound_card_current; -extern int sound_gain; extern void snddev_log(const char *fmt, ...); diff --git a/src/sound/sound_dev.c b/src/sound/sound_dev.c index 9e0e3ef..590f199 100644 --- a/src/sound/sound_dev.c +++ b/src/sound/sound_dev.c @@ -8,7 +8,7 @@ * * Sound devices support module. * - * Version: @(#)sound_dev.c 1.0.3 2018/04/10 + * Version: @(#)sound_dev.c 1.0.4 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -87,6 +87,7 @@ extern const device_t wss_device; static const sound_t sound_cards[] = { {"Disabled", "none", NULL }, + {"Internal", "internal", NULL }, {"[ISA] Adlib", "adlib", &adlib_device }, {"[ISA] Adlib Gold", "adlibgold", &adgold_device }, {"[ISA] Creative Music System", "cms", &cms_device }, diff --git a/src/version.h b/src/version.h index 72b48a1..fdc5d13 100644 --- a/src/version.h +++ b/src/version.h @@ -8,7 +8,7 @@ * * Define application version and build info. * - * Version: @(#)version.h 1.0.7 2018/04/09 + * Version: @(#)version.h 1.0.8 2018/04/19 * * Author: Fred N. van Kempen, * @@ -55,7 +55,7 @@ #define EMU_VER_MAJOR 0 #define EMU_VER_MINOR 1 #define EMU_VER_REV 5 -#define EMU_VER_PATCH 1 +#define EMU_VER_PATCH 2 /* Standard C preprocessor macros. */ diff --git a/src/video/vid_ega.c b/src/video/vid_ega.c index 7013fec..02b64ab 100644 --- a/src/video/vid_ega.c +++ b/src/video/vid_ega.c @@ -9,7 +9,7 @@ * Emulation of the EGA, Chips & Technologies SuperEGA, and * AX JEGA graphics cards. * - * Version: @(#)vid_ega.c 1.0.6 2018/04/09 + * Version: @(#)vid_ega.c 1.0.7 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, diff --git a/src/video/vid_s3_virge.c b/src/video/vid_s3_virge.c index 7654c5f..359e096 100644 --- a/src/video/vid_s3_virge.c +++ b/src/video/vid_s3_virge.c @@ -8,7 +8,7 @@ * * S3 ViRGE emulation. * - * Version: @(#)vid_s3_virge.c 1.0.8 2018/04/09 + * Version: @(#)vid_s3_virge.c 1.0.9 2018/04/15 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -479,7 +479,7 @@ static void s3_virge_out(uint16_t addr, uint8_t val, void *p) case 2: case 3: svga->bpp = 15; break; case 4: case 5: svga->bpp = 16; break; case 7: svga->bpp = 24; break; - case 13: svga->bpp = ((vid_card == VID_VIRGEVX_VLB) || (vid_card == VID_VIRGEVX_PCI)) ? 24 : 32; break; + case 13: svga->bpp = ((video_card == VID_VIRGEVX_VLB) || (video_card == VID_VIRGEVX_PCI)) ? 24 : 32; break; default: svga->bpp = 8; break; } break; @@ -594,7 +594,7 @@ static void s3_virge_recalctimings(svga_t *svga) } } - if ((vid_card != VID_VIRGEVX_VLB) && (vid_card != VID_VIRGEVX_PCI)) + if ((video_card != VID_VIRGEVX_VLB) && (video_card != VID_VIRGEVX_PCI)) { if ((svga->bpp == 15) || (svga->bpp == 16)) { @@ -658,7 +658,7 @@ static void s3_virge_recalctimings(svga_t *svga) if (((svga->miscout >> 2) & 3) == 3) { int n = svga->seqregs[0x12] & 0x1f; - int r = (svga->seqregs[0x12] >> 5) & ((virge->is_375 || ((vid_card == VID_VIRGEVX_VLB) || (vid_card == VID_VIRGEVX_PCI))) ? 7 : 3); + int r = (svga->seqregs[0x12] >> 5) & ((virge->is_375 || ((video_card == VID_VIRGEVX_VLB) || (video_card == VID_VIRGEVX_PCI))) ? 7 : 3); int m = svga->seqregs[0x13] & 0x7f; double freq = (((double)m + 2) / (((double)n + 2) * (double)(1 << r))) * 14318184.0; diff --git a/src/video/vid_svga.h b/src/video/vid_svga.h index fc9f98c..7de2c96 100644 --- a/src/video/vid_svga.h +++ b/src/video/vid_svga.h @@ -227,25 +227,25 @@ extern uint32_t shade[5][256]; static __inline uint32_t svga_color_transform(uint32_t color) { uint8_t *clr8 = (uint8_t *) &color; - if (!video_grayscale && !invert_display) + if (!vid_grayscale && !invert_display) return color; - if (video_grayscale) + if (vid_grayscale) { - if (video_graytype) + if (vid_graytype) { - if (video_graytype == 1) + if (vid_graytype == 1) color = ((54 * (uint32_t)clr8[2]) + (183 * (uint32_t)clr8[1]) + (18 * (uint32_t)clr8[0])) / 255; else color = ((uint32_t)clr8[2] + (uint32_t)clr8[1] + (uint32_t)clr8[0]) / 3; } else color = ((76 * (uint32_t)clr8[2]) + (150 * (uint32_t)clr8[1]) + (29 * (uint32_t)clr8[0])) / 255; - switch (video_grayscale) + switch (vid_grayscale) { case 2: case 3: case 4: - color = shade[video_grayscale][color]; + color = shade[vid_grayscale][color]; break; default: clr8[3] = 0; diff --git a/src/video/vid_svga_render.c b/src/video/vid_svga_render.c index 3a9d9a8..d8b2355 100644 --- a/src/video/vid_svga_render.c +++ b/src/video/vid_svga_render.c @@ -8,7 +8,7 @@ * * SVGA renderers. * - * Version: @(#)vid_svga_render.c 1.0.8 2018/03/18 + * Version: @(#)vid_svga_render.c 1.0.9 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -47,11 +47,6 @@ #include "vid_svga_render.h" -int invert_display = 0; -int video_grayscale = 0; -int video_graytype = 0; - - uint32_t shade[5][256] = { {0}, // RGB Color (unused) diff --git a/src/video/video.c b/src/video/video.c index 0e8240f..e06f918 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.13 2018/04/10 + * Version: @(#)video.c 1.0.14 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -437,7 +437,7 @@ video_update_timing(void) timing = &timing_endeavor; break; default: - new_card = video_old_to_new(vid_card); + new_card = video_old_to_new(video_card); timing = video_card_gettiming(new_card); break; } diff --git a/src/video/video.h b/src/video/video.h index bb7551a..f844d8e 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -8,7 +8,7 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.15 2018/04/10 + * Version: @(#)video.h 1.0.16 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -185,9 +185,6 @@ extern bitmap_t *screen, extern PALETTE cgapal, cgapal_mono[6]; extern uint32_t pal_lookup[256]; -extern int video_fullscreen, - video_fullscreen_scale, - video_fullscreen_first; extern int fullchange; extern uint8_t fontdat[2048][8]; extern uint8_t fontdatm[2048][16]; @@ -198,11 +195,9 @@ extern uint32_t *video_6to8, *video_15to32, *video_16to32; extern int xsize,ysize; -extern int enable_overscan; extern int update_overscan; extern int overscan_x, overscan_y; -extern int force_43; extern int video_timing_read_b, video_timing_read_w, video_timing_read_l; @@ -213,11 +208,7 @@ extern int video_speed; extern int video_res_x, video_res_y, video_bpp; -extern int vid_resize; extern int cga_palette; -extern int vid_cga_contrast; -extern int video_grayscale; -extern int video_graytype; extern float cpuclock; extern int emu_fps, @@ -263,7 +254,7 @@ extern void updatewindowsize(int x, int y); extern void video_init(void); extern void video_close(void); -extern void video_reset(int card); +extern void video_reset(void); extern uint8_t video_force_resize_get(void); extern void video_force_resize_set(uint8_t res); extern void video_update_timing(void); diff --git a/src/video/video_dev.c b/src/video/video_dev.c index 9eddc88..82b13fb 100644 --- a/src/video/video_dev.c +++ b/src/video/video_dev.c @@ -12,7 +12,7 @@ * an "extern" reference to its device into this file, and * add an entry for it into the table. * - * Version: @(#)video_dev.c 1.0.16 2018/04/10 + * Version: @(#)video_dev.c 1.0.17 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -326,10 +326,10 @@ video_detect(void) void -video_reset(int card) +video_reset(void) { - pclog("VIDEO: reset (romset=%d, vid_card=%d, internal=%d)\n", - romset, card, (machines[machine].flags & MACHINE_VIDEO)?1:0); + pclog("VIDEO: reset (romset=%d, video_card=%d, internal=%d)\n", + romset, video_card, (machines[machine].flags & MACHINE_VIDEO)?1:0); /* Reset the CGA palette. */ cga_palette = 0; @@ -341,8 +341,8 @@ video_reset(int card) loadfont(L"video/mdsi/genius/8x12.bin", 4); /* Do not initialize internal cards here. */ - if ((card == VID_NONE) || \ - (card == VID_INTERNAL) || machines[machine].fixed_vidcard) return; + if ((video_card == VID_NONE) || \ + (video_card == VID_INTERNAL) || machines[machine].fixed_vidcard) return; if (fontdatksc5601 != NULL) { free(fontdatksc5601); @@ -350,7 +350,7 @@ video_reset(int card) } /* Initialize the video card. */ - device_add(video_cards[video_old_to_new(card)].device); + device_add(video_cards[video_old_to_new(video_card)].device); /* Enable the Voodoo if configured. */ if (voodoo_enabled) @@ -487,7 +487,7 @@ video_is_mda(void) return(0); } - return((video_cards[video_old_to_new(vid_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_MDA); + return((video_cards[video_old_to_new(video_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_MDA); } @@ -521,7 +521,7 @@ video_is_cga(void) return(0); } - return((video_cards[video_old_to_new(vid_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_CGA); + return((video_cards[video_old_to_new(video_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_CGA); } @@ -555,5 +555,5 @@ video_is_ega_vga(void) return(1); } - return((video_cards[video_old_to_new(vid_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_SPECIAL); + return((video_cards[video_old_to_new(video_card)].flags & VIDEO_FLAG_TYPE_MASK) == VIDEO_FLAG_TYPE_SPECIAL); } diff --git a/src/win/mingw/Makefile.MinGW b/src/win/mingw/Makefile.MinGW index 1e8be79..5677ba4 100644 --- a/src/win/mingw/Makefile.MinGW +++ b/src/win/mingw/Makefile.MinGW @@ -8,7 +8,7 @@ # # Makefile for Windows systems using the MinGW32 environment. # -# Version: @(#)Makefile.mingw 1.0.24 2018/04/09 +# Version: @(#)Makefile.mingw 1.0.26 2018/04/14 # # Author: Fred N. van Kempen, # @@ -119,6 +119,9 @@ endif ifndef I686 I686 := n endif +ifndef XTA + XTA := n +endif ifndef OPENAL OPENAL := y endif @@ -444,6 +447,10 @@ ifeq ($(DEV_BRANCH), y) DEVBROBJ += m_at_440fx.o endif + ifeq ($(XTA), y) + OPTS += -DUSE_XTA + endif + ifeq ($(STEALTH32), y) OPTS += -DUSE_STEALTH32 DEVBROBJ += vid_icd2061.o @@ -542,6 +549,9 @@ HDDOBJ := hdd.o \ hdc_mfm_at.o \ hdc_esdi_at.o hdc_esdi_mca.o \ hdc_ide.o +ifeq ($(XTA), y) +HDDOBJ += hdc_ide_xta.o +endif CDROMOBJ := cdrom.o \ cdrom_dosbox.o cdrom_image.o cdrom_null.o diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index 7e05498..6a58632 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.10 2018/04/10 +# Version: @(#)Makefile.VC 1.0.12 2018/04/14 # # Author: Fred N. van Kempen, # @@ -119,6 +119,9 @@ endif ifndef I686 I686 := n endif +ifndef XTA + XTA := n +endif ifndef OPENAL OPENAL := y endif @@ -412,6 +415,10 @@ ifeq ($(DEV_BRANCH), y) DEVBROBJ += m_at_440fx.obj endif + ifeq ($(XTA), y) + OPTS += -DUSE_XTA + endif + ifeq ($(STEALTH32), y) OPTS += -DUSE_STEALTH32 DEVBROBJ += vid_icd2061.obj @@ -507,6 +514,9 @@ HDDOBJ := hdd.obj \ hdc_mfm_at.obj \ hdc_esdi_at.obj hdc_esdi_mca.obj \ hdc_ide.obj +ifeq ($(XTA), y) +HDDOBJ += hdc_ide_xta.o +#endif CDROMOBJ := cdrom.obj \ cdrom_dosbox.obj cdrom_image.obj cdrom_null.obj diff --git a/src/win/win.c b/src/win/win.c index 0e6ea6a..28e4e71 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * Platform main support module for Windows. * - * Version: @(#)win.c 1.0.12 2018/04/10 + * Version: @(#)win.c 1.0.13 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -367,7 +367,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) int argc, i; /* Set this to the default value (windowed mode). */ - video_fullscreen = 0; + vid_fullscreen = 0; /* We need this later. */ hinstance = hInst; @@ -620,7 +620,7 @@ plat_vidapi(const char *name) } /* Default value. */ - return(1); + return(0); } @@ -644,10 +644,7 @@ plat_vidapi_name(int api) break; case 1: -#if 0 - /* Direct3D is default. */ name = "d3d"; -#endif break; #endif @@ -711,11 +708,11 @@ plat_setvid(int api) void plat_vidsize(int x, int y) { - if (! vid_apis[video_fullscreen][vid_api].resize) return; + if (! vid_apis[vid_fullscreen][vid_api].resize) return; startblit(); video_wait_for_blit(); - vid_apis[video_fullscreen][vid_api].resize(x, y); + vid_apis[vid_fullscreen][vid_api].resize(x, y); endblit(); } @@ -723,7 +720,7 @@ plat_vidsize(int x, int y) int get_vidpause(void) { - return(vid_apis[video_fullscreen][vid_api].pause()); + return(vid_apis[vid_fullscreen][vid_api].pause()); } @@ -733,13 +730,13 @@ plat_setfullscreen(int on) HWND *hw; /* Want off and already off? */ - if (!on && !video_fullscreen) return; + if (!on && !vid_fullscreen) return; /* Want on and already on? */ - if (on && video_fullscreen) return; + if (on && vid_fullscreen) return; - if (on && video_fullscreen_first) { - video_fullscreen_first = 0; + if (on && vid_fullscreen_first) { + vid_fullscreen_first = 0; ui_msgbox(MBX_INFO, (wchar_t *)IDS_2107); } @@ -750,10 +747,10 @@ plat_setfullscreen(int on) win_mouse_close(); /* Close the current mode, and open the new one. */ - vid_apis[video_fullscreen][vid_api].close(); - video_fullscreen = on; - hw = (video_fullscreen) ? &hwndMain : &hwndRender; - vid_apis[video_fullscreen][vid_api].init((void *) *hw); + vid_apis[vid_fullscreen][vid_api].close(); + vid_fullscreen = on; + hw = (vid_fullscreen) ? &hwndMain : &hwndRender; + vid_apis[vid_fullscreen][vid_api].init((void *) *hw); #ifdef USE_WX wx_set_fullscreen(on); @@ -767,7 +764,7 @@ plat_setfullscreen(int on) /* Finally, handle the host's mouse cursor. */ /* pclog("%s full screen, %s cursor\n", on ? "enter" : "leave", on ? "hide" : "show"); */ - show_cursor(video_fullscreen ? 0 : -1); + show_cursor(vid_fullscreen ? 0 : -1); } diff --git a/src/win/win_d3d.cpp b/src/win/win_d3d.cpp index 92bdb66..fbc36e0 100644 --- a/src/win/win_d3d.cpp +++ b/src/win/win_d3d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct3D 9. * - * Version: @(#)win_d3d.cpp 1.0.6 2018/03/25 + * Version: @(#)win_d3d.cpp 1.0.7 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -103,7 +103,7 @@ d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h) int ratio_w, ratio_h; double hsr, gsr, ra, d; - switch (video_fullscreen_scale) { + switch (vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: d3d_size_default(w_rect, l, t, r, b); break; diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index e73d252..ebe53a1 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -11,7 +11,7 @@ * NOTES: This code should be re-merged into a single init() with a * 'fullscreen' argument, indicating FS mode is requested. * - * Version: @(#)win_ddraw.cpp 1.0.3 2018/03/17 + * Version: @(#)win_ddraw.cpp 1.0.4 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -349,9 +349,9 @@ ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h) int ratio_w, ratio_h; double hsr, gsr, ra, d; - pclog("video_fullscreen_scale = %i\n", video_fullscreen_scale); + pclog("vid_fullscreen_scale = %i\n", vid_fullscreen_scale); - switch (video_fullscreen_scale) { + switch (vid_fullscreen_scale) { case FULLSCR_SCALE_FULL: ddraw_fs_size_default(w_rect, r_dest); break; diff --git a/src/win/win_devconf.c b/src/win/win_devconf.c index 9792db2..4a73963 100644 --- a/src/win/win_devconf.c +++ b/src/win/win_devconf.c @@ -12,7 +12,7 @@ * and builds a complete Win32 DIALOG resource block in a * buffer in memory, and then passes that to the API handler. * - * Version: @(#)win_devconf.c 1.0.9 2018/04/07 + * Version: @(#)win_devconf.c 1.0.10 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -56,8 +56,114 @@ #include "win.h" -static device_t *config_device; -static uint8_t deviceconfig_changed = 0; +static const device_t *devconf_device; +static int8_t devconf_changed = 0; + + +static void +dlg_init(HWND hdlg) +{ + wchar_t temp[512]; + char ansitmp[512]; + const device_config_t *cfg; + const device_config_selection_t *sel; + const device_t *dev = devconf_device; + int c, id, num, val; + wchar_t* str; + HWND h; + + id = IDC_CONFIG_BASE; + cfg = dev->config; + + while (cfg->type != -1) { + sel = cfg->selection; + h = GetDlgItem(hdlg, id); + + switch (cfg->type) { + case CONFIG_BINARY: + val = config_get_int(dev->name, + cfg->name, cfg->default_int); + SendMessage(h, BM_SETCHECK, val, 0); + id++; + break; + + case CONFIG_SELECTION: + val = config_get_int(dev->name, + cfg->name, cfg->default_int); + c = 0; + while (sel->description && sel->description[0]) { + mbstowcs(temp, sel->description, sizeof_w(temp)); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)temp); + if (val == sel->value) + SendMessage(h, CB_SETCURSEL, c, 0); + sel++; + c++; + } + id += 2; + break; + + case CONFIG_MIDI: + val = config_get_int(dev->name, + cfg->name, cfg->default_int); + num = plat_midi_get_num_devs(); + for (c = 0; c < num; c++) { + plat_midi_get_dev_name(c, ansitmp); + mbstowcs(temp, ansitmp, sizeof_w(temp)); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)temp); + if (val == c) + SendMessage(h, CB_SETCURSEL, c, 0); + } + id += 2; + break; + + case CONFIG_SPINNER: + val = config_get_int(dev->name, + cfg->name, cfg->default_int); + _swprintf(temp, L"%i", val); + SendMessage(h, WM_SETTEXT, 0, (LPARAM)temp); + id += 2; + break; + + case CONFIG_FNAME: + str = config_get_wstring(dev->name, cfg->name, NULL); + if (str != NULL) + SendMessage(h, WM_SETTEXT, 0, (LPARAM)str); + id += 3; + break; + + case CONFIG_HEX16: + val = config_get_hex16(dev->name, + cfg->name, cfg->default_int); + c = 0; + while (sel->description && sel->description[0]) { + mbstowcs(temp, sel->description, sizeof_w(temp)); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)temp); + if (val == sel->value) + SendMessage(h, CB_SETCURSEL, c, 0); + sel++; + c++; + } + id += 2; + break; + + case CONFIG_HEX20: + val = config_get_hex20(dev->name, + cfg->name, cfg->default_int); + c = 0; + while (sel->description && sel->description[0]) { + mbstowcs(temp, sel->description, sizeof_w(temp)); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)temp); + if (val == sel->value) + SendMessage(h, CB_SETCURSEL, c, 0); + sel++; + c++; + } + id += 2; + break; + } + cfg++; + } +} #ifdef __amd64__ @@ -67,235 +173,132 @@ static BOOL CALLBACK #endif dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { - wchar_t ws[512]; - char s[512]; + wchar_t ws[512], temp[512]; + char s[512], *ansistr; + const device_config_selection_t *sel; + const device_t *dev = devconf_device; + const device_config_t *cfg = dev->config; + int c, cid, changed, id, val; HWND h; - int val_int; - int id; - int c; - int num; - int changed; - int cid; - const device_config_t *config; - LPTSTR lptsTemp; switch (message) { case WM_INITDIALOG: - id = IDC_CONFIG_BASE; - config = config_device->config; - lptsTemp = (LPTSTR)malloc(512); - - while (config->type != -1) { - const device_config_selection_t *selection = config->selection; - h = GetDlgItem(hdlg, id); - - switch (config->type) { - case CONFIG_BINARY: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); - - SendMessage(h, BM_SETCHECK, val_int, 0); - - id++; - break; - - case CONFIG_SELECTION: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); - - c = 0; - while (selection->description && selection->description[0]) { - mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - id += 2; - break; - - case CONFIG_MIDI: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); - - num = plat_midi_get_num_devs(); - for (c = 0; c < num; c++) { - plat_midi_get_dev_name(c, s); - mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == c) - SendMessage(h, CB_SETCURSEL, c, 0); - } - id += 2; - break; - - case CONFIG_SPINNER: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); - - _swprintf(ws, L"%i", val_int); - SendMessage(h, WM_SETTEXT, 0, (LPARAM)ws); - id += 2; - break; - - case CONFIG_FNAME: - { - wchar_t* str = config_get_wstring((char *)config_device->name, (char *)config->name, 0); - if (str) - SendMessage(h, WM_SETTEXT, 0, (LPARAM)str); - id += 3; - } - break; - - case CONFIG_HEX16: - val_int = config_get_hex16((char *)config_device->name, (char *)config->name, config->default_int); - - c = 0; - while (selection->description && selection->description[0]) { - mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - id += 2; - break; - - case CONFIG_HEX20: - val_int = config_get_hex20((char *)config_device->name, (char *)config->name, config->default_int); - - c = 0; - while (selection->description && selection->description[0]) { - mbstowcs(lptsTemp, selection->description, strlen(selection->description) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)lptsTemp); - if (val_int == selection->value) - SendMessage(h, CB_SETCURSEL, c, 0); - selection++; - c++; - } - id += 2; - break; - } - config++; - } - - free(lptsTemp); + dlg_init(hdlg); return TRUE; case WM_COMMAND: cid = LOWORD(wParam); if (cid == IDOK) { id = IDC_CONFIG_BASE; - config = config_device->config; changed = 0; - while (config->type != -1) { - const device_config_selection_t *selection = config->selection; + while (cfg->type != -1) { + sel = cfg->selection; h = GetDlgItem(hdlg, id); - switch (config->type) { + switch (cfg->type) { case CONFIG_BINARY: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); + val = config_get_int(dev->name, cfg->name, cfg->default_int); - if (val_int != SendMessage(h, BM_GETCHECK, 0, 0)) + if (val != SendMessage(h, BM_GETCHECK, 0, 0)) changed = 1; id++; break; case CONFIG_SELECTION: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); + val = config_get_int(dev->name, cfg->name, cfg->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; + sel++; - if (val_int != selection->value) + if (val != sel->value) changed = 1; id += 2; break; case CONFIG_MIDI: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); + val = config_get_int(dev->name, cfg->name, cfg->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); - if (val_int != c) + if (val != c) changed = 1; id += 2; break; case CONFIG_FNAME: - { - char* str = config_get_string((char *)config_device->name, (char *)config->name, (char*)""); - SendMessage(h, WM_GETTEXT, 511, (LPARAM)s); - if (strcmp(str, s)) - changed = 1; - id += 3; - } + ansistr = config_get_string(dev->name, cfg->name, ""); + SendMessage(h, WM_GETTEXT, sizeof(s), (LPARAM)s); + if (strcmp(ansistr, s)) + changed = 1; + id += 3; break; case CONFIG_SPINNER: - val_int = config_get_int((char *)config_device->name, (char *)config->name, config->default_int); - if (val_int > config->spinner.max) - val_int = config->spinner.max; - else if (val_int < config->spinner.min) - val_int = config->spinner.min; + val = config_get_int(dev->name, cfg->name, cfg->default_int); + if (val > cfg->spinner.max) + val = cfg->spinner.max; + else if (val < cfg->spinner.min) + val = cfg->spinner.min; - SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); - wcstombs(s, ws, 79); /*tic*/ + SendMessage(h, WM_GETTEXT, sizeof_w(temp), (LPARAM)temp); + wcstombs(s, temp, 79); /*tic*/ sscanf(s, "%i", &c); - if (val_int != c) + if (val != c) changed = 1; id += 2; break; case CONFIG_HEX16: - val_int = config_get_hex16((char *)config_device->name, (char *)config->name, config->default_int); + val = config_get_hex16(dev->name, cfg->name, cfg->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; + sel++; - if (val_int != selection->value) + if (val != sel->value) changed = 1; id += 2; break; case CONFIG_HEX20: - val_int = config_get_hex20((char *)config_device->name, (char *)config->name, config->default_int); + val = config_get_hex20(dev->name, cfg->name, cfg->default_int); c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; + sel++; - if (val_int != selection->value) + if (val != sel->value) changed = 1; id += 2; break; } - config++; + cfg++; } if (! changed) { - deviceconfig_changed = 0; + devconf_changed = 0; EndDialog(hdlg, 0); return TRUE; } - deviceconfig_changed = 1; + devconf_changed = 1; id = IDC_CONFIG_BASE; - config = config_device->config; + cfg = dev->config; - while (config->type != -1) { - const device_config_selection_t *selection = config->selection; + while (cfg->type != -1) { + sel = cfg->selection; h = GetDlgItem(hdlg, id); - switch (config->type) { + switch (cfg->type) { case CONFIG_BINARY: - config_set_int((char *)config_device->name, (char *)config->name, SendMessage(h, BM_GETCHECK, 0, 0)); + config_set_int(dev->name, cfg->name, SendMessage(h, BM_GETCHECK, 0, 0)); id++; break; @@ -303,22 +306,22 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case CONFIG_SELECTION: c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; - config_set_int((char *)config_device->name, (char *)config->name, selection->value); + sel++; + config_set_int(dev->name, cfg->name, sel->value); id += 2; break; case CONFIG_MIDI: c = SendMessage(h, CB_GETCURSEL, 0, 0); - config_set_int((char *)config_device->name, (char *)config->name, c); + config_set_int(dev->name, cfg->name, c); id += 2; break; case CONFIG_FNAME: SendMessage(h, WM_GETTEXT, 511, (LPARAM)ws); - config_set_wstring((char *)config_device->name, (char *)config->name, ws); + config_set_wstring(dev->name, cfg->name, ws); id += 3; break; @@ -327,12 +330,12 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, WM_GETTEXT, 79, (LPARAM)ws); wcstombs(s, ws, 79); sscanf(s, "%i", &c); - if (c > config->spinner.max) - c = config->spinner.max; - else if (c < config->spinner.min) - c = config->spinner.min; + if (c > cfg->spinner.max) + c = cfg->spinner.max; + else if (c < cfg->spinner.min) + c = cfg->spinner.min; - config_set_int((char *)config_device->name, (char *)config->name, c); + config_set_int(dev->name, cfg->name, c); id += 2; break; @@ -340,8 +343,8 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case CONFIG_HEX16: c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; - config_set_hex16((char *)config_device->name, (char *)config->name, selection->value); + sel++; + config_set_hex16(dev->name, cfg->name, sel->value); id += 2; break; @@ -349,27 +352,27 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) case CONFIG_HEX20: c = SendMessage(h, CB_GETCURSEL, 0, 0); for (; c > 0; c--) - selection++; - config_set_hex20((char *)config_device->name, (char *)config->name, selection->value); + sel++; + config_set_hex20(dev->name, cfg->name, sel->value); id += 2; break; } - config++; + cfg++; } EndDialog(hdlg, 0); return TRUE; } else if (cid == IDCANCEL) { - deviceconfig_changed = 0; + devconf_changed = 0; EndDialog(hdlg, 0); return TRUE; } else { - int id = IDC_CONFIG_BASE; - const device_config_t *config = config_device->config; + id = IDC_CONFIG_BASE; + cfg = dev->config; - while (config->type != -1) { - switch (config->type) { + while (cfg->type != -1) { + switch (cfg->type) { case CONFIG_BINARY: id++; break; @@ -389,26 +392,26 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) file_filter[0] = 0; c = 0; - while (config->file_filter[c].description && config->file_filter[c].description[0]) { + while (cfg->file_filter[c].description && cfg->file_filter[c].description[0]) { if (c > 0) strcat(file_filter, "|"); - strcat(file_filter, config->file_filter[c].description); + strcat(file_filter, cfg->file_filter[c].description); strcat(file_filter, " ("); d = 0; - while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0]) { + while (cfg->file_filter[c].extensions[d] && cfg->file_filter[c].extensions[d][0]) { if (d > 0) strcat(file_filter, ";"); strcat(file_filter, "*."); - strcat(file_filter, config->file_filter[c].extensions[d]); + strcat(file_filter, cfg->file_filter[c].extensions[d]); d++; } strcat(file_filter, ")|"); d = 0; - while (config->file_filter[c].extensions[d] && config->file_filter[c].extensions[d][0]) { + while (cfg->file_filter[c].extensions[d] && cfg->file_filter[c].extensions[d][0]) { if (d > 0) strcat(file_filter, ";"); strcat(file_filter, "*."); - strcat(file_filter, config->file_filter[c].extensions[d]); + strcat(file_filter, cfg->file_filter[c].extensions[d]); d++; } c++; @@ -427,7 +430,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } break; } - config++; + cfg++; } } break; @@ -437,63 +440,71 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) } -#define DATABLOCK_SIZE 16384 +/* + * Build the full dialog from the template in + * memory, and data taken from the device config. + */ +#define DLG_MAX_SIZE 16384 uint8_t deviceconfig_open(HWND hwnd, device_t *device) { char temp[128]; - const device_config_t *config = device->config; - uint16_t *data_block = malloc(DATABLOCK_SIZE); - uint16_t *data; - DLGTEMPLATE *dlg = (DLGTEMPLATE *)data_block; - DLGITEMTEMPLATE *item; - int y = 10; - int id = IDC_CONFIG_BASE; + const device_config_t *cfg = device->config; + uint16_t *blk, *data; + DLGITEMTEMPLATE *itm; + DLGTEMPLATE *dlg; + int id, y; - deviceconfig_changed = 0; + devconf_changed = 0; - memset(data_block, 0x00, DATABLOCK_SIZE); + /* Allocate the dialog data block. */ + blk = malloc(DLG_MAX_SIZE); + memset(blk, 0x00, DLG_MAX_SIZE); + dlg = (DLGTEMPLATE *)blk; - dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU; + /* Set up the basic dialog info. */ + dlg->style = DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | \ + WS_POPUP | WS_CAPTION | WS_SYSMENU; dlg->x = 10; dlg->y = 10; dlg->cx = 220; dlg->cy = 70; + y = dlg->y; + /* Dialog menu bar, title bar, class, etc. */ data = (uint16_t *)(dlg + 1); - - *data++ = 0; /*no menu*/ - *data++ = 0; /*predefined dialog box class*/ + *data++ = 0; /* no menu bar */ + *data++ = 0; /* predefined dialog box class */ sprintf(temp, "%s Configuration", device->name); data += MultiByteToWideChar(CP_ACP, 0, temp, -1, data, 50); - *data++ = 9; /*Point*/ + /* Font style and size to use. */ + *data++ = 9; /* point size */ data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 50); - if (((uintptr_t)data) & 2) data++; - while (config->type != -1) { - switch (config->type) { + /* Now add the items from the configuration. */ + id = IDC_CONFIG_BASE; + while (cfg->type != -1) { + switch (cfg->type) { case CONFIG_BINARY: - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX; + itm->x = 10; + itm->y = y; + itm->cx = 80; + itm->cy = 15; + itm->id = id++; - item->cx = 80; - item->cy = 15; - - item->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; *data++ = 0x0080; /* button class */ - data += MultiByteToWideChar(CP_ACP, 0, - config->description, -1, data, 256); + cfg->description, -1, data, 256); *data++ = 0; /* no creation data */ + /* Move to next available line. */ y += 20; break; @@ -501,223 +512,199 @@ deviceconfig_open(HWND hwnd, device_t *device) case CONFIG_MIDI: case CONFIG_HEX16: case CONFIG_HEX20: - /*Combo box*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; - - item->cx = 140; - item->cy = 150; - - item->style = WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_VSCROLL; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0085; /* combo box class */ + /* combo box */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | \ + CBS_DROPDOWNLIST | WS_VSCROLL; + itm->x = 70; + itm->y = y; + itm->cx = 140; + itm->cy = 150; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0085; /* combo box class */ data += MultiByteToWideChar(CP_ACP, 0, - config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - + cfg->description, -1, data, 256); + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; - - item->cx = 60; - item->cy = 15; - - item->style = WS_CHILD | WS_VISIBLE; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + /* static tex t*/ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE; + itm->x = 10; + itm->y = y; + itm->cx = 60; + itm->cy = 15; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0082; /* static class */ data += MultiByteToWideChar(CP_ACP, 0, - config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - + cfg->description, -1, data, 256); + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ + /* Move to next available line. */ y += 20; break; case CONFIG_SPINNER: - /*Spinner*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; - - item->cx = 140; - item->cy = 14; - - item->style = WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_NUMBER; - item->dwExtendedStyle = WS_EX_CLIENTEDGE; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0081; /* edit text class */ + /* spinner */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | \ + ES_AUTOHSCROLL | ES_NUMBER; + itm->dwExtendedStyle = WS_EX_CLIENTEDGE; + itm->x = 70; + itm->y = y; + itm->cx = 140; + itm->cy = 14; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0081; /* edit text class */ data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); - *data++ = 0; /* no creation data */ - + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ /* TODO: add up down class */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; - - item->cx = 60; - item->cy = 15; - - item->style = WS_CHILD | WS_VISIBLE; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + /* static text */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE; + itm->x = 10; + itm->y = y; + itm->cx = 60; + itm->cy = 15; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0082; /* static class */ data += MultiByteToWideChar(CP_ACP, 0, - config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - + cfg->description, -1, data, 256); + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ + /* Move to next available line. */ y += 20; break; case CONFIG_FNAME: - /*File*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 70; - item->y = y; - item->id = id++; - - item->cx = 100; - item->cy = 14; - - item->style = WS_CHILD | WS_VISIBLE | ES_READONLY; - item->dwExtendedStyle = WS_EX_CLIENTEDGE; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0081; /* edit text class */ + /* file */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | ES_READONLY; + itm->dwExtendedStyle = WS_EX_CLIENTEDGE; + itm->x = 70; + itm->y = y; + itm->id = id++; + itm->cx = 100; + itm->cy = 14; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0081; /* edit text class */ data += MultiByteToWideChar(CP_ACP, 0, "", -1, data, 256); - *data++ = 0; /* no creation data */ - + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ /* Button */ - item = (DLGITEMTEMPLATE *)data; - item->x = 175; - item->y = y; - item->id = id++; - - item->cx = 35; - item->cy = 14; - - item->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON; + itm->x = 175; + itm->y = y; + itm->cx = 35; + itm->cy = 14; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0080; /* button class */ data += MultiByteToWideChar(CP_ACP, 0, "Browse", -1, data, 256); - *data++ = 0; /* no creation data */ - + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ - /*Static text*/ - item = (DLGITEMTEMPLATE *)data; - item->x = 10; - item->y = y; - item->id = id++; - - item->cx = 60; - item->cy = 15; - - item->style = WS_CHILD | WS_VISIBLE; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0082; /* static class */ + /* static text */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE; + itm->x = 10; + itm->y = y; + itm->cx = 60; + itm->cy = 15; + itm->id = id++; + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0082; /* static class */ data += MultiByteToWideChar(CP_ACP, 0, - config->description, -1, data, 256); - *data++ = 0; /* no creation data */ - + cfg->description, -1, data, 256); + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; + data++; /* align */ + /* Move to next available line. */ y += 20; break; } + /* Align to next 4-byte boundary. */ if (((uintptr_t)data) & 2) data++; - config++; + /* Next item in configuration. */ + cfg++; } dlg->cdit = (id - IDC_CONFIG_BASE) + 2; - item = (DLGITEMTEMPLATE *)data; - item->x = 20; - item->y = y; - item->cx = 50; - item->cy = 14; - item->id = IDOK; /* OK button identifier */ - item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + itm->x = 20; + itm->y = y; + itm->cx = 50; + itm->cy = 14; + itm->id = IDOK; /* OK button identifier */ + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0080; /* button class */ data += MultiByteToWideChar(CP_ACP, 0, "OK", -1, data, 50); - *data++ = 0; /* no creation data */ - + *data++ = 0; /* no creation data */ if (((uintptr_t)data) & 2) - data++; - - item = (DLGITEMTEMPLATE *)data; - item->x = 80; - item->y = y; - item->cx = 50; - item->cy = 14; - item->id = IDCANCEL; /* OK button identifier */ - item->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; - - data = (uint16_t *)(item + 1); - *data++ = 0xFFFF; - *data++ = 0x0080; /* button class */ + data++; /* align */ + itm = (DLGITEMTEMPLATE *)data; + itm->style = WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON; + itm->x = 80; + itm->y = y; + itm->cx = 50; + itm->cy = 14; + itm->id = IDCANCEL; /* CANCEL button identifier */ + data = (uint16_t *)(itm + 1); + *data++ = 0xffff; + *data++ = 0x0080; /* button class */ data += MultiByteToWideChar(CP_ACP, 0, "Cancel", -1, data, 50); *data++ = 0; /* no creation data */ + /* Set final height of dialog. */ dlg->cy = y + 20; - config_device = device; + devconf_device = device; DialogBoxIndirect(hinstance, dlg, hwnd, dlg_proc); - free(data_block); + free(blk); - return deviceconfig_changed; + return(devconf_changed); } diff --git a/src/win/win_mouse.cpp b/src/win/win_mouse.cpp index e2befd7..684b05b 100644 --- a/src/win/win_mouse.cpp +++ b/src/win/win_mouse.cpp @@ -8,7 +8,7 @@ * * Mouse interface to host device. * - * Version: @(#)win_mouse.cpp 1.0.2 2018/03/07 + * Version: @(#)win_mouse.cpp 1.0.3 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -70,7 +70,7 @@ win_mouse_init(void) fatal("plat_mouse_init: CreateDevice failed\n"); if (FAILED(lpdi_mouse->SetCooperativeLevel(hwndMain, - DISCL_FOREGROUND | (video_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE)))) + DISCL_FOREGROUND | (vid_fullscreen ? DISCL_EXCLUSIVE : DISCL_NONEXCLUSIVE)))) fatal("plat_mouse_init: SetCooperativeLevel failed\n"); if (FAILED(lpdi_mouse->SetDataFormat(&c_dfDIMouse))) @@ -101,7 +101,7 @@ mouse_poll(void) lpdi_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate); } - if (mouse_capture || video_fullscreen) { + if (mouse_capture || vid_fullscreen) { if (x != mousestate.lX || y != mousestate.lY || z != mousestate.lZ) { mouse_x += mousestate.lX; mouse_y += mousestate.lY; diff --git a/src/win/win_settings.c b/src/win/win_settings.c index df28ae8..3e0a658 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings.c 1.0.21 2018/04/09 + * Version: @(#)win_settings.c 1.0.22 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -87,7 +87,7 @@ static int temp_dynarec; #endif /* Video category. */ -static int temp_vid_card, temp_video_speed, temp_voodoo; +static int temp_video_card, temp_video_speed, temp_voodoo; /* Input devices category. */ static int temp_mouse, temp_joystick; @@ -182,7 +182,7 @@ settings_init(void) temp_sync = enable_sync; /* Video category */ - temp_vid_card = vid_card; + temp_video_card = video_card; temp_video_speed = video_speed; temp_voodoo = voodoo_enabled; @@ -191,8 +191,8 @@ settings_init(void) temp_joystick = joystick_type; /* Sound category */ - temp_sound_card = sound_card_current; - temp_midi_device = midi_device_current; + temp_sound_card = sound_card; + temp_midi_device = midi_device; temp_mpu401 = mpu401_standalone_enable; temp_opl3_type = opl3_type; temp_float = sound_is_float; @@ -212,7 +212,7 @@ settings_init(void) } /* Other peripherals category */ - temp_scsi_card = scsi_card_current; + temp_scsi_card = scsi_card; temp_hdc_type = hdc_type; temp_ide_ter = ide_enable[2]; temp_ide_ter_irq = ide_irq[2]; @@ -257,7 +257,7 @@ settings_changed(void) i = i || (temp_sync != enable_sync); /* Video category */ - i = i || (vid_card != temp_vid_card); + i = i || (video_card != temp_video_card); i = i || (video_speed != temp_video_speed); i = i || (voodoo_enabled != temp_voodoo); @@ -266,8 +266,8 @@ settings_changed(void) i = i || (joystick_type != temp_joystick); /* Sound category */ - i = i || (sound_card_current != temp_sound_card); - i = i || (midi_device_current != temp_midi_device); + i = i || (sound_card != temp_sound_card); + i = i || (midi_device != temp_midi_device); i = i || (mpu401_standalone_enable != temp_mpu401); i = i || (opl3_type != temp_opl3_type); i = i || (sound_is_float != temp_float); @@ -286,7 +286,7 @@ settings_changed(void) } /* Peripherals category */ - i = i || (temp_scsi_card != scsi_card_current); + i = i || (temp_scsi_card != scsi_card); i = i || (temp_hdc_type != hdc_type); i = i || (temp_ide_ter != ide_enable[2]); i = i || (temp_ide_ter_irq != ide_irq[2]); @@ -358,7 +358,7 @@ settings_save(void) enable_sync = temp_sync; /* Video category */ - vid_card = temp_vid_card; + video_card = temp_video_card; video_speed = temp_video_speed; voodoo_enabled = temp_voodoo; @@ -367,8 +367,8 @@ settings_save(void) joystick_type = temp_joystick; /* Sound category */ - sound_card_current = temp_sound_card; - midi_device_current = temp_midi_device; + sound_card = temp_sound_card; + midi_device = temp_midi_device; mpu401_standalone_enable = temp_mpu401; opl3_type = temp_opl3_type; sound_is_float = temp_float; @@ -388,7 +388,7 @@ settings_save(void) } /* Peripherals category */ - scsi_card_current = temp_scsi_card; + scsi_card = temp_scsi_card; hdc_type = temp_hdc_type; ide_enable[2] = temp_ide_ter; ide_irq[2] = temp_ide_ter_irq; diff --git a/src/win/win_settings_input.h b/src/win/win_settings_input.h index a0ad01e..d54db5f 100644 --- a/src/win/win_settings_input.h +++ b/src/win/win_settings_input.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_input.h 1.0.3 2018/04/10 + * Version: @(#)win_settings_input.h 1.0.4 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -51,7 +51,7 @@ mouse_valid(int num, int m) { const device_t *dev; - if ((num == MOUSE_TYPE_INTERNAL) && + if ((num == MOUSE_INTERNAL) && !(machines[m].flags & MACHINE_MOUSE)) return(0); dev = mouse_get_device(num); diff --git a/src/win/win_settings_machine.h b/src/win/win_settings_machine.h index 85ac430..1158e13 100644 --- a/src/win/win_settings_machine.h +++ b/src/win/win_settings_machine.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_machine.h 1.0.2 2018/04/07 + * Version: @(#)win_settings_machine.h 1.0.3 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -314,7 +314,13 @@ machine_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) if ((machines[temp_machine].flags & MACHINE_AT) && (machines[temp_machine].ram_granularity < 128)) temp_mem_size *= 1024; if (machines[temp_machine].flags & MACHINE_VIDEO) - vid_card = VID_INTERNAL; + video_card = VID_INTERNAL; + if (machines[temp_machine].flags & MACHINE_MOUSE) + mouse_type = MOUSE_INTERNAL; + if (machines[temp_machine].flags & MACHINE_SOUND) + sound_card = SOUND_INTERNAL; + if (machines[temp_machine].flags & MACHINE_HDC) + hdc_type = HDC_INTERNAL; return FALSE; default: diff --git a/src/win/win_settings_video.h b/src/win/win_settings_video.h index 055148f..2b7a3b3 100644 --- a/src/win/win_settings_video.h +++ b/src/win/win_settings_video.h @@ -8,7 +8,7 @@ * * Implementation of the Settings dialog. * - * Version: @(#)win_settings_video.h 1.0.1 2018/04/05 + * Version: @(#)win_settings_video.h 1.0.2 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -69,7 +69,7 @@ recalc_vid_list(HWND hdlg) device_is_valid(video_card_getdevice(c), machines[temp_machine].flags)) { mbstowcs(temp, stransi, sizeof_w(temp)); SendMessage(h, CB_ADDSTRING, 0, (LPARAM)temp); - if (video_new_to_old(c) == temp_vid_card) { + if (video_new_to_old(c) == temp_video_card) { SendMessage(h, CB_SETCURSEL, d, 0); found_card = 1; } @@ -141,7 +141,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp); wcstombs(tempA, temp, sizeof(tempA)); vid = video_card_getid(tempA); - temp_vid_card = video_new_to_old(vid); + temp_video_card = video_new_to_old(vid); h = GetDlgItem(hdlg, IDC_CONFIGURE_VID); if (video_card_has_config(vid)) @@ -176,7 +176,7 @@ video_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) h = GetDlgItem(hdlg, IDC_COMBO_VIDEO); SendMessage(h, CB_GETLBTEXT, SendMessage(h, CB_GETCURSEL, 0, 0), (LPARAM)temp); wcstombs(tempA, temp, sizeof(tempA)); - temp_vid_card = video_new_to_old(video_card_getid(tempA)); + temp_video_card = video_new_to_old(video_card_getid(tempA)); h = GetDlgItem(hdlg, IDC_COMBO_VIDEO_SPEED); temp_video_speed = SendMessage(h, CB_GETCURSEL, 0, 0) - 1; diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index c613d91..5d54d6f 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -8,7 +8,7 @@ * * Implementation of the Status Bar module. * - * Version: @(#)win_stbar.c 1.0.8 2018/04/10 + * Version: @(#)win_stbar.c 1.0.9 2018/04/14 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -673,7 +673,7 @@ ui_sb_update_panes(void) } if ((cdrom_drives[i].bus_type == CDROM_BUS_SCSI) && - (scsi_card_current == 0)) { + (scsi_card == 0)) { continue; } @@ -690,7 +690,7 @@ ui_sb_update_panes(void) } if ((zip_drives[i].bus_type == ZIP_BUS_SCSI) && - (scsi_card_current == 0)) { + (scsi_card == 0)) { continue; } @@ -699,7 +699,7 @@ ui_sb_update_panes(void) } } for (i=0; i * Miran Grca, @@ -366,13 +366,13 @@ ResetAllMenus(void) if (vid_resize) CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_DDRAW+vid_api, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_CGACON, vid_cga_contrast?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); - CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAYCT_601+vid_graytype, MF_CHECKED); + CheckMenuItem(menuMain, IDM_VID_GRAY_RGB+vid_grayscale, MF_CHECKED); } @@ -560,9 +560,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_FS_SQ: case IDM_VID_FS_INT: case IDM_VID_FS_KEEPRATIO: - CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED); - video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; - CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); + CheckMenuItem(hmenu, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_UNCHECKED); + vid_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; + CheckMenuItem(hmenu, IDM_VID_FS_FULL+vid_fullscreen_scale, MF_CHECKED); device_force_redraw(); config_save(); break; @@ -604,9 +604,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_GRAYCT_601: case IDM_VID_GRAYCT_709: case IDM_VID_GRAYCT_AVE: - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_UNCHECKED); - video_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; - CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+video_graytype, MF_CHECKED); + CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+vid_graytype, MF_UNCHECKED); + vid_graytype = LOWORD(wParam) - IDM_VID_GRAYCT_601; + CheckMenuItem(hmenu, IDM_VID_GRAYCT_601+vid_graytype, MF_CHECKED); device_force_redraw(); config_save(); break; @@ -616,9 +616,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_GRAY_AMBER: case IDM_VID_GRAY_GREEN: case IDM_VID_GRAY_WHITE: - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_UNCHECKED); - video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; - CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+video_grayscale, MF_CHECKED); + CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+vid_grayscale, MF_UNCHECKED); + vid_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB; + CheckMenuItem(hmenu, IDM_VID_GRAY_RGB+vid_grayscale, MF_CHECKED); device_force_redraw(); config_save(); break; @@ -704,7 +704,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_LBUTTONUP: - if (! video_fullscreen) + if (! vid_fullscreen) plat_mouse_capture(1); break; @@ -787,7 +787,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_RESETD3D: startblit(); - if (video_fullscreen) + if (vid_fullscreen) d3d_reset_fs(); else d3d_reset(); @@ -1059,7 +1059,7 @@ ui_init(int nCmdShow) plat_mouse_capture(0); } - if (video_fullscreen && keyboard_isfsexit()) { + if (vid_fullscreen && keyboard_isfsexit()) { /* Signal "exit fullscreen mode". */ /* pclog("leave full screen though key combination\n"); */ plat_setfullscreen(0); @@ -1086,7 +1086,7 @@ ui_init(int nCmdShow) wchar_t * ui_window_title(wchar_t *s) { - if (! video_fullscreen) { + if (! vid_fullscreen) { if (s != NULL) wcscpy(wTitle, s); else @@ -1141,7 +1141,7 @@ plat_resize(int x, int y) RECT r; #if 0 -pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", video_fullscreen, vid_api, x, y); +pclog("PLAT: VID[%d,%d] resizing to %dx%d\n", vid_fullscreen, vid_api, x, y); #endif /* First, see if we should resize the UI window. */ if (!vid_resize) { @@ -1173,7 +1173,7 @@ plat_mouse_capture(int on) RECT rect; /* Do not try to capture the mouse if no mouse configured. */ - if (mouse_type == MOUSE_TYPE_NONE) return; + if (mouse_type == MOUSE_NONE) return; if (on && !mouse_capture) { /* Enable the in-app mouse. */