mirror of
https://github.com/exoticorn/microw8.git
synced 2026-01-20 19:26:43 +01:00
enable nontrapping fptoint feature in c and zig example
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user