mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-08-09 07:25:08 +00:00
move snake
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
package com.htmlism.firepower.demo
|
||||||
|
|
||||||
|
import scala.util.chaining._
|
||||||
|
|
||||||
|
import cats.syntax.all._
|
||||||
|
|
||||||
|
import com.htmlism.firepower.core.AsmBlock._
|
||||||
|
import com.htmlism.firepower.core._
|
||||||
|
|
||||||
|
object AnnotatedSnake:
|
||||||
|
val program: String =
|
||||||
|
List(
|
||||||
|
CommentBlock.fromMultiline(asciiArt),
|
||||||
|
CommentBlock(List("Change direction: W A S D")),
|
||||||
|
AnonymousCodeBlock(
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent(
|
||||||
|
None,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent.Instruction("lda $00", None),
|
||||||
|
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
AsmBlock.Intent(
|
||||||
|
"this block has some preamble".some,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent.Instruction("lda $00", None),
|
||||||
|
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
NamedCodeBlock(
|
||||||
|
"labeled",
|
||||||
|
"This is a subroutine description".some,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent(
|
||||||
|
None,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent.Instruction("lda $00", None),
|
||||||
|
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
AsmBlock.Intent(
|
||||||
|
"this block has some preamble".some,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent.Instruction("lda $00", None),
|
||||||
|
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map(AsmBlock.toLines)
|
||||||
|
.pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity))
|
||||||
|
.pipe(str.Line.mkString)
|
||||||
|
|
||||||
|
private lazy val asciiArt =
|
||||||
|
""" ___ _ __ ___ __ ___
|
||||||
|
|/ __|_ _ __ _| |_____ / /| __|/ \_ )
|
||||||
|
|\__ \ ' \/ _` | / / -_) _ \__ \ () / /
|
||||||
|
||___/_||_\__,_|_\_\___\___/___/\__/___|""".stripMargin
|
@@ -28,59 +28,9 @@ object PrintPrograms extends ZIOAppDefault:
|
|||||||
)
|
)
|
||||||
.pipe(xxs => AsmBlock.interFlatMap(xxs)(List("", ""), identity))
|
.pipe(xxs => AsmBlock.interFlatMap(xxs)(List("", ""), identity))
|
||||||
.pipe(Line.mkString),
|
.pipe(Line.mkString),
|
||||||
"annotated-snake.asm" -> List(
|
"annotated-snake.asm" -> AnnotatedSnake.program
|
||||||
CommentBlock.fromMultiline(asciiArt),
|
|
||||||
CommentBlock(List("Change direction: W A S D")),
|
|
||||||
AnonymousCodeBlock(
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent(
|
|
||||||
None,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent.Instruction("lda $00", None),
|
|
||||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
AsmBlock.Intent(
|
|
||||||
"this block has some preamble".some,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent.Instruction("lda $00", None),
|
|
||||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
NamedCodeBlock(
|
|
||||||
"labeled",
|
|
||||||
"This is a subroutine description".some,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent(
|
|
||||||
None,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent.Instruction("lda $00", None),
|
|
||||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
AsmBlock.Intent(
|
|
||||||
"this block has some preamble".some,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent.Instruction("lda $00", None),
|
|
||||||
AsmBlock.Intent.Instruction("lda $01", "instruction comment".some)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.map(AsmBlock.toLines)
|
|
||||||
.pipe(xs => AsmBlock.interFlatMap(xs)(List("", ""), identity))
|
|
||||||
.pipe(Line.mkString)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private lazy val asciiArt =
|
|
||||||
""" ___ _ __ ___ __ ___
|
|
||||||
|/ __|_ _ __ _| |_____ / /| __|/ \_ )
|
|
||||||
|\__ \ ' \/ _` | / / -_) _ \__ \ () / /
|
|
||||||
||___/_||_\__,_|_\_\___\___/___/\__/___|""".stripMargin
|
|
||||||
|
|
||||||
def run: Task[Unit] =
|
def run: Task[Unit] =
|
||||||
for {
|
for {
|
||||||
// just a traverse in slow motion...
|
// just a traverse in slow motion...
|
||||||
|
Reference in New Issue
Block a user