Mika's and McMartin's modularization patch, v2

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@23 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
luminescent
2002-09-09 03:20:03 +00:00
parent 1eb1a51e45
commit ccb03ffc09
20 changed files with 1067 additions and 1073 deletions
+34 -37
View File
@@ -27,8 +27,8 @@ AM_MAINTAINER_MODE
# Configurables
CFLAGS="$CFLAGS -g -O2 -DGFXMODULE_SDL_PURE"
CPPFLAGS="$CPPFLAGS -g -O2 -DGFXMODULE_SDL_PURE"
CFLAGS="$CFLAGS -g -O2 -DHAVE_OPENGL -DGFXMODULE_SDL -DSOUNDMODULE_SDL"
CPPFLAGS="$CPPFLAGS -g -O2 -DHAVE_OPENGL -DGFXMODULE_SDL -DSOUNDMODULE_SDL"
# These defines seem to be missing, and they are added here as a workaround.
@@ -82,46 +82,45 @@ 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 <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#],[
#],[
#have_opengl=yes
#])
#AC_MSG_RESULT($have_opengl)
#GL_LIBS=$SYS_GL_LIBS
GL_LIBS=
],[
],[
have_opengl=yes
])
AC_MSG_RESULT($have_opengl)
GL_LIBS=$SYS_GL_LIBS
AC_SUBST(GL_LIBS)
# Figure out which math library to use
@@ -199,8 +198,6 @@ AC_CONFIG_FILES([
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
+41 -19
View File
@@ -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 /D "GFXMODULE_SDL_PURE" /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 "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_SDL" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=snBsc.exe
@@ -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 /D "GFXMODULE_SDL_PURE" /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 "HAVE_OPENGL" /D "GFXMODULE_SDL" /D "SOUNDMODULE_SDL" /FR /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=snBsc.exe
@@ -236,38 +236,52 @@ SOURCE=..\sc2code\libs\graphics\sdl\sdl_common.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\dcqueue.c
# 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
SOURCE=..\sc2code\libs\graphics\sdl\primitives.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
SOURCE=..\sc2code\libs\graphics\sdl\primitives.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\pure\pure.h
SOURCE=..\sc2code\libs\graphics\sdl\opengl.c
# End Source File
# End Group
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\opengl.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\pure.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\pure.h
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\3do_blt.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\3do_funcs.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\graphics\sdl\3do_getbody.c
# End Source File
# End Group
# End Group
# Begin Group "input"
@@ -281,6 +295,10 @@ SOURCE=..\sc2code\libs\input\inpintrn.h
SOURCE=..\sc2code\libs\input\input_common.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\input\input_common.h
# End Source File
# Begin Group "sdl"
# PROP Default_Filter ""
@@ -332,7 +350,7 @@ SOURCE=..\sc2code\libs\memory\w_memlib.c
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\sc2code\libs\resource\DIRECT.C
SOURCE=..\sc2code\libs\resource\direct.c
# End Source File
# Begin Source File
@@ -394,6 +412,10 @@ SOURCE=..\sc2code\libs\sound\trackplayer.h
SOURCE=..\sc2code\libs\sound\sound_common.c
# End Source File
# Begin Source File
SOURCE=..\sc2code\libs\sound\sound_common.h
# End Source File
# Begin Group "sdl"
# PROP Default_Filter ""
+1 -1
View File
@@ -39,7 +39,7 @@ typedef TIME_VALUE *PTIME_VALUE;
typedef SWORD COORD;
typedef COORD *PCOORD;
typedef UWORD COLOR;
typedef DWORD COLOR;
typedef COLOR *PCOLOR;
#define BUILD_COLOR(c32k,c256) \
+1 -14
View File
@@ -16,22 +16,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/******************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*******************************************/
#include "libs/graphics/gfxintrn.h"
#include "libs/input/inpintrn.h"
#include "libs/graphics/gfx_common.h"
#define NUMBER_OF_PLUTVALS 32
#define NUMBER_OF_PLUT_UINT32s (NUMBER_OF_PLUTVALS >> 1)
#define GET_VAR_PLUT(i) (_varPLUTs + (i) * NUMBER_OF_PLUT_UINT32s)
@@ -46,7 +34,6 @@ int ScreenWidth;
int ScreenHeight;
int ScreenWidthActual;
int ScreenHeightActual;
int ScreenBPPActual;
int GraphicsDriver;
int TFB_DEBUG_HALT;
+23 -17
View File
@@ -16,21 +16,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#ifndef GFX_COMMON_H
#define GFX_COMMON_H
#ifdef WIN32
#pragma warning (disable:4244) /* Disable bogus conversion warnings. */
#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -40,11 +32,24 @@
#include "libs/vidlib.h"
#include "libs/misc.h"
#define TFB_WINDOW_CAPTION "The Ur-Quan Masters"
int Main(int argc, char *argv[]);
int Starcon2Main (void *);
// driver for TFB_InitGraphics
enum
{
TFB_GFXDRIVER_SDL_OPENGL,
TFB_GFXDRIVER_SDL_PURE,
};
// Graphics Stuff
// flags for TFB_InitGraphics
#define TFB_GFXFLAGS_FULLSCREEN (1<<0)
#define TFB_GFXFLAGS_BILINEAR_FILTERING (1<<1)
int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp);
int TFB_CreateGamePlayThread ();
void TFB_ProcessEvents ();
// 3DO Graphics Stuff
void LoadIntoExtraScreen (PRECT r);
void DrawFromExtraScreen (PRECT r);
@@ -54,7 +59,6 @@ void SetGraphicScale (int scale);
void SetGraphicUseOtherExtra (int other);
void *GetScreenBitmap ();
void ScreenTransition (int transition, PRECT pRect);
void ScreenOrigin (FRAME Display, COORD sx, COORD sy);
extern float FrameRate;
extern int FrameRateTickBase;
@@ -223,6 +227,8 @@ extern int ScreenWidth;
extern int ScreenHeight;
extern int ScreenWidthActual;
extern int ScreenHeightActual;
extern int ScreenBPPActual;
extern int GraphicsDriver;
int Starcon2Main (void *);
#endif
@@ -3,8 +3,6 @@
# Written by Mudry <mudry@user.sf.net>, protected by GNU GPL.
# CVS $ Id: $
SUBDIRS = opengl pure
CFLAGS = -Wall
INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \
@@ -14,9 +12,8 @@ INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \
noinst_LTLIBRARIES = libsdl.la
libsdl_la_SOURCES = sdl_common.c rotozoom.c
libsdl_la_SOURCES = 3do_blt.c 3do_funcs.c 3do_getbody.c dcqueue.c opengl.c \
primitives.c pure.c rotozoom.c sdl_common.c
libsdl_la_LIBADD = opengl/libopengl.la pure/libpure.la
noinst_HEADERS = sdl_common.h rotozoom.h
noinst_HEADERS = opengl.h primitives.h pure.h rotozoom.h sdl_common.h
+9 -3
View File
@@ -9,9 +9,14 @@
*/
#ifdef GFXMODULE_SDL
#ifdef WIN32
#pragma warning (disable:4018)
#endif
#include <stdlib.h>
#include <string.h>
#include "rotozoom.h"
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
@@ -330,7 +335,7 @@ void transformSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int cx, int cy,
{
int x, y, t1, t2, dx, dy, xd, yd, sdx, sdy, ax, ay, ex, ey, sw, sh;
tColorRGBA c00, c01, c10, c11;
tColorRGBA *pc, *sp, *spb;
tColorRGBA *pc, *sp;
int gap;
/*
@@ -590,7 +595,6 @@ SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int s
double zoominv;
double sanglezoom, canglezoom, sanglezoominv, canglezoominv;
int dstwidthhalf, dstwidth, dstheighthalf, dstheight;
double x, y, cx, cy, sx, sy;
int is32bit;
int i, src_converted;
@@ -936,3 +940,5 @@ SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smoo
*/
return (rz_dst);
}
#endif
+360 -481
View File
@@ -16,532 +16,411 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef GFXMODULE_SDL
#include "sdl_common.h"
#include "opengl.h"
#include "pure.h"
#include "rotozoom.h"
#include "primitives.h"
#ifdef WIN32
#include <io.h>
#endif
#include <fcntl.h>
SDL_Surface *SDL_Video;
SDL_Surface *SDL_Screen;
SDL_Surface *ExtraScreen;
volatile int continuity_break;
//Status: Implemented!
DWORD
GetTimeCounter () //I wonder if it's ms, ticks, or seconds...
int
TFB_InitGraphics (int driver, int flags, int width, int height, int bpp)
{
DWORD ret;
int result;
ret = (DWORD) (SDL_GetTicks () * ONE_SECOND / 1000.0);
return (ret);
if (driver == TFB_GFXDRIVER_SDL_OPENGL)
{
#ifdef HAVE_OPENGL
result = TFB_GL_InitGraphics (driver, flags, width, height, bpp);
#else
driver = TFB_GFXDRIVER_SDL_PURE;
printf("OpenGL support not compiled in, so using pure sdl driver\n");
result = TFB_Pure_InitGraphics (driver, flags, width, height, bpp);
#endif
}
else
{
result = TFB_Pure_InitGraphics (driver, flags, width, height, bpp);
}
SDL_EnableUNICODE (1);
SDL_WM_SetCaption (TFB_WINDOW_CAPTION, NULL);
//if (flags & TFB_GFXFLAGS_FULLSCREEN)
// SDL_ShowCursor (SDL_DISABLE);
return 0;
}
DWORD
SetSemaphore (SEMAPHORE *sem)
int
TFB_CreateGamePlayThread ()
{
SDL_SemWait (*sem);
return (GetTimeCounter ());
TFB_DEBUG_HALT = 0;
GraphicsSem = SDL_CreateSemaphore (1);
_MemorySem = SDL_CreateSemaphore (1);
SDL_CreateThread (Starcon2Main, NULL);
return 0;
}
void
ClearSemaphore (SEMAPHORE *sem)
TFB_ProcessEvents ()
{
SDL_SemPost (*sem);
}
SDL_Event Event;
TASK
AddTask (TASK_FUNC arg1, COUNT arg2)
{
return (SDL_CreateThread ((int (*)(void *)) arg1, NULL));
}
void
DeleteTask (TASK T)
{
SDL_KillThread (T);
}
DWORD
SleepTask (DWORD wake_time)
{
DWORD t;
t = GetTimeCounter ();
if (wake_time <= t)
SDL_Delay (0);
else
SDL_Delay ((wake_time - t) * 1000 / ONE_SECOND);
return (GetTimeCounter ());
}
// following stuff was in getbody.c before modularization
extern char *_cur_resfile_name;
static void
process_image (FRAMEPTR FramePtr, SDL_Surface *img[], int cel_ct)
{
int hx, hy, h;
TYPE_SET (FramePtr->TypeIndexAndFlags, WANT_PIXMAP << FTYPE_SHIFT);
INDEX_SET (FramePtr->TypeIndexAndFlags, cel_ct);
hx = hy = 0;
SDL_LockSurface (img[cel_ct]);
if (img[cel_ct]->w >= 3 && (h = img[cel_ct]->h))
while (SDL_PollEvent (&Event))
{
if (img[cel_ct]->format->palette)
{
int w;
BYTE *pixel, *p, Cknockout, Chotx, Choty;
img[cel_ct]->clip_rect.x = img[cel_ct]->w;
img[cel_ct]->clip_rect.y = img[cel_ct]->h;
img[cel_ct]->clip_rect.w = img[cel_ct]->clip_rect.h = 0;
p = pixel = img[cel_ct]->pixels;
Cknockout = *p++;
Chotx = *p;
*p++ = Cknockout;
Choty = *p;
*p++ = Cknockout;
SDL_SetColorKey
(
img[cel_ct], SDL_SRCCOLORKEY,
SDL_MapRGB
(
img[cel_ct]->format,
img[cel_ct]->format->palette->colors[Cknockout].r,
img[cel_ct]->format->palette->colors[Cknockout].g,
img[cel_ct]->format->palette->colors[Cknockout].b
)
);
do
{
w = img[cel_ct]->w - (p - pixel);
if (w)
{
int x, y;
BYTE opval;
opval = Cknockout;
do
{
BYTE pval;
pval = *p;
if (pval == Chotx)
{
*p = Cknockout;
hx = img[cel_ct]->w - w;
}
if (pval == Choty)
{
*p = Cknockout;
hy = img[cel_ct]->h - h;
}
pval = *p;
if (pval == Cknockout)
{
if (opval != Cknockout)
{
x = img[cel_ct]->w - w;
if (x > img[cel_ct]->clip_rect.x + img[cel_ct]->clip_rect.w)
img[cel_ct]->clip_rect.w = x - img[cel_ct]->clip_rect.x;
y = img[cel_ct]->h - h;
if (y >= img[cel_ct]->clip_rect.y + img[cel_ct]->clip_rect.h)
img[cel_ct]->clip_rect.h = y - img[cel_ct]->clip_rect.y + 1;
}
}
else
{
if (opval == Cknockout)
{
x = img[cel_ct]->w - w;
if (x < img[cel_ct]->clip_rect.x)
{
if (img[cel_ct]->clip_rect.w == 0)
img[cel_ct]->clip_rect.w = 1;
else
img[cel_ct]->clip_rect.w += img[cel_ct]->clip_rect.x - x;
img[cel_ct]->clip_rect.x = x;
}
y = img[cel_ct]->h - h;
if (y < img[cel_ct]->clip_rect.y)
{
if (img[cel_ct]->clip_rect.h == 0)
img[cel_ct]->clip_rect.h = 1;
else
img[cel_ct]->clip_rect.h += img[cel_ct]->clip_rect.y - y;
img[cel_ct]->clip_rect.y = y;
}
}
}
opval = pval;
} while (++p, --w);
if (opval != Cknockout)
{
x = img[cel_ct]->w - w;
if (x > img[cel_ct]->clip_rect.x + img[cel_ct]->clip_rect.w)
img[cel_ct]->clip_rect.w = x - img[cel_ct]->clip_rect.x;
y = img[cel_ct]->h - h;
if (y >= img[cel_ct]->clip_rect.y + img[cel_ct]->clip_rect.h)
img[cel_ct]->clip_rect.h = y - img[cel_ct]->clip_rect.y + 1;
}
}
p = (pixel += img[cel_ct]->pitch);
} while (--h);
}
else
{
}
}
SDL_UnlockSurface (img[cel_ct]);
hx -= img[cel_ct]->clip_rect.x;
hy -= img[cel_ct]->clip_rect.y;
FramePtr->DataOffs = (BYTE *)TFB_LoadImage (img[cel_ct]) - (BYTE *)FramePtr;
img[cel_ct] = ((TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs))->SurfaceSDL;
hx += img[cel_ct]->clip_rect.x;
hy += img[cel_ct]->clip_rect.y;
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (hx, hy));
SetFrameBounds (FramePtr, img[cel_ct]->clip_rect.w, img[cel_ct]->clip_rect.h);
#if 0
printf ("\thot[%d, %d], rect[%d, %d, %d, %d]\n",
hx, hy,
img[cel_ct]->clip_rect.x,
img[cel_ct]->clip_rect.y,
img[cel_ct]->clip_rect.w,
img[cel_ct]->clip_rect.h);
#endif
}
MEM_HANDLE
_GetCelData (FILE *fp, DWORD length)
{
#ifdef WIN32
int omode;
#endif
int cel_ct, n;
DWORD opos;
char CurrentLine[1024], filename[1024];
#define MAX_CELS 256
SDL_Surface *img[MAX_CELS];
DRAWABLE Drawable;
opos = ftell (fp);
{
char *s1, *s2;
if (_cur_resfile_name == 0
|| (((s2 = 0), (s1 = strrchr (_cur_resfile_name, '/')) == 0)
&& (s2 = strrchr (_cur_resfile_name, '\\')) == 0))
n = 0;
else
{
if (s2 > s1)
s1 = s2;
n = s1 - _cur_resfile_name + 1;
strncpy (filename, _cur_resfile_name, n);
}
}
#ifdef WIN32
omode = _setmode (fileno (fp), O_TEXT);
#endif
cel_ct = 0;
while (fgets (CurrentLine, sizeof (CurrentLine), fp) && cel_ct < MAX_CELS)
{
if
(
sscanf(CurrentLine, "%s", &filename[n]) == 1
&& (img[cel_ct] = IMG_Load (filename))
&& img[cel_ct]->w > 0
&& img[cel_ct]->h > 0
&& img[cel_ct]->format->BitsPerPixel >= 8
)
++cel_ct;
else if (img[cel_ct])
printf("_GetCelData: Bad file!\n"),
SDL_FreeSurface (img[cel_ct]);
if ((int)ftell (fp) - (int)opos >= (int)length)
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 */
TFB_SwapBuffers ();
break;
default:
break;
}
#ifdef WIN32
_setmode (fileno (fp), omode);
//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];
}
}
*/
}
}
TFB_Image*
TFB_LoadImage (SDL_Surface *img)
{
TFB_Image *myImage;
SDL_Surface *new_surf;
float x_scale = (float)ScreenWidthActual / ScreenWidth;
float y_scale = (float)ScreenHeightActual / ScreenHeight;
myImage = (TFB_Image*) HMalloc (sizeof (TFB_Image));
myImage->dirty = FALSE;
myImage->ScaledImg = NULL;
if (img->format->BytesPerPixel < 4) {
// Because image doesn't have alpha channel, blit it to new surface, using
// transparent color (if SDL_SetColorKey was called before this)
SDL_Surface *full_surf;
SDL_Rect SDL_DstRect;
full_surf = SDL_CreateRGBSurface (SDL_SWSURFACE, img->clip_rect.w, img->clip_rect.h,
32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
SDL_DstRect.x = SDL_DstRect.y = 0;
SDL_BlitSurface (img, &img->clip_rect, full_surf, &SDL_DstRect);
full_surf->clip_rect.x = full_surf->clip_rect.y = 0;
full_surf->clip_rect.w = img->clip_rect.w;
full_surf->clip_rect.h = img->clip_rect.h;
SDL_FreeSurface (img);
img = full_surf;
}
if ((x_scale==1.0f && y_scale==1.0f) || (img->w==0 && img->h==0))
{
new_surf = img;
}
else
{
// Note: SMOOTHING_OFF and SMOOTHING_ON controls bilinear filtering
new_surf = zoomSurface (img, x_scale, y_scale, SMOOTHING_OFF);
}
// Now convert to the native display format
myImage->DrawableImg = TFB_DisplayFormatAlpha (new_surf);
if (new_surf != img)
SDL_FreeSurface(new_surf);
myImage->SurfaceSDL = TFB_DisplayFormatAlpha (img);
SDL_FreeSurface(img);
return(myImage);
}
void
TFB_FreeImage (TFB_Image *img)
{
if (img)
{
TFB_DrawCommand DC;
DC.Type = TFB_DRAWCOMMANDTYPE_DELETEIMAGE;
DC.image = (TFB_ImageStruct*) img;
TFB_EnqueueDrawCommand (&DC);
}
}
void
TFB_UpdateDrawableImage (TFB_Image *img)
{
SDL_Surface *new_surf;
float x_scale = (float)ScreenWidthActual / ScreenWidth;
float y_scale = (float)ScreenHeightActual / ScreenHeight;
SDL_LockSurface (img->SurfaceSDL);
new_surf = zoomSurface (img->SurfaceSDL, x_scale, y_scale, SMOOTHING_OFF);
SDL_UnlockSurface (img->SurfaceSDL);
// Now convert to the native display format
SDL_FreeSurface (img->DrawableImg);
img->DrawableImg = TFB_DisplayFormatAlpha (new_surf);
SDL_FreeSurface (new_surf);
}
void
TFB_SwapBuffers ()
{
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
TFB_GL_SwapBuffers ();
else
TFB_Pure_SwapBuffers ();
#else
TFB_Pure_SwapBuffers ();
#endif
}
SDL_Surface*
TFB_DisplayFormatAlpha (SDL_Surface *surface)
{
#ifdef HAVE_OPENGL
if (GraphicsDriver == TFB_GFXDRIVER_SDL_OPENGL)
{
return TFB_GL_DisplayFormatAlpha (surface);
}
#endif
Drawable = 0;
if (cel_ct && (Drawable = AllocDrawable (cel_ct, 0)))
{
DRAWABLEPTR DrawablePtr;
return SDL_DisplayFormatAlpha (surface);
}
if ((DrawablePtr = LockDrawable (Drawable)) == 0)
{
while (cel_ct--)
SDL_FreeSurface (img[cel_ct]);
void
TFB_FlushGraphics () // Only call from main thread!!
{
int semval;
Uint32 this_flush;
static Uint32 last_flush = 0;
mem_release (Drawable);
Drawable = 0;
this_flush = SDL_GetTicks ();
if (this_flush - last_flush < 1000 / 100)
return;
semval = SDL_SemTryWait (GraphicsSem);
if (semval != 0 && !continuity_break)
return;
continuity_break = 0;
if (DrawCommandQueue == 0 || DrawCommandQueue->Size == 0)
{
if (semval == 0)
SDL_SemPost (GraphicsSem);
return;
}
last_flush = this_flush;
if (semval == 0)
SDL_SemPost (GraphicsSem);
while (DrawCommandQueue->Size > 0)
{
TFB_DrawCommand DC_real;
TFB_Image *DC_image;
TFB_DrawCommand* DC = &DC_real;
if (!TFB_DrawCommandQueue_Pop (DrawCommandQueue, DC))
{
printf ("Woah there coyboy! Trouble with TFB_Queues...\n");
continue;
}
DC_image = (TFB_Image*) DC->image;
switch (DC->Type)
{
case TFB_DRAWCOMMANDTYPE_IMAGE:
if (DC_image==0)
{
printf ("Error!!! Bad Image!\n");
}
else
{
FRAMEPTR FramePtr;
SDL_Rect targetRect;
DrawablePtr->hDrawable = GetDrawableHandle (Drawable);
TYPE_SET (DrawablePtr->FlagsAndIndex,
(DRAWABLE_TYPE)ROM_DRAWABLE << FTYPE_SHIFT);
INDEX_SET (DrawablePtr->FlagsAndIndex, cel_ct - 1);
targetRect.x = DC->x * ScreenWidthActual / ScreenWidth;
targetRect.y = DC->y * ScreenHeightActual / ScreenHeight;
FramePtr = &DrawablePtr->Frame[cel_ct];
while (--FramePtr, cel_ct--)
process_image (FramePtr, img, cel_ct);
UnlockDrawable (Drawable);
}
}
if (Drawable == 0)
printf ("Couldn't get cel data for '%s'\n", _cur_resfile_name);
return (GetDrawableHandle (Drawable));
}
BOOLEAN
_ReleaseCelData (MEM_HANDLE handle)
{
DRAWABLEPTR DrawablePtr;
if ((DrawablePtr = LockDrawable (handle)) == 0)
return (FALSE);
if (TYPE_GET (DrawablePtr->FlagsAndIndex) != SCREEN_DRAWABLE)
if (DC->Qualifier != MAPPED_TO_DISPLAY)
{
int cel_ct;
FRAMEPTR FramePtr;
cel_ct = INDEX_GET (DrawablePtr->FlagsAndIndex);
FramePtr = &DrawablePtr->Frame[cel_ct];
while (--FramePtr, cel_ct--)
if ((DC->w != DC_image->SurfaceSDL->w || DC->h != DC_image->SurfaceSDL->h) &&
DC_image->ScaledImg)
{
if (FramePtr->DataOffs)
{
TFB_Image *img;
img = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
FramePtr->DataOffs = 0;
TFB_FreeImage (img);
}
}
}
UnlockDrawable (handle);
mem_release (handle);
return (TRUE);
}
MEM_HANDLE
_GetFontData (FILE *fp, DWORD length)
{
DWORD cel_ct;
COUNT num_entries;
FONT_REF FontRef;
DIRENTRY FontDir;
BOOLEAN found_chars;
#define MAX_CELS 256
SDL_Surface *img[MAX_CELS] = { 0 };
char pattern[1024];
if (_cur_resfile_name == 0)
return (0);
sprintf (pattern, "%s/*.*", _cur_resfile_name);
found_chars = FALSE;
FontDir = CaptureDirEntryTable (LoadDirEntryTable (pattern, &num_entries));
while (num_entries--)
{
char *char_name;
char_name = GetDirEntryAddress (SetAbsDirEntryTableIndex (FontDir, num_entries));
if (sscanf (char_name, "%u.", (unsigned int) &cel_ct) == 1
&& cel_ct >= FIRST_CHAR
&& img[cel_ct -= FIRST_CHAR] == 0
&& sprintf (pattern, "%s/%s", _cur_resfile_name, char_name)
&& (img[cel_ct] = IMG_Load (pattern)))
{
if (img[cel_ct]->w > 0
&& img[cel_ct]->h > 0
&& img[cel_ct]->format->BitsPerPixel >= 8)
found_chars = TRUE;
else
{
SDL_FreeSurface (img[cel_ct]);
img[cel_ct] = 0;
}
}
}
DestroyDirEntryTable (ReleaseDirEntryTable (FontDir));
FontRef = 0;
if (found_chars && (FontRef = AllocFont (0)))
{
FONTPTR FontPtr;
cel_ct = MAX_CELS; // MAX_CHARS;
if ((FontPtr = LockFont (FontRef)) == 0)
{
while (cel_ct--)
{
if (img[cel_ct])
SDL_FreeSurface (img[cel_ct]);
}
mem_release (FontRef);
FontRef = 0;
SDL_BlitSurface(DC_image->ScaledImg, NULL, SDL_Screen, &targetRect);
}
else
{
FRAMEPTR FramePtr;
FontPtr->FontRef = FontRef;
FontPtr->Leading = 0;
FramePtr = &FontPtr->CharDesc[cel_ct];
while (--FramePtr, cel_ct--)
if (DC_image->dirty)
{
if (img[cel_ct])
{
process_image (FramePtr, img, cel_ct);
SetFrameBounds (FramePtr, GetFrameWidth (FramePtr) + 1, GetFrameHeight (FramePtr));
if (img[0])
SetFrameHotSpot (FramePtr, MAKE_HOT_SPOT (0, img[0]->clip_rect.h));
if (GetFrameHeight (FramePtr) > FontPtr->Leading)
FontPtr->Leading = GetFrameHeight (FramePtr);
}
}
++FontPtr->Leading;
UnlockFont (FontRef);
}
}
(void) fp; /* Satisfying compiler (unused parameter) */
(void) length; /* Satisfying compiler (unused parameter) */
return (FontRef);
}
BOOLEAN
_ReleaseFontData (MEM_HANDLE handle)
{
FONTPTR FontPtr;
if ((FontPtr = LockFont (handle)) == 0)
return (FALSE);
{
int cel_ct;
FRAMEPTR FramePtr;
cel_ct = MAX_CHARS;
FramePtr = &FontPtr->CharDesc[cel_ct];
while (--FramePtr, cel_ct--)
{
if (FramePtr->DataOffs)
{
TFB_Image *img;
img = (TFB_Image *)((BYTE *)FramePtr + FramePtr->DataOffs);
FramePtr->DataOffs = 0;
TFB_FreeImage (img);
}
}
TFB_UpdateDrawableImage (DC_image);
DC_image->dirty = FALSE;
}
UnlockFont (handle);
mem_release (handle);
return (TRUE);
}
// _request_drawable was in drawable.c before modularization
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;
SDL_BlitSurface(DC_image->DrawableImg, NULL, SDL_Screen, &targetRect);
}
}
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--)
SDL_BlitSurface(DC_image->SurfaceSDL, NULL, SDL_Screen, &targetRect);
}
}
break;
case TFB_DRAWCOMMANDTYPE_LINE:
{
TFB_Image *Image;
int x_scale = ScreenWidthActual / ScreenWidth;
int y_scale = ScreenHeightActual / ScreenHeight;
int x1, y1, x2, y2;
Uint32 color;
PutPixelFn screen_plot;
int xi, yi;
screen_plot = putpixel_for (SDL_Screen);
if (DrawableType == RAM_DRAWABLE
&& (Image = TFB_LoadImage (SDL_CreateRGBSurface (
SDL_HWSURFACE,
imgw,
imgh,
24,
0x00FF0000,
0x0000FF00,
0x000000FF,
0x00000000
))))
FramePtr->DataOffs = (BYTE *)Image - (BYTE *)FramePtr;
x1 = DC->x * x_scale;
x2 = DC->w * x_scale;
y1 = DC->y * y_scale;
y2 = DC->h * y_scale;
color = SDL_MapRGB (SDL_Screen->format, DC->r, DC->g, DC->b);
TYPE_SET (FramePtr->TypeIndexAndFlags, DrawableType);
INDEX_SET (FramePtr->TypeIndexAndFlags, NumFrames);
SetFrameBounds (FramePtr, width, height);
--FramePtr;
}
UnlockDrawable (Drawable);
SDL_LockSurface (SDL_Screen);
for (xi = 0; xi < x_scale; xi++)
{
for (yi = 0; yi < y_scale; yi++)
{
line (x1 + xi, y1 + yi, x2 + xi, y2 + yi,
color, screen_plot, SDL_Screen);
}
}
SDL_UnlockSurface (SDL_Screen);
break;
}
case TFB_DRAWCOMMANDTYPE_RECTANGLE:
{
SDL_Rect r;
r.x = DC->x * ScreenWidthActual / ScreenWidth;
r.y = DC->y * ScreenHeightActual / ScreenHeight;
r.w = DC->w * ScreenWidthActual / ScreenWidth;
r.h = DC->h * ScreenHeightActual / ScreenHeight;
return (Drawable);
SDL_FillRect(SDL_Screen, &r, SDL_MapRGB(SDL_Screen->format, DC->r, DC->g, DC->b));
break;
}
case TFB_DRAWCOMMANDTYPE_SCISSORENABLE:
{
SDL_Rect r;
r.x = DC->x * ScreenWidthActual / ScreenWidth;
r.y = DC->y * ScreenHeightActual / ScreenHeight;
r.w = DC->w * ScreenWidthActual / ScreenWidth;
r.h = DC->h * ScreenHeightActual / ScreenHeight;
SDL_SetClipRect(SDL_Screen, &r);
break;
}
case TFB_DRAWCOMMANDTYPE_SCISSORDISABLE:
SDL_SetClipRect(SDL_Screen, NULL);
break;
case TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER:
{
SDL_Rect src, dest;
src.x = dest.x = DC->x * ScreenWidthActual / ScreenWidth;
src.y = dest.y = DC->y * ScreenHeightActual / ScreenHeight;
src.w = DC->w * ScreenWidthActual / ScreenWidth;
src.h = DC->h * ScreenHeightActual / ScreenHeight;
if (DC_image == 0)
{
SDL_BlitSurface(SDL_Screen, &src, ExtraScreen, &dest);
}
else
{
dest.x = 0;
dest.y = 0;
SDL_BlitSurface(SDL_Screen, &src, DC_image->SurfaceSDL, &dest);
DC_image->dirty = TRUE;
}
break;
}
case TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER:
{
SDL_Rect src, dest;
src.x = dest.x = DC->x * ScreenWidthActual / ScreenWidth;
src.y = dest.y = DC->y * ScreenHeightActual / ScreenHeight;
src.w = DC->w * ScreenWidthActual / ScreenWidth;
src.h = DC->h * ScreenHeightActual / ScreenHeight;
SDL_BlitSurface(ExtraScreen, &src, SDL_Screen, &dest);
break;
}
case TFB_DRAWCOMMANDTYPE_DELETEIMAGE:
SDL_FreeSurface (DC_image->SurfaceSDL);
SDL_FreeSurface (DC_image->DrawableImg);
if (DC_image->ScaledImg) {
//printf("DELETEIMAGE to ScaledImg %x, size %d %d\n",DC_image->ScaledImg,DC_image->ScaledImg->w,DC_image->ScaledImg->h);
SDL_FreeSurface (DC_image->ScaledImg);
}
HFree (DC_image);
break;
}
TFB_DeallocateDrawCommand (DC);
}
TFB_SwapBuffers();
}
#endif
+28 -19
View File
@@ -16,35 +16,44 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#ifndef SDL_COMMON_H
#define SDL_COMMON_H
#include "SDL.h"
#include "SDL_thread.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
#include "libs/graphics/gfxintrn.h"
#include "libs/input/inpintrn.h"
#include "libs/graphics/gfx_common.h"
#if defined (GFXMODULE_SDL_OPENGL)
#include "libs/graphics/sdl/opengl/opengl.h"
#elif defined (GFXMODULE_SDL_PURE)
#include "libs/graphics/sdl/pure/pure.h"
#endif
#include "libs/input/sdl/input.h"
extern SDL_Surface *SDL_Video;
extern SDL_Surface *SDL_Screen;
extern SDL_Surface *ExtraScreen;
extern volatile int continuity_break;
void ScreenOrigin (FRAME Display, COORD sx, COORD sy);
void LoadDisplay (PDISPLAY_INTERFACE *pDisplay);
// TFB_ImageStruct will be casted to this and vice versa, so sizes must be equal
typedef struct tfb_image
{
SDL_Surface *SurfaceSDL;
SDL_Surface *DrawableImg;
SDL_Surface *ScaledImg;
int scale; // used with ScaledImg
BOOLEAN dirty; // true if DrawableImg needs to be created again
UBYTE pad[sizeof(TFB_ImageStruct)-sizeof(SDL_Surface*)-sizeof(SDL_Surface*)-
sizeof(SDL_Surface*)-sizeof(int)-sizeof(BOOLEAN)];
} TFB_Image;
TFB_Image *TFB_LoadImage (SDL_Surface *img);
void TFB_FreeImage (TFB_Image *img);
void TFB_UpdateDrawableImage (TFB_Image *img);
void TFB_SwapBuffers ();
SDL_Surface* TFB_DisplayFormatAlpha (SDL_Surface *surface);
#endif
+1 -1
View File
@@ -13,5 +13,5 @@ INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \
noinst_LTLIBRARIES = libinput.la
libinput_la_SOURCES = input_common.c
libinput_la_LIBADD = sdl/libsdlinput.la
noinst_HEADERS = inpintrn.h
noinst_HEADERS = input_common.h inpintrn.h
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "input_common.h"
#include "inpintrn.h"
INPUT_DEVICE
+448 -415
View File
@@ -16,18 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef GFXMODULE_SDL
#include "libs/graphics/sdl/sdl_common.h"
@@ -52,6 +41,218 @@ static UNICODE OtherKey;
static BOOLEAN (* PauseFunc) (void);
int
TFB_InitInput (int driver, int flags)
{
int i;
SDL_Joystick *Joystick1;
if ((SDL_InitSubSystem(SDL_INIT_JOYSTICK)) == -1)
{
printf("Couldn't initialize joystick subsystem: %s\n", SDL_GetError());
exit(-1);
}
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);
}
for(i = 0; i < 512; i++)
{
KeyboardDown[i] = FALSE;
//KeyboardStroke[i] = FALSE;
}
ControlA = SDLK_f;
ControlB = SDLK_d;
ControlC = SDLK_s;
ControlX = SDLK_a;
ControlStart = SDLK_RETURN;
ControlLeftShift = SDLK_LSHIFT;
ControlRightShift = SDLK_RSHIFT;
return 0;
}
void
ProcessKeyboardEvent(const SDL_Event *Event)
{
if(Event->key.keysym.sym == SDLK_BACKQUOTE)
{
exit(0);
}
else
{
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;
}
}
}
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);
}
}
}
// Status: Unimplemented
extern BOOLEAN
InitInput (UNICODE Pause, UNICODE Exit, BOOLEAN (*PFunc) (void))
@@ -70,6 +271,241 @@ InitInput (UNICODE Pause, UNICODE Exit, BOOLEAN (*PFunc) (void))
return (TRUE);
}
//Status: Ignored
BOOLEAN
UninitInput () // Looks like it'll be empty
{
BOOLEAN ret;
// printf("Unimplemented function activated: UninitInput()\n");
ret = TRUE;
return (ret);
}
void
FlushInput ()
{
kbdtail = kbdhead = 0;
}
//Status: Unimplemented
UNICODE
KBDToUNICODE (UNICODE SK_in)
//This one'll probably require a big table. Arg.
{
return (SK_in);
}
Uint16
GetUNICODEKey ()
{
if (kbdtail != kbdhead)
{
Uint16 ch;
ch = kbdbuf[kbdhead];
kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1);
return (ch);
}
return (0);
}
// Status: Unimplemented
UNICODE
KeyHit () // Does this clear the top of a queue, or just read it?
{
int i;
for (i = 0; i < sizeof (KeyboardDown) / sizeof (KeyboardDown[0]); ++i)
{
if (KeyboardDown[i])
{
if (i == SDLK_RETURN)
return ('\n');
else if (i >= 256)
{
switch (i)
{
case SDLK_KP_ENTER:
return ('\n');
case SDLK_KP4:
case SDLK_LEFT:
return (SK_LF_ARROW);
case SDLK_KP6:
case SDLK_RIGHT:
return (SK_RT_ARROW);
case SDLK_KP8:
case SDLK_UP:
return (SK_UP_ARROW);
case SDLK_KP2:
case SDLK_DOWN:
return (SK_DN_ARROW);
case SDLK_KP7:
case SDLK_HOME:
return (SK_HOME);
case SDLK_KP9:
case SDLK_PAGEUP:
return (SK_PAGE_UP);
case SDLK_KP1:
case SDLK_END:
return (SK_END);
case SDLK_KP3:
case SDLK_PAGEDOWN:
return (SK_PAGE_DOWN);
case SDLK_KP0:
case SDLK_INSERT:
return (SK_INSERT);
case SDLK_KP_PERIOD:
case SDLK_DELETE:
return (SK_DELETE);
case SDLK_KP_PLUS:
return (SK_KEYPAD_PLUS);
case SDLK_KP_MINUS:
return (SK_KEYPAD_MINUS);
case SDLK_LSHIFT:
return (SK_LF_SHIFT);
case SDLK_RSHIFT:
return (SK_RT_SHIFT);
case SDLK_LCTRL:
case SDLK_RCTRL:
return (SK_CTL);
case SDLK_LALT:
case SDLK_RALT:
return (SK_ALT);
case SDLK_F1:
case SDLK_F2:
case SDLK_F3:
case SDLK_F4:
case SDLK_F5:
case SDLK_F6:
case SDLK_F7:
case SDLK_F8:
case SDLK_F9:
case SDLK_F10:
case SDLK_F11:
case SDLK_F12:
return ((UNICODE) ((i - SDLK_F1) + SK_F1));
}
continue;
}
return ((UNICODE) i);
}
}
return (0);
}
//Status: Unimplemented
int
KeyDown (UNICODE which_scan)
// This might use SK_* stuff, of just plain old chars
{
int i;
i = which_scan;
if (i == '\n')
{
if (KeyboardDown[SDLK_KP_ENTER])
return (1);
i = SDLK_RETURN;
}
else if (i >= 128)
{
switch (i)
{
case SK_LF_ARROW:
if (KeyboardDown[SDLK_KP4])
return (1);
i = SDLK_LEFT;
break;
case SK_RT_ARROW:
if (KeyboardDown[SDLK_KP6])
return (1);
i = SDLK_RIGHT;
break;
case SK_UP_ARROW:
if (KeyboardDown[SDLK_KP8])
return (1);
i = SDLK_UP;
break;
case SK_DN_ARROW:
if (KeyboardDown[SDLK_KP2])
return (1);
i = SDLK_DOWN;
break;
case SK_HOME:
if (KeyboardDown[SDLK_KP7])
return (1);
i = SDLK_HOME;
break;
case SK_PAGE_UP:
if (KeyboardDown[SDLK_KP9])
return (1);
i = SDLK_PAGEUP;
break;
case SK_END:
if (KeyboardDown[SDLK_KP1])
return (1);
i = SDLK_END;
break;
case SK_PAGE_DOWN:
if (KeyboardDown[SDLK_KP3])
return (1);
i = SDLK_PAGEDOWN;
break;
case SK_INSERT:
if (KeyboardDown[SDLK_KP0])
return (1);
i = SDLK_INSERT;
break;
case SK_DELETE:
if (KeyboardDown[SDLK_KP_PERIOD])
return (1);
i = SDLK_DELETE;
break;
case SK_KEYPAD_PLUS:
i = SDLK_KP_PLUS;
break;
case SK_KEYPAD_MINUS:
i = SDLK_KP_MINUS;
break;
case SK_LF_SHIFT:
i = SDLK_LSHIFT;
break;
case SK_RT_SHIFT:
i = SDLK_RSHIFT;
break;
case SK_CTL:
if (KeyboardDown[SDLK_LCTRL])
return (1);
i = SDLK_RCTRL;
break;
case SK_ALT:
if (KeyboardDown[SDLK_LALT])
return (1);
i = SDLK_RALT;
break;
case SK_F1:
case SK_F2:
case SK_F3:
case SK_F4:
case SK_F5:
case SK_F6:
case SK_F7:
case SK_F8:
case SK_F9:
case SK_F10:
case SK_F11:
case SK_F12:
i = (i - SK_F1) + SDLK_F1;
}
}
return (KeyboardDown[i]);
}
INPUT_STATE
AnyButtonPress (BOOLEAN DetectSpecial)
{
@@ -143,21 +579,6 @@ _get_pause_exit_state (void)
return (InputState);
}
Uint16
GetUNICODEKey ()
{
if (kbdtail != kbdhead)
{
Uint16 ch;
ch = kbdbuf[kbdhead];
kbdhead = (kbdhead + 1) & (KBDBUFSIZE - 1);
return (ch);
}
return (0);
}
// Status: Unimplemented
INPUT_STATE
_get_serial_keyboard_state (INPUT_REF ref, INPUT_STATE InputState)
@@ -368,392 +789,4 @@ _get_joystick_state (INPUT_REF ref, INPUT_STATE InputState)
return (InputState);
}
void
FlushInput ()
{
kbdtail = kbdhead = 0;
}
void
ProcessKeyboardEvent(const SDL_Event *Event)
{
if(Event->key.keysym.sym == SDLK_BACKQUOTE)
{
exit(0);
}
else
{
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;
}
}
}
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);
}
}
}
//Status: Unimplemented
UNICODE
KBDToUNICODE (UNICODE SK_in)
//This one'll probably require a big table. Arg.
{
return (SK_in);
}
//Status: Ignored
BOOLEAN
UninitInput () // Looks like it'll be empty
{
BOOLEAN ret;
// printf("Unimplemented function activated: UninitInput()\n");
ret = TRUE;
return (ret);
}
// Status: Unimplemented
UNICODE
KeyHit () // Does this clear the top of a queue, or just read it?
{
int i;
for (i = 0; i < sizeof (KeyboardDown) / sizeof (KeyboardDown[0]); ++i)
{
if (KeyboardDown[i])
{
if (i == SDLK_RETURN)
return ('\n');
else if (i >= 256)
{
switch (i)
{
case SDLK_KP_ENTER:
return ('\n');
case SDLK_KP4:
case SDLK_LEFT:
return (SK_LF_ARROW);
case SDLK_KP6:
case SDLK_RIGHT:
return (SK_RT_ARROW);
case SDLK_KP8:
case SDLK_UP:
return (SK_UP_ARROW);
case SDLK_KP2:
case SDLK_DOWN:
return (SK_DN_ARROW);
case SDLK_KP7:
case SDLK_HOME:
return (SK_HOME);
case SDLK_KP9:
case SDLK_PAGEUP:
return (SK_PAGE_UP);
case SDLK_KP1:
case SDLK_END:
return (SK_END);
case SDLK_KP3:
case SDLK_PAGEDOWN:
return (SK_PAGE_DOWN);
case SDLK_KP0:
case SDLK_INSERT:
return (SK_INSERT);
case SDLK_KP_PERIOD:
case SDLK_DELETE:
return (SK_DELETE);
case SDLK_KP_PLUS:
return (SK_KEYPAD_PLUS);
case SDLK_KP_MINUS:
return (SK_KEYPAD_MINUS);
case SDLK_LSHIFT:
return (SK_LF_SHIFT);
case SDLK_RSHIFT:
return (SK_RT_SHIFT);
case SDLK_LCTRL:
case SDLK_RCTRL:
return (SK_CTL);
case SDLK_LALT:
case SDLK_RALT:
return (SK_ALT);
case SDLK_F1:
case SDLK_F2:
case SDLK_F3:
case SDLK_F4:
case SDLK_F5:
case SDLK_F6:
case SDLK_F7:
case SDLK_F8:
case SDLK_F9:
case SDLK_F10:
case SDLK_F11:
case SDLK_F12:
return ((UNICODE) ((i - SDLK_F1) + SK_F1));
}
continue;
}
return ((UNICODE) i);
}
}
return (0);
}
//Status: Unimplemented
int
KeyDown (UNICODE which_scan)
// This might use SK_* stuff, of just plain old chars
{
int i;
i = which_scan;
if (i == '\n')
{
if (KeyboardDown[SDLK_KP_ENTER])
return (1);
i = SDLK_RETURN;
}
else if (i >= 128)
{
switch (i)
{
case SK_LF_ARROW:
if (KeyboardDown[SDLK_KP4])
return (1);
i = SDLK_LEFT;
break;
case SK_RT_ARROW:
if (KeyboardDown[SDLK_KP6])
return (1);
i = SDLK_RIGHT;
break;
case SK_UP_ARROW:
if (KeyboardDown[SDLK_KP8])
return (1);
i = SDLK_UP;
break;
case SK_DN_ARROW:
if (KeyboardDown[SDLK_KP2])
return (1);
i = SDLK_DOWN;
break;
case SK_HOME:
if (KeyboardDown[SDLK_KP7])
return (1);
i = SDLK_HOME;
break;
case SK_PAGE_UP:
if (KeyboardDown[SDLK_KP9])
return (1);
i = SDLK_PAGEUP;
break;
case SK_END:
if (KeyboardDown[SDLK_KP1])
return (1);
i = SDLK_END;
break;
case SK_PAGE_DOWN:
if (KeyboardDown[SDLK_KP3])
return (1);
i = SDLK_PAGEDOWN;
break;
case SK_INSERT:
if (KeyboardDown[SDLK_KP0])
return (1);
i = SDLK_INSERT;
break;
case SK_DELETE:
if (KeyboardDown[SDLK_KP_PERIOD])
return (1);
i = SDLK_DELETE;
break;
case SK_KEYPAD_PLUS:
i = SDLK_KP_PLUS;
break;
case SK_KEYPAD_MINUS:
i = SDLK_KP_MINUS;
break;
case SK_LF_SHIFT:
i = SDLK_LSHIFT;
break;
case SK_RT_SHIFT:
i = SDLK_RSHIFT;
break;
case SK_CTL:
if (KeyboardDown[SDLK_LCTRL])
return (1);
i = SDLK_RCTRL;
break;
case SK_ALT:
if (KeyboardDown[SDLK_LALT])
return (1);
i = SDLK_RALT;
break;
case SK_F1:
case SK_F2:
case SK_F3:
case SK_F4:
case SK_F5:
case SK_F6:
case SK_F7:
case SK_F8:
case SK_F9:
case SK_F10:
case SK_F11:
case SK_F12:
i = (i - SK_F1) + SDLK_F1;
}
}
return (KeyboardDown[i]);
}
#endif
-12
View File
@@ -16,18 +16,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#ifndef INPUT_H
#define INPUT_H
+1 -1
View File
@@ -13,5 +13,5 @@ INCLUDES = @SDL_CFLAGS@ @SMPEG_CFLAGS@ \
noinst_LTLIBRARIES = libsound.la
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
noinst_HEADERS = play.h redbook.h sndintrn.h trackplayer.h sound_common.h
+4 -1
View File
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef SOUNDMODULE_SDL
#include "libs/strings/strintrn.h"
#include "libs/sound/sndintrn.h"
@@ -26,6 +26,9 @@
#include <fcntl.h>
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound_common.h"
#include "SDL_mixer.h"
MEM_HANDLE
_GetSoundBankData (FILE *fp, DWORD length)
+3 -1
View File
@@ -16,12 +16,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef SOUNDMODULE_SDL
#include "libs/sound/sndintrn.h"
#include "timlib.h"
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound_common.h"
#include "SDL_mixer.h"
static MUSIC_REF curMusicRef;
+46 -12
View File
@@ -16,20 +16,54 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef SOUNDMODULE_SDL
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound_common.h"
#include "SDL_mixer.h"
int
TFB_InitSound (int driver, int flags, int frequency)
{
char SoundcardName[256];
int audio_rate,audio_channels;
Uint16 audio_format;
SDL_version compile_version;
if ((SDL_InitSubSystem(SDL_INIT_AUDIO)) == -1)
{
printf("Couldn't initialize audio subsystem: %s\n", SDL_GetError());
exit(-1);
}
if (Mix_OpenAudio(frequency, 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);
return 0;
}
//Status: Unimplemented
void
+4 -13
View File
@@ -16,22 +16,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#if defined (GFXMODULE_SDL_OPENGL) || defined (GFXMODULE_SDL_PURE)
#ifdef SOUNDMODULE_SDL
#include "libs/graphics/sdl/sdl_common.h"
#include "libs/sound/sound_common.h"
#include "libs/sound/trackplayer.h"
#include "SDL_mixer.h"
#define VOICE_CHANNEL 0
@@ -17,6 +17,7 @@
*/
#include "libs/graphics/gfx_common.h"
#include "libs/sound/sound_common.h"
extern int _music_volume;
+54 -16
View File
@@ -16,25 +16,63 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/****************************************
Star Control II: 3DO => SDL Port
Copyright Toys for Bob, 2002
Programmer: Chris Nelson
*****************************************/
#include "libs/graphics/gfx_common.h"
#include "libs/sound/sound_common.h"
#include "libs/input/input_common.h"
int
main(int argc, char *argv[])
main (int argc, char *argv[])
{
// TODO: Currently every graphics module has to implement its own main function.
// Should be divided later into smaller parts with common code.
int i;
int gfxdriver = TFB_GFXDRIVER_SDL_PURE;
int gfxflags = 0;
int width = 640, height = 480, bpp = 16;
int frequency = 44100;
return Main(argc,argv);
// TODO: proper commandline parser, this is just a quick hack
for (i=1;i<argc;++i)
{
if (!strcmp(argv[i],"-res"))
{
i++;
sscanf(argv[i],"%dx%d",&width,&height);
}
else if (!strcmp(argv[i],"-bpp"))
{
i++;
sscanf(argv[i],"%d",&bpp);
}
else if (!strcmp(argv[i],"-fullscreen"))
{
gfxflags |= TFB_GFXFLAGS_FULLSCREEN;
}
else if (!strcmp(argv[i],"-opengl"))
{
gfxdriver = TFB_GFXDRIVER_SDL_OPENGL;
gfxflags |= TFB_GFXFLAGS_BILINEAR_FILTERING;
}
else if (!strcmp(argv[i],"-linear"))
{
gfxflags &= ~TFB_GFXFLAGS_BILINEAR_FILTERING;
}
else if (!strcmp(argv[i],"-frequency"))
{
i++;
sscanf(argv[i],"%d",&frequency);
}
}
TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);
TFB_InitSound (TFB_SOUNDDRIVER_SDL, 0, frequency);
TFB_InitInput (TFB_INPUTDRIVER_SDL, 0);
TFB_CreateGamePlayThread ();
for (;;)
{
TFB_ProcessEvents ();
TFB_FlushGraphics ();
}
return 0;
}