Skip to content

Commit

Permalink
Add mocked APU communications
Browse files Browse the repository at this point in the history
This produces a fake handshake that is just enough
for some games to be satisfied and proceed with
their boot process.
  • Loading branch information
twvd committed Nov 5, 2023
1 parent a5b24c4 commit ed34ab3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/snes/bus/mainbus.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::cell::Cell;
use std::cell::{Cell, RefCell};

use anyhow::Result;
use dbg_hex::dbg_hex;
Expand Down Expand Up @@ -54,6 +54,8 @@ where

/// NMITIMEN register
nmitimen: u8,

apumock: RefCell<[u8; 4]>,
}

enum DMADirection {
Expand Down Expand Up @@ -156,6 +158,8 @@ where
intreq_nmi: false,
intreq_int: false,
nmitimen: 0,

apumock: RefCell::new([0xAA, 0, 0, 0]),
}
}

Expand Down Expand Up @@ -215,6 +219,18 @@ where
0x0000..=0x1FFF => Some(self.wram[addr]),
// Picture Processing Unit
0x2100..=0x213F => self.ppu.read(fulladdr),
// APU comms
0x2140..=0x217F => {
let ch = (addr - 0x2140) % 4;
let mut apumock = self.apumock.borrow_mut();
let value = apumock[ch];
apumock[ch] = match ch {
0 => 0xAA,
1 => 0xBB,
_ => 0,
};
Some(value)
}
// WMDATA - WRAM Data Read/Write (R/W)
0x2180 => {
let addr = self.wmadd.get();
Expand Down Expand Up @@ -315,6 +331,13 @@ where
0x0000..=0x1FFF => Some(self.wram[addr] = val),
// Picture Processing Unit
0x2100..=0x213F => self.ppu.write(fulladdr, val),
// APU comms
0x2140..=0x217F => {
let ch = (addr - 0x2140) % 4;
let mut apumock = self.apumock.borrow_mut();
apumock[ch] = val;
Some(())
}
// WMDATA - WRAM Data Read/Write
0x2180 => {
let addr = self.wmadd.get();
Expand Down

0 comments on commit ed34ab3

Please sign in to comment.