Skip to content

Commit c692ed2

Browse files
committed
Update PPU mode even if LCD is disabled
1 parent fdaab91 commit c692ed2

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

emu/src/main.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ use structopt::StructOpt;
1919
enum Args {
2020
#[structopt(about = "Run a ROM on the emulator")]
2121
Run {
22-
#[structopt(parse(from_os_str))]
22+
#[structopt(parse(from_os_str), help = "Path to ROM file")]
2323
rom_file: PathBuf,
2424

25-
#[structopt(default_value = "6", long)]
25+
#[structopt(default_value = "4", long, help = "Emulation resolution multiplier")]
2626
scale: u32,
2727

28-
#[structopt(default_value = "1", long)]
28+
#[structopt(default_value = "1", long, help = "Emulation speed multiplier")]
2929
speed: u8,
3030

31-
#[structopt(long)]
31+
#[structopt(long, help = "Boot into the DMG boot ROM")]
3232
boot_rom: bool,
3333

34-
#[structopt(long)]
34+
#[structopt(long, help = "Trace all instructions to a file in the current directory")]
3535
trace: bool,
3636
},
3737
#[structopt(about = "Inspect a ROM")]
@@ -248,7 +248,6 @@ fn gui(rom_file: PathBuf, scale: u32, speed: u8, boot_rom: bool, trace: bool) {
248248
if !paused {
249249
// Render a single frame
250250
handle_frame(&mut gameboy, &mut canvas, &mut texture, &mut joypad_events, outline);
251-
252251
}
253252

254253
let elapsed = frame_start.elapsed();
@@ -288,8 +287,8 @@ fn main() {
288287
Ok(c) => c,
289288
};
290289

291-
println!("\nTitle: {}", cartridge.title().unwrap());
292-
println!("Manufacturer: {}", cartridge.manufacturer_code().unwrap());
290+
println!("\nTitle: {}", cartridge.title().unwrap_or("N/A"));
291+
println!("Manufacturer: {}", cartridge.manufacturer_code().unwrap_or("N/A"));
293292
println!("GBC support: {}", cartridge.cgb());
294293
println!("Cartridge type: {:?}", cartridge.cartridge_type().unwrap());
295294
println!("ROM size: {:?}", cartridge.rom_size().unwrap());

lib/src/cpu.rs

+2
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ impl Cpu {
234234

235235
// Then write the instruction
236236
write!(f, "{:03}:{}:{:#06X} - {}\n\n", bank, memory_type, pc, inst).unwrap();
237+
238+
f.flush().unwrap();
237239
}
238240

239241
/// Execute a single step of DMA (if active).

lib/src/ppu.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -512,16 +512,14 @@ impl Ppu {
512512
self.dot = dot;
513513
self.ly = line;
514514

515-
if self.lcdc.lcd_display_enable() {
516-
// Update the internal PPU status
517-
//
518-
// This also returns which interrupts need to be triggered
519-
let stat_mode_change = self.update_status(mode, interrupts);
515+
// Update the internal PPU status
516+
//
517+
// This also returns which interrupts need to be triggered
518+
let stat_mode_change = self.update_status(mode, interrupts);
520519

521-
if stat_mode_change {
522-
// Render data to the frame
523-
self.render();
524-
}
520+
if self.lcdc.lcd_display_enable() && stat_mode_change {
521+
// Render data to the frame
522+
self.render();
525523
}
526524
}
527525

@@ -1133,6 +1131,7 @@ impl MemoryRead<u16, u8> for Ppu {
11331131
self.vram.read(addr)
11341132
} else {
11351133
// PPU returns 0xFF if VRAM is locked
1134+
log::info!("Blocked VRAM read from 0x{:X}", addr);
11361135
0xFF
11371136
}
11381137
}
@@ -1183,6 +1182,8 @@ impl MemoryWrite<u16, u8> for Ppu {
11831182
if !self.oam_locked() {
11841183
let idx = (addr - Self::OAM_START_ADDR) as usize;
11851184
self.oam[idx] = value;
1185+
} else {
1186+
log::info!("Blocked OAM write to 0x{:X}: 0x{:X}", addr, value);
11861187
}
11871188
}
11881189
Self::LCDC_ADDR => {

0 commit comments

Comments
 (0)