osa1 / wasmrun

[WIP] A Wasm interpreter with debugging and inspection capabilities
Other
11 stars 1 forks source link

Demo idea: wasm4 #3

Open osa1 opened 2 years ago

osa1 commented 2 years ago

I was thinking about a fun demo application that we can implement using wasmrun, and I think wasm4 would be a fun one.

We need to implement this API in host:

fn blit(sprite: *const u8, x: i32, y: i32, width: u32, height: u32, flags: u32);

fn blit_sub(
    sprite: *const u8,
    x: i32,
    y: i32,
    width: u32,
    height: u32,
    src_x: u32,
    src_y: u32,
    stride: u32,
    flags: u32,
);

fn line(x1: i32, y1: i32, x2: i32, y2: i32);

fn oval(x: i32, y: i32, width: u32, height: u32);

fn rect(x: i32, y: i32, width: u32, height: u32);

fn text(text: *const u8, length: usize, x: i32, y: i32);

fn vline(x: i32, y: i32, len: u32);

fn hline(x: i32, y: i32, len: u32);

fn tone(frequency: u32, duration: u32, volume: u32, flags: u32);

fn diskr(dest: *mut u8, size: u32) -> u32;

fn diskw(src: *const u8, size: u32) -> u32;

fn trace(trace: *const u8, length: usize);

And write user input to a specific location in Wasm application memory and render the bitmap.

osa1 commented 2 years ago

pixels, minifb, or softbuffer could be used for the windowing and rendering parts. I don't know if they play sounds out of the box, but it should be fine to ignore tone calls at least initially.

softbuffer README says:

Softbuffer should be used over pixels when its GPU-accelerated post-processing effects are not needed