mirror of
https://github.com/FranLMSP/rultra64.git
synced 2026-10-02 07:25:21 -04:00
ROM loading
This commit is contained in:
Generated
+811
-5
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -6,4 +6,5 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = "0.16.0"
|
eframe = "0.16.0"
|
||||||
|
rfd = "0.7"
|
||||||
+15
-1
@@ -17,10 +17,20 @@ impl Emulator {
|
|||||||
pub fn new_hle() -> Self {
|
pub fn new_hle() -> Self {
|
||||||
Self {
|
Self {
|
||||||
cpu: CPU::new_hle(),
|
cpu: CPU::new_hle(),
|
||||||
mmu: MMU::new_hle(),
|
mmu: MMU::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reload(&mut self) {
|
||||||
|
self.cpu = CPU::new();
|
||||||
|
self.mmu = MMU::new();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reload_hle(&mut self) {
|
||||||
|
self.cpu = CPU::new_hle();
|
||||||
|
self.mmu = MMU::new();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn tick(&mut self) {
|
pub fn tick(&mut self) {
|
||||||
self.cpu.fetch_and_exec_opcode(&mut self.mmu);
|
self.cpu.fetch_and_exec_opcode(&mut self.mmu);
|
||||||
}
|
}
|
||||||
@@ -28,4 +38,8 @@ impl Emulator {
|
|||||||
pub fn cpu(&self) -> &CPU {
|
pub fn cpu(&self) -> &CPU {
|
||||||
&self.cpu
|
&self.cpu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn mut_mmu(&mut self) -> &mut MMU {
|
||||||
|
&mut self.mmu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+11
-1
@@ -24,7 +24,7 @@ pub struct EmulatorApp {
|
|||||||
impl Default for EmulatorApp {
|
impl Default for EmulatorApp {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
core: Emulator::new(),
|
core: Emulator::new_hle(),
|
||||||
selected_register: Register::CPU,
|
selected_register: Register::CPU,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,6 +68,16 @@ impl epi::App for EmulatorApp {
|
|||||||
egui::menu::bar(ui, |ui| {
|
egui::menu::bar(ui, |ui| {
|
||||||
ui.menu_button("File", |ui| {
|
ui.menu_button("File", |ui| {
|
||||||
if ui.button("Load ROM").clicked() {
|
if ui.button("Load ROM").clicked() {
|
||||||
|
if let Some(path) = rfd::FileDialog::new().pick_file() {
|
||||||
|
let picked_path = path.display().to_string();
|
||||||
|
if let Ok(rom) = crate::rom::ROM::new_from_filename(&picked_path) {
|
||||||
|
let mut emulator_core = emulator_core.borrow_mut();
|
||||||
|
emulator_core.reload_hle();
|
||||||
|
emulator_core.mut_mmu().set_rom(rom);
|
||||||
|
emulator_core.mut_mmu().hle_ipl();
|
||||||
|
println!("ROM loaded!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ui.button("Quit").clicked() {
|
if ui.button("Quit").clicked() {
|
||||||
frame.quit();
|
frame.quit();
|
||||||
|
|||||||
+8
-7
@@ -52,20 +52,21 @@ impl MMU {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_hle() -> Self {
|
pub fn hle_ipl(&mut self) {
|
||||||
let mut mmu = Self::new();
|
|
||||||
// Skip IPL1 and IPL2
|
// Skip IPL1 and IPL2
|
||||||
for i in 0..0x1000 {
|
for i in 0..0x1000 {
|
||||||
let byte = mmu.read_virtual(0xB0000000 + i, 1);
|
let byte = self.read_virtual(0xB0000000 + i, 1);
|
||||||
mmu.write_virtual(0xA4000000 + i, &byte);
|
self.write_virtual(0xA4000000 + i, &byte);
|
||||||
}
|
}
|
||||||
// Skip IPL3
|
// Skip IPL3
|
||||||
for i in 0..0x100000 {
|
for i in 0..0x100000 {
|
||||||
let byte = mmu.read_physical_byte(0x10001000 + i);
|
let byte = self.read_physical_byte(0x10001000 + i);
|
||||||
mmu.write_physical_byte(0x00001000 + i, byte);
|
self.write_physical_byte(0x00001000 + i, byte);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mmu
|
pub fn set_rom(&mut self, rom: ROM) {
|
||||||
|
self.rom = rom;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn convert(address: i64) -> i64 {
|
pub fn convert(address: i64) -> i64 {
|
||||||
|
|||||||
Reference in New Issue
Block a user