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 ; Screen(0) = White
lda #$01 lda #$01 ; a = White
sta $200 sta $200 ; Screen(0) = a
; Screen(1) = Green ; Screen(1) = Green
lda #$05 lda #$05 ; a = Green
sta $201 sta $201 ; Screen(1) = a
; Screen(2) = Orange ; Screen(2) = Orange
lda #$08 lda #$08 ; a = Orange
sta $202 sta $202 ; Screen(2) = a

View File

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

View File

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

View File

@ -74,7 +74,26 @@ object AsmBlock:
case class Instruction(code: String, comment: Option[String]) case class Instruction(code: String, comment: Option[String])
def toLines(x: Intent): List[String] = def toLines(x: Intent): List[String] =
x.label.map(toComment).map(withIndent).toList ++ x val comment =
.instructions x.label.map(toComment).map(withIndent).toList
.map(i => i.code + i.comment.map(toComment).map(" " + _).getOrElse(""))
.map(withIndent) 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( AsmBlock.Intent(
s"${mv.dest.toComment} = ${mv.src.toComment}".some, s"${mv.dest.toComment} = ${mv.src.toComment}".some,
List( List(
AsmBlock.Intent.Instruction(instruction("LDA", opts.instructionCase) + " " + argument, None),
AsmBlock AsmBlock
.Intent .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
)
) )
) )
} }