Skip to content

Commit

Permalink
Properly emulate RAM size for LoROM carts
Browse files Browse the repository at this point in the history
  • Loading branch information
twvd committed Dec 11, 2023
1 parent 0fd4269 commit 1fc2505
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/snes/cartridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl BusMember<Address> for Cartridge {

// LoROM SRAM
(0x70..=0x7D, 0x0000..=0x7FFF) if !self.hirom => {
Some(self.ram[(bank - 0x70) * 0x8000 + addr])
Some(self.ram[(bank - 0x70) * 0x8000 + addr & self.ram_mask])
}

// HiROM
Expand All @@ -220,7 +220,7 @@ impl BusMember<Address> for Cartridge {

// LoROM SRAM
(0x70..=0x7D, 0x0000..=0x7FFF) if !self.hirom => {
Some(self.ram[(bank - 0x70) * 0x8000 + addr] = val)
Some(self.ram[(bank - 0x70) * 0x8000 + addr & self.ram_mask] = val)
}

_ => None,
Expand Down
3 changes: 2 additions & 1 deletion src/snes/cpu_spc700/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ where
InstructionType::TSET1 => self.op_tsetclr1(instr, true),
InstructionType::TCLR1 => self.op_tsetclr1(instr, false),

InstructionType::SLEEP | InstructionType::STOP => panic!("SPC700 halted!"),
InstructionType::SLEEP => panic!("SPC700 hit SLEEP!"),
InstructionType::STOP => panic!("SPC700 hit STOP!"),
}
}

Expand Down

0 comments on commit 1fc2505

Please sign in to comment.