mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-09-28 12:54:45 +00:00
add snake length; more documentation
This commit is contained in:
parent
8b9828c63e
commit
0902288b15
@ -3,9 +3,11 @@ package com.htmlism.mos6502.dsl
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
/**
|
||||
* @param name A name for this location, used to alias its address
|
||||
*
|
||||
* @tparam A The input type of the write and the output type of the read
|
||||
*/
|
||||
case class ReadWriteLocation[A](address: Address) {
|
||||
case class ReadWriteLocation[A](name: String, address: Address) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
|
@ -3,9 +3,13 @@ package com.htmlism.mos6502.dsl
|
||||
//import com.htmlism.mos6502.model._
|
||||
|
||||
/**
|
||||
* For a memory-mapped device that may return different values across multiple reads (e.g. a random number generator)
|
||||
*
|
||||
* @param name A name for this device, used to alias its address
|
||||
*
|
||||
* @tparam A The return type of the read
|
||||
*/
|
||||
case class VolatileDevice[A](address: Address) {
|
||||
case class VolatileDevice[A](name: String, address: Address) {
|
||||
def read(implicit ctx: AssemblyContext): Unit = {
|
||||
val _ = ctx
|
||||
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
||||
|
@ -68,10 +68,11 @@ class Easy6502Spec extends AnyFlatSpec with should.Matchers {
|
||||
}
|
||||
|
||||
"snake" should "compile" in {
|
||||
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 sysRandom = VolatileDevice[Int]("sysRandom", 0xfe.z)
|
||||
val sysLastKey = VolatileDevice[AsciiValue]("sysLastKey", 0xff.z)
|
||||
val snakeDirection = ReadWriteLocation[Direction]("snakeDirection", 0x02.z)
|
||||
val appleLocation = ReadWriteLocation[Int]("appleLocation", 0x00.z)
|
||||
val snakeLength = ReadWriteLocation[Int]("snakeLength", 0x00.z)
|
||||
|
||||
val initSnake =
|
||||
sub("initSnake") { implicit a =>
|
||||
|
Loading…
Reference in New Issue
Block a user