mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- deleted the old anim player.
This commit is contained in:
parent
726ebec9ec
commit
8cb8f85569
7 changed files with 22 additions and 969 deletions
|
@ -34,7 +34,6 @@ set( PCH_SOURCES
|
|||
src/spawn_d.cpp
|
||||
src/spawn_r.cpp
|
||||
src/zz_actors.cpp
|
||||
src/zz_anim.cpp
|
||||
src/zz_cheats.cpp
|
||||
src/zz_common.cpp
|
||||
src/zz_d_menu.cpp
|
||||
|
|
|
@ -325,375 +325,7 @@ static void gamenumber(long x,long y,long n,char s)
|
|||
}
|
||||
|
||||
|
||||
void endanimsounds(long fr)
|
||||
{
|
||||
switch(ud.volume_number)
|
||||
{
|
||||
case 0:break;
|
||||
case 1:
|
||||
switch(fr)
|
||||
{
|
||||
case 1:
|
||||
sound(390);
|
||||
break;
|
||||
case 26:
|
||||
sound(390);
|
||||
break;
|
||||
case 36:
|
||||
sound(390);
|
||||
break;
|
||||
case 54:
|
||||
sound(390);
|
||||
break;
|
||||
case 62:
|
||||
sound(390);
|
||||
break;
|
||||
case 75:
|
||||
sound(390);
|
||||
break;
|
||||
case 81:
|
||||
sound(390);
|
||||
break;
|
||||
case 115:
|
||||
sound(390);
|
||||
break;
|
||||
case 124:
|
||||
sound(390);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
switch(fr)
|
||||
{
|
||||
case 1:
|
||||
sound(390);
|
||||
break;
|
||||
case 98:
|
||||
sound(390);
|
||||
break;
|
||||
case 82+20:
|
||||
sound(390);
|
||||
sound(390);
|
||||
break;
|
||||
case 104+20:
|
||||
sound(390);
|
||||
break;
|
||||
case 114+20:
|
||||
sound(390);
|
||||
break;
|
||||
case 158:
|
||||
sound(390);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void logoanimsounds(long fr, short s)
|
||||
{
|
||||
#ifdef RRRA
|
||||
switch (s)
|
||||
{
|
||||
case 1:
|
||||
if (fr == 1)
|
||||
sound(256);
|
||||
break;
|
||||
case 2:
|
||||
if (fr == 1)
|
||||
sound(257);
|
||||
break;
|
||||
case 3:
|
||||
if (fr == 1)
|
||||
sound(258);
|
||||
break;
|
||||
case 4:
|
||||
if (fr == 1)
|
||||
sound(259);
|
||||
break;
|
||||
case 5:
|
||||
break;
|
||||
case 6:
|
||||
if (fr == 1)
|
||||
sound(479);
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch(s)
|
||||
{
|
||||
case -1:
|
||||
if (fr == 1)
|
||||
sound(29);
|
||||
break;
|
||||
case 0:
|
||||
if (fr == 1)
|
||||
sound(478);
|
||||
break;
|
||||
case 1:
|
||||
if (fr == 1)
|
||||
sound(479);
|
||||
break;
|
||||
case 4:
|
||||
if (fr == 1)
|
||||
sound(35);
|
||||
break;
|
||||
case 5:
|
||||
if (fr == 1)
|
||||
sound(82);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
#ifdef RRRA
|
||||
short playanm(char *fn,char t, short s)
|
||||
#else
|
||||
void playanm(char *fn,char t, short s)
|
||||
#endif
|
||||
{
|
||||
char *animbuf, *palptr;
|
||||
long i, j, k, length, numframes;
|
||||
int handle;
|
||||
#ifdef RRRA
|
||||
char *windir = getenv("windir");
|
||||
if (windir)
|
||||
{
|
||||
cddrives = 0;
|
||||
cdon = 0;
|
||||
sound(390);
|
||||
return -1;
|
||||
}
|
||||
handle = kopen4load(fn,0);
|
||||
if(handle == -1) return -1;
|
||||
length = kfilelength(handle);
|
||||
#else
|
||||
handle = kopen4load(fn,0);
|
||||
if(handle == -1) return;
|
||||
length = kfilelength(handle);
|
||||
#endif
|
||||
|
||||
walock[MAXTILES-3-t] = 219+t;
|
||||
|
||||
if(anim == 0)
|
||||
allocache((long *)&anim,length+sizeof(anim_t),&walock[MAXTILES-3-t]);
|
||||
|
||||
animbuf = (char *)(FP_OFF(anim)+sizeof(anim_t));
|
||||
|
||||
tilesizx[MAXTILES-3-t] = 200;
|
||||
tilesizy[MAXTILES-3-t] = 320;
|
||||
|
||||
kread(handle,animbuf,length);
|
||||
kclose(handle);
|
||||
|
||||
setview(0, 0, xdim, ydim);
|
||||
clearview(0);
|
||||
nextpage();
|
||||
|
||||
ANIM_LoadAnim (animbuf);
|
||||
numframes = ANIM_NumFrames();
|
||||
|
||||
palptr = ANIM_GetPalette();
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
j = (i<<2); k = j-i;
|
||||
tempbuf[j+0] = (palptr[k+2]>>2);
|
||||
tempbuf[j+1] = (palptr[k+1]>>2);
|
||||
tempbuf[j+2] = (palptr[k+0]>>2);
|
||||
tempbuf[j+3] = 0;
|
||||
}
|
||||
|
||||
VBE_setPalette(0L,256L,tempbuf);
|
||||
|
||||
ototalclock = totalclock + 10;
|
||||
|
||||
KB_FlushKeyboardQueue();
|
||||
|
||||
for(i=1;i<numframes;i++)
|
||||
{
|
||||
while(totalclock < ototalclock)
|
||||
{
|
||||
if( KB_KeyWaiting() )
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
clearsoundlocks();
|
||||
#ifdef RRRA
|
||||
ANIM_FreeAnim();
|
||||
walock[MAXTILES-3-t] = 1;
|
||||
return 10;
|
||||
#else
|
||||
goto ENDOFANIMLOOP;
|
||||
#endif
|
||||
}
|
||||
getpackets();
|
||||
}
|
||||
|
||||
if(t == 6) ototalclock += 400;
|
||||
#ifdef RRRA
|
||||
else if(t == 5) ototalclock += 8;
|
||||
#else
|
||||
else if(t == 5) ototalclock += 9;
|
||||
#endif
|
||||
else if(ud.volume_number == 2) ototalclock += 10;
|
||||
else if(ud.volume_number == 1) ototalclock += 18;
|
||||
else ototalclock += 10;
|
||||
|
||||
waloff[MAXTILES-3-t] = FP_OFF(ANIM_DrawFrame(i));
|
||||
rotatesprite(0<<16,0<<16,65536L,512,MAXTILES-3-t,0,0,2+4+8+16+64, 0,0,xdim-1,ydim-1);
|
||||
nextpage();
|
||||
|
||||
if(t == 5) logoanimsounds(i,s);
|
||||
else if(t < 4) endanimsounds(i);
|
||||
}
|
||||
|
||||
ENDOFANIMLOOP:
|
||||
|
||||
ANIM_FreeAnim ();
|
||||
walock[MAXTILES-3-t] = 1;
|
||||
#ifdef RRRA
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RRRA
|
||||
|
||||
#if 0
|
||||
void PlayMapAnim(void)
|
||||
{
|
||||
const char *fn;
|
||||
char t;
|
||||
char *animbuf, *palptr;
|
||||
long i, j, k, length=0, numframes=0;
|
||||
int handle=-1;
|
||||
char *windir;
|
||||
|
||||
fn = NULL;
|
||||
t = 5;
|
||||
if (ud.volume_number == 0)
|
||||
{
|
||||
switch (ud.level_number)
|
||||
{
|
||||
case 1:
|
||||
fn = "lvl1.anm";
|
||||
break;
|
||||
case 2:
|
||||
fn = "lvl2.anm";
|
||||
break;
|
||||
case 3:
|
||||
fn = "lvl3.anm";
|
||||
break;
|
||||
case 4:
|
||||
fn = "lvl4.anm";
|
||||
break;
|
||||
case 5:
|
||||
fn = "lvl5.anm";
|
||||
break;
|
||||
case 6:
|
||||
fn = "lvl6.anm";
|
||||
break;
|
||||
default:
|
||||
fn = "lvl7.anm";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ud.level_number)
|
||||
{
|
||||
case 1:
|
||||
fn = "lvl8.anm";
|
||||
break;
|
||||
case 2:
|
||||
fn = "lvl9.anm";
|
||||
break;
|
||||
case 3:
|
||||
fn = "lvl10.anm";
|
||||
break;
|
||||
case 4:
|
||||
fn = "lvl11.anm";
|
||||
break;
|
||||
case 5:
|
||||
fn = "lvl12.anm";
|
||||
break;
|
||||
case 6:
|
||||
fn = "lvl13.anm";
|
||||
break;
|
||||
default:
|
||||
fn = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
windir = getenv("windir");
|
||||
if (windir)
|
||||
{
|
||||
cddrives = 0;
|
||||
cdon = 0;
|
||||
sound(390);
|
||||
return;
|
||||
}
|
||||
handle = kopen4load(fn,0);
|
||||
if(handle == -1) return;
|
||||
length = kfilelength(handle);
|
||||
|
||||
walock[MAXTILES-3-t] = 219+t;
|
||||
|
||||
if(anim == 0)
|
||||
allocache((long *)&anim,length+sizeof(anim_t),&walock[MAXTILES-3-t]);
|
||||
|
||||
animbuf = (char *)(FP_OFF(anim)+sizeof(anim_t));
|
||||
|
||||
tilesizx[MAXTILES-3-t] = 200;
|
||||
tilesizy[MAXTILES-3-t] = 320;
|
||||
|
||||
kread(handle,animbuf,length);
|
||||
kclose(handle);
|
||||
|
||||
ANIM_LoadAnim (animbuf);
|
||||
numframes = ANIM_NumFrames();
|
||||
|
||||
palptr = ANIM_GetPalette();
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
j = (i<<2); k = j-i;
|
||||
tempbuf[j+0] = (palptr[k+2]>>2);
|
||||
tempbuf[j+1] = (palptr[k+1]>>2);
|
||||
tempbuf[j+2] = (palptr[k+0]>>2);
|
||||
tempbuf[j+3] = 0;
|
||||
}
|
||||
|
||||
VBE_setPalette(0L,256L,tempbuf);
|
||||
|
||||
ototalclock = totalclock + 10;
|
||||
|
||||
KB_FlushKeyboardQueue();
|
||||
|
||||
for(i=1;i<numframes;i++)
|
||||
{
|
||||
while(totalclock < ototalclock)
|
||||
{
|
||||
if( KB_KeyWaiting() )
|
||||
{
|
||||
FX_StopAllSounds();
|
||||
clearsoundlocks();
|
||||
goto ENDOFANIMLOOP;
|
||||
}
|
||||
getpackets();
|
||||
}
|
||||
|
||||
ototalclock += 20;
|
||||
|
||||
waloff[MAXTILES-3-t] = FP_OFF(ANIM_DrawFrame(i));
|
||||
rotatesprite(0<<16,0<<16,65536L,512,MAXTILES-3-t,0,0,2+4+8+16+64, 0,0,xdim-1,ydim-1);
|
||||
nextpage();
|
||||
}
|
||||
|
||||
ENDOFANIMLOOP:
|
||||
|
||||
ANIM_FreeAnim ();
|
||||
walock[MAXTILES-3-t] = 1;
|
||||
}
|
||||
|
||||
void ShowMapFrame(void)
|
||||
{
|
||||
short t = -1, i;
|
||||
|
@ -759,8 +391,6 @@ void ShowMapFrame(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
|
@ -854,15 +484,28 @@ void bonussequence_r(int num, CompletionFunc completion)
|
|||
RunScreenJob(jobs, job, completion);
|
||||
}
|
||||
|
||||
#if 0
|
||||
CCMD(testbonus)
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// RRRA only
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void PlayMapAnim(CompletionFunc completion)
|
||||
{
|
||||
if (argv.argc() > 1)
|
||||
char fn[20];
|
||||
|
||||
int lev = ud.level_number + 7 * ud.volume_number;
|
||||
if (lev >= 1 && lev <= 13)
|
||||
{
|
||||
bonussequence_r(strtol(argv[1], nullptr, 0), nullptr);
|
||||
mysnprintf(fn, 20, "lvl%d.anm", lev);
|
||||
|
||||
static const int framespeed[] = { 20, 20, 7200 }; // wait for one minute on the final frame
|
||||
JobDesc job = { PlayVideo(fn, nullptr, framespeed) };
|
||||
RunScreenJob(&job, 1, completion);
|
||||
}
|
||||
else completion(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
|
|
|
@ -1,462 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include "ns.h" // Must come before everything else!
|
||||
|
||||
#include "baselayer.h"
|
||||
#include "baselayer.h"
|
||||
#include "duke3d.h"
|
||||
#include "animlib.h"
|
||||
#include "compat.h"
|
||||
#include "cmdlib.h"
|
||||
#include "v_2ddrawer.h"
|
||||
#include "animtexture.h"
|
||||
#include "../glbackend/glbackend.h"
|
||||
|
||||
|
||||
#include "zz_anim.h"
|
||||
|
||||
#ifdef USE_LIBVPX
|
||||
# include "animvpx.h"
|
||||
#endif
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
// animsound_t.sound
|
||||
|
||||
TArray<dukeanim_t> g_Animations;
|
||||
dukeanim_t * g_animPtr;
|
||||
|
||||
dukeanim_t* Anim_Find(const char* s)
|
||||
{
|
||||
auto index = g_Animations.FindEx([=](dukeanim_t& anm) { return !anm.name.CompareNoCase(s); });
|
||||
if (index == g_Animations.Size())
|
||||
{
|
||||
FString fname = s;
|
||||
DefaultExtension(fname, ".anm");
|
||||
index = g_Animations.FindEx([=](dukeanim_t& anm) { return !anm.name.CompareNoCase(fname); });
|
||||
if (index == g_Animations.Size())
|
||||
{
|
||||
fname = s;
|
||||
DefaultExtension(fname, ".ivf");
|
||||
index = g_Animations.FindEx([=](dukeanim_t& anm) { return !anm.name.CompareNoCase(fname); });
|
||||
if (index == g_Animations.Size()) return nullptr;
|
||||
}
|
||||
}
|
||||
return &g_Animations[index];
|
||||
}
|
||||
|
||||
dukeanim_t * Anim_Create(char const * fn)
|
||||
{
|
||||
g_Animations.Reserve(1);
|
||||
auto p = &g_Animations.Last();
|
||||
p->name = fn;
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef DYNSOUNDREMAP_ENABLE
|
||||
static int32_t const StopAllSounds = -1;
|
||||
#else
|
||||
# define StopAllSounds -1
|
||||
#endif
|
||||
|
||||
void Anim_Init(void)
|
||||
{
|
||||
struct defaultanmsound {
|
||||
#ifdef DYNSOUNDREMAP_ENABLE
|
||||
int32_t const & sound;
|
||||
#else
|
||||
int16_t sound;
|
||||
#endif
|
||||
uint8_t frame;
|
||||
};
|
||||
|
||||
struct defaultanm {
|
||||
char const *fn;
|
||||
defaultanmsound const *sounds;
|
||||
uint8_t numsounds;
|
||||
uint8_t fdelay;
|
||||
};
|
||||
|
||||
#define anmsnd(x) (x), ARRAY_SIZE(x)
|
||||
static defaultanm const anms[] =
|
||||
{
|
||||
{ "lvl1.anm", NULL, 0, 20 },
|
||||
{ "lvl2.anm", NULL, 0, 20 },
|
||||
{ "lvl3.anm", NULL, 0, 20 },
|
||||
{ "lvl4.anm", NULL, 0, 20 },
|
||||
{ "lvl5.anm", NULL, 0, 20 },
|
||||
{ "lvl6.anm", NULL, 0, 20 },
|
||||
{ "lvl7.anm", NULL, 0, 20 },
|
||||
{ "lvl8.anm", NULL, 0, 20 },
|
||||
{ "lvl9.anm", NULL, 0, 20 },
|
||||
{ "lvl10.anm", NULL, 0, 20 },
|
||||
{ "lvl11.anm", NULL, 0, 20 },
|
||||
{ "lvl12.anm", NULL, 0, 20 },
|
||||
{ "lvl13.anm", NULL, 0, 20 },
|
||||
};
|
||||
#undef anmsnd
|
||||
|
||||
for (defaultanm const& anm : anms)
|
||||
{
|
||||
dukeanim_t* anim = Anim_Create(anm.fn);
|
||||
anim->framedelay = anm.fdelay;
|
||||
|
||||
if (anm.numsounds)
|
||||
{
|
||||
anim->Sounds.Resize(anm.numsounds);
|
||||
int const numsounds = anm.numsounds;
|
||||
for (int i = 0; i < numsounds; ++i)
|
||||
{
|
||||
defaultanmsound const& src = anm.sounds[i];
|
||||
animsound_t& dst = anim->Sounds[i];
|
||||
|
||||
dst.sound = src.sound;
|
||||
dst.frame = src.frame;
|
||||
}
|
||||
}
|
||||
|
||||
anim->frameflags = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Anim_Play(const char *fn)
|
||||
{
|
||||
#if 0
|
||||
dukeanim_t *anim = Anim_Find(fn);
|
||||
|
||||
if (!anim)
|
||||
{
|
||||
Printf("Animation %s is undefined!\n", fn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t soundidx = 0; // custom anim sounds
|
||||
int32_t running = 1, i;
|
||||
|
||||
inputState.ClearAllInput();
|
||||
|
||||
#ifdef USE_LIBVPX
|
||||
uint16_t framenum = 0;
|
||||
while (videoGetRenderMode() >= REND_POLYMOST) // if, really
|
||||
{
|
||||
char const * dot = Bstrrchr(fn, '.');
|
||||
if (!dot)
|
||||
break;
|
||||
|
||||
dukeanim_t const * origanim = anim;
|
||||
FileReader handle;
|
||||
if (!Bstrcmp(dot, ".ivf"))
|
||||
{
|
||||
handle = fileSystem.OpenFileReader(fn);
|
||||
if (!handle.isOpen())
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
char vpxfn[BMAX_PATH];
|
||||
Bstrncpyz(vpxfn, fn, BMAX_PATH);
|
||||
|
||||
ptrdiff_t dotpos = dot - fn;
|
||||
if (dotpos + 4 >= BMAX_PATH)
|
||||
break;
|
||||
|
||||
char *vpxfndot = vpxfn + dotpos;
|
||||
vpxfndot[1] = 'i';
|
||||
vpxfndot[2] = 'v';
|
||||
vpxfndot[3] = 'f';
|
||||
vpxfndot[4] = '\0';
|
||||
|
||||
handle = fileSystem.OpenFileReader(vpxfn);
|
||||
if (!handle.isOpen())
|
||||
break;
|
||||
|
||||
anim = Anim_Find(vpxfn);
|
||||
}
|
||||
|
||||
animvpx_ivf_header_t info;
|
||||
i = animvpx_read_ivf_header(handle, &info);
|
||||
|
||||
if (i)
|
||||
{
|
||||
Printf("Failed reading IVF file: %s\n", animvpx_read_ivf_header_errmsg[i]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (anim)
|
||||
animvpx_setup_glstate(anim->frameflags);
|
||||
else
|
||||
animvpx_setup_glstate(origanim->frameflags);
|
||||
|
||||
animvpx_codec_ctx codec;
|
||||
|
||||
if (animvpx_init_codec(&info, handle, &codec))
|
||||
{
|
||||
Printf("Error initializing VPX codec.\n");
|
||||
animvpx_restore_glstate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint32_t const convnumer = 120 * info.fpsdenom;
|
||||
uint32_t const convdenom = info.fpsnumer * origanim->framedelay;
|
||||
|
||||
uint32_t const msecsperframe = scale(info.fpsdenom, 1000, info.fpsnumer);
|
||||
uint32_t nextframetime = timerGetTicks();
|
||||
uint8_t *pic;
|
||||
|
||||
// Printf("msecs per frame: %d\n", msecsperframe);
|
||||
|
||||
do
|
||||
{
|
||||
nextframetime += msecsperframe;
|
||||
|
||||
i = animvpx_nextpic(&codec, &pic);
|
||||
if (i)
|
||||
{
|
||||
Printf("Failed getting next pic: %s\n", animvpx_nextpic_errmsg[i]);
|
||||
if (codec.errmsg)
|
||||
{
|
||||
Printf(" %s\n", codec.errmsg);
|
||||
if (codec.errmsg_detail)
|
||||
Printf(" detail: %s\n", codec.errmsg_detail);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!pic)
|
||||
break; // no more pics!
|
||||
|
||||
twod->ClearScreen();
|
||||
|
||||
ototalclock = totalclock + 1; // pause game like ANMs
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// after rendering the frame but before displaying: maybe play sound...
|
||||
framenum++;
|
||||
if (anim)
|
||||
{
|
||||
while (soundidx < anim->Sounds.Size() && anim->Sounds[soundidx].frame <= framenum)
|
||||
{
|
||||
int16_t sound = anim->Sounds[soundidx].sound;
|
||||
if (sound == -1)
|
||||
FX_StopAllSounds();
|
||||
else
|
||||
S_PlaySound(sound, CHAN_AUTO, CHANF_UI);
|
||||
|
||||
soundidx++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16_t convframenum = scale(framenum, convnumer, convdenom);
|
||||
while (soundidx < origanim->Sounds.Size() && origanim->Sounds[soundidx].frame <= convframenum)
|
||||
{
|
||||
int16_t sound = origanim->Sounds[soundidx].sound;
|
||||
if (sound == -1)
|
||||
FX_StopAllSounds();
|
||||
else
|
||||
S_PlaySound(sound, CHAN_AUTO, CHANF_UI);
|
||||
|
||||
soundidx++;
|
||||
}
|
||||
}
|
||||
|
||||
videoNextPage();
|
||||
do
|
||||
{
|
||||
G_HandleAsync();
|
||||
|
||||
if (inputState.CheckAllInput())
|
||||
{
|
||||
running = 0;
|
||||
break;
|
||||
}
|
||||
} while (timerGetTicks() < nextframetime);
|
||||
} while (running);
|
||||
|
||||
#ifdef DEBUGGINGAIDS
|
||||
animvpx_print_stats(&codec);
|
||||
#endif
|
||||
|
||||
//
|
||||
animvpx_restore_glstate();
|
||||
animvpx_uninit_codec(&codec);
|
||||
|
||||
inputState.ClearAllInput();
|
||||
return !running; // done with playing VP8!
|
||||
}
|
||||
#endif
|
||||
// ANM playback --- v v v ---
|
||||
|
||||
int32_t ogltexfiltermode = gl_texture_filter;
|
||||
auto fr = fileSystem.OpenFileReader(fn);
|
||||
|
||||
if (!fr.isOpen())
|
||||
return 0;
|
||||
|
||||
auto buffer = fr.ReadPadded(1);
|
||||
fr.Close();
|
||||
|
||||
if (buffer.Size() <= 5)
|
||||
{
|
||||
Printf("Warning: skipping playback of empty ANM file \"%s\".\n", fn);
|
||||
goto end_anim;
|
||||
}
|
||||
|
||||
anim->animbuf = buffer.Data();
|
||||
|
||||
uint32_t firstfour;
|
||||
Bmemcpy(&firstfour, anim->animbuf, 4);
|
||||
|
||||
// "DKIF" (.ivf)
|
||||
if (firstfour == B_LITTLE32(0x46494B44))
|
||||
goto end_anim;
|
||||
|
||||
int32_t numframes;
|
||||
|
||||
// "LPF " (.anm)
|
||||
if (firstfour != B_LITTLE32(0x2046504C) ||
|
||||
ANIM_LoadAnim(anim->animbuf, buffer.Size()-1) < 0 ||
|
||||
(numframes = ANIM_NumFrames()) <= 0)
|
||||
{
|
||||
// XXX: ANM_LoadAnim() still checks less than the bare minimum,
|
||||
// e.g. ANM file could still be too small and not contain any frames.
|
||||
Printf("Error: malformed ANM file \"%s\".\n", fn);
|
||||
goto end_anim;
|
||||
}
|
||||
|
||||
ototalclock = totalclock;
|
||||
|
||||
i = 1;
|
||||
int32_t frametime; frametime = 0;
|
||||
|
||||
{
|
||||
AnimTextures animtex;
|
||||
animtex.SetSize(AnimTexture::Paletted, 320, 200);
|
||||
|
||||
do
|
||||
{
|
||||
if (i > 4 && totalclock > frametime + 60)
|
||||
{
|
||||
Printf("WARNING: slowdown in %s, skipping playback\n", fn);
|
||||
goto end_anim_restore_gl;
|
||||
}
|
||||
|
||||
G_HandleAsync();
|
||||
|
||||
if (totalclock < ototalclock - 1)
|
||||
continue;
|
||||
|
||||
animtex.SetFrame(ANIM_GetPalette(), ANIM_DrawFrame(i));
|
||||
|
||||
if (inputState.CheckAllInput())
|
||||
{
|
||||
running = 0;
|
||||
goto end_anim_restore_gl;
|
||||
}
|
||||
|
||||
if (restorepalette == 1)
|
||||
{
|
||||
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0);
|
||||
restorepalette = 0;
|
||||
}
|
||||
|
||||
frametime = (int32_t)totalclock;
|
||||
|
||||
videoClearScreen(0);
|
||||
|
||||
int32_t z;
|
||||
#if 0
|
||||
if (anim->frameaspect1 > 0 && anim->frameaspect2 > 0 && ((anim->frameaspect1 / anim->frameaspect2) != (tilesiz[TILE_ANIM].y / (tilesiz[TILE_ANIM].x * 1.2))))
|
||||
{
|
||||
int32_t const oyxaspect = yxaspect;
|
||||
if ((anim->frameaspect1 / anim->frameaspect2) >= ((decltype(anim->frameaspect1))xdim / ydim))
|
||||
z = divscale16(320, tilesiz[TILE_ANIM].y);
|
||||
else
|
||||
z = divscale16(lrint(320 * ydim * anim->frameaspect1), lrint(tilesiz[TILE_ANIM].y * xdim * anim->frameaspect2));
|
||||
int32_t aspect = divscale16(lrint(tilesiz[TILE_ANIM].y * anim->frameaspect2), lrint(tilesiz[TILE_ANIM].x * anim->frameaspect1));
|
||||
renderSetAspect(viewingrange, aspect);
|
||||
rotatesprite_fs(160 << 16, 100 << 16, z, 512, TILE_ANIM, 0, 0, 2 | 4 | 8 | 64 | 1024);
|
||||
renderSetAspect(viewingrange, oyxaspect);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ((320 / (200 * 1.2f)) > (1.f * xdim / ydim))
|
||||
z = divscale16(320 * xdim * 3, 320 * ydim * 4);
|
||||
else
|
||||
z = divscale16(200, 200);
|
||||
rotatesprite_fs(160 << 16, 100 << 16, z, 0, -1, 0, 0, 2 | 8 | 64, animtex.GetFrame());
|
||||
}
|
||||
|
||||
g_animPtr = NULL;
|
||||
|
||||
videoNextPage();
|
||||
|
||||
inputState.ClearAllInput();
|
||||
|
||||
ototalclock += anim->framedelay;
|
||||
|
||||
while (soundidx < anim->Sounds.Size() && anim->Sounds[soundidx].frame <= (uint16_t)i)
|
||||
{
|
||||
int16_t sound = anim->Sounds[soundidx].sound;
|
||||
if (sound == -1)
|
||||
FX_StopAllSounds();
|
||||
else
|
||||
S_PlaySound(sound, CHAN_AUTO, CHANF_UI);
|
||||
|
||||
soundidx++;
|
||||
}
|
||||
|
||||
++i;
|
||||
} while (i < numframes);
|
||||
}
|
||||
|
||||
end_anim_restore_gl:
|
||||
gl_texture_filter = ogltexfiltermode;
|
||||
end_anim:
|
||||
inputState.ClearAllInput();
|
||||
anim->animbuf = nullptr;
|
||||
ANIM_FreeAnim();
|
||||
tileDelete(TILE_ANIM);
|
||||
|
||||
return !running;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
END_DUKE_NS
|
|
@ -1,53 +0,0 @@
|
|||
//-------------------------------------------------------------------------
|
||||
/*
|
||||
Copyright (C) 2010 EDuke32 developers and contributors
|
||||
|
||||
This file is part of EDuke32.
|
||||
|
||||
EDuke32 is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#ifndef anim_h_
|
||||
#define anim_h_
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
struct animsound_t
|
||||
{
|
||||
uint16_t frame = 0;
|
||||
int16_t sound = 0;
|
||||
};
|
||||
|
||||
struct dukeanim_t
|
||||
{
|
||||
FString name;
|
||||
double frameaspect1 = 0, frameaspect2 = 0;
|
||||
uint8_t* animbuf = nullptr;
|
||||
TArray<animsound_t> Sounds;
|
||||
uint8_t framedelay = 0;
|
||||
uint8_t frameflags = 0;
|
||||
};
|
||||
|
||||
extern dukeanim_t* g_animPtr;
|
||||
extern TArray<dukeanim_t> g_Animations;
|
||||
extern dukeanim_t * Anim_Find(const char *s);
|
||||
extern dukeanim_t * Anim_Create(const char *fn);
|
||||
int32_t Anim_Play(const char *fn);
|
||||
void Anim_Init(void);
|
||||
|
||||
END_DUKE_NS
|
||||
#endif
|
||||
|
|
@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "net.h"
|
||||
#include "menus.h"
|
||||
#include "savegame.h"
|
||||
#include "zz_anim.h"
|
||||
#include "demo.h"
|
||||
|
||||
#include "cheats.h"
|
||||
|
@ -2018,8 +2017,6 @@ int GameInterface::app_main()
|
|||
i = 1-i;
|
||||
}
|
||||
|
||||
Anim_Init();
|
||||
|
||||
const char *defsfile = G_DefFile();
|
||||
uint32_t stime = timerGetTicks();
|
||||
if (!loaddefinitionsfile(defsfile))
|
||||
|
@ -2063,14 +2060,6 @@ int GameInterface::app_main()
|
|||
ud.last_level = -1;
|
||||
registerosdcommands();
|
||||
|
||||
#ifdef HAVE_CLIPSHAPE_FEATURE
|
||||
int const clipMapError = engineLoadClipMaps();
|
||||
if (clipMapError > 0)
|
||||
Printf("There was an error loading the sprite clipping map (status %d).\n", clipMapError);
|
||||
|
||||
g_clipMapFiles.Reset();
|
||||
#endif
|
||||
|
||||
videoInit();
|
||||
V_LoadTranslations();
|
||||
videoSetPalette(BASEPAL, 0);
|
||||
|
|
|
@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "ns.h" // Must come before everything else!
|
||||
|
||||
#include "duke3d.h"
|
||||
#include "zz_anim.h"
|
||||
#include "menus.h"
|
||||
#include "demo.h"
|
||||
#include "savegame.h"
|
||||
|
|
|
@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "compat.h"
|
||||
#include "screens.h"
|
||||
|
||||
#include "zz_anim.h"
|
||||
#include "sbar.h"
|
||||
#include "menus.h"
|
||||
#include "demo.h"
|
||||
|
@ -1664,70 +1663,6 @@ void G_BonusScreen(int32_t bonusonly)
|
|||
g_vixenLevel = 0;
|
||||
}
|
||||
|
||||
void G_PlayMapAnim(void)
|
||||
{
|
||||
const char *animFile;
|
||||
if (ud.volume_number == 0)
|
||||
{
|
||||
switch (ud.level_number)
|
||||
{
|
||||
case 1:
|
||||
animFile = "lvl1.anm";
|
||||
break;
|
||||
case 2:
|
||||
animFile = "lvl2.anm";
|
||||
break;
|
||||
case 3:
|
||||
animFile = "lvl3.anm";
|
||||
break;
|
||||
case 4:
|
||||
animFile = "lvl4.anm";
|
||||
break;
|
||||
case 5:
|
||||
animFile = "lvl5.anm";
|
||||
break;
|
||||
case 6:
|
||||
animFile = "lvl6.anm";
|
||||
break;
|
||||
default:
|
||||
animFile = "lvl7.anm";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (ud.level_number)
|
||||
{
|
||||
case 1:
|
||||
animFile = "lvl8.anm";
|
||||
break;
|
||||
case 2:
|
||||
animFile = "lvl9.anm";
|
||||
break;
|
||||
case 3:
|
||||
animFile = "lvl10.anm";
|
||||
break;
|
||||
case 4:
|
||||
animFile = "lvl11.anm";
|
||||
break;
|
||||
case 5:
|
||||
animFile = "lvl12.anm";
|
||||
break;
|
||||
case 6:
|
||||
animFile = "lvl13.anm";
|
||||
break;
|
||||
default:
|
||||
animFile = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (animFile == NULL)
|
||||
return;
|
||||
|
||||
Anim_Play(animFile);
|
||||
}
|
||||
|
||||
void G_ShowMapFrame(void)
|
||||
{
|
||||
int frame = -1;
|
||||
|
@ -1789,6 +1724,9 @@ void G_ShowMapFrame(void)
|
|||
rotatesprite_fs(160<<16,100<<16,65536L,0,TILE_RRTILE8624+frame,0,0,10+64+128);
|
||||
}
|
||||
|
||||
void PlayMapAnim(CompletionFunc completion);
|
||||
|
||||
|
||||
void G_BonusScreenRRRA(int32_t bonusonly)
|
||||
{
|
||||
int32_t gfx_offset;
|
||||
|
@ -1930,7 +1868,7 @@ void G_BonusScreenRRRA(int32_t bonusonly)
|
|||
{
|
||||
bonuscnt++;
|
||||
Mus_Stop();
|
||||
G_PlayMapAnim();
|
||||
PlayMapAnim([](bool) {});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue