mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-05-28 21:41:31 +00:00
start unknown adt
This commit is contained in:
parent
d5b70c66ab
commit
41af66de90
|
@ -8,23 +8,14 @@ import com.htmlism.firepower.core.AsmBlock._
|
|||
import com.htmlism.firepower.core._
|
||||
|
||||
object PrintThree:
|
||||
case class Move[A: Definable, B: Definable](src: A, dest: B):
|
||||
def defines: List[Definable.Table] =
|
||||
List(
|
||||
Definable[A]
|
||||
.table(src),
|
||||
Definable[B]
|
||||
.table(dest)
|
||||
)
|
||||
|
||||
def build(screen: Easy6502.Screen): List[Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
def build(screen: Easy6502.Screen): List[UnknownAdt.Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
List(
|
||||
Move(Easy6502.Color.White, screen(0)),
|
||||
Move(Easy6502.Color.Green, screen(1)),
|
||||
Move(Easy6502.Color.Orange, screen(2))
|
||||
UnknownAdt.Move(Easy6502.Color.White, screen(0)),
|
||||
UnknownAdt.Move(Easy6502.Color.Green, screen(1)),
|
||||
UnknownAdt.Move(Easy6502.Color.Orange, screen(2))
|
||||
)
|
||||
|
||||
val program: List[Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
val program: List[UnknownAdt.Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
build(Easy6502.Screen(0x200))
|
||||
|
||||
def assemble(opts: AssemblerOptions): List[String] =
|
||||
|
@ -47,44 +38,6 @@ object PrintThree:
|
|||
|
||||
private def codes(opts: AssemblerOptions.DefinitionsMode) =
|
||||
program
|
||||
.map { mv =>
|
||||
val argument =
|
||||
opts match
|
||||
case AssemblerOptions.DefinitionsMode.UseLiterals =>
|
||||
f"#$$${mv.src.toValue}%02X"
|
||||
|
||||
case AssemblerOptions.DefinitionsMode.UseDefinitions |
|
||||
AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
|
||||
"#" + mv.src.toDefine
|
||||
|
||||
val argumentTwo =
|
||||
opts 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
|
||||
.one("LDA", argument, s"a = ${mv.src.toComment}".some),
|
||||
AsmBlock
|
||||
.Intent
|
||||
.Instruction
|
||||
.one(
|
||||
"STA",
|
||||
argumentTwo,
|
||||
s"${mv.dest.toComment} = a".some
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
.map(UnknownAdt.Move.toIntent(_, opts))
|
||||
.pipe(AnonymousCodeBlock(_))
|
||||
.pipe(List(_))
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.htmlism.firepower.demo
|
||||
|
||||
import cats.syntax.all._
|
||||
|
||||
import com.htmlism.firepower.core._
|
||||
|
||||
sealed trait UnknownAdt
|
||||
|
||||
object UnknownAdt:
|
||||
case class Move[A: Definable, B: Definable](src: A, dest: B):
|
||||
def defines: List[Definable.Table] =
|
||||
List(
|
||||
Definable[A]
|
||||
.table(src),
|
||||
Definable[B]
|
||||
.table(dest)
|
||||
)
|
||||
|
||||
object Move:
|
||||
def toIntent[A: Definable, B: Definable](mv: Move[A, B], opts: AssemblerOptions.DefinitionsMode): AsmBlock.Intent =
|
||||
val argument =
|
||||
opts match
|
||||
case AssemblerOptions.DefinitionsMode.UseLiterals =>
|
||||
f"#$$${mv.src.toValue}%02X"
|
||||
|
||||
case AssemblerOptions.DefinitionsMode.UseDefinitions |
|
||||
AssemblerOptions.DefinitionsMode.UseDefinitionsWithMath =>
|
||||
"#" + mv.src.toDefine
|
||||
|
||||
val argumentTwo =
|
||||
opts 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
|
||||
.one("LDA", argument, s"a = ${mv.src.toComment}".some),
|
||||
AsmBlock
|
||||
.Intent
|
||||
.Instruction
|
||||
.one(
|
||||
"STA",
|
||||
argumentTwo,
|
||||
s"${mv.dest.toComment} = a".some
|
||||
)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user