mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 10:12:11 +00:00
Including more test roms and initializing the registers
This commit is contained in:
parent
f9d5cfaa02
commit
9d8d05c660
BIN
roms/cpu_instrs_individual/01-special.gb
Normal file
BIN
roms/cpu_instrs_individual/01-special.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/02-interrupts.gb
Normal file
BIN
roms/cpu_instrs_individual/02-interrupts.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/03-op sp,hl.gb
Normal file
BIN
roms/cpu_instrs_individual/03-op sp,hl.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/04-op r,imm.gb
Normal file
BIN
roms/cpu_instrs_individual/04-op r,imm.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/05-op rp.gb
Normal file
BIN
roms/cpu_instrs_individual/05-op rp.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/06-ld r,r.gb
Normal file
BIN
roms/cpu_instrs_individual/06-ld r,r.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/07-jr,jp,call,ret,rst.gb
Normal file
BIN
roms/cpu_instrs_individual/07-jr,jp,call,ret,rst.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/08-misc instrs.gb
Normal file
BIN
roms/cpu_instrs_individual/08-misc instrs.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/09-op r,r.gb
Normal file
BIN
roms/cpu_instrs_individual/09-op r,r.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/10-bit ops.gb
Normal file
BIN
roms/cpu_instrs_individual/10-bit ops.gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/11-op a,(hl).gb
Normal file
BIN
roms/cpu_instrs_individual/11-op a,(hl).gb
Normal file
Binary file not shown.
BIN
roms/cpu_instrs_individual/cpu_instrs.gb
Normal file
BIN
roms/cpu_instrs_individual/cpu_instrs.gb
Normal file
Binary file not shown.
@ -43,7 +43,7 @@ pub struct Bus {
|
|||||||
|
|
||||||
impl Bus {
|
impl Bus {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let game_rom = match ROM::load_file("roms/cpu_instrs.gb".to_string()) {
|
let game_rom = match ROM::load_file("roms/cpu_instrs_individual/01-special.gb".to_string()) {
|
||||||
Ok(rom) => rom,
|
Ok(rom) => rom,
|
||||||
_ => ROM::from_bytes(&[0; 0xFFFF])
|
_ => ROM::from_bytes(&[0; 0xFFFF])
|
||||||
};
|
};
|
||||||
|
37
src/cpu.rs
37
src/cpu.rs
@ -87,16 +87,16 @@ pub struct Registers {
|
|||||||
impl Registers {
|
impl Registers {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
a: 0,
|
a: 0x01,
|
||||||
f: 0b00000000, // The first 4 lower bits are always set to 0
|
f: 0xB0, // The first 4 lower bits are always set to 0
|
||||||
b: 0,
|
b: 0x00,
|
||||||
c: 0,
|
c: 0x00,
|
||||||
d: 0,
|
d: 0x00,
|
||||||
e: 0,
|
e: 0xD8,
|
||||||
h: 0,
|
h: 0x01,
|
||||||
l: 0,
|
l: 0x4D,
|
||||||
sp: 0,
|
sp: 0xFFFE,
|
||||||
pc: 0x100, // On power up, the Gameboy executes the instruction at hex 100
|
pc: 0x0100, // On power up, the Gameboy executes the instruction at hex 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,9 +275,20 @@ impl CPU {
|
|||||||
let program_counter = self.registers.get(Register::PC);
|
let program_counter = self.registers.get(Register::PC);
|
||||||
let parameter_bytes = CPU::read_parameter_bytes(program_counter, bus);
|
let parameter_bytes = CPU::read_parameter_bytes(program_counter, bus);
|
||||||
let opcode = CPU::parse_opcode(¶meter_bytes);
|
let opcode = CPU::parse_opcode(¶meter_bytes);
|
||||||
println!("{:?}", opcode);
|
// println!("Opcode: {:02X?} | PC: {:04X?} | Params: {:02X?}", opcode, self.registers.get(Register::PC), ¶meter_bytes);
|
||||||
println!("PC: {:04X?}", self.registers.get(Register::PC));
|
println!("A: {:02X} F: {:02X} B: {:02X} C: {:02X} D: {:02X} E: {:02X} H: {:02X} L: {:02X} SP: {:04X} PC: 00:{:04X} {:02X?}",
|
||||||
println!("{:02X?}", ¶meter_bytes);
|
self.registers.get(Register::A),
|
||||||
|
self.registers.get(Register::F),
|
||||||
|
self.registers.get(Register::B),
|
||||||
|
self.registers.get(Register::C),
|
||||||
|
self.registers.get(Register::D),
|
||||||
|
self.registers.get(Register::E),
|
||||||
|
self.registers.get(Register::H),
|
||||||
|
self.registers.get(Register::L),
|
||||||
|
self.registers.get(Register::SP),
|
||||||
|
self.registers.get(Register::PC),
|
||||||
|
parameter_bytes,
|
||||||
|
);
|
||||||
self.exec(opcode, bus);
|
self.exec(opcode, bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user