Mirai's Miscellaneous Misadventures
M48 / include / mimimi.h
#ifndef MIMIMI_H
#define MIMIMI_H
struct mimimi_position
{
int x, y;
};
struct mimimi_size
{
int width, height;
};
struct mimimi_image
{
int width, height;
unsigned char *colors;
};
struct mimimi_engine
{
void *data;
void *(*texture)(void *data, struct mimimi_image *image);
void (*invalidate)(void *data, void *texture);
void (*stamp)(void *data, int x, int y, void *texture);
struct mimimi_size size;
};
struct mimimi_physics
{
int dx, dy;
unsigned char airborne;
int width, height;
int gravity;
};
struct mimimi_collision
{
int count;
struct mimimi_position **positions;
int strength;
int proximity;
int height;
int tolerance;
};
struct mimimi_life
{
int knocked_time;
int immunity_time;
int pristinity;
int max_pristinity;
int recovery_time;
};
struct mimimi_fall
{
int max_speed;
int knocked_time;
};
struct mimimi_walk
{
int ground_speed;
int airborne_speed;
int direction;
};
struct mimimi_ground
{
int width, height;
unsigned char *tiles;
};
struct mimimi_sprite
{
struct mimimi_position position;
struct mimimi_physics physics;
struct mimimi_life life;
struct mimimi_fall fall;
struct mimimi_walk walk;
struct mimimi_ground *ground;
struct mimimi_position offset;
};
struct mimimi_conveyor
{
struct mimimi_sprite *sprite;
struct mimimi_ground *ground;
unsigned char was_airborne;
int speed;
};
struct mimimi_positioned_physics
{
struct mimimi_physics *physics;
struct mimimi_physics other;
struct mimimi_position transform;
struct mimimi_position *position;
struct mimimi_position previous;
unsigned char was_airborne;
};
struct mimimi_trampoline
{
struct mimimi_sprite *sprite;
struct mimimi_ground *ground;
int restitution;
int dy;
};
struct mimimi_video
{
int count;
struct mimimi_image *images;
void **textures;
};
struct mimimi_video_set
{
int standing_video_count;
int jumping_video_count;
struct mimimi_video *standing;
struct mimimi_video *knocked;
struct mimimi_video *falling;
struct mimimi_video *jumping;
};
struct mimimi_appearance
{
struct mimimi_video_set left, right;
};
struct mimimi_font
{
unsigned char glyphs[0x60][0x10];
};
struct mimimi_pose_layer
{
int slant;
int y_angle;
int z_angle;
};
struct mimimi_pose
{
int x;
int y;
int count;
struct mimimi_pose_layer layers[0x100];
};
struct mimimi_movement
{
int count;
struct mimimi_pose *poses;
};
struct mimimi_background
{
void *texture;
struct mimimi_position *camera;
int x, y, z;
};
struct mimimi_display
{
struct mimimi_position *camera;
struct mimimi_sprite *sprite;
struct mimimi_appearance *appearance;
unsigned char animation_time;
int direction;
int width, height;
};
struct mimimi_row
{
int width;
int height;
int count;
unsigned char colors[0x80];
};
struct mimimi_layer
{
int x, y, z;
int width;
int amplifier;
int count;
struct mimimi_row rows[0x80];
};
struct mimimi_model_layer
{
int parent_index;
struct mimimi_layer *layer;
};
struct mimimi_model
{
int count;
struct mimimi_model_layer layers[0x80];
};
struct mimimi_history
{
unsigned int left, right;
};
struct mimimi_clamped_camera_threshold
{
int x;
int top;
int bottom;
};
struct mimimi_clamped_camera
{
struct mimimi_position *position;
struct mimimi_position *input;
struct mimimi_position output;
struct mimimi_clamped_camera_threshold *thresholds;
int count;
};
struct mimimi_dialogue_paragraph
{
struct mimimi_model *model;
char *name;
char *text;
};
struct mimimi_dialogue
{
struct mimimi_dialogue_paragraph *paragraphs;
int count;
};
struct mimimi_strip_dialogue
{
struct mimimi_engine *engine;
int count;
void *texture;
int notches[0x80];
unsigned char held;
int i;
int x, y;
struct mimimi_image image;
unsigned char colors[128 * 2048];
};
struct mimimi_toast_dialogue
{
struct mimimi_engine *engine;
int count;
void *textures[0x80];
int delays[0x80];
int heights[0x80];
unsigned char colors[128 * 2048];
int i, j, k;
};
struct mimimi_offset_threshold
{
int x;
struct mimimi_position offset;
};
struct mimimi_offset
{
struct mimimi_sprite *sprite;
struct mimimi_offset_threshold *thresholds;
int count;
};
struct mimimi_momentum
{
int x;
int dx;
};
struct mimimi_platform
{
struct mimimi_positioned_physics physics;
struct mimimi_ground ground;
void *texture;
};
struct mimimi_logo_line
{
unsigned char *packed;
struct mimimi_size size;
struct mimimi_position position;
};
struct mimimi_logo
{
struct mimimi_logo_line *lines;
unsigned char colors[8][16384];
struct mimimi_image images[8];
void *textures[8];
int y_offsets[8];
int count;
};
extern struct mimimi_font *mimimi_font;
extern struct mimimi_model *mimimi_mango;
extern struct mimimi_model *mimimi_pepper;
extern signed char *mimimi_sine;
extern signed char *mimimi_cosine;
extern int mimimi_angle(int x, int y);
extern struct mimimi_logo_line *mimimi_logo_lines;
extern int mimimi_logo_line_count;
int mimimi_div(int n, int q);
int mimimi_div_up(int n, int q);
int mimimi_div_down(int n, int q);
int mimimi_mod(int n, int q);
void mimimi_collision_tick(struct mimimi_collision *collision);
void mimimi_camera_tick(struct mimimi_position *camera, struct mimimi_position *position, int ox, int oy);
void mimimi_camera_stamp(struct mimimi_engine *engine, struct mimimi_position *camera, int x, int y, int z, void *texture);
void mimimi_clamped_camera_tick(struct mimimi_clamped_camera *camera);
void mimimi_collision_physics_tick(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground);
void mimimi_dynamics_tick(struct mimimi_physics *physics, struct mimimi_position *position);
void mimimi_physics_tick(struct mimimi_physics *physics, struct mimimi_position *position, struct mimimi_ground *ground);
void mimimi_physics(struct mimimi_physics *physics, int width, int height);
void mimimi_life_tick(struct mimimi_life *life);
void mimimi_fall_tick(struct mimimi_fall *fall, struct mimimi_physics *physics, struct mimimi_life *life);
void mimimi_walk_tick(struct mimimi_walk *walk, struct mimimi_physics *physics);
void mimimi_sprite(struct mimimi_sprite *sprite, struct mimimi_ground *ground, int x, int y, int width, int height);
void mimimi_sprite_tick(struct mimimi_sprite *sprite);
void mimimi_conveyor_tick(struct mimimi_conveyor *conveyor);
void mimimi_positioned_physics_tick(struct mimimi_positioned_physics *physics, struct mimimi_ground *ground);
void mimimi_positioned_physics(struct mimimi_positioned_physics *physics, struct mimimi_physics *other, struct mimimi_position *position);
void mimimi_trampoline_tick(struct mimimi_trampoline *trampoline);
void mimimi_appearance(struct mimimi_appearance *appearance, struct mimimi_model *model, int x, int y);
void mimimi_video(struct mimimi_video *video, struct mimimi_engine *engine);
void mimimi_invalidate_video(struct mimimi_video *video, struct mimimi_engine *engine);
void mimimi_prepare_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine);
void mimimi_invalidate_appearance(struct mimimi_appearance *appearance, struct mimimi_engine *engine);
int mimimi_measure_character(struct mimimi_font *font, char ch);
int mimimi_draw_character(struct mimimi_font *font, char ch, struct mimimi_image *target, int x, int y, unsigned char color);
int mimimi_measure_segment(struct mimimi_font *font, char *text, int count);
int mimimi_draw_segment(struct mimimi_font *font, char *text, int count, struct mimimi_image *target, int x, int y, unsigned char color);
char *mimimi_skip_word(char *text);
int mimimi_count_word(char *text);
int mimimi_measure_word(struct mimimi_font *font, char *text);
int mimimi_draw_word(struct mimimi_font *font, char *text, struct mimimi_image *target, int x, int y, unsigned char color);
char *mimimi_skip_paragraph(char *text);
int mimimi_count_paragraph(char *text);
int mimimi_measure_paragraph(struct mimimi_font *font, char *text);
int mimimi_draw_paragraph(struct mimimi_font *font, char *text, struct mimimi_image *target, int x, int y, unsigned char color);
char *mimimi_skip_line(struct mimimi_font *font, char *text, int width);
int mimimi_count_line(struct mimimi_font *font, char *text, int width);
int mimimi_measure_line(struct mimimi_font *font, char *text, int width);
int mimimi_draw_line(struct mimimi_font *font, char *text, int width, struct mimimi_image *target, int x, int y, unsigned char color);
int mimimi_measure_text(struct mimimi_font *font, char *text, int width, int line_height);
int 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);
void mimimi_movement(struct mimimi_video *video, struct mimimi_model *model, struct mimimi_movement *movement);
void mimimi_pose(struct mimimi_image *image, struct mimimi_model *model, struct mimimi_pose *pose);
void mimimi_background_tick(struct mimimi_background *background, struct mimimi_engine *engine);
void mimimi_display_tick(struct mimimi_display *display, struct mimimi_engine *engine);
unsigned char mimimi_ground_tile(struct mimimi_ground *ground, int x, int y);
void mimimi_history_tick(struct mimimi_history *history, unsigned char left, unsigned char right);
void mimimi_controls_tick(struct mimimi_walk *walk, struct mimimi_history *history, void (*jump)(void *data), void *data);
void mimimi_jump(void *data);
void mimimi_strip_dialogue(struct mimimi_strip_dialogue *strip_dialogue, struct mimimi_dialogue *dialogue, struct mimimi_engine *engine);
unsigned char mimimi_strip_dialogue_tick(struct mimimi_strip_dialogue *dialogue, unsigned char held);
void mimimi_toast_dialogue(struct mimimi_toast_dialogue *toast_dialogue, struct mimimi_dialogue *dialogue, struct mimimi_engine *engine);
unsigned char mimimi_toast_dialogue_top_tick(struct mimimi_toast_dialogue *dialogue);
unsigned char mimimi_toast_dialogue_bottom_tick(struct mimimi_toast_dialogue *dialogue);
void mimimi_offset_tick(struct mimimi_offset *offset, int x, int y);
void mimimi_linear_propagate(struct mimimi_momentum *momentum, int value, int x0, int scale, int weight);
void mimimi_linear_apply(struct mimimi_momentum *momentum, int *value, int x0, int scale);
void mimimi_angular_propagate(struct mimimi_momentum *momentum, struct mimimi_position *position, int x0, int y0, int a0, int scale, int weight);
void mimimi_angular_apply(struct mimimi_momentum *momentum, struct mimimi_position *position, int x0, int y0, int a0, int scale, int length);
void mimimi_platform_display_tick(struct mimimi_platform *platform, struct mimimi_position *camera, int x, int y, struct mimimi_engine *engine);
void mimimi_logo(struct mimimi_engine *engine, struct mimimi_logo *logo, struct mimimi_logo_line *lines, int count);
unsigned char mimimi_logo_tick(struct mimimi_engine *engine, struct mimimi_logo *logo, int x, int y);
void mimimi_unpack_bits(int size, unsigned char *unpacked, unsigned char *packed);
int mimimi_wasm(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
int mimimi_fbdev(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
int mimimi_minifb(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
int mimimi_sdl2(void (*start)(void *chapter, struct mimimi_engine *engine), void (*tick)(void *chapter, unsigned char left, unsigned char right), unsigned long int size);
#endif