diff --git a/src/cpu_common/cpu.h b/src/cpu_common/cpu.h index 5d60d7310..6275a9b24 100644 --- a/src/cpu_common/cpu.h +++ b/src/cpu_common/cpu.h @@ -321,7 +321,7 @@ struct _cpustate_ { #define CPU_STATUS_MASK 0xffff0000 #endif -#ifdef __MSC__ +#ifdef _MSC_VER # define COMPILE_TIME_ASSERT(expr) /*nada*/ #else # ifdef EXTREME_DEBUG diff --git a/src/disk/hdd_image.c b/src/disk/hdd_image.c index 337265546..aa8bf8509 100644 --- a/src/disk/hdd_image.c +++ b/src/disk/hdd_image.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #define HAVE_STDARG_H diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 4b6b3d200..25e607e0b 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -29,6 +29,7 @@ /* The Win32 API uses _wcsicmp. */ #ifdef _WIN32 # define wcscasecmp _wcsicmp +# define strcasecmp _stricmp #endif #if defined(UNIX) && defined(FREEBSD) @@ -37,11 +38,20 @@ # define fseeko64 fseeko # define ftello64 ftello # define off64_t off_t +#elif defined(_MSC_VER) +//# define fopen64 fopen +# define fseeko64 _fseeki64 +# define ftello64 _ftelli64 +# define off64_t off_t #endif -/* A hack (GCC-specific?) to allow us to ignore unused parameters. */ -#define UNUSED(arg) __attribute__((unused))arg +#ifdef _MSC_VER +# define UNUSED(arg) arg +#else + /* A hack (GCC-specific?) to allow us to ignore unused parameters. */ +# define UNUSED(arg) __attribute__((unused))arg +#endif /* Return the size (in wchar's) of a wchar_t array. */ #define sizeof_w(x) (sizeof((x)) / sizeof(wchar_t)) diff --git a/src/include/86box/vid_voodoo_codegen_x86-64.h b/src/include/86box/vid_voodoo_codegen_x86-64.h index bbb4be868..cecf3a539 100644 --- a/src/include/86box/vid_voodoo_codegen_x86-64.h +++ b/src/include/86box/vid_voodoo_codegen_x86-64.h @@ -13,6 +13,7 @@ # include #endif +#include #include #define BLOCK_NUM 8 diff --git a/src/include/86box/vid_voodoo_codegen_x86.h b/src/include/86box/vid_voodoo_codegen_x86.h index 8e5f5f38d..6cf2562d0 100644 --- a/src/include/86box/vid_voodoo_codegen_x86.h +++ b/src/include/86box/vid_voodoo_codegen_x86.h @@ -13,6 +13,7 @@ # include #endif +#include #include #define BLOCK_NUM 8 diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 1734b71de..da43e31b9 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -79,6 +79,10 @@ #endif +#ifdef __cplusplus +extern "C" { +#endif + extern HINSTANCE hinstance; extern HWND hwndMain, hwndRender; @@ -94,10 +98,6 @@ extern WCHAR wopenfilestring[512]; extern uint8_t filterindex; -#ifdef __cplusplus -extern "C" { -#endif - #ifdef USE_CRASHDUMP extern void InitCrashDump(void); #endif diff --git a/src/network/net_pcnet.c b/src/network/net_pcnet.c index df7dec9e2..f7cf2a5dc 100644 --- a/src/network/net_pcnet.c +++ b/src/network/net_pcnet.c @@ -21,7 +21,6 @@ #else #include #endif -#include #include #include #include diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index fcde2f1f1..1003907c3 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -53,12 +53,12 @@ typedef struct gsapi_revision_s { long revisiondate; } gsapi_revision_t; -static GSDLLAPI int (*gsapi_revision)(gsapi_revision_t *pr, int len); -static GSDLLAPI int (*gsapi_new_instance)(void **pinstance, void *caller_handle); -static GSDLLAPI void (*gsapi_delete_instance)(void *instance); -static GSDLLAPI int (*gsapi_set_arg_encoding)(void *instance, int encoding); -static GSDLLAPI int (*gsapi_init_with_args)(void *instance, int argc, char **argv); -static GSDLLAPI int (*gsapi_exit)(void *instance); +static int (GSDLLAPI *gsapi_revision)(gsapi_revision_t *pr, int len); +static int (GSDLLAPI *gsapi_new_instance)(void **pinstance, void *caller_handle); +static void (GSDLLAPI *gsapi_delete_instance)(void *instance); +static int (GSDLLAPI *gsapi_set_arg_encoding)(void *instance, int encoding); +static int (GSDLLAPI *gsapi_init_with_args)(void *instance, int argc, char **argv); +static int (GSDLLAPI *gsapi_exit)(void *instance); static dllimp_t ghostscript_imports[] = { { "gsapi_revision", &gsapi_revision }, @@ -405,12 +405,12 @@ ps_close(void *p) } const lpt_device_t lpt_prt_ps_device = { - name: "Generic PostScript printer", - init: ps_init, - close: ps_close, - write_data: ps_write_data, - write_ctrl: ps_write_ctrl, - read_data: NULL, - read_status: ps_read_status, - read_ctrl: NULL + .name = "Generic PostScript printer", + .init = ps_init, + .close = ps_close, + .write_data = ps_write_data, + .write_ctrl = ps_write_ctrl, + .read_data = NULL, + .read_status = ps_read_status, + .read_ctrl = NULL }; \ No newline at end of file diff --git a/src/random.c b/src/random.c index aa0986960..4f7168c4b 100644 --- a/src/random.c +++ b/src/random.c @@ -25,7 +25,7 @@ uint32_t preconst = 0x6ED9EBA1; -static __inline__ uint32_t rotl32c (uint32_t x, uint32_t n) +static __inline uint32_t rotl32c (uint32_t x, uint32_t n) { #if 0 assert (n<32); @@ -33,7 +33,7 @@ static __inline__ uint32_t rotl32c (uint32_t x, uint32_t n) return (x<>(-n&31)); } -static __inline__ uint32_t rotr32c (uint32_t x, uint32_t n) +static __inline uint32_t rotr32c (uint32_t x, uint32_t n) { #if 0 assert (n<32); @@ -45,11 +45,11 @@ static __inline__ uint32_t rotr32c (uint32_t x, uint32_t n) #define ROTATE_RIGHT rotr32c -static __inline__ unsigned long long rdtsc(void) +static __inline unsigned long long rdtsc(void) { #if defined(__i386__) || defined (__x86_64__) unsigned hi, lo; -#ifdef __MSC__ +#ifdef _MSC_VER __asm { rdtsc mov hi, edx ; EDX:EAX is already standard return!! diff --git a/src/scsi/scsi_ncr53c8xx.c b/src/scsi/scsi_ncr53c8xx.c index cf3532a02..265e16d4b 100644 --- a/src/scsi/scsi_ncr53c8xx.c +++ b/src/scsi/scsi_ncr53c8xx.c @@ -336,7 +336,7 @@ static uint8_t ncr53c8xx_reg_readb(ncr53c8xx_t *dev, uint32_t offset); static void ncr53c8xx_reg_writeb(ncr53c8xx_t *dev, uint32_t offset, uint8_t val); -static __inline__ int32_t +static __inline int32_t sextract32(uint32_t value, int start, int length) { /* Note that this implementation relies on right shift of signed @@ -346,7 +346,7 @@ sextract32(uint32_t value, int start, int length) } -static __inline__ int +static __inline int ncr53c8xx_irq_on_rsl(ncr53c8xx_t *dev) { return (dev->sien0 & NCR_SIST0_RSL) && (dev->scid & NCR_SCID_RRE); @@ -490,7 +490,7 @@ ncr53c8xx_write(ncr53c8xx_t *dev, uint32_t addr, uint8_t *buf, uint32_t len) } -static __inline__ uint32_t +static __inline uint32_t read_dword(ncr53c8xx_t *dev, uint32_t addr) { uint32_t buf; @@ -588,7 +588,7 @@ ncr53c8xx_script_dma_interrupt(ncr53c8xx_t *dev, int stat) } -static __inline__ void +static __inline void ncr53c8xx_set_phase(ncr53c8xx_t *dev, int phase) { dev->sstat1 = (dev->sstat1 & ~PHASE_MASK) | phase; diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index d69268950..09a51994b 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -641,7 +641,8 @@ void adgold_timer_poll(void *p) static void adgold_get_buffer(int32_t *buffer, int len, void *p) { adgold_t *adgold = (adgold_t *)p; - int16_t adgold_buffer[len*2]; + int16_t* adgold_buffer = malloc(sizeof(int16_t) * len * 2); + if (adgold_buffer == NULL) fatal("adgold_buffer = NULL"); int c; @@ -747,6 +748,8 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) adgold->opl.pos = 0; adgold->pos = 0; + + free(adgold_buffer); } diff --git a/src/sound/snd_audiopci.c b/src/sound/snd_audiopci.c index 952152de5..8bc8cbab6 100644 --- a/src/sound/snd_audiopci.c +++ b/src/sound/snd_audiopci.c @@ -3,6 +3,7 @@ #include #include #include +#define _USE_MATH_DEFINES #include #define HAVE_STDARG_H #include <86box/86box.h> diff --git a/src/sound/snd_emu8k.c b/src/sound/snd_emu8k.c index 706b0e130..70465f121 100644 --- a/src/sound/snd_emu8k.c +++ b/src/sound/snd_emu8k.c @@ -5,6 +5,7 @@ #include #include #include +#define _USE_MATH_DEFINES #include #define HAVE_STDARG_H #include <86box/86box.h> diff --git a/src/sound/snd_sb_dsp.c b/src/sound/snd_sb_dsp.c index 6fccf6dd3..a33d2cda4 100644 --- a/src/sound/snd_sb_dsp.c +++ b/src/sound/snd_sb_dsp.c @@ -4,6 +4,7 @@ 486-50 - 32kHz Pentium - 45kHz*/ +#define _USE_MATH_DEFINES #include #include #include diff --git a/src/video/vid_voodoo.c b/src/video/vid_voodoo.c index 88a7e556c..7212eff15 100644 --- a/src/video/vid_voodoo.c +++ b/src/video/vid_voodoo.c @@ -7223,7 +7223,8 @@ static void voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uin int x; // Scratchpad for avoiding feedback streaks - uint8_t fil3[(voodoo->h_disp) * 3]; + uint8_t *fil3 = malloc((voodoo->h_disp) * 3); + if (fil3 == NULL) fatal("fil3 = NULL"); /* 16 to 32-bit */ for (x=0; xthefilterg[fil3[x*3+1]][fil3[ (x+1) *3+1]]; fil[(x)*3+2] = voodoo->thefilter[fil3[x*3+2]][fil3[ (x+1) *3+2]]; } + + free(fil3); } @@ -7289,7 +7292,8 @@ static void voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uin int x; // Scratchpad for blending filter - uint8_t fil3[(voodoo->h_disp) * 3]; + uint8_t *fil3 = malloc((voodoo->h_disp) * 3); + if (fil3 == NULL) fatal("fil3 = NULL"); /* 16 to 32-bit */ for (x=0; xthefilterb [fil[(column-1)*3]][((src[column] & 31) << 3)]; fil3[(column-1)*3+1] = voodoo->thefilterg [fil[(column-1)*3+1]][(((src[column] >> 5) & 63) << 2)]; fil3[(column-1)*3+2] = voodoo->thefilter [fil[(column-1)*3+2]][(((src[column] >> 11) & 31) << 3)]; + + free(fil3); } void voodoo_callback(void *p) @@ -7400,7 +7406,8 @@ void voodoo_callback(void *p) if (voodoo->scrfilter && voodoo->scrfilterEnabled) { - uint8_t fil[(voodoo->h_disp) * 3]; /* interleaved 24-bit RGB */ + uint8_t *fil = malloc((voodoo->h_disp) * 3); + if (fil == NULL) fatal("fil = NULL"); if (voodoo->type == VOODOO_2) voodoo_filterline_v2(voodoo, fil, voodoo->h_disp, src, voodoo->line); @@ -7411,6 +7418,8 @@ void voodoo_callback(void *p) { p[x] = (voodoo->clutData256[fil[x*3]].b << 0 | voodoo->clutData256[fil[x*3+1]].g << 8 | voodoo->clutData256[fil[x*3+2]].r << 16); } + + free(fil); } else { diff --git a/src/win/86Box.rc b/src/win/86Box.rc index a0b387c2d..5a1593662 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -1,4 +1,4 @@ -/* +/* * 86Box A hypervisor and IBM PC system emulator that specializes in * running old operating systems and software designed for IBM * PC systems and compatibles from 1981 through fairly recent diff --git a/src/win/win_discord.c b/src/win/win_discord.c index d374fbce8..ec379ea9f 100644 --- a/src/win/win_discord.c +++ b/src/win/win_discord.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #define HAVE_STDARG_H #include <86box/86box.h> diff --git a/src/win/win_joystick.cpp b/src/win/win_joystick.cpp index b13a8893f..1f9de5ee6 100644 --- a/src/win/win_joystick.cpp +++ b/src/win/win_joystick.cpp @@ -18,6 +18,7 @@ */ #define DIRECTINPUT_VERSION 0x0800 #include +#define _USE_MATH_DEFINES #include #include #include @@ -29,6 +30,8 @@ #include <86box/gameport.h> #include <86box/win.h> +#define DIDEVTYPE_JOYSTICK 4 + plat_joystick_t plat_joystick_state[MAX_PLAT_JOYSTICKS]; joystick_t joystick_state[MAX_JOYSTICKS]; diff --git a/src/win/win_joystick_rawinput.c b/src/win/win_joystick_rawinput.c index 2ce664bbb..c4f947bac 100644 --- a/src/win/win_joystick_rawinput.c +++ b/src/win/win_joystick_rawinput.c @@ -21,6 +21,7 @@ #include #include #include +#define _USE_MATH_DEFINES #include #include #include diff --git a/src/win/win_joystick_xinput.c b/src/win/win_joystick_xinput.c index 3b62d449d..0e3f5fdce 100644 --- a/src/win/win_joystick_xinput.c +++ b/src/win/win_joystick_xinput.c @@ -19,6 +19,7 @@ * Copyright 2019 GH Cao. */ #include +#define _USE_MATH_DEFINES #include #include #include