Mirai's Miscellaneous Misadventures

M51 / core / video.c

1/* license: AGPLv3 or later */
2/* copyright 2024 zamfofex */
3
4#include <mimimi.h>
5
6void mimimi_video(struct mimimi_video *video, struct mimimi_engine *engine)
7{
8	int i;
9	for (i = 0 ; i < video->count ; i++)
10		video->textures[i] = (*engine->texture)(engine->data, video->images + i);
11}
12
13void mimimi_invalidate_video(struct mimimi_video *video, struct mimimi_engine *engine)
14{
15	int i;
16	for (i = 0 ; i < video->count ; i++)
17		(*engine->invalidate)(engine->data, video->textures[i]);
18}
19
20static void mimimi_video_set(struct mimimi_video_set *videos, struct mimimi_engine *engine)
21{
22	int i;
23	for (i = 0 ; i < videos->standing_video_count ; i++)
24		mimimi_video(videos->standing + i, engine);
25	mimimi_video(videos->knocked, engine);
26	mimimi_video(videos->falling, engine);
27	for (i = 0 ; i < videos->jumping_video_count ; i++)
28		mimimi_video(videos->jumping + i, engine);
29}
30
31static void mimimi_invalidate_video_set(struct mimimi_video_set *videos, struct mimimi_engine *engine)
32{
33	int i;
34	for (i = 0 ; i < videos->standing_video_count ; i++)
35		mimimi_invalidate_video(videos->standing + i, engine);
36	mimimi_invalidate_video(videos->knocked, engine);
37	mimimi_invalidate_video(videos->falling, engine);
38	for (i = 0 ; i < videos->jumping_video_count ; i++)
39		mimimi_invalidate_video(videos->jumping + i, engine);
40}
41
42void mimimi_prepare_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine)
43{
44	mimimi_video_set(&appearance->left, engine);
45	mimimi_video_set(&appearance->right, engine);
46}
47
48void mimimi_invalidate_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine)
49{
50	mimimi_invalidate_video_set(&appearance->left, engine);
51	mimimi_invalidate_video_set(&appearance->right, engine);
52}