mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-02-06 16:29:55 +00:00
write labels
This commit is contained in:
parent
45af484839
commit
8b839841c1
@ -5,9 +5,20 @@ import cats.data.NonEmptyList
|
||||
sealed trait Color
|
||||
|
||||
object Color {
|
||||
implicit val ev: Operand[Color] =
|
||||
Operand.operandInt
|
||||
.contra(toByte, _.toString)
|
||||
implicit val colorOperand: Operand[Color] =
|
||||
new Operand[Color] {
|
||||
def toAddressLiteral(x: Color): String =
|
||||
"#" + x.toString.toLowerCase()
|
||||
|
||||
def toShow(x: Color): String =
|
||||
x.toString
|
||||
|
||||
def operandType: OperandType =
|
||||
ValueLiteral
|
||||
|
||||
def toDefinitionLiteral(x: Color): String =
|
||||
toByte(x).toString
|
||||
}
|
||||
|
||||
implicit val colorEnum: EnumAsm[Color] =
|
||||
new EnumAsm[Color] {
|
||||
|
@ -10,21 +10,6 @@ trait Operand[A] {
|
||||
def operandType: OperandType
|
||||
|
||||
def toDefinitionLiteral(x: A): String
|
||||
|
||||
def contra[B](f: B => A, show: B => String): Operand[B] =
|
||||
new Operand[B] {
|
||||
val operandType: OperandType =
|
||||
self.operandType
|
||||
|
||||
def toShow(x: B): String =
|
||||
show(x)
|
||||
|
||||
def toDefinitionLiteral(x: B): String =
|
||||
toAddressLiteral(x)
|
||||
|
||||
def toAddressLiteral(x: B): String =
|
||||
self.toAddressLiteral(f(x))
|
||||
}
|
||||
}
|
||||
|
||||
object Operand {
|
||||
|
@ -18,11 +18,11 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
}
|
||||
|
||||
doc.triplets shouldEqual List(
|
||||
("LDA", "#$01".some, "write White to screen (0)".some),
|
||||
("LDA", "#white".some, "write White to screen (0)".some),
|
||||
("STA", "$0200".some, "".some),
|
||||
("LDA", "#$05".some, "write Green to screen (1)".some),
|
||||
("LDA", "#green".some, "write Green to screen (1)".some),
|
||||
("STA", "$0201".some, "".some),
|
||||
("LDA", "#$08".some, "write Orange to screen (2)".some),
|
||||
("LDA", "#orange".some, "write Orange to screen (2)".some),
|
||||
("STA", "$0202".some, "".some)
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user