mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-02-03 12:30:21 +00:00
add more devices
This commit is contained in:
parent
4859ae575a
commit
58f15e85e8
@ -2,14 +2,17 @@ package com.htmlism.mos6502.dsl
|
||||
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
case class ReadWriteDevice[A](address: Address) {
|
||||
/**
|
||||
* @tparam A The input type of the write and the output type of the read
|
||||
*/
|
||||
case class ReadWriteLocation[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
|
||||
def write(x: A)(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = (x, ctx)
|
||||
// ctx.push(STA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
}
|
||||
}
|
@ -2,6 +2,9 @@ package com.htmlism.mos6502.dsl
|
||||
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
/**
|
||||
* @tparam A The return type of the read
|
||||
*/
|
||||
case class VolatileDevice[A](address: Address) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
|
@ -68,8 +68,10 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
}
|
||||
|
||||
"snake" should "compile" in {
|
||||
val sysRandom = VolatileDevice[Int](0xfe.addr)
|
||||
val sysLastKey = VolatileDevice[AsciiValue](0xff.addr)
|
||||
val sysRandom = VolatileDevice[Int](0xfe.z)
|
||||
val sysLastKey = VolatileDevice[AsciiValue](0xff.z)
|
||||
val snakeDirection = ReadWriteLocation[Direction](0x02.z)
|
||||
val appleLocation = ReadWriteLocation[Int](0x00.z)
|
||||
|
||||
val initSnake =
|
||||
sub("initSnake") { implicit a =>
|
||||
@ -135,6 +137,8 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
asm { implicit a =>
|
||||
sysRandom.read
|
||||
sysLastKey.read
|
||||
snakeDirection.read
|
||||
appleLocation.read
|
||||
|
||||
jump(init)
|
||||
jump(loop)
|
||||
|
Loading…
x
Reference in New Issue
Block a user