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