Visual Studio fixes

This commit is contained in:
jacksonmj 2011-06-22 19:22:48 +01:00 committed by Simon Robertshaw
parent 04b3eb11fd
commit 36e2a07a5b
6 changed files with 73 additions and 35 deletions

View File

@ -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

View File

@ -1,3 +1,5 @@
#ifdef FONTEDITOR
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -282,3 +284,5 @@ int main(int argc, char *argv[])
return 0;
}
#endif

View File

@ -1,3 +1,5 @@
#ifdef FONTEDITOR
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -98,3 +100,5 @@ int main(int argc, char *argv[])
return 0;
}
#endif

View File

@ -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

View File

@ -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;

View File

@ -16,7 +16,11 @@
#include <misc.h>
#include <console.h>
#include <images.h>
#if defined(WIN32) && !defined(__GNUC__)
#include <io.h>
#else
#include <dirent.h>
#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, &current_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))
{
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)))
fname = derp->d_name;
#endif
if(strlen(fname)>4)
{
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, &current_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);