Implement reading from real memory
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::{ffi::c_void, ptr, slice};
|
||||
use std::{ffi::c_void, ops::Range, ptr, slice};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use bitflags::bitflags;
|
||||
@@ -101,6 +101,8 @@ extern "C" {
|
||||
fn vb_get_user_data(sim: *mut VB) -> *mut c_void;
|
||||
#[link_name = "vbInit"]
|
||||
fn vb_init(sim: *mut VB) -> *mut VB;
|
||||
#[link_name = "vbRead"]
|
||||
fn vb_read(sim: *mut VB, address: u32, typ_: VBDataType) -> i32;
|
||||
#[link_name = "vbReset"]
|
||||
fn vb_reset(sim: *mut VB);
|
||||
#[link_name = "vbSetCartRAM"]
|
||||
@@ -314,6 +316,13 @@ impl Sim {
|
||||
VBRegister::PC => unsafe { vb_get_program_counter(self.sim) },
|
||||
}
|
||||
}
|
||||
|
||||
pub fn read_memory(&mut self, addresses: Range<u32>, into: &mut Vec<u8>) {
|
||||
for address in addresses {
|
||||
let byte = unsafe { vb_read(self.sim, address, VBDataType::U8) };
|
||||
into.push(byte as u8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Sim {
|
||||
|
||||
Reference in New Issue
Block a user