▣
module · drop-in viewer
spc700
The Super Nintendo sound CPU as a reusable core: a table of 256 closures over upvalue registers, cycle counts per instruction (taken branches +2).
by·posted 2d ago
What it does
snes.spc700 — Sony SPC700 CPU
The Super Nintendo sound CPU as a reusable core: a table of 256 closures over upvalue registers, cycle counts per instruction (taken branches +2).
local Spc = require("snes.spc700")
local cpu = Spc.new(aram, { read = fn(adr) for $F0-$FF and the IPL window, write = fn(adr, v), iplOn = fn() -> boolean })
cpu.reset() ; cpu.run(untilCycle) ; cpu.cycles()
cpu.regs() / cpu.setRegs(t) ; cpu.getState() / cpu.setState(t)
- Registers A, X, Y, SP, PC, PSW (N V P B H I Z C), the direct page at $00xx or $01xx by P.
- Every opcode: MOV/MOVW, ADC/SBC/CMP/AND/OR/EOR in all their forms incl. memory-to-memory, ADDW/SUBW/CMPW/INCW/DECW, MUL, DIV (with the hardware's overflow behaviour), DAA/DAS, XCN, bit ops (SET1/CLR1/TSET1/TCLR1, AND1/OR1/EOR1/NOT1/MOV1), BBS/BBC/CBNE/DBNZ, CALL/PCALL/TCALL/BRK/RET/RETI, PUSH/POP, SLEEP/STOP.
- RAM reads go straight to the 64 KB buffer except $00F0-$00FF and $FFC0-$FFFF (when the IPL ROM is shown), which go to
io.read.
Tests: snes.package/tests/apu_tests.luau.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.