Some more cleanups wrt the sharing of the SDL codebase between

Linux and Windows.

Reworked the Makefile (again).  Now you have to edit it and select
which system you are using for the SDL port (linux or windows),
then start compilation with 'make sdl'.

The makefile is starting to get harder to manage, and with the
explosion of features, I'm looking into moving to a configure
script (autoconf and automake) for a future release.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@227 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2003-12-05 19:51:09 +00:00
parent 41556196e4
commit 1457853110
4 changed files with 93 additions and 75 deletions

View File

@ -13,7 +13,7 @@
## See the file "license" for information on usage and redistribution of ## See the file "license" for information on usage and redistribution of
## this file, and for a DISCLAIMER OF ALL WARRANTIES. ## this file, and for a DISCLAIMER OF ALL WARRANTIES.
## ##
## $Id: makefile,v 1.46 2003-12-04 22:22:53 stephena Exp $ ## $Id: makefile,v 1.47 2003-12-05 19:51:08 stephena Exp $
##============================================================================ ##============================================================================
##============================================================================ ##============================================================================
@ -23,7 +23,14 @@
## Comment a line out to disable that option, remove comment to enable it. ## Comment a line out to disable that option, remove comment to enable it.
##============================================================================ ##============================================================================
OPTIMIZATIONS = $(CXXFLAGS) -Wall -Wunused ### add your own compiler optimizations here
### if none are provided, the defaults will be used
OPTIMIZATIONS =
### which system the SDL version is being compiled on
### you should only enable one at a time
SYSTEM_SDL = linux
#SYSTEM_SDL = windows
### which sound drivers to compile for the SDL version ### which sound drivers to compile for the SDL version
### OSS is most compatible, SDL for platforms where OSS not available ### OSS is most compatible, SDL for platforms where OSS not available
@ -40,19 +47,17 @@ SOUND_SDL = 1
JOYSTICK_SUPPORT = 1 JOYSTICK_SUPPORT = 1
### to include support for saving snapshots in png format ### to include support for saving snapshots in png format
### (requires PNG library) FIXME ### (requires PNG library)
### Only SDL port supported for now FIXME SNAPSHOT_SUPPORT = 1
# SNAPSHOT_SUPPORT = 1
### comment this out if your system doesn't ### comment this out if your system doesn't
### have the gettimeofday function ### have the gettimeofday function
#HAVE_GETTIMEOFDAY = 1 # HAVE_GETTIMEOFDAY = 1
### to include support for game developers ### to include support for game developers
### enables some extra commandline options that allow the user ### enables some extra commandline options that allow the user
### to override some emulation defaults ### to override some emulation defaults
### Only SDL port supported for now # DEVELOPER_SUPPORT = 1
DEVELOPER_SUPPORT = 1
### if your C++ compiler doesn't support the bool type ### if your C++ compiler doesn't support the bool type
# BSPF_BOOL = 1 # BSPF_BOOL = 1
@ -79,7 +84,7 @@ OPTS.SDL =
LIBS.SDL = `sdl-config --libs` LIBS.SDL = `sdl-config --libs`
CFLAGS.SDL = `sdl-config --cflags` CFLAGS.SDL = `sdl-config --cflags`
OPTS.DOS = -DDOS=1 OPTS.DOS = -DDOS
SRC = .. SRC = ..
CORE = $(SRC)/emucore CORE = $(SRC)/emucore
@ -88,62 +93,94 @@ COMMON = $(SRC)/ui/common
INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src -I$(CORE)/m6502/src/bspf/src -I$(COMMON) INCLUDES = -I. -I$(CORE) -I$(CORE)/m6502/src -I$(CORE)/m6502/src/bspf/src -I$(COMMON)
FLAGS = $(OPTIMIZATIONS) $(INCLUDES) $(SYS_INCLUDES) ## set some sane optimizations if none have been provided
ifndef OPTIMIZATIONS
ifdef CXXFLAGS
OPTIMIZATIONS = $(CXXFLAGS)
else
OPTIMIZATIONS = -O2 -march=i386
endif
endif
FLAGS = $(OPTIMIZATIONS) -Wall -Wunused $(INCLUDES) $(SYS_INCLUDES)
## set the user-defined options ## set the user-defined options
ifdef BSPF_BOOL ifdef BSPF_BOOL
OPTS.DOS += -DBSPF_BOOL=1 OPTS.DOS += -DBSPF_BOOL
endif endif
ifdef SHOW_TIMING ifdef SHOW_TIMING
OPTS.SDL += -DSHOW_TIMING=1 OPTS.SDL += -DSHOW_TIMING
OPTS.DOS += -DSHOW_TIMING=1 OPTS.DOS += -DSHOW_TIMING
endif endif
ifdef DEBUG ifdef DEBUG
OPTS.SDL += -DDEBUG=1 OPTS.SDL += -DDEBUG
OPTS.DOS += -DDEBUG=1 OPTS.DOS += -DDEBUG
endif endif
ifdef JOYSTICK_SUPPORT ifdef JOYSTICK_SUPPORT
OPTS.SDL += -DHAVE_JOYSTICK=1 OPTS.SDL += -DHAVE_JOYSTICK
endif endif
ifdef SNAPSHOT_SUPPORT ifdef SNAPSHOT_SUPPORT
OBJS.SDL += Snapshot.o OBJS.SDL += Snapshot.o
OPTS.SDL += -DSNAPSHOT_SUPPORT=1 OPTS.SDL += -DSNAPSHOT_SUPPORT
LIBS.SDL += -lpng -lz LIBS.SDL += -lpng -lz
endif endif
ifdef HAVE_GETTIMEOFDAY ifdef HAVE_GETTIMEOFDAY
OPTS.SDL += -DHAVE_GETTIMEOFDAY=1 OPTS.SDL += -DHAVE_GETTIMEOFDAY
endif endif
ifdef DEVELOPER_SUPPORT ifdef DEVELOPER_SUPPORT
OPTS.SDL += -DDEVELOPER_SUPPORT=1 OPTS.SDL += -DDEVELOPER_SUPPORT
OPTS.DOS += -DDEVELOPER_SUPPORT=1 OPTS.DOS += -DDEVELOPER_SUPPORT
endif endif
ifeq ($(sounD_OSS), 1) ifeq ($(SOUND_OSS), 1)
OPTS.SDL += -DSOUND_OSS=1 OPTS.SDL += -DSOUND_OSS
OBJS.SDL += SoundOSS.o OBJS.SDL += SoundOSS.o
endif endif
ifeq ($(SOUND_SDL), 1) ifeq ($(SOUND_SDL), 1)
OPTS.SDL += -DSOUND_SDL=1 OPTS.SDL += -DSOUND_SDL
OBJS.SDL += SoundSDL.o OBJS.SDL += SoundSDL.o
endif endif
ifeq ($(SOUND_ALSA), 1) ifeq ($(SOUND_ALSA), 1)
OPTS.SDL += -DSOUND_ALSA=1 OPTS.SDL += -DSOUND_ALSA
OBJS.SDL += SoundALSA.o OBJS.SDL += SoundALSA.o
LIBS.SDL += -lasound LIBS.SDL += -lasound
endif endif
ifeq ($(OPENGL_SUPPORT), 1) ##============================================================================
OPTS.SDL += -DDISPLAY_OPENGL=1 ## Now figure out what has to be built for SDL
OBJS.SDL += FrameBufferGL.o ##============================================================================
LIBS.SDL += -lopengl32 ifeq ($(SYSTEM_SDL), linux)
CFLAGS.SDL += -L/usr/X11R6/lib
OPTS.SDL += -DBSPF_UNIX -DUNIX
LIBS.SDL += -lX11 -lXext
OBJS.SDL += SettingsUNIX.o
ifeq ($(OPENGL_SUPPORT), 1)
OPTS.SDL += -DDISPLAY_OPENGL
OBJS.SDL += FrameBufferGL.o
LIBS.SDL += -lGL
endif
endif
ifeq ($(SYSTEM_SDL), windows)
CFLAGS.SDL += ""
OPTS.SDL += -DBSPF_WIN32 -DWIN32
LIBS.SDL += ""
OBJS.SDL += SettingsWin32.o
ifeq ($(OPENGL_SUPPORT), 1)
OPTS.SDL += -DDISPLAY_OPENGL -DTEXTURES_ARE_LOST
OBJS.SDL += FrameBufferGL.o
LIBS.SDL += -lopengl32
endif
endif endif
@ -154,9 +191,8 @@ default:
@echo "" @echo ""
@echo "<version> is one of:" @echo "<version> is one of:"
@echo "" @echo ""
@echo " dos DOS version using DJGPP" @echo " dos DOS version using DJGPP"
@echo " linux-sdl Linux SDL version" @echo " sdl SDL version (edit makefile for version)"
@echo " win32-sdl Windows SDL version"
@echo "" @echo ""
@echo "Hopefully new versions will be added soon!" @echo "Hopefully new versions will be added soon!"
@echo "" @echo ""
@ -166,36 +202,19 @@ dos:
LD="gxx" \ LD="gxx" \
CXX="gcc" \ CXX="gcc" \
INCLUDES="$(INCLUDES) -I$(UI)/dos -I$(UI)/sound" \ INCLUDES="$(INCLUDES) -I$(UI)/dos -I$(UI)/sound" \
OPTIONS="-DBSPF_DOS=1" \ OPTIONS="-DBSPF_DOS" \
OPTIONS+="$(OPTS.DOS)" \ OPTIONS+="$(OPTS.DOS)" \
LDFLAGS="" \ LDFLAGS="" \
LDLIBS="" \ LDLIBS="" \
OBJS="mainDOS.o PCJoys.o SndDOS.o dos_sb.o vga.o" OBJS="mainDOS.o PCJoys.o SndDOS.o dos_sb.o vga.o"
linux-sdl: sdl:
make stella.sdl \ make stella.sdl \
INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/sound" \ INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/sound" \
SYS_INCLUDES="" \ OPTIONS="$(OPTS.SDL)" \
OPTIONS="-DBSPF_UNIX=1 -DUNIX=1" \ LDFLAGS="$(CFLAGS.SDL)" \
OPTIONS+="$(OPTS.SDL)" \ LDLIBS="$(LIBS.SDL)" \
LDFLAGS="-L/usr/X11R6/lib" \ OBJS="mainSDL.o FrameBufferSDL.o FrameBufferSoft.o" \
LDFLAGS+="$(CFLAGS.SDL)" \
LDLIBS="-lX11 -lXext" \
LDLIBS+="$(LIBS.SDL)" \
OBJS="mainSDL.o SettingsUNIX.o FrameBufferSDL.o FrameBufferSoft.o" \
OBJS+="$(OBJS.SDL)"
win32-sdl:
make stella.sdl \
INCLUDES="$(INCLUDES) -I$(UI)/sdl -I$(UI)/sound" \
SYS_INCLUDES="" \
OPTIONS="-DBSPF_UNIX=1 -DWIN32" \
OPTIONS+="$(OPTS.SDL)" \
LDFLAGS="" \
LDFLAGS+="$(CFLAGS.SDL)" \
LDLIBS="" \
LDLIBS+="$(LIBS.SDL)" \
OBJS="mainSDL.o SettingsWin32.o FrameBufferSDL.o FrameBufferSoft.o" \
OBJS+="$(OBJS.SDL)" OBJS+="$(OBJS.SDL)"

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: Settings.cxx,v 1.15 2003-12-04 19:18:45 stephena Exp $ // $Id: Settings.cxx,v 1.16 2003-12-05 19:51:09 stephena Exp $
//============================================================================ //============================================================================
#include <cassert> #include <cassert>
@ -50,8 +50,8 @@ Settings::Settings()
set("palette", "standard"); set("palette", "standard");
#ifdef SNAPSHOT_SUPPORT #ifdef SNAPSHOT_SUPPORT
set("ssdir", ""); set("ssdir", ".");
set("ssname", ""); set("ssname", "romname");
set("sssingle", "false"); set("sssingle", "false");
#endif #endif
#ifdef DEVELOPER_SUPPORT #ifdef DEVELOPER_SUPPORT

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: SettingsUNIX.cxx,v 1.5 2003-11-18 15:04:17 stephena Exp $ // $Id: SettingsUNIX.cxx,v 1.6 2003-12-05 19:51:09 stephena Exp $
//============================================================================ //============================================================================
#include <cstdlib> #include <cstdlib>
@ -73,11 +73,6 @@ SettingsUNIX::SettingsUNIX()
set("hidecursor", "false"); set("hidecursor", "false");
set("volume", "-1"); set("volume", "-1");
set("accurate", "true"); set("accurate", "true");
#ifdef SNAPSHOT_SUPPORT
set("ssname", "romname");
set("ssdir", "./");
set("ssingle", "false");
#endif
set("joyleft", "0"); set("joyleft", "0");
set("joyright", "1"); set("joyright", "1");
} }

