Removed some old files.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@17 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,304 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
|
||||
Star Control II: 3DO => SDL Port
|
||||
|
||||
Copyright Toys for Bob, 2002
|
||||
|
||||
3DO_wrapper.h programmer: Chris Nelson
|
||||
|
||||
*****************************************/
|
||||
|
||||
//This file will supply every function that Starcon2 expects of the 3DO, via SDL.
|
||||
|
||||
#ifndef THREEDO_WRAPPER_H
|
||||
#define THREEDO_WRAPPER_H
|
||||
|
||||
#include "./gl.h"
|
||||
#include "SDL.h"
|
||||
#include "smpeg.h"
|
||||
#include "SDL_mixer.h"
|
||||
#include "SDL_thread.h"
|
||||
#include "SDL_image.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "starcon.h"
|
||||
#include "libs/gfxlib.h"
|
||||
#include "libs/vidlib.h"
|
||||
#include <math.h>
|
||||
|
||||
//#defines
|
||||
|
||||
#define Stream FILE
|
||||
#define MEMTYPE_ANY 1
|
||||
|
||||
//SDL Stuff
|
||||
|
||||
void InitSDL();
|
||||
int Starcon2Main (void *);
|
||||
|
||||
//Graphics Stuff
|
||||
|
||||
void LoadIntoExtraScreen (PRECT r);
|
||||
void DrawFromExtraScreen (PRECT r);
|
||||
void SetGraphicStrength (int numer, int denom);
|
||||
void SetGraphicGrabOther (int grab_other);
|
||||
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;
|
||||
|
||||
//Image + Drawing Stuff
|
||||
|
||||
typedef struct tfb_image
|
||||
{
|
||||
SDL_Surface *SurfaceSDL;
|
||||
Uint32 glTexture;
|
||||
float glTextureW;
|
||||
float glTextureH;
|
||||
} TFB_Image;
|
||||
|
||||
TFB_Image *TFB_LoadImage (SDL_Surface *img);
|
||||
void TFB_FreeImage (TFB_Image *img);
|
||||
|
||||
enum
|
||||
{
|
||||
TFB_DRAWCOMMANDTYPE_LINE,
|
||||
TFB_DRAWCOMMANDTYPE_RECTANGLE,
|
||||
TFB_DRAWCOMMANDTYPE_IMAGE,
|
||||
TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER,
|
||||
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORENABLE,
|
||||
TFB_DRAWCOMMANDTYPE_SCISSORDISABLE,
|
||||
TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER,
|
||||
TFB_DRAWCOMMANDTYPE_DELETEIMAGE,
|
||||
};
|
||||
|
||||
typedef struct tfb_drawcommand
|
||||
{
|
||||
int Type;
|
||||
int x;
|
||||
int y;
|
||||
int w;
|
||||
int h;
|
||||
TFB_Image *image; // only used for image draw type
|
||||
int r; // RGB only used for rect draw types
|
||||
int g;
|
||||
int b;
|
||||
int Qualifier;
|
||||
} TFB_DrawCommand;
|
||||
|
||||
// Queue Stuff
|
||||
|
||||
typedef struct tfb_drawcommandnode
|
||||
{
|
||||
TFB_DrawCommand *Command;
|
||||
void *Ahead;
|
||||
void *Behind;
|
||||
} TFB_DrawCommandNode;
|
||||
|
||||
typedef struct tfb_drawcommandqueue
|
||||
{
|
||||
TFB_DrawCommandNode *Front;
|
||||
TFB_DrawCommandNode *Back;
|
||||
int Size;
|
||||
} TFB_DrawCommandQueue;
|
||||
|
||||
TFB_DrawCommandQueue *TFB_DrawCommandQueue_Create ();
|
||||
|
||||
void TFB_DrawCommandQueue_Push (TFB_DrawCommandQueue* myQueue,
|
||||
TFB_DrawCommand* Command);
|
||||
|
||||
TFB_DrawCommand *TFB_DrawCommandQueue_Pop (TFB_DrawCommandQueue* myQueue);
|
||||
|
||||
void TFB_DeallocateDrawCommand (TFB_DrawCommand* Command);
|
||||
|
||||
// End Queue Stuff
|
||||
|
||||
extern TFB_DrawCommandQueue *DrawCommandQueue;
|
||||
|
||||
// The TFB_Enqueue* functions are necessary, because only the main thread can
|
||||
// draw to the OpenGL window.
|
||||
void TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand);
|
||||
void TFB_FlushGraphics (); //Only call from main thread!!
|
||||
|
||||
//Sound Stuff
|
||||
|
||||
//Track player Stuff
|
||||
|
||||
void ResumeTrack();
|
||||
void PauseTrack();
|
||||
COUNT PlayingTrack();
|
||||
void JumpTrack(int abort);
|
||||
void FastForward();
|
||||
void FastReverse();
|
||||
void StopTrack();
|
||||
void SpliceTrack(UNICODE *filespec, UNICODE *textspec);
|
||||
int GetSoundData(char *data);
|
||||
int GetSoundInfo (int *len, int *offs);
|
||||
|
||||
extern SEMAPHORE _MemorySem;
|
||||
// Non-Volitile RAM Stuff
|
||||
|
||||
// CD Stuff
|
||||
|
||||
int CD_get_drive(); // Returns 0
|
||||
unsigned int CD_get_volsize(); // Returns 0
|
||||
|
||||
// IO Stuff
|
||||
|
||||
// Multi-tasking Stuff
|
||||
|
||||
// CCB Stuff
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ccb_Flags;
|
||||
int ccb_HDX;
|
||||
int ccb_HDY;
|
||||
int ccb_HDDX;
|
||||
int ccb_HDDY;
|
||||
int ccb_VDX;
|
||||
int ccb_VDY;
|
||||
int ccb_PIXC;
|
||||
void* ccb_SourcePtr;
|
||||
unsigned int* ccb_PLUTPtr;
|
||||
int ccb_Width;
|
||||
int ccb_Height;
|
||||
int ccb_PRE0;
|
||||
int ccb_PRE1;
|
||||
void* ccb_NextPtr;
|
||||
int ccb_XPos;
|
||||
int ccb_YPos;
|
||||
} CCB;
|
||||
|
||||
// Geez, I hope these #defines work out...
|
||||
|
||||
#define CCB_SPABS (1 << 0)
|
||||
#define CCB_PPABS (1 << 1)
|
||||
#define CCB_YOXY (1 << 2)
|
||||
#define CCB_ACW (1 << 3)
|
||||
#define CCB_ACCW (1 << 4)
|
||||
#define CCB_LDSIZE (1 << 5)
|
||||
#define CCB_CCBPRE (1 << 6)
|
||||
#define CCB_LDPRS (1 << 7)
|
||||
#define CCB_LDPPMP (1 << 8)
|
||||
#define CCB_ACE (1 << 9)
|
||||
#define CCB_LCE (1 << 10)
|
||||
#define CCB_PLUTPOS (1 << 11)
|
||||
#define CCB_BGND (1 << 12)
|
||||
#define CCB_NPABS (1 << 13)
|
||||
#define CCB_PACKED (1 << 14)
|
||||
#define CCB_LDPLUT (1 << 15)
|
||||
#define CCB_LAST (1 << 16)
|
||||
#define CCB_USEAV (1 << 17)
|
||||
|
||||
#define PPMP_0_SHIFT 0 // ?
|
||||
#define PPMP_1_SHIFT 1 // ?
|
||||
|
||||
#define PPMPC_MS_PIN (1 << 0)
|
||||
#define PPMPC_MS_CCB (1 << 1)
|
||||
#define PPMPC_SF_8 (1 << 2)
|
||||
#define PPMPC_MF_8 (1 << 3)
|
||||
#define PPMPC_MF_SHIFT 3
|
||||
#define PPMPC_1S_PDC (1 << 4)
|
||||
#define PPMPC_2S_CFBD (1 << 5)
|
||||
#define PPMPC_2D_1 (1 << 6)
|
||||
#define PPMPC_MF_6 (1 << 7)
|
||||
#define PPMPC_2S_0 (1 << 8)
|
||||
#define PPMPC_1S_CFBD (1 << 9)
|
||||
#define PPMPC_MF_2 (1 << 10)
|
||||
#define PPMPC_SF_2 (1 << 11)
|
||||
#define PPMPC_2S_PDC (1 << 12)
|
||||
#define PPMPC_MF_1 (1 << 13)
|
||||
#define PPMPC_SF_16 (1 << 14)
|
||||
|
||||
#define PRE0_LITERAL (1 << 0)
|
||||
#define PRE0_VCNT_PREFETCH (1 << 1)
|
||||
#define PRE0_VCNT_SHIFT 1
|
||||
#define PRE0_VCNT_MASK (1 << 1)
|
||||
#define PRE0_BPP_8 (1 << 2)
|
||||
#define PRE0_BPP_SHIFT 2
|
||||
#define PRE0_BPP_16 (1 << 3)
|
||||
#define PRE0_BGND (1 << 4)
|
||||
#define PRE0_LINEAR (1 << 5)
|
||||
#define PRE0_SKIPX_MASK 0
|
||||
#define PRE0_SKIPX_SHIFT 0
|
||||
#define PRE0_BPP_1 (1 << 6)
|
||||
#define PRE1_TLLSB_PDC0 (1 << 7)
|
||||
#define PRE1_TLHPCNT_PREFETCH (1 << 7)
|
||||
#define PRE1_TLHPCNT_SHIFT 7
|
||||
#define PRE1_TLHPCNT_MASK (1 << 7)
|
||||
#define PRE1_WOFFSET_PREFETCH (1 << 8)
|
||||
#define PRE1_WOFFSET10_SHIFT (1 << 9)
|
||||
#define PRE1_WOFFSET8_SHIFT (1 << 10)
|
||||
|
||||
// Cel Stuff
|
||||
|
||||
void add_cel(CCB* cel);
|
||||
void add_cels(CCB* first, CCB* last);
|
||||
void myMapCel(CCB* myCCB, POINT Points[4]);
|
||||
int _ThreeDO_batch_cels(int unknown);
|
||||
CCB *ParseCel(CCB*,unsigned int);
|
||||
|
||||
// Misc Stuff
|
||||
|
||||
#define SqrtF16 sqrt
|
||||
#define Atan2F16 atan2
|
||||
#define CosF16 cos
|
||||
#define SinF16 sin
|
||||
|
||||
#define CelData void
|
||||
|
||||
// Unknown Stuff
|
||||
|
||||
void OpenMathFolio();
|
||||
|
||||
extern int ScreenWidth;
|
||||
extern int ScreenHeight;
|
||||
extern int ScreenWidthActual;
|
||||
extern int ScreenHeightActual;
|
||||
|
||||
extern Uint8 KeyboardDown[512];
|
||||
|
||||
extern UBYTE ControlA;
|
||||
extern UBYTE ControlB;
|
||||
extern UBYTE ControlC;
|
||||
extern UBYTE ControlX;
|
||||
extern UBYTE ControlStart;
|
||||
extern UBYTE ControlLeftShift;
|
||||
extern UBYTE ControlRightShift;
|
||||
|
||||
extern void *HMalloc (Uint32 size);
|
||||
extern void HFree (void *p);
|
||||
extern void *HCalloc (Uint32 size);
|
||||
extern void *HRealloc (void *p, Uint32 size);
|
||||
|
||||
extern int TFB_DEBUG_HALT;
|
||||
|
||||
#endif // THREEDO_WRAPPER_H
|
||||
@@ -1,45 +0,0 @@
|
||||
#ifdef WIN32
|
||||
|
||||
/* To avoid including windows.h,
|
||||
Win32's <GL/gl.h> needs APIENTRY and WINGDIAPI defined properly. */
|
||||
|
||||
#pragma warning (disable:4244) /* Disable bogus conversion warnings. */
|
||||
|
||||
#ifndef APIENTRY
|
||||
#define GLUT_APIENTRY_DEFINED
|
||||
#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
|
||||
#define APIENTRY __stdcall
|
||||
#else
|
||||
#define APIENTRY
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is from Win32's <winnt.h> */
|
||||
#ifndef CALLBACK
|
||||
#if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
|
||||
#define CALLBACK __stdcall
|
||||
#else
|
||||
#define CALLBACK
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is from Win32's <wingdi.h> and <winnt.h> */
|
||||
#ifndef WINGDIAPI
|
||||
#define GLUT_WINGDIAPI_DEFINED
|
||||
#define WINGDIAPI __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
/* This is from Win32's <ctype.h> */
|
||||
#ifndef _WCHAR_T_DEFINED
|
||||
typedef unsigned short wchar_t;
|
||||
#define _WCHAR_T_DEFINED
|
||||
#endif
|
||||
|
||||
#include "GL/glu.h"
|
||||
|
||||
#else /* !defined(WIN32) */
|
||||
|
||||
#include "GL/glu.h"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,417 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
#include "gfxintrn.h"
|
||||
#include "SDL_wrapper.h"
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
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))
|
||||
{
|
||||
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)
|
||||
break;
|
||||
}
|
||||
#ifdef WIN32
|
||||
_setmode (fileno (fp), omode);
|
||||
#endif
|
||||
|
||||
Drawable = 0;
|
||||
if (cel_ct && (Drawable = AllocDrawable (cel_ct, 0)))
|
||||
{
|
||||
DRAWABLEPTR DrawablePtr;
|
||||
|
||||
if ((DrawablePtr = LockDrawable (Drawable)) == 0)
|
||||
{
|
||||
while (cel_ct--)
|
||||
SDL_FreeSurface (img[cel_ct]);
|
||||
|
||||
mem_release (Drawable);
|
||||
Drawable = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
FRAMEPTR FramePtr;
|
||||
|
||||
DrawablePtr->hDrawable = GetDrawableHandle (Drawable);
|
||||
TYPE_SET (DrawablePtr->FlagsAndIndex,
|
||||
(DRAWABLE_TYPE)ROM_DRAWABLE << FTYPE_SHIFT);
|
||||
INDEX_SET (DrawablePtr->FlagsAndIndex, cel_ct - 1);
|
||||
|
||||
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)
|
||||
{
|
||||
int cel_ct;
|
||||
FRAMEPTR FramePtr;
|
||||
|
||||
cel_ct = INDEX_GET (DrawablePtr->FlagsAndIndex);
|
||||
|
||||
FramePtr = &DrawablePtr->Frame[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
FRAMEPTR FramePtr;
|
||||
|
||||
FontPtr->FontRef = FontRef;
|
||||
FontPtr->Leading = 0;
|
||||
FramePtr = &FontPtr->CharDesc[cel_ct];
|
||||
while (--FramePtr, cel_ct--)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UnlockFont (handle);
|
||||
mem_release (handle);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
#include "inpintrn.h"
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateSerialKeyboardDevice (void)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
if ((InputDevice = AllocInputDevice ()) != (INPUT_DEVICE)NULL_PTR)
|
||||
{
|
||||
INPUT_DESCPTR InputPtr;
|
||||
|
||||
if ((InputPtr =
|
||||
LockInputDevice (InputDevice)) == (INPUT_DESCPTR)NULL_PTR)
|
||||
{
|
||||
FreeInputDevice (InputDevice);
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetInputDeviceHandle (InputPtr, InputDevice);
|
||||
SetInputDeviceInputFunc (InputPtr, _get_serial_keyboard_state);
|
||||
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
}
|
||||
|
||||
return (InputDevice);
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateJoystickKeyboardDevice (UNICODE lfkey, UNICODE rtkey, UNICODE
|
||||
topkey, UNICODE botkey, UNICODE but1key, UNICODE but2key, UNICODE
|
||||
but3key, UNICODE shift1key, UNICODE shift2key)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
if ((InputDevice = AllocInputDevice ()) != (INPUT_DEVICE)NULL_PTR)
|
||||
{
|
||||
INPUT_DESCPTR InputPtr;
|
||||
|
||||
if ((InputPtr =
|
||||
LockInputDevice (InputDevice)) == (INPUT_DESCPTR)NULL_PTR)
|
||||
{
|
||||
FreeInputDevice (InputDevice);
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetInputDeviceHandle (InputPtr, InputDevice);
|
||||
SetInputDeviceInputFunc (InputPtr, _get_joystick_keyboard_state);
|
||||
SetInputDeviceKeyEquivalents (InputPtr,
|
||||
lfkey, rtkey, topkey, botkey,
|
||||
but1key, but2key, but3key,
|
||||
shift1key, shift2key);
|
||||
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
}
|
||||
|
||||
return (InputDevice);
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateJoystickDevice (COUNT port)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
if (!_joystick_port_active (port))
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
else if ((InputDevice = AllocInputDevice ()) != (INPUT_DEVICE)NULL_PTR)
|
||||
{
|
||||
INPUT_DESCPTR InputPtr;
|
||||
|
||||
if ((InputPtr =
|
||||
LockInputDevice (InputDevice)) == (INPUT_DESCPTR)NULL_PTR)
|
||||
{
|
||||
FreeInputDevice (InputDevice);
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetInputDeviceHandle (InputPtr, InputDevice);
|
||||
SetInputDeviceInputFunc (InputPtr, _get_joystick_state);
|
||||
SetInputDeviceJoystickPort (InputPtr, port);
|
||||
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
}
|
||||
|
||||
return (InputDevice);
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateInternalDevice (INPUT_STATE (*input_func) (INPUT_REF InputRef,
|
||||
INPUT_STATE InputState))
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
if (input_func == NULL_PTR)
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
else if ((InputDevice = AllocInputDevice ()) != (INPUT_DEVICE)NULL_PTR)
|
||||
{
|
||||
INPUT_DESCPTR InputPtr;
|
||||
|
||||
if ((InputPtr =
|
||||
LockInputDevice (InputDevice)) == (INPUT_DESCPTR)NULL_PTR)
|
||||
{
|
||||
FreeInputDevice (InputDevice);
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetInputDeviceHandle (InputPtr, InputDevice);
|
||||
SetInputDeviceInputFunc (InputPtr, input_func);
|
||||
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
}
|
||||
|
||||
return (InputDevice);
|
||||
}
|
||||
|
||||
INPUT_REF
|
||||
CaptureInputDevice (INPUT_DEVICE InputDevice)
|
||||
{
|
||||
if (InputDevice != (INPUT_DEVICE)NULL_PTR)
|
||||
return ((INPUT_REF)LockInputDevice (InputDevice));
|
||||
|
||||
return ((INPUT_REF)NULL_PTR);
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
ReleaseInputDevice (INPUT_REF InputRef)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
if (InputRef == (INPUT_REF)NULL_PTR)
|
||||
InputDevice = (INPUT_DEVICE)NULL_PTR;
|
||||
else
|
||||
{
|
||||
InputDevice = GetInputDeviceHandle (InputRef);
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
|
||||
return (InputDevice);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DestroyInputDevice (INPUT_DEVICE InputDevice)
|
||||
{
|
||||
if (InputDevice != (INPUT_DEVICE)NULL_PTR)
|
||||
return (FreeInputDevice (InputDevice));
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
INPUT_STATE
|
||||
GetInputState (INPUT_REF InputRef)
|
||||
{
|
||||
if (InputRef == 0)
|
||||
return (_get_pause_exit_state ());
|
||||
else
|
||||
return ((*GetInputDeviceInputFunc (InputRef))
|
||||
(InputRef, _get_pause_exit_state ()));
|
||||
}
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
#include "libs/strings/strintrn.h"
|
||||
#include "sndintrn.h"
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "SDL_wrapper.h"
|
||||
|
||||
MEM_HANDLE
|
||||
_GetSoundBankData (FILE *fp, DWORD length)
|
||||
{
|
||||
#ifdef WIN32
|
||||
int omode;
|
||||
#endif
|
||||
int snd_ct, n;
|
||||
DWORD opos;
|
||||
char CurrentLine[1024], filename[1024];
|
||||
#define MAX_FX 256
|
||||
Mix_Chunk *sndfx[MAX_FX];
|
||||
STRING_TABLE Snd;
|
||||
|
||||
opos = ftell (fp);
|
||||
|
||||
{
|
||||
char *s1, *s2;
|
||||
extern char *_cur_resfile_name;
|
||||
|
||||
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
|
||||
snd_ct = 0;
|
||||
while (fgets (CurrentLine, sizeof (CurrentLine), fp) && snd_ct < MAX_FX)
|
||||
{
|
||||
if
|
||||
(
|
||||
sscanf(CurrentLine, "%s", &filename[n]) == 1 &&
|
||||
(sndfx[snd_ct] = Mix_LoadWAV (filename))
|
||||
)
|
||||
{
|
||||
++snd_ct;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("_GetSoundBankData: Bad file!\n");
|
||||
}
|
||||
|
||||
if (ftell (fp) - opos >= length)
|
||||
break;
|
||||
}
|
||||
#ifdef WIN32
|
||||
_setmode (fileno (fp), omode);
|
||||
#endif
|
||||
|
||||
Snd = 0;
|
||||
if (snd_ct && (Snd = AllocStringTable (
|
||||
sizeof (STRING_TABLE_DESC)
|
||||
+ (sizeof (DWORD) * snd_ct)
|
||||
+ (sizeof (sndfx[0]) * snd_ct)
|
||||
)))
|
||||
{
|
||||
STRING_TABLEPTR fxTab;
|
||||
|
||||
LockStringTable (Snd, &fxTab);
|
||||
if (fxTab == 0)
|
||||
{
|
||||
while (snd_ct--)
|
||||
Mix_FreeChunk (sndfx[snd_ct]);
|
||||
FreeStringTable (Snd);
|
||||
Snd = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD *offs, StringOffs;
|
||||
|
||||
fxTab->StringCount = snd_ct;
|
||||
fxTab->flags = 0;
|
||||
offs = fxTab->StringOffsets;
|
||||
StringOffs = sizeof (STRING_TABLE_DESC) + (sizeof (DWORD) * snd_ct);
|
||||
memcpy ((BYTE *)fxTab + StringOffs, sndfx, sizeof (sndfx[0]) * snd_ct);
|
||||
do
|
||||
{
|
||||
*offs++ = StringOffs;
|
||||
StringOffs += sizeof (sndfx[0]);
|
||||
} while (snd_ct--);
|
||||
UnlockStringTable (Snd);
|
||||
}
|
||||
}
|
||||
|
||||
return ((MEM_HANDLE)Snd);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
_ReleaseSoundBankData (MEM_HANDLE Snd)
|
||||
{
|
||||
STRING_TABLEPTR fxTab;
|
||||
|
||||
LockStringTable (Snd, &fxTab);
|
||||
if (fxTab)
|
||||
{
|
||||
int snd_ct;
|
||||
Mix_Chunk **sptr;
|
||||
|
||||
snd_ct = fxTab->StringCount;
|
||||
sptr = (Mix_Chunk **)((BYTE *)fxTab + fxTab->StringOffsets[0]);
|
||||
while (snd_ct--)
|
||||
{
|
||||
Mix_FreeChunk (*sptr);
|
||||
*sptr++ = 0;
|
||||
}
|
||||
UnlockStringTable (Snd);
|
||||
FreeStringTable (Snd);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
MEM_HANDLE
|
||||
_GetMusicData (FILE *fp, DWORD length)
|
||||
{
|
||||
MEM_HANDLE h;
|
||||
extern char *_cur_resfile_name;
|
||||
|
||||
h = 0;
|
||||
if (_cur_resfile_name && (h = AllocMusicData (sizeof (void *))))
|
||||
{
|
||||
Mix_Music **pmus;
|
||||
|
||||
LockMusicData (h, &pmus);
|
||||
if (pmus == 0 || (*pmus = Mix_LoadMUS (_cur_resfile_name)) == 0)
|
||||
{
|
||||
UnlockMusicData (h);
|
||||
mem_release (h);
|
||||
h = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
}
|
||||
UnlockMusicData (h);
|
||||
}
|
||||
|
||||
(void) fp; /* satisfy compiler (unused parameter) */
|
||||
(void) length; /* satisfy compiler (unused parameter) */
|
||||
return (h);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
_ReleaseMusicData (MEM_HANDLE handle)
|
||||
{
|
||||
Mix_Music **pmus;
|
||||
|
||||
LockMusicData (handle, &pmus);
|
||||
if (pmus == 0)
|
||||
return (FALSE);
|
||||
|
||||
Mix_FreeMusic (*pmus);
|
||||
|
||||
UnlockMusicData (handle);
|
||||
mem_release (handle);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DestroySound(SOUND_REF target)
|
||||
{
|
||||
return (_ReleaseSoundBankData (target));
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
#include "sndintrn.h"
|
||||
#include "timlib.h"
|
||||
|
||||
#include "SDL_wrapper.h"
|
||||
|
||||
static MUSIC_REF curMusicRef;
|
||||
|
||||
void
|
||||
PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
|
||||
{
|
||||
Mix_Music **pmus;
|
||||
|
||||
LockMusicData (MusicRef, &pmus);
|
||||
if (pmus)
|
||||
{
|
||||
PLRStop (curMusicRef);
|
||||
|
||||
curMusicRef = MusicRef;
|
||||
Mix_PlayMusic (*pmus, Continuous ? -1 : 1);
|
||||
}
|
||||
(void) Priority; /* Satisfy compiler because of unused variable */
|
||||
}
|
||||
|
||||
void
|
||||
PLRStop (MUSIC_REF MusicRef)
|
||||
{
|
||||
if (MusicRef == curMusicRef || MusicRef == (MUSIC_REF)~0)
|
||||
{
|
||||
Mix_HaltMusic ();
|
||||
|
||||
UnlockMusicData (curMusicRef);
|
||||
curMusicRef = 0;
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
PLRPlaying (MUSIC_REF MusicRef)
|
||||
{
|
||||
if (curMusicRef && (MusicRef == curMusicRef || MusicRef == (MUSIC_REF)~0))
|
||||
{
|
||||
if (Mix_PlayingMusic ())
|
||||
return (TRUE);
|
||||
PLRStop (curMusicRef);
|
||||
}
|
||||
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
PLRPause (MUSIC_REF MusicRef)
|
||||
{
|
||||
if (MusicRef == curMusicRef || MusicRef == (MUSIC_REF)~0)
|
||||
{
|
||||
// Mix_FadeOutMusic (1 * 1000);
|
||||
Mix_PauseMusic ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PLRResume (MUSIC_REF MusicRef)
|
||||
{
|
||||
if (MusicRef == curMusicRef || MusicRef == (MUSIC_REF)~0)
|
||||
{
|
||||
// Mix_FadeInMusic (1 * 1000);
|
||||
Mix_ResumeMusic ();
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
DestroyMusic (MUSIC_REF MusicRef)
|
||||
{
|
||||
return (FreeMusicData (MusicRef));
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
//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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
|
||||
Star Control II: 3DO => SDL Port
|
||||
|
||||
Copyright Toys for Bob, 2002
|
||||
|
||||
starcon2.cpp programmer: Chris Nelson
|
||||
|
||||
*****************************************/
|
||||
|
||||
#include "SDL_wrapper.h"
|
||||
|
||||
#define VOICE_CHANNEL 0
|
||||
|
||||
extern int do_subtitles (UNICODE *pStr);
|
||||
|
||||
static int tct, tcur, no_voice;
|
||||
#define MAX_CLIPS 50
|
||||
static struct
|
||||
{
|
||||
int text_spliced;
|
||||
Mix_Chunk *chunk;
|
||||
UNICODE *text;
|
||||
} track_clip[MAX_CLIPS];
|
||||
|
||||
void
|
||||
JumpTrack (int abort)
|
||||
{
|
||||
Mix_ChannelFinished (0);
|
||||
|
||||
if (track_clip[tcur].chunk)
|
||||
Mix_HaltChannel (VOICE_CHANNEL);
|
||||
|
||||
no_voice = 1;
|
||||
do_subtitles ((void *)~0);
|
||||
|
||||
if (abort)
|
||||
tcur = tct;
|
||||
}
|
||||
|
||||
static void
|
||||
advance_track (int channel_finished)
|
||||
{
|
||||
if (channel_finished <= VOICE_CHANNEL)
|
||||
{
|
||||
if (channel_finished == VOICE_CHANNEL)
|
||||
++tcur;
|
||||
if (tcur < tct)
|
||||
{
|
||||
Mix_PlayChannel (VOICE_CHANNEL, track_clip[tcur].chunk, 0);
|
||||
do_subtitles (0);
|
||||
}
|
||||
else if (channel_finished == VOICE_CHANNEL)
|
||||
{
|
||||
--tcur;
|
||||
no_voice = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ResumeTrack ()
|
||||
{
|
||||
if (tcur < tct)
|
||||
{
|
||||
if (Mix_Playing /* Mix_Paused */ (VOICE_CHANNEL))
|
||||
Mix_Resume (VOICE_CHANNEL);
|
||||
else if (!no_voice)
|
||||
{
|
||||
if (tcur == 0)
|
||||
Mix_ChannelFinished (advance_track);
|
||||
advance_track (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
COUNT
|
||||
PlayingTrack ()
|
||||
{
|
||||
if (tcur < tct)
|
||||
{
|
||||
if (do_subtitles (track_clip[tcur].text)
|
||||
|| (no_voice && ++tcur < tct && do_subtitles (0)))
|
||||
return (tcur + 1);
|
||||
else if (track_clip[tcur].chunk)
|
||||
return (Mix_Playing (VOICE_CHANNEL) ? (COUNT)(tcur + 1) : 0);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
StopTrack ()
|
||||
{
|
||||
Mix_ChannelFinished (0);
|
||||
Mix_HaltChannel (VOICE_CHANNEL);
|
||||
|
||||
while (tct--)
|
||||
{
|
||||
if (track_clip[tct].text_spliced)
|
||||
{
|
||||
track_clip[tct].text_spliced = 0;
|
||||
HFree (track_clip[tct].text);
|
||||
track_clip[tct].text = 0;
|
||||
}
|
||||
if (track_clip[tct].chunk)
|
||||
{
|
||||
Mix_FreeChunk (track_clip[tct].chunk);
|
||||
track_clip[tct].chunk = 0;
|
||||
}
|
||||
}
|
||||
tct = tcur = 0;
|
||||
no_voice = 0;
|
||||
do_subtitles (0);
|
||||
}
|
||||
|
||||
void
|
||||
SpliceTrack (UNICODE *TrackName, UNICODE *TrackText)
|
||||
{
|
||||
if (TrackText)
|
||||
{
|
||||
if (TrackName == 0)
|
||||
{
|
||||
if (tct)
|
||||
{
|
||||
int slen1, slen2;
|
||||
UNICODE *oTT;
|
||||
|
||||
oTT = track_clip[tct - 1].text;
|
||||
slen1 = wstrlen (oTT);
|
||||
slen2 = wstrlen (TrackText);
|
||||
if (track_clip[tct - 1].text_spliced)
|
||||
track_clip[tct - 1].text = HRealloc (oTT, slen1 + slen2 + 1);
|
||||
else
|
||||
{
|
||||
track_clip[tct - 1].text = HMalloc (slen1 + slen2 + 1);
|
||||
wstrcpy (track_clip[tct - 1].text, oTT);
|
||||
track_clip[tct - 1].text_spliced = 1;
|
||||
}
|
||||
wstrcpy (&track_clip[tct - 1].text[slen1], TrackText);
|
||||
}
|
||||
}
|
||||
else if (tct < MAX_CLIPS)
|
||||
{
|
||||
track_clip[tct].text = TrackText;
|
||||
track_clip[tct].chunk = Mix_LoadWAV (TrackName);
|
||||
track_clip[tct].text_spliced = 0;
|
||||
++tct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PauseTrack ()
|
||||
{
|
||||
if (tcur < tct && track_clip[tcur].chunk)
|
||||
Mix_Pause (VOICE_CHANNEL);
|
||||
}
|
||||
|
||||
void
|
||||
FastReverse ()
|
||||
{
|
||||
JumpTrack (0);
|
||||
no_voice = 0;
|
||||
tcur = 0;
|
||||
ResumeTrack ();
|
||||
}
|
||||
|
||||
void
|
||||
FastForward ()
|
||||
{
|
||||
JumpTrack (0);
|
||||
// no_voice = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user