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