mirror of
https://github.com/Candygoblen123/SwiftNES.git
synced 2024-11-21 17:46:23 -06:00
PPU: background rendering
This commit is contained in:
parent
be170bf750
commit
f9efe23b0b
@ -157,9 +157,10 @@ class CPU {
|
||||
func run(onCycle: @escaping () -> (), onComplete: @escaping () -> ()) {
|
||||
let opcodes = OPCODES_MAP
|
||||
while true {
|
||||
if let _nmi = bus.pollNMI() {
|
||||
|
||||
if bus.pollNMI() != nil {
|
||||
print(programCounter)
|
||||
interrupt(.NMI)
|
||||
print(programCounter)
|
||||
}
|
||||
processOpcodes(onCycle: onCycle, opcodes: opcodes) {
|
||||
onComplete()
|
||||
|
@ -9,7 +9,7 @@ func dumpCpuState(_ cpu: CPU) -> String {
|
||||
{
|
||||
let (addr, _) = cpu.getAbsoluteAddress(opcode.mode, addr: cpu.programCounter + 1)
|
||||
|
||||
return (addr, cpu.memRead(addr))
|
||||
return (addr, 0)//cpu.memRead(addr))
|
||||
}()
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ class Bus {
|
||||
}
|
||||
|
||||
func pollNMI() -> UInt8? {
|
||||
ppu.nmiInterrupt
|
||||
ppu.pollNMI()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class NesPPU {
|
||||
var scanline: UInt16 = 0
|
||||
var cycles: Int = 0
|
||||
|
||||
var nmiInterrupt: UInt8?
|
||||
var nmiInterrupt: UInt8? = nil
|
||||
|
||||
init(_ chrRom: [UInt8], _ mirroring: Mirroring) {
|
||||
self.chrRom = chrRom
|
||||
@ -52,6 +52,12 @@ class NesPPU {
|
||||
return false
|
||||
}
|
||||
|
||||
func pollNMI() -> UInt8? {
|
||||
let tmp = self.nmiInterrupt
|
||||
self.nmiInterrupt = nil
|
||||
return tmp
|
||||
}
|
||||
|
||||
func writeToPPUAddr(_ value: UInt8) {
|
||||
addr.update(value)
|
||||
}
|
||||
@ -110,7 +116,7 @@ class NesPPU {
|
||||
|
||||
func writeToData(_ data: UInt8) {
|
||||
let addr = addr.get()
|
||||
//print("\(addr): \(data)")
|
||||
print("\(addr): \(data)")
|
||||
switch addr {
|
||||
case 0...0x1fff:
|
||||
print("Attempt to write to chr rom space \(addr)!")
|
||||
|
@ -28,7 +28,7 @@ struct ControlRegister: OptionSet {
|
||||
static let GENERATE_NMI = ControlRegister(rawValue: 0b10000000)
|
||||
|
||||
func vramAddrIncrement() -> UInt8 {
|
||||
if self.contains(.VRAM_ADD_INCREMENT) {
|
||||
if !self.contains(.VRAM_ADD_INCREMENT) {
|
||||
1
|
||||
} else {
|
||||
32
|
||||
@ -40,7 +40,7 @@ struct ControlRegister: OptionSet {
|
||||
}
|
||||
|
||||
func backgroundPatternAddr() -> Int {
|
||||
if self.contains(.BACKROUND_PATTERN_ADDR) {
|
||||
if !self.contains(.BACKROUND_PATTERN_ADDR) {
|
||||
0
|
||||
} else {
|
||||
0x1000
|
||||
|
Loading…
Reference in New Issue
Block a user