mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2024-12-29 08:29:54 +00:00
scalafmt
This commit is contained in:
parent
f52048ef1f
commit
92599edba0
@ -12,4 +12,4 @@ case object IndirectX extends AddressingMode
|
||||
case object IndirectY extends AddressingMode
|
||||
case object Accumulator extends AddressingMode
|
||||
case object Implied extends AddressingMode
|
||||
case object NoMode extends AddressingMode
|
||||
case object NoMode extends AddressingMode
|
||||
|
@ -2,16 +2,22 @@ package com.htmlism
|
||||
|
||||
sealed trait Instruction { def theme: String; def color: String }
|
||||
|
||||
case object NoInstruction extends Instruction { def theme: String = "noop"; def color: String = "white" }
|
||||
case object NoInstruction extends Instruction {
|
||||
def theme: String = "noop"; def color: String = "white"
|
||||
}
|
||||
|
||||
sealed trait Logical extends Instruction { def theme: String = "logical"; def color: String = "OliveDrab" }
|
||||
sealed trait Logical extends Instruction {
|
||||
def theme: String = "logical"; def color: String = "OliveDrab"
|
||||
}
|
||||
|
||||
case object AND extends Logical
|
||||
case object EOR extends Logical
|
||||
case object ORA extends Logical
|
||||
case object BIT extends Logical
|
||||
|
||||
sealed trait Arithmetic extends Instruction { def theme: String = "arithmetic"; def color: String = "CadetBlue" }
|
||||
sealed trait Arithmetic extends Instruction {
|
||||
def theme: String = "arithmetic"; def color: String = "CadetBlue"
|
||||
}
|
||||
|
||||
case object ADC extends Arithmetic
|
||||
case object SBC extends Arithmetic
|
||||
@ -19,42 +25,56 @@ case object CMP extends Arithmetic
|
||||
case object CPX extends Arithmetic
|
||||
case object CPY extends Arithmetic
|
||||
|
||||
sealed trait Load extends Instruction { def theme: String = "load"; def color: String = "BurlyWood" }
|
||||
sealed trait Load extends Instruction {
|
||||
def theme: String = "load"; def color: String = "BurlyWood"
|
||||
}
|
||||
case object LDA extends Load
|
||||
case object LDX extends Load
|
||||
case object LDY extends Load
|
||||
|
||||
sealed trait Store extends Instruction { def theme: String = "store"; def color: String = "Bisque" }
|
||||
sealed trait Store extends Instruction {
|
||||
def theme: String = "store"; def color: String = "Bisque"
|
||||
}
|
||||
|
||||
case object STA extends Store
|
||||
case object STX extends Store
|
||||
case object STY extends Store
|
||||
|
||||
sealed trait Shift extends Instruction { def theme: String = "shift"; def color: String = "SlateBlue" }
|
||||
sealed trait Shift extends Instruction {
|
||||
def theme: String = "shift"; def color: String = "SlateBlue"
|
||||
}
|
||||
|
||||
case object ASL extends Shift
|
||||
case object LSR extends Shift
|
||||
case object ROL extends Shift
|
||||
case object ROR extends Shift
|
||||
|
||||
sealed trait Increment extends Instruction { def theme: String = "increment"; def color: String = "LightPink" }
|
||||
sealed trait Increment extends Instruction {
|
||||
def theme: String = "increment"; def color: String = "LightPink"
|
||||
}
|
||||
|
||||
case object INC extends Increment
|
||||
case object INX extends Increment
|
||||
case object INY extends Increment
|
||||
|
||||
sealed trait Decrement extends Instruction { def theme: String = "decrement"; def color: String = "Khaki" }
|
||||
sealed trait Decrement extends Instruction {
|
||||
def theme: String = "decrement"; def color: String = "Khaki"
|
||||
}
|
||||
|
||||
case object DEC extends Decrement
|
||||
case object DEX extends Decrement
|
||||
case object DEY extends Decrement
|
||||
|
||||
sealed trait Jump extends Instruction { def theme: String = "jump"; def color: String = "Salmon" }
|
||||
sealed trait Jump extends Instruction {
|
||||
def theme: String = "jump"; def color: String = "Salmon"
|
||||
}
|
||||
case object JMP extends Jump
|
||||
case object JSR extends Jump
|
||||
case object RTS extends Jump
|
||||
|
||||
sealed trait Branch extends Instruction { def theme: String = "branch"; def color: String = "DodgerBlue" }
|
||||
sealed trait Branch extends Instruction {
|
||||
def theme: String = "branch"; def color: String = "DodgerBlue"
|
||||
}
|
||||
case object BCC extends Branch
|
||||
case object BCS extends Branch
|
||||
case object BEQ extends Branch
|
||||
@ -64,12 +84,16 @@ case object BPL extends Branch
|
||||
case object BVC extends Branch
|
||||
case object BVS extends Branch
|
||||
|
||||
sealed trait System extends Instruction { def theme: String = "system"; def color: String = "Peru" }
|
||||
sealed trait System extends Instruction {
|
||||
def theme: String = "system"; def color: String = "Peru"
|
||||
}
|
||||
case object BRK extends System
|
||||
case object NOP extends System
|
||||
case object RTI extends System
|
||||
|
||||
sealed trait Stack extends Instruction { def theme: String = "stack"; def color: String = "Wheat" }
|
||||
sealed trait Stack extends Instruction {
|
||||
def theme: String = "stack"; def color: String = "Wheat"
|
||||
}
|
||||
case object TSX extends Stack
|
||||
case object TXS extends Stack
|
||||
case object PHA extends Stack
|
||||
@ -77,19 +101,25 @@ case object PHP extends Stack
|
||||
case object PLA extends Stack
|
||||
case object PLP extends Stack
|
||||
|
||||
sealed trait Transfer extends Instruction { def theme: String = "transfer"; def color: String = "Teal" }
|
||||
sealed trait Transfer extends Instruction {
|
||||
def theme: String = "transfer"; def color: String = "Teal"
|
||||
}
|
||||
case object TAX extends Transfer
|
||||
case object TAY extends Transfer
|
||||
case object TXA extends Transfer
|
||||
case object TYA extends Transfer
|
||||
|
||||
sealed trait Clear extends Instruction { def theme: String = "clear"; def color: String = "LightSteelBlue" }
|
||||
sealed trait Clear extends Instruction {
|
||||
def theme: String = "clear"; def color: String = "LightSteelBlue"
|
||||
}
|
||||
case object CLC extends Clear
|
||||
case object CLD extends Clear
|
||||
case object CLI extends Clear
|
||||
case object CLV extends Clear
|
||||
|
||||
sealed trait SetFlag extends Instruction { def theme: String = "set"; def color: String = "Thistle" }
|
||||
sealed trait SetFlag extends Instruction {
|
||||
def theme: String = "set"; def color: String = "Thistle"
|
||||
}
|
||||
case object SEC extends SetFlag
|
||||
case object SED extends SetFlag
|
||||
case object SEI extends SetFlag
|
||||
|
@ -15,6 +15,7 @@ object MatchOpcodes {
|
||||
.collect { case (n, Some(x)) => (n, x) }
|
||||
.toMap
|
||||
|
||||
// format: off
|
||||
def injectedOpcodes: Map[Int, (Instruction, AddressingMode)] =
|
||||
Map(
|
||||
0x10 -> BPL,
|
||||
@ -56,6 +57,7 @@ object MatchOpcodes {
|
||||
0xCA -> DEX,
|
||||
0xEA -> NOP
|
||||
).mapValues(x => x -> Implied)
|
||||
// format: on
|
||||
|
||||
def doStuff(out: PrintWriter): Unit = {
|
||||
val lookup = generatedOpcodes ++ injectedOpcodes
|
||||
@ -94,7 +96,8 @@ object MatchOpcodes {
|
||||
lookup.get(fullInt) match {
|
||||
case Some((ints, mode)) =>
|
||||
val hex = f"$fullInt%2X"
|
||||
out.print(s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
out.print(
|
||||
s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
|
||||
case None =>
|
||||
out.print(s"<td>UNDEF</td>")
|
||||
@ -135,7 +138,8 @@ object MatchOpcodes {
|
||||
lookup.get(fullInt) match {
|
||||
case Some((ints, mode)) =>
|
||||
val hex = f"$fullInt%2X"
|
||||
out.print(s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
out.print(
|
||||
s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
|
||||
case None =>
|
||||
out.print(s"<td>UNDEF</td>")
|
||||
@ -153,7 +157,9 @@ object MatchOpcodes {
|
||||
quartile(out, 3, lookup)
|
||||
}
|
||||
|
||||
def quartile(out: PrintWriter, n: Int, lookup: Map[Int, (Instruction, AddressingMode)]) = {
|
||||
def quartile(out: PrintWriter,
|
||||
n: Int,
|
||||
lookup: Map[Int, (Instruction, AddressingMode)]) = {
|
||||
out.print(s"<h2>${paddedBinary(n, 2)}</h2>")
|
||||
|
||||
out.print("<table>")
|
||||
@ -177,7 +183,6 @@ object MatchOpcodes {
|
||||
|
||||
out.print("</tr>")
|
||||
|
||||
|
||||
for (r <- rows) {
|
||||
out.print("<tr>")
|
||||
|
||||
@ -190,7 +195,8 @@ object MatchOpcodes {
|
||||
lookup.get(fullInt) match {
|
||||
case Some((ints, mode)) =>
|
||||
val hex = f"$fullInt%2X"
|
||||
out.print(s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
out.print(
|
||||
s"<th class=${'"' + ints.theme + '"'} style=${'"' + "background-color: " + ints.color + '"'}>$ints $mode<br>$hex</th>")
|
||||
|
||||
case None =>
|
||||
out.print(s"<td>UNDEF</td>")
|
||||
@ -207,7 +213,7 @@ object MatchOpcodes {
|
||||
def wideColumns: Seq[Int] =
|
||||
for {
|
||||
cc <- 0 to 3
|
||||
y <- 0 to 1
|
||||
y <- 0 to 1
|
||||
xx <- 0 to 3
|
||||
} yield (xx << 3) + (y << 2) + cc
|
||||
|
||||
@ -239,7 +245,14 @@ object MatchOpcodes {
|
||||
Seq(ORA, AND, EOR, ADC, STA, LDA, CMP, SBC)(aaa)
|
||||
|
||||
val addressingMode =
|
||||
Seq(IndirectX, ZeroPage, Immediate, Absolute, IndirectY, ZeroPageX, AbsoluteY, AbsoluteX)(bbb)
|
||||
Seq(IndirectX,
|
||||
ZeroPage,
|
||||
Immediate,
|
||||
Absolute,
|
||||
IndirectY,
|
||||
ZeroPageX,
|
||||
AbsoluteY,
|
||||
AbsoluteX)(bbb)
|
||||
|
||||
Some(instruction -> addressingMode)
|
||||
}
|
||||
@ -249,7 +262,14 @@ object MatchOpcodes {
|
||||
Seq(ASL, ROL, LSR, ROR, STX, LDX, DEC, INC)(aaa)
|
||||
|
||||
val addressingMode =
|
||||
Seq(Immediate, ZeroPage, Accumulator, Absolute, NoMode, ZeroPageX, NoMode, AbsoluteX)(bbb)
|
||||
Seq(Immediate,
|
||||
ZeroPage,
|
||||
Accumulator,
|
||||
Absolute,
|
||||
NoMode,
|
||||
ZeroPageX,
|
||||
NoMode,
|
||||
AbsoluteX)(bbb)
|
||||
|
||||
Some(instruction -> addressingMode)
|
||||
}
|
||||
@ -259,8 +279,15 @@ object MatchOpcodes {
|
||||
Seq(NoInstruction, BIT, JMP, JMP, STY, LDY, CPY, CPX)(aaa)
|
||||
|
||||
val addressingMode =
|
||||
Seq(Immediate, ZeroPage, NoMode, Absolute, NoMode, ZeroPageX, NoMode, AbsoluteX)(bbb)
|
||||
|
||||
Seq(Immediate,
|
||||
ZeroPage,
|
||||
NoMode,
|
||||
Absolute,
|
||||
NoMode,
|
||||
ZeroPageX,
|
||||
NoMode,
|
||||
AbsoluteX)(bbb)
|
||||
|
||||
Some(instruction -> addressingMode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,13 @@ object AtomExtractor {
|
||||
pow(ex - 1, acc * 2)
|
||||
}
|
||||
|
||||
abstract class PrimitiveBitExtractor(val length: Int) extends BitExtractor[Int] {
|
||||
abstract class PrimitiveBitExtractor(val length: Int)
|
||||
extends BitExtractor[Int] {
|
||||
private lazy val mask = AtomExtractor.pow(length) - 1
|
||||
|
||||
def unapply(n: Int): Option[Int] = Some(n & mask)
|
||||
}
|
||||
|
||||
object OneBit extends PrimitiveBitExtractor(1)
|
||||
object TwoBits extends PrimitiveBitExtractor(2)
|
||||
object ThreeBits extends PrimitiveBitExtractor(3)
|
||||
object OneBit extends PrimitiveBitExtractor(1)
|
||||
object TwoBits extends PrimitiveBitExtractor(2)
|
||||
object ThreeBits extends PrimitiveBitExtractor(3)
|
||||
|
@ -2,6 +2,4 @@ package com.htmlism
|
||||
|
||||
import org.scalatest.FlatSpec
|
||||
|
||||
class BitMatchingSpec extends FlatSpec {
|
||||
|
||||
}
|
||||
class BitMatchingSpec extends FlatSpec {}
|
||||
|
Loading…
Reference in New Issue
Block a user