diff --git a/README.md b/README.md index 8f04f8e..a0527d7 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ - [Easy 6502](https://skilldrick.github.io/easy6502/) - [Annotated Snake6502](https://gist.github.com/wkjagt/9043907) +- [Ultimate Commodore 64 Reference - 6502](https://www.pagetable.com/c64ref/6502/) ## Colophon diff --git a/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/CpuState.scala b/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/CpuState.scala new file mode 100644 index 0000000..2542736 --- /dev/null +++ b/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/CpuState.scala @@ -0,0 +1,35 @@ +package com.htmlism.firepower.cpu + +case class CpuState( + accumulator: UByte, + xRegister: UByte, + yRegister: UByte, + stackPointer: UByte, + programCounterLo: UByte, + programCounterHi: UByte, + negative: Boolean, + overflow: Boolean, + break: Boolean, + decimal: Boolean, + interruptsDisabled: Boolean, + zero: Boolean, + carry: Boolean +) + +object CpuState: + val empty: CpuState = + CpuState( + accumulator = UByte(0), + xRegister = UByte(0), + yRegister = UByte(0), + stackPointer = UByte(0), + programCounterLo = UByte(0), + programCounterHi = UByte(0), + negative = false, + overflow = false, + break = false, + decimal = false, + interruptsDisabled = false, + zero = false, + carry = false + ) diff --git a/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/UByte.scala b/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/UByte.scala new file mode 100644 index 0000000..8d38a53 --- /dev/null +++ b/firepower-cpu/src/main/scala/com/htmlism/firepower/cpu/UByte.scala @@ -0,0 +1,15 @@ +package com.htmlism.firepower.cpu + +opaque type UByte = + Byte + +extension (b: UByte) + def inc: UByte = + ((b & 0xff) + 1).toByte + + def dec: UByte = + ((b & 0xff) - 1).toByte + +object UByte: + def apply(n: Int): UByte = + n.toByte