mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-06 06:53:39 +00:00
uvm32 initial version
This commit is contained in:
commit
c9d30b6d28
34 changed files with 2088 additions and 0 deletions
40
apps/zig-mandel/src/main.zig
Normal file
40
apps/zig-mandel/src/main.zig
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const uvm = @import("uvm.zig");
|
||||
|
||||
fn mandel() void {
|
||||
const xmin: i32 = -8601;
|
||||
const xmax: i32 = 2867;
|
||||
const ymin: i32 = -4915;
|
||||
const ymax: i32 = 4915;
|
||||
const maxiter: usize = 32;
|
||||
const dx: i32 = @divTrunc((xmax - xmin), 79);
|
||||
const dy: i32 = @divTrunc((ymax - ymin), 24);
|
||||
var cy = ymin;
|
||||
|
||||
while (cy <= ymax) {
|
||||
var cx = xmin;
|
||||
while (cx <= xmax) {
|
||||
var x: i32 = 0;
|
||||
var y: i32 = 0;
|
||||
var x2: i32 = 0;
|
||||
var y2: i32 = 0;
|
||||
var iter: usize = 0;
|
||||
while (iter < maxiter) : (iter += 1) {
|
||||
if (x2 + y2 > 16384) break;
|
||||
y = ((x * y) >> 11) + cy;
|
||||
x = x2 - y2 + cx;
|
||||
x2 = (x * x) >> 12;
|
||||
y2 = (y * y) >> 12;
|
||||
uvm.yield();
|
||||
}
|
||||
uvm.printc(' ' + @as(u8, @intCast(iter)));
|
||||
cx += dx;
|
||||
}
|
||||
uvm.printc('\n');
|
||||
cy += dy;
|
||||
}
|
||||
}
|
||||
|
||||
export fn main() void {
|
||||
mandel();
|
||||
uvm.println("Hello world");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue