diff --git a/src/chip8/emulator.rs b/src/chip8/emulator.rs index 532f4b8..a193e62 100644 --- a/src/chip8/emulator.rs +++ b/src/chip8/emulator.rs @@ -1,7 +1,7 @@ use crate::chip8::audio::Speaker; use crate::chip8::display::Screen; use crate::chip8::keyboard::Keyboard; -use crate::chip8::memory::{Memory, MEMORY_SIZE, PROGRAM_LOAD_ADDRESS}; +use crate::chip8::memory::{self, Memory}; use crate::chip8::registers::{Register::*, Registers}; use crate::chip8::stack::Stack; @@ -52,12 +52,12 @@ impl Chip8 { let rom = fs::read(file).expect("Cannot read ROM"); let rom_length = rom.len(); - if rom_length > MEMORY_SIZE - PROGRAM_LOAD_ADDRESS { + if rom_length > memory::MEMORY_SIZE - memory::PROGRAM_LOAD_ADDRESS { panic!("ROM too big, aborting") } for (i, byte) in rom.iter().enumerate() { - self.memory.set(PROGRAM_LOAD_ADDRESS + i, *byte); + self.memory.set(memory::PROGRAM_LOAD_ADDRESS + i, *byte); } rom_length diff --git a/src/chip8/memory.rs b/src/chip8/memory.rs index bab4720..ab05774 100644 --- a/src/chip8/memory.rs +++ b/src/chip8/memory.rs @@ -3,7 +3,7 @@ pub const PROGRAM_LOAD_ADDRESS: usize = 0x200; const DEFAULT_CHARACTER_SET_START: usize = 0; -const DEFAULT_CHARACTER_SET: [u8; 80] = [ +static DEFAULT_CHARACTER_SET: [u8; 80] = [ 0xf0, 0x90, 0x90, 0x90, 0xf0, // 0 0x20, 0x60, 0x20, 0x20, 0x70, // 1 0xf0, 0x10, 0xf0, 0x80, 0xf0, // 2 diff --git a/src/chip8/registers.rs b/src/chip8/registers.rs index dc248c9..7ab58cf 100644 --- a/src/chip8/registers.rs +++ b/src/chip8/registers.rs @@ -1,4 +1,4 @@ -use super::memory::PROGRAM_LOAD_ADDRESS; +use super::memory; const DATA_REGISTERS: usize = 16; @@ -66,7 +66,7 @@ impl Registers { i: 0, delay_timer: 0, sound_timer: 0, - pc: PROGRAM_LOAD_ADDRESS as u16, + pc: memory::PROGRAM_LOAD_ADDRESS as u16, sp: 0, } }