mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-05-12 08:56:12 +00:00
added gen apple example
This commit is contained in:
parent
9d038a0160
commit
c1a6ed0714
@ -6,6 +6,10 @@
|
|||||||
init:
|
init:
|
||||||
; initializes values
|
; initializes values
|
||||||
|
|
||||||
|
JSR initSnake
|
||||||
|
|
||||||
|
JSR generateApplePosition
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
||||||
@ -19,3 +23,9 @@ initSnake:
|
|||||||
; initializes the snake
|
; initializes the snake
|
||||||
|
|
||||||
RTS
|
RTS
|
||||||
|
|
||||||
|
|
||||||
|
generateApplePosition:
|
||||||
|
; generates the position of the apple
|
||||||
|
|
||||||
|
RTS
|
||||||
|
@ -21,7 +21,8 @@ object SnakeEasy6502:
|
|||||||
.copy(intents =
|
.copy(intents =
|
||||||
() =>
|
() =>
|
||||||
List(
|
List(
|
||||||
initSnake.call
|
initSnake.call,
|
||||||
|
generateApplePosition.call
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,6 +32,9 @@ object SnakeEasy6502:
|
|||||||
lazy val initSnake =
|
lazy val initSnake =
|
||||||
Subroutine("initSnake", "initializes the snake")
|
Subroutine("initSnake", "initializes the snake")
|
||||||
|
|
||||||
|
lazy val generateApplePosition =
|
||||||
|
Subroutine("generateApplePosition", "generates the position of the apple")
|
||||||
|
|
||||||
def firstCodeBlock(xs: List[MetaIntent]): AsmBlock.AnonymousCodeBlock =
|
def firstCodeBlock(xs: List[MetaIntent]): AsmBlock.AnonymousCodeBlock =
|
||||||
AsmBlock
|
AsmBlock
|
||||||
.AnonymousCodeBlock(xs.map(_.toIntent))
|
.AnonymousCodeBlock(xs.map(_.toIntent))
|
||||||
@ -49,20 +53,22 @@ object SnakeEasy6502:
|
|||||||
case head :: tail =>
|
case head :: tail =>
|
||||||
if (callGraph.contains(head.target)) callGraphRecur(callGraph, tail)
|
if (callGraph.contains(head.target)) callGraphRecur(callGraph, tail)
|
||||||
else
|
else
|
||||||
|
val rts =
|
||||||
|
AsmBlock.Intent(
|
||||||
|
None,
|
||||||
|
List(
|
||||||
|
AsmBlock.Intent.Instruction.zero("rts")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val sub =
|
val sub =
|
||||||
AsmBlock.NamedCodeBlock(
|
AsmBlock.NamedCodeBlock(
|
||||||
head.target,
|
head.target,
|
||||||
head.description.some,
|
head.description.some,
|
||||||
List(
|
head.xs.map(_.toIntent) :+ rts
|
||||||
AsmBlock.Intent(
|
|
||||||
None,
|
|
||||||
List(
|
|
||||||
AsmBlock.Intent.Instruction.zero("rts")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// breadth-first expansion
|
||||||
callGraphRecur(callGraph.updated(head.target, sub), todo ::: head.xs)
|
callGraphRecur(callGraph.updated(head.target, sub), todo ::: head.xs)
|
||||||
|
|
||||||
case Nil =>
|
case Nil =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user