Add more instructions. Fix JR bug. Start implementation of IO R/W

This commit is contained in:
Michael Smith
2025-09-03 09:11:16 +02:00
parent 7c494acc7e
commit 7678fda9e7
4 changed files with 272 additions and 4 deletions

46
gb/io.go Normal file
View File

@@ -0,0 +1,46 @@
package gb
import (
"fmt"
"os"
)
var SerialData [2]byte
func IORead(address uint16) byte {
if address == 0xFF01 {
return SerialData[0]
}
if address == 0xFF02 {
return SerialData[1]
}
if (address >= 0xFF04) && (address <= 0xFF07) {
fmt.Printf("Reading from IO: invalid address %X. Timer not yet implemented!", address)
os.Exit(1)
}
fmt.Printf("Reading from IO: invalid address %X", address)
os.Exit(1)
return 0
}
func IOWrite(address uint16, value byte) {
if address == 0xFF01 {
SerialData[0] = value
}
if address == 0xFF02 {
SerialData[1] = value
}
if (address >= 0xFF04) && (address <= 0xFF07) {
fmt.Printf("Writing to IO: invalid address %X. Timer not yet implemented!", address)
os.Exit(1)
}
fmt.Printf("Writing to IO: invalid address %X", address)
os.Exit(1)
}