diff --git a/src/main/scala/com/htmlism/mos6502/dsl/AsmDocumentContext.scala b/src/main/scala/com/htmlism/mos6502/dsl/AsmDocumentContext.scala index 7e6b58f..95f4cdd 100644 --- a/src/main/scala/com/htmlism/mos6502/dsl/AsmDocumentContext.scala +++ b/src/main/scala/com/htmlism/mos6502/dsl/AsmDocumentContext.scala @@ -50,14 +50,22 @@ case class Subroutine(name: String, fragment: AsmFragment, jumpRegistry: ListSet case class DefinitionGroup(comment: String, xs: List[Definition[_]]) extends TopLevelAsmDocumentFragment { def toAsm: String = { - val commentLine = + val groupCommentLine = "; " + comment val definitionLines = xs - .map(d => f"define ${d.name}%-20s${d.value}") + .map { d => + d.comment match { + case Some(c) => + f"define ${d.name}%-20s${d.value} ; $c" - (commentLine :: definitionLines) + case None => + f"define ${d.name}%-20s${d.value}" + } + } + + (groupCommentLine :: definitionLines) .mkString("\n") } } @@ -75,6 +83,9 @@ class DefinitionGroupContext { DefinitionGroup(s, xs.toList) } +/** + * @param comment Typically used by resources to describe their type safety + */ case class Definition[A: Operand](name: String, x: A, comment: Option[String]) { lazy val value: String = implicitly[Operand[A]] diff --git a/src/main/scala/com/htmlism/mos6502/dsl/ReadWriteLocation.scala b/src/main/scala/com/htmlism/mos6502/dsl/ReadWriteLocation.scala index 6300799..4464f88 100644 --- a/src/main/scala/com/htmlism/mos6502/dsl/ReadWriteLocation.scala +++ b/src/main/scala/com/htmlism/mos6502/dsl/ReadWriteLocation.scala @@ -24,7 +24,7 @@ object ReadWriteLocation { new Definable[ReadWriteLocation[A]] { def toDefinitions(x: ReadWriteLocation[A]): List[Definition[ZeroAddress]] = List { - Definition(x.name, x.address) + Definition(x.name, x.address, "Read/write location for A values") } } } diff --git a/src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala b/src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala index 1e9392c..c810604 100644 --- a/src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala +++ b/src/main/scala/com/htmlism/mos6502/dsl/VolatileDevice.scala @@ -21,7 +21,7 @@ object VolatileDevice { new Definable[VolatileDevice[A]] { def toDefinitions(x: VolatileDevice[A]): List[Definition[ZeroAddress]] = List { - Definition(x.name, x.address) + Definition(x.name, x.address, "Volatile generator for A values") } } }