start from cli
This commit is contained in:
10
README.md
10
README.md
@@ -4,6 +4,16 @@ Just another implementation of a NES emulator written in Rust.
|
|||||||
|
|
||||||
**A note of warning:** This is an exploratory coding project with the aim to understand concepts of assembler and emulation in general. If you are looking for a cycle-accurate ready-to-use NES emulator to play some games, this is the wrong one.
|
**A note of warning:** This is an exploratory coding project with the aim to understand concepts of assembler and emulation in general. If you are looking for a cycle-accurate ready-to-use NES emulator to play some games, this is the wrong one.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
``` bash
|
||||||
|
./jane super_mario.nes
|
||||||
|
|
||||||
|
# With optional start address for the CPU (mainly for debugging)
|
||||||
|
./jane nestest.nes C000
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to compile with `--release` for 60 fps.
|
||||||
|
|
||||||
## what works
|
## what works
|
||||||
* CPU
|
* CPU
|
||||||
* Reading Roms (iNES)
|
* Reading Roms (iNES)
|
||||||
|
|||||||
18
src/main.rs
18
src/main.rs
@@ -10,6 +10,7 @@ extern crate fps_counter;
|
|||||||
|
|
||||||
mod nes;
|
mod nes;
|
||||||
|
|
||||||
|
use std::env;
|
||||||
use crate::nes::*;
|
use crate::nes::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use piston_window::*;
|
use piston_window::*;
|
||||||
@@ -35,14 +36,23 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
fn main() -> Result<(), Error> {
|
||||||
simple_logger::init_with_level(Level::Warn).unwrap();
|
simple_logger::init_with_level(Level::Info).unwrap();
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
if args.len() < 2 {
|
||||||
|
bail!("No cartridge supplied. Usage: ./jane cartridge.nes");
|
||||||
|
} else {
|
||||||
|
println!("Loading cartridge: {}", args[1]);
|
||||||
|
}
|
||||||
|
|
||||||
let mut nes = NES::new();
|
let mut nes = NES::new();
|
||||||
let cartridge = Path::new("test_roms/nestest.nes");
|
let cartridge = Cartridge::new(Path::new(&args[1]))?;
|
||||||
let cartridge = Cartridge::new(cartridge)?;
|
|
||||||
nes.insert_cartridge(cartridge);
|
nes.insert_cartridge(cartridge);
|
||||||
nes.start();
|
nes.start();
|
||||||
// nes.cpu.regs.pc = 0xC000;
|
if args.len() > 2 {
|
||||||
|
let pc = Addr::from_str_radix(&args[2], 16)?;
|
||||||
|
println!("Setting PC to {:#06x}", pc);
|
||||||
|
nes.cpu.regs.pc = pc;
|
||||||
|
}
|
||||||
|
|
||||||
// disassemble instructions
|
// disassemble instructions
|
||||||
let disasm = Disasm::disassemble(&nes.memory, 0xC000, 0xFFFF).unwrap();
|
let disasm = Disasm::disassemble(&nes.memory, 0xC000, 0xFFFF).unwrap();
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ impl NES {
|
|||||||
self.clock();
|
self.clock();
|
||||||
}
|
}
|
||||||
self.ppu.borrow_mut().frame_ready = false;
|
self.ppu.borrow_mut().frame_ready = false;
|
||||||
|
info!("clock {}", self.clock_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ impl CPU {
|
|||||||
self.curr_op = opcode;
|
self.curr_op = opcode;
|
||||||
let instruction = Instruction::decode_op(opcode);
|
let instruction = Instruction::decode_op(opcode);
|
||||||
|
|
||||||
info!("{:#06X} {:02X} {} A:{:02X} X:{:02X} Y:{:02X} P:{:02X} SP:{:02X} CYC:{}",
|
debug!("{:#06X} {:02X} {} A:{:02X} X:{:02X} Y:{:02X} P:{:02X} SP:{:02X} CYC:{}",
|
||||||
self.regs.pc-1, opcode, instruction.operation,
|
self.regs.pc-1, opcode, instruction.operation,
|
||||||
self.regs.a, self.regs.x, self.regs.y, self.regs.flags, self.regs.sp, self.cycles);
|
self.regs.a, self.regs.x, self.regs.y, self.regs.flags, self.regs.sp, self.cycles);
|
||||||
self.cycles_ahead += self.run_instruction(mem, instruction);
|
self.cycles_ahead += self.run_instruction(mem, instruction);
|
||||||
|
|||||||
Reference in New Issue
Block a user