diff --git a/sc2/clean.sh b/sc2/clean.sh new file mode 100755 index 000000000..97b2080c1 --- /dev/null +++ b/sc2/clean.sh @@ -0,0 +1,15 @@ +#!/bin/sh +find . -name "*.o" -print0 | xargs -0 rm -f +find . -name "*.a" -print0 | xargs -0 rm -f +find . -name "*.lo" -print0 | xargs -0 rm -f +find . -name "*.la" -print0 | xargs -0 rm -f +find . -name .libs -print0 | xargs -0 rm -rf +find . -name .deps -print0 | xargs -0 rm -rf +find . -name Makefile -print0 | xargs -0 rm -rf +find . -name Makefile.in -print0 | xargs -0 rm -rf +rm -f aclocal.m4 config.guess config.h config.h.in config.log config.status \ + config.sub configure \ + install-sh libtool ltmain.sh missing mkinstalldirs \ + stamp-h stamp-h.in src/sc2 +rm -rf libltdl +rm -rf autom4te.cache diff --git a/sc2/configure.ac b/sc2/configure.ac index 283a8aa5c..b155f77bd 100644 --- a/sc2/configure.ac +++ b/sc2/configure.ac @@ -27,8 +27,8 @@ AM_MAINTAINER_MODE # Configurables -CFLAGS="$CFLAGS -g" -CPPFLAGS="$CPPFLAGS -g" +CFLAGS="$CFLAGS -g -O2 -DGFXMODULE_SDL_PURE" +CPPFLAGS="$CPPFLAGS -g -O2 -DGFXMODULE_SDL_PURE" # These defines seem to be missing, and they are added here as a workaround. @@ -82,45 +82,46 @@ AC_CHECK_HEADERS(SDL/SDL_image.h, , AC_MSG_ERROR(Your system is missing SDL_imag AC_CHECK_HEADERS(SDL/SDL_mixer.h, , AC_MSG_ERROR(Your system is missing SDL_mixer.h!)) # Select platform dependent OpenGL libs.. (tweak your patform here) -case "$target" in - *-*-linux-gnu*) - SYS_GL_LIBS="-lGL" - ;; - *-*-cygwin* | *-*-mingw32*) - SYS_GL_LIBS="-lopengl32" - SYS_GL_CFLAGS="-DGL_VERSION_1_2" - ;; - *-*-beos*) - SYS_GL_LIBS="-lGL" - ;; - *-*-darwin*) - SYS_GL_LIBS="" - ;; - *) - if test x$have_x = xyes; then - CFLAGS="$CFLAGS $X_CFLAGS" - SYS_GL_LIBS="$X_LIBS -lGL" - else - SYS_GL_LIBS="-lGL" - fi - ;; -esac +#case "$target" in +# *-*-linux-gnu*) +# SYS_GL_LIBS="-lGL" +# ;; +# *-*-cygwin* | *-*-mingw32*) +# SYS_GL_LIBS="-lopengl32" +# SYS_GL_CFLAGS="-DGL_VERSION_1_2" +# ;; +# *-*-beos*) +# SYS_GL_LIBS="-lGL" +# ;; +# *-*-darwin*) +# SYS_GL_LIBS="" +# ;; +# *) +# if test x$have_x = xyes; then +# CFLAGS="$CFLAGS $X_CFLAGS" +# SYS_GL_LIBS="$X_LIBS -lGL" +# else +# SYS_GL_LIBS="-lGL" +# fi +# ;; +#esac # Check for OpenGL -AC_MSG_CHECKING(for OpenGL support) -have_opengl=no -AC_TRY_COMPILE([ +#AC_MSG_CHECKING(for OpenGL support) +#have_opengl=no +#AC_TRY_COMPILE([ #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif -],[ -],[ -have_opengl=yes -]) -AC_MSG_RESULT($have_opengl) -GL_LIBS=$SYS_GL_LIBS +#],[ +#],[ +#have_opengl=yes +#]) +#AC_MSG_RESULT($have_opengl) +#GL_LIBS=$SYS_GL_LIBS +GL_LIBS= AC_SUBST(GL_LIBS) # Figure out which math library to use @@ -193,8 +194,13 @@ AC_CONFIG_FILES([ src/sc2code/libs/resource/Makefile src/sc2code/libs/math/Makefile src/sc2code/libs/input/Makefile + src/sc2code/libs/input/sdl/Makefile src/sc2code/libs/sound/Makefile + src/sc2code/libs/sound/sdl/Makefile src/sc2code/libs/graphics/Makefile + src/sc2code/libs/graphics/sdl/Makefile + src/sc2code/libs/graphics/sdl/opengl/Makefile + src/sc2code/libs/graphics/sdl/pure/Makefile src/sc2code/libs/video/Makefile src/sc2code/planets/Makefile src/sc2code/ships/Makefile diff --git a/sc2/content/defgrp.dat b/sc2/content/defgrp.dat index 39874f8b6..00cb5c048 100644 Binary files a/sc2/content/defgrp.dat and b/sc2/content/defgrp.dat differ diff --git a/sc2/content/randgrp.dat b/sc2/content/randgrp.dat index 77d5d9693..d52344b86 100644 Binary files a/sc2/content/randgrp.dat and b/sc2/content/randgrp.dat differ diff --git a/sc2/src/Makefile.am b/sc2/src/Makefile.am index 06a1c94bb..e074f0bd1 100644 --- a/sc2/src/Makefile.am +++ b/sc2/src/Makefile.am @@ -14,7 +14,7 @@ INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \ bin_PROGRAMS = sc2 -sc2_SOURCES = SDL_wrapper.c port.c starcon2.c trackplayer.c +sc2_SOURCES = port.c starcon2.c sc2_LDADD = sc2code/libsc2.la @SDL_LIBS@ @GL_LIBS@ @SMPEG_LIBS@ -noinst_HEADERS = SDL_wrapper.h +noinst_HEADERS = port.h diff --git a/sc2/src/msvc++/Starcon2.dsp b/sc2/src/msvc++/Starcon2.dsp index e41989cf0..a9cfa611c 100644 --- a/sc2/src/msvc++/Starcon2.dsp +++ b/sc2/src/msvc++/Starcon2.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D SAFE_X=0 /D SAFE_Y=0 /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D SAFE_X=0 /D SAFE_Y=0 /D "GFXMODULE_SDL_PURE" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=snBsc.exe @@ -50,7 +50,7 @@ BSC32=snBsc.exe # ADD BSC32 /nologo LINK32=snLink.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib smpeg.lib opengl32.lib glu32.lib /nodefaultlib:"msvcrtd.lib" /nologo /subsystem:console /machine:I386 /out:"../../Content/Starcon2.exe" +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib smpeg.lib /nodefaultlib:"msvcrtd.lib" /nologo /subsystem:console /machine:I386 /out:"../../Content/Starcon2.exe" !ELSEIF "$(CFG)" == "Starcon2 - Win32 Debug" @@ -66,7 +66,7 @@ LINK32=snLink.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D SAFE_X=0 /D SAFE_Y=0 /FR /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I ".." /I "..\sc2code" /I "..\sc2code\libs" /I "..\sc2code\ships" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D _VW=320 /D _VH=240 /D SAFE_X=0 /D SAFE_Y=0 /D "GFXMODULE_SDL_PURE" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=snBsc.exe @@ -74,7 +74,7 @@ BSC32=snBsc.exe # ADD BSC32 /nologo /o"Starcon2.bsc" LINK32=snLink.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib smpeg.lib opengl32.lib glu32.lib /nodefaultlib:"msvcrt.lib" /nologo /subsystem:console /debug /machine:I386 /out:"../../Content/Starcon2Debug.exe" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib smpeg.lib /nodefaultlib:"msvcrt.lib" /nologo /subsystem:console /debug /machine:I386 /out:"../../Content/Starcon2Debug.exe" /pdbtype:sept # SUBTRACT LINK32 /nodefaultlib !ENDIF @@ -85,8 +85,20 @@ LINK32=snLink.exe # Name "Starcon2 - Win32 Debug" # Begin Group "Source Files" -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Group "3DO Code" +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\starcon2.c +# End Source File +# Begin Source File + +SOURCE=..\port.c +# End Source File +# Begin Source File + +SOURCE=..\port.h +# End Source File +# Begin Group "sc2code" # PROP Default_Filter "" # Begin Group "libs" @@ -161,10 +173,6 @@ SOURCE=..\sc2code\libs\graphics\frame.c # End Source File # Begin Source File -SOURCE=..\sc2code\libs\graphics\getbody.c -# End Source File -# Begin Source File - SOURCE=..\sc2code\libs\graphics\gfxintrn.h # End Source File # Begin Source File @@ -207,6 +215,60 @@ SOURCE=..\sc2code\libs\graphics\resgfx.c SOURCE=..\sc2code\libs\graphics\stamp.c # End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\gfx_common.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\gfx_common.h +# End Source File +# Begin Group "sdl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\sdl_common.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\sdl_common.h +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\rotozoom.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\rotozoom.h +# End Source File +# Begin Group "opengl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\opengl\opengl.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\opengl\opengl.h +# End Source File +# End Group + +# Begin Group "pure" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\pure\pure.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\graphics\sdl\pure\pure.h +# End Source File +# End Group + +# End Group # End Group # Begin Group "input" @@ -217,8 +279,21 @@ SOURCE=..\sc2code\libs\input\inpintrn.h # End Source File # Begin Source File -SOURCE=..\sc2code\libs\input\input.c +SOURCE=..\sc2code\libs\input\input_common.c # End Source File +# Begin Group "sdl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\input\sdl\input.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\input\sdl\input.h +# End Source File +# End Group + # End Group # Begin Group "math" @@ -297,11 +372,7 @@ SOURCE=..\sc2code\libs\sound\fileinst.c # End Source File # Begin Source File -SOURCE=..\sc2code\libs\sound\modfuncs.c -# End Source File -# Begin Source File - -SOURCE=..\sc2code\libs\sound\play.c +SOURCE=..\sc2code\libs\sound\play.h # End Source File # Begin Source File @@ -315,6 +386,35 @@ SOURCE=..\sc2code\libs\sound\resinst.c SOURCE=..\sc2code\libs\sound\sndintrn.h # End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\sound\trackplayer.h +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\sound\sound_common.c +# End Source File +# Begin Group "sdl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\sc2code\libs\sound\sdl\modfuncs.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\sound\sdl\play.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\sound\sdl\sound.c +# End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\sound\sdl\trackplayer.c +# End Source File + +# End Group # End Group # Begin Group "strings" @@ -400,6 +500,11 @@ SOURCE=..\sc2code\libs\vargs.h SOURCE=..\sc2code\libs\vidlib.h # End Source File +# Begin Source File + +SOURCE=..\sc2code\libs\misc.h +# End Source File + # End Group # Begin Group "comm" @@ -2882,38 +2987,6 @@ SOURCE=..\sc2code\weapon.c SOURCE=..\sc2code\weapon.h # End Source File # End Group -# Begin Group "NeoStarcon2 Wrappers" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\SDL_wrapper.c -# End Source File -# Begin Source File - -SOURCE=..\SDL_wrapper.h -# End Source File -# Begin Source File - -SOURCE=..\starcon2.c -# End Source File -# Begin Source File - -SOURCE=..\trackplayer.c -# End Source File -# Begin Source File - -SOURCE=..\port.c -# End Source File -# Begin Source File - -SOURCE=..\port.h -# End Source File -# Begin Source File - -SOURCE=..\gl.h -# End Source File -# End Group # End Group # End Target # End Project diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index 95d7c1ee4..c27d4c8b2 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //#include "starcon.h" QUEUE disp_q; diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index a501706e8..0cd545554 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -17,16 +17,17 @@ */ #include -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" +#include "libs/sound/trackplayer.h" #include "starcon.h" #include "commglue.h" -void InitOscilloscope (Sint32 x, Sint32 y, Sint32 width, Sint32 height, +void InitOscilloscope (int x, int y, int width, int height, void *f); void SetSliderImage (void *f); -void InitSlider (Sint32 x, Sint32 y, Sint32 width, Sint32 height, - Sint32 bwidth, Sint32 bheight, void *f); -void Oscilloscope (Sint32 grab_data); +void InitSlider (int x, int y, int width, int height, + int bwidth, int bheight, void *f); +void Oscilloscope (int grab_data); void Slider (void); diff --git a/sc2/src/sc2code/commglue.c b/sc2/src/sc2code/commglue.c index 1498a86cf..5c69e237f 100644 --- a/sc2/src/sc2code/commglue.c +++ b/sc2/src/sc2code/commglue.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "commglue.h" -#include "SDL_wrapper.h" +#include "libs/sound/trackplayer.h" void NPCPhrase (int index) diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index d83689544..559f3222b 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "commglue.h" -#include "SDL_wrapper.h" +#include "libs/sound/trackplayer.h" //Added by Chris diff --git a/sc2/src/sc2code/credits.c b/sc2/src/sc2code/credits.c index 751eb1670..03918dc71 100644 --- a/sc2/src/sc2code/credits.c +++ b/sc2/src/sc2code/credits.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/fmv.c b/sc2/src/sc2code/fmv.c index 627d93af7..d9739bf80 100644 --- a/sc2/src/sc2code/fmv.c +++ b/sc2/src/sc2code/fmv.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "vidlib.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 6b0c942e8..1f980fca4 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -19,7 +19,7 @@ #include #include "starcon.h" #include "commglue.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/libs/Makefile.am b/sc2/src/sc2code/libs/Makefile.am index 95e011850..b9cc7fa1d 100644 --- a/sc2/src/sc2code/libs/Makefile.am +++ b/sc2/src/sc2code/libs/Makefile.am @@ -7,7 +7,8 @@ SUBDIRS = decomp graphics input math memory resource sound strings video noinst_HEADERS = \ compiler.h declib.h errlib.h gfxlib.h inplib.h mathlib.h \ - memlib.h reslib.h sndlib.h strlib.h timlib.h vargs.h vidlib.h + memlib.h reslib.h sndlib.h strlib.h timlib.h vargs.h vidlib.h \ + misc.h INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \ -I$(top_srcdir)/src \ diff --git a/sc2/src/sc2code/libs/graphics/Makefile.am b/sc2/src/sc2code/libs/graphics/Makefile.am index 0e2127928..786ef6dcc 100644 --- a/sc2/src/sc2code/libs/graphics/Makefile.am +++ b/sc2/src/sc2code/libs/graphics/Makefile.am @@ -3,6 +3,8 @@ # Written by Mudry , protected by GNU GPL. # CVS $ Id: $ +SUBDIRS = sdl + CFLAGS = -Wall INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \ @@ -14,9 +16,11 @@ noinst_LTLIBRARIES = libgraphics.la libgraphics_la_SOURCES = clipline.c context.c drawable.c filegfx.c font.c \ frame.c intersec.c line.c loaddisp.c makepoly.c map.c \ - pixmap.c poly.c rect.c resgfx.c stamp.c boxint.c getbody.c + pixmap.c poly.c rect.c resgfx.c stamp.c boxint.c gfx_common.c + +libgraphics_la_LIBADD = sdl/libsdl.la #libgraphics_la_LDFLAGS = @SMPEG_LIBS@ -noinst_HEADERS = context.h display.h drawable.h font.h gfxintrn.h +noinst_HEADERS = context.h display.h drawable.h font.h gfxintrn.h gfx_common.h diff --git a/sc2/src/sc2code/libs/graphics/drawable.c b/sc2/src/sc2code/libs/graphics/drawable.c index 987adf27b..e871df76c 100644 --- a/sc2/src/sc2code/libs/graphics/drawable.c +++ b/sc2/src/sc2code/libs/graphics/drawable.c @@ -17,7 +17,6 @@ */ #include "gfxintrn.h" -#include "SDL_wrapper.h" FRAMEPTR _CurFramePtr; @@ -58,66 +57,6 @@ SetContextBGFrame (FRAME Frame) return (LastFrame); } -DRAWABLE -_request_drawable (COUNT NumFrames, DRAWABLE_TYPE DrawableType, - CREATE_FLAGS flags, SIZE width, SIZE height) -{ - DRAWABLE Drawable; - - Drawable = AllocDrawableImage ( - NumFrames, DrawableType, flags, width, height - ); - if (Drawable) - { - DRAWABLEPTR DrawablePtr; - - if ((DrawablePtr = LockDrawable (Drawable)) == 0) - { - FreeDrawable (Drawable); - Drawable = 0; - } - else - { - int imgw, imgh; - FRAMEPTR FramePtr; - - DrawablePtr->hDrawable = GetDrawableHandle (Drawable); - TYPE_SET (DrawablePtr->FlagsAndIndex, flags << FTYPE_SHIFT); - INDEX_SET (DrawablePtr->FlagsAndIndex, NumFrames - 1); - - imgw = (flags & MAPPED_TO_DISPLAY) ? width * ScreenWidthActual / ScreenWidth : width; - imgh = (flags & MAPPED_TO_DISPLAY) ? height * ScreenHeightActual / ScreenHeight : height; - FramePtr = &DrawablePtr->Frame[NumFrames - 1]; - while (NumFrames--) - { - TFB_Image *Image; - - - if (DrawableType == RAM_DRAWABLE - && (Image = TFB_LoadImage (SDL_CreateRGBSurface ( - SDL_HWSURFACE, - imgw, - imgh, - 24, - 0x00FF0000, - 0x0000FF00, - 0x000000FF, - 0x00000000 - )))) - FramePtr->DataOffs = (BYTE *)Image - (BYTE *)FramePtr; - - TYPE_SET (FramePtr->TypeIndexAndFlags, DrawableType); - INDEX_SET (FramePtr->TypeIndexAndFlags, NumFrames); - SetFrameBounds (FramePtr, width, height); - --FramePtr; - } - UnlockDrawable (Drawable); - } - } - - return (Drawable); -} - DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, PSIZE pwidth, PSIZE pheight) { diff --git a/sc2/src/sc2code/libs/input/Makefile.am b/sc2/src/sc2code/libs/input/Makefile.am index b799d6b6a..570018dff 100644 --- a/sc2/src/sc2code/libs/input/Makefile.am +++ b/sc2/src/sc2code/libs/input/Makefile.am @@ -3,12 +3,15 @@ # Written by Mudry , protected by GNU GPL. # CVS $ Id: $ +SUBDIRS = sdl + INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/sc2code \ -I$(top_srcdir)/src/sc2code/libs noinst_LTLIBRARIES = libinput.la -libinput_la_SOURCES = input.c +libinput_la_SOURCES = input_common.c +libinput_la_LIBADD = sdl/libsdlinput.la noinst_HEADERS = inpintrn.h diff --git a/sc2/src/sc2code/libs/resource/getres.c b/sc2/src/sc2code/libs/resource/getres.c index f446d4266..f0e97dddd 100644 --- a/sc2/src/sc2code/libs/resource/getres.c +++ b/sc2/src/sc2code/libs/resource/getres.c @@ -17,7 +17,7 @@ */ #include "resintrn.h" -#include "SDL_wrapper.h" +#include "port.h" char *_cur_resfile_name; diff --git a/sc2/src/sc2code/libs/sound/Makefile.am b/sc2/src/sc2code/libs/sound/Makefile.am index becdefb1c..37dbe69c7 100644 --- a/sc2/src/sc2code/libs/sound/Makefile.am +++ b/sc2/src/sc2code/libs/sound/Makefile.am @@ -3,11 +3,15 @@ # Written by Mudry , protected by GNU GPL. # CVS $ Id: $ +SUBDIRS = sdl + INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/sc2code \ -I$(top_srcdir)/src/sc2code/libs noinst_LTLIBRARIES = libsound.la -libsound_la_SOURCES = fileinst.c play.c resinst.c modfuncs.c -noinst_HEADERS = play.h redbook.h sndintrn.h +libsound_la_SOURCES = fileinst.c resinst.c sound_common.c +libsound_la_LIBADD = sdl/libsdlsound.la +noinst_HEADERS = play.h redbook.h sndintrn.h trackplayer.h + diff --git a/sc2/src/sc2code/libs/sound/play.h b/sc2/src/sc2code/libs/sound/play.h index 024e5d078..0308f524f 100644 --- a/sc2/src/sc2code/libs/sound/play.h +++ b/sc2/src/sc2code/libs/sound/play.h @@ -1,3 +1,21 @@ +//Copyright Paul Reiche, Fred Ford. 1992-2002 + +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #ifndef _PLAY_H #define _PLAY_H diff --git a/sc2/src/sc2code/libs/strings/getstr.c b/sc2/src/sc2code/libs/strings/getstr.c index 5808bedae..27b04b64b 100644 --- a/sc2/src/sc2code/libs/strings/getstr.c +++ b/sc2/src/sc2code/libs/strings/getstr.c @@ -17,7 +17,7 @@ */ #include "strintrn.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" #ifdef WIN32 #include #endif diff --git a/sc2/src/sc2code/oscill.c b/sc2/src/sc2code/oscill.c index c4ddc9fba..48ace3cc3 100644 --- a/sc2/src/sc2code/oscill.c +++ b/sc2/src/sc2code/oscill.c @@ -23,20 +23,19 @@ //#include "filefunctions.h" //#include "BlockFile.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris +//Modified by Mika (removed use of SDL datatypes) -#include "SDL/SDL.h" - -typedef Uint8 uint8; -typedef Uint8 uchar; -typedef Sint8 sint8; -typedef Uint16 uint16; -typedef Sint16 sint16; -typedef Uint32 uint32; -typedef Sint32 int32; -typedef Sint32 sint32; +typedef unsigned char uint8; +typedef unsigned char uchar; +typedef signed char sint8; +typedef unsigned short uint16; +typedef signed short sint16; +typedef unsigned int uint32; +typedef signed int int32; +typedef signed int sint32; //End Added by Chris diff --git a/sc2/src/sc2code/outfit.c b/sc2/src/sc2code/outfit.c index f98d2db8b..b454e52d8 100644 --- a/sc2/src/sc2code/outfit.c +++ b/sc2/src/sc2code/outfit.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/planets/lander.c b/sc2/src/sc2code/planets/lander.c index 5ea9241d7..8e2008db7 100644 --- a/sc2/src/sc2code/planets/lander.c +++ b/sc2/src/sc2code/planets/lander.c @@ -19,7 +19,7 @@ #include "starcon.h" #include "lander.h" #include "lifeform.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/planets/pl_stuff.c b/sc2/src/sc2code/planets/pl_stuff.c index 59978cef8..1d5c7323b 100644 --- a/sc2/src/sc2code/planets/pl_stuff.c +++ b/sc2/src/sc2code/planets/pl_stuff.c @@ -23,8 +23,7 @@ //#include "filefunctions.h" //#include "BlockFile.h" #include "starcon.h" -#include "SDL.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris @@ -55,7 +54,7 @@ #define NUM_TINTS 4 -#define PIXC_DUP(v) (((Uint32)(v) << PPMP_0_SHIFT) | ((Uint32)(v) << PPMP_1_SHIFT)) +#define PIXC_DUP(v) (((unsigned int)(v) << PPMP_0_SHIFT) | ((unsigned int)(v) << PPMP_1_SHIFT)) #define PIXC_UNCODED16 (PIXC_DUP (PPMPC_MF_8 | PPMPC_SF_8)) #define PIXC_UNCODED8 (PIXC_DUP (PPMPC_MF_8 | PPMPC_SF_8)) #define PIXC_CODED (PIXC_DUP (PPMPC_MS_PIN | PPMPC_SF_8)) @@ -89,9 +88,9 @@ typedef struct { - Sint32 x0[15], x1[15], y0[15], y1[15]; - Sint32 ystep[15]; - Sint32 src_ws[XBANDS]; + int x0[15], x1[15], y0[15], y1[15]; + int ystep[15]; + int src_ws[XBANDS]; CCB planet_ccb, surface_ccb, tint_ccb[NUM_TINTS]; @@ -99,13 +98,13 @@ typedef struct CCB repair_ccb[2]; - Sint32 black_circ_plut[16]; + int black_circ_plut[16]; UBYTE rmap[HEIGHT][LINE_PIXELS]; CCB *cur_ccb; - Sint32 old_sx, old_sy; + int old_sx, old_sy; CCB plCCB[NUM_CELS]; @@ -113,7 +112,7 @@ typedef struct UBYTE zoom_batch; #ifdef SCALE_ROTATE - Sint32 scale; + int scale; #endif CCB *pcirc_ccb, *pblur_ccb; @@ -178,11 +177,11 @@ static PLANET_STUFF *planet_stuff; #define SCALE_CEL(ccb,cx,cy) \ do \ { \ - Sint32 s, _dx, _dy; \ + int s, _dx, _dy; \ \ s = scale & SCALE_AMT_MASK; \ - _dx = (Sint32)((scale & SCALE_X_MASK) >> SCALE_X_SHIFT) - 1; \ - _dy = (Sint32)((scale & SCALE_Y_MASK) >> SCALE_Y_SHIFT) - 1; \ + _dx = (int)((scale & SCALE_X_MASK) >> SCALE_X_SHIFT) - 1; \ + _dy = (int)((scale & SCALE_Y_MASK) >> SCALE_Y_SHIFT) - 1; \ (ccb)->ccb_XPos = (((ccb)->ccb_XPos - (cx)) * s) >> SCALE_AMT_SHIFT; \ (ccb)->ccb_YPos = (((ccb)->ccb_YPos - (cy)) * s) >> SCALE_AMT_SHIFT; \ if (_dx < 0) \ @@ -213,7 +212,7 @@ static PLANET_STUFF *planet_stuff; static void build_steps () { - Sint32 y, i, c, inc; + int y, i, c, inc; c = 1; inc = 1; @@ -249,9 +248,9 @@ for (i = 0; y < (HEIGHT >> 1); i++) } static void -build_tables (Sint32 da) +build_tables (int da) { - Sint32 y, i; + int y, i; build_steps (); @@ -259,7 +258,7 @@ build_tables (Sint32 da) for (y = 0, i = 0; y <= (HEIGHT >> 1); i++) { - Sint32 dx, dy, a, h; + int dx, dy, a, h; h = ystep[i]; @@ -300,14 +299,14 @@ printf ("%ld,%ld\n", x1[i] >> 16, y1[i] >> 16); } static void -draw_band (Sint32 src_x, Sint32 src_y, Sint32 dst_cx, Sint32 dst_cy) +draw_band (int src_x, int src_y, int dst_cx, int dst_cy) { //I_CANNOT_FIGURE_OUT_HOW_TO_FIX_THIS_FILE___STREAM???(); - Sint32 *sp; - Sint32 i; + int *sp; + int i; - sp = (Sint32 *)planet_ccb.ccb_SourcePtr + src_y * (LINE_PIXELS >> 1); + sp = (int *)planet_ccb.ccb_SourcePtr + src_y * (LINE_PIXELS >> 1); for (i = 0; i < XBANDS; i++) { @@ -330,9 +329,9 @@ draw_band (Sint32 src_x, Sint32 src_y, Sint32 dst_cx, Sint32 dst_cy) } static void -set_band_cels (Sint32 src_y, Sint32 src_h, Sint32 band) +set_band_cels (int src_y, int src_h, int band) { - Sint32 i, dst_x0, dst_y0, dst_x1, dst_y1, dx0, dy0, dx1, dy1; + int i, dst_x0, dst_y0, dst_x1, dst_y1, dx0, dy0, dx1, dy1; if (src_y > (HEIGHT >> 1)) { @@ -376,7 +375,7 @@ set_band_cels (Sint32 src_y, Sint32 src_h, Sint32 band) #define dd d[i] #define src_w src_ws[i] POINT quadpts[4]; - Sint32 d[XBANDS] = { 17, 47, 64, 64, 47, 17 }; + int d[XBANDS] = { 17, 47, 64, 64, 47, 17 }; quadpts[0].x = dst_x0; quadpts[0].y = dst_y0; @@ -413,7 +412,7 @@ set_band_cels (Sint32 src_y, Sint32 src_h, Sint32 band) static void init_rotate_cels () { - Sint32 i, incr, y; + int i, incr, y; incr = 1; cur_ccb = plCCB; @@ -438,10 +437,10 @@ printf ("using %d cels for rotate\n", cur_ccb - plCCB); #endif void -SetPlanetTilt (Sint32 da) +SetPlanetTilt (int da) { #if 0 - Sint32 w, i; + int w, i; shield_pulse = MAX_PULSE_RED; for (i = 0, cur_ccb = plCCB; i < NUM_ROTATE_CELS; i++, cur_ccb++) @@ -452,7 +451,7 @@ SetPlanetTilt (Sint32 da) if (!src_ws[0]) { - Sint32 err; + int err; w = (WIDTH / 2) / XBANDS; err = XBANDS; @@ -487,13 +486,13 @@ SetPlanetTilt (Sint32 da) } int -RotatePlanet (Sint32 x, Sint32 dx, Sint32 dy) +RotatePlanet (int x, int dx, int dy) { #if 1 return (0); #else - Sint32 i, y; - Sint32 incr; + int i, y; + int incr; CCB *first; dx <<= 16; @@ -661,7 +660,7 @@ while (AnyButtonPress (FALSE)); } void -DrawPlanet (Sint32 x, Sint32 y, Sint32 dy, Uint32 rgb) +DrawPlanet (int x, int y, int dy, unsigned int rgb) { #if 1 STAMP s; @@ -673,7 +672,7 @@ DrawPlanet (Sint32 x, Sint32 y, Sint32 dy, Uint32 rgb) #else if (rgb || !pshield_ccb->ccb_HDY) { - Sint32 i, nt, my; + int i, nt, my; if (!pshield_ccb->ccb_HDY) { @@ -723,7 +722,7 @@ DrawPlanet (Sint32 x, Sint32 y, Sint32 dy, Uint32 rgb) else tint_ccb[i].ccb_YPos = my << 16; tint_ccb[i].ccb_XPos = x << 16; - *((Uint32 *)tint_ccb[i].ccb_SourcePtr) = rgb | (rgb << 16) | 0x80008000; + *((unsigned int *)tint_ccb[i].ccb_SourcePtr) = rgb | (rgb << 16) | 0x80008000; add_cel (&tint_ccb[i]); } } diff --git a/sc2/src/sc2code/planets/planets.c b/sc2/src/sc2code/planets/planets.c index 8c124349e..a088a2793 100644 --- a/sc2/src/sc2code/planets/planets.c +++ b/sc2/src/sc2code/planets/planets.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "scan.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 746870487..b5dc7cfab 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -17,18 +17,17 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" extern void DeltaTopography (COUNT num_iterations, PSBYTE DepthArray, PRECT pRect, SIZE depth_delta); void SetPlanetMusic (BYTE planet_type); -void SetPlanetTilt (Sint32 da); +void SetPlanetTilt (int da); void RepairBackRect (PRECT pRect); -int RotatePlanet (Sint32 x, Sint32 dx, Sint32 dy); +int RotatePlanet (int x, int dx, int dy); #define NUM_BATCH_POINTS 64 diff --git a/sc2/src/sc2code/planets/planmap.c b/sc2/src/sc2code/planets/planmap.c index 317ae780d..7b1c46792 100644 --- a/sc2/src/sc2code/planets/planmap.c +++ b/sc2/src/sc2code/planets/planmap.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include "gfxlib.h" #include "scan.h" #include "libs/compiler.h" diff --git a/sc2/src/sc2code/planets/pstarmap.c b/sc2/src/sc2code/planets/pstarmap.c index 1a2d982c7..f2d1b6d87 100644 --- a/sc2/src/sc2code/planets/pstarmap.c +++ b/sc2/src/sc2code/planets/pstarmap.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index a793cba00..577ec10eb 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "lifeform.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/planets/solarsys.c b/sc2/src/sc2code/planets/solarsys.c index 6e6a1fc11..59c7c11a1 100644 --- a/sc2/src/sc2code/planets/solarsys.c +++ b/sc2/src/sc2code/planets/solarsys.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/process.c b/sc2/src/sc2code/process.c index 9d0b19161..8ff3fce4f 100644 --- a/sc2/src/sc2code/process.c +++ b/sc2/src/sc2code/process.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" COUNT DisplayFreeList; PRIMITIVE DisplayArray[MAX_DISPLAY_PRIMS]; diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index f9338e893..950179545 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "melee.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" //Added by Chris diff --git a/sc2/src/sc2code/sis.c b/sc2/src/sc2code/sis.c index 4216d66b8..7463b68dd 100644 --- a/sc2/src/sc2code/sis.c +++ b/sc2/src/sc2code/sis.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "commglue.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" void RepairSISBorder (void) diff --git a/sc2/src/sc2code/starbase.c b/sc2/src/sc2code/starbase.c index 4463c42c0..c05ca3e5a 100644 --- a/sc2/src/sc2code/starbase.c +++ b/sc2/src/sc2code/starbase.c @@ -17,7 +17,7 @@ */ #include "starcon.h" -#include "SDL_wrapper.h" +#include "libs/graphics/gfx_common.h" PMENU_STATE pMenuState; diff --git a/sc2/src/sc2code/utils.c b/sc2/src/sc2code/utils.c index bc3a1ada9..3de92213a 100644 --- a/sc2/src/sc2code/utils.c +++ b/sc2/src/sc2code/utils.c @@ -18,7 +18,7 @@ #include "starcon.h" #include "commglue.h" -#include "SDL_wrapper.h" +#include "libs/sound/trackplayer.h" void DrawStarConBox (PRECT pRect, SIZE BorderWidth, COLOR TopLeftColor, COLOR diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 3860512ef..ab3c1fd7f 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -24,538 +24,17 @@ Copyright Toys for Bob, 2002 - starcon2.cpp programmer: Chris Nelson + Programmer: Chris Nelson *****************************************/ -#include "SDL_wrapper.h" - -//Global Variables for the wrapper. - -Uint8 KeyboardDown[512]; -#define KBDBUFSIZE (1 << 8) -static int kbdhead, kbdtail; -static Uint16 kbdbuf[KBDBUFSIZE]; - -UBYTE ControlA; -UBYTE ControlB; -UBYTE ControlC; -UBYTE ControlX; -UBYTE ControlStart; -UBYTE ControlLeftShift; -UBYTE ControlRightShift; - -int ScreenWidth; -int ScreenHeight; -int ScreenWidthActual; -int ScreenHeightActual; -int ScreenBPPActual; - -SDL_Surface *ExtraScreen; - -int TFB_DEBUG_HALT; - -Uint16 -GetUNICODEKey () -{ - if (kbdtail != kbdhead) - { - Uint16 ch; - - ch = kbdbuf[kbdhead]; - kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1); - return (ch); - } - - return (0); -} - -void -FlushInput () -{ - kbdtail = kbdhead = 0; -} - -void -ProcessKeyboardEvent(const SDL_Event *Event) -{ - if(Event->key.keysym.sym == SDLK_TAB && Event->type == SDL_KEYDOWN) - { - SDL_GL_SwapBuffers(); //Debug: Hit tab to swap buffers - } - else if(Event->key.keysym.sym == SDLK_BACKQUOTE) - { - exit(0); - } - else//if(Event->type == SDL_KEYDOWN) - { - if (Event->type == SDL_KEYDOWN) - { - if ((kbdbuf[kbdtail] = Event->key.keysym.unicode) - || (kbdbuf[kbdtail] = Event->key.keysym.sym) <= 0x7F) - { - kbdtail = (kbdtail + 1) & (KBDBUFSIZE - 1); - if (kbdtail == kbdhead) - kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1); - } - KeyboardDown[Event->key.keysym.sym]=TRUE; - } - else - { - KeyboardDown[Event->key.keysym.sym]=FALSE; - } - } - - if (Event->key.keysym.sym == SDLK_BACKSPACE && Event->type == SDL_KEYDOWN) - { - //Stop + Start Starcon running. - - //TFB_DEBUG_HALT = !TFB_DEBUG_HALT; - } - - if (Event->type == SDL_KEYDOWN && TFB_DEBUG_HALT) - { - //Used for debugging Buffer copy operations - - if (Event->key.keysym.sym==SDLK_d) - { - //Draw - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - - // - - glDrawBuffer (GL_BACK_LEFT); - glLoadIdentity (); - glOrtho (0, ScreenWidth, ScreenHeight, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glDisable (GL_SCISSOR_TEST); - - glBegin (GL_QUADS); - { - glColor3f (rand() % 2, rand () % 2, rand () % 2); - glVertex2i (0, ScreenHeight); - //glColor3f (rand() % 2, rand() % 2, rand() % 2); - glVertex2i(0, 0); - //glColor3f (rand() % 2, rand () % 2, rand () % 2); - glVertex2i (ScreenWidth, 0); - glColor3f (rand() % 2, rand () % 2, rand () % 2); - glVertex2i(ScreenWidth, ScreenHeight); - } - glEnd(); - - // - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - } - if (Event->key.keysym.sym == SDLK_s) - { - SDL_GL_SwapBuffers(); - } - if (Event->key.keysym.sym == SDLK_c) - { - //Copy from front to back - glReadBuffer(GL_FRONT); - glDrawBuffer(GL_BACK); - - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - - glOrtho (0, ScreenWidthActual, ScreenHeightActual, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glRasterPos2d (0, ScreenHeightActual - .1); - //Re "-.1": All values 0 < x < .5 work. Strange!! - - glDisable (GL_SCISSOR_TEST); - glCopyPixels (0, 0, ScreenWidthActual, ScreenHeightActual, - GL_COLOR); - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - } - } -} - -void ProcessJoystickEvent (const SDL_Event* Event) -{ - SDL_Event PseudoEvent; - - return; - - if (Event->type == SDL_JOYAXISMOTION) - { - if (Event->jaxis.axis == 0) - { - //x-axis - - if (Event->jaxis.value <= -5) //Left - { - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = SDLK_LEFT; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_RIGHT; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jaxis.value >= 5) //Right - { - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_LEFT; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = SDLK_RIGHT; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jaxis.value > -5 && Event->jaxis.value < 5) - //Neither Left nor Right - { - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_LEFT; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_RIGHT; - ProcessKeyboardEvent (&PseudoEvent); - } - } - if (Event->jaxis.axis == 1) - { - //y-axis - - if (Event->jaxis.value <= -5) //Down - { - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = SDLK_DOWN; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_UP; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jaxis.value >= 5) //Up - { - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_DOWN; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = SDLK_UP; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jaxis.value >-5 && Event->jaxis.value < 5) - //Neither Down nor Up - { - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_DOWN; - ProcessKeyboardEvent (&PseudoEvent); - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = SDLK_UP; - ProcessKeyboardEvent (&PseudoEvent); - } - } - } - if (Event->type == SDL_JOYBUTTONDOWN) - { - printf("Joystick %i down\n", Event->jbutton.button); - - if (Event->jbutton.button % 3 == 0) - { - //Mimic the Primary key - - PseudoEvent.type=SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = ControlA; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jbutton.button % 3 == 1) - { - //Mimic the Secondary key - - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = ControlB; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jbutton.button % 3 == 2) - { - //Mimic the Tertiary key - - PseudoEvent.type = SDL_KEYDOWN; - PseudoEvent.key.keysym.sym = ControlC; - ProcessKeyboardEvent (&PseudoEvent); - } - } - if (Event->type == SDL_JOYBUTTONUP) - { - if (Event->jbutton.button % 3 == 0) - { - //Mimic the Primary key - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = ControlA; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jbutton.button % 3 == 1) - { - //Mimic the Secondary key - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = ControlB; - ProcessKeyboardEvent (&PseudoEvent); - } - if (Event->jbutton.button % 3 == 2) - { - //Mimic the Tertiary key - - PseudoEvent.type = SDL_KEYUP; - PseudoEvent.key.keysym.sym = ControlC; - ProcessKeyboardEvent (&PseudoEvent); - } - } -} - +#include "libs/graphics/gfx_common.h" int main(int argc, char *argv[]) { - SDL_Surface* Screen; - SDL_Joystick *Joystick1; - SDL_Event Event; - SDL_version compile_version; + // TODO: Currently every graphics module has to implement its own main function. + // Should be divided later into smaller parts with common code. - char SoundcardName[256]; - char VideoName[256]; - int audio_rate,audio_channels; - Uint16 audio_format; - - int a,i; - - //FILE* Debug; - //Debug = fopen ("Debug.txt","w"); _dup2(fileno(Debug),1); - - //Begin System Initialization - - printf("Initializing SDL.\n"); - - if ((SDL_Init (SDL_INIT_VIDEO - | SDL_INIT_AUDIO - | SDL_INIT_JOYSTICK - | SDL_INIT_NOPARACHUTE //For Debugging in MSVC++ - ) == -1)) - { - printf("Could not initialize SDL: %s.\n", SDL_GetError()); - exit(-1); - } - SDL_VideoDriverName (VideoName, sizeof (VideoName)); - printf("SDL driver used: %s\n", VideoName); - // Set the environment variable SDL_VIDEODRIVER to override - // For Linux: x11 (default), dga, fbcon, directfb, svgalib, - // ggi, aalib - // For Windows: directx (default), windib - atexit (SDL_Quit); - - printf ("SDL initialized.\n"); - - SDL_EnableUNICODE (1); - - printf ("Initializing Screen.\n"); - - ScreenWidth = 320; - ScreenHeight = 240; - ScreenWidthActual = 640; - ScreenHeightActual = 480; - ScreenBPPActual = 16; - - switch(ScreenBPPActual) { - case 8: - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 2); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 3); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 3); - break; - case 15: - case 16: - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - break; - case 24: - case 32: - SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); - break; - } - SDL_GL_SetAttribute (SDL_GL_DEPTH_SIZE, ScreenBPPActual); - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1); - - Screen = SDL_SetVideoMode ( - ScreenWidthActual, ScreenHeightActual, ScreenBPPActual, - 0 -// | SDL_HWSURFACE -// | SDL_DOUBLEBUF - | SDL_OPENGL - | SDL_ANYFORMAT -// | SDL_FULLSCREEN - ); - if (Screen == NULL) - { - printf ("Couldn't set %ix%ix%i video mode: %s\n", - ScreenWidthActual, ScreenHeightActual, ScreenBPPActual, - SDL_GetError ()); - exit(-1); - } - else - { - printf ("Set the resolution to: %ix%ix%i\n", - SDL_GetVideoSurface()->w, SDL_GetVideoSurface()->h, - SDL_GetVideoSurface()->format->BitsPerPixel); - printf("OpenGL renderer: %s version: %s\n", glGetString(GL_RENDERER), - glGetString(GL_VERSION)); - - } - - //glShadeModel (GL_SMOOTH); - glClearColor (0,0,0,0); - glViewport (0, 0, ScreenWidthActual, ScreenHeightActual); - glDrawBuffer (GL_FRONT_LEFT); - glClear (GL_COLOR_BUFFER_BIT); - SDL_GL_SwapBuffers (); //Clear both buffers at init - glClear (GL_COLOR_BUFFER_BIT); - glEnable (GL_ALPHA_TEST); - glDisable (GL_DITHER); - glAlphaFunc (GL_GREATER, 0); - - printf ("%i joysticks were found.\n", SDL_NumJoysticks ()); - if(SDL_NumJoysticks() > 0) - { - printf ("The names of the joysticks are:\n"); - for(i = 0; i < SDL_NumJoysticks (); i++) - { - printf(" %s\n", SDL_JoystickName (i)); - } - SDL_JoystickEventState (SDL_ENABLE); - Joystick1 = SDL_JoystickOpen (0); - if (SDL_NumJoysticks () > 1) - SDL_JoystickOpen(1); - } - - if (Mix_OpenAudio(44100, AUDIO_S16, 2, 4096)) - { - printf ("Unable to open audio!\n"); - exit (-1); - } - atexit (Mix_CloseAudio); - - SDL_AudioDriverName (SoundcardName, sizeof (SoundcardName)); - - Mix_QuerySpec (&audio_rate, &audio_format, &audio_channels); - printf ("Opened %s at %d Hz %d bit %s, %d bytes audio buffer\n", - SoundcardName, audio_rate, audio_format & 0xFF, - audio_channels > 1 ? "stereo" : "mono", 4096); - - MIX_VERSION (&compile_version); - printf ("Compiled with SDL_mixer version: %d.%d.%d\n", - compile_version.major, - compile_version.minor, - compile_version.patch); - printf ("Running with SDL_mixer version: %d.%d.%d\n", - Mix_Linked_Version()->major, - Mix_Linked_Version()->minor, - Mix_Linked_Version()->patch); - - //SDL_ShowCursor (SDL_DISABLE); - - GraphicsSem = SDL_CreateSemaphore (1); - _MemorySem = SDL_CreateSemaphore (1); - - //End System Initialization - - //Begin Game Initialization - - for(a = 0; a < 512; a++) - { - KeyboardDown[a] = FALSE; - //KeyboardStroke[a] = FALSE; - } - ControlA = SDLK_f; - ControlB = SDLK_d; - ControlC = SDLK_s; - ControlX = SDLK_a; - ControlStart = SDLK_RETURN; - ControlLeftShift = SDLK_LSHIFT; - ControlRightShift = SDLK_RSHIFT; - - //End Game Initialization - - TFB_DEBUG_HALT = 0; - - //Begin MultiThreading - - printf ("\n---\n\n"); - - SDL_CreateThread (Starcon2Main, NULL); - - //End MultiThreading - - //Start Test Code - - //End Test Code - - //Start main game loop here - - for (;;) - { - //Process Events - - while (SDL_PollEvent (&Event)) - { - switch (Event.type) { - case SDL_ACTIVEEVENT: /* Loose/gain visibility */ - // TODO - break; - case SDL_KEYDOWN: /* Key pressed */ - case SDL_KEYUP: /* Key released */ - ProcessKeyboardEvent (&Event); - break; - case SDL_JOYAXISMOTION: /* Joystick axis motion */ - case SDL_JOYBUTTONDOWN: /* Joystick button pressed */ - case SDL_JOYBUTTONUP: /* Joystick button released */ - ProcessJoystickEvent (&Event); - break; - case SDL_QUIT: - exit (0); - break; - case SDL_VIDEORESIZE: /* User resized video mode */ - // TODO - break; - case SDL_VIDEOEXPOSE: /* Screen needs to be redrawn */ - // TODO - break; - default: - break; - } - } - - TFB_FlushGraphics (); - - //Still testing this... Should fix sticky input soon... - /* - { - Uint8* Temp; - - SDL_PumpEvents (); - Temp = SDL_GetKeyState (NULL); - for(a = 0; a < 512; a++) - { - KeyboardDown[a] = Temp[a]; - } - } - */ - } + return Main(argc,argv); }