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

fix: switching of the LCD

parent 4a9c6fc8
No related branches found
No related tags found
No related merge requests found
Pipeline #940 passed
......@@ -89,10 +89,10 @@ fn main() {
//game_boy.load_rom_file("../../res/roms.prop/alleyway.gb");
//game_boy.load_rom_file("../../res/roms/firstwhite.gb");
//game_boy.load_rom_file("../../res/roms/opus5.gb");
game_boy.load_rom_file("../../res/roms/opus5.gb");
//game_boy.load_rom_file("../../res/roms/paradius/cpu/01-special.gb"); // PASSED
game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb");
//game_boy.load_rom_file("../../res/roms/paradius/cpu/02-interrupts.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/03-op sp,hl.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/04-op r,imm.gb"); // PASSED
//game_boy.load_rom_file("../../res/roms/paradius/cpu/05-op rp.gb"); // PASSED
......
......@@ -109,6 +109,14 @@ impl Cpu {
panic!("Invalid PC area at 0x{:04x}", pc);
}
// @todo this is so bad, need to improve this by an order
// of magnitude
if self.halted {
if ((self.mmu.ie & 0x01 == 0x01) && self.mmu.ppu().int_vblank()) || ((self.mmu.ie & 0x04 == 0x04) && self.mmu.timer().int_tima()) {
self.halted = false;
}
}
if self.ime {
// @todo aggregate all of this interrupts in the MMU
if (self.mmu.ie & 0x01 == 0x01) && self.mmu.ppu().int_vblank() {
......@@ -179,7 +187,7 @@ impl Cpu {
if *instruction_str == "! UNIMP !" || *instruction_str == "HALT" {
if *instruction_str == "HALT" {
println!("Waiting for 0x{:02x} in HALT", self.mmu.ie);
println!("HALT with IE=0x{:02x} IME={}", self.mmu.ie, self.ime);
}
println!(
"{}\t(0x{:02x})\t${:04x} {}",
......
......@@ -316,10 +316,6 @@ impl Ppu {
}
pub fn clock(&mut self, cycles: u8) {
if !self.switch_lcd {
return;
}
// increments the current mode clock by the provided amount
// of CPU cycles (probably coming from a previous CPU clock)
self.mode_clock += cycles as u16;
......@@ -416,6 +412,13 @@ impl Ppu {
self.switch_window = value & 0x20 == 0x20;
self.window_map = value & 0x40 == 0x40;
self.switch_lcd = value & 0x80 == 0x80;
// in case the LCD is off takes the opportunity
// to clear the screen, this is the expected
// behaviour for this specific situation
if !self.switch_lcd {
self.clear_frame_buffer();
}
}
0x0041 => {
self.stat_hblank = value & 0x04 == 0x04;
......@@ -579,6 +582,9 @@ impl Ppu {
}
fn render_line(&mut self) {
if !self.switch_lcd {
return;
}
if self.switch_bg {
self.render_background();
}
......
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