debugging
This commit is contained in:
parent
a32a6b8eea
commit
066e977687
|
@ -12,7 +12,7 @@ pub struct Triangle {
|
||||||
waveform_counter: usize,
|
waveform_counter: usize,
|
||||||
|
|
||||||
pub length_counter: u8,
|
pub length_counter: u8,
|
||||||
length_counter_halt: bool, // (this bit is also the linear counter's control flag) / (this bit is also the length counter halt flag)
|
length_counter_halt: bool, // (this bit is also the linear counter's control flag)
|
||||||
|
|
||||||
linear_counter: u8,
|
linear_counter: u8,
|
||||||
counter_reload_value: u8,
|
counter_reload_value: u8,
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl Cpu {
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
// assert!(self.memory_at(0xAD79, 141) == UNDERGROUND_LEVEL.to_vec() && self.memory_at(0xA133, 45) == UNDERGROUND_ENEMIES.to_vec());
|
// assert!(self.memory_at(0xAD79, 141) == UNDERGROUND_LEVEL.to_vec() && self.memory_at(0xA133, 45) == UNDERGROUND_ENEMIES.to_vec());
|
||||||
let pc = self.PC;
|
// let pc = self.PC;
|
||||||
// if address == 0x06D6 {
|
// if address == 0x06D6 {
|
||||||
// // let mem = self.memory_at(0xAD79, 141);
|
// // let mem = self.memory_at(0xAD79, 141);
|
||||||
// // println!("memory at 0xAD79: {:02X?}", mem);
|
// // println!("memory at 0xAD79: {:02X?}", mem);
|
||||||
|
@ -186,31 +186,31 @@ impl Cpu {
|
||||||
// self.more += 24;
|
// self.more += 24;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if pc == 0xB1E5 {
|
// if pc == 0xB1E5 {
|
||||||
println!("===========================");
|
// println!("===========================");
|
||||||
if self.more == 0 {
|
// if self.more == 0 {
|
||||||
self.more += 24;
|
// self.more += 24;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if self.more > 0 {
|
// if self.more > 0 {
|
||||||
let operands = match num_bytes {
|
// let operands = match num_bytes {
|
||||||
1 => " ".to_string(),
|
// 1 => " ".to_string(),
|
||||||
2 => format!("{:02X} ", self.read(pc + 1)),
|
// 2 => format!("{:02X} ", self.read(pc + 1)),
|
||||||
3 => format!("{:02X} {:02X}", self.read(pc + 1), self.read(pc+2)),
|
// 3 => format!("{:02X} {:02X}", self.read(pc + 1), self.read(pc+2)),
|
||||||
_ => "error".to_string(),
|
// _ => "error".to_string(),
|
||||||
};
|
// };
|
||||||
print!("{:04X} {:02X} {} {} A:{:02X} X:{:02X} Y:{:02X} P:{:02X} SP:{:02X}",
|
// print!("{:04X} {:02X} {} {} A:{:02X} X:{:02X} Y:{:02X} P:{:02X} SP:{:02X}",
|
||||||
pc, self.read(pc), operands, OPCODE_DISPLAY_NAMES[opcode],
|
// pc, self.read(pc), operands, OPCODE_DISPLAY_NAMES[opcode],
|
||||||
self.A, self.X, self.Y, self.P, self.S,
|
// self.A, self.X, self.Y, self.P, self.S,
|
||||||
);
|
// );
|
||||||
// let mut zpg = Vec::<u8>::new();
|
// // let mut zpg = Vec::<u8>::new();
|
||||||
// for i in 0..32 {
|
// // for i in 0..32 {
|
||||||
// zpg.push(self.read(i));
|
// // zpg.push(self.read(i));
|
||||||
// }
|
// // }
|
||||||
// print!(" zpg: {:x?}", zpg);
|
// // print!(" zpg: {:x?}", zpg);
|
||||||
print!("\n");
|
// print!("\n");
|
||||||
self.more -= 1;
|
// self.more -= 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// advance program counter according to how many bytes that instruction operated on
|
// advance program counter according to how many bytes that instruction operated on
|
||||||
self.advance_pc(mode);
|
self.advance_pc(mode);
|
||||||
|
@ -252,6 +252,20 @@ impl Cpu {
|
||||||
// if address == 0x06D6 {
|
// if address == 0x06D6 {
|
||||||
// println!("writing 0x{:02X} to 0x{:04X}", val, address);
|
// println!("writing 0x{:02X} to 0x{:04X}", val, address);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
let vars = vec![
|
||||||
|
("PlayerEntranceCtrl", 0x0710),
|
||||||
|
("AltEntranceControl", 0x0752),
|
||||||
|
("EntrancePage", 0x0751),
|
||||||
|
("AreaPointer", 0x0750),
|
||||||
|
("AreaAddrsLOffset", 0x074f),
|
||||||
|
];
|
||||||
|
for i in vars.iter() {
|
||||||
|
if i.1 == address {
|
||||||
|
println!("writing 0x{:02X} to {}", val, i.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
match address {
|
match address {
|
||||||
0x0000..=0x1FFF => self.mem[address % 0x0800] = val,
|
0x0000..=0x1FFF => self.mem[address % 0x0800] = val,
|
||||||
0x2000..=0x3FFF => self.write_ppu_reg(address % 8, val),
|
0x2000..=0x3FFF => self.write_ppu_reg(address % 8, val),
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -202,5 +202,15 @@ shows the program counter at 0xB1EF, meaning I was right that the routine's addr
|
||||||
Anyway, hook PC == $B1E5.
|
Anyway, hook PC == $B1E5.
|
||||||
|
|
||||||
Ok, so, comparing logs with the good emulator down the WORKING pipe in 1-1 shows a divergence in behavior based on loading value 0x6E from $0755 into the accumulator,
|
Ok, so, comparing logs with the good emulator down the WORKING pipe in 1-1 shows a divergence in behavior based on loading value 0x6E from $0755 into the accumulator,
|
||||||
and comparing that to 0x50. What's at $0755? Player_Pos_ForScroll.
|
and comparing that to 0x50. What's at $0755? Player_Pos_ForScroll, which is just Mario's horizontal position on screen.
|
||||||
|
And that's the only difference, over and over, so doesn't really matter.
|
||||||
|
Now need to see what's different when we drop into the bad room. 1200 lines in log from one pipe,
|
||||||
|
25 lines each (24 and a separator) so 48 iterations of VerticalPipeEntry per pipe.
|
||||||
|
But logs for VerticalPipeEntry for the bad room also seem to match the good emulator except for the Player_Pos_ForScroll...
|
||||||
|
Other suspicious variables:
|
||||||
|
PlayerEntranceCtrl
|
||||||
|
AltEntranceControl
|
||||||
|
EntrancePage
|
||||||
|
AreaPointer
|
||||||
|
AreaAddrsLOffset
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue