28 lines
1.0 KiB
Kotlin
28 lines
1.0 KiB
Kotlin
package de.platon42.mc68kemu
|
|
|
|
|
|
@OptIn(ExperimentalUnsignedTypes::class)
|
|
class Rom(start: Int, val rom: UByteArray) : MemoryRegion(start, rom.size) {
|
|
override fun readByte(address: Int): Int {
|
|
return rom[address - start].toInt()
|
|
}
|
|
|
|
override fun readWord(address: Int): Int {
|
|
val i = address - start
|
|
return (rom[i].toInt() shl 8) or rom[i + 1].toInt()
|
|
}
|
|
|
|
override fun readLong(address: Int): Int {
|
|
val i = address - start
|
|
return (rom[i].toInt() shl 24) or
|
|
(rom[i + 1].toInt() shl 16) or
|
|
(rom[i + 2].toInt() shl 8) or
|
|
rom[i + 3].toInt()
|
|
}
|
|
|
|
override fun writeByte(address: Int, value: Int) = throw UnsupportedOperationException("Attempt to write to rom ${address.toHex(8)}")
|
|
|
|
override fun writeWord(address: Int, value: Int) = throw UnsupportedOperationException("Attempt to write to rom ${address.toHex(8)}")
|
|
|
|
override fun writeLong(address: Int, value: Int) = throw UnsupportedOperationException("Attempt to write to rom ${address.toHex(8)}")
|
|
} |