Preliminary ship spin support.
This includes perhaps 2/3s of the patch on Bugzilla -- the remainder no longer works with the current repository. As a result, ship spins in the Shipyard are disabled in this patch. This will be addressed in a later patch. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2711 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -50,8 +50,8 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
|
||||
|
||||
FreeHyperData ();
|
||||
|
||||
sprintf (buf, "ship%02d", index);
|
||||
DoFMV (buf, "spin", FALSE);
|
||||
sprintf (buf, "slides/spins/ship%02d.duk", index);
|
||||
DoFMV (buf, "slides/spins/spin.aif", FALSE);
|
||||
|
||||
GetContextClipRect (&old_r);
|
||||
r.corner.x = r.corner.y = 0;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#define _FMV_H
|
||||
|
||||
#include "libs/compiler.h"
|
||||
|
||||
#define WANT_SHIP_SPINS
|
||||
|
||||
extern void Logo (void);
|
||||
extern void SplashScreen (void (* DoProcessing)(DWORD TimeOut));
|
||||
|
||||
@@ -111,6 +111,8 @@ typedef struct tfb_duckvideodecoder
|
||||
#define DUCK_GENERAL_FPS 14.622f
|
||||
#define DUCK_MAX_FRAME_SIZE 0x8000U
|
||||
#define DUCK_END_OF_SEQUENCE 1
|
||||
/* Some ship spin animations contain extra frames that must be discarded. */
|
||||
#define VIDEO_SPIN_LOOP_FRAME 89
|
||||
|
||||
static void
|
||||
dukv_DecodeFrame (uint8* src_p, uint32* dst_p, uint32 wb, uint32 hb,
|
||||
@@ -529,7 +531,8 @@ dukv_RenderFrame (THIS_PTR)
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
if (!This->audio_synced)
|
||||
This->callbacks.SetTimer (This, (uint32) (1000.0f / DUCK_GENERAL_FPS));
|
||||
}
|
||||
|
||||
static const char*
|
||||
@@ -702,6 +705,10 @@ dukv_DecodeNext (THIS_PTR)
|
||||
|
||||
dukv_RenderFrame (This);
|
||||
|
||||
if (dukv->decoder.looping
|
||||
&& (dukv->decoder.cur_frame == VIDEO_SPIN_LOOP_FRAME))
|
||||
VideoDecoder_SeekFrame (&dukv->decoder, 0);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,12 @@ VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit)
|
||||
if (!vid)
|
||||
return NO_FMV;
|
||||
|
||||
if (loopname != NULL) {
|
||||
vid->hAudio2 = LoadMusicFile (loopname);
|
||||
vid->decoder->audio_synced = FALSE;
|
||||
vid->decoder->looping = TRUE;
|
||||
}
|
||||
|
||||
if (_cur_video)
|
||||
TFB_StopVideo (_cur_video);
|
||||
_cur_video = NULL_VIDEO_REF;
|
||||
@@ -105,7 +111,6 @@ VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit)
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
/* dodge compiler warnings */
|
||||
(void) loopname;
|
||||
(void) uninit;
|
||||
|
||||
return ret;
|
||||
@@ -123,6 +128,9 @@ _init_video_file(const char *pStr)
|
||||
{
|
||||
TFB_VideoClip* vid;
|
||||
TFB_VideoDecoder* dec;
|
||||
char* filename;
|
||||
char* pext;
|
||||
MUSIC_REF altsound;
|
||||
|
||||
dec = VideoDecoder_Load (contentDir, pStr);
|
||||
if (!dec)
|
||||
@@ -135,6 +143,21 @@ _init_video_file(const char *pStr)
|
||||
vid->h = vid->decoder->h;
|
||||
vid->guard = CreateMutex ("video guard", SYNC_CLASS_VIDEO);
|
||||
|
||||
/* Override main sound with .wav if available. */
|
||||
filename = HMalloc (strlen (pStr) + 5);
|
||||
strcpy (filename, pStr);
|
||||
pext = strrchr (filename, '.');
|
||||
if (pext)
|
||||
*pext = 0;
|
||||
strcat (filename, ".wav");
|
||||
altsound = LoadMusicFile (filename);
|
||||
if (altsound != 0) {
|
||||
DestroyMusic (vid->hAudio);
|
||||
vid->hAudio = altsound;
|
||||
} else
|
||||
vid->hAudio = 0;
|
||||
vid->hAudio2 = 0;
|
||||
|
||||
return (VIDEO_REF) vid;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ typedef struct tfb_videoclip
|
||||
RECT dst_rect; // destination screen rect
|
||||
RECT src_rect; // source rect
|
||||
MUSIC_REF hAudio;
|
||||
MUSIC_REF hAudio2;
|
||||
Task play_task;
|
||||
uint32 frame_time; // time when next frame should be rendered
|
||||
TFB_Image* frame; // frame preped and optimized for rendering
|
||||
|
||||
@@ -29,6 +29,29 @@ static void* vp_GetCanvasLine (TFB_VideoDecoder*, uint32 line);
|
||||
static uint32 vp_GetTicks (TFB_VideoDecoder*);
|
||||
static bool vp_SetTimer (TFB_VideoDecoder*, uint32 msecs);
|
||||
|
||||
void
|
||||
startAudioStream (MUSIC_REF aud, uint32 ss, BOOLEAN loop)
|
||||
{
|
||||
TFB_SoundSample **pmus;
|
||||
|
||||
LockMusicData (aud, &pmus);
|
||||
if (pmus)
|
||||
{
|
||||
LockMutex (soundSource[ss].stream_mutex);
|
||||
PlayStream ((*pmus), ss, loop, false, true);
|
||||
UnlockMutex (soundSource[ss].stream_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
stopAudioStream (MUSIC_REF aud, uint32 ss)
|
||||
{
|
||||
LockMutex (soundSource[ss].stream_mutex);
|
||||
StopStream (ss);
|
||||
UnlockMutex (soundSource[ss].stream_mutex);
|
||||
UnlockMusicData (aud);
|
||||
}
|
||||
|
||||
TFB_VideoCallbacks vp_DecoderCBs =
|
||||
{
|
||||
vp_GetCanvasLine,
|
||||
@@ -123,7 +146,10 @@ as_video_play_task (void *data)
|
||||
|
||||
LockMutex (vid->guard);
|
||||
want_frame = vid->want_frame;
|
||||
PlayMusic (vid->hAudio, FALSE, 1);
|
||||
if (vid->hAudio)
|
||||
startAudioStream (vid->hAudio, SPEECH_SOURCE, FALSE);
|
||||
if (vid->hAudio2)
|
||||
startAudioStream (vid->hAudio2, MUSIC_SOURCE, TRUE);
|
||||
UnlockMutex (vid->guard);
|
||||
|
||||
clagged = 0;
|
||||
@@ -208,7 +234,10 @@ as_video_play_task (void *data)
|
||||
|
||||
ret = VideoDecoder_Decode (vid->decoder);
|
||||
}
|
||||
StopMusic ();
|
||||
if (vid->hAudio)
|
||||
stopAudioStream (vid->hAudio, SPEECH_SOURCE);
|
||||
if (vid->hAudio2)
|
||||
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
|
||||
vid->playing = false;
|
||||
|
||||
FinishTask (task);
|
||||
@@ -232,7 +261,11 @@ video_play_task (void *data)
|
||||
|
||||
LockMutex (vid->guard);
|
||||
if (vid->hAudio)
|
||||
PlayMusic (vid->hAudio, FALSE, 1);
|
||||
startAudioStream (vid->hAudio, SPEECH_SOURCE, FALSE);
|
||||
|
||||
if (vid->hAudio2)
|
||||
startAudioStream (vid->hAudio2, MUSIC_SOURCE, TRUE);
|
||||
|
||||
UnlockMutex (vid->guard);
|
||||
|
||||
// this works like so:
|
||||
@@ -264,7 +297,9 @@ video_play_task (void *data)
|
||||
}
|
||||
vid->playing = false;
|
||||
if (vid->hAudio)
|
||||
StopMusic ();
|
||||
stopAudioStream (vid->hAudio, SPEECH_SOURCE);
|
||||
if (vid->hAudio2)
|
||||
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
|
||||
|
||||
FinishTask (task);
|
||||
|
||||
@@ -315,7 +350,9 @@ TFB_PlayVideo (VIDEO_REF VidRef, uint32 x, uint32 y)
|
||||
vid->cur_frame = -1;
|
||||
vid->want_frame = -1;
|
||||
|
||||
if (vid->hAudio == 0)
|
||||
vid->hAudio = LoadMusicFile (vid->decoder->filename);
|
||||
|
||||
StopMusic ();
|
||||
|
||||
if (vid->decoder->audio_synced)
|
||||
@@ -375,10 +412,17 @@ TFB_StopVideo (VIDEO_REF VidRef)
|
||||
|
||||
if (vid->hAudio)
|
||||
{
|
||||
StopMusic ();
|
||||
if (vid->hAudio) {
|
||||
stopAudioStream (vid->hAudio, SPEECH_SOURCE);
|
||||
DestroyMusic (vid->hAudio);
|
||||
vid->hAudio = 0;
|
||||
}
|
||||
if (vid->hAudio2) {
|
||||
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
|
||||
DestroyMusic (vid->hAudio2);
|
||||
vid->hAudio2 = 0;
|
||||
}
|
||||
}
|
||||
if (vid->frame)
|
||||
{
|
||||
TFB_DrawScreen_DeleteImage (vid->frame);
|
||||
|
||||
@@ -1733,9 +1733,14 @@ DoPickShip (MELEE_STATE *pMS)
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
else if (PulsedInputState.menu[KEY_MENU_SPECIAL])
|
||||
else if (PulsedInputState.menu[KEY_MENU_SPECIAL]
|
||||
&& (pMeleeState->CurIndex != (BYTE)~0))
|
||||
{
|
||||
BOOLEAN (*InputFunc) (struct melee_state *pInputState);
|
||||
InputFunc = pMS->InputFunc;
|
||||
pMS->InputFunc = 0; /* disable ship flashing */
|
||||
DoShipSpin (pMS->CurIndex, (MUSIC_REF)0);
|
||||
pMS->InputFunc = InputFunc;
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@@ -66,6 +66,10 @@ static const COORD hangar_x_coords[HANGAR_SHIPS_ROW] =
|
||||
#define HANGAR_ROWS (HANGAR_SHIPS / HANGAR_SHIPS_ROW)
|
||||
#define HANGAR_ANIM_RATE 15 // fps
|
||||
|
||||
/* This is a temporary stopgap to disable shipspin attempts here until
|
||||
they actually work */
|
||||
#undef WANT_SHIP_SPINS
|
||||
|
||||
enum
|
||||
{
|
||||
SHIPYARD_CREW,
|
||||
|
||||
Reference in New Issue
Block a user