diff --git a/sc2/src/SDL_wrapper.c b/sc2/src/SDL_wrapper.c deleted file mode 100644 index b840a1db5..000000000 --- a/sc2/src/SDL_wrapper.c +++ /dev/null @@ -1,1953 +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.cpp programmer: Chris Nelson - -*******************************************/ - -// - -#include "libs/graphics/gfxintrn.h" -#include "libs/input/inpintrn.h" -#include "SDL_wrapper.h" - -//#if SDL_BYTEORDER == SDL_BIG_ENDIAN - -#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) -DWORD* _varPLUTs; //Not a function -PDISPLAY_INTERFACE _pCurDisplay; //Not a function. Probably has to be initialized... - -void (*mask_func_array[]) - (PRECT pClipRect, PRIMITIVEPTR PrimPtr) - = { 0 }; - -//Status: Implemented! -DWORD -GetTimeCounter () //I wonder if it's ms, ticks, or seconds... -{ - DWORD ret; - - ret = (DWORD) (SDL_GetTicks () * ONE_SECOND / 1000.0); - return (ret); -} - -void -BatchGraphics (void) -{ -} - -void -UnbatchGraphics (void) -{ -} - -//Status: Unimplemented -DWORD -XFormColorMap (COLORMAPPTR colormap, SIZE time) - // Not sure what the time's supposed to mean... -{ - // printf ("Unimplemented function activated: XFormColorMap()\n"); - return (GetTimeCounter () + time); -} - -static volatile int continuity_break; - -void -FlushGraphics (void) -{ - continuity_break = 1; -} - -void -DrawFromExtraScreen (PRECT r) //No scaling? -{ - RECT locRect; - TFB_DrawCommand* DC; - - if (!r) - { - locRect.corner.x = locRect.corner.y = 0; - locRect.extent.width = SCREEN_WIDTH; - locRect.extent.height = SCREEN_HEIGHT; - r = &locRect; - } - - DC=HMalloc(sizeof(TFB_DrawCommand)); - - DC->Type = TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER; - DC->x = r->corner.x; - DC->y = r->corner.y; - DC->w = r->extent.width; - DC->h = r->extent.height; - - TFB_EnqueueDrawCommand (DC); -} - -void -SetGraphicUseOtherExtra (int other) //Could this possibly be more cryptic?!? :) -{ -} - -void -LoadIntoExtraScreen (PRECT r) //like a glTexture? -{ - RECT locRect; - TFB_DrawCommand *DC; - - if (!r) - { - locRect.corner.x = locRect.corner.y = 0; - locRect.extent.width = SCREEN_WIDTH; - locRect.extent.height = SCREEN_HEIGHT; - r = &locRect; - } - -// printf ("LoadIntoExtraScreen (%d, %d, {%d, %d})\n", r->corner.x, r->corner.y, r->extent.width, r->extent.height); - DC = HMalloc (sizeof (TFB_DrawCommand)); - - DC->Type = TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER; - DC->x = r->corner.x; - DC->y = r->corner.y; - DC->w = r->extent.width; - DC->h = r->extent.height; - DC->image = 0; - - TFB_EnqueueDrawCommand (DC); -} - -void -SetGraphicGrabOther (int grab_other) -{ -} - -//Status: Unimplemented -void -ScreenTransition (int TransType, PRECT pRect) //TransType==3 -{ - //printf ("Unimplemented function activated: ScreenTransition()\n"); -} - -//Status: Unimplemented -UNICODE -KBDToUNICODE (UNICODE SK_in) - //This one'll probably require a big table. Arg. -{ - return (SK_in); -} - -//Status: Unimplemented -BOOLEAN -SetColorMap (COLORMAPPTR map) - //There's also a macro for thing in appglue.h... Hmm... -{ - BOOLEAN ret; - - //printf("Unimplemented function activated: SetColorMap()\n"); - ret = TRUE; - return (ret); -} - -//Status: Unimplemented -void -StopSound() - // So does this stop ALL sound? How about music? -{ - Mix_HaltChannel (-1); -} - -//Status: Ignored -BOOLEAN -UninitInput () // Looks like it'll be empty -{ - BOOLEAN ret; - - // printf("Unimplemented function activated: UninitInput()\n"); - ret = TRUE; - return (ret); -} - -static DRAWABLE -alloc_image (COUNT NumFrames, DRAWABLE_TYPE DrawableType, CREATE_FLAGS - flags, SIZE width, SIZE height) -{ - DWORD data_byte_count; - DRAWABLE Drawable; - - data_byte_count = 0; - if (flags & WANT_MASK) - data_byte_count += (DWORD) SCAN_WIDTH (width) * height; - if ((flags & WANT_PIXMAP) && DrawableType == RAM_DRAWABLE) - { - width = ((width << 1) + 3) & ~3; - data_byte_count += (DWORD) width * height; - } - - Drawable = AllocDrawable (NumFrames, data_byte_count * NumFrames); - if (Drawable) - { - if (DrawableType == RAM_DRAWABLE) - { - COUNT i; - DWORD data_offs; - DRAWABLEPTR DrawablePtr; - FRAMEPTR F; - - data_offs = sizeof (*F) * NumFrames; - DrawablePtr = LockDrawable (Drawable); - for (i = 0, F = &DrawablePtr->Frame[0]; i < NumFrames; ++i, ++F) - { - F->DataOffs = data_offs; - data_offs += data_byte_count - sizeof (*F); - } - UnlockDrawable (Drawable); - } - } - - return (Drawable); -} - -static int gscale; - -static void -blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) -{ - TFB_Image *img; - PFRAME_DESC SrcFramePtr; - - SrcFramePtr = (PFRAME_DESC)PrimPtr->Object.Stamp.frame; - if (SrcFramePtr->DataOffs == 0) - { - printf ("Non-existent image to blt()\n"); - return; - } - - img = (TFB_Image *) ((BYTE *) SrcFramePtr + SrcFramePtr->DataOffs); - - if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE) - { - TFB_DrawCommand *DrawCommand; - - DrawCommand = HMalloc (sizeof (TFB_DrawCommand)); - if (DrawCommand) - { - DrawCommand->Type = TFB_DRAWCOMMANDTYPE_IMAGE; - DrawCommand->x = pClipRect->corner.x - - GetFrameHotX (_CurFramePtr); - DrawCommand->y = pClipRect->corner.y - - GetFrameHotY (_CurFramePtr); - DrawCommand->w = img->SurfaceSDL->clip_rect.w; - DrawCommand->h = img->SurfaceSDL->clip_rect.h; - if (gscale) - { - DrawCommand->x += (GetFrameHotX (SrcFramePtr) * - ((1 << 8) - gscale)) >> 8; - DrawCommand->y += (GetFrameHotY (SrcFramePtr) * - ((1 << 8) - gscale)) >> 8; - DrawCommand->w = (DrawCommand->w * gscale) >> 8; - DrawCommand->h = (DrawCommand->h * gscale) >> 8; - } - DrawCommand->image = img; //TFB_Image - if (GetPrimType (PrimPtr) == STAMPFILL_PRIM) - { - DWORD c32k; - - c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index - DrawCommand->r = (c32k >> (10 - (8 - 5))) & 0xF8; - DrawCommand->g = (c32k >> (5 - (8 - 5))) & 0xF8; - DrawCommand->b = (c32k << (8 - 5)); - } - - DrawCommand->Qualifier = (TYPE_GET (GetFrameParentDrawable ( - SrcFramePtr)->FlagsAndIndex) >> FTYPE_SHIFT) & - MAPPED_TO_DISPLAY; - - TFB_EnqueueDrawCommand(DrawCommand); - } - } - else - { - SDL_Rect SDL_SrcRect, SDL_DstRect; - - SDL_SrcRect.x = (short) img->SurfaceSDL->clip_rect.x; - SDL_SrcRect.y = (short) img->SurfaceSDL->clip_rect.y; - SDL_SrcRect.w = (short) img->SurfaceSDL->clip_rect.w; - SDL_SrcRect.h = (short) img->SurfaceSDL->clip_rect.h; - - SDL_DstRect.x = (short) pClipRect->corner.x - - GetFrameHotX (_CurFramePtr) + SDL_SrcRect.x; - SDL_DstRect.y = (short) pClipRect->corner.y - - GetFrameHotY (_CurFramePtr) + SDL_SrcRect.y; - - SDL_BlitSurface ( - img->SurfaceSDL, // src - &SDL_SrcRect, // src rect - ((TFB_Image *) ((BYTE *) _CurFramePtr + - _CurFramePtr->DataOffs))->SurfaceSDL, - &SDL_DstRect // dst rect - ); - } -} - -static void -fillrect_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) -{ - BYTE r, g, b; - DWORD c32k; - - c32k = GetPrimColor (PrimPtr) >> 8; //shift out color index - r = (c32k >> (10 - (8 - 5))) & 0xF8; - g = (c32k >> (5 - (8 - 5))) & 0xF8; - b = (c32k << (8 - 5)); - - if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE) - { - TFB_DrawCommand *DrawCommand; - - DrawCommand = HMalloc (sizeof (TFB_DrawCommand)); - if (DrawCommand) - { - DrawCommand->Type = TFB_DRAWCOMMANDTYPE_RECTANGLE; - DrawCommand->x = pClipRect->corner.x - GetFrameHotX (_CurFramePtr); - DrawCommand->y = pClipRect->corner.y - GetFrameHotY (_CurFramePtr); - DrawCommand->w = pClipRect->extent.width; - DrawCommand->h = pClipRect->extent.height; - DrawCommand->r = r; - DrawCommand->g = g; - DrawCommand->b = b; - - if (gscale && GetPrimType (PrimPtr) != POINT_PRIM) - { - DrawCommand->w = (DrawCommand->w * gscale) >> 8; - DrawCommand->h = (DrawCommand->h * gscale) >> 8; - DrawCommand->x += (pClipRect->extent.width - - DrawCommand->w) >> 1; - DrawCommand->y += (pClipRect->extent.height - - DrawCommand->h) >> 1; - } - - TFB_EnqueueDrawCommand(DrawCommand); - } - } - else - { - SDL_Rect SDLRect; - SDL_Surface *surf; - - surf = ((TFB_Image *) ((BYTE *) _CurFramePtr + - _CurFramePtr->DataOffs))->SurfaceSDL; - - SDLRect.x = (short) (pClipRect->corner.x - - GetFrameHotX (_CurFramePtr)); - SDLRect.y = (short) (pClipRect->corner.y - - GetFrameHotY (_CurFramePtr)); - SDLRect.w = (short) pClipRect->extent.width; - SDLRect.h = (short) pClipRect->extent.height; - - SDL_FillRect (surf, &SDLRect, SDL_MapRGB (surf->format, r, g, b)); - } -} - -static void -cmap_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) -{ -// printf ("Unimplemented function activated: cmap_blt()\n"); -} - -static void -line_blt (PRECT pClipRect, PRIMITIVEPTR PrimPtr) -{ - float x1,y1,x2,y2; - BYTE r, g, b; - DWORD c32k; - - c32k = GetPrimColor (PrimPtr) >> 8; // shift out color index - r = (c32k >> (10 - (8 - 5))) & 0xF8; - g = (c32k >> (5 - (8 - 5))) & 0xF8; - b = (c32k << (8 - 5)); - - x1=PrimPtr->Object.Line.first.x - GetFrameHotX (_CurFramePtr); - y1=PrimPtr->Object.Line.first.y - GetFrameHotY (_CurFramePtr); - x2=PrimPtr->Object.Line.second.x - GetFrameHotX (_CurFramePtr); - y2=PrimPtr->Object.Line.second.y - GetFrameHotY (_CurFramePtr); - - if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE) - { - TFB_DrawCommand *DC; - - DC = HMalloc (sizeof (TFB_DrawCommand)); - - DC->Type = TFB_DRAWCOMMANDTYPE_LINE; - DC->x = x1; - DC->y = y1; - DC->w = x2; - DC->h = y2; - DC->r = r; - DC->g = g; - DC->b = b; - - TFB_EnqueueDrawCommand(DC); - } - else - { - } -} - -static void -read_screen (PRECT lpRect, FRAMEPTR DstFramePtr) -{ - if (TYPE_GET (_CurFramePtr->TypeIndexAndFlags) != SCREEN_DRAWABLE - || TYPE_GET (DstFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE - || !(TYPE_GET (GetFrameParentDrawable (DstFramePtr) - ->FlagsAndIndex) - & ((DWORD) MAPPED_TO_DISPLAY << FTYPE_SHIFT))) - { - printf("Unimplemented function activated: read_screen()\n"); - } - else - { - TFB_DrawCommand* DC; - - DC = HMalloc(sizeof(TFB_DrawCommand)); - - DC->Type = TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER; - DC->x = lpRect->corner.x; - DC->y = lpRect->corner.y; - DC->w = lpRect->extent.width; - DC->h = lpRect->extent.height; - DC->image = (TFB_Image *) ((BYTE *) DstFramePtr + - DstFramePtr->DataOffs); - - TFB_EnqueueDrawCommand (DC); - } -} - -void (*func_array[]) (PRECT pClipRect, PRIMITIVEPTR PrimPtr) = -{ - fillrect_blt, - blt, - blt, - line_blt, - _text_blt, - cmap_blt, - _rect_blt, - fillrect_blt, - _fillpoly_blt, - _fillpoly_blt, -}; - -static DISPLAY_INTERFACE DisplayInterface = -{ - WANT_MASK, - - 16, // SCREEN_DEPTH, - 320, - 240, - - alloc_image, - read_screen, - - func_array, -}; - -void -LoadDisplay (PDISPLAY_INTERFACE *pDisplay) -{ - *pDisplay = &DisplayInterface; -} - -static TFB_DrawCommandQueue *DrawCommandQueue; -static void *ExtraScreen; - -//Status: Not entirely unimplemented! -BOOLEAN -InitGraphics (int argc, char* argv[], COUNT KbytesRequired) - // Kbytes should only matter if we wanted to port Starcon2 to the - // hand-helds... -{ - BOOLEAN ret; - - LoadDisplay (&_pCurDisplay); - mem_init (); - ActivateDisplay (); - - DrawCommandQueue = TFB_DrawCommandQueue_Create (); - - ExtraScreen = HMalloc (ScreenWidthActual * ScreenHeightActual * 4); - ret = TRUE; - return (ret); -} - -// Status: Unimplemented -void -UninitGraphics () // Also probably empty -{ - HFree (DrawCommandQueue); - - HFree (ExtraScreen); - mem_uninit (); -} - -// Status: Unimplemented -void -UninitSound () //Maybe I should call StopSound() first? -{ - //printf("Unimplemented function activated: UninitSound()\n"); -} - -// Status: Ignored -void -UninitVideo () //empty -{ - // printf("Unimplemented function activated: UninitVideo()\n"); -} - -static int _music_volume = (MAX_VOLUME + 1) >> 1; - -// Status: Unimplemented -void -SetMusicVolume(COUNT Volume) //Volume calibration... [0,255]? -{ - Mix_VolumeMusic ((_music_volume = Volume) * SDL_MIX_MAXVOLUME / - MAX_VOLUME); -} - -static TASK FadeTask; -static SIZE TTotal; -static SIZE volume_end; - -static int -fade_task (void *data) -{ - SIZE TDelta, volume_beg; - DWORD StartTime, CurTime; - - volume_beg = _music_volume; - StartTime = CurTime = GetTimeCounter (); - do - { - CurTime = SleepTask (CurTime + 1); - if ((TDelta = (SIZE) (CurTime - StartTime)) > TTotal) - TDelta = TTotal; - - SetMusicVolume ((COUNT) (volume_beg + (SIZE) - ((long) (volume_end - volume_beg) * TDelta / TTotal))); - } while (TDelta < TTotal); - - FadeTask = 0; - return (1); -} - -DWORD -FadeMusic (BYTE end_vol, SIZE TimeInterval) -{ - DWORD TimeOut; - - if (FadeTask) - { - volume_end = _music_volume; - TTotal = 1; - do - TaskSwitch (); - while (FadeTask); - TaskSwitch (); - } - - if ((TTotal = TimeInterval) <= 0) - TTotal = 1; /* prevent divide by zero and negative fade */ - volume_end = end_vol; - - if (TTotal > 1 && (FadeTask = AddTask (fade_task, 0))) - { - TimeOut = GetTimeCounter () + TTotal + 1; - } - else - { - SetMusicVolume (end_vol); - TimeOut = GetTimeCounter (); - } - - return (TimeOut); -} - -//Status: Unimplemented -void -FlushColorXForms() //Not entirely sure what's done here. CLUT stuff? -{ -// printf ("Unimplemented function activated: FlushColorXForms()\n"); -} - -//Status: Unimplemented -BOOLEAN -SoundPlaying() -{ - return (Mix_Playing (-1) != 0); -} - -//Status: Unimplemented -void -VidStop() // At least this one makes sense. -{ - // printf ("Unimplemented function activated: VidStop()\n"); -} - -//Status: Unimplemented -MEM_HANDLE -VidPlaying() // Easy enough. -{ - MEM_HANDLE ret; - - //printf("Unimplemented function activated: VidPlaying()\n"); - ret = 0; - return (ret); -} - -//Status: Unimplemented -VIDEO_TYPE -VidPlay (VIDEO_REF VidRef, char *loopname, BOOLEAN uninit) - // uninit? when done, I guess. -{ - VIDEO_TYPE ret; - ret = 0; - -// printf("Unimplemented function activated: VidPlay()\n"); - return (ret); -} - -int -GetSoundData(char* data) //Returns the data size. -{ - int ret; - - printf("Unimplemented function activated: GetSoundData()\n"); - ret = 0; - return (ret); -} - -// Status: Unimplemented -int -GetSoundInfo(int* length, int* offset) - // Umm... How does it know which sound? -{ - int ret; - - printf ("Unimplemented function activated: GetSoundInfo()\n"); - ret = 0; - return (ret); -} - -// Status: Unimplemented -BOOLEAN -ChannelPlaying(COUNT WhichChannel) - // SDL will have a nice interface for this, I hope. -{ - // printf("Unimplemented function activated: ChannelPlaying()\n"); - return ((BOOLEAN) Mix_Playing (WhichChannel)); -} - -// Status: Unimplemented -void -SetGraphicScale (int scale) - //Calibration... -{ - gscale = scale; -} - -// Status: Unimplemented -void -PlayChannel( - COUNT channel, - PVOID sample, - COUNT sample_length, - COUNT loop_begin, - COUNT loop_length, - unsigned char priority -) // This one's important. -{ - Mix_Chunk* Chunk; - - Chunk=*(Mix_Chunk**)sample; - Mix_PlayChannel ( - channel, //-1 would be easiest - Chunk, - 0 - ); -} - -//Status: Unimplemented -void -StopChannel(COUNT channel, unsigned char Priority) // Easy w/ SDL. -{ - Mix_HaltChannel (channel); -} - -// Status: Maybe Implemented -PBYTE -GetSampleAddress (SOUND sound) - // I might be prototyping this wrong, type-wise. -{ - return ((PBYTE)GetSoundAddress (sound)); -} - -// Status: Unimplemented -COUNT -GetSampleLength (SOUND sound) -{ - COUNT ret; - Mix_Chunk *Chunk; - - Chunk = (Mix_Chunk *) sound; - ret = 0; // Chunk->alen; - -// printf ("Maybe Implemented function activated: GetSampleLength()\n"); - return(ret); -} - -// Status: Unimplemented -void -SetChannelRate (COUNT channel, DWORD rate_hz, unsigned char priority) - // in hz -{ -// printf ("Unimplemented function activated: SetChannelRate()\n"); -} - -// Status: Unimplemented -COUNT -GetSampleRate (SOUND sound) -{ - COUNT ret; - -// printf("Unimplemented function activated: GetSampleRate()\n"); - ret=0; - return(ret); -} - -// Status: Unimplemented -void -SetChannelVolume (COUNT channel, COUNT volume, BYTE priority) - // I wonder what this whole priority business is... - // I can probably ignore it. -{ -// printf ("Unimplemented function activated: SetChannelVolume()\n"); -} - -static UNICODE PauseKey; -static UNICODE ExitKey; -static UNICODE OtherKey; - -static BOOLEAN (* PauseFunc) (void); - -// Status: Unimplemented -extern BOOLEAN -InitInput (UNICODE Pause, UNICODE Exit, BOOLEAN (*PFunc) (void)) -//Be careful with this one. -{ - PauseKey = Pause; - ExitKey = Exit; - - // Find a unique byte ID not equal to PauseKey, ExitKey, or 0. - OtherKey = 1; - while (OtherKey == PauseKey || OtherKey == ExitKey) - OtherKey++; - - PauseFunc = PFunc; - - return (TRUE); -} - -INPUT_STATE -AnyButtonPress (BOOLEAN DetectSpecial) -{ - int i; - - if (DetectSpecial) - { - if (KeyDown (PauseKey) && PauseFunc && (*PauseFunc) ()) - ; - } - - for (i = 0; i < sizeof (KeyboardDown) / sizeof (KeyboardDown[0]); ++i) - { - if (KeyboardDown[i]) - return (DEVICE_BUTTON1); - } -#if 0 - for (i = 0; i < JOYSTICKS_AVAIL; i++) - if (read_joystick (i)) - return (DEVICE_BUTTON1); -#endif - - return (0); -} - -// Status: Ignored -BOOLEAN -InitVideo (BOOLEAN useCDROM) //useCDROM doesn't really apply to us... -{ - BOOLEAN ret; - -// printf("Unimplemented function activated: InitVideo()\n"); - ret = TRUE; - return (ret); -} - -//Status: Ignored -BOOLEAN -InitSound (int argc, char* argv[]) - // Odd things to pass the InitSound function... -{ - BOOLEAN ret; - -// printf("Unimplemented function activated: InitSound()\n"); - ret = TRUE; - return (ret); -} - -// Status: Unimplemented -void -SetGraphicStrength (int numerator, int denominator) - // I just hope numerator always = denominator... -{ -// printf("Unimplemented function activated: SetGrahicsStrength()\n"); -} - -// 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]); -} - -// Status: Unimplemented -BOOLEAN -BatchColorMap (COLORMAPPTR ColorMapPtr) - // Batch... I wonder what that verb means in this context? - // SvdB: I don't think it is a verb. -{ - BOOLEAN ret; - -// printf("Unimplemented function activated: BatchColorMap()\n"); - ret = TRUE; - return (ret); -} - -// Status: Unimplemented -BOOLEAN -_image_intersect (PIMAGE_BOX box1, PIMAGE_BOX box2, PRECT rect) - // This is a biggie. -{ - BOOLEAN ret; - -// printf ("Unimplemented function activated: _image_intersect()\n"); - ret = TRUE; - return (ret); -} - -// Status: Unimplemented -INPUT_STATE -_get_serial_keyboard_state (INPUT_REF ref, INPUT_STATE InputState) - // I hope these are defined somewhere... -{ - Uint16 key; - extern Uint16 GetUNICODEKey (void); - - if ((key = GetUNICODEKey ()) == '\r') - key = '\n'; - SetInputUNICODE (&InputState, key); - SetInputDevType (&InputState, KEYBOARD_DEVICE); - - return (InputState); -} - -// Status: Unimplemented -INPUT_STATE -_get_joystick_keyboard_state (INPUT_REF InputRef, INPUT_STATE InputState) - // see line above. -{ - SBYTE dx, dy; - BYTEPTR KeyEquivalentPtr; - - KeyEquivalentPtr = GetInputDeviceKeyEquivalentPtr (InputRef); - dx = (SBYTE)(KeyDown (KeyEquivalentPtr[1]) - - KeyDown (KeyEquivalentPtr[0])); - SetInputXComponent (&InputState, dx); - - KeyEquivalentPtr += 2; - dy = (SBYTE)(KeyDown (KeyEquivalentPtr[1]) - - KeyDown (KeyEquivalentPtr[0])); - SetInputYComponent (&InputState, dy); - - KeyEquivalentPtr += 2; - if (KeyDown (*KeyEquivalentPtr++)) - InputState |= DEVICE_BUTTON1; - if (KeyDown (*KeyEquivalentPtr++)) - InputState |= DEVICE_BUTTON2; - if (KeyDown (*KeyEquivalentPtr++)) - InputState |= DEVICE_BUTTON3; - - if (KeyDown (*KeyEquivalentPtr++)) - InputState |= DEVICE_LEFTSHIFT; - if (KeyDown (*KeyEquivalentPtr++)) - InputState |= DEVICE_RIGHTSHIFT; - - if (InputState) - SetInputDevType (&InputState, JOYSTICK_DEVICE); - - return (InputState); -} - -/* -// Status: Implemented -INPUT_STATE -_get_joystick_state (INPUT_REF ref, INPUT_STATE InputState) - // consistant, at least. -{ -// printf ("Half-implemented function activated: _get_joystick_state()\n"); - - if (KeyboardStroke[SDLK_LEFT]) - { - SetInputXComponent (&InputState, -1); -// printf ("LEFT!\n"); - KeyboardStroke[SDLK_LEFT] = FALSE; - } - if (KeyboardStroke[SDLK_RIGHT]) - { - SetInputXComponent (&InputState, 1); -// printf ("RIGHT!\n"); - KeyboardStroke[SDLK_RIGHT] = FALSE; - } - - if (KeyboardStroke[SDLK_UP]) - { - SetInputYComponent (&InputState, -1); -// printf ("UP!\n"); - KeyboardStroke[SDLK_UP] = FALSE; - } - if (KeyboardStroke[SDLK_DOWN]) - { - SetInputYComponent (&InputState, 1); -// printf ("DOWN!\n"); - KeyboardStroke[SDLK_DOWN] = FALSE; - } - - if (KeyboardStroke[ControlA]) - { - InputState |= DEVICE_BUTTON1; -// printf("BUTTON1!\n"); - KeyboardStroke[ControlA]=FALSE; - } - if (KeyboardStroke[ControlB]) - { - InputState |= DEVICE_BUTTON2; -// printf ("BUTTON2!\n"); - KeyboardStroke[ControlB] = FALSE; - } - if (KeyboardStroke[ControlC]) - { - InputState |= DEVICE_BUTTON3; -// printf ("BUTTON3!\n"); - KeyboardStroke[ControlC] = FALSE; - } - if (KeyboardStroke[ControlX]) - { - InputState |= DEVICE_EXIT; -// printf ("BUTTONX!\n"); - KeyboardStroke[ControlX] = FALSE; - } - if (KeyboardStroke[ControlStart]) - { - InputState |= DEVICE_PAUSE; -// printf ("CONTROLSTART!\n"); - KeyboardStroke[ControlStart] = FALSE; - } - if (KeyboardStroke[ControlLeftShift]) - { - InputState |= DEVICE_LEFTSHIFT; -// printf ("LEFTSHIFT!\n"); - KeyboardStroke[ControlLeftShift] = FALSE; - } - if (KeyboardStroke[ControlRightShift]) - { - InputState |= DEVICE_RIGHTSHIFT; -// printf ("RIGHTSHIFT!\n"); - KeyboardStroke[ControlRightShift] = FALSE; - } - - return (InputState); -} -*/ - -INPUT_STATE -_get_joystick_state (INPUT_REF ref, INPUT_STATE InputState) - // consistant, at least. -{ -#if 0 - if (ref == JoystickInput[1] && 0) - { - //printf ("ref\n"); - - return(0); - } - -// printf ("Half-implemented function activated: _get_joystick_state()\n"); - - if (KeyboardDown[SDLK_LEFT]) - { - SetInputXComponent (&InputState, -1); - //printf ("LEFT!\n"); - } - if (KeyboardDown[SDLK_RIGHT]) - { - SetInputXComponent (&InputState, 1); - //printf ("RIGHT!\n"); - } - - if (KeyboardDown[SDLK_UP]) - { - SetInputYComponent (&InputState, -1); - //printf ("UP!\n"); - } - if (KeyboardDown[SDLK_DOWN]) - { - SetInputYComponent (&InputState, 1); - //printf ("DOWN!\n"); - } - - if (KeyboardDown[ControlA]) - { - InputState |= DEVICE_BUTTON1; - //printf ("BUTTON1!\n"); - } - if (KeyboardDown[ControlB]) - { - InputState |= DEVICE_BUTTON2; - //printf ("BUTTON2!\n"); - } - if (KeyboardDown[ControlC]) - { - InputState |= DEVICE_BUTTON3; - //printf ("BUTTON3!\n"); - } - if (KeyboardDown[ControlX]) - { - InputState |= DEVICE_EXIT; - //printf ("BUTTONX!\n"); - } - if (KeyboardDown[ControlStart]) - { - InputState |= DEVICE_PAUSE; - //printf ("CONTROLSTART!\n"); - } - if (KeyboardDown[ControlLeftShift]) - { - InputState |= DEVICE_LEFTSHIFT; - //printf ("LEFTSHIFT!\n"); - } - if (KeyboardDown[ControlRightShift]) - { - InputState |= DEVICE_RIGHTSHIFT; - //printf ("RIGHTSHIFT!\n"); - } -#endif - - return (InputState); -} - -// Status: Ignored - The keyboard will serve as the joystick, thus a port is always open. -BOOLEAN -_joystick_port_active(COUNT port) //SDL handles this nicely. -{ - printf ("Unimplemented function activated: _joystick_port_active()\n"); - return (0); -} - -INPUT_STATE -_get_pause_exit_state (void) -{ - INPUT_STATE InputState; - - InputState = 0; - if (KeyDown (PauseKey)) - { - if (PauseFunc && (*PauseFunc) ()) - ; - } - else if (KeyDown (ExitKey)) - { - InputState = DEVICE_EXIT; - } -#if 0 - for (i = 0; i < JOYSTICKS_AVAIL; i++) - { - DWORD joy; - - joy = read_joystick (i); - if (joy & ControlStart) // pause - { - if (PauseFunc && (*PauseFunc) ()) -// while (KeyDown (PauseKey)) - ; - } - else if (joy & ControlX) // exit - { -// while (KeyDown (ExitKey)) -// TaskSwitch (); - - InputState = DEVICE_EXIT; - } - } -#endif - - return (InputState); -} - -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 ()); -} - -VIDEO_REF -_init_video_file(PVOID pStr) -{ - VIDEO_REF ret; - - printf ("Unimplemented function activated: _init_video_file()\n"); - ret = 0; - return (ret); -} - -// Draw Command Queue Stuff -TFB_DrawCommandQueue* -TFB_DrawCommandQueue_Create() -{ - TFB_DrawCommandQueue* myQueue; - - myQueue = (TFB_DrawCommandQueue*) HMalloc( - sizeof(TFB_DrawCommandQueue)); - - myQueue->Back = 0; - myQueue->Front = 0; - myQueue->Size = 0; - - return (myQueue); -} - -void -TFB_DrawCommandQueue_Push (TFB_DrawCommandQueue* myQueue, - TFB_DrawCommand* Command) -{ - TFB_DrawCommandNode* NewNode; - - NewNode = (TFB_DrawCommandNode*) HMalloc (sizeof (TFB_DrawCommandNode)); - NewNode->Command = Command; - NewNode->Behind = NewNode; - - if (myQueue->Size == 0) - { - NewNode->Ahead = NewNode; - myQueue->Front = NewNode; - } - else - { - NewNode->Ahead = myQueue->Back; - myQueue->Back->Behind = NewNode; - } - - myQueue->Back=NewNode; - myQueue->Size++; -} - -TFB_DrawCommand * -TFB_DrawCommandQueue_Pop (TFB_DrawCommandQueue *myQueue) -{ - TFB_DrawCommand *ReturnMe; - TFB_DrawCommandNode *NextFront; - - if (myQueue->Size == 0) - return (0); - - ReturnMe = myQueue->Front->Command; - NextFront = myQueue->Front->Behind; - HFree (myQueue->Front); - if (myQueue->Size == 1) - { - myQueue->Front=0; - myQueue->Back=0; - } - else - { - myQueue->Front=NextFront; - myQueue->Front->Ahead=myQueue->Front; - } - - myQueue->Size--; - - return (ReturnMe); -} - -void -TFB_DeallocateDrawCommand (TFB_DrawCommand* Command) -{ - HFree(Command); -} - -// - -DWORD -SetSemaphore (SEMAPHORE *sem) -{ - SDL_SemWait (*sem); - return (GetTimeCounter ()); -} - -void -ClearSemaphore (SEMAPHORE *sem) -{ - SDL_SemPost (*sem); -} - -TASK -AddTask (TASK_FUNC arg1, COUNT arg2) -{ - return (SDL_CreateThread ((int (*)(void *)) arg1, NULL)); -} - -void -DeleteTask (TASK T) -{ - SDL_KillThread (T); -} - -static int Next2Power (int in) -{ - int c; - for(c = 1; c <= in ; c *= 2) - ; - - return(c); -} - -TFB_Image* TFB_LoadImage (SDL_Surface *img) -{ - TFB_Image* myImage; - - myImage = (TFB_Image*) HMalloc (sizeof (TFB_Image)); - - // Create a new SDL Image - - if (img->format->BytesPerPixel < 4) - { - SDL_Surface *new_surf; - - new_surf = SDL_CreateRGBSurface ( - SDL_SWSURFACE, - img->clip_rect.w, - img->clip_rect.h, - 32, - 0x000000FF, - 0x0000FF00, - 0x00FF0000, - 0xFF000000 - ); - if (new_surf) - { - SDL_Rect SDL_DstRect; - - SDL_DstRect.x = SDL_DstRect.y = 0; - /* - SDL_FillRect ( - new_surf, - &SDL_DstRect, - SDL_MapRGBA(new_surf->format, 1, 1, 1, .5) - ); - */ - SDL_BlitSurface ( - img, // src - &img->clip_rect, // src rect - new_surf, // dst - &SDL_DstRect // dst rect - ); - - new_surf->clip_rect.x = new_surf->clip_rect.y = 0; - new_surf->clip_rect.w = img->clip_rect.w; - new_surf->clip_rect.h = img->clip_rect.h; - - SDL_FreeSurface (img); - img = new_surf; - } - } - myImage->SurfaceSDL=img; - - // Figure out glTexture* Variables - - myImage->glTextureW = Next2Power (myImage->SurfaceSDL->clip_rect.w); - myImage->glTextureH = Next2Power (myImage->SurfaceSDL->clip_rect.h); - - myImage->glTexture = 0; - - return(myImage); -} - -void -TFB_FreeImage (TFB_Image *img) -{ - if (img) - { - TFB_DrawCommand* DC; - - DC = HMalloc (sizeof (TFB_DrawCommand)); - - DC->Type = TFB_DRAWCOMMANDTYPE_DELETEIMAGE; - DC->image = img; - - TFB_EnqueueDrawCommand (DC); - } -} - -void -TFB_EnqueueDrawCommand (TFB_DrawCommand* DrawCommand) -{ - if (TFB_DEBUG_HALT) - { - return; - } - - if (DrawCommand->Type <= TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER - && TYPE_GET (_CurFramePtr->TypeIndexAndFlags) == SCREEN_DRAWABLE) - { - static RECT scissor_rect; - - // Set the clipping region. - if (scissor_rect.corner.x != _pCurContext->ClipRect.corner.x - || scissor_rect.corner.y != _pCurContext->ClipRect.corner.y - || scissor_rect.extent.width != - _pCurContext->ClipRect.extent.width - || scissor_rect.extent.height != - _pCurContext->ClipRect.extent.height) - { - // Enqueue command to set the glScissor spec - - TFB_DrawCommand* DC; - - scissor_rect = _pCurContext->ClipRect; - - DC = HMalloc (sizeof (TFB_DrawCommand)); - - DC->Type = scissor_rect.extent.width - ? (DC->x = scissor_rect.corner.x, - DC->y=scissor_rect.corner.y, - DC->w=scissor_rect.extent.width, - DC->h=scissor_rect.extent.height), - TFB_DRAWCOMMANDTYPE_SCISSORENABLE - : TFB_DRAWCOMMANDTYPE_SCISSORDISABLE; - - TFB_EnqueueDrawCommand(DC); - } - } - - TFB_DrawCommandQueue_Push (DrawCommandQueue, DrawCommand); -} - -void -TFB_FlushGraphics () //Only call from main thread!! -{ -#define NUM_FLUSH_PASSES 1 - int semval, pass; - TFB_DrawCommandQueue DCQ_Copy, DCQ_Swap; - Uint32 this_flush; - static Uint32 last_flush = 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; - - DCQ_Copy = *DrawCommandQueue; - DrawCommandQueue->Back = 0; - DrawCommandQueue->Front = 0; - DrawCommandQueue->Size = 0; - DCQ_Swap = *DrawCommandQueue; - if (semval == 0) - SDL_SemPost (GraphicsSem); - - glDrawBuffer (GL_BACK); - for (pass = 0; pass < NUM_FLUSH_PASSES; ++pass) - { - while (DCQ_Copy.Size > 0) - { - TFB_DrawCommand* DC; - - DC = TFB_DrawCommandQueue_Pop (&DCQ_Copy); - - if (DC == 0) - { - printf ("Woah there coyboy! Trouble with TFB_Queues...\n"); - continue; - } - - switch (DC->Type) - { - case TFB_DRAWCOMMANDTYPE_IMAGE: - if (DC->image==0) - { - printf ("Error!!! Bad Image!\n"); - } - else - { - int vx, vy; - float y0, y1; - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - - // - - glLoadIdentity (); - if (DC->Qualifier != MAPPED_TO_DISPLAY) - { - glOrtho (0,ScreenWidth,ScreenHeight, 0, -1, 1); - vx = DC->x; - vy = DC->y; - y0 = 0; - y1 = DC->image->SurfaceSDL->clip_rect.h / - DC->image->glTextureH; - } - else - { - glOrtho (0, ScreenWidthActual, - ScreenHeightActual, 0, -1, 1); - vx = DC->x * ScreenWidthActual / ScreenWidth; - vy = DC->y * ScreenHeightActual / ScreenHeight; - y0 = DC->image->SurfaceSDL->clip_rect.h / - DC->image->glTextureH; - y1 = 0; - } - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - vx += DC->image->SurfaceSDL->clip_rect.x; - vy += DC->image->SurfaceSDL->clip_rect.y; - if (DC->image->glTexture) - { - glBindTexture (GL_TEXTURE_2D,DC->image->glTexture); - } - else - { - //Load Image into glTexture - - glGenTextures(1, &(DC->image->glTexture)); - glBindTexture(GL_TEXTURE_2D, DC->image->glTexture); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glPixelStorei(GL_UNPACK_ROW_LENGTH, DC->image->SurfaceSDL->w); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); -// glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); -// glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexImage2D // Make a blank texture - ( - GL_TEXTURE_2D, - 0, - GL_RGBA, // All incoming SDL_Surfaces must have an alpha channel - DC->image->glTextureW, - DC->image->glTextureH, - 0, - GL_RGBA, // All glTextures will have an alpha channel - GL_UNSIGNED_BYTE, - 0 // Valid in OpenGL 1.1 or later - ); - SDL_LockSurface(DC->image->SurfaceSDL); - glTexSubImage2D ( - GL_TEXTURE_2D, // Must be GL_TEXTURE_2D - 0, // Level of detail number (mipmapping) - DC->image->SurfaceSDL->clip_rect.x, // X - DC->image->SurfaceSDL->clip_rect.y, // Y - DC->image->SurfaceSDL->clip_rect.w, // Width - DC->image->SurfaceSDL->clip_rect.h, // Height - GL_RGBA, // Format - GL_UNSIGNED_BYTE, // Type - DC->image->SurfaceSDL->pixels // Pixels - ); - SDL_UnlockSurface(DC->image->SurfaceSDL); - } - glEnable (GL_TEXTURE_2D); - glEnable (GL_BLEND); - glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glColor4f (1,1,1,1); - glBegin (GL_QUADS); - - glTexCoord2f (0,y0); - glVertex2i (vx, vy); - - glTexCoord2f (0,y1); - glVertex2i (vx, vy + DC->h); - - glTexCoord2f (DC->image->SurfaceSDL->clip_rect.w / DC->image->glTextureW, y1); - glVertex2i (vx + DC->w, vy + DC->h); - - glTexCoord2f (DC->image->SurfaceSDL->clip_rect.w / DC->image->glTextureW, y0); - glVertex2i (vx + DC->w, vy); - - glEnd (); - glDisable (GL_BLEND); - glDisable (GL_TEXTURE_2D); - - // - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - } - break; - case TFB_DRAWCOMMANDTYPE_LINE: - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - - glLoadIdentity (); - glOrtho (0, ScreenWidth, ScreenHeight, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - // - - glColor3f ((float) DC->r / 255.0, (float) DC->g / 255.0, - (float) DC->b / 255.0); - glBegin (GL_LINES); - { - glVertex2f (DC->x,DC->y); - glVertex2f (DC->w,DC->h); - } - glEnd (); - - // - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - break; - case TFB_DRAWCOMMANDTYPE_RECTANGLE: - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - - // - - glLoadIdentity (); - glOrtho (0, ScreenWidth, ScreenHeight, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - - glBegin (GL_QUADS); - { - glColor3f (((float) DC->r) / 255.0, - ((float) DC->g) / 255.0, - ((float) DC->b) / 255.0); - glVertex2i (DC->x , DC->y + DC->h); - glVertex2i (DC->x , DC->y ); - glVertex2i (DC->x + DC->w, DC->y ); - glVertex2i (DC->x + DC->w, DC->y + DC->h); - } - glEnd (); - - // - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - break; - case TFB_DRAWCOMMANDTYPE_SCISSORENABLE: - { - int x; - int y; - int w; - int h; - - x = DC->x * ScreenWidthActual / ScreenWidth; - y = (ScreenHeight - (DC->y + DC->h)) * - ScreenHeightActual / ScreenHeight; - w = DC->w * ScreenWidthActual / ScreenWidth; - h = DC->h * ScreenHeightActual / ScreenHeight; - - glEnable (GL_SCISSOR_TEST); - glScissor (x, y, w, h); - break; - } - case TFB_DRAWCOMMANDTYPE_SCISSORDISABLE: - glDisable (GL_SCISSOR_TEST); - break; - case TFB_DRAWCOMMANDTYPE_COPYBACKBUFFERTOOTHERBUFFER: - if (pass == 0) - { - int x, y, w, h; - void *pixels; - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); - - glOrtho(0, ScreenWidth,ScreenHeight, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glRasterPos2d (0,0); - - x = DC->x * ScreenWidthActual / ScreenWidth; - y = (ScreenHeight - (DC->y + DC->h)) * - ScreenHeightActual / ScreenHeight; - w = DC->w * ScreenWidthActual / ScreenWidth; - h = DC->h * ScreenHeightActual / ScreenHeight; - if (DC->image == 0) - { - glPixelStorei (GL_PACK_ROW_LENGTH, - ScreenWidthActual); - glPixelStorei (GL_PACK_SKIP_PIXELS, x); - glPixelStorei (GL_PACK_SKIP_ROWS, y); - pixels = ExtraScreen; - } - else - { - SDL_LockSurface (DC->image->SurfaceSDL); - - glPixelStorei (GL_PACK_ROW_LENGTH, - DC->image->SurfaceSDL->w); - glPixelStorei (GL_PACK_SKIP_PIXELS, 0); - glPixelStorei (GL_PACK_SKIP_ROWS, 0); - pixels = DC->image->SurfaceSDL->pixels; // Pixels - } - - glReadBuffer (GL_BACK); -// glFlush (); -//glFinish (); - glReadPixels (x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, - pixels); - glPixelStorei (GL_PACK_ROW_LENGTH, 0); - - if (DC->image) - { - SDL_UnlockSurface (DC->image->SurfaceSDL); - } - else - { - glPixelStorei (GL_PACK_SKIP_ROWS, 0); - glPixelStorei (GL_PACK_SKIP_PIXELS, 0); - } - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - } - break; - case TFB_DRAWCOMMANDTYPE_COPYFROMOTHERBUFFER: - { - int x, y, w, h; - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); - glOrtho (0, ScreenWidth, ScreenHeight, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glRasterPos2d (DC->x, DC->y + DC->h); - - x = DC->x * ScreenWidthActual / ScreenWidth; - y = (ScreenHeight - (DC->y + DC->h)) * - ScreenHeightActual / ScreenHeight; - w = DC->w * ScreenWidthActual / ScreenWidth; - h = DC->h * ScreenHeightActual / ScreenHeight; - - glPixelStorei (GL_UNPACK_ROW_LENGTH, ScreenWidthActual); - glPixelStorei (GL_UNPACK_SKIP_PIXELS, x); - glPixelStorei (GL_UNPACK_SKIP_ROWS, y); - glDrawPixels (w, h, GL_RGBA, GL_UNSIGNED_BYTE, - ExtraScreen); - glPixelStorei (GL_UNPACK_SKIP_ROWS, 0); - glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei (GL_UNPACK_ROW_LENGTH, 0); - - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - break; - } - case TFB_DRAWCOMMANDTYPE_DELETEIMAGE: - if (pass == NUM_FLUSH_PASSES - 1) - { - SDL_FreeSurface (DC->image->SurfaceSDL); - if (DC->image->glTexture) - glDeleteTextures (1, &(DC->image->glTexture)); - HFree (DC->image); - } - break; - } - - if (pass == NUM_FLUSH_PASSES - 1) - TFB_DeallocateDrawCommand (DC); - else - TFB_DrawCommandQueue_Push (&DCQ_Swap, DC); - } - - if (pass == 0) - { - GLboolean ScissorMode; - - glGetBooleanv (GL_SCISSOR_TEST, &ScissorMode); - - glFlush (); - SDL_GL_SwapBuffers (); -// glFlush(); -#if NUM_FLUSH_PASSES > 1 - DCQ_Copy = DCQ_Swap; -#else - glReadBuffer (GL_FRONT); - glDrawBuffer (GL_BACK); - - glMatrixMode (GL_PROJECTION); - glPushMatrix (); - glLoadIdentity (); - - glOrtho (0, ScreenWidthActual, ScreenHeightActual, 0, -1, 1); - glMatrixMode (GL_MODELVIEW); - glLoadIdentity (); - glDisable (GL_SCISSOR_TEST); - glRasterPos2d (0, ScreenHeightActual - .1); - // Re "-.1": All values 0 < x < .5 work. Strange!! - - glCopyPixels (0, 0, ScreenWidthActual, ScreenHeightActual, - GL_COLOR); - - glPopMatrix (); - glMatrixMode (GL_MODELVIEW); - - if (ScissorMode) - { - glEnable (GL_SCISSOR_TEST); - } -#endif - } - } -} diff --git a/sc2/src/SDL_wrapper.h b/sc2/src/SDL_wrapper.h deleted file mode 100644 index 0bec2fa48..000000000 --- a/sc2/src/SDL_wrapper.h +++ /dev/null @@ -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 -#include - -#include "starcon.h" -#include "libs/gfxlib.h" -#include "libs/vidlib.h" -#include - -//#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 diff --git a/sc2/src/gl.h b/sc2/src/gl.h deleted file mode 100644 index 532166b5f..000000000 --- a/sc2/src/gl.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifdef WIN32 - -/* To avoid including windows.h, - Win32's 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 */ -#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 and */ -#ifndef WINGDIAPI -#define GLUT_WINGDIAPI_DEFINED -#define WINGDIAPI __declspec(dllimport) -#endif - -/* This is from Win32's */ -#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 - diff --git a/sc2/src/sc2code/libs/graphics/getbody.c b/sc2/src/sc2code/libs/graphics/getbody.c deleted file mode 100644 index 0b3266ddb..000000000 --- a/sc2/src/sc2code/libs/graphics/getbody.c +++ /dev/null @@ -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 -#endif -#include - -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); -} diff --git a/sc2/src/sc2code/libs/input/input.c b/sc2/src/sc2code/libs/input/input.c deleted file mode 100644 index 2a6fd6ead..000000000 --- a/sc2/src/sc2code/libs/input/input.c +++ /dev/null @@ -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 ())); -} - diff --git a/sc2/src/sc2code/libs/sound/modfuncs.c b/sc2/src/sc2code/libs/sound/modfuncs.c deleted file mode 100644 index 50ab74eaa..000000000 --- a/sc2/src/sc2code/libs/sound/modfuncs.c +++ /dev/null @@ -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 -#endif -#include - -#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)); -} diff --git a/sc2/src/sc2code/libs/sound/play.c b/sc2/src/sc2code/libs/sound/play.c deleted file mode 100644 index 2113964c0..000000000 --- a/sc2/src/sc2code/libs/sound/play.c +++ /dev/null @@ -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)); -} diff --git a/sc2/src/trackplayer.c b/sc2/src/trackplayer.c deleted file mode 100644 index 622486f6d..000000000 --- a/sc2/src/trackplayer.c +++ /dev/null @@ -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; -}