diff --git a/font/Makefile b/font/Makefile index e3b0c8c16..7bb04e0a0 100644 --- a/font/Makefile +++ b/font/Makefile @@ -1,5 +1,5 @@ editor: editor.c - gcc -oeditor -DSCALE=2 editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99 + gcc -oeditor -DSCALE=2 -DFONTEDITOR editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99 clean: rm -f editor packer diff --git a/font/editor.c b/font/editor.c index 71c5aa039..77147822d 100644 --- a/font/editor.c +++ b/font/editor.c @@ -1,3 +1,5 @@ +#ifdef FONTEDITOR + #include #include #include @@ -282,3 +284,5 @@ int main(int argc, char *argv[]) return 0; } + +#endif diff --git a/font/packer.c b/font/packer.c index db57b1a08..b30e6d375 100644 --- a/font/packer.c +++ b/font/packer.c @@ -1,3 +1,5 @@ +#ifdef FONTEDITOR + #include #include #include @@ -98,3 +100,5 @@ int main(int argc, char *argv[]) return 0; } + +#endif diff --git a/includes/defines.h b/includes/defines.h index 8daeaba67..1294ad717 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -112,6 +112,12 @@ typedef unsigned int pixel; #ifdef WIN32 #define strcasecmp stricmp #endif +#if defined(WIN32) && !defined(__GNUC__) +#define fmin min +#define fminf min +#define fmax max +#define fmaxf max +#endif #define SDEUT diff --git a/src/graphics.c b/src/graphics.c index fd6213f9d..6a15e5a93 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -163,7 +163,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh) q = malloc(rw*rh*PIXELSIZE); memcpy(q, src, rw*rh*PIXELSIZE); } else if(rw > sw && rh > sh){ - float fx, fy, fyc, fxc, intp; + float fx, fy, fyc, fxc; + double intp; pixel tr, tl, br, bl; q = malloc(rw*rh*PIXELSIZE); //Bilinear interpolation for upscaling @@ -172,8 +173,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh) { fx = ((float)x)*((float)sw)/((float)rw); fy = ((float)y)*((float)sh)/((float)rh); - fxc = modff(fx, &intp); - fyc = modff(fy, &intp); + fxc = modf(fx, &intp); + fyc = modf(fy, &intp); fxceil = (int)ceil(fx); fyceil = (int)ceil(fy); if (fxceil>=sw) fxceil = sw-1; @@ -190,7 +191,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh) } } else { //Stairstepping - float fx, fy, fyc, fxc, intp; + float fx, fy, fyc, fxc; + double intp; pixel tr, tl, br, bl; int rrw = rw, rrh = rh; pixel * oq; @@ -212,8 +214,8 @@ pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh) { fx = ((float)x)*((float)sw)/((float)rw); fy = ((float)y)*((float)sh)/((float)rh); - fxc = modff(fx, &intp); - fyc = modff(fy, &intp); + fxc = modf(fx, &intp); + fyc = modf(fy, &intp); fxceil = (int)ceil(fx); fyceil = (int)ceil(fy); if (fxceil>=sw) fxceil = sw-1; diff --git a/src/interface.c b/src/interface.c index 1cbf0d615..a85ea1f0c 100644 --- a/src/interface.c +++ b/src/interface.c @@ -16,7 +16,11 @@ #include #include #include +#if defined(WIN32) && !defined(__GNUC__) +#include +#else #include +#endif SDLMod sdl_mod; int sdl_key, sdl_wheel, sdl_caps=0, sdl_ascii, sdl_zoom_trig=0; @@ -5109,9 +5113,26 @@ typedef struct savelist_e savelist_e; savelist_e *get_local_saves(char *folder, char *search, int *results_ret) { int index = 0, results = 0; - struct dirent *derp; savelist_e *new_savelist = NULL; - savelist_e *current_item = NULL; + savelist_e *current_item = NULL, *new_item = NULL; + char *fname; +#if defined(WIN32) && !defined(__GNUC__) + struct _finddata_t current_file; + intptr_t findfile_handle; + char *filematch = malloc(strlen(folder)+4); + sprintf(filematch, "%s%s", folder, "*.*"); + findfile_handle = _findfirst(filematch, ¤t_file); + free(filematch); + if (findfile_handle == -1L) + { + *results_ret = 0; + return NULL; + } + do + { + fname = current_file.name; +#else + struct dirent *derp; DIR *directory = opendir(folder); if(!directory) { @@ -5119,39 +5140,40 @@ savelist_e *get_local_saves(char *folder, char *search, int *results_ret) *results_ret = 0; return NULL; } - while(derp = readdir(directory)){ - char *ext; - if(strlen(derp->d_name)>4) + while(derp = readdir(directory)) + { + fname = derp->d_name; +#endif + if(strlen(fname)>4) { - ext = derp->d_name+(strlen(derp->d_name)-4); - if((!strncmp(ext, ".cps", 4) || !strncmp(ext, ".stm", 4)) && (search==NULL || strstr(derp->d_name, search))) + char *ext = fname+(strlen(fname)-4); + if((!strncmp(ext, ".cps", 4) || !strncmp(ext, ".stm", 4)) && (search==NULL || strstr(fname, search))) { + new_item = malloc(sizeof(savelist_e)); + new_item->filename = malloc(strlen(folder)+strlen(fname)+1); + sprintf(new_item->filename, "%s%s", folder, fname); + new_item->name = mystrdup(fname); + new_item->image = NULL; + new_item->next = NULL; if(new_savelist==NULL){ - new_savelist = malloc(sizeof(savelist_e)); - new_savelist->filename = malloc(strlen(folder)+strlen(derp->d_name)+1); - sprintf(new_savelist->filename, "%s%s", folder, derp->d_name); - new_savelist->name = mystrdup(derp->d_name); - new_savelist->image = NULL; - new_savelist->next = NULL; - new_savelist->prev = NULL; - current_item = new_savelist; + new_savelist = new_item; + new_item->prev = NULL; } else { - savelist_e *prev_item = current_item; - current_item->next = malloc(sizeof(savelist_e)); - current_item = current_item->next; - current_item->filename = malloc(strlen(folder)+strlen(derp->d_name)+1); - sprintf(current_item->filename, "%s%s", folder, derp->d_name); - current_item->name = mystrdup(derp->d_name); - current_item->image = NULL; - current_item->next = NULL; - current_item->prev = prev_item; + current_item->next = new_item; + new_item->prev = current_item; } + current_item = new_item; results++; } } } - *results_ret = results; +#if defined(WIN32) && !defined(__GNUC__) + while (_findnext(findfile_handle, ¤t_file) == 0); + _findclose(findfile_handle); +#else closedir(directory); +#endif + *results_ret = results; return new_savelist; } @@ -5306,6 +5328,7 @@ void catalogue_ui(pixel * vid_buf) float scrollvel, offsetf = 0.0f; char savetext[128] = ""; char * last = mystrdup(""); + savelist_e *saves, *cssave, *csave; ui_edit ed; vid_buf2 = calloc((XRES+BARSIZE)*(YRES+MENUSIZE), PIXELSIZE); @@ -5321,9 +5344,8 @@ void catalogue_ui(pixel * vid_buf) ed.nx = 0; strcpy(ed.str, ""); - savelist_e *saves = get_local_saves(LOCAL_SAVE_DIR PATH_SEP, NULL, &rescount); - savelist_e *cssave = saves; - savelist_e *csave = saves; + saves = get_local_saves(LOCAL_SAVE_DIR PATH_SEP, NULL, &rescount); + cssave = csave = saves; while (!sdl_poll()) { b = SDL_GetMouseState(&mx, &my);