diff --git a/ncc/examples/ball.c b/ncc/examples/ball.c index b47cb86..deb821e 100644 --- a/ncc/examples/ball.c +++ b/ncc/examples/ball.c @@ -9,7 +9,7 @@ #define BALL_RADIUS 20 #define AUDIO_LEN 8_000 -// RGBA pixels: 800 * 600 +// RGBA pixels u32 frame_buffer[FRAME_HEIGHT][FRAME_WIDTH]; // Current ball position @@ -58,7 +58,7 @@ void draw_ball() void update() { // Clear the frame buffer, set all pixels to black - memset32(frame_buffer, 0, 800 * 600); + memset32(frame_buffer, 0, sizeof(frame_buffer) / sizeof(u32)); draw_ball(); diff --git a/vm/src/audio.rs b/vm/src/audio.rs index e7c8b04..cee944f 100644 --- a/vm/src/audio.rs +++ b/vm/src/audio.rs @@ -76,7 +76,7 @@ impl AudioCallback for InputCB // Copy the samples to make them accessible to the audio thread INPUT_STATE.with_borrow_mut(|s| { s.input_tid = self.thread.id; - s.samples.clear(); + s.samples.resize(buf.len(), 0); s.samples.copy_from_slice(buf); }); @@ -110,11 +110,6 @@ thread_local! { static INPUT_STATE: RefCell = RefCell::new(InputState::default()); } - - - - - pub fn audio_open_output(thread: &mut Thread, sample_rate: Value, num_channels: Value, format: Value, cb: Value) -> Value { if thread.id != 0 {