diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 7c6a6bd3f..4a3a5dd6f 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ # # Modified Makefile for Win32 (MinGW32) environment. # -# Version: @(#)Makefile.mingw 1.0.56 2017/10/10 +# Version: @(#)Makefile.mingw 1.0.57 2017/10/11 # # Authors: Miran Grca, # Fred N. van Kempen, @@ -453,7 +453,7 @@ clean: @-rm *.res 2>NUL clobber: clean - @echO Cleaning executables.. + @echo Cleaning executables.. @-rm *.d 2>NUL @-rm *.exe 2>NUL # @-rm *.depends 2>NUL diff --git a/src/cdrom/cdrom.c b/src/cdrom/cdrom.c index 82792156c..ab9210560 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.15 2017/10/10 + * Version: @(#)cdrom.c 1.0.16 2017/10/12 * * Author: Miran Grca, * @@ -989,16 +989,16 @@ void cdrom_mode_sense_load(uint8_t id) switch(id) { case 0: - f = _wfopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"rb"); + f = plat_fopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"rb"); break; case 1: - f = _wfopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"rb"); + f = plat_fopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"rb"); break; case 2: - f = _wfopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"rb"); + f = plat_fopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"rb"); break; case 3: - f = _wfopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"rb"); + f = plat_fopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"rb"); break; default: return; @@ -1017,16 +1017,16 @@ void cdrom_mode_sense_save(uint8_t id) switch(id) { case 0: - f = _wfopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"wb"); + f = plat_fopen(nvr_path(L"cdrom_1_mode_sense.bin"), L"wb"); break; case 1: - f = _wfopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"wb"); + f = plat_fopen(nvr_path(L"cdrom_2_mode_sense.bin"), L"wb"); break; case 2: - f = _wfopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"wb"); + f = plat_fopen(nvr_path(L"cdrom_3_mode_sense.bin"), L"wb"); break; case 3: - f = _wfopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"wb"); + f = plat_fopen(nvr_path(L"cdrom_4_mode_sense.bin"), L"wb"); break; default: return; diff --git a/src/cdrom/cdrom_dosbox.cpp b/src/cdrom/cdrom_dosbox.cpp index 0b2ea24c6..a8b1ef389 100644 --- a/src/cdrom/cdrom_dosbox.cpp +++ b/src/cdrom/cdrom_dosbox.cpp @@ -20,7 +20,10 @@ #define _LARGEFILE_SOURCE #define _LARGEFILE64_SOURCE -#define _GNU_SOURCE +#ifdef WIN32 +//FIXME: should not be needed. */ +# define _GNU_SOURCE +#endif #include #include diff --git a/src/cdrom/cdrom_image.cc b/src/cdrom/cdrom_image.cc index e1d5a0dce..bff23da58 100644 --- a/src/cdrom/cdrom_image.cc +++ b/src/cdrom/cdrom_image.cc @@ -9,9 +9,10 @@ #include #include #include -#include +#include #include #include "../config.h" +#include "../plat.h" #include "cdrom_dosbox.h" #include "cdrom.h" #include "cdrom_image.h" @@ -990,10 +991,10 @@ int image_open(uint8_t id, wchar_t *fn) if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed) { - _swprintf(cdrom_image[id].image_path, L"%ws", fn); + swprintf(cdrom_image[id].image_path, sizeof(cdrom_image[id].image_path)/sizeof(wchar_t), L"%ws", fn); } - if (!wcsicmp(get_extension_w(fn), L"ISO")) + if (! wcscasecmp(get_extension_w(fn), L"ISO")) { cdrom_image[id].image_is_iso = 1; } diff --git a/src/config.c b/src/config.c index e74951968..2df51ee1e 100644 --- a/src/config.c +++ b/src/config.c @@ -8,11 +8,7 @@ * * Configuration file handler. * -<<<<<<< HEAD - * Version: @(#)config.c 1.0.16 2017/10/10 -======= - * Version: @(#)config.c 1.0.16 2017/10/11 ->>>>>>> 89ec4e0fa703eacfdada3ab3d55f885bc28522f1 + * Version: @(#)config.c 1.0.18 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -57,9 +53,10 @@ #include "sound/snd_opl.h" #include "sound/sound.h" #include "video/video.h" -#include "ui.h" +#include "plat.h" #include "plat_joystick.h" #include "plat_midi.h" +#include "ui.h" typedef struct _list_ { @@ -245,9 +242,9 @@ config_read(wchar_t *fn) FILE *f; #ifdef ANSI_CFG - f = _wfopen(fn, L"rt"); + f = plat_fopen(fn, L"rt"); #else - f = _wfopen(fn, L"rt, ccs=UNICODE"); + f = plat_fopen(fn, L"rt, ccs=UNICODE"); #endif if (f == NULL) return(0); @@ -343,9 +340,9 @@ config_write(wchar_t *fn) int fl = 0; #ifdef ANSI_CFG - f = _wfopen(fn, L"wt"); + f = plat_fopen(fn, L"wt"); #else - f = _wfopen(fn, L"wt, ccs=UNICODE"); + f = plat_fopen(fn, L"wt, ccs=UNICODE"); #endif if (f == NULL) return; @@ -2010,7 +2007,8 @@ append_filename(char *dest, char *s1, char *s2, int size) void append_filename_w(wchar_t *dest, wchar_t *s1, wchar_t *s2, int size) { - _swprintf(dest, L"%s%s", s1, s2); + /* We assume 512 here (pathnames) which "should" be safe. --FvK */ + swprintf(dest, 512, L"%s%s", s1, s2); } diff --git a/src/cpu/386.c b/src/cpu/386.c index a050fde14..e988d3186 100644 --- a/src/cpu/386.c +++ b/src/cpu/386.c @@ -41,20 +41,20 @@ x86seg _oldds; extern int cpl_override; -int has_fpu; extern int fpucount; uint16_t rds; uint16_t ea_rseg; -int is486; int cgate32; uint32_t cr2, cr3, cr4; uint32_t dr[8]; - +#if FIXME +/* in mem.c and rom.c */ uint8_t romext[32768]; uint8_t *ram,*rom; +#endif uint32_t rmdat32; #define rmdat rmdat32 diff --git a/src/cpu/386_dynarec.c b/src/cpu/386_dynarec.c index 9c5ad3a95..d8c2418ed 100644 --- a/src/cpu/386_dynarec.c +++ b/src/cpu/386_dynarec.c @@ -45,17 +45,16 @@ int trap; int cpl_override=0; -int has_fpu; int fpucount=0; uint16_t rds; uint16_t ea_rseg; -int is486; int cgate32; - +#if FIXME uint8_t romext[32768]; uint8_t *ram,*rom; +#endif uint32_t rmdat32; uint32_t backupregs[16]; diff --git a/src/cpu/808x.c b/src/cpu/808x.c index d3f98e84d..2a10834e6 100644 --- a/src/cpu/808x.c +++ b/src/cpu/808x.c @@ -18,10 +18,11 @@ * 2 clocks - fetch opcode 1 2 clocks - execute * 2 clocks - fetch opcode 2 etc * - * Version: @(#)808x.c 1.0.3 2017/10/04 + * Version: @(#)808x.c 1.0.4 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -32,14 +33,16 @@ #include "../ibm.h" #include "cpu.h" #include "x86.h" -#include "../keyboard.h" /* its WRONG to have this in here!! --FvK */ #include "../mem.h" #include "../rom.h" #include "../nmi.h" #include "../pic.h" #include "../timer.h" #include "../device.h" /* for scsi.h */ +#include "../keyboard.h" /* its WRONG to have this in here!! --FvK */ #include "../scsi/scsi.h" /* its WRONG to have this in here!! --FvK */ +#include "../plat.h" + int xt_cpu_multi; int nmi = 0; @@ -131,7 +134,10 @@ int noint=0; int output=0; +#if 0 +/* Also in mem.c */ int shadowbios=0; +#endif int ins=0; @@ -487,7 +493,10 @@ void makeznptable() if (c&0x8000) znptable16[c]|=N_FLAG; } } +#if 1 +/* Also in mem.c */ int timetolive=0; +#endif extern uint32_t oldcs2; extern uint32_t oldpc2; @@ -507,7 +516,7 @@ void dumpregs(int force) #ifndef RELEASE_BUILD indump = 1; output=0; - _wchdir(cfg_path); + (void)plat_chdir(cfg_path); nopageerrors=1; f=fopen("ram.dmp","wb"); fwrite(ram,mem_size*1024,1,f); diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index f875901c4..ae09c637f 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -8,11 +8,12 @@ * * CPU type handler. * - * Version: @(#)cpu.c 1.0.2 2017/09/24 + * Version: @(#)cpu.c 1.0.3 2017/10/12 * * Authors: Sarah Walker, * leilei, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 leilei. * Copyright 2016,2017 Miran Grca. @@ -114,7 +115,7 @@ int cpu_waitstates; int cpu_cache_int_enabled, cpu_cache_ext_enabled; int cpu_pci_speed; -int is286, is386; +int is286, is386, is486; int israpidcad, is_pentium; uint64_t tsc = 0; diff --git a/src/cpu/x86.h b/src/cpu/x86.h index deb210cb6..a49ea9769 100644 --- a/src/cpu/x86.h +++ b/src/cpu/x86.h @@ -17,7 +17,7 @@ uint8_t opcode; int noint; uint16_t lastcs,lastpc; -int timetolive,keyboardtimer; +extern int timetolive,keyboardtimer; #define setznp168 setznp16 diff --git a/src/cpu/x86seg.c b/src/cpu/x86seg.c index 5f036245f..8fd3cd135 100644 --- a/src/cpu/x86seg.c +++ b/src/cpu/x86seg.c @@ -8,10 +8,11 @@ * * x86 CPU segment emulation. * - * Version: @(#)x86seg.c 1.0.2 2017/10/02 + * Version: @(#)x86seg.c 1.0.3 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -39,7 +40,6 @@ int stimes = 0; int dtimes = 0; int btimes = 0; -int is486=1; uint32_t abrt_error; int cgate16,cgate32; diff --git a/src/cpu/x86seg.h b/src/cpu/x86seg.h index f4badadf4..4f12a8d65 100644 --- a/src/cpu/x86seg.h +++ b/src/cpu/x86seg.h @@ -8,10 +8,11 @@ * * x86 CPU segment emulation. * - * Version: @(#)x86seg.h 1.0.0 2017/05/30 + * Version: @(#)x86seg.h 1.0.1 2017/10/12 * * Author: Miran Grca, + * * Copyright 2016-2017 Miran Grca. */ -void do_seg_load(x86seg *s, uint16_t *segdat); +extern void do_seg_load(x86seg *s, uint16_t *segdat); diff --git a/src/disk/hdc_ide.c b/src/disk/hdc_ide.c index cbc68bc80..f32501b12 100644 --- a/src/disk/hdc_ide.c +++ b/src/disk/hdc_ide.c @@ -9,7 +9,7 @@ * Implementation of the IDE emulation for hard disks and ATAPI * CD-ROM devices. * - * Version: @(#)hdc_ide.c 1.0.11 2017/10/09 + * Version: @(#)hdc_ide.c 1.0.12 2017/10/11 * * Authors: Sarah Walker, * Miran Grca, @@ -17,6 +17,9 @@ * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ +#define __USE_LARGEFILE64 +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE #include #include #include @@ -621,7 +624,7 @@ void ide_reset(void) ide_drives[d].type = IDE_NONE; if (ide_drives[d].hdd_num != -1) hdd_image_close(ide_drives[d].hdd_num); - if (ide_drive_is_cdrom(&ide_drives[d])) + if ((d < 8) && ide_drive_is_cdrom(&ide_drives[d])) { cdrom[atapi_cdrom_drives[d]].status = READY_STAT | DSC_STAT; } diff --git a/src/disk/hdc_mfm_at.c b/src/disk/hdc_mfm_at.c index d191e8517..53bfcc4d1 100644 --- a/src/disk/hdc_mfm_at.c +++ b/src/disk/hdc_mfm_at.c @@ -12,7 +12,7 @@ * based design. Most cards were WD1003-WA2 or -WAH, where the * -WA2 cards had a floppy controller as well (to save space.) * - * Version: @(#)hdd_mfm_at.c 1.0.6 2017/10/09 + * Version: @(#)hdd_mfm_at.c 1.0.7 2017/10/11 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -20,6 +20,9 @@ * Copyright 2008-2017 Sarah Walker. * Copyright 2017 Fred N. van Kempen. */ +#define __USE_LARGEFILE64 +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE #include #include #include diff --git a/src/disk/hdc_mfm_xt.c b/src/disk/hdc_mfm_xt.c index c6e82fdfb..0ff2c652a 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: @(#)hdd_mfm_xt.c 1.0.8 2017/10/09 + * Version: @(#)hdd_mfm_xt.c 1.0.9 2017/10/11 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -49,6 +49,9 @@ * Copyright 2008-2017 Sarah Walker. * Copyright 2017 Fred N. van Kempen. */ +#define __USE_LARGEFILE64 +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE #include #include #include diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index 564ec5ffa..e51548708 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -8,11 +8,12 @@ * * Handling of hard disk image files. * - * Version: @(#)hdd_image.c 1.0.2 2017/10/01 + * Version: @(#)hdd_image.c 1.0.4 2017/11/12 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016-2017 Miran Grca. * Copyright 2017 Fred N. van Kempen. @@ -28,6 +29,7 @@ #include #include #include "../ibm.h" +#include "../plat.h" #include "hdd.h" @@ -75,7 +77,7 @@ int image_is_hdi(const wchar_t *s) return 0; } memcpy(ext, ws + ((len - 4) << 1), 8); - if (wcsicmp(ext, L".HDI") == 0) + if (! wcscasecmp(ext, L".HDI")) { return 1; } @@ -105,7 +107,7 @@ image_is_hdx(const wchar_t *s, int check_signature) { if (check_signature) { - f = _wfopen(s, L"rb"); + f = plat_fopen((wchar_t *)s, L"rb"); if (!f) { return 0; @@ -176,7 +178,7 @@ int hdd_image_load(int id) memset(hdd[id].fn, 0, sizeof(hdd[id].fn)); return 0; } - hdd_images[id].file = _wfopen(fn, L"rb+"); + hdd_images[id].file = plat_fopen(fn, L"rb+"); if (hdd_images[id].file == NULL) { /* Failed to open existing hard disk image */ @@ -191,7 +193,7 @@ int hdd_image_load(int id) return 0; } - hdd_images[id].file = _wfopen(fn, L"wb+"); + hdd_images[id].file = plat_fopen(fn, L"wb+"); if (hdd_images[id].file == NULL) { hdd_image_log("Unable to open image\n"); diff --git a/src/floppy/floppy.c b/src/floppy/floppy.c index 5c653cf84..3d6fd09d2 100644 --- a/src/floppy/floppy.c +++ b/src/floppy/floppy.c @@ -9,7 +9,7 @@ * Generic floppy disk interface that communicates with the * other handlers. * - * Version: @(#)floppy.c 1.0.6 2017/10/09 + * Version: @(#)floppy.c 1.0.8 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -26,6 +26,7 @@ #include "../rom.h" #include "../config.h" #include "../timer.h" +#include "../plat.h" #include "../ui.h" #include "floppy.h" #include "floppy_86f.h" @@ -136,14 +137,14 @@ void floppy_load(int drive, wchar_t *fn) if (!fn) return; p = get_extension_w(fn); if (!p) return; - f = _wfopen(fn, L"rb"); + f = plat_fopen(fn, L"rb"); if (!f) return; fseek(f, -1, SEEK_END); size = ftell(f) + 1; fclose(f); while (loaders[c].ext) { - if (!_wcsicmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) + if (!wcscasecmp(p, loaders[c].ext) && (size == loaders[c].size || loaders[c].size == -1)) { driveloaders[drive] = c; memcpy(floppyfns[drive], fn, (wcslen(fn) << 1) + 2); diff --git a/src/floppy/floppy_86f.c b/src/floppy/floppy_86f.c index a7a16c1e6..9328d7d3d 100644 --- a/src/floppy/floppy_86f.c +++ b/src/floppy/floppy_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)floppy_86f.c 1.0.6 2017/10/09 + * Version: @(#)floppy_86f.c 1.0.7 2017/10/12 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -28,6 +28,7 @@ #include "../dma.h" #include "../nvr.h" #include "../random.h" +#include "../plat.h" #include "../ui.h" #include "floppy.h" #include "fdc.h" @@ -3072,7 +3073,7 @@ void d86f_writeback(int drive) /* The image is compressed. */ /* Open the original, compressed file. */ - cf = _wfopen(d86f[drive].original_file_name, L"wb"); + cf = plat_fopen(d86f[drive].original_file_name, L"wb"); /* Write the header to the original file. */ fwrite(header, 1, header_size, cf); @@ -3364,10 +3365,10 @@ void d86f_load(int drive, wchar_t *fn) d86f_unregister(drive); writeprot[drive] = 0; - d86f[drive].f = _wfopen(fn, L"rb+"); + d86f[drive].f = plat_fopen(fn, L"rb+"); if (!d86f[drive].f) { - d86f[drive].f = _wfopen(fn, L"rb"); + d86f[drive].f = plat_fopen(fn, L"rb"); if (!d86f[drive].f) { memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); @@ -3478,7 +3479,7 @@ void d86f_load(int drive, wchar_t *fn) fclose(d86f[drive].f); d86f[drive].f = NULL; - d86f[drive].f = _wfopen(temp_file_name, L"wb"); + d86f[drive].f = plat_fopen(temp_file_name, L"wb"); if (!d86f[drive].f) { d86f_log("86F: Unable to create temporary decompressed file\n"); @@ -3486,7 +3487,7 @@ void d86f_load(int drive, wchar_t *fn) return; } - tf = _wfopen(fn, L"rb"); + tf = plat_fopen(fn, L"rb"); for (i = 0; i < 8; i++) { @@ -3512,12 +3513,12 @@ void d86f_load(int drive, wchar_t *fn) if (!temp) { d86f_log("86F: Error decompressing file\n"); - _wremove(temp_file_name); + plat_remove(temp_file_name); memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); return; } - d86f[drive].f = _wfopen(temp_file_name, L"rb+"); + d86f[drive].f = plat_fopen(temp_file_name, L"rb+"); } if (d86f[drive].disk_flags & 0x100) @@ -3528,7 +3529,7 @@ void d86f_load(int drive, wchar_t *fn) d86f[drive].f = NULL; if (d86f[drive].is_compressed) { - _wremove(temp_file_name); + plat_remove(temp_file_name); } memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); return; @@ -3542,7 +3543,7 @@ void d86f_load(int drive, wchar_t *fn) d86f[drive].f = NULL; if (d86f[drive].is_compressed) { - _wremove(temp_file_name); + plat_remove(temp_file_name); } memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); return; @@ -3561,11 +3562,11 @@ void d86f_load(int drive, wchar_t *fn) if (d86f[drive].is_compressed) { - d86f[drive].f = _wfopen(temp_file_name, L"rb"); + d86f[drive].f = plat_fopen(temp_file_name, L"rb"); } else { - d86f[drive].f = _wfopen(fn, L"rb"); + d86f[drive].f = plat_fopen(fn, L"rb"); } } @@ -3675,5 +3676,5 @@ void d86f_close(int drive) d86f[drive].f = NULL; } if (d86f[drive].is_compressed) - _wremove(temp_file_name); + plat_remove(temp_file_name); } diff --git a/src/floppy/floppy_fdi.c b/src/floppy/floppy_fdi.c index acb46491f..1f65696b5 100644 --- a/src/floppy/floppy_fdi.c +++ b/src/floppy/floppy_fdi.c @@ -9,10 +9,11 @@ * Implementation of the FDI floppy stream image format * interface to the FDI2RAW module. * - * Version: @(#)floppy_fdi.c 1.0.2 2017/09/24 + * Version: @(#)floppy_fdi.c 1.0.3 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -21,6 +22,7 @@ #include #include #include "../ibm.h" +#include "../plat.h" #include "floppy.h" #include "floppy_86f.h" #include "floppy_img.h" @@ -264,7 +266,7 @@ void fdi_load(int drive, wchar_t *fn) char header[26]; writeprot[drive] = fwriteprot[drive] = 1; - fdi[drive].f = _wfopen(fn, L"rb"); + fdi[drive].f = plat_fopen(fn, L"rb"); if (!fdi[drive].f) { memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); diff --git a/src/floppy/floppy_imd.c b/src/floppy/floppy_imd.c index 97c9480b0..f5de9700d 100644 --- a/src/floppy/floppy_imd.c +++ b/src/floppy/floppy_imd.c @@ -8,7 +8,7 @@ * * Implementation of the IMD floppy image format. * - * Version: @(#)floppy_imd.c 1.0.2 2017/09/24 + * Version: @(#)floppy_imd.c 1.0.3 2017/10/12 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -19,6 +19,7 @@ #include #include #include "../ibm.h" +#include "../plat.h" #include "floppy.h" #include "floppy_imd.h" #include "fdc.h" @@ -89,10 +90,10 @@ void imd_load(int drive, wchar_t *fn) d86f_unregister(drive); writeprot[drive] = 0; - imd[drive].f = _wfopen(fn, L"rb+"); + imd[drive].f = plat_fopen(fn, L"rb+"); if (!imd[drive].f) { - imd[drive].f = _wfopen(fn, L"rb"); + imd[drive].f = plat_fopen(fn, L"rb"); if (!imd[drive].f) { memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); diff --git a/src/floppy/floppy_img.c b/src/floppy/floppy_img.c index b1567cb9b..20f712981 100644 --- a/src/floppy/floppy_img.c +++ b/src/floppy/floppy_img.c @@ -9,10 +9,11 @@ * Implementation of the raw sector-based floppy image format, * as well as the Japanese FDI, CopyQM, and FDF formats. * - * Version: @(#)floppy_img.c 1.0.2 2017/09/24 + * Version: @(#)floppy_img.c 1.0.3 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -23,6 +24,7 @@ #include #include "../ibm.h" #include "../config.h" +#include "../plat.h" #include "floppy.h" #include "floppy_img.h" #include "fdc.h" @@ -349,10 +351,10 @@ void img_load(int drive, wchar_t *fn) d86f_unregister(drive); writeprot[drive] = 0; - img[drive].f = _wfopen(fn, L"rb+"); + img[drive].f = plat_fopen(fn, L"rb+"); if (!img[drive].f) { - img[drive].f = _wfopen(fn, L"rb"); + img[drive].f = plat_fopen(fn, L"rb"); if (!img[drive].f) { memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); @@ -370,7 +372,7 @@ void img_load(int drive, wchar_t *fn) img[drive].interleave = img[drive].skew = 0; - if (_wcsicmp(ext, L"FDI") == 0) + if (! wcscasecmp(ext, L"FDI")) { /* This is a Japanese FDI image, so let's read the header */ pclog("img_load(): File is a Japanese FDI image...\n"); @@ -415,7 +417,7 @@ void img_load(int drive, wchar_t *fn) pclog("img_load(): File is a FDF image...\n"); fwriteprot[drive] = writeprot[drive] = 1; fclose(img[drive].f); - img[drive].f = _wfopen(fn, L"rb"); + img[drive].f = plat_fopen(fn, L"rb"); fdf = 1; @@ -600,7 +602,7 @@ void img_load(int drive, wchar_t *fn) pclog("img_load(): File is a CopyQM image...\n"); fwriteprot[drive] = writeprot[drive] = 1; fclose(img[drive].f); - img[drive].f = _wfopen(fn, L"rb"); + img[drive].f = plat_fopen(fn, L"rb"); fseek(img[drive].f, 0x03, SEEK_SET); fread(&bpb_bps, 1, 2, img[drive].f); diff --git a/src/floppy/floppy_json.c b/src/floppy/floppy_json.c index 562a305a0..57c6dfde9 100644 --- a/src/floppy/floppy_json.c +++ b/src/floppy/floppy_json.c @@ -8,9 +8,10 @@ * * Implementation of the PCjs JSON floppy image format. * - * Version: @(#)floppy_json.c 1.0.4 2017/10/07 + * Version: @(#)floppy_json.c 1.0.6 2017/10/12 * * Author: Fred N. van Kempen, + * * Copyright 2017 Fred N. van Kempen. */ #include @@ -19,6 +20,7 @@ #include #include #include "../ibm.h" +#include "../plat.h" #include "floppy.h" #include "fdc.h" #include "fdd.h" @@ -476,7 +478,7 @@ json_load(int drive, wchar_t *fn) memset(img, 0x00, sizeof(json_t)); /* Open the image file. */ - img->f = _wfopen(fn, L"rb"); + img->f = plat_fopen(fn, L"rb"); if (img->f == NULL) { memset(fn, 0x00, sizeof(wchar_t)); return; diff --git a/src/floppy/floppy_td0.c b/src/floppy/floppy_td0.c index ca4d4ceef..0d16e3250 100644 --- a/src/floppy/floppy_td0.c +++ b/src/floppy/floppy_td0.c @@ -8,7 +8,7 @@ * * Implementation of the Teledisk floppy image format. * - * Version: @(#)floppy_td0.c 1.0.3 2017/09/24 + * Version: @(#)floppy_td0.c 1.0.4 2017/10/12 * * Authors: Milodrag Milanovic, * Haruhiko OKUMURA, @@ -43,6 +43,7 @@ #include #include #include "../ibm.h" +#include "../plat.h" #include "floppy.h" #include "floppy_td0.h" #include "fdc.h" @@ -533,7 +534,7 @@ void td0_load(int drive, wchar_t *fn) d86f_unregister(drive); writeprot[drive] = 1; - td0[drive].f = _wfopen(fn, L"rb"); + td0[drive].f = plat_fopen(fn, L"rb"); if (!td0[drive].f) { memset(floppyfns[drive], 0, sizeof(floppyfns[drive])); diff --git a/src/intel_flash.c b/src/intel_flash.c index e112e10bf..807c53d23 100644 --- a/src/intel_flash.c +++ b/src/intel_flash.c @@ -8,10 +8,11 @@ * * Implementation of the Intel 2 Mbit 8-bit flash devices. * - * Version: @(#)intel_flash.c 1.0.5 2017/10/04 + * Version: @(#)intel_flash.c 1.0.7 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -26,6 +27,8 @@ #include "mem.h" #include "machine/machine.h" #include "nvr.h" +#include "plat.h" + #define FLASH_IS_BXB 2 #define FLASH_INVERT 1 @@ -178,7 +181,7 @@ static void intel_flash_add_mappings_inverted(flash_t *flash) void *intel_flash_init(uint8_t type) { FILE *f; - int i; + int i, l; flash_t *flash; wchar_t *machine_name; wchar_t *flash_name; @@ -186,10 +189,12 @@ void *intel_flash_init(uint8_t type) flash = malloc(sizeof(flash_t)); memset(flash, 0, sizeof(flash_t)); - machine_name = (wchar_t *) malloc((strlen(machine_get_internal_name_ex(machine)) << 1) + 2); - mbstowcs(machine_name, machine_get_internal_name_ex(machine), strlen(machine_get_internal_name_ex(machine)) + 1); - flash_name = (wchar_t *) malloc((wcslen(machine_name) << 1) + 2 + 8); - _swprintf(flash_name, L"%s.bin", machine_name); + l = strlen(machine_get_internal_name_ex(machine)) + 1; + machine_name = (wchar_t *) malloc(l << 1); + mbstowcs(machine_name, machine_get_internal_name_ex(machine), l); + l = wcslen(machine_name) + 5; + flash_name = (wchar_t *) malloc(l << 1); + swprintf(flash_name, l, L"%s.bin", machine_name); wcscpy(flash_path, flash_name); diff --git a/src/lnx/lnx_thread.c b/src/lnx/lnx_thread.c deleted file mode 100644 index 70e458e06..000000000 --- a/src/lnx/lnx_thread.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#include -#include -#include -#include -#include "../plat.h" - - -typedef struct { - pthread_cond_t cond; - pthread_mutex_t mutex; -} event_pthread_t; - - -thread_t * -thread_create(void (*thread_rout)(void *param), void *param) -{ - pthread_t *thread = malloc(sizeof(pthread_t)); - - if (thread != NULL) - pthread_create(thread, NULL, thread_rout, param); - - return(thread); -} - - -void -thread_kill(thread_t *handle) -{ - pthread_t *thread = (pthread_t *)handle; - - if (thread != NULL) { - pthread_cancel(*thread); - pthread_join(*thread, NULL); - - free(thread); - } -} - - -event_t * -thread_create_event(void) -{ - event_pthread_t *event = malloc(sizeof(event_pthread_t)); - - if (event != NULL) { - pthread_cond_init(&event->cond, NULL); - pthread_mutex_init(&event->mutex, NULL); - } - - return((event_t *)event); -} - - -void -thread_set_event(event_t *handle) -{ - event_pthread_t *event = (event_pthread_t *)handle; - - if (event != NULL) { - pthread_mutex_lock(&event->mutex); - pthread_cond_broadcast(&event->cond); - pthread_mutex_unlock(&event->mutex); - } -} - - -void -thread_reset_event(event_t *handle) -{ -} - - -int -thread_wait_event(event_t *handle, int timeout) -{ - event_pthread_t *event = (event_pthread_t *)handle; - struct timespec abstime; - - clock_gettime(CLOCK_REALTIME, &abstime); - abstime.tv_nsec += (timeout % 1000) * 1000000; - abstime.tv_sec += (timeout / 1000); - if (abstime.tv_nsec > 1000000000) { - abstime.tv_nsec -= 1000000000; - abstime.tv_sec++; - } - - pthread_mutex_lock(&event->mutex); - pthread_cond_timedwait(&event->cond, &event->mutex, &abstime); - pthread_mutex_unlock(&event->mutex); - - return(0); -} - - -void -thread_destroy_event(event_t *handle) -{ - event_pthread_t *event = (event_pthread_t *)handle; - - if (event != NULL) { - pthread_cond_destroy(&event->cond); - pthread_mutex_destroy(&event->mutex); - - free(event); - } -} - - -void -thread_sleep(int t) -{ - usleep(t * 1000); -} diff --git a/src/lnx/plat_thread.h b/src/lnx/plat_thread.h deleted file mode 100644 index dfb3a9c26..000000000 --- a/src/lnx/plat_thread.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright holders: Sarah Walker - see COPYING for more details -*/ -#ifndef PLAT_THREAD_H -# define PLAT_THREAD_H - - -typedef void thread_t; -typedef void event_t; - - -extern thread_t *thread_create(void (*thread_rout)(void *param), void *param); -extern void thread_kill(thread_t *handle); - -extern event_t *thread_create_event(void); -extern void thread_set_event(event_t *event); -extern void thread_reset_event(event_t *_event); -extern int thread_wait_event(event_t *event, int timeout); -extern void thread_destroy_event(event_t *_event); - -extern void thread_sleep(int t); - - -#endif /*PLAT_THREAD_H*/ diff --git a/src/mem.c b/src/mem.c index d5a391ebc..3ad1b5015 100644 --- a/src/mem.c +++ b/src/mem.c @@ -55,7 +55,8 @@ int writelookup[256],writelookupp[256]; uintptr_t *writelookup2; int writelnext; -int shadowbios,shadowbios_write; +int shadowbios = 0, + shadowbios_write; int mem_a20_state; diff --git a/src/network/net_pcap.c b/src/network/net_pcap.c index c1831e1b7..96b14ad7f 100644 --- a/src/network/net_pcap.c +++ b/src/network/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.8 2017/10/10 + * Version: @(#)net_pcap.c 1.0.9 2017/10/11 * * Author: Fred N. van Kempen, * diff --git a/src/network/net_slirp.c b/src/network/net_slirp.c index ce5f1cc43..639772a86 100644 --- a/src/network/net_slirp.c +++ b/src/network/net_slirp.c @@ -8,7 +8,7 @@ * * Handle SLiRP library processing. * - * Version: @(#)net_slirp.c 1.0.7 2017/10/10 + * Version: @(#)net_slirp.c 1.0.8 2017/10/11 * * Author: Fred N. van Kempen, * diff --git a/src/network/slirp/debug.c b/src/network/slirp/debug.c index 556e02672..50cae86a7 100644 --- a/src/network/slirp/debug.c +++ b/src/network/slirp/debug.c @@ -6,6 +6,9 @@ * terms and conditions of the copyright. */ +#ifndef WIN32 +# include +#endif #include "slirp.h" FILE *dfd = NULL; diff --git a/src/network/slirp/misc.c b/src/network/slirp/misc.c index 90bc2483e..0da04dee2 100644 --- a/src/network/slirp/misc.c +++ b/src/network/slirp/misc.c @@ -7,6 +7,9 @@ #define WANT_SYS_IOCTL_H #include +#ifndef WIN32 +# include +#endif #include "slirp.h" u_int curtime, time_fasttimo, last_slowtimo, detach_time; diff --git a/src/network/slirp/slirp.h b/src/network/slirp/slirp.h index 3f4efd0bd..0cacdb8ca 100644 --- a/src/network/slirp/slirp.h +++ b/src/network/slirp/slirp.h @@ -59,6 +59,12 @@ typedef unsigned long ioctlsockopt_t; # define init_udp slirp_init_udp # define final_udp slirp_final_udp #else +# include +typedef uint8_t u_int8_t; +typedef uint16_t u_int16_t; +typedef uint32_t u_int32_t; +typedef uint64_t u_int64_t; +typedef char *SLIRPcaddr_t; typedef int ioctlsockopt_t; # define ioctlsocket ioctl # define closesocket(s) close(s) diff --git a/src/network/slirp/socket.c b/src/network/slirp/socket.c index 5e6fb2dc0..fba38fc79 100644 --- a/src/network/slirp/socket.c +++ b/src/network/slirp/socket.c @@ -7,6 +7,9 @@ #define WANT_SYS_IOCTL_H #include +#ifndef WIN32 +# include +#endif #include "slirp.h" #include "ip_icmp.h" #include "main.h" diff --git a/src/network/slirp/tcp_subr.c b/src/network/slirp/tcp_subr.c index cb0f0750a..5168e4ae4 100644 --- a/src/network/slirp/tcp_subr.c +++ b/src/network/slirp/tcp_subr.c @@ -40,6 +40,9 @@ #define WANT_SYS_IOCTL_H #include +#ifndef WIN32 +# include +#endif #include "slirp.h" /* patchable/settable parameters for tcp */ diff --git a/src/network/slirp/udp.c b/src/network/slirp/udp.c index fbeb3c340..7c7d0831b 100644 --- a/src/network/slirp/udp.c +++ b/src/network/slirp/udp.c @@ -39,6 +39,9 @@ */ #include +#ifndef WIN32 +# include +#endif #include "slirp.h" #include "ip_icmp.h" diff --git a/src/nvr.c b/src/nvr.c index 8ad43f540..c9c8837c3 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -186,7 +186,7 @@ * (DS12887A) which implemented a "century" register to be * compatible with Y2K. * - * Version: @(#)nvr.c 1.0.6 2017/10/09 + * Version: @(#)nvr.c 1.0.7 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -681,7 +681,7 @@ nvr_load(void) f = NULL; if (saved_nvr->mask != 0) { pclog("Opening NVR file: %ws...\n", saved_nvr->fname); - f = _wfopen(nvr_path(saved_nvr->fname), L"rb"); + f = plat_fopen(nvr_path(saved_nvr->fname), L"rb"); } if (f != NULL) { @@ -724,7 +724,7 @@ nvr_save(void) f = NULL; if (saved_nvr->mask != 0) { pclog("Saving NVR file: %ws...\n", saved_nvr->fname); - f = _wfopen(nvr_path(saved_nvr->fname), L"wb"); + f = plat_fopen(nvr_path(saved_nvr->fname), L"wb"); } if (f != NULL) { @@ -775,5 +775,5 @@ nvr_path(wchar_t *str) FILE * nvr_fopen(wchar_t *str, wchar_t *mode) { - return(_wfopen(nvr_path(str), mode)); + return(plat_fopen(nvr_path(str), mode)); } diff --git a/src/pc.c b/src/pc.c index 4d845eae7..00d6c345f 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Emulation core dispatcher. * - * Version: @(#)pc.c 1.0.23 2017/10/11 + * Version: @(#)pc.c 1.0.24 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -212,12 +212,12 @@ pc_init(int argc, wchar_t *argv[]) * a shortcut (desktop icon), however, the CWD * could have been set to something else. */ - _wgetcwd(cfg_path, sizeof(cfg_path)-1); + plat_getcwd(cfg_path, sizeof(cfg_path)-1); for (c=1; c * Fred N. van Kempen, @@ -28,12 +28,20 @@ extern "C" { /* System-related functions. */ +extern FILE *plat_fopen(wchar_t *path, wchar_t *mode); +extern void plat_remove(wchar_t *path); +extern int plat_getcwd(wchar_t *bufp, int max); +extern int plat_chdir(wchar_t *path); extern void get_executable_name(wchar_t *s, int size); extern void set_window_title(wchar_t *s); extern int dir_check_exist(wchar_t *path); extern int dir_create(wchar_t *path); extern void leave_fullscreen(void); +#ifdef WIN32 +# define wcscasecmp _wcsicmp +#endif + /* Resource management. */ extern wchar_t *plat_get_string(int id); @@ -95,5 +103,4 @@ extern void startslirp(void); extern void endslirp(void); - #endif /*EMU_PLAT_H*/ diff --git a/src/rom.c b/src/rom.c index 25d9019d6..d1edba500 100644 --- a/src/rom.c +++ b/src/rom.c @@ -13,7 +13,7 @@ * - c386sx16 BIOS fails checksum * - the loadfont() calls should be done elsewhere * - * Version: @(#)rom.c 1.0.7 2017/10/10 + * Version: @(#)rom.c 1.0.9 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -33,6 +33,7 @@ #include "mem.h" #include "rom.h" #include "video/video.h" /* for loadfont() */ +#include "plat.h" int romspresent[ROM_MAX]; @@ -47,7 +48,7 @@ rom_fopen(wchar_t *fn, wchar_t *mode) put_backslash_w(temp); wcscat(temp, fn); - return(_wfopen(temp, mode)); + return(plat_fopen(temp, mode)); } @@ -60,7 +61,7 @@ rom_getfile(wchar_t *fn, wchar_t *s, int size) put_backslash_w(s); wcscat(s, fn); - f = _wfopen(s, L"rb"); + f = plat_fopen(s, L"rb"); if (f != NULL) { (void)fclose(f); return(1); diff --git a/src/scsi/scsi_disk.c b/src/scsi/scsi_disk.c index 7cd0fd599..2a1536f85 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.13 2017/10/10 + * Version: @(#)scsi_disk.c 1.0.14 2017/10/12 * * Author: Miran Grca, * Copyright 2017 Miran Grca. @@ -698,8 +698,8 @@ void scsi_hd_mode_sense_load(uint8_t id) FILE *f; wchar_t temp[512]; memset(temp, 0, 1024); - _swprintf(temp, L"scsi_hd_%02i_mode_sense.bin", id); - f = _wfopen(nvr_path(temp), L"rb"); + swprintf(temp, 512, L"scsi_hd_%02i_mode_sense.bin", id); + f = plat_fopen(nvr_path(temp), L"rb"); if (!f) { return; @@ -713,8 +713,8 @@ void scsi_hd_mode_sense_save(uint8_t id) FILE *f; wchar_t temp[512]; memset(temp, 0, 1024); - _swprintf(temp, L"scsi_hd_%02i_mode_sense.bin", id); - f = _wfopen(nvr_path(temp), L"wb"); + swprintf(temp, 512, L"scsi_hd_%02i_mode_sense.bin", id); + f = plat_fopen(nvr_path(temp), L"wb"); if (!f) { return; diff --git a/src/ui.h b/src/ui.h index 0b80d6bd6..291894f3a 100644 --- a/src/ui.h +++ b/src/ui.h @@ -28,7 +28,7 @@ extern "C" { #ifdef WIN32 # include "win/resource.h" #else -# ... dunno yet ... +# include "lnx/strings.h" #endif diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index bb85028a5..29bcb683c 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -8,7 +8,7 @@ * * Emulation of the 3DFX Voodoo Graphics controller. * - * Version: @(#)vid_voodoo.c 1.0.1 2017/10/10 + * Version: @(#)vid_voodoo.c 1.0.2 2017/10/11 * * Authors: Sarah Walker, * leilei @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include "../ibm.h" diff --git a/src/win/win.c b/src/win/win.c index c0ab892c1..83ef6d181 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -8,7 +8,7 @@ * * The Emulator's Windows core. * - * Version: @(#)win.c 1.0.20 2017/10/10 + * Version: @(#)win.c 1.0.21 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -1335,6 +1335,36 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nFunsterStil) } +FILE * +plat_fopen(wchar_t *path, wchar_t *mode) +{ + return(_wfopen(path, mode)); +} + + +void +plat_remove(wchar_t *path) +{ + _wremove(path); +} + + +int +plat_getcwd(wchar_t *bufp, int max) +{ + (void)_wgetcwd(bufp, max); + + return(0); +} + + +int +plat_chdir(wchar_t *path) +{ + return(_wchdir(path)); +} + + void get_executable_name(wchar_t *s, int size) { diff --git a/src/win/win_dynld.c b/src/win/win_dynld.c index fd1553a38..1065867e8 100644 --- a/src/win/win_dynld.c +++ b/src/win/win_dynld.c @@ -8,7 +8,7 @@ * * Try to load a support DLL. * - * Version: @(#)win_dynld.c 1.0.4 2017/10/10 + * Version: @(#)win_dynld.c 1.0.5 2017/10/11 * * Author: Fred N. van Kempen, * @@ -19,7 +19,6 @@ #include #include #include -#include #include #include "../ibm.h" #include "../plat_dynld.h" @@ -31,7 +30,6 @@ dynld_module(const char *name, dllimp_t *table) HMODULE h; dllimp_t *imp; void *func; - /* char **foo; */ /* See if we can load the desired module. */ if ((h = LoadLibrary(name)) == NULL) { diff --git a/src/win/win_joystick.cc b/src/win/win_joystick.cc index d34fe68cb..695638ee8 100644 --- a/src/win/win_joystick.cc +++ b/src/win/win_joystick.cc @@ -8,7 +8,7 @@ * * Joystick interface to host device. * - * Version: @(#)win_joystick.cc 1.0.3 2017/10/10 + * Version: @(#)win_joystick.cc 1.0.4 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -19,6 +19,7 @@ #define DIRECTINPUT_VERSION 0x0800 #include #include +#include #include extern "C" { #include "../device.h" diff --git a/src/win/win_mouse.cc b/src/win/win_mouse.cc index 5b23e421d..fc5bc8b7e 100644 --- a/src/win/win_mouse.cc +++ b/src/win/win_mouse.cc @@ -8,7 +8,7 @@ * * Mouse interface to host device. * - * Version: @(#)win_mouse.cc 1.0.3 2017/10/10 + * Version: @(#)win_mouse.cc 1.0.4 2017/10/12 * * Authors: Sarah Walker, * Miran Grca, @@ -18,6 +18,7 @@ */ #define DIRECTINPUT_VERSION 0x0800 #include +#include #include #include "../plat.h" #include "../plat_mouse.h"