array print

This commit is contained in:
Mark Canlas 2022-12-06 17:06:53 -05:00
parent 6e43e197c9
commit 458dc5d329
5 changed files with 32 additions and 8 deletions

View File

@ -21,12 +21,12 @@ define SCREEN $200
; Screen(0) = White
LDA #COLOR_White
STA $200
STA SCREEN+0
; Screen(1) = Green
LDA #COLOR_Green
STA $201
STA SCREEN+1
; Screen(2) = Orange
LDA #COLOR_Orange
STA $202
STA SCREEN+2

View File

@ -21,12 +21,12 @@ define SCREEN $200
; Screen(0) = White
LDA #COLOR_White
STA $200
STA SCREEN
; Screen(1) = Green
LDA #COLOR_Green
STA $201
STA TODO
; Screen(2) = Orange
LDA #COLOR_Orange
STA $202
STA TODO

View File

@ -11,6 +11,8 @@ trait Definable[A]:
extension (x: A) def toDefine: String
extension (x: A) def toDefineWithMath: String
object Definable:
def apply[A](using ev: Definable[A]): Definable[A] =
ev

View File

@ -31,6 +31,10 @@ object Easy6502:
def toDefine: String =
"COLOR_" + x.toString
extension (x: Color)
def toDefineWithMath: String =
"COLOR_" + x.toString
class Screen(baseAddr: Int):
def apply(offset: Int): Screen.Pixel =
Screen.Pixel(baseAddr, offset)
@ -53,4 +57,11 @@ object Easy6502:
extension (x: Pixel)
def toDefine: String =
"TODO"
if (x.offset == 0)
"SCREEN"
else
"TODO"
extension (x: Pixel)
def toDefineWithMath: String =
"SCREEN+" + x.offset

View File

@ -61,13 +61,24 @@ object PrintThree:
AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
"#" + mv.src.toDefine
val argumentTwo =
opts.definitionsMode match
case AssemblerOptions.DefinitionsMode.UseLiterals =>
AsmBlock.toHex(mv.dest.toValue)
case AssemblerOptions.DefinitionsMode.UseDefinitions =>
mv.dest.toDefine
case AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
mv.dest.toDefineWithMath
AsmBlock.Intent(
s"${mv.dest.toComment} = ${mv.src.toComment}".some,
List(
AsmBlock.Intent.Instruction(instruction("LDA", opts.instructionCase) + " " + argument, None),
AsmBlock
.Intent
.Instruction(instruction("STA", opts.instructionCase) + " " + AsmBlock.toHex(mv.dest.toValue), None)
.Instruction(instruction("STA", opts.instructionCase) + " " + argumentTwo, None)
)
)
}