Mirai's Miscellaneous Misadventures
M53 / mimimi.h
1
2
3
4#ifndef MIMIMI
5#define MIMIMI
6
7struct mimimi_position {
8 int x, y;
9};
10
11struct mimimi_size {
12 int width, height;
13};
14
15struct mimimi_image {
16 int width, height;
17 unsigned char *colors;
18};
19
20struct mimimi_physics {
21 int dx, dy;
22 unsigned char airborne;
23 int width, height;
24 int gravity;
25 struct mimimi_sprite *sprite;
26};
27
28struct mimimi_life {
29 int knocked_time;
30 int immunity_time;
31 int pristinity;
32 int max_pristinity;
33 int recovery_time;
34};
35
36struct mimimi_fall {
37 int max_speed;
38 int knocked_time;
39};
40
41struct mimimi_walk {
42 int ground_speed;
43 int airborne_speed;
44 int direction;
45};
46
47struct mimimi_ground {
48 int width, height;
49 unsigned char tiles[0x2000];
50};
51
52struct mimimi_sprite {
53 struct mimimi_position position;
54 struct mimimi_physics physics;
55 struct mimimi_life life;
56 struct mimimi_fall fall;
57 struct mimimi_walk walk;
58 struct mimimi_ground *ground;
59 struct mimimi_position offset;
60 struct mimimi_model *model;
61 unsigned char animation_time;
62 unsigned char landing_time;
63 int direction;
64 int trailing_y;
65 unsigned char trail;
66};
67
68struct mimimi_conveyor {
69 struct mimimi_sprite *sprite;
70 struct mimimi_ground *ground;
71 unsigned char was_airborne;
72 int speed;
73};
74
75struct mimimi_positioned_physics {
76 struct mimimi_physics *physics;
77 struct mimimi_physics other;
78 struct mimimi_position transform;
79 struct mimimi_position *position;
80 struct mimimi_position previous;
81 unsigned char was_airborne;
82};
83
84struct mimimi_trampoline {
85 struct mimimi_sprite *sprite;
86 struct mimimi_ground *ground;
87 int restitution;
88 int dy;
89};
90
91struct mimimi_font {
92 unsigned char glyphs[0x60][0x10];
93};
94
95struct mimimi_pose_layer {
96 int slant;
97 int y_angle;
98 int z_angle;
99 int y;
100};
101
102struct mimimi_pose {
103 int x, y;
104 struct mimimi_pose_layer layers[0x80];
105};
106
107struct mimimi_background {
108 struct mimimi_image image;
109 int x, y, z;
110};
111
112struct mimimi_row {
113 int width;
114 int height;
115 int count;
116 unsigned char colors[0x80];
117};
118
119struct mimimi_layer {
120 int x, y, z;
121 int width;
122 int amplifier;
123 int count;
124 struct mimimi_row rows[0x80];
125};
126
127struct mimimi_model_layer {
128 int parent_index;
129 struct mimimi_layer *layer;
130};
131
132struct mimimi_model {
133 int count;
134 struct mimimi_model_layer layers[0x80];
135};
136
137struct mimimi_history {
138 unsigned int left, right;
139};
140
141struct mimimi_clamped_camera {
142 struct mimimi_position *input;
143 struct mimimi_position output;
144 struct mimimi_position offset;
145 struct mimimi_size size;
146};
147
148struct mimimi_dialogue_paragraph {
149 struct mimimi_model *model;
150 char *name;
151 char *text;
152};
153
154struct mimimi_dialogue {
155 struct mimimi_dialogue_paragraph *paragraphs;
156 int count;
157};
158
159struct mimimi_toast_dialogue {
160 int count;
161 int *delays;
162 int *heights;
163 struct mimimi_image *images;
164 int i, j, k;
165};
166
167struct mimimi_momentum {
168 int x;
169 int dx;
170};
171
172struct mimimi_platform {
173 struct mimimi_positioned_physics physics;
174 struct mimimi_ground *ground;
175 struct mimimi_image *image;
176};
177
178struct mimimi_linear_motion {
179 int *value;
180 int origin;
181 int scale;
182};
183
184struct mimimi_angular_motion {
185 struct mimimi_position *value;
186 struct mimimi_position origin;
187 int angle;
188 int scale;
189 int height;
190};
191
192struct mimimi_platform_set {
193 struct mimimi_momentum momentum;
194 int balance;
195 int strength;
196 int linear_weight;
197 int angular_weight;
198 int min, max;
199
200 int linear_platform_count;
201 struct mimimi_platform *linear_platforms;
202 struct mimimi_linear_motion *linear_motions;
203
204 int angular_platform_count;
205 struct mimimi_platform *angular_platforms;
206 struct mimimi_angular_motion *angular_motions;
207};
208
209struct mimimi_area {
210 struct mimimi_ground *ground;
211 struct mimimi_position offset;
212 struct mimimi_background *backgrounds;
213 int background_count;
214 struct mimimi_background *foregrounds;
215 int foreground_count;
216};
217
218struct mimimi_stage {
219 struct mimimi_sprite *sprites;
220 int sprite_count;
221 struct mimimi_position camera;
222 struct mimimi_clamped_camera clamped_camera;
223 struct mimimi_area *areas;
224 int area_count;
225 struct mimimi_platform_set *platform_sets;
226 int platform_set_count;
227};
228
229struct mimimi_input {
230 unsigned char left, right;
231 struct mimimi_size size;
232};
233
234struct mimimi_output {
235 struct mimimi_image image;
236};
237
238extern struct mimimi_font *mimimi_font;
239
240extern struct mimimi_model *mimimi_mango;
241extern struct mimimi_model *mimimi_pepper;
242
243extern struct mimimi_model *mimimi_homura_flash;
244extern struct mimimi_model *mimimi_mirai_flash;
245extern struct mimimi_model *mimimi_haruka_flash;
246
247extern struct mimimi_model *mimimi_ryoubi_flash;
248extern struct mimimi_model *mimimi_ryouna_flash;
249
250extern struct mimimi_model *mimimi_mirai_shinomas;
251
252extern signed char *mimimi_sine;
253extern signed char *mimimi_cosine;
254
255int mimimi_div(int n, int q);
256int mimimi_div_up(int n, int q);
257int mimimi_div_down(int n, int q);
258int mimimi_mod(int n, int q);
259int mimimi_angle(int x, int y);
260
261void mimimi_stamp(struct mimimi_image *target, int x, int y,
262 struct mimimi_image *source);
263
264void mimimi_camera_tick(struct mimimi_position *camera,
265 struct mimimi_position *position, int ox, int oy);
266void mimimi_camera_stamp(struct mimimi_image *target,
267 struct mimimi_position *camera, int x, int y, int z,
268 struct mimimi_image *source);
269void mimimi_clamped_camera_tick(struct mimimi_clamped_camera *camera,
270 int width, int height);
271
272void mimimi_collision_physics_tick(struct mimimi_physics *physics,
273 struct mimimi_position *position, struct mimimi_ground *ground);
274void mimimi_dynamics_tick(struct mimimi_physics *physics,
275 struct mimimi_position *position);
276void mimimi_physics_tick(struct mimimi_physics *physics,
277 struct mimimi_position *position, struct mimimi_ground *ground);
278void mimimi_physics(struct mimimi_physics *physics, int width, int height);
279
280void mimimi_life_tick(struct mimimi_life *life);
281void mimimi_fall_tick(struct mimimi_fall *fall,
282 struct mimimi_physics *physics, struct mimimi_life *life);
283void mimimi_walk_tick(struct mimimi_walk *walk,
284 struct mimimi_physics *physics);
285
286void mimimi_sprite(struct mimimi_sprite *sprite, struct mimimi_model *model,
287 struct mimimi_ground *ground, int x, int y, int width, int height);
288void mimimi_sprite_tick(struct mimimi_sprite *sprite);
289
290void mimimi_conveyor_tick(struct mimimi_conveyor *conveyor);
291void mimimi_positioned_physics_tick(struct mimimi_positioned_physics
292 *physics, struct mimimi_ground *ground);
293void mimimi_positioned_physics(struct mimimi_positioned_physics *physics,
294 struct mimimi_physics *other, struct mimimi_position *position);
295void mimimi_trampoline_tick(struct mimimi_trampoline *trampoline);
296
297int mimimi_measure_character(struct mimimi_font *font, char ch);
298int mimimi_draw_character(struct mimimi_font *font, char ch,
299 struct mimimi_image *target, int x, int y, unsigned char color);
300
301int mimimi_measure_segment(struct mimimi_font *font, char *text,
302 int count);
303int mimimi_draw_segment(struct mimimi_font *font, char *text, int count,
304 struct mimimi_image *target, int x, int y, unsigned char color);
305
306char *mimimi_skip_word(char *text);
307int mimimi_count_word(char *text);
308int mimimi_measure_word(struct mimimi_font *font, char *text);
309int mimimi_draw_word(struct mimimi_font *font, char *text,
310 struct mimimi_image *target, int x, int y, unsigned char color);
311
312char *mimimi_skip_paragraph(char *text);
313int mimimi_count_paragraph(char *text);
314int mimimi_measure_paragraph(struct mimimi_font *font, char *text);
315int mimimi_draw_paragraph(struct mimimi_font *font, char *text,
316 struct mimimi_image *target, int x, int y, unsigned char color);
317
318char *mimimi_skip_line(struct mimimi_font *font, char *text, int width);
319int mimimi_count_line(struct mimimi_font *font, char *text, int width);
320int mimimi_measure_line(struct mimimi_font *font, char *text, int width);
321int mimimi_draw_line(struct mimimi_font *font, char *text, int width,
322 struct mimimi_image *target, int x, int y, unsigned char color);
323
324int mimimi_measure_text(struct mimimi_font *font, char *text, int width,
325 int line_height);
326int mimimi_draw_text(struct mimimi_font *font, char *text, int width,
327 int line_height, struct mimimi_image *target, int x, int y,
328 unsigned char color);
329
330void mimimi_pose(struct mimimi_image *image, struct mimimi_model *model,
331 struct mimimi_pose *pose);
332void mimimi_interpolate(struct mimimi_pose *a, struct mimimi_pose *b, int i,
333 int count);
334
335void mimimi_background_tick(struct mimimi_background *background,
336 struct mimimi_image *image, struct mimimi_position *camera,
337 struct mimimi_position *offset);
338void mimimi_display_tick(struct mimimi_image *image,
339 struct mimimi_sprite *sprite, struct mimimi_position *camera);
340
341unsigned char mimimi_ground_tile(struct mimimi_ground *ground, int x, int y);
342
343void mimimi_history_tick(struct mimimi_history *history,
344 unsigned char left, unsigned char right);
345void mimimi_controls_tick(struct mimimi_walk *walk,
346 struct mimimi_history *history, void (*jump)(void *data), void *data);
347void mimimi_jump(void *data);
348
349void mimimi_toast_dialogue(struct mimimi_toast_dialogue *toast_dialogue,
350 struct mimimi_dialogue *dialogue);
351int mimimi_toast_dialogue_tick(struct mimimi_toast_dialogue *dialogue,
352 struct mimimi_image *image);
353
354void mimimi_stage(struct mimimi_stage *stage,
355 struct mimimi_ground **grounds, int count);
356void mimimi_stage_tick(struct mimimi_stage *stage,
357 struct mimimi_image *image);
358struct mimimi_sprite *mimimi_spawn(struct mimimi_stage *stage,
359 struct mimimi_model *model, int x, int y, int width, int height);
360
361void mimimi_linear_propagate(struct mimimi_momentum *momentum, int value,
362 int x0, int scale);
363void mimimi_linear_apply(struct mimimi_momentum *momentum, int *value,
364 int x0, int scale);
365
366void mimimi_angular_propagate(struct mimimi_momentum *momentum,
367 struct mimimi_position *position, int x0, int y0, int a0, int scale);
368void mimimi_angular_apply(struct mimimi_momentum *momentum,
369 struct mimimi_position *position, int x0, int y0, int a0, int scale,
370 int length);
371
372void mimimi_linear_motion_propagate(struct mimimi_linear_motion *motion,
373 struct mimimi_momentum *momentum);
374void mimimi_linear_motion_apply(struct mimimi_linear_motion *motion,
375 struct mimimi_momentum *momentum);
376
377void mimimi_angular_motion_propagate(struct mimimi_angular_motion *motion,
378 struct mimimi_momentum *momentum);
379void mimimi_angular_motion_apply(struct mimimi_angular_motion *motion,
380 struct mimimi_momentum *momentum);
381
382void mimimi_platform_display_tick(struct mimimi_platform *platform,
383 struct mimimi_position *camera, struct mimimi_image *image);
384struct mimimi_platform_set *mimimi_add_platform_set(struct mimimi_stage *stage);
385void mimimi_spawn_linear_platform(struct mimimi_stage *stage,
386 struct mimimi_platform_set *platforms, struct mimimi_ground *ground,
387 struct mimimi_image *image, int x, int y, int scale);
388void mimimi_spawn_angular_platform(struct mimimi_stage *stage,
389 struct mimimi_platform_set *platforms, struct mimimi_ground *ground,
390 struct mimimi_image *image, int x, int y, int a, int scale,
391 int height);
392
393void mimimi_platform_set_tick(struct mimimi_platform_set *platform_set);
394void mimimi_platform_set_display_tick(struct mimimi_platform_set *platforms,
395 struct mimimi_image *image, struct mimimi_position *camera);
396
397void mimimi_unpack_bits(int size, unsigned char *unpacked,
398 unsigned char *packed);
399
400void mimimi_linear_motion(struct mimimi_linear_motion *motion, int *value,
401 int origin, int scale);
402void mimimi_angular_motion(struct mimimi_angular_motion *motion,
403 struct mimimi_position *value, int x0, int y0, int a0, int scale,
404 int height);
405
406void mimimi_background(struct mimimi_image *image,
407 struct mimimi_ground *ground, unsigned char *colors);
408
409void mimimi_boxing(struct mimimi_size *size, struct mimimi_image *image);
410
411void mimimi_scale(struct mimimi_image *target, struct mimimi_image *source);
412
413void mimimi_main(void (*tick)(void *data, struct mimimi_output *output,
414 struct mimimi_input *input), void *data);
415
416#endif