update readme, remove todo! from bus and display registers

This commit is contained in:
2023-05-11 22:08:42 -05:00
parent 8333eb13cb
commit 0cc55d7b20
5 changed files with 66 additions and 10 deletions
+9 -7
View File
@@ -2,13 +2,15 @@
Work in progress experimental SNES emulator written in Rust.
## Resources
* https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM
* https://ersanio.gitbook.io/assembly-for-the-snes
* https://wiki.superfamicom.org
* https://snesdev.mesen.ca/wiki/index.php
* https://problemkaputt.de/fullsnes.htm
* BCD addition and substraction: https://ehaskins.com/2018-01-30%20Z80%20DAA/
* 65816 programming manual: https://www.nesdev.org/w/images/default/7/76/Programmanual.pdf
* SNES General:
* https://wiki.superfamicom.org
* https://snesdev.mesen.ca/wiki/index.php
* https://problemkaputt.de/fullsnes.htm
* 65816 CPU:
* https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM
* https://ersanio.gitbook.io/assembly-for-the-snes
* 65816 programming manual: https://www.nesdev.org/w/images/default/7/76/Programmanual.pdf
* BCD addition and substraction: https://ehaskins.com/2018-01-30%20Z80%20DAA/
* Test ROMs
* PeterLemon's test ROMs: https://github.com/PeterLemon/SNES
* Retro Game Mechanics Explained SNES playlists:
+13 -2
View File
@@ -1,8 +1,13 @@
use crate::ppu::PPU;
use crate::cpu::internal_registers::InternalRegisters;
use crate::rom::ROM;
use crate::rom::lo_rom::LoROM;
pub struct Bus {
wram: [u8; 0x10000],
pub ppu: PPU,
pub rom: Box<dyn ROM>,
pub internal_registers: InternalRegisters,
}
#[derive(PartialEq, Debug)]
@@ -19,6 +24,8 @@ impl Bus {
Self {
wram: [0; 0x10000],
ppu: PPU::new(),
rom: Box::new(LoROM::new()),
internal_registers: InternalRegisters::new(),
}
}
@@ -54,7 +61,9 @@ impl Bus {
match section {
MemoryMap::WRAM => self.read_wram(address),
MemoryMap::PPU => self.ppu.registers.read(address as u16),
_ => todo!("Implement other memory sections. Address: {:#08X}", address),
MemoryMap::CPU => self.internal_registers.read(address as u16),
MemoryMap::Joypad => 0x00, // TODO: Placeholder
MemoryMap::Cartridge => self.rom.read(address),
}
}
@@ -63,7 +72,9 @@ impl Bus {
match section {
MemoryMap::WRAM => self.write_wram(address, value),
MemoryMap::PPU => self.ppu.registers.write(address as u16, value),
_ => todo!("Implement other memory sections. Address: {:#08X}", address),
MemoryMap::CPU => self.internal_registers.write(address as u16, value),
MemoryMap::Joypad => {}, // TODO: Placeholder
MemoryMap::Cartridge => self.rom.write(address, value),
}
}
}
+24
View File
@@ -0,0 +1,24 @@
pub const INTERNAL_REGISTERS_ADDRESS: u16 = 0x4200;
pub struct InternalRegisters {
_registers: [u8; 32],
}
impl InternalRegisters {
pub fn new() -> Self {
Self {
_registers: [0; 32],
}
}
pub fn read(&self, _address: u16) -> u8 {
// TODO: Placeholder
// self.registers[(address - INTERNAL_REGISTERS_ADDRESS) as usize]
0x00
}
pub fn write(&mut self, _address: u16, _value: u8) {
// TODO: Placeholder
// self.registers[(address - INTERNAL_REGISTERS_ADDRESS) as usize] = value;
}
}
+1
View File
@@ -4,3 +4,4 @@ pub mod bus;
pub mod registers;
pub mod instructions;
pub mod cycles;
pub mod internal_registers;
+19 -1
View File
@@ -217,7 +217,7 @@ fn main() {
if let Some(path) = FileDialog::new()
.pick_file()
{
match emulator.rom.load(&String::from(path.to_str().unwrap())) {
match emulator.bus.rom.load(&String::from(path.to_str().unwrap())) {
Ok(_) => {
state.emulation.is_paused = false;
},
@@ -289,6 +289,24 @@ fn main() {
)
}
}
if state.debug_options.show_cpu_registers {
let window = imgui::Window::new("CPU Registers");
window
.size([150.0, 200.0], Condition::FirstUseEver)
.build(&ui, || {
ui.text(format!("SP: | {:#06X}", emulator.cpu.registers.sp));
ui.text(format!("X: | {:#06X}", emulator.cpu.registers.x));
ui.text(format!("Y: | {:#06X}", emulator.cpu.registers.y));
ui.text(format!("A: | {:#06X}", emulator.cpu.registers.a));
ui.text(format!("P: | {:#04X}", emulator.cpu.registers.p));
ui.text(format!("D: | {:#06X}", emulator.cpu.registers.d));
ui.text(format!("PBR: | {:#04X}", emulator.cpu.registers.pbr));
ui.text(format!("DBR: | {:#04X}", emulator.cpu.registers.dbr));
ui.text(format!("PC: | {:#06X}", emulator.cpu.registers.pc));
ui.text(format!("EMU MODE: | {}", emulator.cpu.registers.emulation_mode));
});
}
}
// Actually run the emulation