Minor cleanup
This commit is contained in:
parent
9fce6f97dc
commit
3b23c8c5b1
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue