enable nontrapping fptoint feature in c and zig example

This commit is contained in:
2022-01-02 16:06:01 +01:00
parent d239775411
commit acea5cb6e0
3 changed files with 7 additions and 7 deletions

View File

@@ -3,10 +3,6 @@
IMPORT("env", "atan2") extern float atan2(float, float);
IMPORT("env", "time") extern float time();
int ftoi(float v) {
return __builtin_wasm_trunc_s_i32_f32(v);
}
float sqrt(float v) {
return __builtin_sqrt(v);
}
@@ -22,7 +18,7 @@ void upd() {
float y = (float)(i / 320 - 120);
float d = 40000.0f / sqrt(x * x + y * y + 1.0f);
float u = atan2(x, y) * 512.0f / 3.141f;
unsigned char c = (unsigned char)(ftoi(d + t * 2.0f) ^ ftoi(u + t)) >> 4;
unsigned char c = (unsigned char)((int)(d + t * 2.0f) ^ (int)(u + t)) >> 4;
FRAMEBUFFER[i] = c;
i += 1;