mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-01-31 23:29:44 +00:00
hexy values
This commit is contained in:
parent
501bc4b527
commit
6e43e197c9
@ -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 $00
|
||||
define COLOR_White $01
|
||||
define COLOR_Red $02
|
||||
define COLOR_Cyan $03
|
||||
define COLOR_Purple $04
|
||||
define COLOR_Green $05
|
||||
define COLOR_Blue $06
|
||||
define COLOR_Yellow $07
|
||||
define COLOR_Orange $08
|
||||
define COLOR_Brown $09
|
||||
define COLOR_LightRed $0A
|
||||
define COLOR_DarkGrey $0B
|
||||
define COLOR_Grey $0C
|
||||
define COLOR_LightGreen $0D
|
||||
define COLOR_LightBlue $0E
|
||||
define COLOR_LightGrey $0F
|
||||
|
||||
|
||||
define SCREEN 200
|
||||
define SCREEN $200
|
||||
|
||||
|
||||
; Screen(0) = White
|
||||
|
@ -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 $00
|
||||
define COLOR_White $01
|
||||
define COLOR_Red $02
|
||||
define COLOR_Cyan $03
|
||||
define COLOR_Purple $04
|
||||
define COLOR_Green $05
|
||||
define COLOR_Blue $06
|
||||
define COLOR_Yellow $07
|
||||
define COLOR_Orange $08
|
||||
define COLOR_Brown $09
|
||||
define COLOR_LightRed $0A
|
||||
define COLOR_DarkGrey $0B
|
||||
define COLOR_Grey $0C
|
||||
define COLOR_LightGreen $0D
|
||||
define COLOR_LightBlue $0E
|
||||
define COLOR_LightGrey $0F
|
||||
|
||||
|
||||
define SCREEN 200
|
||||
define SCREEN $200
|
||||
|
||||
|
||||
; Screen(0) = White
|
||||
|
@ -29,6 +29,17 @@ object AsmBlock:
|
||||
def withIndent(s: String): String =
|
||||
" " + s
|
||||
|
||||
def toHex(n: Int): String =
|
||||
val hex =
|
||||
if (n < 16 * 16)
|
||||
String.format("%1$02x", n)
|
||||
else if (n < 16 * 16 * 16)
|
||||
String.format("%1$03x", n)
|
||||
else
|
||||
String.format("%1$04x", n)
|
||||
|
||||
"$" + hex.toUpperCase
|
||||
|
||||
def toLines(xs: AsmBlock): List[String] =
|
||||
xs match
|
||||
case CommentBlock(ys) =>
|
||||
@ -42,7 +53,7 @@ object AsmBlock:
|
||||
|
||||
kvs
|
||||
.map { case (k, v) =>
|
||||
String.format(s"define %-${maximumLength}s $v", k)
|
||||
String.format(s"define %-${maximumLength}s ${toHex(v)}", k)
|
||||
}
|
||||
|
||||
case NamedCodeBlock(label, oComment, intents) =>
|
||||
|
@ -26,7 +26,7 @@ object PrintThree:
|
||||
)
|
||||
|
||||
val program: List[Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
build(Easy6502.Screen(200))
|
||||
build(Easy6502.Screen(0x200))
|
||||
|
||||
def assemble(opts: AssemblerOptions): String =
|
||||
(defines(opts) ++ codes(opts))
|
||||
@ -65,7 +65,9 @@ object PrintThree:
|
||||
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) + " $" + mv.dest.toValue, None)
|
||||
AsmBlock
|
||||
.Intent
|
||||
.Instruction(instruction("STA", opts.instructionCase) + " " + AsmBlock.toHex(mv.dest.toValue), None)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user