Starting Win32 support.

This commit is contained in:
Themaister 2011-01-07 17:59:53 +01:00
parent 3d20fe70cd
commit 2a4995c21f
12 changed files with 118 additions and 16 deletions

View File

@ -5,7 +5,7 @@ TARGET = ssnes
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o
LIBS =
DEFINES =
DEFINES = -DHAVE_CONFIG_H
ifeq ($(HAVE_SRC), 1)
LIBS += $(SRC_LIBS)

58
Makefile.win32 Normal file
View File

@ -0,0 +1,58 @@
TARGET = ssnes.exe
OBJ = ssnes.o file.o driver.o conf/config_file.o settings.o dynamic.o
CC = gcc
CXX = g++
HAVE_SRC = 1
HAVE_SDL = 1
libsnes = -lsnes
LIBS =
DEFINES = -I. -DHAVE_SRC -DHAVE_SDL
LDFLAGS = -L.
SRC_LIBS = -lsamplerate-0
SDL_LIBS = -lSDLmain -lSDL
ifeq ($(HAVE_SRC), 1)
LIBS += $(SRC_LIBS)
DEFINES += $(SRC_CFLAGS)
endif
ifeq ($(HAVE_SDL), 1)
OBJ += gfx/gl.o input/sdl.o audio/sdl.o audio/buffer.o
LIBS += $(SDL_LIBS) -lopengl32
DEFINES += $(SDL_CFLAGS)
endif
LIBS += $(libsnes)
CFLAGS = -Wall -O3 -g -std=gnu99 -I.
all: $(TARGET)
$(TARGET): $(OBJ)
$(CXX) -o $@ $(OBJ) $(LIBS) $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
install: $(TARGET)
install -m755 $(TARGET) $(DESTDIR)$(PREFIX)/bin
install -m644 ssnes.cfg $(DESTDIR)/etc/ssnes.cfg
uninstall: $(TARGET)
rm -rf $(DESTDIR)/$(PREFIX)/bin/$(TARGET)
clean:
rm -f *.o
rm -f audio/*.o
rm -f conf/*.o
rm -f gfx/*.o
rm -f record/*.o
rm -f hqflt/*.o
rm -f hqflt/snes_ntsc/*.o
rm -f $(TARGET)
.PHONY: all install uninstall clean

View File

@ -132,7 +132,7 @@ static void print_config(config_file_t *conf)
struct entry_list *tmp = conf->entries;
while (tmp != NULL)
{
printf("Key: \"%s\", Value: \"%s\"\n", tmp->key, tmp->value);
SSNES_LOG("Config => Key: \"%s\", Value: \"%s\"\n", tmp->key, tmp->value);
tmp = tmp->next;
}
}

View File

@ -22,14 +22,24 @@
#ifndef __CONFIG_DEF_H
#define __CONFIG_DEF_H
#include <SDL/SDL.h>
#include <stdbool.h>
#include "libsnes.hpp"
#include "driver.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SDL
#include <SDL/SDL.h>
#else
#error HAVE_SDL is not defined!
#endif
#ifdef HAVE_SRC
#include <samplerate.h>
#else
#error HAVE_SRC is not defined!
#endif
@ -104,7 +114,7 @@ static const unsigned out_rate = 48000;
// Input samplerate from libSNES.
// Lower this (slightly) if you are experiencing frequent audio dropouts while vsync is enabled.
static const unsigned in_rate = 31950;
static const unsigned in_rate = 31980;
// Audio device (e.g. hw:0,0 or /dev/audio). If NULL, will use defaults.
static const char* audio_device = NULL;
@ -127,7 +137,7 @@ static const bool audio_sync = true;
// Axis threshold (between 0.0 and 1.0)
// How far an axis must be tilted to result in a button press
#define AXIS_THRESHOLD 0.8
#define AXIS_THRESHOLD 0.5
#define AXIS_NEG(x) ((uint32_t)(x << 16) | 0xFFFF)
#define AXIS_POS(x) ((uint32_t)(x) | 0xFFFF0000U)

View File

@ -21,7 +21,10 @@
#include <stdio.h>
#include <string.h>
#include "hqflt/filters.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
static const audio_driver_t *audio_drivers[] = {
#ifdef HAVE_ALSA

View File

@ -18,7 +18,12 @@
#include "dynamic.h"
#include "general.h"
#include <string.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <libsnes.hpp>
#ifdef HAVE_DYNAMIC
#include <dlfcn.h>

View File

@ -23,7 +23,11 @@
#include "driver.h"
#include <stdio.h>
#include "record/ffemu.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_SRC
#include <samplerate.h>
#endif
@ -103,14 +107,17 @@ extern struct global g_extern;
#define SSNES_LOG(msg, args...) do { \
if (g_extern.verbose) \
fprintf(stderr, "SSNES: " msg, ##args); \
fflush(stderr); \
} while(0)
#define SSNES_ERR(msg, args...) do { \
fprintf(stderr, "SSNES [ERROR] :: " msg, ##args); \
fprintf(stderr, "SSNES [ERROR] :: " msg, ##args); \
fflush(stderr); \
} while(0)
#define SSNES_WARN(msg, args...) do { \
fprintf(stderr, "SSNES [WARN] :: " msg, ##args); \
fprintf(stderr, "SSNES [WARN] :: " msg, ##args); \
fflush(stderr); \
} while(0)
#endif

View File

@ -24,7 +24,10 @@
#include <sys/time.h>
#include <string.h>
#include "general.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#define NO_SDL_GLEXT
#include <SDL/SDL.h>
@ -276,7 +279,7 @@ static void gl_set_nonblock_state(void *data, bool state)
{
SSNES_LOG("GL VSync => %s\n", state ? "off" : "on");
#ifdef _WIN32
static BOOL (APIENTRY wgl_swap_interval*)(int) = NULL;
static BOOL (APIENTRY *wgl_swap_interval)(int) = NULL;
if (!wgl_swap_interval)
SSNES_WARN("SDL VSync toggling seems to be broken, attempting to use WGL VSync call directly instead.\n");
if (!wgl_swap_interval) wgl_swap_interval = (BOOL (APIENTRY*)(int)) wglGetProcAddress("wglSwapIntervalEXT");

View File

@ -19,7 +19,9 @@
#ifndef __FILTERS_H
#define __FILTERS_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_FILTER

View File

@ -21,7 +21,11 @@
#include <assert.h>
#include <string.h>
#include "hqflt/filters.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <ctype.h>
struct settings g_settings;
@ -60,6 +64,9 @@ static void set_defaults(void)
case AUDIO_AL:
def_audio = "openal";
break;
case AUDIO_SDL:
def_audio = "sdl";
break;
default:
break;
}

11
ssnes.c
View File

@ -223,6 +223,12 @@ static void fill_pathname(char *out_path, char *in_path, const char *replace)
#define FFMPEG_HELP_QUARK
#endif
#ifdef _WIN32
#define SSNES_DEFAULT_CONF_PATH_STR "\n\tDefaults to ssnes.cfg in same directory as ssnes.exe"
#else
#define SSNES_DEFAULT_CONF_PATH_STR " Defaults to $XDG_CONFIG_HOME/ssnes/ssnes.cfg"
#endif
static void print_help(void)
{
puts("=================================================");
@ -231,7 +237,8 @@ static void print_help(void)
puts("Usage: ssnes [rom file] [-h/--help | -s/--save" FFMPEG_HELP_QUARK "]");
puts("\t-h/--help: Show this help message");
puts("\t-s/--save: Path for save file (*.srm). Required when rom is input from stdin");
puts("\t-c/--config: Path for config file. Defaults to $XDG_CONFIG_HOME/ssnes/ssnes.cfg");
puts("\t-c/--config: Path for config file." SSNES_DEFAULT_CONF_PATH_STR);
#ifdef HAVE_FFMPEG
puts("\t-r/--record: Path to record video file. Settings for video/audio codecs are found in config file.");
#endif
@ -354,7 +361,7 @@ int main(int argc, char *argv[])
SSNES_ERR("Could not read ROM file.\n");
exit(1);
}
SSNES_LOG("ROM size: %zi bytes\n", rom_len);
SSNES_LOG("ROM size: %d bytes\n", (int)rom_len);
if (g_extern.rom_file != NULL)
fclose(g_extern.rom_file);

View File

@ -10,8 +10,8 @@
# video_yscale = 3.0
# Fullscreen resolution
# video_fullscreen_x = 1280
# video_fullscreen_y = 720
video_fullscreen_x = 1920
video_fullscreen_y = 1200
# Start in fullscreen. Can be changed at runtime.
# video_fullscreen = false
@ -43,16 +43,16 @@
# audio_enable = true
# Audio output samplerate.
# audio_out_rate = 48000
audio_out_rate = 48000
# Audio input samplerate from libsnes.
# Lower this (slightly) if you are experiencing frequent audio dropouts while vsync is enabled.
# Conversely, increase this slightly if you are experiencing good audio,
# but lots of dropped frames. Reasonable values for this is 32000 +/- 100 Hz.
# audio_in_rate = 31950
audio_in_rate = 31980
# Audio driver backend. Depending on configuration possible candidates are: alsa, oss, rsound, roar, openal
# audio_driver = alsa
# audio_driver = sdl
# Override the default audio device the audio_driver uses.
# audio_device =
@ -61,7 +61,7 @@
# audio_sync = true
# Desired audio latency in milliseconds. Might not be honored if driver can't provide given latency.
# audio_latency = 64
audio_latency = 16
# libsamplerate quality. Valid values are from 1 to 5. These values map to zero_order_hold, linear, sinc_fastest, sinc_medium and sinc_best.
# audio_src_quality =