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

feat: new checking of interrupt level

parent 34666917
No related branches found
No related tags found
No related merge requests found
Pipeline #877 passed
...@@ -81,8 +81,8 @@ fn main() { ...@@ -81,8 +81,8 @@ fn main() {
let mut game_boy = GameBoy::new(); let mut game_boy = GameBoy::new();
game_boy.load_boot_sgb(); game_boy.load_boot_sgb();
//game_boy.load_rom_file("../../res/roms.prop/tetris.gb"); //game_boy.load_rom_file("../../res/roms.prop/tetris.gb");
game_boy.load_rom_file("../../res/roms.prop/alleyway.gb"); //game_boy.load_rom_file("../../res/roms.prop/alleyway.gb");
//game_boy.load_rom_file("../../res/roms/07-jr,jp,call,ret,rst.gb"); game_boy.load_rom_file("../../res/roms/07-jr,jp,call,ret,rst.gb");
//game_boy.load_rom_file("../../res/roms/firstwhite.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/ld_r_r.gb"); //game_boy.load_rom_file("../../res/roms/ld_r_r.gb");
......
...@@ -108,12 +108,12 @@ impl Cpu { ...@@ -108,12 +108,12 @@ impl Cpu {
let (instruction_fn, instruction_time, instruction_str) = instruction; let (instruction_fn, instruction_time, instruction_str) = instruction;
if *instruction_str == "! UNIMP !" { //if *instruction_str == "! UNIMP !" {
println!( println!(
"{}\t(0x{:02x})\t${:04x} {}", "{}\t(0x{:02x})\t${:04x} {}",
instruction_str, opcode, pc, is_prefix instruction_str, opcode, pc, is_prefix
); );
} //}
// calls the current instruction and increments the number of // calls the current instruction and increments the number of
// cycles executed by the instruction time of the instruction // cycles executed by the instruction time of the instruction
......
...@@ -94,9 +94,9 @@ pub struct Ppu { ...@@ -94,9 +94,9 @@ pub struct Ppu {
stat_lyc: bool, stat_lyc: bool,
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy, PartialEq)]
pub enum PpuMode { pub enum PpuMode {
Hblank = 0, HBlank = 0,
VBlank = 1, VBlank = 1,
OamRead = 2, OamRead = 2,
VramRead = 3, VramRead = 3,
...@@ -156,10 +156,10 @@ impl Ppu { ...@@ -156,10 +156,10 @@ impl Ppu {
} }
self.mode_clock = 0; self.mode_clock = 0;
self.mode = PpuMode::Hblank; self.mode = PpuMode::HBlank;
} }
} }
PpuMode::Hblank => { PpuMode::HBlank => {
if self.mode_clock >= 204 { if self.mode_clock >= 204 {
self.ly += 1; self.ly += 1;
...@@ -396,4 +396,13 @@ impl Ppu { ...@@ -396,4 +396,13 @@ impl Ppu {
print!("\n"); print!("\n");
} }
} }
/// Obtains the current level of the LCD interrupt by
/// checking the current PPU state in various sections.
fn interrupt_level(&self) -> bool {
self.stat_lyc && self.lyc == self.ly
|| self.stat_oam && self.mode == PpuMode::OamRead
|| self.stat_vblank && self.mode == PpuMode::VBlank
|| self.stat_vblank && self.mode == PpuMode::HBlank
}
} }
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