From 2e2d793569d2903b950c402c15d835067e064c7b Mon Sep 17 00:00:00 2001 From: mcmartin Date: Sat, 26 May 2007 09:02:50 +0000 Subject: [PATCH] Basic support for .ani based ship spins. At the moment there are no pauseframes or annotations. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2764 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/fmv.c | 22 ++++++++++++++-- sc2/src/sc2code/fmv.h | 4 ++- sc2/src/sc2code/intro.c | 56 ++++++++++++++++++++++++++++++++++++++++- 4 files changed, 79 insertions(+), 4 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index b58d733b6..6cd3ef73d 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Basic support for .ani-based shipspin animations - Michael - Fixed some Melnorme history info timestamps - Alex - Fixed Ur-Quan story timestamps, from Vlad-Ceru Opran - Removed the 256-frame limit on .ani files - Michael diff --git a/sc2/src/sc2code/fmv.c b/sc2/src/sc2code/fmv.c index ca7481c9c..f56594452 100644 --- a/sc2/src/sc2code/fmv.c +++ b/sc2/src/sc2code/fmv.c @@ -53,10 +53,28 @@ DoShipSpin (COUNT index, MUSIC_REF hMusic) StopMusic (); FreeHyperData (); - + sprintf (vnbuf, "slides/spins/ship%02u.duk", (unsigned)index); sprintf (snbuf, "slides/spins/ship%02u.aif", (unsigned)index); - DoFMVEx (vnbuf, "slides/spins/spin.aif", snbuf, SHIP_SPIN_LOOP_FRAME); + if (optWhichIntro == OPT_PC || !DoFMVEx (vnbuf, "slides/spins/spin.aif", snbuf, SHIP_SPIN_LOOP_FRAME)) + { + FRAME f; + sprintf (vnbuf, "slides/spins/ship%02u.ani", (unsigned)index); + f = CaptureDrawable (LoadGraphicFile (vnbuf)); + if (f) + { + clut_buf[0] = FadeAllToColor; + XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 20); + FlushColorXForms (); + + ShowShipAnim (f); + + DestroyDrawable (ReleaseDrawable (f)); + } + clut_buf[0] = FadeAllToBlack; + SleepThreadUntil (XFormColorMap ((COLORMAPPTR)clut_buf, ONE_SECOND / 4)); + FlushColorXForms (); + } GetContextClipRect (&old_r); r.corner.x = r.corner.y = 0; diff --git a/sc2/src/sc2code/fmv.h b/sc2/src/sc2code/fmv.h index 76c6d8c46..e76a595e8 100644 --- a/sc2/src/sc2code/fmv.h +++ b/sc2/src/sc2code/fmv.h @@ -18,6 +18,8 @@ #define _FMV_H #include "libs/compiler.h" +#include "libs/sndlib.h" +#include "libs/gfxlib.h" #define WANT_SHIP_SPINS extern void Logo (void); @@ -25,7 +27,6 @@ extern void SplashScreen (void (* DoProcessing)(DWORD TimeOut)); extern void Introduction (void); extern void Victory (void); -#include "libs/sndlib.h" extern void DoShipSpin (COUNT index, MUSIC_REF hMusic); extern BOOLEAN DoFMV (const char *name); @@ -35,6 +36,7 @@ extern BOOLEAN DoFMVEx (const char *name, const char *audname, extern BOOLEAN ShowPresentation (STRING PresStr); extern BOOLEAN ShowPresentationFile (const char *name); +extern BOOLEAN ShowShipAnim (FRAME anim); #endif /* _FMV_H */ diff --git a/sc2/src/sc2code/intro.c b/sc2/src/sc2code/intro.c index 7756e9c41..ab7e251b6 100644 --- a/sc2/src/sc2code/intro.c +++ b/sc2/src/sc2code/intro.c @@ -68,9 +68,18 @@ typedef struct } PRESENTATION_INPUT_STATE; +typedef struct { + /* standard state required by DoInput */ + BOOLEAN (*InputFunc) (void *pInputState); + COUNT MenuRepeatDelay; + + /* Spinanim state */ + STAMP anim; + TimeCount last_time; +} SPINANIM_INPUT_STATE; static BOOLEAN DoPresentation (void *pIS); - +static BOOLEAN DoSpinAnim (void *pIS); BOOLEAN DoFMVEx (const char *name, const char *audname, const char *speechname, @@ -758,4 +767,49 @@ ShowPresentation (STRING PresStr) return TRUE; } +/* This needs expansion; in particular, it needs to handle pause + * frames and annotations */ +static BOOLEAN +DoSpinAnim (void *pIS) +{ + SPINANIM_INPUT_STATE *pSIS = (SPINANIM_INPUT_STATE *)pIS; + STAMP *s = &pSIS->anim; + + if (AnyButtonPress (FALSE) + || (GLOBAL (CurrentActivity) & CHECK_ABORT)) + + { + return FALSE; + } + + DrawStamp (s); + s->frame = SetRelFrameIndex (s->frame, 1); + + if (GetFrameIndex(s->frame) == 0) + { + return FALSE; + } + + SleepThread (pSIS->last_time + ONE_SECOND / 30 - GetTimeCounter ()); + pSIS->last_time = GetTimeCounter (); + return TRUE; +} + +BOOLEAN +ShowShipAnim (FRAME anim) +{ + SPINANIM_INPUT_STATE is; + + is.anim.origin.x = SCREEN_WIDTH >> 1; + is.anim.origin.y = SCREEN_HEIGHT >> 1; + is.anim.frame = anim; + is.last_time = GetTimeCounter (); + + is.InputFunc = DoSpinAnim; + is.MenuRepeatDelay = 0; + + DoInput (&is, TRUE); + + return TRUE; +}