Cleanup of 3DO ship spin support

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2721 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2007-04-05 06:28:58 +00:00
parent c1b7ca97f8
commit cdb51cf448
13 changed files with 127 additions and 76 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.7: Changes towards version 0.7:
- Cleanup of 3DO ship spin support; spin speech works now - Alex
- No longer creating and mounting a temporary directory. It is no longer - No longer creating and mounting a temporary directory. It is no longer
used, but it might be again at some point, for loadable modules. - SvdB used, but it might be again at some point, for loadable modules. - SvdB
- Added RNG functions that work on a supplied state - SvdB - Added RNG functions that work on a supplied state - SvdB
+11 -8
View File
@@ -31,11 +31,15 @@
#include "libs/inplib.h" #include "libs/inplib.h"
/* Some ship spin animations contain extra frames that must be discarded. */
#define SHIP_SPIN_LOOP_FRAME 89
void void
DoShipSpin (COUNT index, MUSIC_REF hMusic) DoShipSpin (COUNT index, MUSIC_REF hMusic)
{ {
#ifdef WANT_SHIP_SPINS #ifdef WANT_SHIP_SPINS
char buf[30]; char vnbuf[32];
char snbuf[32];
BYTE clut_buf[1]; BYTE clut_buf[1];
RECT old_r, r; RECT old_r, r;
@@ -50,8 +54,9 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic)
FreeHyperData (); FreeHyperData ();
sprintf (buf, "slides/spins/ship%02d.duk", index); sprintf (vnbuf, "slides/spins/ship%02u.duk", (unsigned)index);
DoFMV (buf, "slides/spins/spin.aif", FALSE); sprintf (snbuf, "slides/spins/ship%02u.aif", (unsigned)index);
DoFMVEx (vnbuf, "slides/spins/spin.aif", snbuf, SHIP_SPIN_LOOP_FRAME);
GetContextClipRect (&old_r); GetContextClipRect (&old_r);
r.corner.x = r.corner.y = 0; r.corner.x = r.corner.y = 0;
@@ -138,8 +143,7 @@ Introduction (void)
/* by default we do 3DO cinematics; or PC slides when 3DO files are /* by default we do 3DO cinematics; or PC slides when 3DO files are
* not present */ * not present */
if (optWhichIntro == OPT_PC || if (optWhichIntro == OPT_PC || !DoFMV ("slides/intro/intro.duk"))
!DoFMV ("slides/intro/intro.duk", NULL, TRUE))
ShowPresentation ( CaptureStringTable ( ShowPresentation ( CaptureStringTable (
LoadStringTable (INTROPRES_STRTAB))); LoadStringTable (INTROPRES_STRTAB)));
@@ -157,8 +161,7 @@ Victory (void)
/* by default we do 3DO cinematics; or PC slides when 3DO files are /* by default we do 3DO cinematics; or PC slides when 3DO files are
* not present */ * not present */
if (optWhichIntro == OPT_PC || if (optWhichIntro == OPT_PC || !DoFMV ("slides/ending/victory.duk"))
!DoFMV ("slides/ending/victory.duk", NULL, TRUE))
ShowPresentation ( CaptureStringTable ( ShowPresentation ( CaptureStringTable (
LoadStringTable (FINALPRES_STRTAB))); LoadStringTable (FINALPRES_STRTAB)));
@@ -169,7 +172,7 @@ Victory (void)
void void
Logo (void) Logo (void)
{ {
DoFMV ("logo", NULL, FALSE); DoFMV ("logo");
} }
+4 -2
View File
@@ -28,8 +28,10 @@ extern void Victory (void);
#include "libs/sndlib.h" #include "libs/sndlib.h"
extern void DoShipSpin (COUNT index, MUSIC_REF hMusic); extern void DoShipSpin (COUNT index, MUSIC_REF hMusic);
extern BOOLEAN DoFMV (const char *name, const char *loopname, extern BOOLEAN DoFMV (const char *name);
BOOLEAN uninit); extern BOOLEAN DoFMVEx (const char *name, const char *audname,
const char *speechname, DWORD loopframe);
extern BOOLEAN ShowPresentation (STRING PresStr); extern BOOLEAN ShowPresentation (STRING PresStr);
extern BOOLEAN ShowPresentationFile (const char *name); extern BOOLEAN ShowPresentationFile (const char *name);
+22 -3
View File
@@ -27,7 +27,7 @@
#include "libs/graphics/gfx_common.h" #include "libs/graphics/gfx_common.h"
#include "libs/graphics/drawable.h" #include "libs/graphics/drawable.h"
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
//#include "libs/vidlib.h" #include "libs/vidlib.h"
#include "libs/inplib.h" #include "libs/inplib.h"
#include "libs/log.h" #include "libs/log.h"
@@ -73,21 +73,40 @@ static BOOLEAN DoPresentation (void *pIS);
BOOLEAN BOOLEAN
DoFMV (const char *name, const char *loopname, BOOLEAN uninit) DoFMVEx (const char *name, const char *audname, const char *speechname,
DWORD loopframe)
{ {
VIDEO_REF VidRef; VIDEO_REF VidRef;
MUSIC_REF AudRef = 0;
MUSIC_REF SpeechRef = 0;
VidRef = LoadVideoFile (name); VidRef = LoadVideoFile (name);
if (!VidRef) if (!VidRef)
return FALSE; return FALSE;
VidPlay (VidRef, loopname, uninit); if (audname)
AudRef = LoadMusicFile (audname);
if (speechname)
SpeechRef = LoadMusicFile (speechname);
VidPlayEx (VidRef, AudRef, SpeechRef, loopframe);
VidDoInput (); VidDoInput ();
VidStop (); VidStop ();
DestroyVideo (VidRef); DestroyVideo (VidRef);
if (SpeechRef)
DestroyMusic (SpeechRef);
if (AudRef)
DestroyMusic (AudRef);
return TRUE; return TRUE;
} }
BOOLEAN
DoFMV (const char *name)
{
return DoFMVEx (name, NULL, NULL, VID_NO_LOOP);
}
static BOOLEAN static BOOLEAN
ParseColorString (const char *Src, COLOR* pColor) ParseColorString (const char *Src, COLOR* pColor)
{ {
@@ -23,7 +23,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "libs/gfxlib.h" #include "libs/gfxlib.h"
#include "libs/vidlib.h"
#include "libs/misc.h" #include "libs/misc.h"
// driver for TFB_InitGraphics // driver for TFB_InitGraphics
+2
View File
@@ -72,6 +72,8 @@ extern void PLRStop (MUSIC_REF MusicRef);
extern BOOLEAN PLRPlaying (MUSIC_REF MusicRef); extern BOOLEAN PLRPlaying (MUSIC_REF MusicRef);
extern void PLRPause (MUSIC_REF MusicRef); extern void PLRPause (MUSIC_REF MusicRef);
extern void PLRResume (MUSIC_REF MusicRef); extern void PLRResume (MUSIC_REF MusicRef);
extern void PlaySpeech (MUSIC_REF SpeechRef);
extern void StopSpeech (void);
extern void PlayChannel (COUNT channel, void *sample, SoundPosition pos, extern void PlayChannel (COUNT channel, void *sample, SoundPosition pos,
void *positional_object, unsigned char priority); void *positional_object, unsigned char priority);
extern BOOLEAN ChannelPlaying (COUNT Channel); extern BOOLEAN ChannelPlaying (COUNT Channel);
+31
View File
@@ -22,6 +22,7 @@
static MUSIC_REF curMusicRef; static MUSIC_REF curMusicRef;
static MUSIC_REF curSpeechRef;
void void
PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority) PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
@@ -95,6 +96,36 @@ PLRResume (MUSIC_REF MusicRef)
} }
} }
void
PlaySpeech (MUSIC_REF SpeechRef)
{
TFB_SoundSample **pmus;
LockMusicData (SpeechRef, &pmus);
if (pmus)
{
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PlayStream (*pmus, SPEECH_SOURCE, false, false, true);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
curSpeechRef = SpeechRef;
}
}
void
StopSpeech (void)
{
if (!curSpeechRef)
return;
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
StopStream (SPEECH_SOURCE);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
UnlockMusicData (curSpeechRef);
curSpeechRef = 0;
}
BOOLEAN BOOLEAN
DestroyMusic (MUSIC_REF MusicRef) DestroyMusic (MUSIC_REF MusicRef)
{ {
-6
View File
@@ -111,8 +111,6 @@ typedef struct tfb_duckvideodecoder
#define DUCK_GENERAL_FPS 14.622f #define DUCK_GENERAL_FPS 14.622f
#define DUCK_MAX_FRAME_SIZE 0x8000U #define DUCK_MAX_FRAME_SIZE 0x8000U
#define DUCK_END_OF_SEQUENCE 1 #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 static void
dukv_DecodeFrame (uint8* src_p, uint32* dst_p, uint32 wb, uint32 hb, dukv_DecodeFrame (uint8* src_p, uint32* dst_p, uint32 wb, uint32 hb,
@@ -705,10 +703,6 @@ dukv_DecodeNext (THIS_PTR)
dukv_RenderFrame (This); dukv_RenderFrame (This);
if (dukv->decoder.looping
&& (dukv->decoder.cur_frame == VIDEO_SPIN_LOOP_FRAME))
VideoDecoder_SeekFrame (&dukv->decoder, 0);
return 1; return 1;
} }
+28 -28
View File
@@ -23,6 +23,7 @@
#define NULL_VIDEO_REF (0) #define NULL_VIDEO_REF (0)
static VIDEO_REF _cur_video = NULL_VIDEO_REF; static VIDEO_REF _cur_video = NULL_VIDEO_REF;
static MUSIC_REF _cur_speech = 0;
BOOLEAN BOOLEAN
InitVideoPlayer (BOOLEAN useCDROM) InitVideoPlayer (BOOLEAN useCDROM)
@@ -50,12 +51,14 @@ UninitVideoPlayer (void)
void void
VidStop () VidStop ()
{ {
if (_cur_speech)
StopSpeech ();
if (_cur_video) if (_cur_video)
{ {
TFB_StopVideo (_cur_video); TFB_StopVideo (_cur_video);
TFB_FadeClearScreen (); TFB_FadeClearScreen ();
} }
_cur_speech = 0;
_cur_video = NULL_VIDEO_REF; _cur_video = NULL_VIDEO_REF;
} }
@@ -73,9 +76,8 @@ VidPlaying ()
} }
VIDEO_TYPE VIDEO_TYPE
VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit) VidPlayEx (VIDEO_REF VidRef, MUSIC_REF AudRef, MUSIC_REF SpeechRef,
// uninit was used to uninit the game kernel DWORD LoopFrame)
// before spawning duck exe
{ {
VIDEO_TYPE ret; VIDEO_TYPE ret;
TFB_VideoClip* vid = (TFB_VideoClip*) VidRef; TFB_VideoClip* vid = (TFB_VideoClip*) VidRef;
@@ -83,14 +85,22 @@ VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit)
if (!vid) if (!vid)
return NO_FMV; return NO_FMV;
if (loopname != NULL) { if (AudRef)
vid->hAudio2 = LoadMusicFile (loopname); {
if (vid->hAudio)
DestroyMusic (vid->hAudio);
vid->hAudio = AudRef;
vid->decoder->audio_synced = FALSE; vid->decoder->audio_synced = FALSE;
vid->decoder->looping = TRUE;
} }
vid->loop_frame = LoopFrame;
vid->loop_to = 0;
if (_cur_speech)
StopSpeech ();
if (_cur_video) if (_cur_video)
TFB_StopVideo (_cur_video); TFB_StopVideo (_cur_video);
_cur_speech = 0;
_cur_video = NULL_VIDEO_REF; _cur_video = NULL_VIDEO_REF;
TFB_FadeClearScreen (); TFB_FadeClearScreen ();
@@ -103,6 +113,11 @@ VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit)
{ {
_cur_video = VidRef; _cur_video = VidRef;
ret = SOFTWARE_FMV; ret = SOFTWARE_FMV;
if (SpeechRef)
{
PlaySpeech (SpeechRef);
_cur_speech = SpeechRef;
}
} }
else else
{ {
@@ -110,12 +125,15 @@ VidPlay (VIDEO_REF VidRef, const char *loopname, BOOLEAN uninit)
} }
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
/* dodge compiler warnings */
(void) uninit;
return ret; return ret;
} }
VIDEO_TYPE
VidPlay (VIDEO_REF VidRef)
{
return VidPlayEx (VidRef, 0, 0, VID_NO_LOOP);
}
void void
VidDoInput (void) VidDoInput (void)
{ {
@@ -128,9 +146,6 @@ _init_video_file(const char *pStr)
{ {
TFB_VideoClip* vid; TFB_VideoClip* vid;
TFB_VideoDecoder* dec; TFB_VideoDecoder* dec;
char* filename;
char* pext;
MUSIC_REF altsound;
dec = VideoDecoder_Load (contentDir, pStr); dec = VideoDecoder_Load (contentDir, pStr);
if (!dec) if (!dec)
@@ -143,21 +158,6 @@ _init_video_file(const char *pStr)
vid->h = vid->decoder->h; vid->h = vid->decoder->h;
vid->guard = CreateMutex ("video guard", SYNC_CLASS_VIDEO); 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; return (VIDEO_REF) vid;
} }
+3 -1
View File
@@ -37,13 +37,15 @@ typedef struct tfb_videoclip
RECT dst_rect; // destination screen rect RECT dst_rect; // destination screen rect
RECT src_rect; // source rect RECT src_rect; // source rect
MUSIC_REF hAudio; MUSIC_REF hAudio;
MUSIC_REF hAudio2;
Task play_task; Task play_task;
uint32 frame_time; // time when next frame should be rendered uint32 frame_time; // time when next frame should be rendered
TFB_Image* frame; // frame preped and optimized for rendering TFB_Image* frame; // frame preped and optimized for rendering
uint32 cur_frame; // index of frame currently displayed uint32 cur_frame; // index of frame currently displayed
uint32 max_frame_wait; uint32 max_frame_wait;
bool playing; bool playing;
bool own_audio;
uint32 loop_frame; // frame index to loop from
uint32 loop_to; // frame index to loop to
Mutex guard; Mutex guard;
uint32 want_frame; // audio-signaled desired frame index uint32 want_frame; // audio-signaled desired frame index
+15 -21
View File
@@ -147,9 +147,7 @@ as_video_play_task (void *data)
LockMutex (vid->guard); LockMutex (vid->guard);
want_frame = vid->want_frame; want_frame = vid->want_frame;
if (vid->hAudio) if (vid->hAudio)
startAudioStream (vid->hAudio, SPEECH_SOURCE, FALSE); PlayMusic (vid->hAudio, FALSE, 1);
if (vid->hAudio2)
startAudioStream (vid->hAudio2, MUSIC_SOURCE, TRUE);
UnlockMutex (vid->guard); UnlockMutex (vid->guard);
clagged = 0; clagged = 0;
@@ -235,9 +233,7 @@ as_video_play_task (void *data)
ret = VideoDecoder_Decode (vid->decoder); ret = VideoDecoder_Decode (vid->decoder);
} }
if (vid->hAudio) if (vid->hAudio)
stopAudioStream (vid->hAudio, SPEECH_SOURCE); StopMusic ();
if (vid->hAudio2)
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
vid->playing = false; vid->playing = false;
FinishTask (task); FinishTask (task);
@@ -261,10 +257,7 @@ video_play_task (void *data)
LockMutex (vid->guard); LockMutex (vid->guard);
if (vid->hAudio) if (vid->hAudio)
startAudioStream (vid->hAudio, SPEECH_SOURCE, FALSE); PlayMusic (vid->hAudio, (vid->loop_frame != VID_NO_LOOP), 1);
if (vid->hAudio2)
startAudioStream (vid->hAudio2, MUSIC_SOURCE, TRUE);
UnlockMutex (vid->guard); UnlockMutex (vid->guard);
@@ -293,13 +286,14 @@ video_play_task (void *data)
UnlockMutex (GraphicsLock); UnlockMutex (GraphicsLock);
FlushGraphics (); // needed to prevent half-frame updates FlushGraphics (); // needed to prevent half-frame updates
if (vid->cur_frame == vid->loop_frame)
VideoDecoder_SeekFrame (vid->decoder, vid->loop_to);
ret = VideoDecoder_Decode (vid->decoder); ret = VideoDecoder_Decode (vid->decoder);
} }
vid->playing = false; vid->playing = false;
if (vid->hAudio) if (vid->hAudio)
stopAudioStream (vid->hAudio, SPEECH_SOURCE); StopMusic ();
if (vid->hAudio2)
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
FinishTask (task); FinishTask (task);
@@ -350,8 +344,11 @@ TFB_PlayVideo (VIDEO_REF VidRef, uint32 x, uint32 y)
vid->cur_frame = -1; vid->cur_frame = -1;
vid->want_frame = -1; vid->want_frame = -1;
if (vid->hAudio == 0) if (!vid->hAudio)
{
vid->hAudio = LoadMusicFile (vid->decoder->filename); vid->hAudio = LoadMusicFile (vid->decoder->filename);
vid->own_audio = true;
}
StopMusic (); StopMusic ();
@@ -412,15 +409,12 @@ TFB_StopVideo (VIDEO_REF VidRef)
if (vid->hAudio) if (vid->hAudio)
{ {
if (vid->hAudio) { StopMusic ();
stopAudioStream (vid->hAudio, SPEECH_SOURCE); if (vid->own_audio)
{
DestroyMusic (vid->hAudio); DestroyMusic (vid->hAudio);
vid->hAudio = 0; vid->hAudio = 0;
} vid->own_audio = false;
if (vid->hAudio2) {
stopAudioStream (vid->hAudio2, MUSIC_SOURCE);
DestroyMusic (vid->hAudio2);
vid->hAudio2 = 0;
} }
} }
if (vid->frame) if (vid->frame)
+6 -3
View File
@@ -19,7 +19,8 @@
#ifndef _VIDLIB_H #ifndef _VIDLIB_H
#define _VIDLIB_H #define _VIDLIB_H
#include "compiler.h" #include "libs/compiler.h"
#include "libs/sndlib.h"
typedef enum typedef enum
{ {
@@ -35,8 +36,10 @@ extern void UninitVideoPlayer (void);
extern VIDEO_REF LoadVideoFile (const char *pStr); extern VIDEO_REF LoadVideoFile (const char *pStr);
extern BOOLEAN DestroyVideo (VIDEO_REF VideoRef); extern BOOLEAN DestroyVideo (VIDEO_REF VideoRef);
extern VIDEO_TYPE VidPlay (VIDEO_REF VidRef, const char *loopname, extern VIDEO_TYPE VidPlay (VIDEO_REF VidRef);
BOOLEAN uninit); extern VIDEO_TYPE VidPlayEx (VIDEO_REF VidRef, MUSIC_REF AudRef,
MUSIC_REF SpeechRef, DWORD LoopFrame);
#define VID_NO_LOOP (0U-1)
extern void VidStop (void); extern void VidStop (void);
extern VIDEO_REF VidPlaying (void); extern VIDEO_REF VidPlaying (void);
extern void VidDoInput (void); extern void VidDoInput (void);
+1
View File
@@ -29,6 +29,7 @@
#include "libs/strlib.h" #include "libs/strlib.h"
#include "libs/reslib.h" #include "libs/reslib.h"
#include "libs/inplib.h" #include "libs/inplib.h"
#include "libs/vidlib.h"
#include "libs/sound/sound.h" #include "libs/sound/sound.h"
#include "libs/resource/stringbank.h" #include "libs/resource/stringbank.h"
#include "libs/log.h" #include "libs/log.h"