This commit is contained in:
Mark Canlas 2020-08-13 00:42:21 -04:00
parent 7216023708
commit f221eacd42

View File

@ -35,6 +35,13 @@ object DslDemo extends App {
A.add(0xc4)
}
// first color example
withAssemblyContext { implicit ctx =>
cpu.A = Color.White : Color
cpu.A = Color.Green : Color
cpu.A = Color.Orange : Color
}
def withAssemblyContext(f: AssemblyContext => Unit): Unit = {
val ctx: AssemblyContext =
new AssemblyContext
@ -92,6 +99,13 @@ class CPU {
ctx.pushAsm(f"LDA #$$$n%h")
}
def A_=[A : EnumAsByte](x: A)(implicit ctx: AssemblyContext): Unit = {
val n = implicitly[EnumAsByte[A]].toByte(x)
ctx.describe(s"set a to value $n")
ctx.pushAsm(f"LDA #$$$n%h")
}
def A_=(reg: registers.DestinationA)(implicit ctx: AssemblyContext): Unit =
ctx.describe(s"set a to register $reg")