mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-22 09:30:45 +00:00
articulate device types
This commit is contained in:
parent
b0e40b3e36
commit
4859ae575a
@ -1,6 +1,8 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
sealed trait Address
|
||||
sealed trait Address {
|
||||
def n: Int
|
||||
}
|
||||
|
||||
object ZeroAddress {
|
||||
implicit val operandZero: Operand[ZeroAddress] =
|
||||
|
15
src/main/scala/com/htmlism/mos6502/dsl/ReadWriteDevice.scala
Normal file
15
src/main/scala/com/htmlism/mos6502/dsl/ReadWriteDevice.scala
Normal file
@ -0,0 +1,15 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
case class ReadWriteDevice[A](address: Address) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
}
|
||||
|
||||
def write(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(STA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
}
|
||||
}
|
10
src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala
Normal file
10
src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala
Normal file
@ -0,0 +1,10 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
case class VolatileDevice[A](address: Address) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
}
|
||||
}
|
@ -68,6 +68,9 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
}
|
||||
|
||||
"snake" should "compile" in {
|
||||
val sysRandom = VolatileDevice[Int](0xfe.addr)
|
||||
val sysLastKey = VolatileDevice[AsciiValue](0xff.addr)
|
||||
|
||||
val initSnake =
|
||||
sub("initSnake") { implicit a =>
|
||||
registers.X.incr
|
||||
@ -130,6 +133,9 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
mapping[AsciiValue]
|
||||
|
||||
asm { implicit a =>
|
||||
sysRandom.read
|
||||
sysLastKey.read
|
||||
|
||||
jump(init)
|
||||
jump(loop)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user