From 62abc3cbd25df4e12615e0282809150003857ff5 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Tue, 20 Nov 2018 03:41:42 -0700 Subject: [PATCH] make mode3 clear a little speedier --- src/video_ram.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/video_ram.rs b/src/video_ram.rs index c4d1601..6cb223a 100644 --- a/src/video_ram.rs +++ b/src/video_ram.rs @@ -69,13 +69,12 @@ pub fn mode3_read_pixel(col: isize, row: isize) -> Option { /// Clears the entire screen to the color specified. pub unsafe fn mode3_clear_screen(color: u16) { + // TODO: use DMA? let color = color as u32; let bulk_color = color << 16 | color; let mut ptr = VolatilePtr(VRAM_BASE_ADDRESS as *mut u32); - for _ in 0..SCREEN_HEIGHT { - for _ in 0..(SCREEN_WIDTH / 2) { - ptr.write(bulk_color); - ptr = ptr.offset(1); - } + for _ in 0..(SCREEN_HEIGHT * SCREEN_WIDTH / 2) { + ptr.write(bulk_color); + ptr = ptr.offset(1); } }