with uneven comments

This commit is contained in:
Mark Canlas 2022-12-06 17:20:30 -05:00
parent 458dc5d329
commit 5370ae45ee
5 changed files with 48 additions and 24 deletions

View File

@ -1,11 +1,11 @@
; Screen(0) = White
lda #$01
sta $200
lda #$01 ; a = White
sta $200 ; Screen(0) = a
; Screen(1) = Green
lda #$05
sta $201
lda #$05 ; a = Green
sta $201 ; Screen(1) = a
; Screen(2) = Orange
lda #$08
sta $202
lda #$08 ; a = Orange
sta $202 ; Screen(2) = a

View File

@ -20,13 +20,13 @@ define SCREEN $200
; Screen(0) = White
LDA #COLOR_White
STA SCREEN+0
LDA #COLOR_White ; a = White
STA SCREEN+0 ; Screen(0) = a
; Screen(1) = Green
LDA #COLOR_Green
STA SCREEN+1
LDA #COLOR_Green ; a = Green
STA SCREEN+1 ; Screen(1) = a
; Screen(2) = Orange
LDA #COLOR_Orange
STA SCREEN+2
LDA #COLOR_Orange ; a = Orange
STA SCREEN+2 ; Screen(2) = a

View File

@ -20,13 +20,13 @@ define SCREEN $200
; Screen(0) = White
LDA #COLOR_White
STA SCREEN
LDA #COLOR_White ; a = White
STA SCREEN ; Screen(0) = a
; Screen(1) = Green
LDA #COLOR_Green
STA TODO
LDA #COLOR_Green ; a = Green
STA TODO ; Screen(1) = a
; Screen(2) = Orange
LDA #COLOR_Orange
STA TODO
LDA #COLOR_Orange ; a = Orange
STA TODO ; Screen(2) = a

View File

@ -74,7 +74,26 @@ object AsmBlock:
case class Instruction(code: String, comment: Option[String])
def toLines(x: Intent): List[String] =
x.label.map(toComment).map(withIndent).toList ++ x
.instructions
.map(i => i.code + i.comment.map(toComment).map(" " + _).getOrElse(""))
.map(withIndent)
val comment =
x.label.map(toComment).map(withIndent).toList
val maximumLength =
x
.instructions
.map(_.code.length)
.max
val instructions =
x
.instructions
.map { i =>
i.comment match
case Some(c) =>
String.format(s"%-${maximumLength}s", i.code) + " " + toComment(c)
case None =>
i.code
}
.map(withIndent)
comment ++ instructions

View File

@ -75,10 +75,15 @@ object PrintThree:
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) + " " + argumentTwo, None)
.Instruction(instruction("LDA", opts.instructionCase) + " " + argument, s"a = ${mv.src.toComment}".some),
AsmBlock
.Intent
.Instruction(
instruction("STA", opts.instructionCase) + " " + argumentTwo,
s"${mv.dest.toComment} = a".some
)
)
)
}