Structify the hardcoded Anim_Setup calls.

git-svn-id: https://svn.eduke32.com/eduke32@6281 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-25 11:24:14 +00:00
parent aebd4c53c4
commit 6b880ccb06
2 changed files with 27 additions and 22 deletions

View file

@ -72,33 +72,40 @@ dukeanim_t * Anim_Create(char const * fn)
return anim;
}
static dukeanim_t * Anim_Setup(const char *fn, uint8_t fdelay, void (*sound_func)(int32_t))
{
dukeanim_t * anim = Anim_Create(fn);
anim->framedelay = fdelay;
anim->sound_func = sound_func;
return anim;
}
void Anim_Init(void)
{
hash_init(&h_dukeanim);
Anim_Setup("logo.anm", 9, logoanimsounds);
Anim_Setup("3dr.anm", 10, NULL);
struct defaultanm {
char const *fn;
void (*sound_func)(int32_t);
uint8_t fdelay;
};
static defaultanm const anms[] =
{
{ "logo.anm", logoanimsounds, 9 },
{ "3dr.anm", NULL, 10 },
#ifndef EDUKE32_STANDALONE
Anim_Setup("vol4e1.anm", 10, endanimvol41);
Anim_Setup("vol4e2.anm", 14, endanimvol42);
Anim_Setup("vol4e3.anm", 10, endanimvol43);
Anim_Setup("vol41a.anm", 14, first4animsounds);
Anim_Setup("vol42a.anm", 18, intro4animsounds);
Anim_Setup("vol43a.anm", 10, intro42animsounds);
Anim_Setup("duketeam.anm", 10, NULL);
Anim_Setup("radlogo.anm", 10, NULL);
Anim_Setup("cineov2.anm", 18, endanimsounds);
Anim_Setup("cineov3.anm", 10, endanimsounds);
{ "vol4e1.anm", endanimvol41, 10 },
{ "vol4e2.anm", endanimvol42, 14 },
{ "vol4e3.anm", endanimvol43, 10 },
{ "vol41a.anm", first4animsounds, 14 },
{ "vol42a.anm", intro4animsounds, 18 },
{ "vol43a.anm", intro42animsounds, 10 },
{ "duketeam.anm", NULL, 10 },
{ "radlogo.anm", NULL, 10 },
{ "cineov2.anm", endanimsounds, 18 },
{ "cineov3.anm", endanimsounds, 10 },
#endif
};
for (defaultanm const & anm : anms)
{
dukeanim_t * anim = Anim_Create(anm.fn);
anim->framedelay = anm.fdelay;
anim->sound_func = anm.sound_func;
}
}
int32_t Anim_Play(const char *fn)

View file

@ -23,8 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef anim_h_
#define anim_h_
#define NUM_HARDCODED_ANIMS 12
typedef struct
{
uint8_t* animbuf;