diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 9f149dfde..55a2c9639 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -96,11 +96,11 @@ endif # Nothing should need changing from here on.. # ######################################################################### VPATH := $(EXPATH) . cpu \ - cdrom floppy game hdd machine \ + cdrom disk floppy game machine \ sound \ - sound/munt sound/munt/c_interface sound/munt/sha1 \ - sound/munt/srchelper \ - sound/resid-fp \ + sound/munt sound/munt/c_interface sound/munt/sha1 \ + sound/munt/srchelper \ + sound/resid-fp \ scsi video lzf network network/slirp win PLAT := win/ ifeq ($(X64), y) diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 0508e4bba..f2aaaf14f 100644 --- a/src/cdrom/cdrom.c +++ b/src/cdrom/cdrom.c @@ -9,7 +9,7 @@ * Implementation of the CD-ROM drive with SCSI(-like) * commands, for both ATAPI and SCSI usage. * - * Version: @(#)cdrom.c 1.0.8 2017/09/30 + * Version: @(#)cdrom.c 1.0.8 2017/10/01 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -27,8 +27,8 @@ #include "../piix.h" #include "../scsi/scsi.h" #include "../nvr.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../win/plat_iodev.h" #include "cdrom.h" diff --git a/src/config.c b/src/config.c index 084e0bcac..2793d9fde 100644 --- a/src/config.c +++ b/src/config.c @@ -34,14 +34,14 @@ #include "device.h" #include "lpt.h" #include "nvr.h" -#include "game/gameport.h" #include "cdrom/cdrom.h" +#include "disk/hdd.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "hdd/hdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" +#include "game/gameport.h" #include "machine/machine.h" #include "mouse.h" #include "network/network.h" diff --git a/src/device.c b/src/device.c index 168a8a9b1..552b22f53 100644 --- a/src/device.c +++ b/src/device.c @@ -9,7 +9,7 @@ * Implementation of the generic device interface to handle * all devices attached to the emulator. * - * Version: @(#)device.c 1.0.4 2017/09/24 + * Version: @(#)device.c 1.0.4 2017/10/01 * * Authors: Sarah Walker, * Miran Grca, @@ -49,7 +49,6 @@ void device_add(device_t *d) while (devices[c] != NULL && c < 256) c++; - if (c >= DEVICE_MAX) fatal("device_add : too many devices\n"); diff --git a/src/hdd/hdc.c b/src/disk/hdc.c similarity index 85% rename from src/hdd/hdc.c rename to src/disk/hdc.c index 51cc7b432..7c1a357f5 100644 --- a/src/hdd/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.2 2017/09/30 + * Version: @(#)hdc.c 1.0.2 2017/10/01 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -26,8 +26,8 @@ #include "hdc.h" -char hdc_name[16]; -int hdc_current; +char hdc_name[16]; /* configured HDC name */ +int hdc_current; static void * @@ -121,6 +121,36 @@ static struct { }; +/* Initialize the 'hdc_current' value based on configured HDC name. */ +void +hdc_init(char *name) +{ + int c; + + pclog("HDC: initializing..\n"); + + for (c=0; controllers[c].device; c++) { + if (! strcmp(name, controllers[c].internal_name)) { + hdc_current = c; + break; + } + } +} + + +/* Reset the HDC, whichever one that is. */ +void +hdc_reset(void) +{ + pclog("HDC: reset(current=%d, internal=%d)\n", + hdc_current, (machines[machine].flags & MACHINE_HAS_HDC)?1:0); + + /* If we have a valid controller, add its device. */ + if (hdc_current > 1) + device_add(controllers[hdc_current].device); +} + + char * hdc_get_name(int hdc) { @@ -154,34 +184,3 @@ hdc_current_is_mfm(void) { return(controllers[hdc_current].is_mfm); } - - -void -hdc_init(void) -{ - pclog("HDC: initializing..\n"); - - hdc_current = 0; -} - - -void -hdc_reset(char *name) -{ - int c; - - pclog("HDC: reset(name='%s', internal=%d)\n", name, - (machines[machine].flags & MACHINE_HAS_HDC)?1:0); - - for (c=0; controllers[c].device; c++) { - if (! strcmp(name, controllers[c].internal_name)) { - hdc_current = c; - - if (strcmp(name, "none") && strcmp(name, "internal")) { - device_add(controllers[c].device); - - return; - } - } - } -} diff --git a/src/hdd/hdc.h b/src/disk/hdc.h similarity index 94% rename from src/hdd/hdc.h rename to src/disk/hdc.h index fac94df1e..4949f0fb4 100644 --- a/src/hdd/hdc.h +++ b/src/disk/hdc.h @@ -8,7 +8,7 @@ * * Definitions for the common disk controller handler. * - * Version: @(#)hdc.h 1.0.3 2017/09/30 + * Version: @(#)hdc.h 1.0.3 2017/10/01 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -44,8 +44,8 @@ extern device_t xtide_ps2_device; /* xtide_ps2 */ extern device_t xtide_at_ps2_device; /* xtide_at_ps2 */ -extern void hdc_init(void); -extern void hdc_reset(char *name); +extern void hdc_init(char *name); +extern void hdc_reset(void); extern char *hdc_get_name(int hdc); extern char *hdc_get_internal_name(int hdc); diff --git a/src/hdd/hdc_esdi_at.c b/src/disk/hdc_esdi_at.c similarity index 100% rename from src/hdd/hdc_esdi_at.c rename to src/disk/hdc_esdi_at.c diff --git a/src/hdd/hdc_esdi_mca.c b/src/disk/hdc_esdi_mca.c similarity index 100% rename from src/hdd/hdc_esdi_mca.c rename to src/disk/hdc_esdi_mca.c diff --git a/src/hdd/hdc_ide.c b/src/disk/hdc_ide.c similarity index 99% rename from src/hdd/hdc_ide.c rename to src/disk/hdc_ide.c index 6d843f21d..90728036a 100644 --- a/src/hdd/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -632,7 +632,7 @@ void ide_reset(void) idecallback[2]=idecallback[3]=0; idecallback[4]=0; - pclog("IDE: start loading disks...\n"); + pclog("IDE: loading disks...\n"); c = 0; for (d = 0; d < HDD_NUM; d++) { @@ -649,7 +649,7 @@ void ide_reset(void) if (++c >= (IDE_NUM+XTIDE_NUM)) break; } } - pclog("IDE: done loading, %d disks.\n", c); + pclog("IDE: done, loaded %d disks.\n", c); for (d = 0; d < IDE_NUM; d++) { @@ -2309,8 +2309,6 @@ void ide_init_first(void) { int d; - pclog("IDE: initializing...\n"); - memset(ide_drives, 0x00, sizeof(ide_drives)); for (d = 0; d < (IDE_NUM+XTIDE_NUM); d++) { diff --git a/src/hdd/hdc_ide.h b/src/disk/hdc_ide.h similarity index 100% rename from src/hdd/hdc_ide.h rename to src/disk/hdc_ide.h diff --git a/src/hdd/hdc_mfm_at.c b/src/disk/hdc_mfm_at.c similarity index 100% rename from src/hdd/hdc_mfm_at.c rename to src/disk/hdc_mfm_at.c diff --git a/src/hdd/hdc_mfm_xt.c b/src/disk/hdc_mfm_xt.c similarity index 100% rename from src/hdd/hdc_mfm_xt.c rename to src/disk/hdc_mfm_xt.c diff --git a/src/hdd/hdc_xtide.c b/src/disk/hdc_xtide.c similarity index 84% rename from src/hdd/hdc_xtide.c rename to src/disk/hdc_xtide.c index 6cbefc17d..a97ac2a59 100644 --- a/src/hdd/hdc_xtide.c +++ b/src/disk/hdc_xtide.c @@ -21,7 +21,7 @@ * already on their way out, the newer IDE standard based on the * PC/AT controller and 16b design became the IDE we now know. * - * Version: @(#)xtide.c 1.0.5 2017/09/29 + * Version: @(#)xtide.c 1.0.6 2017/10/10 * * Authors: Sarah Walker, * Miran Grca, @@ -44,10 +44,10 @@ #include "hdc_ide.h" -#define XT_ROM_PATH L"roms/hdd/xtide/ide_xt.bin" -#define AT_ROM_PATH L"roms/hdd/xtide/ide_at.bin" -#define PS2_ROM_PATH L"roms/hdd/xtide/SIDE1V12.BIN" -#define PS2AT_ROM_PATH L"roms/hdd/xtide/ide_at_1_1_5.bin" +#define ROM_PATH_XT L"roms/hdd/xtide/ide_xt.bin" +#define ROM_PATH_AT L"roms/hdd/xtide/ide_at.bin" +#define ROM_PATH_PS2 L"roms/hdd/xtide/SIDE1V12.BIN" +#define ROM_PATH_PS2AT L"roms/hdd/xtide/ide_at_1_1_5.bin" typedef struct { @@ -91,13 +91,13 @@ static uint8_t xtide_read(uint16_t port, void *priv) { xtide_t *xtide = (xtide_t *)priv; - uint16_t tempw; + uint16_t tempw = 0xffff; switch (port & 0xf) { case 0x0: tempw = readidew(4); xtide->data_high = tempw >> 8; - return(tempw & 0xff); + break; case 0x1: case 0x2: @@ -106,17 +106,22 @@ xtide_read(uint16_t port, void *priv) case 0x5: case 0x6: case 0x7: - return(readide(4, (port & 0xf) | 0x1f0)); + tempw = readide(4, (port & 0xf) | 0x1f0); + break; case 0x8: - return(xtide->data_high); + tempw = xtide->data_high; + break; case 0xe: - return(readide(4, 0x3f6)); + tempw = readide(4, 0x3f6); + break; default: - return(0xff); + break; } + + return(tempw & 0xff); } @@ -127,7 +132,7 @@ xtide_init(void) memset(xtide, 0x00, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, XT_ROM_PATH, + rom_init(&xtide->bios_rom, ROM_PATH_XT, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); ide_xtide_init(); @@ -135,7 +140,7 @@ xtide_init(void) io_sethandler(0x0300, 16, xtide_read, NULL, NULL, xtide_write, NULL, NULL, xtide); - + return(xtide); } @@ -143,7 +148,7 @@ xtide_init(void) static int xtide_available(void) { - return(rom_present(XT_ROM_PATH)); + return(rom_present(ROM_PATH_XT)); } @@ -154,7 +159,7 @@ xtide_at_init(void) memset(xtide, 0x00, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, AT_ROM_PATH, + rom_init(&xtide->bios_rom, ROM_PATH_AT, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); ide_init(); @@ -166,7 +171,7 @@ xtide_at_init(void) static int xtide_at_available(void) { - return(rom_present(AT_ROM_PATH)); + return(rom_present(ROM_PATH_AT)); } @@ -177,7 +182,7 @@ xtide_ps2_init(void) memset(xtide, 0x00, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, PS2_ROM_PATH, + rom_init(&xtide->bios_rom, ROM_PATH_PS2, 0xc8000, 0x8000, 0x7fff, 0, MEM_MAPPING_EXTERNAL); ide_xtide_init(); @@ -193,7 +198,7 @@ xtide_ps2_init(void) static int xtide_ps2_available(void) { - return(rom_present(PS2_ROM_PATH)); + return(rom_present(ROM_PATH_PS2)); } @@ -204,7 +209,7 @@ xtide_at_ps2_init(void) memset(xtide, 0x00, sizeof(xtide_t)); - rom_init(&xtide->bios_rom, PS2AT_ROM_PATH, + rom_init(&xtide->bios_rom, ROM_PATH_PS2AT, 0xc8000, 0x4000, 0x3fff, 0, MEM_MAPPING_EXTERNAL); ide_init(); @@ -216,7 +221,7 @@ xtide_at_ps2_init(void) static int xtide_at_ps2_available(void) { - return(rom_present(PS2AT_ROM_PATH)); + return(rom_present(ROM_PATH_PS2AT)); } diff --git a/src/hdd/hdd.c b/src/disk/hdd.c similarity index 100% rename from src/hdd/hdd.c rename to src/disk/hdd.c diff --git a/src/hdd/hdd.h b/src/disk/hdd.h similarity index 100% rename from src/hdd/hdd.h rename to src/disk/hdd.h diff --git a/src/hdd/hdd_image.c b/src/disk/hdd_image.c similarity index 100% rename from src/hdd/hdd_image.c rename to src/disk/hdd_image.c diff --git a/src/hdd/hdd_table.c b/src/disk/hdd_table.c similarity index 100% rename from src/hdd/hdd_table.c rename to src/disk/hdd_table.c diff --git a/src/ibm.h b/src/ibm.h index d8831cc89..28fe029dc 100644 --- a/src/ibm.h +++ b/src/ibm.h @@ -10,7 +10,7 @@ * * !!!NOTE!!! The goal is to GET RID of this file. Do NOT add stuff !! * - * Version: @(#)ibm.h 1.0.6 2017/09/29 + * Version: @(#)ibm.h 1.0.7 2017/10/01 * * Authors: Sarah Walker, * Miran Grca, @@ -526,10 +526,6 @@ extern uint64_t timer_freq; extern int infocus; -extern void onesec(void); - -extern void resetpc_cad(void); -extern void ctrl_alt_esc(void); extern int dump_on_exit; extern int start_in_fullscreen; @@ -589,8 +585,24 @@ extern int scale; /* Function prototypes. */ +extern void pclog(const char *format, ...); +extern void pclog_w(const wchar_t *format, ...); +extern void fatal(const char *format, ...); +extern void pc_init_modules(void); +extern void pc_init(int argc, wchar_t *argv[]); +extern void pc_close(void); +extern void resetpchard_close(void); +extern void resetpchard_init(void); +extern void pc_reset_hard(void); +extern void pc_full_speed(void); +extern void pc_speed_changed(void); +extern void pc_send_cad(void); +extern void pc_send_cae(void); +extern void pc_run(void); +extern void onesec(void); + + extern int checkio(int port); -extern void closepc(void); extern void codegen_block_end(void); extern void codegen_reset(void); extern void cpu_set_edx(void); @@ -602,12 +614,9 @@ extern void execx86(int cycs); extern void flushmmucache(void); extern void flushmmucache_cr3(void); extern int idivl(int32_t val); -extern void initmodules(void); -extern void initpc(int argc, wchar_t *argv[]); extern void loadcscall(uint16_t seg); extern void loadcsjmp(uint16_t seg, uint32_t oxpc); extern void mmu_invalidate(uint32_t addr); -extern void pclog(const char *format, ...); extern void pmodeint(int num, int soft); extern void pmoderetf(int is32, uint16_t off); extern void pmodeiret(int is32); @@ -615,14 +624,9 @@ extern void port_92_clear_reset(void); extern uint8_t readdacfifo(void); extern void refreshread(void); extern void resetmcr(void); -extern void resetpchard_close(void); -extern void resetpchard_init(void); -extern void resetpchard(void); extern void resetreadlookup(void); extern void resetx86(void); -extern void runpc(void); extern void softresetx86(void); -extern void speedchanged(void); extern void x86_int_sw(int num); extern int x86_int_sw_rm(int num); extern void x86gpf(char *s, uint16_t error); @@ -633,10 +637,6 @@ extern void x87_dumpregs(void); extern void x87_reset(void); /* Platform functions. */ -extern void pclog(const char *format, ...); -extern void pclog_w(const wchar_t *format, ...); -extern void fatal(const char *format, ...); - extern void update_status_bar_icon(int tag, int active); extern void update_status_bar_icon_state(int tag, int state); extern void status_settextw(wchar_t *wstr); diff --git a/src/io.c b/src/io.c index d10793439..db9b05f68 100644 --- a/src/io.c +++ b/src/io.c @@ -120,11 +120,13 @@ void io_removehandler(uint16_t base, int size, } } +#if 0 uint8_t cgamode,cgastat=0,cgacol; int hsync; uint8_t lpt2dat; int sw9; int t237=0; +#endif uint8_t inb(uint16_t port) { uint8_t temp = 0xff; diff --git a/src/machine/machine_at.c b/src/machine/machine_at.c index d4eff4422..4c5196fed 100644 --- a/src/machine/machine_at.c +++ b/src/machine/machine_at.c @@ -13,8 +13,8 @@ #include "../game/gameport.h" #include "../keyboard_at.h" #include "../lpt.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "machine_common.h" #include "machine_at.h" diff --git a/src/machine/machine_at_ali1429.c b/src/machine/machine_at_ali1429.c index 83a71e47d..8b551cd3d 100644 --- a/src/machine/machine_at_ali1429.c +++ b/src/machine/machine_at_ali1429.c @@ -10,8 +10,8 @@ #include "../io.h" #include "../mem.h" #include "../device.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "machine_at.h" #include "machine_at_ali1429.h" diff --git a/src/machine/machine_at_sis_85c471.c b/src/machine/machine_at_sis_85c471.c index 91b2a2659..f8fc4af0b 100644 --- a/src/machine/machine_at_sis_85c471.c +++ b/src/machine/machine_at_sis_85c471.c @@ -24,11 +24,11 @@ #include "../device.h" #include "../lpt.h" #include "../serial.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../floppy/floppy.h" #include "../floppy/fdc.h" #include "../floppy/fdd.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" #include "machine_at.h" #include "machine_at_sis_85c471.h" diff --git a/src/machine/machine_ps1.c b/src/machine/machine_ps1.c index 45dddc558..2b2089815 100644 --- a/src/machine/machine_ps1.c +++ b/src/machine/machine_ps1.c @@ -19,11 +19,11 @@ #include "../lpt.h" #include "../serial.h" #include "../keyboard_at.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../floppy/floppy.h" #include "../floppy/fdd.h" #include "../floppy/fdc.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" #include "../sound/snd_ps1.h" #include "machine_common.h" #include "machine_ps1.h" diff --git a/src/pc.c b/src/pc.c index 6326b4787..e2f86c7c1 100644 --- a/src/pc.c +++ b/src/pc.c @@ -33,7 +33,13 @@ #include "dma.h" #include "random.h" #include "device.h" -#include "game/gameport.h" +#include "cdrom/cdrom.h" +#include "cdrom/cdrom_image.h" +#include "cdrom/cdrom_ioctl.h" +#include "cdrom/cdrom_null.h" +#include "disk/hdd.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/floppy_86f.h" #include "floppy/floppy_fdi.h" @@ -42,13 +48,7 @@ #include "floppy/floppy_td0.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "cdrom/cdrom.h" -#include "cdrom/cdrom_image.h" -#include "cdrom/cdrom_ioctl.h" -#include "cdrom/cdrom_null.h" -#include "hdd/hdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" +#include "game/gameport.h" #include "keyboard.h" #include "keyboard_at.h" #include "lpt.h" @@ -91,33 +91,33 @@ wchar_t exe_path[1024]; wchar_t cfg_path[1024]; wchar_t nvr_path[1024]; -int window_w, window_h, window_x, window_y, window_remember; +int window_w, window_h, window_x, window_y, window_remember; +int dump_on_exit = 0; +int start_in_fullscreen = 0; +int CPUID; +int vid_resize, vid_api; +int output; +int atfullspeed; +int cycles_lost = 0; +int clockrate; +int insc = 0; +float mips, flops; +int framecount, fps; +int win_title_update = 0; +int updatestatus = 0; +int pollmouse_delay = 2; +int mousecapture; +int suppress_overscan = 0; +int cpuspeed2; -int dump_on_exit = 0; -int start_in_fullscreen = 0; -int CPUID; -int vid_resize, vid_api; - -int cycles_lost = 0; - -int clockrate; -int insc=0; -float mips,flops; extern int mmuflush; extern int readlnum,writelnum; -void fullspeed(); - -int framecount,fps; - -int output; -int atfullspeed; - -int infocus; -int mousecapture; -void pclog(const char *format, ...) +/* Log something to the logfile or stdout. */ +void +pclog(const char *format, ...) { #ifndef RELEASE_BUILD va_list ap; @@ -128,7 +128,10 @@ void pclog(const char *format, ...) #endif } -void pclog_w(const wchar_t *format, ...) + +/* Log something to the logfile or stdout. */ +void +pclog_w(const wchar_t *format, ...) { #ifndef RELEASE_BUILD va_list ap; @@ -139,640 +142,600 @@ void pclog_w(const wchar_t *format, ...) #endif } -#ifndef __unix -#ifndef _LIBC -# define __builtin_expect(expr, val) (expr) -#endif -#undef memmem - - -/* Return the first occurrence of NEEDLE in HAYSTACK. */ -void *memmem (const void *haystack, size_t haystack_len, const void *needle, size_t needle_len) -{ - const char *begin; - const char *const last_possible = (const char *) haystack + haystack_len - needle_len; - - if (needle_len == 0) - /* The first occurrence of the empty string is deemed to occur at - the beginning of the string. */ - return (void *) haystack; - - /* Sanity check, otherwise the loop might search through the whole - memory. */ - if (__builtin_expect (haystack_len < needle_len, 0)) - return NULL; - - for (begin = (const char *) haystack; begin <= last_possible; ++begin) - if (begin[0] == ((const char *) needle)[0] && !memcmp ((const void *) &begin[1], (const void *) ((const char *) needle + 1), needle_len - 1)) - return (void *) begin; - - return NULL; -} -#endif - - -void fatal(const char *format, ...) +/* Log a fatal error, and display a UI message before exiting. */ +void +fatal(const char *format, ...) { char msg[1024]; -#ifndef __unix - char *newline; -#endif va_list ap; + char *sp; + va_start(ap, format); vsprintf(msg, format, ap); printf(msg); va_end(ap); fflush(stdout); + savenvr(); + config_save(); -#ifndef __unix - newline = memmem(msg, strlen(msg), "\n", strlen("\n")); - if (newline != NULL) - { - *newline = 0; - } - plat_msgbox_fatal(msg); -#endif + dumppic(); dumpregs(1); + + /* Make sure the message does not have a trailing newline. */ + if ((sp = strchr(msg, '\n')) != NULL) *sp = '\0'; + +#ifndef __unix + plat_msgbox_fatal(msg); +#endif + fflush(stdout); + exit(-1); } -uint8_t cgastat; - -int pollmouse_delay = 2; -void pollmouse(void) +static void +usage(void) { - int x, y, z; - pollmouse_delay--; - if (pollmouse_delay) return; - pollmouse_delay = 2; - mouse_poll_host(); - mouse_get_mickeys(&x, &y, &z); - mouse_poll(x, y, z, mouse_buttons); -} + printf("Command line options:\n\n"); + printf("--config file.cfg - use given file as initial configuration\n"); + printf("--dump - always dump memory on exit\n"); + printf("--fullscreen - start in fullscreen mode\n"); + printf("--vmpath pathname - set 'path' to be root for vm\n"); -/*PC1512 languages - - 7=English - 6=German - 5=French - 4=Spanish - 3=Danish - 2=Swedish - 1=Italian - 3,2,1 all cause the self test to fail for some reason - */ - -int cpuspeed2; - -int clocks[3][12][4]= -{ - { - {4772728,13920,59660,5965}, /*4.77MHz*/ - {8000000,23333,110000,0}, /*8MHz*/ - {10000000,29166,137500,0}, /*10MHz*/ - {12000000,35000,165000,0}, /*12MHz*/ - {16000000,46666,220000,0}, /*16MHz*/ - }, - { - {8000000,23333,110000,0}, /*8MHz*/ - {12000000,35000,165000,0}, /*12MHz*/ - {16000000,46666,220000,0}, /*16MHz*/ - {20000000,58333,275000,0}, /*20MHz*/ - {25000000,72916,343751,0}, /*25MHz*/ - }, - { - {16000000, 46666,220000,0}, /*16MHz*/ - {20000000, 58333,275000,0}, /*20MHz*/ - {25000000, 72916,343751,0}, /*25MHz*/ - {33000000, 96000,454000,0}, /*33MHz*/ - {40000000,116666,550000,0}, /*40MHz*/ - {50000000, 72916*2,343751*2,0}, /*50MHz*/ - {33000000*2, 96000*2,454000*2,0}, /*66MHz*/ - {75000000, 72916*3,343751*3,0}, /*75MHz*/ - {80000000,116666*2,550000*2,0}, /*80MHz*/ - {100000000, 72916*4,343751*4,0}, /*100MHz*/ - {120000000,116666*3,550000*3,0}, /*120MHz*/ - {133000000, 96000*4,454000*4,0}, /*133MHz*/ - } -}; - -int updatestatus; -int win_title_update=0; - - -void onesec(void) -{ - fps=framecount; - framecount=0; - win_title_update=1; -} - -void pc_reset(void) -{ - cpu_set(); - resetx86(); - dma_reset(); - fdc_reset(); - pic_reset(); - serial_reset(); - - if (AT) - setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); - else - setpitclock(14318184.0); + exit(-1); + /*NOTREACHED*/ } -#undef printf -void initpc(int argc, wchar_t *argv[]) +/* + * Perform initial startup of the PC. + * + * This is the platform-indepenent part of the startup, + * where we check commandline arguments and loading a + * configuration file. + */ +void +pc_init(int argc, wchar_t *argv[]) { - wchar_t *config_file = NULL; - wchar_t *p; + wchar_t *config_file = NULL; + wchar_t *p; #ifdef WALTJE - struct direct *dp; - DIR *dir; + struct direct *dp; + DIR *dir; #endif - int c; + int c; - /* Grab the executable's full path. */ - get_executable_name(exe_path, sizeof(exe_path)-1); - p = get_filename_w(exe_path); - *p = L'\0'; - pclog("exe_path=%S\n", exe_path); + /* Grab the executable's full path. */ + get_executable_name(exe_path, sizeof(exe_path)-1); + p = get_filename_w(exe_path); + *p = L'\0'; + pclog("exe_path=%S\n", exe_path); - /* - * Get the current working directory. - * This is normally the directory from where the - * program was run. If we have been started via - * a shortcut (desktop icon), however, the CWD - * could have been set to something else. - */ - _wgetcwd(cfg_path, sizeof(cfg_path)-1); + /* + * Get the current working directory. + * This is normally the directory from where the + * program was run. If we have been started via + * a shortcut (desktop icon), however, the CWD + * could have been set to something else. + */ + _wgetcwd(cfg_path, sizeof(cfg_path)-1); - for (c = 1; c < argc; c++) - { - if (!_wcsicmp(argv[c], L"--help")) - { + for (c=1; c> '%S'\n", dp->d_name); - } - closedir(dir); - } else { - printf("Could not open '%S'..\n", exe_path); + dir = opendirw(exe_path); + if (dir != NULL) { + printf("Directory '%S':\n", exe_path); + for (;;) { + dp = readdir(dir); + if (dp == NULL) break; + printf(">> '%S'\n", dp->d_name); } + closedir(dir); + } else { + printf("Could not open '%S'..\n", exe_path); + } #endif - /* .. and then exit. */ - exit(0); - } - else if (!_wcsicmp(argv[c], L"--vmpath") || - !_wcsicmp(argv[c], L"-P")) - { - if ((c+1) == argc) - break; - wcscpy(cfg_path, argv[c+1]); - c++; - } + /* .. and then exit. */ + exit(0); + /*NOTREACHED*/ + } else if (!_wcsicmp(argv[c], L"--vmpath") || + !_wcsicmp(argv[c], L"-P")) { + if ((c+1) == argc) break; - /* Uhm... out of options here.. */ - else goto usage; - } - - /* Make sure cfg_path has a trailing backslash. */ - if ((cfg_path[wcslen(cfg_path)-1] != L'\\') && - (cfg_path[wcslen(cfg_path)-1] != L'/')) { - wcscat(cfg_path, L"\\"); - } - pclog("cwd_path=%S\n", cfg_path); - - if (config_file != NULL) { - /* - * The user specified a configuration file. - * - * If this is an absolute path, keep it, as - * they probably have a reason to do that. - * Otherwise, assume the pathname given is - * relative to whatever the cfg_path is. - */ - if ((config_file[1] == L':') || /* drive letter present */ - (config_file[0] == L'\\')) /* backslash, root dir */ - append_filename_w(config_file_default, - NULL, /* empty */ - config_file, 511); - else - append_filename_w(config_file_default, - cfg_path, - config_file, 511); - config_file = NULL; - } else { - append_filename_w(config_file_default, cfg_path, CONFIG_FILE_W, 511); + wcscpy(cfg_path, argv[++c]); } + /* Uhm... out of options here.. */ + else goto usage; + } + + /* Make sure cfg_path has a trailing backslash. */ + if ((cfg_path[wcslen(cfg_path)-1] != L'\\') && + (cfg_path[wcslen(cfg_path)-1] != L'/')) { + wcscat(cfg_path, L"\\"); + } + pclog("cwd_path=%S\n", cfg_path); + + if (config_file != NULL) { /* - * This is weird, but we need to clear that global - * data before we actually use it, and the config - * file reader will add data to those areas.. --FvK + * The user specified a configuration file. + * + * If this is an absolute path, keep it, as + * they probably have a reason to do that. + * Otherwise, assume the pathname given is + * relative to whatever the cfg_path is. */ - hdd_init(); - hdc_init(); + if ((config_file[1] == L':') || /* drive letter present */ + (config_file[0] == L'\\')) /* backslash, root dir */ + append_filename_w(config_file_default, + NULL, config_file, 511); + else + append_filename_w(config_file_default, + cfg_path, config_file, 511); + config_file = NULL; + } else { + append_filename_w(config_file_default, cfg_path, CONFIG_FILE_W, 511); + } - config_load(config_file); + /* + * We are about to read the configuration file, which MAY + * put data into global variables (the hard- and floppy + * disks are an example) so we have to initialize those + * modules before we load the config.. + */ + hdd_init(); + + config_load(config_file); } -void initmodules(void) + +void +pc_full_speed(void) { - int i; + cpuspeed2 = cpuspeed; - /* Initialize modules. */ - random_init(); - mouse_init(); -#ifdef WALTJE - serial_init(); -#endif - joystick_init(); - video_init(); - ide_init_first(); - - mem_init(); - rom_load_bios(romset); - mem_add_bios(); - - cpuspeed2=(AT)?2:1; - atfullspeed=0; - - codegen_init(); - - device_init(); - - timer_reset(); - - for (i = 0; i < CDROM_NUM; i++) - { - if (cdrom_drives[i].bus_type) - { - SCSIReset(cdrom_drives[i].scsi_device_id, cdrom_drives[i].scsi_device_lun); - } - - if (cdrom_drives[i].host_drive == 200) - { - image_open(i, cdrom_image[i].image_path); - } - else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) - { - ioctl_open(i, cdrom_drives[i].host_drive); - } - else - { - cdrom_null_open(i, cdrom_drives[i].host_drive); - } - } - - sound_reset(); - fdc_init(); - floppy_init(); - fdi_init(); - img_init(); - d86f_init(); - td0_init(); - imd_init(); - - floppy_load(0, floppyfns[0]); - floppy_load(1, floppyfns[1]); - floppy_load(2, floppyfns[2]); - floppy_load(3, floppyfns[3]); - - loadnvr(); - sound_init(); - - ide_reset(); - - scsi_card_init(); - - fullspeed(); - shadowbios=0; - - for (i = 0; i < CDROM_NUM; i++) - { - if (cdrom_drives[i].host_drive == 200) - { - image_reset(i); - } - else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) - { - ioctl_reset(i); - } - } -} - -void resetpc(void) -{ - pc_reset(); - shadowbios=0; -} - -void pc_keyboard_send(uint8_t val) -{ + if (! atfullspeed) { + pclog("Set fullspeed - %i %i %i\n", is386, AT, cpuspeed2); if (AT) - { - keyboard_at_adddata_keyboard_raw(val); - } - else - { - keyboard_send(val); - } -} + setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); + else + setpitclock(14318184.0); + } + atfullspeed = 1; -void resetpc_cad(void) -{ - pc_keyboard_send(29); /* Ctrl key pressed */ - pc_keyboard_send(56); /* Alt key pressed */ - pc_keyboard_send(83); /* Delete key pressed */ - pc_keyboard_send(157); /* Ctrl key released */ - pc_keyboard_send(184); /* Alt key released */ - pc_keyboard_send(211); /* Delete key released */ + nvr_recalc(); } -void ctrl_alt_esc(void) +void +pc_speed_changed(void) { - pc_keyboard_send(29); /* Ctrl key pressed */ - pc_keyboard_send(56); /* Alt key pressed */ - pc_keyboard_send(1); /* Esc key pressed */ - pc_keyboard_send(157); /* Ctrl key released */ - pc_keyboard_send(184); /* Alt key released */ - pc_keyboard_send(129); /* Esc key released */ + if (AT) + setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); + else + setpitclock(14318184.0); + + nvr_recalc(); } -int suppress_overscan = 0; -void resetpchard_close(void) +/* Initialize modules, ran once, after pc_init. */ +void +pc_init_modules(void) { - suppress_overscan = 0; + int i; - savenvr(); + cpuspeed2 = (AT) ? 2 : 1; + atfullspeed = 0; - device_close_all(); - mouse_emu_close(); - closeal(); -} + codegen_init(); -void resetpchard_init(void) -{ - int i = 0; + random_init(); - sound_realloc_buffers(); + mem_init(); + rom_load_bios(romset); + mem_add_bios(); - initalmain(0,NULL); - - device_init(); - midi_device_init(); - inital(); - - timer_reset(); - sound_reset(); - mem_resize(); - fdc_init(); - floppy_reset(); - - hdc_reset(hdc_name); -#ifndef WALTJE - serial_init(); + mouse_init(); +#ifdef WALTJE + serial_init(); #endif - machine_init(); - video_reset(); - speaker_init(); - lpt1_device_init(); + joystick_init(); + video_init(); + ide_init_first(); - ide_ter_disable(); - ide_qua_disable(); - if (ide_enable[2]) - ide_ter_init(); - if (ide_enable[3]) - ide_qua_init(); - ide_reset(); + device_init(); + + timer_reset(); - scsi_card_init(); - network_reset(); - - sound_card_init(); - if (mpu401_standalone_enable) - mpu401_device_add(); - if (GUS) - device_add(&gus_device); - if (GAMEBLASTER) - device_add(&cms_device); - if (SSI2001) - device_add(&ssi2001_device); - if (voodoo_enabled) - device_add(&voodoo_device); - pc_reset(); - mouse_emu_init(); - - loadnvr(); - - shadowbios = 0; - - keyboard_at_reset(); - - cpu_cache_int_enabled = cpu_cache_ext_enabled = 0; - - for (i = 0; i < CDROM_NUM; i++) - { - if (cdrom_drives[i].host_drive == 200) - { - image_reset(i); - } - else if ((cdrom_drives[i].host_drive >= 'A') && (cdrom_drives[i].host_drive <= 'Z')) - { - ioctl_reset(i); - } + for (i=0; i='A') && (cdrom_drives[i].host_drive <= 'Z')) + { + ioctl_open(i, cdrom_drives[i].host_drive); + } else { + cdrom_null_open(i, cdrom_drives[i].host_drive); + } + } + + sound_reset(); + +#if 1 + /* This should be in floppy.c and fdc.c --FvK */ + fdc_init(); + + floppy_init(); + fdi_init(); + img_init(); + d86f_init(); + td0_init(); + imd_init(); + + floppy_load(0, floppyfns[0]); + floppy_load(1, floppyfns[1]); + floppy_load(2, floppyfns[2]); + floppy_load(3, floppyfns[3]); +#endif + + loadnvr(); + + sound_init(); + + hdc_init(hdc_name); + + ide_reset(); + + scsi_card_init(); + + pc_full_speed(); + + for (i=0; i= 'A') && (cdrom_drives[i].host_drive <= 'Z')) { + ioctl_reset(i); + } + } + + shadowbios = 0; } -void resetpchard(void) + +void +pc_reset(void) { - resetpchard_close(); - resetpchard_init(); + cpu_set(); + resetx86(); + dma_reset(); + fdc_reset(); + pic_reset(); + serial_reset(); + + if (AT) + setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); + else + setpitclock(14318184.0); + + shadowbios = 0; } + +void +pc_keyboard_send(uint8_t val) +{ + if (AT) + keyboard_at_adddata_keyboard_raw(val); + else + keyboard_send(val); +} + + +void +pc_send_cad(void) +{ + pc_keyboard_send(29); /* Ctrl key pressed */ + pc_keyboard_send(56); /* Alt key pressed */ + pc_keyboard_send(83); /* Delete key pressed */ + pc_keyboard_send(157); /* Ctrl key released */ + pc_keyboard_send(184); /* Alt key released */ + pc_keyboard_send(211); /* Delete key released */ +} + + +void +pc_send_cae(void) +{ + pc_keyboard_send(29); /* Ctrl key pressed */ + pc_keyboard_send(56); /* Alt key pressed */ + pc_keyboard_send(1); /* Esc key pressed */ + pc_keyboard_send(157); /* Ctrl key released */ + pc_keyboard_send(184); /* Alt key released */ + pc_keyboard_send(129); /* Esc key released */ +} + + +void +resetpchard_close(void) +{ + suppress_overscan = 0; + + savenvr(); + + device_close_all(); + mouse_emu_close(); + closeal(); +} + + +void +resetpchard_init(void) +{ + int i; + + sound_realloc_buffers(); + + initalmain(0,NULL); + + device_init(); + midi_device_init(); + inital(); + + timer_reset(); + sound_reset(); + mem_resize(); + fdc_init(); + floppy_reset(); + +#ifndef WALTJE + serial_init(); +#endif + machine_init(); + video_reset(); + speaker_init(); + lpt1_device_init(); + + hdc_reset(); + + ide_ter_disable(); + ide_qua_disable(); + if (ide_enable[2]) + ide_ter_init(); + if (ide_enable[3]) + ide_qua_init(); + ide_reset(); + + scsi_card_init(); + network_reset(); + + sound_card_init(); + if (mpu401_standalone_enable) + mpu401_device_add(); + if (GUS) + device_add(&gus_device); + if (GAMEBLASTER) + device_add(&cms_device); + if (SSI2001) + device_add(&ssi2001_device); + if (voodoo_enabled) + device_add(&voodoo_device); + + pc_reset(); + + mouse_emu_init(); + + loadnvr(); + + shadowbios = 0; + + keyboard_at_reset(); + + cpu_cache_int_enabled = cpu_cache_ext_enabled = 0; + + for (i=0; i= 'A') && (cdrom_drives[i].host_drive <= 'Z')) + { + ioctl_reset(i); + } + } + + sound_cd_thread_reset(); +} + + +void +pc_reset_hard(void) +{ + resetpchard_close(); + + resetpchard_init(); +} + + +void +pc_close(void) +{ + int i; + + for (i=0; iexit(i); + + dumppic(); + + for (i=0; i=100) - { - framecountx=0; - mips=(float)insc/1000000.0f; - insc=0; - flops=(float)fpucount/1000000.0f; - fpucount=0; - sreadlnum=readlnum; - swritelnum=writelnum; - segareads=egareads; - segawrites=egawrites; - scycles_lost = cycles_lost; + keyboard_process(); - cpu_recomp_blocks_latched = cpu_recomp_blocks; - cpu_recomp_ins_latched = cpu_state.cpu_recomp_ins; - cpu_recomp_full_ins_latched = cpu_recomp_full_ins; - cpu_new_blocks_latched = cpu_new_blocks; - cpu_recomp_flushes_latched = cpu_recomp_flushes; - cpu_recomp_evicted_latched = cpu_recomp_evicted; - cpu_recomp_reuse_latched = cpu_recomp_reuse; - cpu_recomp_removed_latched = cpu_recomp_removed; - cpu_reps_latched = cpu_reps; - cpu_notreps_latched = cpu_notreps; - - cpu_recomp_blocks = 0; - cpu_state.cpu_recomp_ins = 0; - cpu_recomp_full_ins = 0; - cpu_new_blocks = 0; - cpu_recomp_flushes = 0; - cpu_recomp_evicted = 0; - cpu_recomp_reuse = 0; - cpu_recomp_removed = 0; - cpu_reps = 0; - cpu_notreps = 0; + pollmouse(); - updatestatus=1; - readlnum=writelnum=0; - egareads=egawrites=0; - cycles_lost = 0; - mmuflush=0; - emu_fps = frames; - frames = 0; - } - if (win_title_update) - { - win_title_update=0; - mbstowcs(wmachine, machine_getname(), strlen(machine_getname()) + 1); - mbstowcs(wcpu, machines[machine].cpu[cpu_manufacturer].cpus[cpu].name, strlen(machines[machine].cpu[cpu_manufacturer].cpus[cpu].name) + 1); - _swprintf(s, L"%s v%s - %i%% - %s - %s - %s", EMU_NAME_W, EMU_VERSION_W, fps, wmachine, wcpu, (!mousecapture) ? plat_get_string_from_id(IDS_2077) : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079))); - set_window_title(s); - } - done++; + if (joystick_type != 7) + joystick_poll(); + + endblit(); + + framecountx++; + framecount++; + if (framecountx >= 100) { + framecountx = 0; + mips = (float)insc/1000000.0f; + insc = 0; + flops = (float)fpucount/1000000.0f; + fpucount = 0; + sreadlnum = readlnum; + swritelnum = writelnum; + segareads = egareads; + segawrites = egawrites; + scycles_lost = cycles_lost; + + cpu_recomp_blocks_latched = cpu_recomp_blocks; + cpu_recomp_ins_latched = cpu_state.cpu_recomp_ins; + cpu_recomp_full_ins_latched = cpu_recomp_full_ins; + cpu_new_blocks_latched = cpu_new_blocks; + cpu_recomp_flushes_latched = cpu_recomp_flushes; + cpu_recomp_evicted_latched = cpu_recomp_evicted; + cpu_recomp_reuse_latched = cpu_recomp_reuse; + cpu_recomp_removed_latched = cpu_recomp_removed; + cpu_reps_latched = cpu_reps; + cpu_notreps_latched = cpu_notreps; + + cpu_recomp_blocks = 0; + cpu_state.cpu_recomp_ins = 0; + cpu_recomp_full_ins = 0; + cpu_new_blocks = 0; + cpu_recomp_flushes = 0; + cpu_recomp_evicted = 0; + cpu_recomp_reuse = 0; + cpu_recomp_removed = 0; + cpu_reps = 0; + cpu_notreps = 0; + + updatestatus = 1; + readlnum = writelnum = 0; + egareads = egawrites = 0; + cycles_lost = 0; + mmuflush = 0; + emu_fps = frames; + frames = 0; + } + + if (win_title_update) { + mbstowcs(wmachine, machine_getname(), strlen(machine_getname())+1); + mbstowcs(wcpu, machines[machine].cpu[cpu_manufacturer].cpus[cpu].name, + strlen(machines[machine].cpu[cpu_manufacturer].cpus[cpu].name)+1); + _swprintf(s, L"%s v%s - %i%% - %s - %s - %s", + EMU_NAME_W, EMU_VERSION_W, + fps, wmachine, wcpu, + (!mousecapture) ? plat_get_string_from_id(IDS_2077) + : ((mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON) ? plat_get_string_from_id(IDS_2078) : plat_get_string_from_id(IDS_2079))); + set_window_title(s); + + win_title_update = 0; + } + + done++; } -void fullspeed(void) + +void +onesec(void) { - cpuspeed2=cpuspeed; - if (!atfullspeed) - { - printf("Set fullspeed - %i %i %i\n",is386,AT,cpuspeed2); - if (AT) - setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); - else - setpitclock(14318184.0); - } - atfullspeed=1; - nvr_recalc(); -} - -void speedchanged(void) -{ - if (AT) - setpitclock(machines[machine].cpu[cpu_manufacturer].cpus[cpu].rspeed); - else - setpitclock(14318184.0); - nvr_recalc(); -} - -void closepc(void) -{ - int i = 0; - for (i = 0; i < CDROM_NUM; i++) - { - cdrom_drives[i].handler->exit(i); - } - dumppic(); - for (i = 0; i < FDD_NUM; i++) - { - floppy_close(i); - } - dumpregs(0); - video_close(); - lpt1_device_close(); - device_close_all(); - midi_close(); - network_close(); + fps = framecount; + framecount = 0; + win_title_update = 1; } diff --git a/src/pci.c b/src/pci.c index d945c7a63..28775c685 100644 --- a/src/pci.c +++ b/src/pci.c @@ -10,11 +10,11 @@ #include "device.h" #include "pci.h" #include "keyboard_at.h" +#include "cdrom/cdrom.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" -#include "cdrom/cdrom.h" static uint64_t pci_irq_hold[16]; diff --git a/src/piix.c b/src/piix.c index 2d233737b..de56b65a6 100644 --- a/src/piix.c +++ b/src/piix.c @@ -12,7 +12,7 @@ * word 0 - base address * word 1 - bits 1 - 15 = byte count, bit 31 = end of transfer * - * Version: @(#)piix.c 1.0.4 2017/09/30 + * Version: @(#)piix.c 1.0.5 2017/10/01 * * Authors: Sarah Walker, * Miran Grca, @@ -30,8 +30,8 @@ #include "keyboard_at.h" #include "mem.h" #include "pci.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "piix.h" @@ -612,7 +612,9 @@ void piix_bus_master_set_irq(int channel) piix_busmaster[channel & 0x0F].status |= (channel >> 4); } -/* static int reset_reg = 0; + +#if 0 +static int reset_reg = 0; static uint8_t rc_read(uint16_t port, void *priv) { @@ -625,7 +627,7 @@ static void rc_write(uint16_t port, uint8_t val, void *priv) { if (reset_reg & 2) { - resetpchard(); + pc_reset_hard(); } else { @@ -637,12 +639,13 @@ static void rc_write(uint16_t port, uint8_t val, void *priv) { piix_reset(); } - resetide(); + ide_reset(); softresetx86(); } } reset_reg = val; -} */ +} +#endif void piix_reset(void) { diff --git a/src/scsi/scsi.c b/src/scsi/scsi.c index c5a62b3b7..3857a7d3e 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.6 2017/09/30 + * Version: @(#)scsi.c 1.0.6 2017/10/01 * * Authors: TheCollector1995, * Miran Grca, @@ -26,7 +26,7 @@ #include "../timer.h" #include "../device.h" #include "../cdrom/cdrom.h" -#include "../hdd/hdc.h" +#include "../disk/hdc.h" #include "scsi.h" #include "scsi_aha154x.h" #include "scsi_buslogic.h" diff --git a/src/scsi/scsi_device.c b/src/scsi/scsi_device.c index d4eaef583..f06a47d37 100644 --- a/src/scsi/scsi_device.c +++ b/src/scsi/scsi_device.c @@ -8,7 +8,7 @@ * * The generic SCSI device command handler. * - * Version: @(#)scsi_device.c 1.0.4 2017/09/29 + * Version: @(#)scsi_device.c 1.0.4 2017/10/01 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -21,7 +21,7 @@ #include #include "../ibm.h" #include "../cdrom/cdrom.h" -#include "../hdd/hdd.h" +#include "../disk/hdd.h" #include "scsi.h" #include "scsi_disk.h" diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index c4e65fee8..f06b8855c 100644 --- a/src/scsi/scsi_disk.c +++ b/src/scsi/scsi_disk.c @@ -6,7 +6,7 @@ * * Emulation of SCSI fixed and removable disks. * - * Version: @(#)scsi_disk.c 1.0.9 2017/09/30 + * Version: @(#)scsi_disk.c 1.0.9 2017/10/01 * * Author: Miran Grca, * Copyright 2017 Miran Grca. @@ -23,9 +23,9 @@ #include "../device.h" #include "../piix.h" #include "../cdrom/cdrom.h" -#include "../hdd/hdd.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" +#include "../disk/hdd.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../win/plat_iodev.h" #include "scsi.h" #include "scsi_disk.h" diff --git a/src/sio_fdc37c665.c b/src/sio_fdc37c665.c index 4b32d84ba..c9cef0759 100644 --- a/src/sio_fdc37c665.c +++ b/src/sio_fdc37c665.c @@ -24,11 +24,11 @@ #include "device.h" #include "lpt.h" #include "serial.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" #include "sio.h" diff --git a/src/sio_fdc37c669.c b/src/sio_fdc37c669.c index f2dac8cbd..bfff245b0 100644 --- a/src/sio_fdc37c669.c +++ b/src/sio_fdc37c669.c @@ -22,11 +22,11 @@ #include "device.h" #include "lpt.h" #include "serial.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" #include "sio.h" diff --git a/src/sio_fdc37c932fr.c b/src/sio_fdc37c932fr.c index 2ecc95b74..205cfde23 100644 --- a/src/sio_fdc37c932fr.c +++ b/src/sio_fdc37c932fr.c @@ -22,11 +22,11 @@ #include "device.h" #include "lpt.h" #include "serial.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" #include "sio.h" diff --git a/src/sio_pc87306.c b/src/sio_pc87306.c index 44fb5a914..c955c372e 100644 --- a/src/sio_pc87306.c +++ b/src/sio_pc87306.c @@ -22,11 +22,11 @@ #include "device.h" #include "lpt.h" #include "serial.h" +#include "disk/hdc.h" +#include "disk/hdc_ide.h" #include "floppy/floppy.h" #include "floppy/fdc.h" #include "floppy/fdd.h" -#include "hdd/hdc.h" -#include "hdd/hdc_ide.h" #include "sio.h" diff --git a/src/win/86Box.rc b/src/win/86Box.rc index e6cffab78..7ac919517 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -8,7 +8,7 @@ * * Windows resource script. * - * Version: @(#)86Box.rc 1.0.12 2017/10/01 + * Version: @(#)86Box.rc 1.0.13 2017/10/01 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -808,8 +808,10 @@ BEGIN IDS_2150 "Thrustmaster Flight Control System" IDS_2151 "Disabled" IDS_2152 "None" - IDS_2153 "AT Fixed Disk Adapter" - IDS_2154 "Internal Controller" +#if UNUSED + IDS_2153 + IDS_2154 +#endif IDS_2155 "IRQ %i" IDS_2156 "%" PRIu64 IDS_2157 "%" PRIu64 " MB (CHS: %" PRIu64 ", %" PRIu64 ", %" PRIu64 ")" diff --git a/src/win/resource.h b/src/win/resource.h index 54b22209d..29e6f8f12 100644 --- a/src/win/resource.h +++ b/src/win/resource.h @@ -10,8 +10,9 @@ * * NOTE: FIXME: Strings 2176 and 2193 are same. * NOTE: FIXME: string 2095 not in use. + * NOTE: FIXME: strings 2152-2154 not in use. * - * Version: @(#)resource.h 1.0.6 2017/09/23 + * Version: @(#)resource.h 1.0.8 2017/10/01 * * Authors: Sarah Walker, * Miran Grca, @@ -308,8 +309,10 @@ #define IDS_2150 2150 // "Thrustmaster Flight Control System" #define IDS_2151 2151 // "Disabled" #define IDS_2152 2152 // "None" -#define IDS_2153 2153 // "AT Fixed Disk Adapter" -#define IDS_2154 2154 // "Internal IDE" +#if NOTUSED +#define IDS_2153 2153 +#define IDS_2154 2154 +#endif #define IDS_2155 2155 // "IRQ %i" #define IDS_2156 2156 // "MFM (%01i:%01i)" #define IDS_2157 2157 // "IDE (PIO+DMA) (%01i:%01i)" diff --git a/src/win/win.c b/src/win/win.c index dd47c2695..b7943b061 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -43,11 +43,11 @@ #include "../cdrom/cdrom_ioctl.h" #include "../cdrom/cdrom_image.h" #include "../cdrom/cdrom_null.h" +#include "../disk/hdd.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../floppy/floppy.h" #include "../floppy/fdd.h" -#include "../hdd/hdd.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" #include "../scsi/scsi.h" #include "../scsi/scsi_disk.h" #include "../network/network.h" @@ -158,7 +158,6 @@ static int *sb_icon_flags; static int *sb_part_meanings; static int *sb_part_icons; static WCHAR **sbTips; - static int sb_parts = 0; static int sb_ready = 0; @@ -334,7 +333,7 @@ void mainthread(LPVOID param) { start_time = timer_read(); drawits-=10; if (drawits>50) drawits=0; - runpc(); + pc_run(); frames++; if (frames >= 200 && nvr_dosave) { @@ -496,7 +495,7 @@ static void init_cdrom_host_drives(void) } -HMENU create_popup_menu(int part) +static HMENU create_popup_menu(int part) { HMENU newHandle; newHandle = CreatePopupMenu(); @@ -505,7 +504,7 @@ HMENU create_popup_menu(int part) } -void create_floppy_submenu(HMENU m, int id) +static void create_floppy_submenu(HMENU m, int id) { AppendMenu(m, MF_STRING, IDM_FLOPPY_IMAGE_NEW | id, win_language_get_string_from_id(IDS_2161)); AppendMenu(m, MF_SEPARATOR, 0, 0); @@ -515,7 +514,7 @@ void create_floppy_submenu(HMENU m, int id) AppendMenu(m, MF_STRING, IDM_FLOPPY_EJECT | id, win_language_get_string_from_id(IDS_2164)); } -void create_cdrom_submenu(HMENU m, int id) +static void create_cdrom_submenu(HMENU m, int id) { int i = 0; WCHAR s[64]; @@ -579,7 +578,7 @@ check_menu_items: } } -void create_removable_disk_submenu(HMENU m, int id) +static void create_removable_disk_submenu(HMENU m, int id) { AppendMenu(m, MF_STRING, IDM_RDISK_EJECT | id, win_language_get_string_from_id(IDS_2166)); AppendMenu(m, MF_STRING, IDM_RDISK_RELOAD | id, win_language_get_string_from_id(IDS_2167)); @@ -1621,79 +1620,81 @@ void reset_menus(void) int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { - HWND hwnd; /* This is the handle for our window */ - MSG messages; /* Here messages to the application are saved */ - WNDCLASSEX wincl; /* Data structure for the windowclass */ + HWND hwnd; /* handle for our window */ + MSG messages; /* received-messages buffer */ + WNDCLASSEX wincl; /* buffer for main window's class */ + HACCEL haccel; /* handle to accelerator table */ int c, d, bRet; - WCHAR emulator_title[200]; + WCHAR title[200]; LARGE_INTEGER qpc_freq; - HACCEL haccel; /* Handle to accelerator table */ + + /* Process the command line for options. */ + process_command_line(); memset(recv_key, 0, sizeof(recv_key)); - process_command_line(); - win_language_load_common_strings(); - hinstance=hThisInstance; - /* The Window structure */ + /* The Window structure. */ + hinstance = hThisInstance; wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; - wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ - wincl.style = CS_DBLCLKS; /* Catch double-clicks */ + wincl.lpfnWndProc = WindowProcedure; /* called by Windows */ + wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); - /* Use default icon and mouse-pointer */ + /* Use default icon and mouse-pointer. */ wincl.hIcon = LoadIcon(hinstance, (LPCTSTR) 100); wincl.hIconSm = LoadIcon(hinstance, (LPCTSTR) 100); wincl.hCursor = NULL; - wincl.lpszMenuName = NULL; /* No menu */ - wincl.cbClsExtra = 0; /* No extra bytes after the window class */ - wincl.cbWndExtra = 0; /* structure or the window instance */ - /* Use Windows's default color as the background of the window */ + wincl.lpszMenuName = NULL; /* no menu */ + wincl.cbClsExtra = 0; /* no extra bytes after window class */ + wincl.cbWndExtra = 0; /* structure or the window instance */ + + /* Use Windows's default color as the background of the window. */ wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; - /* Register the window class, and if it fails quit the program */ - if (!RegisterClassEx(&wincl)) - { - return 0; + /* Register the window class, and if it fails quit the program. */ + if (! RegisterClassEx(&wincl)) { + return(0); } wincl.lpszClassName = szSubClassName; - wincl.lpfnWndProc = subWindowProcedure; /* This function is called by windows */ - - if (!RegisterClassEx(&wincl)) - { - return 0; + wincl.lpfnWndProc = subWindowProcedure; /* called by Windows */ + if (! RegisterClassEx(&wincl)) { + return(0); } menu = LoadMenu(hThisInstance, TEXT("MainMenu")); - _swprintf(emulator_title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); + _swprintf(title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( - 0, /* Extended possibilites for variation */ - szClassName, /* Classname */ - emulator_title, /* Title Text */ - (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX)/* | DS_3DLOOK*/, /* default window */ + 0, /* no extended possibilites */ + szClassName, /* class name */ + title, /* Title Text */ +#if 0 + (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX), /* default window */ +#else + (WS_OVERLAPPEDWINDOW & ~WS_SIZEBOX) | DS_3DLOOK, +#endif CW_USEDEFAULT, /* Windows decides the position */ - CW_USEDEFAULT, /* where the window ends up on the screen */ - 640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* The programs width */ - 480+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ - HWND_DESKTOP, /* The window is a child-window to desktop */ - menu, /* Menu */ + CW_USEDEFAULT, /* where window ends up on the screen */ + 640+(GetSystemMetrics(SM_CXFIXEDFRAME)*2), /* width */ + 480+(GetSystemMetrics(SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+1, /* and height in pixels */ + HWND_DESKTOP, /* window is a child to desktop */ + menu, /* menu */ hThisInstance, /* Program Instance handler */ - NULL /* No Window Creation data */ + NULL /* no Window Creation data */ ); - /* Make the window visible on the screen */ - ShowWindow (hwnd, nFunsterStil); + /* Make the window visible on the screen. */ + ShowWindow(hwnd, nFunsterStil); /* Load the accelerator table */ haccel = LoadAccelerators(hinstAcc, L"MainAccel"); - if (haccel == NULL) - { + if (haccel == NULL) { fatal("haccel is null\n"); } @@ -1701,38 +1702,37 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz device.usUsage = 0x06; device.dwFlags = RIDEV_NOHOTKEYS; device.hwndTarget = hwnd; - - if (RegisterRawInputDevices(&device, 1, sizeof(device))) - { + if (RegisterRawInputDevices(&device, 1, sizeof(device))) { pclog("Raw input registered!\n"); - } - else - { + } else { pclog("Raw input registration failed!\n"); } get_registry_key_map(); - ghwnd=hwnd; + ghwnd = hwnd; - hwndRender = CreateWindow(L"STATIC", NULL, WS_VISIBLE | WS_CHILD | SS_BITMAP, 0, 0, 1, 1, ghwnd, NULL, hinstance, NULL); + hwndRender = CreateWindow(L"STATIC", NULL, + WS_VISIBLE|WS_CHILD|SS_BITMAP, + 0, 0, 1, 1, ghwnd, NULL, hinstance, NULL); /* FIXME: Kotori, code below should be moved to pc.c, as its not Win specific. */ - initpc(argc, argv); + /* Pre-initialize the system, this loads the config file. */ + pc_init(argc, argv); init_cdrom_host_drives(); network_init(); + /* Now that we know our window sizes, adjust to that. */ hwndStatus = EmulatorStatusBar(hwnd, IDC_STATUS, hThisInstance); - OriginalStatusBarProcedure = GetWindowLongPtr(hwndStatus, GWLP_WNDPROC); SetWindowLongPtr(hwndStatus, GWL_WNDPROC, (LONG_PTR) &StatusBarProcedure); smenu = LoadMenu(hThisInstance, TEXT("StatusBarMenu")); - initmodules(); + pc_init_modules(); if (vid_apis[0][vid_api].init(hwndRender) == 0) { @@ -1746,8 +1746,12 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz } } - if (vid_resize) SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE); - else SetWindowLongPtr(hwnd, GWL_STYLE, (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE); + if (vid_resize) + SetWindowLongPtr(hwnd, GWL_STYLE, + (WS_OVERLAPPEDWINDOW&~WS_MINIMIZEBOX)|WS_VISIBLE); + else + SetWindowLongPtr(hwnd, GWL_STYLE, + (WS_OVERLAPPEDWINDOW&~WS_SIZEBOX&~WS_THICKFRAME&~WS_MAXIMIZEBOX&~WS_MINIMIZEBOX)|WS_VISIBLE); reset_menus(); @@ -1771,7 +1775,16 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz } pclog("A total of %d ROM sets have been loaded.\n", d); - /* Load the ROMs for the selected machine. */ + /* + * Load the ROMs for the selected machine. + * + * FIXME: + * We should not do that here. If something turns out + * to be wrong with the configuration (such as missing + * ROM images, we should just display a fatal message + * in the render window's center, let them click OK, + * and then exit so they can remedy the situation. + */ if (! rom_load_bios(romset)) { /* Whoops, ROMs not found. */ if (romset!=-1) @@ -1787,17 +1800,14 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz romset = c; machine = machine_getmachine(romset); config_save(); - resetpchard(); + pc_reset_hard(); break; } } } for (c = 0; c < GFX_MAX; c++) - { gfx_present[c] = video_card_available(video_old_to_new(c)); - } - if (!video_card_available(video_old_to_new(gfxcard))) { if (romset!=-1) @@ -1810,14 +1820,17 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz { gfxcard = c; config_save(); - resetpchard(); + pc_reset_hard(); break; } } } + /* Load the selected machine's BIOS. */ rom_load_bios(romset); - resetpchard(); + + /* Perform a hard reset to start the machine. */ + pc_reset_hard(); timeBeginPeriod(1); @@ -1845,65 +1858,57 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz endblit(); device_force_redraw(); } - if (window_remember) - { - MoveWindow(hwnd, window_x, window_y, - window_w, - window_h, - TRUE); - } - else - { - MoveWindow(hwndRender, 0, 0, - winsizex, - winsizey, - TRUE); - MoveWindow(hwndStatus, 0, winsizey + 6, - winsizex, - 17, - TRUE); + + if (window_remember) { + MoveWindow(hwnd, window_x, window_y, window_w, window_h, TRUE); + } else { + MoveWindow(hwndRender, 0, 0, winsizex, winsizey, TRUE); + MoveWindow(hwndStatus, 0, winsizey+6, winsizex, 17, TRUE); } /* Run the message loop. It will run until GetMessage() returns 0 */ - while (!quited) + while (! quited) { - while (((bRet = GetMessage(&messages,NULL,0,0)) != 0) && !quited) - { - if (bRet == -1) - { - fatal("bRet is -1\n"); - } + bRet = GetMessage(&messages, NULL, 0, 0); + if ((bRet == 0) || quited) break; - if (messages.message==WM_QUIT) quited=1; - if (!TranslateAccelerator(hwnd, haccel, &messages)) - { - TranslateMessage(&messages); - DispatchMessage(&messages); - } - - if (recv_key[0x58] && recv_key[0x42] && mousecapture) - { - ClipCursor(&oldclip); - ShowCursor(TRUE); - mousecapture=0; - } - - if ((recv_key[0x1D] || recv_key[0x9D]) && (recv_key[0x38] || recv_key[0xB8]) && (recv_key[0x51] || recv_key[0xD1]) && - video_fullscreen) - { - leave_fullscreen(); - } + if (bRet == -1) { + fatal("bRet is -1\n"); } - quited=1; + if (messages.message == WM_QUIT) { + quited = 1; + break; + } + + if (! TranslateAccelerator(hwnd, haccel, &messages)) { + TranslateMessage(&messages); + DispatchMessage(&messages); + } + + if (recv_key[0x58] && recv_key[0x42] && mousecapture) { + ClipCursor(&oldclip); + ShowCursor(TRUE); + mousecapture = 0; + } + + if ((recv_key[0x1D] || recv_key[0x9D]) && + (recv_key[0x38] || recv_key[0xB8]) && + (recv_key[0x51] || recv_key[0xD1]) && video_fullscreen) { + leave_fullscreen(); + } } startblit(); + Sleep(200); - TerminateThread(mainthreadh,0); + TerminateThread(mainthreadh, 0); + savenvr(); + config_save(); - closepc(); + + pc_close(); vid_apis[video_fullscreen][vid_api].close(); @@ -1917,9 +1922,10 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz UnregisterClass(szSubClassName, hinstance); UnregisterClass(szClassName, hinstance); - return messages.wParam; + return(messages.wParam); } + HHOOK hKeyboardHook; int hook_enabled = 0; @@ -1935,30 +1941,44 @@ LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) p = (KBDLLHOOKSTRUCT*)lParam; - if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-tab */ - if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-tab */ - if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1; /* disable windows keys */ - if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1; /* disable alt-escape */ - bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1); /* checks ctrl key pressed */ - if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1; /* disable ctrl-escape */ + /* disable alt-tab */ + if (p->vkCode == VK_TAB && p->flags & LLKHF_ALTDOWN) return 1; + + /* disable alt-space */ + if (p->vkCode == VK_SPACE && p->flags & LLKHF_ALTDOWN) return 1; + + /* disable alt-escape */ + if (p->vkCode == VK_ESCAPE && p->flags & LLKHF_ALTDOWN) return 1; + + /* disable windows keys */ + if((p->vkCode == VK_LWIN) || (p->vkCode == VK_RWIN)) return 1; + + /* checks ctrl key pressed */ + bControlKeyDown = GetAsyncKeyState(VK_CONTROL)>>((sizeof(SHORT)*8)-1); + + /* disable ctrl-escape */ + if (p->vkCode == VK_ESCAPE && bControlKeyDown) return 1; return CallNextHookEx( hKeyboardHook, nCode, wParam, lParam ); } -void cdrom_close(uint8_t id) + +void +cdrom_close(uint8_t id) { - switch (cdrom_drives[id].host_drive) - { - case 0: - null_close(id); - break; - default: - ioctl_close(id); - break; - case 200: - image_close(id); - break; - } + switch (cdrom_drives[id].host_drive) { + case 0: + null_close(id); + break; + + case 200: + image_close(id); + break; + + default: + ioctl_close(id); + break; + } } static BOOL CALLBACK about_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) @@ -1994,23 +2014,27 @@ void about_open(HWND hwnd) DialogBox(hinstance, (LPCTSTR)DLG_ABOUT, hwnd, about_dlgproc); } -static void win_pc_reset(int hard) + +static void +win_pc_reset(int hard) { - pause=1; - Sleep(100); - savenvr(); - config_save(); - if (hard) - { - resetpchard(); - } - else - { - resetpc_cad(); - } - pause=0; + pause = 1; + + Sleep(100); + + savenvr(); + + config_save(); + + if (hard) + pc_reset_hard(); + else + pc_send_cad(); + + pause = 0; } + void video_toggle_option(HMENU hmenu, int *val, int id) { startblit(); @@ -2022,6 +2046,7 @@ void video_toggle_option(HMENU hmenu, int *val, int id) device_force_redraw(); } + LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static wchar_t wOldTitle[512]; @@ -2054,11 +2079,11 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM break; case IDM_ACTION_EXIT: - PostQuitMessage (0); /* send a WM_QUIT to the message queue */ + PostQuitMessage(0); break; case IDM_ACTION_CTRL_ALT_ESC: - ctrl_alt_esc(); + pc_send_cae(); break; case IDM_ACTION_PAUSE: diff --git a/src/win/win_deviceconfig.c b/src/win/win_deviceconfig.c index 643bc7f2a..2414e3062 100644 --- a/src/win/win_deviceconfig.c +++ b/src/win/win_deviceconfig.c @@ -358,7 +358,7 @@ static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam config_save(); - resetpchard(); + pc_reset_hard(); EndDialog(hdlg, 0); return TRUE; diff --git a/src/win/win_iodev.c b/src/win/win_iodev.c index c04415a6d..b6ae03e9c 100644 --- a/src/win/win_iodev.c +++ b/src/win/win_iodev.c @@ -8,7 +8,7 @@ * * Windows IO device menu handler. * - * Version: @(#)win_iodev.c 1.0.4 2017/09/29 + * Version: @(#)win_iodev.c 1.0.4 2017/10/01 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -36,7 +36,7 @@ #include "../cdrom/cdrom_image.h" #include "../cdrom/cdrom_ioctl.h" #include "../cdrom/cdrom_null.h" -#include "../hdd/hdd.h" +#include "../disk/hdd.h" #include "../scsi/scsi_disk.h" #include "plat_iodev.h" #include "win.h" diff --git a/src/win/win_settings.c b/src/win/win_settings.c index ffd755445..5857b0a58 100644 --- a/src/win/win_settings.c +++ b/src/win/win_settings.c @@ -8,7 +8,7 @@ * * Windows 86Box Settings dialog handler. * - * Version: @(#)win_settings.c 1.0.16 2017/10/01 + * Version: @(#)win_settings.c 1.0.17 2017/10/01 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -36,11 +36,11 @@ #include "../lpt.h" #include "../mouse.h" #include "../cdrom/cdrom.h" +#include "../disk/hdd.h" +#include "../disk/hdc.h" +#include "../disk/hdc_ide.h" #include "../floppy/floppy.h" #include "../floppy/fdd.h" -#include "../hdd/hdd.h" -#include "../hdd/hdc.h" -#include "../hdd/hdc_ide.h" #include "../scsi/scsi.h" #include "../network/network.h" #include "../sound/sound.h" @@ -77,7 +77,7 @@ static char temp_lpt1_device_name[16]; static int temp_serial[2], temp_lpt; /* Peripherals category */ -static int temp_scsi_card, hdc_ignore, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; +static int temp_scsi_card, temp_ide_ter, temp_ide_ter_irq, temp_ide_qua, temp_ide_qua_irq; static char temp_hdc_name[16]; static char *hdc_names[16]; static int temp_bugger; @@ -332,6 +332,7 @@ static void win_settings_save(void) /* Peripherals category */ scsi_card_current = temp_scsi_card; strncpy(hdc_name, temp_hdc_name, sizeof(temp_hdc_name) - 1); + hdc_init(hdc_name); ide_enable[2] = temp_ide_ter; ide_irq[2] = temp_ide_ter_irq; ide_enable[3] = temp_ide_qua; @@ -365,7 +366,7 @@ static void win_settings_save(void) config_save(); - speedchanged(); + pc_speed_changed(); if (joystick_type != 7) gameport_update_joystick_type(); } @@ -1386,107 +1387,80 @@ static void recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc) h = GetDlgItem(hdlg, IDC_COMBO_HDC); -#if 0 - /* - * We do not ignore this entry, nor do we zap the selection - * list, as we might want to override the internal controller - * with an external one. --FvK - */ - if (machines[temp_machine].flags & MACHINE_HAS_HDC) + valid = 0; + + if (use_selected_hdc) { - hdc_ignore = 1; + c = SendMessage(h, CB_GETCURSEL, 0, 0); - SendMessage(h, CB_RESETCONTENT, 0, 0); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(IDS_2154)); - /* See above, don't disable it. */ - EnableWindow(h, FALSE); - SendMessage(h, CB_SETCURSEL, 1, 0); - } - else - { -#endif - hdc_ignore = 0; - - valid = 0; - - if (use_selected_hdc) + if (c != -1 && hdc_names[c]) { - c = SendMessage(h, CB_GETCURSEL, 0, 0); - - if (c != -1 && hdc_names[c]) - { - strncpy(old_name, hdc_names[c], sizeof(old_name) - 1); - } - else - { - strcpy(old_name, "none"); - } + strncpy(old_name, hdc_names[c], sizeof(old_name) - 1); } else { - strncpy(old_name, temp_hdc_name, sizeof(old_name) - 1); + strcpy(old_name, "none"); } - - SendMessage(h, CB_RESETCONTENT, 0, 0); - c = d = 0; - while (1) - { - s = hdc_get_name(c); - if (s[0] == 0) - { - break; - } - if ((hdc_get_flags(c) & DEVICE_AT) && !(machines[machine].flags & MACHINE_AT)) - { - c++; - continue; - } - if ((hdc_get_flags(c) & DEVICE_PS2) && !(machines[machine].flags & MACHINE_PS2_HDD)) - { - c++; - continue; - } - if ((hdc_get_flags(c) & DEVICE_MCA) && !(machines[machine].flags & MACHINE_MCA)) - { - c++; - continue; - } - if (!hdc_available(c)) - { - c++; - continue; - } -#if 0 - if (c < 2) - { - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) win_language_get_string_from_id(2152 + c)); - } - else -#endif - { - mbstowcs(lptsTemp, s, strlen(s) + 1); - SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); - } - hdc_names[d] = hdc_get_internal_name(c); - if (!strcmp(old_name, hdc_names[d])) - { - SendMessage(h, CB_SETCURSEL, d, 0); - valid = 1; - } - c++; - d++; - } - - if (!valid) - { - SendMessage(h, CB_SETCURSEL, 0, 0); - } - - EnableWindow(h, TRUE); -#if 0 - if (machines[temp_machine].flags & MACHINE_HAS_HDC) } -#endif + else + { + strncpy(old_name, temp_hdc_name, sizeof(old_name) - 1); + } + + SendMessage(h, CB_RESETCONTENT, 0, 0); + c = d = 0; + while (1) + { + s = hdc_get_name(c); + if (s[0] == 0) + { + break; + } + if (c==1 && !(machines[temp_machine].flags&MACHINE_HAS_HDC)) + { + /* Skip "Internal" if machine doesn't have one. */ + c++; + continue; + } + if ((hdc_get_flags(c) & DEVICE_AT) && !(machines[machine].flags & MACHINE_AT)) + { + c++; + continue; + } + if ((hdc_get_flags(c) & DEVICE_PS2) && !(machines[machine].flags & MACHINE_PS2_HDD)) + { + c++; + continue; + } + if ((hdc_get_flags(c) & DEVICE_MCA) && !(machines[machine].flags & MACHINE_MCA)) + { + c++; + continue; + } + if (!hdc_available(c)) + { + c++; + continue; + } + mbstowcs(lptsTemp, s, strlen(s) + 1); + SendMessage(h, CB_ADDSTRING, 0, (LPARAM) lptsTemp); + + hdc_names[d] = hdc_get_internal_name(c); + if (!strcmp(old_name, hdc_names[d])) + { + SendMessage(h, CB_SETCURSEL, d, 0); + valid = 1; + } + c++; + d++; + } + + if (!valid) + { + SendMessage(h, CB_SETCURSEL, 0, 0); + } + + EnableWindow(h, TRUE); free(lptsTemp); } @@ -1645,18 +1619,11 @@ static BOOL CALLBACK win_settings_peripherals_proc(HWND hdlg, UINT message, WPAR return FALSE; case WM_SAVESETTINGS: - if (hdc_ignore == 0) + h = GetDlgItem(hdlg, IDC_COMBO_HDC); + c = SendMessage(h, CB_GETCURSEL, 0, 0); + if (hdc_names[c]) { - h = GetDlgItem(hdlg, IDC_COMBO_HDC); - c = SendMessage(h, CB_GETCURSEL, 0, 0); - if (hdc_names[c]) - { - strncpy(temp_hdc_name, hdc_names[c], sizeof(temp_hdc_name) - 1); - } - else - { - strcpy(temp_hdc_name, "none"); - } + strncpy(temp_hdc_name, hdc_names[c], sizeof(temp_hdc_name) - 1); } else {