Mirai's Miscellaneous Misadventures
M44 / include / mimimi.h
1
2
3
4#ifndef MIMIMI_H
5#define MIMIMI_H
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_engine
24{
25 void *data;
26 void *(*texture)(void *data, struct mimimi_image *image);
27 void (*invalidate)(void *data, void *texture);
28 void (*stamp)(void *data, int x, int y, void *texture);
29 struct mimimi_size size;
30};
31
32struct mimimi_physics
33{
34 int dx, dy;
35 unsigned char airborne;
36 int width, height;
37 int gravity;
38};
39
40struct mimimi_collision
41{
42 int count;
43 struct mimimi_position **positions;
44 int strength;
45 int proximity;
46 int height;
47 int tolerance;
48};
49
50struct mimimi_life
51{
52 int knocked_time;
53 int immunity_time;
54 int pristinity;
55 int max_pristinity;
56 int recovery_time;
57};
58
59struct mimimi_fall
60{
61 int max_speed;
62 int knocked_time;
63};
64
65struct mimimi_walk
66{
67 int ground_speed;
68 int airborne_speed;
69 int direction;
70};
71
72struct mimimi_ground
73{
74 int width, height;
75 unsigned char *tiles;
76};
77
78struct mimimi_sprite
79{
80 struct mimimi_position position;
81 struct mimimi_physics physics;
82 struct mimimi_life life;
83 struct mimimi_fall fall;
84 struct mimimi_walk walk;
85 struct mimimi_ground *ground;
86 struct mimimi_position offset;
87};
88
89struct mimimi_conveyor
90{
91 struct mimimi_sprite *sprite;
92 struct mimimi_ground *ground;
93 unsigned char was_airborne;
94 int speed;
95};
96
97struct mimimi_positioned_physics
98{
99 struct mimimi_physics *physics;
100 struct mimimi_physics other;
101 struct mimimi_position transform;
102 struct mimimi_position *position;
103 struct mimimi_position previous;
104 struct mimimi_position other_position;
105 unsigned char was_airborne;
106};
107
108struct mimimi_trampoline
109{
110 struct mimimi_sprite *sprite;
111 struct mimimi_ground *ground;
112 int restitution;
113 int dy;
114};
115
116struct mimimi_video
117{
118 int count;
119 struct mimimi_image *images;
120 void **textures;
121};
122
123struct mimimi_video_set
124{
125 int standing_video_count;
126 int jumping_video_count;
127 struct mimimi_video *standing;
128 struct mimimi_video *knocked;
129 struct mimimi_video *falling;
130 struct mimimi_video *jumping;
131};
132
133struct mimimi_appearance
134{
135 struct mimimi_video_set left, right;
136};
137
138struct mimimi_font
139{
140 unsigned char glyphs[0x60][0x10];
141};
142
143struct mimimi_pose_layer
144{
145 int slant;
146 int y_angle;
147 int z_angle;
148};
149
150struct mimimi_pose
151{
152 int x;
153 int y;
154 int count;
155 struct mimimi_pose_layer layers[0x100];
156};
157
158struct mimimi_movement
159{
160 int count;
161 struct mimimi_pose *poses;
162};
163
164struct mimimi_background
165{
166 void *texture;
167 struct mimimi_position *camera;
168 int x, y, z;
169};
170
171struct mimimi_display
172{
173 struct mimimi_position *camera;
174 struct mimimi_sprite *sprite;
175 struct mimimi_appearance *appearance;
176 unsigned char animation_time;
177 int direction;
178 int width, height;
179};
180
181struct mimimi_row
182{
183 int width;
184 int height;
185 int count;
186 unsigned char colors[0x80];
187};
188
189struct mimimi_layer
190{
191 int x, y, z;
192 int width;
193 int amplifier;
194 int count;
195 struct mimimi_row rows[0x80];
196};
197
198struct mimimi_model_layer
199{
200 int parent_index;
201 struct mimimi_layer *layer;
202};
203
204struct mimimi_model
205{
206 int count;
207 struct mimimi_model_layer layers[0x80];
208};
209
210struct mimimi_history
211{
212 unsigned int left, right;
213};
214
215struct mimimi_clamped_camera_threshold
216{
217 int x;
218 int top;
219 int bottom;
220};
221
222struct mimimi_clamped_camera
223{
224 struct mimimi_position *origin;
225 struct mimimi_position *position;
226 struct mimimi_position *input;
227 struct mimimi_position output;
228 struct mimimi_clamped_camera_threshold *thresholds;
229 int count;
230};
231
232struct mimimi_dialogue_paragraph
233{
234 struct mimimi_model *model;
235 char *name;
236 char *text;
237};
238
239struct mimimi_dialogue
240{
241 struct mimimi_dialogue_paragraph *paragraphs;
242 int count;
243};
244
245struct mimimi_strip_dialogue
246{
247 struct mimimi_engine *engine;
248 int count;
249 void *texture;
250 int notches[0x80];
251 unsigned char held;
252 int i;
253 int x, y;
254 struct mimimi_image image;
255 unsigned char colors[128 * 2048];
256};
257
258struct mimimi_toast_dialogue
259{
260 struct mimimi_engine *engine;
261 int count;
262 void *textures[0x80];
263 int delays[0x80];
264 int heights[0x80];
265 unsigned char colors[128 * 2048];
266 int i, j, k;
267};
268
269struct mimimi_offset_threshold
270{
271 int x;
272 struct mimimi_position offset;
273};
274
275struct mimimi_offset
276{
277 struct mimimi_position *origin;
278 struct mimimi_sprite *sprite;
279 struct mimimi_offset_threshold *thresholds;
280 int count;
281};
282
283extern struct mimimi_font *mimimi_font;
284
285extern struct mimimi_model *mimimi_mango;
286extern struct mimimi_model *mimimi_pepper;
287
288extern signed char *mimimi_sine;
289extern signed char *mimimi_cosine;
290
291int mimimi_div(int n, int q);
292int mimimi_mod(int n, int q);
293
294void mimimi_collision_tick(struct mimimi_collision *collision);
295
296void mimimi_camera_tick(struct mimimi_position *camera, struct mimimi_position *position, int ox, int oy);
297void mimimi_camera_stamp(struct mimimi_engine *engine, struct mimimi_position *camera, int x, int y, int z, void *texture);
298void mimimi_clamped_camera_tick(struct mimimi_clamped_camera *camera);
299
300void mimimi_collision_physics_tick(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground);
301void mimimi_dynamics_tick(struct mimimi_physics *physics, struct mimimi_position *position);
302void mimimi_physics_tick(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground);
303
304void mimimi_life_tick(struct mimimi_life *life);
305void mimimi_fall_tick(struct mimimi_fall *fall, struct mimimi_physics *physics, struct mimimi_life *life);
306void mimimi_walk_tick(struct mimimi_walk *walk, struct mimimi_physics *physics);
307
308void mimimi_sprite(struct mimimi_sprite *sprite, struct mimimi_ground *ground, int x, int y, int width, int height);
309void mimimi_sprite_tick(struct mimimi_sprite *sprite);
310
311void mimimi_conveyor_tick(struct mimimi_conveyor *conveyor);
312void mimimi_positioned_physics_tick(struct mimimi_positioned_physics *physics, struct mimimi_ground *ground);
313void mimimi_positioned_physics(struct mimimi_positioned_physics *physics, struct mimimi_physics *other, struct mimimi_position *position, struct mimimi_ground *ground, struct mimimi_position *transform);
314void mimimi_trampoline_tick(struct mimimi_trampoline *trampoline);
315
316void mimimi_appearance(struct mimimi_appearance *appearance, struct mimimi_model *model, int x, int y);
317void mimimi_video(struct mimimi_video *video, struct mimimi_engine *engine);
318void mimimi_invalidate_video(struct mimimi_video *video, struct mimimi_engine *engine);
319void mimimi_prepare_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine);
320void mimimi_invalidate_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine);
321
322int mimimi_measure_character(struct mimimi_font *font, char ch);
323int mimimi_draw_character(struct mimimi_font *font, char ch, struct mimimi_image *target, int x, int y, unsigned char color);
324
325int mimimi_measure_segment(struct mimimi_font *font, char *text, int count);
326int mimimi_draw_segment(struct mimimi_font *font, char *text, int count, struct mimimi_image *target, int x, int y, unsigned char color);
327
328char *mimimi_skip_word(char *text);
329int mimimi_count_word(char *text);
330int mimimi_measure_word(struct mimimi_font *font, char *text);
331int mimimi_draw_word(struct mimimi_font *font, char *text, struct mimimi_image *target, int x, int y, unsigned char color);
332
333char *mimimi_skip_paragraph(char *text);
334int mimimi_count_paragraph(char *text);
335int mimimi_measure_paragraph(struct mimimi_font *font, char *text);
336int mimimi_draw_paragraph(struct mimimi_font *font, char *text, struct mimimi_image *target, int x, int y, unsigned char color);
337
338char *mimimi_skip_line(struct mimimi_font *font, char *text, int width);
339int mimimi_count_line(struct mimimi_font *font, char *text, int width);
340int mimimi_measure_line(struct mimimi_font *font, char *text, int width);
341int mimimi_draw_line(struct mimimi_font *font, char *text, int width, struct mimimi_image *target, int x, int y, unsigned char color);
342
343int mimimi_measure_text(struct mimimi_font *font, char *text, int width, int line_height);
344int 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);
345
346void mimimi_movement(struct mimimi_video *video, struct mimimi_model *model, struct mimimi_movement *movement);
347void mimimi_pose(struct mimimi_image *image, struct mimimi_model *model, struct mimimi_pose *pose);
348
349void mimimi_background_tick(struct mimimi_background *background, struct mimimi_engine *engine);
350void mimimi_display_tick(struct mimimi_display *display, struct mimimi_engine *engine);
351
352unsigned char mimimi_ground_tile(struct mimimi_ground *ground, int x, int y);
353
354void mimimi_history_tick(struct mimimi_history *history, unsigned char left, unsigned char right);
355void mimimi_controls_tick(struct mimimi_walk *walk, struct mimimi_history *history, void (*jump)(void *data), void *data);
356void mimimi_jump(void *data);
357
358void mimimi_strip_dialogue(struct mimimi_strip_dialogue *strip_dialogue, struct mimimi_dialogue *dialogue, struct mimimi_engine *engine);
359unsigned char mimimi_strip_dialogue_tick(struct mimimi_strip_dialogue *dialogue, unsigned char held);
360
361void mimimi_toast_dialogue(struct mimimi_toast_dialogue *toast_dialogue, struct mimimi_dialogue *dialogue, struct mimimi_engine *engine);
362unsigned char mimimi_toast_dialogue_top_tick(struct mimimi_toast_dialogue *dialogue);
363unsigned char mimimi_toast_dialogue_bottom_tick(struct mimimi_toast_dialogue *dialogue);
364
365void mimimi_offset_tick(struct mimimi_offset *offset);
366
367int mimimi_wasm(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
368int mimimi_fbdev(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
369
370#endif