diff --git a/extract_assets.py b/extract_assets.py index 706fc728..7c29358b 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -47,6 +47,7 @@ def remove_file(fname): def clean_assets(local_asset_file): assets = set(read_asset_map().keys()) assets.update(read_local_asset_list(local_asset_file)) + local_asset_file.close() for fname in list(assets) + [".assets-local.txt"]: if fname.startswith("@"): continue diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h index e2a3e771..ddff2827 100644 --- a/include/PR/ultratypes.h +++ b/include/PR/ultratypes.h @@ -31,7 +31,12 @@ typedef double f64; #include #include +#if defined(__MINGW32__) +#include <_mingw.h> +#if !defined(__MINGW64_VERSION_MAJOR) +typedef long ssize_t; +#else typedef ptrdiff_t ssize_t; - - +#endif +#endif #endif diff --git a/include/types.h b/include/types.h index 483c894f..870223eb 100644 --- a/include/types.h +++ b/include/types.h @@ -1,5 +1,5 @@ -#ifndef _TYPES_H_ -#define _TYPES_H_ +#ifndef _SM64_TYPES_H_ +#define _SM64_TYPES_H_ // This file contains various data types used in Super Mario 64 that don't yet // have an appropriate header. diff --git a/include/ultra64.h b/include/ultra64.h index 409a3cf7..e78ded49 100644 --- a/include/ultra64.h +++ b/include/ultra64.h @@ -30,4 +30,13 @@ #include #include +#if defined(__MINGW32__) +#include <_mingw.h> +#if !defined(__MINGW64_VERSION_MAJOR) +#include +#define bzero(b,len) (memset((b), '\0', (len)), (void) 0) +#define bcopy(s1, s2, n) memmove((s2), (s1), (n)) +#endif +#endif + #endif diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 7d0175b1..db8c04f8 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -9,8 +9,11 @@ #include "include/text_strings.h" #include "engine/surface_collision.h" #include "pc/configfile.h" +#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) +//quick and dirty fix for some older MinGW.org mingwrt +#else #include - +#endif /** diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index 727de38b..ee35bf60 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -5,6 +5,7 @@ #include #include +#define __NO_MINGW_LFS //Mysterious error in MinGW.org stdio.h #include #include diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 4f6968f7..01bea71f 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -155,7 +155,24 @@ static size_t buf_vbo_num_tris; static struct GfxWindowManagerAPI *gfx_wapi; static struct GfxRenderingAPI *gfx_rapi; +#if defined(__MINGW32__) +#include <_mingw.h> +#if !defined(__MINGW64_VERSION_MAJOR) +#include +#define CLOCK_MONOTONIC 0 +//https://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows +struct timespec { long tv_sec; long tv_nsec; }; //header part +int clock_gettime(int arg, struct timespec *spec) //C-file part +{ __int64 wintime; GetSystemTimeAsFileTime((FILETIME*)&wintime); + wintime -=116444736000000000LL; //1jan1601 to 1jan1970 + spec->tv_sec =wintime / 10000000LL; //seconds + spec->tv_nsec =wintime % 10000000LL*100; //nano-seconds + return 0; +} +#else #include +#endif +#endif static unsigned long get_time(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); diff --git a/tools/utils.h b/tools/utils.h index dff1d6a3..03f482d0 100644 --- a/tools/utils.h +++ b/tools/utils.h @@ -7,8 +7,9 @@ // printing size_t varies by compiler #if defined(_MSC_VER) || defined(__MINGW32__) + #include #define SIZE_T_FORMAT "%Iu" - #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) + #define realpath(N,R) _fullpath((R),(N),MAX_PATH) #else #define SIZE_T_FORMAT "%zu" #endif