mirror of
https://github.com/Candygoblen123/SwiftNES.git
synced 2025-09-10 20:42:03 -05:00
PPU: impl scrolling
This commit is contained in:
@@ -28,6 +28,9 @@ class NesPPU {
|
||||
func tick(_ cycles: UInt8) -> Bool {
|
||||
self.cycles += Int(cycles)
|
||||
if self.cycles >= 341 {
|
||||
if checkSprite0Hit(self.cycles) {
|
||||
status.setSpriteZeroHit(true)
|
||||
}
|
||||
self.cycles = self.cycles - 341
|
||||
self.scanline += 1
|
||||
|
||||
@@ -50,6 +53,12 @@ class NesPPU {
|
||||
return false
|
||||
}
|
||||
|
||||
func checkSprite0Hit(_ cycle: Int) -> Bool {
|
||||
let y = Int(oamData[0])
|
||||
let x = Int(oamData[0])
|
||||
return (y == scanline) && x <= cycle && mask.showSprites()
|
||||
}
|
||||
|
||||
func pollNMI() -> UInt8? {
|
||||
let tmp = self.nmiInterrupt
|
||||
self.nmiInterrupt = nil
|
||||
|
@@ -70,4 +70,19 @@ struct ControlRegister: OptionSet {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
func nametableAddr() -> UInt16 {
|
||||
switch rawValue & 0b11 {
|
||||
case 0:
|
||||
0x2000
|
||||
case 1:
|
||||
0x2400
|
||||
case 2:
|
||||
0x2800
|
||||
case 3:
|
||||
0x2c00
|
||||
default:
|
||||
fatalError("naemtableAddr: Not possible!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user