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; 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) void Anim_Init(void)
{ {
hash_init(&h_dukeanim); hash_init(&h_dukeanim);
Anim_Setup("logo.anm", 9, logoanimsounds); struct defaultanm {
Anim_Setup("3dr.anm", 10, NULL); 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 #ifndef EDUKE32_STANDALONE
Anim_Setup("vol4e1.anm", 10, endanimvol41); { "vol4e1.anm", endanimvol41, 10 },
Anim_Setup("vol4e2.anm", 14, endanimvol42); { "vol4e2.anm", endanimvol42, 14 },
Anim_Setup("vol4e3.anm", 10, endanimvol43); { "vol4e3.anm", endanimvol43, 10 },
Anim_Setup("vol41a.anm", 14, first4animsounds); { "vol41a.anm", first4animsounds, 14 },
Anim_Setup("vol42a.anm", 18, intro4animsounds); { "vol42a.anm", intro4animsounds, 18 },
Anim_Setup("vol43a.anm", 10, intro42animsounds); { "vol43a.anm", intro42animsounds, 10 },
Anim_Setup("duketeam.anm", 10, NULL); { "duketeam.anm", NULL, 10 },
Anim_Setup("radlogo.anm", 10, NULL); { "radlogo.anm", NULL, 10 },
Anim_Setup("cineov2.anm", 18, endanimsounds); { "cineov2.anm", endanimsounds, 18 },
Anim_Setup("cineov3.anm", 10, endanimsounds); { "cineov3.anm", endanimsounds, 10 },
#endif #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) 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_ #ifndef anim_h_
#define anim_h_ #define anim_h_
#define NUM_HARDCODED_ANIMS 12
typedef struct typedef struct
{ {
uint8_t* animbuf; uint8_t* animbuf;