Skip to content
Snippets Groups Projects
Verified Commit 268193f4 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: better drawing of line

parent 85b6d502
No related branches found
No related tags found
No related merge requests found
......@@ -111,7 +111,6 @@ impl Mmu {
}
// Graphics: VRAM (8k)
0x8000 | 0x9000 => {
println!("WRITING TO VRAM");
self.ppu.vram[(addr & 0x1fff) as usize] = value;
if addr < 0x9800 {
self.ppu.update_tile(addr, value);
......
......@@ -214,16 +214,18 @@ impl Ppu {
let y = ((self.scy + self.line) & 0x07) as usize;
let mut x = (self.scx & 0x07) as usize;
let mut frame_offset = self.line as usize * SCREEN_WIDTH * RGBA_SIZE;
// calculates the index of the initial tile in drawing,
// if the tile data set in use is #1, the indices are
// signed, then calculates a real tile offset
let mut tile_index = self.vram[map_offset + line_offset] as usize;
// if the tile data set in use is #1, the
// indices are signed, calculates a real tile offset
if self.bg_tile && tile_index < 128 {
tile_index += 256;
}
// calculates the frame buffer offset position assuming the proper
// Game Boy screen width and RGBA pixel (4 bytes) size
let mut frame_offset = self.line as usize * SCREEN_WIDTH * RGBA_SIZE;
for _index in 0..SCREEN_WIDTH {
// in case the end of tile width has been reached then
// a new tile must be retrieved for plotting
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment