mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 10:12:11 +00:00
Logic to load a rom file
This commit is contained in:
parent
1e363187f1
commit
1902884df9
BIN
roms/cpu_instrs.gb
Normal file
BIN
roms/cpu_instrs.gb
Normal file
Binary file not shown.
@ -1,4 +1,7 @@
|
||||
fn main() {
|
||||
println!("TEST");
|
||||
println!("{}", false as u8);
|
||||
use rust_boy::rom::ROM;
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
let myrom = ROM::load_file("roms/cpu_instrs.gb".to_string())?;
|
||||
myrom.print_content();
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
pub mod utils;
|
||||
pub mod cpu;
|
||||
pub mod rom;
|
||||
|
21
src/rom.rs
Normal file
21
src/rom.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
|
||||
pub struct ROM {
|
||||
bytes: Vec<u8>,
|
||||
}
|
||||
|
||||
impl ROM {
|
||||
pub fn load_file(filename: String) -> std::io::Result<Self> {
|
||||
let mut file = File::open(filename)?;
|
||||
let mut bytes = vec![];
|
||||
file.read_to_end(&mut bytes)?;
|
||||
Ok(Self {
|
||||
bytes,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn print_content(&self) {
|
||||
println!("{:02X?}", self.bytes);
|
||||
}
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
pub struct AddressRange(u16, u16);
|
||||
|
||||
pub enum BitIndex {
|
||||
I0,
|
||||
I1,
|
||||
|
Loading…
Reference in New Issue
Block a user