Trackplayer rewrite; fixes several obscure bugs; SpliceTrack() still a mess
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3228 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
Changes towards version 0.7:
|
||||
- Trackplayer rewrite; fixed many bugs - Alex
|
||||
- Source tree reorg: libs/ moved out of sc2code/, msvc++/ moved to
|
||||
build/msvc6/, src/sc2code/ renamed to src/uqm/ - Coredev
|
||||
- Druuge no longer turn hostile after attempting a salvage (bug #1013) - Alex
|
||||
|
||||
@@ -34,8 +34,8 @@ PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
|
||||
if (pmus)
|
||||
{
|
||||
LockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
|
||||
PlayStream ((*pmus), MUSIC_SOURCE, Continuous,
|
||||
speechVolumeScale == 0.0f, true);
|
||||
// Always scope the music data, we may need it
|
||||
PlayStream ((*pmus), MUSIC_SOURCE, Continuous, true, true);
|
||||
UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
|
||||
|
||||
curMusicRef = MusicRef;
|
||||
@@ -104,6 +104,7 @@ snd_PlaySpeech (MUSIC_REF SpeechRef)
|
||||
if (pmus)
|
||||
{
|
||||
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||
// Do not need to scope the music-as-speech as of now
|
||||
PlayStream (*pmus, SPEECH_SOURCE, false, false, true);
|
||||
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
|
||||
|
||||
|
||||
+29
-10
@@ -102,7 +102,10 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope,
|
||||
soundSource[source].sbuf_size = pos + PAD_SCOPE_BYTES;
|
||||
soundSource[source].sbuf_start = pos;
|
||||
soundSource[source].sbuf_lasttime = GetTimeCounter ();
|
||||
soundSource[source].start_time = (sint32)GetTimeCounter () - offset;
|
||||
// Adjust the start time so it looks like the stream has been playing
|
||||
// from the very beginning
|
||||
soundSource[source].start_time = GetTimeCounter () - offset;
|
||||
soundSource[source].pause_time = 0;
|
||||
soundSource[source].stream_should_be_playing = TRUE;
|
||||
audio_SourcePlay (soundSource[source].handle);
|
||||
}
|
||||
@@ -110,6 +113,8 @@ PlayStream (TFB_SoundSample *sample, uint32 source, bool looping, bool scope,
|
||||
void
|
||||
StopStream (uint32 source)
|
||||
{
|
||||
StopSource (source);
|
||||
|
||||
soundSource[source].stream_should_be_playing = FALSE;
|
||||
soundSource[source].sample = NULL;
|
||||
|
||||
@@ -122,20 +127,28 @@ StopStream (uint32 source)
|
||||
soundSource[source].sbuf_start = 0;
|
||||
soundSource[source].sbuf_size = 0;
|
||||
soundSource[source].sbuf_offset = 0;
|
||||
|
||||
StopSource (source);
|
||||
soundSource[source].pause_time = 0;
|
||||
}
|
||||
|
||||
void
|
||||
PauseStream (uint32 source)
|
||||
{
|
||||
soundSource[source].stream_should_be_playing = FALSE;
|
||||
if (!soundSource[source].pause_time)
|
||||
soundSource[source].pause_time = GetTimeCounter ();
|
||||
audio_SourcePause (soundSource[source].handle);
|
||||
}
|
||||
|
||||
void
|
||||
ResumeStream (uint32 source)
|
||||
{
|
||||
if (soundSource[source].pause_time)
|
||||
{ // Adjust the start time so it looks like the stream has
|
||||
// been playing all this time non-stop
|
||||
soundSource[source].start_time += GetTimeCounter ()
|
||||
- soundSource[source].pause_time;
|
||||
}
|
||||
soundSource[source].pause_time = 0;
|
||||
soundSource[source].stream_should_be_playing = TRUE;
|
||||
audio_SourcePlay (soundSource[source].handle);
|
||||
}
|
||||
@@ -504,29 +517,35 @@ GraphForegroundStream (uint8 *data, sint32 width, sint32 height)
|
||||
long energy;
|
||||
|
||||
|
||||
if (speechVolumeScale != 0.0f)
|
||||
{ // Use speech waveform when speech is enabled
|
||||
// Prefer speech to music
|
||||
source_num = SPEECH_SOURCE;
|
||||
source = &soundSource[source_num];
|
||||
LockMutex (source->stream_mutex);
|
||||
if (speechVolumeScale != 0.0f && (!source->sample ||
|
||||
!source->sample->decoder || !source->sample->decoder->is_null))
|
||||
{ // Use speech waveform, since it's available
|
||||
// Step is picked experimentally. Using step of 1 sample at 11025Hz,
|
||||
// because human speech is mostly in the low frequencies, and it looks
|
||||
// better this way.
|
||||
step = 1;
|
||||
|
||||
}
|
||||
else if (musicVolumeScale != 0.0f)
|
||||
{ // Use music waveform when speech is disabled
|
||||
{ // We do not have speech -- use music waveform
|
||||
UnlockMutex (source->stream_mutex);
|
||||
source_num = MUSIC_SOURCE;
|
||||
source = &soundSource[source_num];
|
||||
LockMutex (source->stream_mutex);
|
||||
|
||||
// Step is picked experimentally. Using step of 4 samples at 11025Hz.
|
||||
// It looks better this way.
|
||||
step = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // We do not have anything usable
|
||||
UnlockMutex (source->stream_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
source = &soundSource[source_num];
|
||||
LockMutex (source->stream_mutex);
|
||||
if (!PlayingStream (source_num) || !source->sample
|
||||
|| !source->sample->decoder || !source->sbuffer
|
||||
|| source->sbuf_size == 0)
|
||||
|
||||
@@ -17,28 +17,23 @@
|
||||
#ifndef TRACKINT_H
|
||||
#define TRACKINT_H
|
||||
|
||||
typedef struct tfb_soundchain
|
||||
struct tfb_soundchunk
|
||||
{
|
||||
TFB_SoundDecoder *decoder; // points at the decoder to read from
|
||||
float start_time;
|
||||
int tag_me;
|
||||
uint32 track_num;
|
||||
UNICODE *text;
|
||||
TFB_TrackCB callback;
|
||||
struct tfb_soundchain *next;
|
||||
} TFB_SoundChain;
|
||||
TFB_SoundDecoder *decoder; // decoder for this chunk
|
||||
float start_time; // relative time from track start
|
||||
int tag_me; // set for chunks with subtitles
|
||||
uint32 track_num; // logical track #, comm code needs this
|
||||
UNICODE *text; // subtitle text
|
||||
TFB_TrackCB callback; // comm callback, executed on chunk start
|
||||
struct tfb_soundchunk *next;
|
||||
};
|
||||
|
||||
typedef struct tfb_soundchaindata
|
||||
{
|
||||
TFB_SoundChain *read_chain_ptr; // points to chain read poistion
|
||||
TFB_SoundChain *play_chain_ptr; // points to chain playing position
|
||||
typedef struct tfb_soundchunk TFB_SoundChunk;
|
||||
|
||||
} TFB_SoundChainData;
|
||||
TFB_SoundChunk *create_SoundChunk (TFB_SoundDecoder *decoder, float start_time);
|
||||
void destroy_SoundChunk_list (TFB_SoundChunk *chain);
|
||||
TFB_SoundChunk *find_next_page (TFB_SoundChunk *cur);
|
||||
TFB_SoundChunk *find_prev_page (TFB_SoundChunk *cur);
|
||||
|
||||
extern TFB_SoundChain *chain_head;
|
||||
|
||||
TFB_SoundChain *create_soundchain (TFB_SoundDecoder *decoder, float startTime);
|
||||
void destroy_soundchain (TFB_SoundChain *chain);
|
||||
TFB_SoundChain *get_chain_previous (TFB_SoundChain *head, TFB_SoundChain *current);
|
||||
|
||||
#endif // TRACKINT_H
|
||||
|
||||
+410
-395
File diff suppressed because it is too large
Load Diff
@@ -21,22 +21,33 @@
|
||||
|
||||
#include "libs/compiler.h"
|
||||
|
||||
|
||||
typedef void (*TFB_TrackCB) (void);
|
||||
|
||||
#define ACCEL_SCROLL_SPEED 300
|
||||
|
||||
void ResumeTrack(void);
|
||||
void PauseTrack(void);
|
||||
COUNT PlayingTrack(void);
|
||||
void JumpTrack(void);
|
||||
void FastForward_Smooth(void);
|
||||
int FastForward_Page(void);
|
||||
void FastReverse_Smooth(void);
|
||||
void FastReverse_Page(void);
|
||||
void StopTrack(void);
|
||||
void SpliceTrack(UNICODE *filespec, UNICODE *textspec, UNICODE *TimeStamp, TFB_TrackCB cb);
|
||||
void SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText);
|
||||
int GetSoundInfo (int max_len);
|
||||
extern void PlayTrack (void);
|
||||
extern void StopTrack (void);
|
||||
extern void JumpTrack (void);
|
||||
extern void PauseTrack (void);
|
||||
extern void ResumeTrack (void);
|
||||
extern COUNT PlayingTrack (void);
|
||||
|
||||
extern void FastReverse_Smooth (void);
|
||||
extern void FastForward_Smooth (void);
|
||||
extern void FastReverse_Page (void);
|
||||
extern void FastForward_Page (void);
|
||||
|
||||
extern void SpliceTrack (UNICODE *filespec, UNICODE *textspec, UNICODE *TimeStamp, TFB_TrackCB cb);
|
||||
extern void SpliceMultiTrack (UNICODE *TrackNames[], UNICODE *TrackText);
|
||||
|
||||
extern int GetTrackPosition (int in_units);
|
||||
|
||||
typedef struct tfb_soundchunk *SUBTITLE_REF;
|
||||
|
||||
extern SUBTITLE_REF GetFirstTrackSubtitle (void);
|
||||
extern SUBTITLE_REF GetNextTrackSubtitle (SUBTITLE_REF LastRef);
|
||||
extern const UNICODE *GetTrackSubtitleText (SUBTITLE_REF SubRef);
|
||||
|
||||
extern const UNICODE *GetTrackSubtitle (void);
|
||||
|
||||
#endif
|
||||
|
||||
+4
-2
@@ -507,6 +507,7 @@ BOOLEAN
|
||||
loadAddon (const char *addon)
|
||||
{
|
||||
uio_DirHandle *addonsDir, *addonDir;
|
||||
int numLoaded;
|
||||
|
||||
addonsDir = uio_openDirRelative (contentDir, "addons", 0);
|
||||
if (addonsDir == NULL)
|
||||
@@ -525,11 +526,12 @@ loadAddon (const char *addon)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
loadIndices (addonDir);
|
||||
numLoaded = loadIndices (addonDir);
|
||||
|
||||
uio_closeDir (addonDir);
|
||||
uio_closeDir (addonsDir);
|
||||
return TRUE;
|
||||
|
||||
return (numLoaded > 0);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+112
-130
@@ -38,7 +38,7 @@
|
||||
#include "libs/graphics/gfx_common.h"
|
||||
#include "libs/inplib.h"
|
||||
#include "libs/sound/sound.h"
|
||||
#include "libs/sound/trackint.h"
|
||||
#include "libs/sound/trackplayer.h"
|
||||
#include "libs/log.h"
|
||||
|
||||
#include <ctype.h>
|
||||
@@ -76,14 +76,18 @@ typedef struct encounter_state
|
||||
} ENCOUNTER_STATE;
|
||||
|
||||
static ENCOUNTER_STATE *pCurInputState;
|
||||
static SUBTITLE_STATE subtitle_state = DONE_SUBTITLE;
|
||||
static Mutex subtitle_mutex;
|
||||
|
||||
TEXT SubtitleText;
|
||||
// Mutex guards accesses to SubtitleText, last_subtitle and clear_subtitles.
|
||||
static Mutex subtitle_mutex;
|
||||
// These vars are indirectly accessed by the ambient_anim_task
|
||||
static volatile BOOLEAN clear_subtitles;
|
||||
static TEXT SubtitleText;
|
||||
static const UNICODE * volatile last_subtitle;
|
||||
|
||||
CONTEXT TextCacheContext;
|
||||
FRAME TextCacheFrame;
|
||||
static CONTEXT TextCacheContext;
|
||||
static FRAME TextCacheFrame;
|
||||
|
||||
volatile BOOLEAN ClearSummary;
|
||||
|
||||
RECT CommWndRect = {
|
||||
// default values; actually inited by HailAlien()
|
||||
@@ -91,6 +95,10 @@ RECT CommWndRect = {
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static void ClearSubtitles (void);
|
||||
static void CheckSubtitles (void);
|
||||
|
||||
|
||||
/* _count_lines - sees how many lines a given input string would take to
|
||||
* display given the line wrapping information
|
||||
*/
|
||||
@@ -432,9 +440,6 @@ uninit_communication (void)
|
||||
DestroyMutex (subtitle_mutex);
|
||||
}
|
||||
|
||||
volatile BOOLEAN ClearSummary;
|
||||
static volatile BOOLEAN ClearSubtitle;
|
||||
|
||||
static void
|
||||
RefreshResponses (ENCOUNTER_STATE *pES)
|
||||
{
|
||||
@@ -488,8 +493,6 @@ RefreshResponses (ENCOUNTER_STATE *pES)
|
||||
static void
|
||||
FeedbackPlayerPhrase (UNICODE *pStr)
|
||||
{
|
||||
last_subtitle = NULL;
|
||||
|
||||
SetContext (SpaceContext);
|
||||
|
||||
BatchGraphics ();
|
||||
@@ -551,52 +554,54 @@ SpewPhrases (COUNT wait_track)
|
||||
DWORD TimeIn;
|
||||
COUNT which_track;
|
||||
FRAME F;
|
||||
BOOLEAN passed = TRUE;
|
||||
BOOLEAN rewind = FALSE;
|
||||
|
||||
TimeIn = GetTimeCounter ();
|
||||
|
||||
ContinuityBreak = FALSE;
|
||||
F = CommData.AlienFrame;
|
||||
if (wait_track == 0)
|
||||
{
|
||||
{ // Restarting with a rewind
|
||||
wait_track = (COUNT)~0;
|
||||
which_track = (COUNT)~0;
|
||||
goto Rewind;
|
||||
rewind = TRUE;
|
||||
}
|
||||
|
||||
which_track = PlayingTrack ();
|
||||
if (which_track == 0)
|
||||
if (which_track == 0 && !rewind)
|
||||
{
|
||||
// initial start of player
|
||||
if (wait_track == 1 || wait_track == (COUNT)~0)
|
||||
{
|
||||
ResumeTrack ();
|
||||
UnlockMutex (GraphicsLock);
|
||||
PlayTrack ();
|
||||
do
|
||||
{
|
||||
TaskSwitch ();
|
||||
LockMutex (GraphicsLock);
|
||||
which_track = PlayingTrack ();
|
||||
UnlockMutex (GraphicsLock);
|
||||
} while (!which_track);
|
||||
LockMutex (GraphicsLock);
|
||||
}
|
||||
}
|
||||
else if (which_track <= wait_track)
|
||||
{ // XXX: I don't know why this is here, but it is not harmful.
|
||||
// We never actually pause in comm.
|
||||
ResumeTrack ();
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
BOOLEAN left = FALSE;
|
||||
BOOLEAN right = FALSE;
|
||||
|
||||
if (GLOBAL (CurrentActivity) & CHECK_ABORT)
|
||||
{
|
||||
which_track = 0; // abort
|
||||
break;
|
||||
}
|
||||
|
||||
UnlockMutex (GraphicsLock);
|
||||
/* FIXME: is this a remnant of 128-tick clock?
|
||||
* with 120-tick clock this will sleep for 1 tick --
|
||||
* for 1/120th of a second; if ONE_SECOND is upgraded
|
||||
* it will probably sleep for 2/120th of a second.
|
||||
* Might need to be fixed.
|
||||
*/
|
||||
// XXX: Executing this loop 64 times a second is a bit extreme
|
||||
SleepThreadUntil (TimeIn + (ONE_SECOND / 64));
|
||||
TimeIn = GetTimeCounter ();
|
||||
#if DEMO_MODE || CREATE_JOURNAL
|
||||
@@ -608,17 +613,13 @@ SpewPhrases (COUNT wait_track)
|
||||
LockMutex (GraphicsLock);
|
||||
if (PulsedInputState.menu[KEY_MENU_CANCEL])
|
||||
{
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8));
|
||||
JumpTrack ();
|
||||
CommData.AlienFrame = F;
|
||||
do_subtitles ((void *)~0);
|
||||
return (FALSE);
|
||||
which_track = 0; // player stopped
|
||||
break;
|
||||
}
|
||||
|
||||
if (which_track)
|
||||
{
|
||||
BOOLEAN left = FALSE;
|
||||
BOOLEAN right = FALSE;
|
||||
CheckSubtitles ();
|
||||
|
||||
if (optSmoothScroll == OPT_PC)
|
||||
{
|
||||
left = PulsedInputState.menu[KEY_MENU_LEFT];
|
||||
@@ -629,58 +630,57 @@ SpewPhrases (COUNT wait_track)
|
||||
left = ImmediateInputState.menu[KEY_MENU_LEFT];
|
||||
right = ImmediateInputState.menu[KEY_MENU_RIGHT];
|
||||
}
|
||||
|
||||
if (right)
|
||||
{
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 3));
|
||||
if (optSmoothScroll == OPT_PC && !FastForward_Page ())
|
||||
{
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8));
|
||||
JumpTrack ();
|
||||
CommData.AlienFrame = F;
|
||||
do_subtitles ((void *)~0);
|
||||
return (FALSE);
|
||||
}
|
||||
if (optSmoothScroll == OPT_PC)
|
||||
FastForward_Page ();
|
||||
else if (optSmoothScroll == OPT_3DO)
|
||||
FastForward_Smooth ();
|
||||
ContinuityBreak = TRUE;
|
||||
// XXX: Ugly hack: This causes all animations (talking and ambient)
|
||||
// in ambient_anim_task to stop progressing. I see no reason why
|
||||
// the animations cannot continue while seeking. This hack has
|
||||
// spawned a multitude of workarounds in the comm code, and IMHO
|
||||
// should be removed.
|
||||
CommData.AlienFrame = 0;
|
||||
}
|
||||
else if (left)
|
||||
else if (left || rewind)
|
||||
{
|
||||
Rewind:
|
||||
rewind = FALSE;
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 4));
|
||||
if (optSmoothScroll == OPT_PC)
|
||||
FastReverse_Page ();
|
||||
else if (optSmoothScroll == OPT_3DO)
|
||||
FastReverse_Smooth ();
|
||||
ContinuityBreak = TRUE;
|
||||
// XXX: See ugly hack discussion above
|
||||
CommData.AlienFrame = 0;
|
||||
}
|
||||
else if (ContinuityBreak)
|
||||
{
|
||||
// This is only done once the seeking is over (in the smooth
|
||||
// scroll case, once the user releases the seek button)
|
||||
ContinuityBreak = FALSE;
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2));
|
||||
which_track = PlayingTrack ();
|
||||
if (which_track && which_track <= wait_track)
|
||||
{
|
||||
if (optSmoothScroll == OPT_3DO)
|
||||
ResumeTrack ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ContinuityBreak = FALSE;
|
||||
passed = (which_track != 0);
|
||||
break;
|
||||
}
|
||||
ContinuityBreak = FALSE;
|
||||
}
|
||||
else if (which_track == wait_track || wait_track == (COUNT)~0)
|
||||
{ // XXX: See ugly hack discussion above
|
||||
// Additionally, this used to have a buggy guard condition, which
|
||||
// would cause the animations to remain paused in a couple cases
|
||||
// after seeking back to the beginning.
|
||||
// Broken cases were: Syreen "several hours later" and Starbase
|
||||
// VUX Beast analysis by the scientist.
|
||||
CommData.AlienFrame = F;
|
||||
}
|
||||
} while (ContinuityBreak
|
||||
|| ((which_track = PlayingTrack ()) && which_track <= wait_track));
|
||||
|
||||
which_track = PlayingTrack ();
|
||||
|
||||
} while (ContinuityBreak || (which_track && which_track <= wait_track));
|
||||
|
||||
CommData.AlienFrame = F;
|
||||
do_subtitles ((void *)~0);
|
||||
ClearSubtitles ();
|
||||
|
||||
if (!which_track || wait_track == (COUNT)~0)
|
||||
{ // reached the end
|
||||
@@ -688,7 +688,9 @@ Rewind:
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
return (passed);
|
||||
// We can only get here when we got to the requested track
|
||||
// without ending or aborting
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOLEAN
|
||||
@@ -848,7 +850,7 @@ typedef struct summary_state
|
||||
// extended state
|
||||
BOOLEAN Initialized;
|
||||
BOOLEAN PrintNext;
|
||||
const TFB_SoundChain *NextSub;
|
||||
SUBTITLE_REF NextSub;
|
||||
const UNICODE *LeftOver;
|
||||
|
||||
} SUMMARY_STATE;
|
||||
@@ -863,7 +865,7 @@ DoConvSummary (SUMMARY_STATE *pSS)
|
||||
if (!pSS->Initialized)
|
||||
{
|
||||
pSS->PrintNext = TRUE;
|
||||
pSS->NextSub = chain_head;
|
||||
pSS->NextSub = GetFirstTrackSubtitle ();
|
||||
pSS->LeftOver = NULL;
|
||||
pSS->MenuRepeatDelay = 0;
|
||||
pSS->InputFunc = DoConvSummary;
|
||||
@@ -912,7 +914,7 @@ DoConvSummary (SUMMARY_STATE *pSS)
|
||||
oldFont = SetContextFont (TinyFont);
|
||||
|
||||
for (row = 0; row < MAX_SUMM_ROWS && pSS->NextSub;
|
||||
++row, pSS->NextSub = pSS->NextSub->next)
|
||||
++row, pSS->NextSub = GetNextTrackSubtitle (pSS->NextSub))
|
||||
{
|
||||
const unsigned char *next;
|
||||
|
||||
@@ -923,7 +925,7 @@ DoConvSummary (SUMMARY_STATE *pSS)
|
||||
}
|
||||
else
|
||||
{
|
||||
t.pStr = pSS->NextSub->text;
|
||||
t.pStr = GetTrackSubtitleText (pSS->NextSub);
|
||||
if (!t.pStr)
|
||||
continue;
|
||||
}
|
||||
@@ -995,6 +997,7 @@ SelectResponse (ENCOUNTER_STATE *pES)
|
||||
LockMutex (GraphicsLock);
|
||||
FeedbackPlayerPhrase (pES->phrase_buf);
|
||||
StopTrack ();
|
||||
ClearSubtitles ();
|
||||
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 2));
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
@@ -1181,7 +1184,7 @@ DoCommunication (ENCOUNTER_STATE *pES)
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
FlushColorXForms ();
|
||||
ClearSubtitle = FALSE;
|
||||
ClearSubtitles ();
|
||||
|
||||
StopMusic ();
|
||||
StopSound ();
|
||||
@@ -1378,8 +1381,6 @@ InitCommunication (CONVERSATION which_comm)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
last_subtitle = NULL;
|
||||
|
||||
LockMutex (GraphicsLock);
|
||||
|
||||
if (LastActivity & CHECK_LOAD)
|
||||
@@ -1654,62 +1655,6 @@ RaceCommunication (void)
|
||||
}
|
||||
}
|
||||
|
||||
SUBTITLE_STATE
|
||||
do_subtitles (UNICODE *pStr)
|
||||
{
|
||||
static UNICODE *last_page = NULL;
|
||||
LockMutex (subtitle_mutex);
|
||||
if (pStr == 0)
|
||||
{
|
||||
subtitle_state = DONE_SUBTITLE;
|
||||
UnlockMutex (subtitle_mutex);
|
||||
return (subtitle_state);
|
||||
}
|
||||
else if (pStr == (void *)~0)
|
||||
{
|
||||
subtitle_state = WAIT_SUBTITLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (last_page == pStr)
|
||||
{
|
||||
UnlockMutex (subtitle_mutex);
|
||||
return (subtitle_state);
|
||||
}
|
||||
subtitle_state = READ_SUBTITLE;
|
||||
ClearSubtitle = TRUE;
|
||||
}
|
||||
last_page = pStr;
|
||||
|
||||
switch (subtitle_state)
|
||||
{
|
||||
case READ_SUBTITLE:
|
||||
{
|
||||
/* Baseline may be updated by the ZFP */
|
||||
SubtitleText.baseline = CommData.AlienTextBaseline;
|
||||
SubtitleText.align = CommData.AlienTextAlign;
|
||||
SubtitleText.pStr = pStr;
|
||||
SubtitleText.CharCount = (COUNT)~0;
|
||||
subtitle_state = WAIT_SUBTITLE;
|
||||
break;
|
||||
}
|
||||
case WAIT_SUBTITLE:
|
||||
{
|
||||
subtitle_state = DONE_SUBTITLE;
|
||||
ClearSubtitle = TRUE;
|
||||
}
|
||||
case DONE_SUBTITLE:
|
||||
break;
|
||||
default:
|
||||
// Should not happen
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
UnlockMutex (subtitle_mutex);
|
||||
|
||||
return (subtitle_state);
|
||||
}
|
||||
|
||||
void
|
||||
RedrawSubtitles (void)
|
||||
{
|
||||
@@ -1718,23 +1663,60 @@ RedrawSubtitles (void)
|
||||
if (!optSubtitles)
|
||||
return;
|
||||
|
||||
LockMutex (subtitle_mutex);
|
||||
if (SubtitleText.pStr)
|
||||
{
|
||||
t = SubtitleText;
|
||||
add_text (1, &t);
|
||||
}
|
||||
UnlockMutex (subtitle_mutex);
|
||||
}
|
||||
|
||||
// Sets ClearSubtitle, returning the old value. The current subtitle state
|
||||
// is also returned, through sub_state
|
||||
// Returns clear_subtitles and resets it
|
||||
BOOLEAN
|
||||
SetClearSubtitle (BOOLEAN flag, SUBTITLE_STATE *sub_state)
|
||||
HaveSubtitlesChanged (void)
|
||||
{
|
||||
BOOLEAN oldClearSubtitle;
|
||||
BOOLEAN ret;
|
||||
|
||||
LockMutex (subtitle_mutex);
|
||||
oldClearSubtitle = ClearSubtitle;
|
||||
*sub_state = subtitle_state;
|
||||
ClearSubtitle = flag;
|
||||
ret = clear_subtitles;
|
||||
clear_subtitles = FALSE;
|
||||
UnlockMutex (subtitle_mutex);
|
||||
|
||||
return oldClearSubtitle;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
ClearSubtitles (void)
|
||||
{
|
||||
LockMutex (subtitle_mutex);
|
||||
clear_subtitles = TRUE;
|
||||
last_subtitle = NULL;
|
||||
SubtitleText.pStr = NULL;
|
||||
SubtitleText.CharCount = 0;
|
||||
UnlockMutex (subtitle_mutex);
|
||||
}
|
||||
|
||||
static void
|
||||
CheckSubtitles (void)
|
||||
{
|
||||
const UNICODE *pStr;
|
||||
|
||||
pStr = GetTrackSubtitle ();
|
||||
|
||||
LockMutex (subtitle_mutex);
|
||||
if (pStr != SubtitleText.pStr)
|
||||
{ // Subtitles changed
|
||||
clear_subtitles = TRUE;
|
||||
// Baseline may be updated by the ZFP
|
||||
SubtitleText.baseline = CommData.AlienTextBaseline;
|
||||
SubtitleText.align = CommData.AlienTextAlign;
|
||||
SubtitleText.pStr = pStr;
|
||||
// may have been cleared too
|
||||
if (pStr)
|
||||
SubtitleText.CharCount = (COUNT)~0;
|
||||
else
|
||||
SubtitleText.CharCount = 0;
|
||||
}
|
||||
UnlockMutex (subtitle_mutex);
|
||||
}
|
||||
|
||||
+3
-14
@@ -21,16 +21,6 @@
|
||||
#include "libs/compiler.h"
|
||||
#include "libs/gfxlib.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DONE_SUBTITLE,
|
||||
NEXT_SUBTITLE,
|
||||
READ_SUBTITLE,
|
||||
SPACE_SUBTITLE,
|
||||
WAIT_SUBTITLE,
|
||||
} SUBTITLE_STATE;
|
||||
|
||||
#ifdef COMM_INTERNAL
|
||||
|
||||
#define SLIDER_Y 107
|
||||
@@ -38,8 +28,7 @@ typedef enum
|
||||
|
||||
#include "commanim.h"
|
||||
|
||||
void DrawAlienFrame (FRAME aframe, SEQUENCE *pSeq);
|
||||
BOOLEAN SetClearSubtitle (BOOLEAN flag, SUBTITLE_STATE *sub_state);
|
||||
extern void DrawAlienFrame (FRAME aframe, SEQUENCE *pSeq);
|
||||
|
||||
extern LOCDATA CommData;
|
||||
extern volatile BOOLEAN ClearSummary;
|
||||
@@ -48,11 +37,11 @@ extern volatile BOOLEAN ClearSummary;
|
||||
|
||||
extern void init_communication (void);
|
||||
extern void uninit_communication (void);
|
||||
extern SUBTITLE_STATE do_subtitles (UNICODE *pStr);
|
||||
extern void AlienTalkSegue (COUNT wait_track);
|
||||
BOOLEAN getLineWithinWidth(TEXT *pText, const unsigned char **startNext,
|
||||
SIZE maxWidth, COUNT maxChars);
|
||||
void RedrawSubtitles (void);
|
||||
extern void RedrawSubtitles (void);
|
||||
extern BOOLEAN HaveSubtitlesChanged (void);
|
||||
|
||||
extern RECT CommWndRect; /* comm window rect */
|
||||
|
||||
|
||||
+11
-11
@@ -454,15 +454,15 @@ ambient_anim_task (void *data)
|
||||
{
|
||||
CONTEXT OldContext;
|
||||
BOOLEAN CheckSub = FALSE;
|
||||
BOOLEAN ClearSub;
|
||||
SUBTITLE_STATE sub_state;
|
||||
BOOLEAN SubtitleChange;
|
||||
|
||||
ClearSub = SetClearSubtitle (FALSE, &sub_state);
|
||||
// Clearing any active subtitles counts as 'change'
|
||||
SubtitleChange = HaveSubtitlesChanged ();
|
||||
|
||||
OldContext = SetContext (TaskContext);
|
||||
|
||||
if (ColorChange || ClearSummary)
|
||||
{
|
||||
{ // Redraw the whole comm screen
|
||||
FRAME F;
|
||||
F = CommData.AlienFrame;
|
||||
CommData.AlienFrame = CommFrame;
|
||||
@@ -470,16 +470,16 @@ ambient_anim_task (void *data)
|
||||
&Sequencer[CommData.NumAnimations - 1]);
|
||||
CommData.AlienFrame = F;
|
||||
CheckSub = TRUE;
|
||||
ClearSub = ClearSummary;
|
||||
SubtitleChange = ClearSummary;
|
||||
ColorChange = FALSE;
|
||||
ClearSummary = FALSE;
|
||||
}
|
||||
if (Change || ClearSub)
|
||||
if (Change || SubtitleChange)
|
||||
{
|
||||
STAMP s;
|
||||
s.origin.x = -SAFE_X;
|
||||
s.origin.y = 0;
|
||||
if (ClearSub)
|
||||
if (SubtitleChange)
|
||||
{
|
||||
s.frame = CommFrame;
|
||||
DrawStamp (&s);
|
||||
@@ -487,14 +487,14 @@ ambient_anim_task (void *data)
|
||||
i = CommData.NumAnimations;
|
||||
while (i--)
|
||||
{
|
||||
if (ClearSub || FrameChanged[i])
|
||||
if (SubtitleChange || FrameChanged[i])
|
||||
{
|
||||
s.frame = AnimFrame[i];
|
||||
DrawStamp (&s);
|
||||
FrameChanged[i] = 0;
|
||||
}
|
||||
}
|
||||
if (ClearSub && TransitionFrame)
|
||||
if (SubtitleChange && TransitionFrame)
|
||||
{
|
||||
s.frame = TransitionFrame;
|
||||
DrawStamp (&s);
|
||||
@@ -515,7 +515,7 @@ ambient_anim_task (void *data)
|
||||
CheckSub = TRUE;
|
||||
}
|
||||
|
||||
if (CheckSub && sub_state >= SPACE_SUBTITLE)
|
||||
if (CheckSub)
|
||||
RedrawSubtitles ();
|
||||
|
||||
SetContext (OldContext);
|
||||
@@ -534,7 +534,7 @@ ambient_anim_task (void *data)
|
||||
}
|
||||
|
||||
Task
|
||||
StartCommAnimTask(void)
|
||||
StartCommAnimTask (void)
|
||||
{
|
||||
return AssignTask (ambient_anim_task, 3072, "ambient animations");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "controls.h"
|
||||
#include "commglue.h"
|
||||
#include "comm.h"
|
||||
#include "colors.h"
|
||||
#include "settings.h"
|
||||
#include "setup.h"
|
||||
@@ -180,11 +179,7 @@ DoConfirmExit (void)
|
||||
!(LastActivity & CHECK_RESTART))
|
||||
ResumeGameClock ();
|
||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||
{
|
||||
ResumeTrack ();
|
||||
if (CommData.AlienTransitionDesc.AnimFlags & TALK_DONE)
|
||||
do_subtitles ((void *)~0);
|
||||
}
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ Slider (void)
|
||||
if (sliderDisabled)
|
||||
return;
|
||||
|
||||
offs = GetSoundInfo (sliderSpace);
|
||||
offs = GetTrackPosition (sliderSpace);
|
||||
if (offs != last_offs || sliderChanged)
|
||||
{
|
||||
sliderChanged = FALSE;
|
||||
|
||||
+4
-1
@@ -33,6 +33,7 @@
|
||||
#include "libs/uio.h"
|
||||
#include "libs/file.h"
|
||||
#include "libs/graphics/gfx_common.h"
|
||||
#include "libs/sound/sound.h"
|
||||
#include "libs/threadlib.h"
|
||||
#include "libs/vidlib.h"
|
||||
#include "libs/log.h"
|
||||
@@ -120,7 +121,9 @@ LoadKernel (int argc, char *argv[])
|
||||
loadAddon ("3domusic");
|
||||
}
|
||||
|
||||
loadAddon ("3dovoice"); /* Always try to use voice data */
|
||||
/* Always try to use voice data */
|
||||
if (!loadAddon ("3dovoice"))
|
||||
speechVolumeScale = 0.0f; // XXX: need better no-speech indicator
|
||||
|
||||
if (optPrecursorsMusic)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "commglue.h"
|
||||
#include "comm.h"
|
||||
#include "controls.h"
|
||||
#include "util.h"
|
||||
#include "setup.h"
|
||||
@@ -224,11 +223,7 @@ PauseGame (void)
|
||||
LOBYTE (GLOBAL (CurrentActivity)) != WON_LAST_BATTLE)
|
||||
ResumeGameClock ();
|
||||
if (CommData.ConversationPhrases && PlayingTrack ())
|
||||
{
|
||||
ResumeTrack ();
|
||||
if (CommData.AlienTransitionDesc.AnimFlags & TALK_DONE)
|
||||
do_subtitles ((void *)~0);
|
||||
}
|
||||
|
||||
UnlockMutex (GraphicsLock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user