defines block

This commit is contained in:
Mark Canlas 2022-12-06 15:38:39 -05:00
parent 77785bef50
commit 9b4aac9a62
4 changed files with 44 additions and 52 deletions

View File

@ -1,22 +1,22 @@
; define COLOR_Black 0
; define COLOR_White 1
; define COLOR_Red 2
; define COLOR_Cyan 3
; define COLOR_Purple 4
; define COLOR_Green 5
; define COLOR_Blue 6
; define COLOR_Yellow 7
; define COLOR_Orange 8
; define COLOR_Brown 9
; define COLOR_LightRed 10
; define COLOR_DarkGrey 11
; define COLOR_Grey 12
; define COLOR_LightGreen 13
; define COLOR_LightBlue 14
; define COLOR_LightGrey 15
define COLOR_Black 0
define COLOR_White 1
define COLOR_Red 2
define COLOR_Cyan 3
define COLOR_Purple 4
define COLOR_Green 5
define COLOR_Blue 6
define COLOR_Yellow 7
define COLOR_Orange 8
define COLOR_Brown 9
define COLOR_LightRed 10
define COLOR_DarkGrey 11
define COLOR_Grey 12
define COLOR_LightGreen 13
define COLOR_LightBlue 14
define COLOR_LightGrey 15
; define SCREEN TODO
define SCREEN TODO
; Screen(0) = White

View File

@ -1,22 +1,22 @@
; define COLOR_Black 0
; define COLOR_White 1
; define COLOR_Red 2
; define COLOR_Cyan 3
; define COLOR_Purple 4
; define COLOR_Green 5
; define COLOR_Blue 6
; define COLOR_Yellow 7
; define COLOR_Orange 8
; define COLOR_Brown 9
; define COLOR_LightRed 10
; define COLOR_DarkGrey 11
; define COLOR_Grey 12
; define COLOR_LightGreen 13
; define COLOR_LightBlue 14
; define COLOR_LightGrey 15
define COLOR_Black 0
define COLOR_White 1
define COLOR_Red 2
define COLOR_Cyan 3
define COLOR_Purple 4
define COLOR_Green 5
define COLOR_Blue 6
define COLOR_Yellow 7
define COLOR_Orange 8
define COLOR_Brown 9
define COLOR_LightRed 10
define COLOR_DarkGrey 11
define COLOR_Grey 12
define COLOR_LightGreen 13
define COLOR_LightBlue 14
define COLOR_LightGrey 15
; define SCREEN TODO
define SCREEN TODO
; Screen(0) = White

View File

@ -9,6 +9,8 @@ object AsmBlock:
def fromMultiline(s: String): CommentBlock =
CommentBlock(s.split("\\n").toList)
case class DefinesBlock(xs: List[(String, String)]) extends AsmBlock
case class NamedCodeBlock(name: String, comment: Option[String], intents: List[AsmBlock.Intent]) extends AsmBlock
case class AnonymousCodeBlock(intents: List[AsmBlock.Intent]) extends AsmBlock
@ -32,6 +34,12 @@ object AsmBlock:
case CommentBlock(ys) =>
ys.map(toComment)
case DefinesBlock(kvs) =>
kvs
.map { case (k, v) =>
s"define $k $v"
}
case NamedCodeBlock(label, oComment, intents) =>
val headerParagraph =
List(label + ":") ++ oComment.map(toComment).map(withIndent).toList

View File

@ -39,30 +39,14 @@ object PrintThree:
case AssemblerOptions.DefinitionsMode.UseLiterals =>
Nil
case AssemblerOptions.DefinitionsMode.UseDefinitions =>
case AssemblerOptions.DefinitionsMode.UseDefinitions | AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
program
.flatMap(_.defines)
.distinct
.map { xs =>
xs
.toList
.map { case (k, v) =>
s"define $k $v"
}
.pipe(AsmBlock.CommentBlock(_))
}
case AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
program
.flatMap(_.defines.toList)
.distinct
.map { xs =>
xs
.toList
.map { case (k, v) =>
s"define $k $v"
}
.pipe(AsmBlock.CommentBlock(_))
.pipe(AsmBlock.DefinesBlock(_))
}
private def codes(opts: AssemblerOptions) =