mirror of
https://github.com/FranLMSP/snes.git
synced 2026-10-05 08:55:18 -04:00
update readme, remove todo! from bus and display registers
This commit is contained in:
@@ -2,13 +2,15 @@
|
|||||||
Work in progress experimental SNES emulator written in Rust.
|
Work in progress experimental SNES emulator written in Rust.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
* https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM
|
* SNES General:
|
||||||
* https://ersanio.gitbook.io/assembly-for-the-snes
|
* https://wiki.superfamicom.org
|
||||||
* https://wiki.superfamicom.org
|
* https://snesdev.mesen.ca/wiki/index.php
|
||||||
* https://snesdev.mesen.ca/wiki/index.php
|
* https://problemkaputt.de/fullsnes.htm
|
||||||
* https://problemkaputt.de/fullsnes.htm
|
* 65816 CPU:
|
||||||
* BCD addition and substraction: https://ehaskins.com/2018-01-30%20Z80%20DAA/
|
* https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM
|
||||||
* 65816 programming manual: https://www.nesdev.org/w/images/default/7/76/Programmanual.pdf
|
* 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
|
* Test ROMs
|
||||||
* PeterLemon's test ROMs: https://github.com/PeterLemon/SNES
|
* PeterLemon's test ROMs: https://github.com/PeterLemon/SNES
|
||||||
* Retro Game Mechanics Explained SNES playlists:
|
* Retro Game Mechanics Explained SNES playlists:
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
use crate::ppu::PPU;
|
use crate::ppu::PPU;
|
||||||
|
use crate::cpu::internal_registers::InternalRegisters;
|
||||||
|
use crate::rom::ROM;
|
||||||
|
use crate::rom::lo_rom::LoROM;
|
||||||
|
|
||||||
pub struct Bus {
|
pub struct Bus {
|
||||||
wram: [u8; 0x10000],
|
wram: [u8; 0x10000],
|
||||||
pub ppu: PPU,
|
pub ppu: PPU,
|
||||||
|
pub rom: Box<dyn ROM>,
|
||||||
|
pub internal_registers: InternalRegisters,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug)]
|
#[derive(PartialEq, Debug)]
|
||||||
@@ -19,6 +24,8 @@ impl Bus {
|
|||||||
Self {
|
Self {
|
||||||
wram: [0; 0x10000],
|
wram: [0; 0x10000],
|
||||||
ppu: PPU::new(),
|
ppu: PPU::new(),
|
||||||
|
rom: Box::new(LoROM::new()),
|
||||||
|
internal_registers: InternalRegisters::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +61,9 @@ impl Bus {
|
|||||||
match section {
|
match section {
|
||||||
MemoryMap::WRAM => self.read_wram(address),
|
MemoryMap::WRAM => self.read_wram(address),
|
||||||
MemoryMap::PPU => self.ppu.registers.read(address as u16),
|
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 {
|
match section {
|
||||||
MemoryMap::WRAM => self.write_wram(address, value),
|
MemoryMap::WRAM => self.write_wram(address, value),
|
||||||
MemoryMap::PPU => self.ppu.registers.write(address as u16, 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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,3 +4,4 @@ pub mod bus;
|
|||||||
pub mod registers;
|
pub mod registers;
|
||||||
pub mod instructions;
|
pub mod instructions;
|
||||||
pub mod cycles;
|
pub mod cycles;
|
||||||
|
pub mod internal_registers;
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ fn main() {
|
|||||||
if let Some(path) = FileDialog::new()
|
if let Some(path) = FileDialog::new()
|
||||||
.pick_file()
|
.pick_file()
|
||||||
{
|
{
|
||||||
match emulator.rom.load(&String::from(path.to_str().unwrap())) {
|
match emulator.bus.rom.load(&String::from(path.to_str().unwrap())) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
state.emulation.is_paused = false;
|
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
|
// Actually run the emulation
|
||||||
|
|||||||
Reference in New Issue
Block a user