Last active
April 13, 2019 15:19
-
-
Save thebirk/776cb832a1bf7c13e9c86e0a90e48b67 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Release - x64 | |
void set_background_color(float r, float g, float b); | |
void draw_line(float x0, float y0, float x1, float y1, float r, float g, float b, float a); | |
float print_string(char* text, float x, float y, float size, float r, float g, float b, float a); | |
float print_int(int number, float x, float y, float size, float r, float g, float b, float a); | |
float print_float(float number, int decimals, float x, float y, float size, float r, float g, float b, float a); | |
double math_cos(double x); | |
double math_sin(double x); | |
double math_atan2(double x, double y); | |
double math_pow(double x, double y); | |
double math_sqrt(double x); | |
int math_rand(); | |
void start_recording(); | |
void stop_recording(); | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
#define PI (3.14159265358) | |
#define ARRAYSIZE(a) (sizeof(a)/sizeof(*a)) | |
double tan(double x) { return math_sin(x) / math_cos(x); } | |
template<typename T> | |
static inline T abs(T v) { | |
return (v < 0) ? -v : v; | |
} | |
struct vec2 { float x, y; }; | |
struct vec3 { float x, y, z; }; | |
struct vec4 { float x, y, z, w; }; | |
struct mat4 { float m[4][4]; }; | |
float vec2_cross(vec2 a, vec2 b) { | |
return a.x * b.y - a.y * b.x; | |
} | |
float vec2_length(vec2 p) { | |
return math_sqrt(p.x*p.x + p.y*p.y); | |
} | |
vec2 vec2_normalize(vec2 p) { | |
float l = vec2_length(p); | |
return { p.x / l, p.y / l }; | |
} | |
vec2 vec2_add(vec2 a, vec2 b) { | |
return { a.x + b.x, a.y + b.y }; | |
} | |
vec2 vec2_subtract(vec2 a, vec2 b) { | |
return { a.x - b.x, a.y - b.y }; | |
} | |
vec2 vec2_mul(vec2 a, vec2 b) { | |
return { a.x * b.x, a.y * b.y }; | |
} | |
vec2 vec2_mul_float(vec2 a, float v) { | |
return { a.x * v, a.y * v }; | |
} | |
vec2 vec2_div(vec2 a, vec2 b) { | |
return { a.x / b.x, a.y / b.y }; | |
} | |
vec2 vec2_div_float(vec2 a, float v) { | |
return { a.x / v, a.y / v }; | |
} | |
float vec3_dot(vec3 a, vec3 b) { | |
return a.x*b.x + a.y*b.y + a.z*b.z; | |
} | |
float vec3_length(vec3 p) { | |
return math_sqrt(vec3_dot(p, p)); | |
} | |
vec3 vec3_normalize(vec3 p) { | |
float l = vec3_length(p); | |
return { | |
p.x / l, | |
p.y / l, | |
p.z / l | |
}; | |
} | |
vec3 vec3_cross(vec3 a, vec3 b) { | |
return { | |
a.y*b.z - a.z*b.y, | |
a.z*b.x - a.x*b.z, | |
a.x*b.y - a.y*b.x | |
}; | |
} | |
vec3 vec3_add(vec3 a, vec3 b) { | |
return { | |
a.x + b.x, | |
a.y + b.y, | |
a.z + b.z | |
}; | |
} | |
vec3 vec3_subtract(vec3 a, vec3 b) { | |
return { | |
a.x - b.x, | |
a.y - b.y, | |
a.z - b.z | |
}; | |
} | |
vec3 vec3_mul(vec3 a, vec3 b) { | |
return { | |
a.x * b.x, | |
a.y * b.y, | |
a.z * b.z | |
}; | |
} | |
vec3 vec3_div(vec3 a, vec3 b) { | |
return { | |
a.x / b.x, | |
a.y / b.y, | |
a.z / b.z | |
}; | |
} | |
vec3 vec3_div_float(vec3 a, float b) { | |
return { | |
a.x / b, | |
a.y / b, | |
a.z / b | |
}; | |
} | |
mat4 perspective(float fovy, float aspect, float near, float far) { | |
mat4 m = { 0 }; | |
float tan_half_fovy = tan(0.5f * fovy); | |
m.m[0][0] = 1.0f / (aspect*tan_half_fovy); | |
m.m[1][1] = 1.0f / (tan_half_fovy); | |
m.m[2][2] = -(far + near) / (far - near); | |
m.m[2][3] = -1.0f; | |
m.m[3][2] = -2.0f*far*near / (far - near); | |
return m; | |
} | |
mat4 lookat(vec3 eye, vec3 centre, vec3 up) { | |
vec3 f = vec3_normalize(vec3_subtract(centre, eye)); | |
vec3 s = vec3_normalize(vec3_cross(f, up)); | |
vec3 u = vec3_cross(s, f); | |
return mat4{ { | |
{+s.x, +u.x, -f.x, 0}, | |
{+s.y, +u.y, -f.y, 0}, | |
{+s.z, +u.z, -f.z, 0}, | |
{-vec3_dot(s, eye), -vec3_dot(u, eye), vec3_dot(f, eye), 1}, | |
} }; | |
} | |
mat4 mat4_identity() { | |
return { { | |
{1, 0, 0, 0}, | |
{0, 1, 0, 0}, | |
{0, 0, 1, 0}, | |
{0, 0, 0, 1}, | |
} }; | |
} | |
mat4 mat4_translate(vec3 v) { | |
mat4 m = mat4_identity(); | |
m.m[3][0] = v.x; | |
m.m[3][1] = v.y; | |
m.m[3][2] = v.z; | |
m.m[3][3] = 1; | |
return m; | |
} | |
mat4 mat4_rotate(vec3 v, float angle_radians) { | |
float c = math_cos(angle_radians); | |
float s = math_sin(angle_radians); | |
vec3 a = vec3_normalize(v); | |
vec3 t = vec3_mul(a, vec3_subtract(vec3{ 1, 1, 1 }, vec3{ c, c, c })); | |
mat4 rot = mat4_identity(); | |
rot.m[0][0] = c + t.x * a.x; | |
rot.m[0][1] = 0 + t.x * a.y + s * a.z; | |
rot.m[0][2] = 0 + t.x * a.z - s * a.y; | |
rot.m[0][3] = 0; | |
rot.m[1][0] = 0 + t.y * a.x - s * a.z; | |
rot.m[1][1] = c + t.y * a.y; | |
rot.m[1][2] = 0 + t.y * a.z + s * a.x; | |
rot.m[1][3] = 0; | |
rot.m[2][0] = 0 + t.z * a.x + s * a.y; | |
rot.m[2][1] = 0 + t.z * a.y - s * a.x; | |
rot.m[2][2] = c + t.z * a.z; | |
rot.m[2][3] = 0; | |
return rot; | |
} | |
mat4 mat4_mul(mat4 a, mat4 b) { | |
mat4 c = { 0 }; | |
for (int j = 0; j < 4; j++) { | |
for (int i = 0; i < 4; i++) { | |
c.m[j][i] = | |
a.m[0][i] * b.m[j][0] + | |
a.m[1][i] * b.m[j][1] + | |
a.m[2][i] * b.m[j][2] + | |
a.m[3][i] * b.m[j][3]; | |
} | |
} | |
return c; | |
} | |
vec4 mat4_mul_vec4(mat4 m, vec4 v) { | |
return vec4{ | |
m.m[0][0] * v.x + m.m[1][0] * v.y + m.m[2][0] * v.z + m.m[3][0] * v.w, | |
m.m[0][1] * v.x + m.m[1][1] * v.y + m.m[2][1] * v.z + m.m[3][1] * v.w, | |
m.m[0][2] * v.x + m.m[1][2] * v.y + m.m[2][2] * v.z + m.m[3][2] * v.w, | |
m.m[0][3] * v.x + m.m[1][3] * v.y + m.m[2][3] * v.z + m.m[3][3] * v.w, | |
}; | |
} | |
vec3 vertices[] = { | |
{-0.5f, 0.5f, -0.5f}, | |
{ 0.5f, 0.5f, -0.5f}, | |
{-0.5f, -0.5f, -0.5f}, | |
{ 0.5f, -0.5f, -0.5f}, | |
{-0.5f, 0.5f, 0.5f}, | |
{ 0.5f, 0.5f, 0.5f}, | |
{-0.5f, -0.5f, 0.5f}, | |
{ 0.5f, -0.5f, 0.5f}, | |
}; | |
int indices[] = { | |
0, 1, | |
2, 3, | |
0, 2, | |
1, 3, | |
4, 5, | |
6, 7, | |
4, 6, | |
5, 7, | |
0, 4, | |
1, 5, | |
2, 6, | |
3, 7, | |
}; | |
vec4 transform_point(mat4 matrix, vec3 pos) { | |
vec4 res = mat4_mul_vec4(matrix, vec4{ pos.x, pos.y, pos.z, 1 }); | |
return res; | |
} | |
vec4 perspective_divide(vec4 a) { | |
return vec4{ | |
a.x / a.w, | |
a.y / a.w, | |
a.z / a.w, | |
a.w | |
}; | |
} | |
vec4 world_to_screen(vec4 pos, float width, float height) { | |
pos.x += 1; | |
pos.y += 1; // This could be pos.y = 1-pos.y, and we wouldnt have to flip the Y later | |
pos.x *= width / 2.0f; | |
pos.y *= height / 2.0f; | |
//result.x = (pos.x + 1.0f) * width / 2.0; | |
//result.y = (pos.y + 1.0f) * height / 2.0; | |
return pos; | |
} | |
vec4 viewclip_coord(vec4 p, float view_width, float view_height) { | |
if (p.x < 0) p.x = 0; | |
if (p.x >= view_width) p.x = view_width - 1; | |
if (p.y < 0) p.y = 0; | |
if (p.y >= view_height) p.y = view_height - 1; | |
return p; | |
} | |
bool is_inside_view(vec2 p, float view_width, float view_height) { | |
return (p.x >= 0 && p.x < view_width && p.y >= 0 && p.y < view_height); | |
} | |
inline bool same_sign(float a, float b) { | |
return a * b > 1.0f; | |
} | |
void project_line(mat4 mvp, vec3 p0, vec3 p1, float view_width, float view_height, vec4 color) { | |
vec4 tp1 = transform_point(mvp, p0); | |
vec4 tp2 = transform_point(mvp, p1); | |
tp1 = perspective_divide(tp1); | |
tp2 = perspective_divide(tp2); | |
#if 1 | |
// Basic curve effect | |
// More effective on smaller line segments | |
float cu = 0.01; | |
float rsq1 = tp1.x * tp1.x + tp1.y*tp1.y; | |
tp1.x -= tp1.x * (cu * rsq1); | |
tp1.y -= tp1.y * (cu * rsq1); | |
float rsq2 = tp2.x * tp2.x + tp2.y*tp2.y; | |
tp2.x -= tp2.x * (cu * rsq2); | |
tp2.y -= tp2.y * (cu * rsq2); | |
#endif | |
tp1 = world_to_screen(tp1, view_width, view_height); | |
tp2 = world_to_screen(tp2, view_width, view_height); | |
// if (!(is_inside_view({ tp1.x, tp1.y }, view_width, view_height) && is_inside_view({ tp2.x, tp2.y }, view_width, view_height))) return; | |
vec2 p = { tp1.x, tp1.y }; | |
vec2 dp = { tp2.x - tp1.x, tp2.y - tp1.y }; | |
dp = vec2_normalize(dp); | |
bool x_flipped_sign = false; | |
bool y_flipped_sign = false; | |
vec2 old_diff = { tp2.x - p.x, tp2.y - p.y }; | |
while (!(x_flipped_sign && y_flipped_sign)) { | |
vec2 new_p = vec2_add(p, dp); | |
vec2 diff = { tp2.x - new_p.x, tp2.y - new_p.y }; | |
if (!x_flipped_sign && !same_sign(diff.x, old_diff.x)) x_flipped_sign = true; | |
if (!y_flipped_sign && !same_sign(diff.y, old_diff.y)) y_flipped_sign = true; | |
old_diff = diff; | |
if (is_inside_view(p, view_width, view_height) && is_inside_view(new_p, view_width, view_height)) { | |
draw_line(p.x, view_height - p.y, new_p.x, view_height - new_p.y, color.x, color.y, color.z, color.w); | |
} | |
p = new_p; | |
} | |
// Debug draw the full line to see diff | |
//draw_line(tp1.x, view_height - tp1.y, tp2.x, view_height - tp2.y, 1, 0, 0, 1); | |
// Have to depth test entire line | |
// this requires subdividing the entire length and depth test all the segments | |
// and only draw the segments that are "visible" | |
// This would be "easier" to implement with triangles, that way we could interpolate across the face and | |
// get depth values for the whole thing and acutally get some pretty cool depth testing. | |
} | |
void project_line_old(mat4 mvp, vec3 p0, vec3 p1, float view_width, float view_height, vec4 color) { | |
vec4 tp1 = transform_point(mvp, p0); | |
vec4 tp2 = transform_point(mvp, p1); | |
tp1 = perspective_divide(tp1); | |
tp2 = perspective_divide(tp2); | |
#if 1 | |
// Basic curve effect | |
// More effective on smaller line segments | |
float cu = 0.01; | |
float rsq1 = tp1.x * tp1.x + tp1.y*tp1.y; | |
tp1.x -= tp1.x * (cu * rsq1); | |
tp1.y -= tp1.y * (cu * rsq1); | |
float rsq2 = tp2.x * tp2.x + tp2.y*tp2.y; | |
tp2.x -= tp2.x * (cu * rsq2); | |
tp2.y -= tp2.y * (cu * rsq2); | |
#endif | |
tp1 = world_to_screen(tp1, view_width, view_height); | |
tp2 = world_to_screen(tp2, view_width, view_height); | |
if ((tp1.x < 0 || tp1.x >= view_width) && (tp1.y < 0 || tp1.y >= view_height)) return; | |
if ((tp2.x < 0 || tp2.x >= view_width) && (tp2.y < 0 || tp2.y >= view_height)) return; | |
// Have to depth test entire line | |
// this requires subdividing the entire length and depth test all the segments | |
// and only draw the segments that are "visible" | |
//tp1 = viewclip_coord(tp1, view_width, view_height); | |
//tp2 = viewclip_coord(tp2, view_width, view_height); | |
draw_line(tp1.x, view_height - tp1.y, tp2.x, view_height - tp2.y, color.x, color.y, color.z, color.w); | |
} | |
void project_triangle(mat4 mvp, vec3 p0, vec3 p1, vec3 p2, float view_width, float view_height, vec4 color) { | |
vec4 tp0 = transform_point(mvp, p0); | |
vec4 tp1 = transform_point(mvp, p1); | |
vec4 tp2 = transform_point(mvp, p2); | |
tp0 = perspective_divide(tp0); | |
tp1 = perspective_divide(tp1); | |
tp2 = perspective_divide(tp2); | |
tp0 = world_to_screen(tp0, view_width, view_height); | |
tp1 = world_to_screen(tp1, view_width, view_height); | |
tp2 = world_to_screen(tp2, view_width, view_height); | |
if ((tp0.x < 0 || tp0.x >= view_width) && (tp0.y < 0 || tp0.y >= view_height)) return; | |
if ((tp1.x < 0 || tp1.x >= view_width) && (tp1.y < 0 || tp1.y >= view_height)) return; | |
if ((tp2.x < 0 || tp2.x >= view_width) && (tp2.y < 0 || tp2.y >= view_height)) return; | |
//tp0 = viewclip_coord(tp0, view_width, view_height); | |
//tp1 = viewclip_coord(tp1, view_width, view_height); | |
//tp2 = viewclip_coord(tp2, view_width, view_height); | |
vec4 top = tp0; | |
vec4 mid = tp1; | |
vec4 bottom = tp2; | |
// wind order culling | |
if ((vec2_cross(vec2{ bottom.x - top.x, bottom.y - top.y }, vec2{ mid.x - top.x, mid.y - top.y }) >= 0)) return; | |
draw_line(tp0.x, view_height - tp0.y, tp1.x, view_height - tp1.y, color.x, color.y, color.z, color.w); | |
draw_line(tp1.x, view_height - tp1.y, tp2.x, view_height - tp2.y, color.x, color.y, color.z, color.w); | |
draw_line(tp0.x, view_height - tp0.y, tp2.x, view_height - tp2.y, color.x, color.y, color.z, color.w); | |
} | |
float lerp(float t, float start, float end) { | |
return start + t * (end - start); | |
} | |
vec3 vec3_lerp(float t, vec3 p0, vec3 p1) { | |
return { | |
lerp(t, p0.x, p1.x), | |
lerp(t, p0.y, p1.y), | |
lerp(t, p0.z, p1.z), | |
}; | |
} | |
static vec3 cube[] = { | |
// back face | |
{-0.5f, -0.5f, -0.5f}, | |
{-0.5f, +0.5f, -0.5f}, | |
{+0.5f, +0.5f, -0.5f}, | |
{-0.5f, -0.5f, -0.5f}, | |
{+0.5f, +0.5f, -0.5f}, | |
{+0.5f, -0.5f, -0.5f}, | |
// front face | |
{-0.5f, +0.5f, +0.5f}, | |
{-0.5f, -0.5f, +0.5f}, | |
{+0.5f, +0.5f, +0.5f}, | |
{+0.5f, +0.5f, +0.5f}, | |
{-0.5f, -0.5f, +0.5f}, | |
{+0.5f, -0.5f, +0.5f}, | |
// left face | |
{-0.5f, -0.5f, -0.5f}, | |
{-0.5f, +0.5f, +0.5f}, | |
{-0.5f, +0.5f, -0.5f}, | |
{-0.5f, -0.5f, -0.5f}, | |
{-0.5f, -0.5f, +0.5f}, | |
{-0.5f, +0.5f, +0.5f}, | |
// right face | |
{+0.5f, +0.5f, +0.5f}, | |
{+0.5f, -0.5f, -0.5f}, | |
{+0.5f, +0.5f, -0.5f}, | |
{+0.5f, -0.5f, +0.5f}, | |
{+0.5f, -0.5f, -0.5f}, | |
{+0.5f, +0.5f, +0.5f}, | |
// bottom face | |
{-0.5f, -0.5f, -0.5f}, | |
{+0.5f, -0.5f, -0.5f}, | |
{+0.5f, -0.5f, +0.5f}, | |
{-0.5f, -0.5f, +0.5f}, | |
{-0.5f, -0.5f, -0.5f}, | |
{+0.5f, -0.5f, +0.5f}, | |
// top face | |
{+0.5f, +0.5f, -0.5f}, | |
{-0.5f, +0.5f, -0.5f}, | |
{+0.5f, +0.5f, +0.5f}, | |
{-0.5f, +0.5f, -0.5f}, | |
{-0.5f, +0.5f, +0.5f}, | |
{+0.5f, +0.5f, +0.5f}, | |
}; | |
static char hmn[9][20] = { | |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, }, | |
{ 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, }, | |
{ 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, }, | |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, | |
}; | |
static int hmn_width = 20; | |
static int hmn_height = 9; | |
mat4 projection; | |
mat4 view; | |
float rot; | |
vec3 camera_pos; | |
bool timed_recording = false; | |
float depth[1920 * 1080] = { 0.0f }; | |
void clear_depth_buffer() { | |
for (size_t i = 0; i < ARRAYSIZE(depth); i++) { | |
depth[i] = 0; | |
} | |
} | |
int camera_target_position = 0; | |
float camera_progress = 0.0f; | |
float camera_speed = 0.3f; | |
vec3 camera_steps[] = { | |
{10, 10, 0}, | |
{0, 10, 5}, | |
{0, 0, 10}, | |
{-5, 7, 5}, | |
{-10, 12, 0}, | |
{0, 0, 0} // Always same as first | |
}; | |
void update(int frame, double time, double delta, float width, float height, char key[256], bool recording) | |
{ | |
#if 1 | |
// Debug clipping with a reduced viewport | |
width /= 2; | |
height /= 2; | |
draw_line(0, height, width, height, 1, 0, 0, 1); | |
draw_line(width, 0, width, height, 1, 0, 0, 1); | |
#endif | |
if (frame == 0) { | |
set_background_color(0, 0, 0); | |
projection = perspective(75 * PI / 180, width / height, 0.001, 1000); | |
rot = 0; | |
camera_pos = camera_steps[camera_target_position]; | |
camera_target_position += 1; | |
view = lookat(camera_pos, { 0, 0, 0 }, { 0, 1, 0 }); | |
camera_steps[ARRAYSIZE(camera_steps) - 1] = camera_steps[0]; | |
//camera_pos = vec3{10, 10, 0}; | |
//view = lookat(camera_pos, { 0, 0, 0 }, { 0, 1, 0 }); | |
//start_recording(); timed_recording = true; | |
} | |
clear_depth_buffer(); | |
if (key[0x70] == 3) | |
{ | |
if (recording) | |
{ | |
stop_recording(); | |
} | |
else | |
{ | |
start_recording(); | |
} | |
} | |
if (timed_recording && recording && frame == 60 * 8.5) { | |
stop_recording(); | |
set_background_color(0.2, 0.2, 0.2); | |
} | |
if (recording) { | |
print_string((char*) "REC", 20, 20, 20, 1, 0, 0, 1); | |
} | |
rot += 0.5 * delta; | |
print_float(time, 4, 20, 50, 20, 1, 1, 1, 1); | |
#if 0 | |
// d7 flyby | |
static mat4 projection = perspective(50 * PI / 180, width / height, 0.001, 1000); | |
float radius = 70.0f; | |
camera_pos.x = math_cos(time) * radius; | |
camera_pos.y = 5; | |
camera_pos.z = math_sin(time) * radius; | |
vec3 poi = { camera_pos.x - camera_pos.z, camera_pos.y / 4, camera_pos.z + camera_pos.x }; | |
float scale = 0.9f; | |
poi.x *= scale; | |
poi.y *= scale; | |
poi.z *= scale; | |
camera_pos.x += 50; | |
camera_pos.z += 50; | |
poi.x += 50; | |
poi.y += 0; | |
poi.z += 10; | |
view = lookat(camera_pos, poi, { 0, 1, 0 }); | |
#else | |
view = lookat({ 0, 0, 6 + 4.0f*(float)math_sin(0.5*time) }, { 0, 0, 0 }, { 0, 1, 0 }); | |
if (0) { | |
camera_progress += delta * camera_speed; | |
if (camera_progress >= 1.0f) { | |
camera_target_position++; | |
if (camera_target_position >= ARRAYSIZE(camera_steps) - 1) camera_target_position = 0; | |
camera_progress = 0; | |
} | |
camera_pos = vec3_lerp(camera_progress, camera_steps[camera_target_position - 1], camera_steps[camera_target_position]); | |
view = lookat(camera_pos, { 0, 0, 0 }, { 0, 1, 0 }); | |
} | |
#endif | |
mat4 model = mat4_rotate({ 1, 0, 0 }, PI / 2); | |
#if 1 | |
for (int j = 0; j < hmn_height; ++j) | |
{ | |
for (int i = 0; i < hmn_width; ++i) | |
{ | |
if (hmn[j][i] == 1) | |
{ | |
auto get_block = [](int x, int y) -> int { | |
if (x < 0 || x >= hmn_width || y < 0 || y >= hmn_height) return 0; | |
return hmn[y][x]; | |
}; | |
bool top = get_block(i, j - 1); | |
bool bottom = get_block(i, j + 1); | |
bool left = get_block(i - 1, j); | |
bool right = get_block(i + 1, j); | |
vec3 back_bottom_left = { -0.5f, -0.5f, -0.5f }; | |
vec3 back_bottom_right = { 0.5f, -0.5f, -0.5f }; | |
vec3 back_top_left = { -0.5f, 0.5f, -0.5f }; | |
vec3 back_top_right = { 0.5f, 0.5f, -0.5f }; | |
vec3 front_bottom_left = { -0.5f, -0.5f, 0.5f }; | |
vec3 front_bottom_right = { 0.5f, -0.5f, 0.5f }; | |
vec3 front_top_left = { -0.5f, 0.5f, 0.5f }; | |
vec3 front_top_right = { 0.5f, 0.5f, 0.5f }; | |
mat4 mymodel = mat4_translate(vec3{ (float)i - (float)hmn_width / 2.0f, 0, (float)j - (float)hmn_height / 2.0f }); | |
mymodel = mat4_mul(model, mymodel); | |
mat4 mvp = mat4_mul(projection, mat4_mul(view, mymodel)); | |
vec4 line_color = { 0.2, 0.2, 1, 1 }; | |
//TODO: Handle lines on corners -- left as an exercise to the reader | |
// bottom line | |
if (!bottom) { | |
project_line(mvp, front_bottom_left, front_bottom_right, width, height, line_color); | |
project_line(mvp, front_top_left, front_top_right, width, height, line_color); | |
if (!left) { | |
project_line(mvp, front_bottom_left, front_top_left, width, height, line_color); | |
} | |
if (!right) { | |
project_line(mvp, front_bottom_right, front_top_right, width, height, line_color); | |
} | |
} | |
// top lines | |
if (!top) { | |
project_line(mvp, back_bottom_left, back_bottom_right, width, height, line_color); | |
project_line(mvp, back_top_left, back_top_right, width, height, line_color); | |
if (!left) { | |
project_line(mvp, back_bottom_left, back_top_left, width, height, line_color); | |
} | |
if (!right) { | |
project_line(mvp, back_bottom_right, back_top_right, width, height, line_color); | |
} | |
} | |
// left line | |
if (!left) { | |
project_line(mvp, back_top_left, front_top_left, width, height, line_color); | |
project_line(mvp, back_bottom_left, front_bottom_left, width, height, line_color); | |
} | |
// right line | |
if (!right) { | |
project_line(mvp, back_top_right, front_top_right, width, height, line_color); | |
project_line(mvp, back_bottom_right, front_bottom_right, width, height, line_color); | |
} | |
} | |
} | |
} | |
#endif | |
#if 0 | |
for (int j = 0; j < hmn_height; ++j) | |
{ | |
for (int i = 0; i < hmn_width; ++i) | |
{ | |
if (hmn[j][i] == 1) | |
{ | |
vec3 back_bottom_left = { -0.5f, -0.5f, -0.5f }; | |
vec3 back_bottom_right = { 0.5f, -0.5f, -0.5f }; | |
vec3 back_top_left = { -0.5f, 0.5f, -0.5f }; | |
vec3 back_top_right = { 0.5f, 0.5f, -0.5f }; | |
vec3 front_bottom_left = { -0.5f, -0.5f, 0.5f }; | |
vec3 front_bottom_right = { 0.5f, -0.5f, 0.5f }; | |
vec3 front_top_left = { -0.5f, 0.5f, 0.5f }; | |
vec3 front_top_right = { 0.5f, 0.5f, 0.5f }; | |
mat4 mymodel = mat4_translate(vec3{ (float)i - (float)hmn_width / 2.0f, 0, (float)j - (float)hmn_height / 2.0f }); | |
mymodel = mat4_mul(model, mymodel); | |
mat4 mvp = mat4_mul(projection, mat4_mul(view, mymodel)); | |
vec4 line_color = { 0.2, 0.2, 1, 1 }; | |
project_line(mvp, back_bottom_left, back_bottom_right, width, height, line_color); | |
project_line(mvp, back_top_left, back_top_right, width, height, line_color); | |
project_line(mvp, back_top_left, back_bottom_left, width, height, line_color); | |
project_line(mvp, back_top_right, back_bottom_right, width, height, line_color); | |
project_line(mvp, front_bottom_left, front_bottom_right, width, height, line_color); | |
project_line(mvp, front_top_left, front_top_right, width, height, line_color); | |
project_line(mvp, front_top_left, front_bottom_left, width, height, line_color); | |
project_line(mvp, front_top_right, front_bottom_right, width, height, line_color); | |
project_line(mvp, back_bottom_left, front_bottom_left, width, height, line_color); | |
project_line(mvp, back_bottom_right, front_bottom_right, width, height, line_color); | |
project_line(mvp, back_top_left, front_top_left, width, height, line_color); | |
project_line(mvp, back_top_right, front_top_right, width, height, line_color); | |
} | |
} | |
} | |
#endif | |
#if 0 | |
for (int j = 0; j < hmn_height; ++j) | |
{ | |
for (int i = 0; i < hmn_width; ++i) | |
{ | |
if (hmn[j][i] == 1) | |
{ | |
mat4 mymodel = mat4_translate(vec3{ (float)i - (float)hmn_width / 2.0f, 0, (float)j - (float)hmn_height / 2.0f }); | |
mymodel = mat4_mul(model, mymodel); | |
for (int v = 0; v < ARRAYSIZE(cube); v += 3) { | |
project_triangle( | |
mat4_mul(projection, mat4_mul(view, mymodel)), | |
cube[v + 0], | |
cube[v + 1], | |
cube[v + 2], | |
width, height, { 1, 1, 1, 1 }); | |
} | |
} | |
} | |
} | |
#endif | |
#if 0 | |
for (int i = 0; i < ARRAYSIZE(indices); i += 2) { | |
vec3 p1 = vertices[indices[i + 0]]; | |
vec3 p2 = vertices[indices[i + 1]]; | |
// subdivide line | |
vec3 d = vec3_subtract(p2, p1); | |
int subdivides = 100; | |
d = vec3_div_float(d, subdivides); | |
vec3 p = p1; | |
for (int i = 0; i < subdivides; i++) { | |
vec3 next_p = vec3_add(p, d); | |
project_line(mat4_mul(projection, view), p, next_p, width, height, { 1, 1, 1, 1 }); | |
p = next_p; | |
} | |
//project_line(mat4_mul(projection, view), p1, p2, width, height, { 0.2, 0.2, 1, 1 }); | |
} | |
#endif | |
/* | |
mvp = mat4_mul(projection, view); | |
project_triangle( | |
mvp, | |
{-0.5f, -0.5f, 0}, | |
{ 0.0f, 0.5f, 0}, | |
{ 0.5f, -0.5f, 0}, | |
width, height, | |
{1, 0, 1, 1} | |
);*/ | |
} | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
#pragma section(".payload", execute) | |
__declspec(allocate(".payload")) volatile unsigned long long payload[] = | |
{ | |
0xd7d7d7d7d7d7d7d7, 0x57565508245c8948, 0x5741564155415441, 0x048b486520ec8348, 0x358d4c0000006025, 0x1dbe0f44000019f4, 0x48e98b4c000019ec, 0x4820428b4818508b, 0x588b48028b48108b, 0x188c8b443c438b20, 0x19548b4100000088, 0x8bd23345d3034820, 0x0ffb0348f68b493a, 0x451b75d83b4407b6, 0xc08445fe2b49c38a, 0xbe0f44c6ff481974, | |
0xc13b44370cb60f06, 0xc28348c2ff41eb74, 0x2419448b41cceb04, 0xc303481c19548b41, 0xb70fd30348ca6349, 0x248b44cb8b48483c, 0x00001977158d48ba, 0x8d48d4ff41e3034c, 0xcb8b480000197915, 0x8d48d4ff41f88b48, 0xcb8b480000197615, 0x40bbd4ff41f08b48, 0x7024448948000000, 0x44ffffff192d8d48, 0x4c8d4ccd8b48c38b, 0x4c00001c9cba6824, | |
0xbacb8b44d7fff08b, 0xb841c933000020b0, 0x8b48d6ff00003000, 0x8b4800001c9cb9f8, 0x48f8458948a4f3f5, 0x0fe0ff0000012705, 0x8d480000192205b6, 0x74c0840000191c35, 0x3eb60fe88bdb3354, 0xff41ce8b48c6ff48, 0x0ff88b4cf70348d6, 0x74c984c6ff480eb6, 0x493eb60ff18b442e, 0xd68b48c6ff48cf8b, 0x1b2e0d8d48d4ff41, 0x048948f703480000, | |
0x01ee8349c3ff48d9, 0x487024748b4cda75, 0xcd8b49b07501ed83, 0xc4834860245c8b48, 0x415d415e415f4120, 0x000000e95d5e5f5c, 0x565508245c894800, 0x4156415541544157, 0xfffc2024ac8d4857, 0x000004e0ec8148ff, 0xc024bc290fe18b4c, 0x0004bac933000004, 0x00001ac015ff0000, 0x13e6158d48ff3345, 0x058d4ccf8b450000, 0x66c78b4100001b6c, | |
0x89450b75ff3a8090, 0x488d4404c0834908, 0x9a3dc2ff48c0ff01, 0xbf0f4ce472000001, 0x1d8d48000015531d, 0x48db034c0000154c, 0x8d480000161e3d8d, 0xdf3b4c00001c3b15, 0xff4903b60f456673, 0x44087380f88041c3, 0x4a4cebc2ff480288, 0xffffff04438cbf0f, 0xffff024394bf0f4e, 0x4cd3034ccb0348ff, 0xc78b4dca2b4dc98b, 0x4dcf470f4dd13b4c, | |
0x66d22b4c1f74c985, 0x00000000841f0f66, 0xff491204b60f4100, 0x3b4dc2ff480288c0, 0x9a72df3b4cee72c1, 0x0001f085c7c0570f, 0x48c0330000005000, 0x89480000159a1d8d, 0x8d8d480000023485, 0x023c8589000001f0, 0x000c97058d480000, 0x000001f485110f00, 0x0f000001f8858948, 0x8948000002248511, 0x85110f000002309d, 0x1485110f00000204, | |
0x0019b715ff000002, 0xb94158247c894c00, 0x247c894c91000000, 0x247c894cc38b4c50, 0x247c894cd38b4848, 0x00382444c7c93340, 0x00302444c7800000, 0x00282444c7800000, 0x00202444c7800000, 0x00197715ff800000, 0xc700000020b94100, 0x00b0000000043085, 0x48c03345d88b4800, 0xc933000000a8858d, 0x858d484824448948, 0x247c894c000000a0, | |
0x448948e1518d4140, 0x000430858d483824, 0x000007302444c700, 0x000001282444c700, 0xb1e8202444894800, 0x00a08d8b48000018, 0x486824448d4c0000, 0x8b48000014ba158d, 0x00a88d8b4810ff01, 0x486024448d4c0000, 0x8b48000014b2158d, 0x68244c8b4810ff01, 0x48000000e0858d4c, 0x8b48000014aa158d, 0x00e08d8b4810ff01, 0x8b4848558d480000, | |
0x484d8b483850ff01, 0x95158d4850458d4c, 0x50ff018b48000014, 0x558d48504d8b4830, 0x570f3024548948b8, 0x00000140bd894cc0, 0x570000014885c748, 0x015085c748000000, 0x0ff3000000010000, 0x85c700000160857f, 0x0000002000000158, 0x00020000015c85c7, 0x7c894c018b480000, 0x4820247c894c2824, 0x408d8d4c6824548b, 0x50ffc38b4c000001, | |
0x4d8d4cb84d8b4878, 0x00001428058d4cc8, 0x4850ff018b48d233, 0x4d8d4c68244c8b48, 0xc03345c8558b48e0, 0x8b484850ff018b48, 0x8b4800558d48c84d, 0x247c894c5050ff01, 0x44894890458d4850, 0x0019a70d8d484824, 0x8d4840247c894400, 0x7c8944000013eb05, 0x448948c933453824, 0x058d48c033453024, 0x0000fdba000013dc, 0x894c282444894800, | |
0x0000175ae820247c, 0x4d8b486824448b48, 0xff018b48388b4890, 0x8b48904d8b482050, 0x481852ff118b48d8, 0x48c9334568244c8b, 0x458d48c38b4cd08b, 0x57ff202444894870, 0x058d48904d8b4860, 0xf085894800001388, 0x137e058d48000000, 0x0001108589480000, 0x89446824448b4800, 0x85c748000000f8bd, 0x00000010000000fc, 0x4400000104bd894c, | |
0x89440000010cbd89, 0x85c74800000118bd, 0x000000020000011c, 0xffff0000012485c7, 0x000128bd894cffff, 0xff018b48388b4800, 0x8b48904d8b482050, 0x481852ff118b48d8, 0xf0958d4868244c8b, 0xb841c88b4c000000, 0x68458d4800000002, 0x5c89482824448948, 0x7c894c5857ff2024, 0x3345d0458d485024, 0x8d484824448948c9, 0x7c89440000187b0d, | |
0x0012d3058d484024, 0x334538247c894400, 0xfdba3024448948c0, 0x12c2058d48000000, 0x4c28244489480000, 0x001631e820247c89, 0x8b486824448b4800, 0x018b48388b48d04d, 0x48d04d8b482050ff, 0x1852ff118b48d88b, 0xc9334568244c8b48, 0x8d48c38b4cd08b48, 0x4489480000008885, 0x4c8b487857ff2024, 0x000080858d4c6824, 0x88bd894cc0570f00, | |
0x78857f0ff3000001, 0x0190bd8944000001, 0x000170958d480000, 0x0000019485c74800, 0x017085c700000001, 0x85c7000000030000, 0x0000000100000174, 0x00017090ff018b48, 0x02708d8d48d23300, 0x00000148b8410000, 0x4c8b4800000939e8, 0x000090858d4c6824, 0x0011ff056f0f6600, 0x00000270958d4800, 0x00010000027885c7, 0x0280857f0ff30000, | |
0x0000029085c70000, 0x029485c700000001, 0x85c6000000010000, 0x018b480f0000029c, 0x458b0000016890ff, 0x0d100ff3c0570f00, 0x244c8b48000011c4, 0x000000bcbd894c68, 0x04458bc02a0f48f3, 0xc7000000c4bd8944, 0x000010000000b085, 0x01000000b485c700, 0x0000b885c7000000, 0x5e0ff30000000400, 0x2a0f48f3c0570fc8, 0x858948d8458d48c0, | |
0x8948c03300000130, 0x580ff30000013885, 0x0ff3d84d110ff3c9, 0x0ff30000115e0d10, 0x48dc4d110ff3c85e, 0x8d4c784d8d4c018b, 0x958d480000013085, 0x481850ff000000b0, 0xb04d8d4c68244c8b, 0x48000000d8bd894c, 0x85c7000000c8958d, 0x000c0000000000c8, 0x0000cc85c7c03345, 0xd085c70000000200, 0xc700000001000000, 0x010000000000d485, | |
0x0f1850ff018b4800, 0x8d4c28458b004510, 0x8b48104d100fc04d, 0x01a0958d4868244c, 0x0001a085110f0000, 0x01c88589c0334500, 0xf22045100ff20000, 0x0f000001c085110f, 0xc748000001b08d11, 0x000003000001bc85, 0x00000001c485c700, 0x50ff018b48000200, 0x0000109805100f28, 0x0d100fd233007d8b, 0x046d8b440000109c, 0x85110f00020070b9, | |
0x0fa07d89000001d0, 0xd5e8000001e08d11, 0xe8804d8d48000013, 0x804d8b48000013d2, 0x4800001079058d4c, 0x8b4800001082158d, 0x48000000c090ff01, 0x01e0858d4c804d8b, 0x001077158d480000, 0x00c090ff018b4800, 0x8d48804d8b480000, 0x02b8410000107315, 0x90ff018b48000000, 0x804d8b48000000a8, 0x8b00001069158d48, 0xdd0b4920e3c148df, | |
0x90ffc38b4c018b48, 0x804d8b48000000b0, 0x4900001059158d48, 0x00003c00000001be, 0xff018b48c68b4d00, 0x4d8b48000000b090, 0x00001048158d4880, 0x000100000001be48, 0x018b48c68b4c0000, 0x8d48000000b090ff, 0x00001316e870244c, 0x018b4870244c8b48, 0x4800000fb9058d4c, 0x90ff00000fc2158d, 0x244c8b48000000c0, 0x000001d0858d4c70, | |
0x4800000fb9158d48, 0x000000c090ff018b, 0x158d4870244c8b48, 0xd400b84100000ff4, 0xa890ff018b480030, 0x70244c8b48000000, 0x4100000f99158d48, 0x018b4800000002b8, 0x8b48000000a890ff, 0x0f8e158d4870244c, 0x018b48c38b4c0000, 0x8b48000000b090ff, 0x0f86158d4870244c, 0x018b48c68b4d0000, 0x8b48000000b090ff, 0x0f7e158d4870244c, | |
0x018b48c68b4c0000, 0x8d48000000b090ff, 0xfd15fff63245604d, 0xffa84d8d48000012, 0xa84d8b000012fb15, 0x0ff2000012fa15ff, 0x8d4800000428bd10, 0xb4290f0000168b1d, 0x401f0f000004d024, 0x00000000841f0f00, 0x202444c7c9334500, 0x48c0334500000001, 0xd233000002408d8d, 0xc0850000126215ff, 0x00000248bd833b74, 0x48000004c4840f12, | |
0x15ff000002408d8d, 0xc7c933450000124c, 0x4500000001202444, 0x0002408d8d48c033, 0x00122715ffd23300, 0x1f05f6c575c08500, 0x046e850f01000015, 0x4860244c8b480000, 0x2824548948f0558d, 0x3345b0558b48f633, 0x018b4820247489c0, 0x487050ff044e8d44, 0x48584d8d48f0458b, 0x35890000137a0589, 0x122615ff0000137c, 0x854558458b480000, | |
0x48f6570fc88b48ff, 0xf2c0570fa84d450f, 0xc12b4860452a0f48, 0x2a0f48f2a84d8948, 0xff8545f05e0ff2f0, 0x04458bfe280f0375, 0x8844db570fc0570f, 0x280fd6280f302474, 0xcf8b41d75c0ff2ce, 0x00458bc02a0f48f3, 0x058d48d82a0f48f3, 0x244489480000145c, 0x41202444110ff328, 0x4560244c8b48d4ff, 0xff41b0558b48c033, 0xff018b48fe280fc7, | |
0x058d4c00458b7850, 0x244c8b48000013ec, 0xe0558b48c0570f60, 0x0018a445c7c9570f, 0x8bc02a0f48f30000, 0x00000438b5890445, 0xf340758930758948, 0x004445c7c82a0f48, 0x3845110ff33f8000, 0x018b483c4d110ff3, 0x8b480000019090ff, 0x00000002ba60244c, 0x0000c090ff018b48, 0x8b4860244c8b4800, 0x8890ff018b486855, 0x60244c8b48000000, | |
0x4800000438958d48, 0xb04d8d4c28245489, 0x24548948a4558d48, 0x8d44018b48d23320, 0x0000009090ff0142, 0xc9334560244c8b48, 0x48c0334570558b48, 0x4c8b485850ff018b, 0xd233784d8d4c6024, 0xff01428d44018b48, 0x4c60244c8b483850, 0x00000001ba30458d, 0x00016090ff018b48, 0x8b4860244c8b4800, 0x018b480000008095, 0x8b480000015890ff, | |
0x8b48018b4860244c, 0xc933450000008895, 0x8b484850ffc03345, 0x45e0458d4c60244c, 0x518d41018b48c933, 0x480000010890ff01, 0xffffb94160244c8b, 0x000090958b48ffff, 0xff018b48c0334500, 0x4c8b480000011890, 0x95158bc033456024, 0x50ff018b48000011, 0xc03345b84d8b4868, 0xff01508d41018b48, 0x00117b3538404050, 0x5c75f68445587400, | |
0xc0334578244c8d4c, 0x000c8f0d8d48d233, 0x8b4800000f70e800, 0x0428858d4c78244c, 0x487024548b480000, 0x4c8b481850ff018b, 0x458b4cc933457824, 0x4800000428958b80, 0x4c8b482050ff018b, 0x2850ff018b487824, 0x840ff6844501b641, 0x123538400000015b, 0x4c8b481e74000011, 0x5850ff018b487824, 0x018b4878244c8b48, 0x34e9f632451050ff, | |
0x4cb84d8b48000001, 0x8d4c000000988d8d, 0x48d23300000b2305, 0x4c8b484850ff018b, 0x000098858b4c6024, 0x018b48c0558b4800, 0x8b480000017890ff, 0x48f0558d4860244c, 0x0001b94128245489, 0x3345c0558b480000, 0x018b4820247489c0, 0x8df05d8b487050ff, 0x894800000000bd3c, 0x894888558d489875, 0xf5af0f41f78b8875, 0x00000000e845c748, | |
0x4800000e6de8ce8b, 0x45e8558d48884d8b, 0x018b48c03345c933, 0x45f84d8b441850ff, 0xf845af0f44ff458d, 0x8be84d8b48d9f741, 0x7c8928246c8944d7, 0x0e38e8c3034c2024, 0x8b48884d8b480000, 0x884d8b482050ff01, 0x3050ff018b48d68b, 0x000e1fe8984d8d48, 0x558b48984d8b4800, 0x015090ff018b4888, 0x4c78244c8b480000, 0x000428958b98458b, | |
0x483050ff018b4800, 0x50ff018b48984d8b, 0x018b48884d8b4810, 0x60244c8b481050ff, 0x48c0558b48c03345, 0xa07d8b7850ff018b, 0x66000012111d8d48, 0x4800000af9156f0f, 0x05c600001102058d, 0xa105c60000000fa7, 0x406f0ff30000000f, 0xdb0f66ca6f0f66f0, 0x0ff3f0487f0ff3c8, 0x0f66ca6f0f66006f, 0x0ff3087f0ff3c8db, 0x66ca6f0f6610406f, | |
0x10487f0ff3c8db0f, 0x6f0f6620406f0ff3, 0x7f0ff3c8db0f66ca, 0x3b4840c083482048, 0xfffffb29e9b17cc3, 0x4c8b481674f68445, 0x5850ff018b487824, 0x018b4878244c8b48, 0xd024b4280f1050ff, 0x9c8b48c033000004, 0xbc280f0000052024, 0xc48148000004c024, 0x5e415f41000004e0, 0xc35d5e5f5c415d41, 0x0101fa8128ec8348, 0xfa837a7463770000, | |
0x657606fa834d7402, 0x00fa81257608fa83, 0xba0f495875000001, 0xc0b60f410f721ee1, 0xc6000010110d8d48, 0xc48348c033030804, 0x4800000002bac328, 0xb84100000ffa0d8d, 0x000045e800000100, 0xc328c48348c03300, 0x00000cd815ffc933, 0x8bc328c48348c033, 0xad74000001042dc2, 0xc483480b7401f883, 0x00000cc025ff4828, 0xb50d8d48c0b60f41, | |
0x33020804c600000f, 0x8948c328c48348c0, 0xb60fc98b4c08247c, 0x0101010101bf48c2, 0x0f48c88b49010101, 0x8b4903e9c148c7af, 0x0fc88b49ab48f3f9, 0xe183f8e08349c2b6, 0x48aaf3013c8d4b07, 0xc3c18b4908247c8b, 0x00000f2005110ff3, 0x00000f1c0d110ff3, 0x00000f1815110ff3, 0x00000e00056348c3, 0x003dea280fe3280f, 0x00008a8d0f000080, | |
0x4828245c100ff300, 0x0dd6058b48400c8d, 0x302454100ff30000, 0x100ff3c804110ff3, 0xc84c110ff3402444, 0xf338244c100ff304, 0x110ff308c85c110f, 0xc84c110ff30cc854, 0x8b14c844110ff310, 0x89c0ff00000da305, 0x48984800000d9b05, 0x0d86058b48400c8d, 0xf3c82c110ff30000, 0x110ff304c864110f, 0xc854110ff308c85c, 0xf310c84c110ff30c, | |
0x6505ff14c844110f, 0x000b7be9c300000d, 0x7de900000b7ce900, 0x00000b7ee900000b, 0x25ff48c3c0510ff2, 0x48ec834800000c04, 0x280fea280f11b60f, 0x000230840fd284e1, 0x00087f15100ff300, 0x1d8b50245c894800, 0x2474894800000d1c, 0xffffeea8358d4858, 0x798d4840247c8948, 0x0ff3302474290f01, 0x0f0000008824b410, 0xbc100ff320247c29, | |
0x290f440000008024, 0x44100f44f3102444, 0xf3240c290f447824, 0x1f0f70244c100f44, 0x00841f0f66660040, 0x80cab60f00000000, 0xe0418d19fa8061ea, 0xc1470f44c0b60f44, 0x870f3e3cdf408d41, 0xc0be0f490000016f, 0x4c000015d18e8d4c, 0x6348000015d0968d, 0x034c00001ce0868c, 0x19b60f45d1034cc9, 0xfffb804102b60f41, 0x80410000013d840f, | |
0x49c2ff490b75fefb, 0x8100000112e9c1ff, 0x068d0f00008000fb, 0xb8c0be0f44000001, 0xd1e8f74166666667, 0xd0031fe8c1c28bfa, 0x44ca6e0f6692048d, 0xc95b0fc36348c02b, 0x1d058b48400c8d48, 0xc06e0f416600000c, 0xf3c3be0f45c05b0f, 0xf3c2590ff3ca590f, 0xf3c3590ff3cb590f, 0xf3c4580ff3cd580f, 0x4c110ff3c804110f, 0xc84c110f44f304c8, | |
0x0cc844110f44f308, 0x0ff310c87c110ff3, 0x666667b814c87411, 0x4100000bd10d8b66, 0x0bc60d89c1ffe8f7, 0xe8c1c28bfad10000, 0x0f6692048dd0031f, 0xc16348c02b44ca6e, 0x48400c8d48c95b0f, 0x416600000b9a058b, 0x0ff3c05b0fc06e0f, 0x0ff3c2590ff3ca59, 0x0ff3c3590ff3cb59, 0x0ff3c4580ff3cd58, 0xc84c110ff3c80411, 0x08c84c110f44f304, | |
0xf30cc844110f44f3, 0x110ff310c87c110f, 0x000b571d8b14c874, 0x000b4f1d89c3ff00, 0xff490159b60f4500, 0xff490142b60f41c1, 0xc3850ffffb8041c2, 0x0ff317b60ffffffe, 0x0fd284c7ff48e358, 0x280f44fffffe5f85, 0x102444280f44240c, 0x74280f20247c280f, 0x4840247c8b483024, 0x245c8b485824748b, 0x48c48348c4280f50, 0x0c260d8d4cc18bc3, | |
0x8b44e1280f990000, 0x44c23344d18b44c0, 0x000000801f0fc22b, 0x666667b8c9ff4900, 0x8b02fac1e8f74166, 0xb60fd0031fe8c1c2, 0x02100c8d02e0c0c2, 0x30c08041c12a44c9, 0xd285c28b44018845, 0x490779d28545cf75, 0x8b492d01c641c9ff, 0xfffd4be9cc280fc9, 0xb860ec83485340ff, 0x2474290f00000006, 0x40247c290fd03b50, 0x0ba60d8d4cc8280f, | |
0x0005cf0d540f0000, 0x0fe4570fd04f0f00, 0xe8280ffa280ff328, 0x83ff428de15a0ff3, 0xdd058d4c507705f8, 0x8c8b419848ffffeb, 0xc803490000159180, 0x05a625590ff2e1ff, 0x25590ff230eb0000, 0x0ff226eb000005a4, 0x1ceb000005a22559, 0x000005a025590ff2, 0x059e25590ff212eb, 0x25590ff208eb0000, 0x6667bb480000059c, 0x0ff2666666666666, | |
0x4cf2000005922558, 0xd285c38b4ddc2c0f, 0x66d28b44427e4f74, 0x00000000841f0f66, 0x49c38b48c9ff4900, 0x8b4802fac148e8f7, 0xd003483fe8c148c2, 0x0c8d02e0c0c2b60f, 0x8041c12a44c90210, 0xc28b4c01884530c0, 0xff49cb7501ea8349, 0x401f0f2e01c641c9, 0x49c38b48c9ff4900, 0x8b4802fac148e8f7, 0xd003483fe8c148c2, 0x0c8d02e0c0c2b60f, | |
0x8041c12a44c90210, 0xc28b4c01884530c0, 0xc0570fcc75d28548, 0xdb854d0c73e82f0f, 0x01c641c9ff490774, 0x00a8248c100ff32d, 0x100ff3d6280f0000, 0x8b49000000b02484, 0x0090249c100ff3c9, 0xa82484110ff30000, 0x2484100ff3000000, 0x8c110ff3000000a0, 0x100ff3000000a024, 0x0ff300000098248c, 0xf300000098248411, 0x00000090248c110f, | |
0x502474280fcf280f, 0xc4834840247c280f, 0x66fffffb95e95b60, 0x00143c0000143290, 0x0014500000144600, 0x0014640000145a00, 0x01000008bc05c600, 0xc300000008b605c6, 0xc600000008ad05c6, 0x00c301000008a705, 0x0000000000000000, 0x01ff201bfe1602ff, 0xfe1f01ff0d03fe0b, 0x1814fe0e0afe2103, 0x130f0509fe2002ff, 0x0a00fe1e04ff191d, | |
0x18222016fe00020c, 0x190509fe2002ff16, 0xff0c02ff120ffe1d, 0x170d01ff21150b03, 0xfe130ffe1b07ff1f, 0x130fff1909fe1d05, 0xff1f1b16ff1b07fe, 0x1e04ff201bff130f, 0x02ff0004221e00ff, 0x221e0f130400ff20, 0x130ffe1e220400ff, 0xff130f00fe2204ff, 0x00ff1e22130f0004, 0x220400ff0f13221e, 0x0ffe0004221e00ff, 0xff130f000422ff13, | |
0x0c07ff1b16fe0c07, 0x220f04ff1f1b16fe, 0x00ff1814fe0e0aff, 0x1611130400ff1e13, 0x04001e22ff201bfe, 0x020a1eff0e0b1518, 0x0400ff1814fe220e, 0x0ffe001e2218120e, 0x00ff221e0004ff12, 0x04ff001e20180e02, 0x04ff120ffe221e00, 0x040eff120ffe1e00, 0x1e00ff1618221e00, 0x02ff2204fe130ffe, 0xff221efe0400fe20, 0xfe1e00ff14202204, | |
0xff221e00ff220f04, 0x001eff22040c001e, 0x0004221e00ff0422, 0x00ff0f1304001eff, 0x2216fe000418201e, 0xff220f1304001eff, 0x02ff1e22130f0004, 0x221e00ff0400fe20, 0x1e00ff042000ff04, 0x04fe2200ff042216, 0x040c00fe200cff1e, 0x0103ff221e0400ff, 0x0301ff2200ff211f, 0x1eff0e020aff1f21, 0x000000000000ff22, 0x001c0015000e002d, | |
0x6c66002d002a0023, 0x746572203474616f, 0x75727473206e7275, 0x74616f6c66207463, 0x7562635f56532032, 0x723a6b2072656666, 0x2872657473696765, 0x7d3b66837b293062, 0x4f503a65837b6782, 0x4c4f433a62803b53, 0x65807b64823b7d3b, 0x495449534f50843a, 0x4f433a62803b4e4f, 0x286a20643b7d3b4c, 0x6320647b29612067, 0x6f6c663d652e633b, | |
0x2e652e6128347461, 0x6f6c662d662a7978, 0x312d2c3128327461, 0x633b29312c302c29, 0x813b622e613d622e, 0x20642868807d3b63, 0x47524154843a2961, 0x3b622e61817b5445, 0x50843a292869807d, 0x7b4e4f495449534f, 0x000000007d3b3081, 0x68207972616e6962, 0x7270207265646165, 0x6320666f20666f6f, 0x0000747065636e6f, 0x43d608efa04bfb29, | |
0x86e6cbbdbda99ca4, 0x4082b5fbbb2c6faa, 0xe190fa8c8b386b8e, 0x48ba627677db970f, 0x2c39b443010728ba, 0x4c48e07250c83a1c, 0xd0a636fa3036b087, 0x4e89d2086f15aaf2, 0x9c4fd3359548b49a, 0x0000305f355f7376, 0x00534f500000006a, 0x355f7370004c4f43, 0x000000680000305f, 0x0000000600000005, 0x0000000100000001, 0xc00000003f800000, | |
0x0010000034363248, 0x719b3800aa000080, 0x0010000000000015, 0x719b3800aa000080, 0x0010000073646976, 0x719b3800aa000080, 0x4687f8c948eba18e, 0x8f6af9c9740a11bf, 0x471442e8f7e34c9a, 0xe5352cd729cb4bb7, 0x4806e676e2724bb8, 0xcd4cb4efd6a8b2b4, 0x4012d6b21652c33d, 0x7da34908037234b8, 0x4e443d2cc459a2e8, 0xb07b6c15e5fe32b1, | |
0x40278d0ac6376a1e, 0xb69bd30a9a6d45be, 0x4d9efb0d20332624, 0x2e106c78f6cb0dbd, 0x007000740075006f, 0x006d002e00740075, 0x0000000000340070, 0x0101010101010101, 0x0101010101010101, 0x000000003e2aaaab, 0x0000000000000000, 0x7fffffff7fffffff, 0x7fffffff7fffffff, 0x4024000000000000, 0x4059000000000000, 0x408f400000000000, | |
0x40c3880000000000, 0x40f86a0000000000, 0x412e848000000000, 0x3fe0000000000000, 0x41636f7250746547, 0x5600737365726464, 0x72506c6175747269, 0x695600746365746f, 0x6c6c416c61757472, 0x4c64616f4c00636f, 0x0041797261726269, 0x2e3233656c6f0a09, 0x6f430f01006c6c64, 0x696c616974696e49, 0x53550b007845657a, 0x6c6c642e32335245, | |
0x5174736f50100600, 0x617373654d746975, 0x576665440f006567, 0x6f7250776f646e69, 0x6967655211004163, 0x73616c4372657473, 0x7243100041784573, 0x646e695765746165, 0x500d00417845776f, 0x617373654d6b6565, 0x7369441100416567, 0x73654d6863746170, 0x640a004165676173, 0x6c6c642e31316433, 0x3131443344120100, 0x6544657461657243, | |
0x3344130065636976, 0x454c49504d4f4344, 0x6c6c642e37345f52, 0x6f434433440b0100, 0x4d0b00656c69706d, 0x4c442e74616c5046, 0x7453464d0a05004c, 0x4d12007075747261, 0x4d65746165724346, 0x6570795461696465, 0x61657243464d1500, 0x79726f6d654d6574, 0x0c00726566667542, 0x6d4979706f43464d, 0x43464d0f00656761, 0x6d61536574616572, | |
0x52454b0d00656c70, 0x6c642e32334c454e, 0x726575511a02006c, 0x6d726f6672655079, 0x7165724665636e61, 0x51180079636e6575, 0x6672655079726575, 0x4365636e616d726f, 0x22007265746e756f, 0x772d736d2d697061, 0x752d7472632d6e69, 0x6c2d7974696c6974, 0x6c642e302d312d31, 0x6e6172730602006c, 0x00646e6172050064, 0x5764616552464d10, | |
0x6c6c642e65746972, 0x657243464d1a0100, 0x576b6e6953657461, 0x6f72467265746972, 0x70611f004c52556d, 0x6e69772d736d2d69, 0x74616d2d7472632d, 0x302d312d316c2d68, 0x630404006c6c642e, 0x006e69730400736f, 0x0400326e61746106, 0x007e25ff00776f70, 0x0000008025ff0000, 0x25ff0000008225ff, 0x008625ff00000084, 0x0000008825ff0000, | |
0x25ff0000008a25ff, 0x00ae25ff000000ac, 0x000000b025ff0000, 0x25ff000000b225ff, 0x00000000000000b4, | |
}; | |
#ifndef _WINDOWS_ | |
typedef struct HINSTANCE__ { int unused; } HINSTANCE__; | |
#endif | |
int __stdcall WinMain(HINSTANCE__* hInstance, HINSTANCE__* hPrevInstance, char* lpCmdLine, int nShowCmd) { return ((int(*)(void*))(payload + 1))(update); } | |
void set_background_color(float r, float g, float b) { ((void(*)(float, float, float))(*payload + 0x1048))(r, g, b); } | |
void draw_line(float x0, float y0, float x1, float y1, float r, float g, float b, float a) { ((void(*)(float, float, float, float, float, float, float, float))(*payload + 0x1061))(x0, y0, x1, y1, r, g, b, a); } | |
double math_cos(double x) { return ((double(*)(double))(*payload + 0x1104))(x); } | |
double math_sin(double x) { return ((double(*)(double))(*payload + 0x1109))(x); } | |
double math_atan2(double x, double y) { return ((double(*)(double, double))(*payload + 0x110e))(x, y); } | |
double math_pow(double x, double y) { return ((double(*)(double, double))(*payload + 0x1113))(x, y); } | |
double math_sqrt(double x) { return ((double(*)(double))(*payload + 0x1118))(x); } | |
int math_rand() { return ((int(*)())(*payload + 0x111d))(); } | |
float print_string(char* text, float x, float y, float size, float r, float g, float b, float a) { return ((float(*)(char*, float, float, float, float, float, float, float))(*payload + 0x1124))(text, x, y, size, r, g, b, a); } | |
float print_int(int number, float x, float y, float size, float r, float g, float b, float a) { return ((float(*)(int, float, float, float, float, float, float, float))(*payload + 0x1371))(number, x, y, size, r, g, b, a); } | |
float print_float(float number, int decimals, float x, float y, float size, float r, float g, float b, float a) { return ((float(*)(float, int, float, float, float, float, float, float, float))(*payload + 0x13d9))(number, decimals, x, y, size, r, g, b, a); } | |
void start_recording() { ((void(*)())(*payload + 0x15a9))(); } | |
void stop_recording() { ((void(*)())(*payload + 0x15b8))(); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment