Mirai's Miscellaneous Misadventures
M53 / engines / wasm.c
1
2
3
4#include <stdlib.h>
5#include "../mimimi.h"
6
7void mimimi_wasm_sync(int width, int height, unsigned char *colors);
8
9int mimimi_wasm_keys(void);
10int mimimi_wasm_width(void);
11int mimimi_wasm_height(void);
12
13void mimimi_main(void (*tick)(void *data, struct mimimi_output *output,
14 struct mimimi_input *input), void *data)
15{
16 unsigned char keys;
17 struct mimimi_input input;
18 struct mimimi_output output;
19
20 for (;;) {
21 keys = mimimi_wasm_keys();
22 input.size.width = mimimi_wasm_width();
23 input.size.height = mimimi_wasm_height();
24 input.left = keys / 2;
25 input.right = keys % 2;
26
27 (*tick)(data, &output, &input);
28 mimimi_wasm_sync(output.image.width, output.image.height,
29 output.image.colors);
30 }
31}