From 45a8742e428c1a6b4bb9a580575838265709597c Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 12 Dec 2017 05:13:32 +0000 Subject: [PATCH] New def token for "cutscene": "aspect" Overrides the aspect ratio for IVF files. cutscene { aspect } Note: For ANMs, you can use rotatesprite and setaspect to draw TILE_ANIM (currently defined as 30716) in EVENT_CUTSCENE with a custom aspect. Patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@6551 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/build/include/animvpx.h | 2 +- source/build/src/animvpx.cpp | 4 +++- source/duke3d/src/anim.cpp | 15 ++++++++++++++- source/duke3d/src/anim.h | 1 + source/duke3d/src/game.cpp | 11 +++++++++++ 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/source/build/include/animvpx.h b/source/build/include/animvpx.h index 196a1010d..08440beb1 100644 --- a/source/build/include/animvpx.h +++ b/source/build/include/animvpx.h @@ -85,7 +85,7 @@ int32_t animvpx_nextpic(animvpx_codec_ctx *codec, uint8_t **pic); void animvpx_setup_glstate(void); void animvpx_restore_glstate(void); -int32_t animvpx_render_frame(animvpx_codec_ctx *codec); +int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect); void animvpx_print_stats(const animvpx_codec_ctx *codec); #endif diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index 339631cde..4038c9c27 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -491,7 +491,7 @@ void animvpx_restore_glstate(void) texuploaded = 0; } -int32_t animvpx_render_frame(animvpx_codec_ctx *codec) +int32_t animvpx_render_frame(animvpx_codec_ctx *codec, double animvpx_aspect) { int32_t t = getticks(); @@ -518,6 +518,8 @@ int32_t animvpx_render_frame(animvpx_codec_ctx *codec) } float vid_wbyh = ((float)codec->width)/codec->height; + if (animvpx_aspect > 0) + vid_wbyh = animvpx_aspect; float scr_wbyh = ((float)xdim)/ydim; float x=1.0, y=1.0; diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index ee18852ff..46890e6f8 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -329,7 +329,20 @@ int32_t Anim_Play(const char *fn) ototalclock = totalclock + 1; // pause game like ANMs - animvpx_render_frame(&codec); + if (anim) + { + if (anim->frameaspect1 == 0 || anim->frameaspect2 == 0) + animvpx_render_frame(&codec, 0); + else + animvpx_render_frame(&codec, anim->frameaspect1 / anim->frameaspect2); + } + else + { + if (origanim->frameaspect1 == 0 || origanim->frameaspect2 == 0) + animvpx_render_frame(&codec, 0); + else + animvpx_render_frame(&codec, origanim->frameaspect1 / origanim->frameaspect2); + } VM_OnEventWithReturn(EVENT_CUTSCENE, g_player[screenpeek].ps->i, screenpeek, framenum); diff --git a/source/duke3d/src/anim.h b/source/duke3d/src/anim.h index c0045e76a..e319ea6fa 100644 --- a/source/duke3d/src/anim.h +++ b/source/duke3d/src/anim.h @@ -30,6 +30,7 @@ typedef struct { typedef struct { + double frameaspect1, frameaspect2; uint8_t* animbuf; animsound_t *sounds; uint16_t numsounds; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 0d32f48d3..4f3e8cf3a 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -172,6 +172,7 @@ enum gametokens T_DELAY, T_RENAMEFILE, T_GLOBALGAMEFLAGS, + T_ASPECT, }; void G_HandleSpecialKeys(void) @@ -5191,6 +5192,7 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) static const tokenlist animTokens [] = { { "delay", T_DELAY }, + { "aspect", T_ASPECT }, { "sounds", T_SOUND }, }; @@ -5318,6 +5320,15 @@ static int parsedefinitions_game(scriptfile *pScript, int firstPass) scriptfile_getnumber(pScript, &temp); animPtr->framedelay = temp; break; + case T_ASPECT: + { + double dtemp, dtemp2; + scriptfile_getdouble(pScript, &dtemp); + scriptfile_getdouble(pScript, &dtemp2); + animPtr->frameaspect1 = dtemp; + animPtr->frameaspect2 = dtemp2; + break; + } case T_SOUND: { char *animSoundsEnd = NULL;