View File

@ -13,7 +13,7 @@
// See the file "license" for information on usage and redistribution of // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// $Id: mainSDL.cxx,v 1.64 2003-12-04 22:22:53 stephena Exp $ // $Id: mainSDL.cxx,v 1.65 2003-12-05 19:51:09 stephena Exp $
//============================================================================ //============================================================================
#include <fstream> #include <fstream>
@ -43,6 +43,9 @@
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
#include "FrameBufferGL.hxx" #include "FrameBufferGL.hxx"
// Indicates whether to use OpenGL mode
static bool theUseOpenGLFlag;
#endif #endif
#ifdef SOUND_ALSA #ifdef SOUND_ALSA
@ -57,11 +60,9 @@
#include "SoundSDL.hxx" #include "SoundSDL.hxx"
#endif #endif
#ifdef UNIX #if defined(UNIX)
#include "SettingsUNIX.hxx" #include "SettingsUNIX.hxx"
#endif #elif defined(WIN32)
#ifdef WIN32
#include "SettingsWin32.hxx" #include "SettingsWin32.hxx"
#endif #endif
@ -343,7 +344,7 @@ void handleEvents()
else if(key == SDLK_RETURN) else if(key == SDLK_RETURN)
theDisplay->toggleFullscreen(); theDisplay->toggleFullscreen();
#ifdef DISPLAY_OPENGL #ifdef DISPLAY_OPENGL
else if(key == SDLK_f) else if(key == SDLK_f && theUseOpenGLFlag)
((FrameBufferGL*)theDisplay)->toggleFilter(); ((FrameBufferGL*)theDisplay)->toggleFilter();
#endif #endif
#ifdef DEVELOPER_SUPPORT #ifdef DEVELOPER_SUPPORT
@ -666,10 +667,9 @@ void cleanup()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#ifdef UNIX #if defined(UNIX)
theSettings = new SettingsUNIX(); theSettings = new SettingsUNIX();
#endif #elif defined(WIN32)
#ifdef WIN32
theSettings = new SettingsWin32(); theSettings = new SettingsWin32();
#endif #endif
if(!theSettings) if(!theSettings)
@ -693,8 +693,11 @@ int main(int argc, char* argv[])
theShowInfoFlag = theSettings->getBool("showinfo"); theShowInfoFlag = theSettings->getBool("showinfo");
// Request that the SDL window be centered, if possible // Request that the SDL window be centered, if possible
// This will probably only work under Linux #if defined(UNIX)
setenv("SDL_VIDEO_CENTERED", "1", 1);
#else
putenv("SDL_VIDEO_CENTERED"); putenv("SDL_VIDEO_CENTERED");
#endif
// Get a pointer to the file which contains the cartridge ROM // Get a pointer to the file which contains the cartridge ROM
const char* file = argv[argc - 1]; const char* file = argv[argc - 1];
@ -734,6 +737,7 @@ int main(int argc, char* argv[])
else if(videodriver == "gl") else if(videodriver == "gl")
{ {
theDisplay = new FrameBufferGL(); theDisplay = new FrameBufferGL();
theUseOpenGLFlag = true;
if(theShowInfoFlag) if(theShowInfoFlag)
cout << "Using OpenGL mode for video.\n"; cout << "Using OpenGL mode for video.\n";
} }