[draw] Add draw calls
This commit is contained in:
@@ -102,17 +102,17 @@ impl Device {
|
|||||||
|
|
||||||
for i in 0..n as usize{
|
for i in 0..n as usize{
|
||||||
let index = Self::get_framebuffer_index(x,y+i);
|
let index = Self::get_framebuffer_index(x,y+i);
|
||||||
let slice_from_memory = self.memory[self.registers.i as usize];
|
let slice_from_memory = self.memory[self.registers.i as usize + i];
|
||||||
|
|
||||||
for bit_index in (0..8).rev() {
|
for bit_index in (0..8).rev() {
|
||||||
// if i'm going to the next line, stop
|
// if i'm going to the next line, stop
|
||||||
if Self::get_framebuffer_index(0, y+1)==index {
|
if Self::get_framebuffer_index(0, y+1)==index {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let bit = (slice_from_memory & 1<<bit_index) >> bit_index;
|
let bit = (slice_from_memory & (1<<bit_index)) >> bit_index;
|
||||||
|
|
||||||
|
let byte = bit * 0xff;
|
||||||
frame_buffer[index+(7-bit_index)] = frame_buffer[index+(7-bit_index)] ^ (bit * 0xff);
|
frame_buffer[index+(7-bit_index)] = frame_buffer[index+(7-bit_index)] ^ (byte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO fix carry bit
|
// TODO fix carry bit
|
||||||
|
@@ -100,7 +100,7 @@ fn main() {
|
|||||||
fn draw_screen(frame_buffer: MutexGuard<Box<[u8; 2048]>>, window_canvas: &mut WindowCanvas, x1: &mut Vec<u8>) {
|
fn draw_screen(frame_buffer: MutexGuard<Box<[u8; 2048]>>, window_canvas: &mut WindowCanvas, x1: &mut Vec<u8>) {
|
||||||
for (i,pixel) in frame_buffer.iter().enumerate(){
|
for (i,pixel) in frame_buffer.iter().enumerate(){
|
||||||
x1[3*i] = *pixel;
|
x1[3*i] = *pixel;
|
||||||
x1[3*i+1] = *pixel;
|
x1[3*i+1] = *pixel ;
|
||||||
x1[3*i+2] = *pixel;
|
x1[3*i+2] = *pixel;
|
||||||
}
|
}
|
||||||
drop(frame_buffer);
|
drop(frame_buffer);
|
||||||
@@ -110,7 +110,7 @@ fn draw_screen(frame_buffer: MutexGuard<Box<[u8; 2048]>>, window_canvas: &mut Wi
|
|||||||
tex.with_lock(None,|u,i|{
|
tex.with_lock(None,|u,i|{
|
||||||
u.copy_from_slice(x1);
|
u.copy_from_slice(x1);
|
||||||
}).expect("Unwrap tex");
|
}).expect("Unwrap tex");
|
||||||
window_canvas.copy(&tex,None,None);
|
window_canvas.copy(&tex,None,None).expect("Failed to set texture");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_frame_buffer() -> Arc<Mutex<Box<[u8; 2048]>>> {
|
fn get_frame_buffer() -> Arc<Mutex<Box<[u8; 2048]>>> {
|
||||||
|
Reference in New Issue
Block a user