1/* @ajax/mesh-ref-doom: programs/doom's CPU reference (mesh-ref lib.rs), operation for operation as
2 * the kernel computes in the cluster float mode: a column's DDA ray through the 16 x 16 map, the wall
3 * height, and the player's pose moved by keys (the host pose of v1 with the view's turn constants).
4 * Freestanding. */
5#ifndef MESH_REF_DOOM_H
6#define MESH_REF_DOOM_H
78#include <stdbool.h>
9#include <stdint.h>
1011/* Column c's ray from (px, py) along dir + plane cam: the wall kind hit (0: none within max_steps),
12 * the side (0 x, 1 y) in *side, the perpendicular distance in *dist (1e30 for none). */
13uint32_t mesh_doom_cast(const uint32_t map[256], float px, float py, float dx, float dy, float plx, float ply,
14 uint32_t c, uint32_t max_steps, uint32_t *side, float *dist);
15/* The column height for a ray's (kind, dist), as doom's render: rows / dist, at most 4 rows. */
16float mesh_doom_height(uint32_t kind, float dist);
17/* The map as the view holds it: cell c = kind of (c % 16, c / 16). */
18void mesh_doom_map(uint32_t out[256]);
1920/* The pose: x, y, dir x, dir y, plane x, plane y. */
21typedef struct {
22 float p[6];
23} mesh_doom_pose;
2425/* A pose at the view's START. */
26mesh_doom_pose mesh_doom_pose_start(void);
27/* Inside the map and on an empty cell (FTZ compares; the cell by truncation). */
28bool mesh_doom_walkable(float x, float y);
29/* Moves by (dx, dy), each axis only if the spot RADIUS beyond it is walkable. */
30void mesh_doom_pose_step(mesh_doom_pose *pose, float dx, float dy);
31/* Rotates dir and plane by the angle with sine s (cosine TURN_COS). */
32void mesh_doom_pose_rotate(mesh_doom_pose *pose, float s);
33/* One key: w s forward/back, a d turn, q e strafe; anything else does nothing. */
34void mesh_doom_pose_apply(mesh_doom_pose *pose, uint8_t key);
3536#endif