mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-02-15 11:32:03 +00:00
scala3 fmt
This commit is contained in:
parent
4d47714e77
commit
2ac62b5af7
@ -48,3 +48,5 @@ docstrings.blankFirstLine = yes
|
||||
|
||||
includeNoParensInSelectChains = true
|
||||
optIn.breakChainOnFirstMethodDot = true
|
||||
|
||||
rewrite.scala3.convertToNewSyntax = true
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.firepower.core
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
sealed trait AsmBlock
|
||||
|
||||
@ -55,12 +55,9 @@ object AsmBlock:
|
||||
|
||||
def toHex(n: Int): String =
|
||||
val hex =
|
||||
if (n < 16 * 16)
|
||||
String.format("%1$02x", n)
|
||||
else if (n < 16 * 16 * 16)
|
||||
String.format("%1$03x", n)
|
||||
else
|
||||
String.format("%1$04x", n)
|
||||
if n < 16 * 16 then String.format("%1$02x", n)
|
||||
else if n < 16 * 16 * 16 then String.format("%1$03x", n)
|
||||
else String.format("%1$04x", n)
|
||||
|
||||
"$" + hex.toUpperCase
|
||||
|
||||
|
@ -5,7 +5,7 @@ object CodeGenerator extends App:
|
||||
('A' to 'Z')
|
||||
.map(_.toString)
|
||||
|
||||
for (n <- 1 to 3)
|
||||
for n <- 1 to 3 do
|
||||
val letters =
|
||||
allLetters.take(n)
|
||||
|
||||
@ -44,7 +44,7 @@ object CodeGenerator extends App:
|
||||
println(" copy(oComment = Some(s))")
|
||||
println
|
||||
|
||||
for (n <- 1 to 3)
|
||||
for n <- 1 to 3 do
|
||||
val classNum =
|
||||
n
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.firepower.core
|
||||
|
||||
import com.htmlism.firepower.core.AsmBlock._
|
||||
import com.htmlism.firepower.core.AsmBlock.*
|
||||
|
||||
case class Subroutine(name: String, description: String, intents: () => List[MetaIntent]):
|
||||
def call: MetaIntent =
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.htmlism.firepower.core
|
||||
|
||||
import org.scalatest.funsuite.AnyFunSuite
|
||||
import org.scalatest.matchers.should._
|
||||
import org.scalatest.matchers.should.*
|
||||
|
||||
import com.htmlism.firepower.core.syntax._
|
||||
import com.htmlism.firepower.core.syntax.*
|
||||
|
||||
object ExampleRegister extends ZeroPageAddress(0x01, "example") with WriteOnlyByteAddress[ExampleRegister]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.firepower.core
|
||||
|
||||
import weaver._
|
||||
import weaver.*
|
||||
|
||||
object MoveSuite extends FunSuite:
|
||||
test("TODO move constant"):
|
||||
|
@ -60,10 +60,8 @@ object Easy6502:
|
||||
|
||||
extension (x: Pixel)
|
||||
def toDefine: String =
|
||||
if (x.offset == 0)
|
||||
"SCREEN"
|
||||
else
|
||||
"TODO"
|
||||
if x.offset == 0 then "SCREEN"
|
||||
else "TODO"
|
||||
|
||||
extension (x: Pixel)
|
||||
def toDefineWithMath: String =
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.htmlism.firepower.demo
|
||||
|
||||
import scala.util.chaining._
|
||||
import scala.util.chaining.*
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.firepower.core.AsmBlock._
|
||||
import com.htmlism.firepower.core._
|
||||
import com.htmlism.firepower.core.AsmBlock.*
|
||||
import com.htmlism.firepower.core.*
|
||||
|
||||
object FeatureDemo:
|
||||
val program: List[String] =
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.htmlism.firepower.demo
|
||||
|
||||
import scala.util.chaining._
|
||||
import scala.util.chaining.*
|
||||
|
||||
import zio.*
|
||||
|
||||
import com.htmlism.firepower.core.AsmBlock._
|
||||
import com.htmlism.firepower.core.AssemblerOptions._
|
||||
import com.htmlism.firepower.core._
|
||||
import com.htmlism.firepower.core.AsmBlock.*
|
||||
import com.htmlism.firepower.core.AssemblerOptions.*
|
||||
import com.htmlism.firepower.core.*
|
||||
import com.htmlism.rufio.withzio.*
|
||||
|
||||
object PrintPrograms extends ZIOAppDefault:
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.htmlism.firepower.demo
|
||||
|
||||
import scala.util.chaining._
|
||||
import scala.util.chaining.*
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.firepower.core.AsmBlock._
|
||||
import com.htmlism.firepower.core._
|
||||
import com.htmlism.firepower.core.AsmBlock.*
|
||||
import com.htmlism.firepower.core.*
|
||||
|
||||
object PrintThree:
|
||||
def build(screen: Easy6502.Screen): List[MetaIntent.Move[Easy6502.Color, Easy6502.Screen.Pixel]] =
|
||||
|
@ -4,7 +4,7 @@ import scala.annotation.tailrec
|
||||
import scala.collection.immutable.ListMap
|
||||
import scala.util.chaining.*
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.firepower.core.AsmBlock.Intent
|
||||
import com.htmlism.firepower.core.*
|
||||
@ -51,7 +51,7 @@ object SnakeEasy6502:
|
||||
): ListMap[String, AsmBlock.NamedCodeBlock] =
|
||||
todo.collect { case x: MetaIntent.Jump => x } match
|
||||
case head :: tail =>
|
||||
if (callGraph.contains(head.target)) callGraphRecur(callGraph, tail)
|
||||
if callGraph.contains(head.target) then callGraphRecur(callGraph, tail)
|
||||
else
|
||||
val rts =
|
||||
AsmBlock.Intent(
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.htmlism.nescant
|
||||
package dsl
|
||||
|
||||
import org.scalatest.flatspec._
|
||||
import org.scalatest.matchers._
|
||||
import org.scalatest.flatspec.*
|
||||
import org.scalatest.matchers.*
|
||||
|
||||
class ByteSinkSpec extends AnyFlatSpec with should.Matchers:
|
||||
"A zero page address" should "be a byte-wide sync" in:
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.htmlism.nescant
|
||||
package dsl
|
||||
|
||||
import org.scalatest.flatspec._
|
||||
import org.scalatest.matchers._
|
||||
import org.scalatest.flatspec.*
|
||||
import org.scalatest.matchers.*
|
||||
|
||||
class ByteSourceSpec extends AnyFlatSpec with should.Matchers:
|
||||
private val sink =
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.htmlism.nescant
|
||||
package dsl
|
||||
|
||||
import org.scalatest.flatspec._
|
||||
import org.scalatest.matchers._
|
||||
import org.scalatest.flatspec.*
|
||||
import org.scalatest.matchers.*
|
||||
|
||||
class PostFixOpsSpec extends AnyFlatSpec with should.Matchers:
|
||||
"Numbers" should "support zero page ops" in:
|
||||
|
@ -14,7 +14,7 @@ object CatsEffectForkPlugin extends AutoPlugin {
|
||||
|
||||
// cats-effect prefers to run in its own main thread
|
||||
// https://github.com/typelevel/cats-effect/pull/3774
|
||||
override val buildSettings: Seq[Setting[_]] = Seq(
|
||||
override val buildSettings: Seq[Setting[?]] = Seq(
|
||||
fork := true
|
||||
)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import sbt.*
|
||||
import sbt.Keys.*
|
||||
|
||||
/**
|
||||
* Automatically enriches projects with the following settings (despite the word "override").
|
||||
|
@ -1,6 +1,6 @@
|
||||
import sbt.Keys._
|
||||
import sbt._
|
||||
import scalafix.sbt.ScalafixPlugin.autoImport._
|
||||
import sbt.Keys.*
|
||||
import sbt.*
|
||||
import scalafix.sbt.ScalafixPlugin.autoImport.*
|
||||
|
||||
object LintingPlugin extends AutoPlugin {
|
||||
override def trigger =
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sbt.Keys._
|
||||
import sbt._
|
||||
import sbt.Keys.*
|
||||
import sbt.*
|
||||
|
||||
object ProjectPlugin extends AutoPlugin {
|
||||
override def trigger = allRequirements
|
||||
|
@ -1,5 +1,5 @@
|
||||
import sbt.Keys._
|
||||
import sbt._
|
||||
import sbt.Keys.*
|
||||
import sbt.*
|
||||
|
||||
/**
|
||||
* Automatically enriches projects with the following settings (despite the word "override").
|
||||
@ -11,11 +11,11 @@ object Scala3Plugin extends AutoPlugin {
|
||||
*/
|
||||
override def trigger: PluginTrigger = AllRequirements
|
||||
|
||||
override val buildSettings: Seq[Setting[_]] = Seq(
|
||||
override val buildSettings: Seq[Setting[?]] = Seq(
|
||||
scalaVersion := "3.3.1"
|
||||
)
|
||||
|
||||
override val projectSettings: Seq[Setting[_]] = Seq(
|
||||
override val projectSettings: Seq[Setting[?]] = Seq(
|
||||
scalacOptions ++= Seq("-indent", "-rewrite")
|
||||
)
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.htmlism
|
||||
|
||||
import java.io.PrintWriter
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
object MatchOpcodes:
|
||||
def paddedBinary(n: Int, width: Int) =
|
||||
@ -95,18 +95,17 @@ object MatchOpcodes:
|
||||
b <- 0 to 7
|
||||
} yield b * 4 + c
|
||||
|
||||
for (f <- fancyColumns)
|
||||
out.print(s"<th>${paddedBinary(f, 8)}</th>")
|
||||
for f <- fancyColumns do out.print(s"<th>${paddedBinary(f, 8)}</th>")
|
||||
|
||||
out.print("</tr>")
|
||||
|
||||
for (r <- Seq(0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0))
|
||||
for r <- Seq(0x00, 0x20, 0x40, 0x60, 0x80, 0xa0, 0xc0, 0xe0) do
|
||||
out.print("<tr>")
|
||||
|
||||
// left header
|
||||
out.print(s"<th>${paddedBinary(r, 3)}</th>")
|
||||
|
||||
for (f <- fancyColumns)
|
||||
for f <- fancyColumns do
|
||||
val fullInt = r + f
|
||||
|
||||
lookup.get(fullInt) match
|
||||
@ -129,18 +128,17 @@ object MatchOpcodes:
|
||||
out.print("<tr>")
|
||||
out.print("<th/>")
|
||||
|
||||
for (c <- wideColumns)
|
||||
out.print(s"<th>${paddedBinary(c, 5)}</th>")
|
||||
for c <- wideColumns do out.print(s"<th>${paddedBinary(c, 5)}</th>")
|
||||
|
||||
out.print("</tr>")
|
||||
|
||||
for (r <- wideRows)
|
||||
for r <- wideRows do
|
||||
out.print("<tr>")
|
||||
|
||||
// left header
|
||||
out.print(s"<th>${paddedBinary(r, 3)}</th>")
|
||||
|
||||
for (c <- wideColumns)
|
||||
for c <- wideColumns do
|
||||
val fullInt = (r << 5) + c
|
||||
|
||||
lookup.get(fullInt) match
|
||||
@ -181,18 +179,17 @@ object MatchOpcodes:
|
||||
val rows =
|
||||
0 to 7
|
||||
|
||||
for (c <- columns)
|
||||
out.print(s"<th>${paddedBinary(c, 3)}</th>")
|
||||
for c <- columns do out.print(s"<th>${paddedBinary(c, 3)}</th>")
|
||||
|
||||
out.print("</tr>")
|
||||
|
||||
for (r <- rows)
|
||||
for r <- rows do
|
||||
out.print("<tr>")
|
||||
|
||||
// left header
|
||||
out.print(s"<th>${paddedBinary(r, 3)}</th>")
|
||||
|
||||
for (c <- columns)
|
||||
for c <- columns do
|
||||
val fullInt = (r << (3 + 2)) + (c << 2) + n
|
||||
|
||||
lookup.get(fullInt) match
|
||||
|
@ -29,10 +29,8 @@ trait BitExtractor[A]:
|
||||
object AtomExtractor:
|
||||
@tailrec
|
||||
def pow(ex: Int, acc: Int = 1): Int =
|
||||
if (ex == 0)
|
||||
acc
|
||||
else
|
||||
pow(ex - 1, acc * 2)
|
||||
if ex == 0 then acc
|
||||
else pow(ex - 1, acc * 2)
|
||||
|
||||
abstract class PrimitiveBitExtractor(val length: Int) extends BitExtractor[Int]:
|
||||
private lazy val mask =
|
||||
|
@ -3,7 +3,7 @@ package com.htmlism.mos6502.dsl
|
||||
import scala.collection.immutable.ListSet
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
case class AsmDocument(xs: List[TopLevelAsmDocumentFragment]):
|
||||
def toAsm: String =
|
||||
|
@ -3,9 +3,9 @@ package com.htmlism.mos6502.dsl
|
||||
import scala.collection.immutable.ListSet
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
object DslDemo extends App:
|
||||
val cpu =
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
/**
|
||||
* A typed collection, like memory mapped to screen pixels. Access by index instead of by address.
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
import cats.syntax.all._
|
||||
import cats.syntax.all.*
|
||||
|
||||
import com.htmlism.mos6502.model.Instruction
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
package syntax
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
trait AsmSyntax:
|
||||
def label(s: String)(using ctx: AssemblyContext): Unit =
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
|
||||
import cats.data.NonEmptyList
|
||||
import org.scalatest.flatspec._
|
||||
import org.scalatest.matchers._
|
||||
import org.scalatest.flatspec.*
|
||||
import org.scalatest.matchers.*
|
||||
|
||||
class DslSpec extends AnyFlatSpec with should.Matchers:
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.htmlism.mos6502.dsl
|
||||
package snake
|
||||
|
||||
import cats.syntax.all._
|
||||
import org.scalatest.flatspec._
|
||||
import org.scalatest.matchers._
|
||||
import cats.syntax.all.*
|
||||
import org.scalatest.flatspec.*
|
||||
import org.scalatest.matchers.*
|
||||
|
||||
import com.htmlism.mos6502.model._
|
||||
import com.htmlism.mos6502.model.*
|
||||
|
||||
class Easy6502Spec extends AnyFlatSpec with should.Matchers:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user