6502-opcodes/firepower-demo/src/main/scala/com/htmlism/firepower/demo/FeatureDemo.scala

62 lines
1.9 KiB
Scala
Raw Normal View History

2022-12-06 13:37:12 +00:00
package com.htmlism.firepower.demo
2023-10-03 20:15:10 +00:00
import scala.util.chaining.*
2022-12-06 13:37:12 +00:00
2023-10-03 20:15:10 +00:00
import cats.syntax.all.*
2022-12-06 13:37:12 +00:00
2023-10-03 20:15:10 +00:00
import com.htmlism.firepower.core.AsmBlock.*
import com.htmlism.firepower.core.*
2022-12-06 13:37:12 +00:00
2022-12-07 15:22:42 +00:00
object FeatureDemo:
2022-12-07 18:36:57 +00:00
val program: List[String] =
2022-12-06 13:37:12 +00:00
List(
CommentBlock.fromMultiline(asciiArt),
CommentBlock(List("Change direction: W A S D")),
AnonymousCodeBlock(
List(
AsmBlock.Intent(
None,
List(
2022-12-07 12:59:59 +00:00
AsmBlock.Intent.Instruction.one("lda", "$00", None),
AsmBlock.Intent.Instruction.one("lda", "$01", "instruction comment".some)
2022-12-06 13:37:12 +00:00
)
),
AsmBlock.Intent(
"this block has some preamble".some,
List(
2022-12-07 12:59:59 +00:00
AsmBlock.Intent.Instruction.one("lda", "$00", None),
AsmBlock.Intent.Instruction.one("lda", "$01", "instruction comment".some)
2022-12-06 13:37:12 +00:00
)
)
)
),
NamedCodeBlock(
"labeled",
"This is a subroutine description".some,
List(
AsmBlock.Intent(
None,
List(
2022-12-07 12:59:59 +00:00
AsmBlock.Intent.Instruction.one("lda", "$00", None),
AsmBlock.Intent.Instruction.one("lda", "$01", "instruction comment".some)
2022-12-06 13:37:12 +00:00
)
),
AsmBlock.Intent(
"this block has some preamble".some,
List(
2022-12-07 12:59:59 +00:00
AsmBlock.Intent.Instruction.one("lda", "$00", None),
AsmBlock.Intent.Instruction.one("lda", "$01", "instruction comment".some)
2022-12-06 13:37:12 +00:00
)
)
)
)
)
2022-12-06 23:06:09 +00:00
.map(AsmBlock.toLines(AssemblerOptions.InstructionCase.Lowercase))
2022-12-06 13:37:12 +00:00
.pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity))
private lazy val asciiArt =
""" ___ _ __ ___ __ ___
|/ __|_ _ __ _| |_____ / /| __|/ \_ )
|\__ \ ' \/ _` | / / -_) _ \__ \ () / /
||___/_||_\__,_|_\_\___\___/___/\__/___|""".stripMargin