mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-06-01 15:41:35 +00:00
25 lines
832 B
Scala
25 lines
832 B
Scala
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](name: String, address: ZeroAddress):
|
|
def read(using ctx: AssemblyContext): Unit =
|
|
val _ = ctx
|
|
// ctx.push(LDA, ev, s"write ${ev.toShow(x)} to $name ($n)")
|
|
|
|
object VolatileDevice:
|
|
given namedResourceForVolatileDevice[A]: NamedResource[VolatileDevice[A]] =
|
|
new NamedResource[VolatileDevice[A]]:
|
|
def toDefinitions(x: VolatileDevice[A]): List[Definition[ZeroAddress]] =
|
|
List:
|
|
Definition(x.name, x.address, "Volatile generator for A values")
|