mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-01-31 23:29:44 +00:00
define table is a function of an instance
This commit is contained in:
parent
a43d4745b9
commit
501bc4b527
@ -16,7 +16,7 @@ define COLOR_LightBlue 14
|
||||
define COLOR_LightGrey 15
|
||||
|
||||
|
||||
define SCREEN TODO
|
||||
define SCREEN 200
|
||||
|
||||
|
||||
; Screen(0) = White
|
||||
|
@ -16,7 +16,7 @@ define COLOR_LightBlue 14
|
||||
define COLOR_LightGrey 15
|
||||
|
||||
|
||||
define SCREEN TODO
|
||||
define SCREEN 200
|
||||
|
||||
|
||||
; Screen(0) = White
|
||||
|
@ -9,7 +9,7 @@ object AsmBlock:
|
||||
def fromMultiline(s: String): CommentBlock =
|
||||
CommentBlock(s.split("\\n").toList)
|
||||
|
||||
case class DefinesBlock(xs: List[(String, String)]) extends AsmBlock
|
||||
case class DefinesBlock(xs: List[(String, Int)]) extends AsmBlock
|
||||
|
||||
case class NamedCodeBlock(name: String, comment: Option[String], intents: List[AsmBlock.Intent]) extends AsmBlock
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.htmlism.firepower.demo
|
||||
import scala.collection.immutable._
|
||||
|
||||
trait Definable[A]:
|
||||
def table: ListMap[String, String]
|
||||
def table(x: A): ListMap[String, Int]
|
||||
|
||||
extension (x: A) def toComment: String
|
||||
|
||||
|
@ -10,12 +10,12 @@ object Easy6502:
|
||||
|
||||
object Color:
|
||||
given Definable[Color] with
|
||||
def table: ListMap[String, String] =
|
||||
def table(x: Color): ListMap[String, Int] =
|
||||
Color
|
||||
.values
|
||||
.iterator
|
||||
.map { c =>
|
||||
"COLOR_" + c.toString -> c.ordinal.toString
|
||||
"COLOR_" + c.toString -> c.ordinal
|
||||
}
|
||||
.pipe(ListMap.from)
|
||||
|
||||
@ -40,8 +40,8 @@ object Easy6502:
|
||||
|
||||
object Pixel:
|
||||
given Definable[Pixel] with
|
||||
def table: ListMap[String, String] =
|
||||
ListMap("SCREEN" -> "TODO") // define table needs to be a function of an instance
|
||||
def table(x: Pixel): ListMap[String, Int] =
|
||||
ListMap("SCREEN" -> x.baseAddr) // define table needs to be a function of an instance
|
||||
|
||||
extension (x: Pixel)
|
||||
def toComment: String =
|
||||
|
@ -9,14 +9,14 @@ import com.htmlism.firepower.core.AsmBlock._
|
||||
import com.htmlism.firepower.core._
|
||||
|
||||
object PrintThree:
|
||||
trait DefinesHelper(xs: Definable[_]*):
|
||||
def defines: Seq[ListMap[String, String]] =
|
||||
xs
|
||||
.iterator
|
||||
.map(_.table)
|
||||
.toList
|
||||
|
||||
case class Move[A: Definable, B: Definable](src: A, dest: B) extends DefinesHelper(Definable[A], Definable[B])
|
||||
case class Move[A: Definable, B: Definable](src: A, dest: B):
|
||||
def defines: List[ListMap[String, Int]] =
|
||||
List(
|
||||
Definable[A]
|
||||
.table(src),
|
||||
Definable[B]
|
||||
.table(dest)
|
||||
)
|
||||
|
||||
def build(screen: Easy6502.Screen): List[Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
List(
|
||||
|
Loading…
x
Reference in New Issue
Block a user