Skip to content

Commit

Permalink
Fix double buffer allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Oct 15, 2024
1 parent 8fab113 commit 3182e7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sys/vga/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ enum ModeName {
G640x480x16,
}

const FRAMEBUFFER: usize = 0xA0000;
const FRAME_BUFFER_ADDR: usize = 0xA0000;
const DOUBLE_BUFFER: [u8; 640 * 480] = [0; 640 * 480];

static MODE: Mutex<Option<ModeName>> = Mutex::new(None);

Expand Down Expand Up @@ -174,14 +175,13 @@ fn set_640x480_mode() {

fn clear_screen() {
// Clear screen
let screen = [0; 640 * 480];
let size = match *MODE.lock() {
Some(ModeName::G320x200x256) => 320 * 200,
Some(ModeName::G640x480x16) => 640 * 480,
_ => return,
};
let src = screen.as_ptr();
let dst = FRAMEBUFFER as *mut u8;
let src = DOUBLE_BUFFER.as_ptr();
let dst = FRAME_BUFFER_ADDR as *mut u8;
unsafe {
core::ptr::copy_nonoverlapping(src, dst, size);
}
Expand Down

0 comments on commit 3182e7f

Please sign in to comment.