Implement timer, some IO operations and more CPU instructions

This commit is contained in:
Michael Smith
2025-09-05 11:15:41 +02:00
parent 7678fda9e7
commit b860999dc8
8 changed files with 243 additions and 37 deletions

View File

@@ -6,41 +6,40 @@ import (
)
var SerialData [2]byte
var InterruptFlags byte
func IORead(address uint16) byte {
if address == 0xFF01 {
return SerialData[0]
}
if address == 0xFF02 {
} else if address == 0xFF02 {
return SerialData[1]
}
if (address >= 0xFF04) && (address <= 0xFF07) {
fmt.Printf("Reading from IO: invalid address %X. Timer not yet implemented!", address)
} else if (address >= 0xFF04) && (address <= 0xFF07) {
return timer.Read(address)
} else if address == 0xFF0F {
return InterruptFlags
} else if (address >= 0xFF10) && (address <= 0xFF3F) {
// Ignore sound
return 0
} else {
fmt.Printf("Reading from IO: invalid address %X\n", 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 {
} else if address == 0xFF02 {
SerialData[1] = value
}
if (address >= 0xFF04) && (address <= 0xFF07) {
fmt.Printf("Writing to IO: invalid address %X. Timer not yet implemented!", address)
} else if (address >= 0xFF04) && (address <= 0xFF07) {
timer.Write(address, value)
} else if address == 0xFF0F {
InterruptFlags = value
} else if (address >= 0xFF10) && (address <= 0xFF3F) {
// Ignore sound
} else {
fmt.Printf("Writing to IO: invalid address %X\n", address)
os.Exit(1)
}
fmt.Printf("Writing to IO: invalid address %X", address)
os.Exit(1)
}