Skip to content

Commit 3d3bb7c

Browse files
committed
core: initialize content of RAM to 0xFF
Fixes #10
1 parent 55cb98d commit 3d3bb7c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

core/after_boot/ppu.sav

0 Bytes
Binary file not shown.

core/src/gameboy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ impl GameBoy {
153153
trace: RefCell::new(Trace::new()),
154154
cpu: Cpu::default(),
155155
cartridge,
156-
wram: [0; 0x2000],
157-
hram: [0; 0x7F],
156+
wram: [0xFF; 0x2000],
157+
hram: [0xFF; 0x7F],
158158
boot_rom,
159159
boot_rom_active: true,
160160
clock_count: 0,
@@ -223,8 +223,8 @@ impl GameBoy {
223223
}
224224
// TODO: Maybe I should reset the cartridge
225225
self.cpu = Cpu::default();
226-
self.wram = [0; 0x2000];
227-
self.hram = [0; 0x7F];
226+
self.wram = [0xFF; 0x2000];
227+
self.hram = [0xFF; 0x7F];
228228
self.boot_rom_active = true;
229229
self.clock_count = 0;
230230
self.timer = Timer::new().into();
@@ -257,8 +257,8 @@ impl GameBoy {
257257
state: cpu::CpuState::Running,
258258
};
259259

260-
self.wram = [0; 0x2000];
261-
self.hram = [0; 0x7F];
260+
self.wram = [0xFF; 0x2000];
261+
self.hram = [0xFF; 0x7F];
262262
self.hram[0x7a..=0x7c].copy_from_slice(&[0x39, 0x01, 0x2e]);
263263

264264
self.boot_rom_active = false;

core/src/gameboy/ppu.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ crate::save_state!(Ppu, self, ctx, data {
537537
impl Default for Ppu {
538538
fn default() -> Self {
539539
Self {
540-
vram: [0; 0x2000],
541-
oam: [0; 0xA0],
540+
vram: [0xFF; 0x2000],
541+
oam: [0xFF; 0xA0],
542542
dma_started: 0x7fff_ffff_ffff_ffff,
543543
dma_running: false,
544544
dma_block_oam: false,
@@ -603,13 +603,13 @@ impl Ppu {
603603
*self = Self {
604604
#[rustfmt::skip]
605605
vram: {
606-
let mut vram = [0; 0x2000];
606+
let mut vram = [0xFF; 0x2000];
607607
vram.load_state(ctx, &mut ppu_state).unwrap();
608608
vram
609609

610610
},
611611
oam: {
612-
let mut oam = [0; 0xA0];
612+
let mut oam = [0xFF; 0xA0];
613613
oam.load_state(ctx, &mut ppu_state).unwrap();
614614
oam
615615
},

0 commit comments

Comments
 (0)