mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2026-10-02 23:45:20 -04:00
Logic to load a rom file
This commit is contained in:
Binary file not shown.
+6
-3
@@ -1,4 +1,7 @@
|
|||||||
fn main() {
|
use rust_boy::rom::ROM;
|
||||||
println!("TEST");
|
|
||||||
println!("{}", false as u8);
|
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 utils;
|
||||||
pub mod cpu;
|
pub mod cpu;
|
||||||
|
pub mod rom;
|
||||||
|
|||||||
+21
@@ -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 {
|
pub enum BitIndex {
|
||||||
I0,
|
I0,
|
||||||
I1,
|
I1,
|
||||||
|
|||||||
Reference in New Issue
Block a user