diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2bbc4209..ed3128e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,7 +29,7 @@ jobs: run: chmod +x gradlew - name: Build - run: ./gradlew --no-daemon :desktop:bootJar + run: ./gradlew --no-daemon :desktop:shadowJar - name: Rename Build if: ${{ matrix.os == 'ubuntu-latest' }} diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Action53.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Action53.kt index 353608cd..343032da 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Action53.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Action53.kt @@ -97,7 +97,7 @@ class Action53(console: Console) : Mapper(console) { companion object { - @JvmStatic private val OUTER_AND = intArrayOf(0x1FE, 0x1FC, 0x1F8, 0x1F0) - @JvmStatic private val INNER_AND = intArrayOf(0x01, 0x03, 0x07, 0x0F) + private val OUTER_AND = intArrayOf(0x1FE, 0x1FC, 0x1F8, 0x1F0) + private val INNER_AND = intArrayOf(0x01, 0x03, 0x07, 0x0F) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuFrameCounter.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuFrameCounter.kt index 8aaf4c63..57de8bad 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuFrameCounter.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuFrameCounter.kt @@ -187,17 +187,17 @@ class ApuFrameCounter(private val console: Console) : MemoryHandler, Resetable, companion object { - @JvmStatic private val STEP_CYCLES_NTSC = arrayOf( + private val STEP_CYCLES_NTSC = arrayOf( intArrayOf(7457, 14913, 22371, 29828, 29829, 29830), intArrayOf(7457, 14913, 22371, 29829, 37281, 37282), ) - @JvmStatic private val STEP_CYCLES_PAL = arrayOf( + private val STEP_CYCLES_PAL = arrayOf( intArrayOf(8313, 16627, 24939, 33252, 33253, 33254), intArrayOf(8313, 16627, 24939, 33253, 41565, 41566), ) - @JvmStatic private val FRAME_TYPE = arrayOf( + private val FRAME_TYPE = arrayOf( arrayOf( FrameType.QUARTER, FrameType.HALF, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuLengthCounter.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuLengthCounter.kt index 191af40d..f3943449 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuLengthCounter.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ApuLengthCounter.kt @@ -100,7 +100,7 @@ abstract class ApuLengthCounter( companion object { - @JvmStatic protected val LC_LOOKUP_TABLE = intArrayOf( + private val LC_LOOKUP_TABLE = intArrayOf( 10, 254, 20, 2, 40, 4, 80, 6, 160, 8, 60, 10, 14, 12, 26, 14, 12, 16, 24, 18, 48, 20, 96, 22, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ArkanoidController.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ArkanoidController.kt index fb507bc7..8e8a1f59 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ArkanoidController.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ArkanoidController.kt @@ -80,6 +80,6 @@ class ArkanoidController( companion object { - @JvmStatic private val SENSIBILITY_PX = intArrayOf(0, 16, 32, 64) + private val SENSIBILITY_PX = intArrayOf(0, 16, 32, 64) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/AudioDevice.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/AudioDevice.kt index 08a411dc..35e7b9d3 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/AudioDevice.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/AudioDevice.kt @@ -1,8 +1,6 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -interface AudioDevice : Closeable { +interface AudioDevice : AutoCloseable { fun play(buffer: ShortArray, length: Int, sampleRate: Int, stereo: Boolean) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/BarcodeReader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/BarcodeReader.kt index 565cf324..ff4f7336 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/BarcodeReader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/BarcodeReader.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface BarcodeReader { +fun interface BarcodeReader { fun inputBarcode(barcode: Long, digitCount: Int) } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Battery.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Battery.kt index 26bb52ba..6165c22d 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Battery.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Battery.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface Battery { +sealed interface Battery { fun saveBattery() diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Blip.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Blip.kt index 729f02a7..84f30c6b 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Blip.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Blip.kt @@ -155,7 +155,7 @@ class Blip(private val size: Int) { const val MIN_SAMPLE = -32768 const val BLIP_MAX_FRAME = 4000 - @JvmStatic private val BL_STEP = arrayOf( + private val BL_STEP = arrayOf( shortArrayOf(43, -115, 350, -488, 1136, -914, 5861, 21022), shortArrayOf(44, -118, 348, -473, 1076, -799, 5274, 21001), shortArrayOf(45, -121, 344, -454, 1011, -677, 4706, 20936), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc11160.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc11160.kt index 29acddbe..af9a4687 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc11160.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc11160.kt @@ -10,7 +10,7 @@ class Bmc11160(console: Console) : Mapper(console) { override val chrPageSize = 0x2000 - override fun initialize() {} + override fun initialize() = Unit override fun reset(softReset: Boolean) { writeRegister(0x8000, 0) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc235.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc235.kt index 8fac42f2..745806da 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc235.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc235.kt @@ -74,7 +74,7 @@ class Bmc235(console: Console) : Mapper(console) { companion object { - @JvmStatic private val CONFIG = arrayOf( + private val CONFIG = arrayOf( arrayOf(intArrayOf(0x00, 0), intArrayOf(0x00, 1), intArrayOf(0x00, 1), intArrayOf(0x00, 1)), arrayOf(intArrayOf(0x00, 0), intArrayOf(0x00, 1), intArrayOf(0x20, 0), intArrayOf(0x00, 1)), arrayOf(intArrayOf(0x00, 0), intArrayOf(0x00, 1), intArrayOf(0x20, 0), intArrayOf(0x40, 0)), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc60311C.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc60311C.kt new file mode 100644 index 00000000..f9471f92 --- /dev/null +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc60311C.kt @@ -0,0 +1,64 @@ +package br.tiagohm.nestalgia.core + +// https://www.nesdev.org/wiki/NES_2.0_Mapper_289 + +class Bmc60311C(console: Console) : Mapper(console) { + + private var innerPrg = 0 + private var outerPrg = 0 + private var mode = 0 + + override val prgPageSize = 0x4000 + + override val chrPageSize = 0x2000 + + override val registerStartAddress = 0x6000 + + override val registerEndAddress = 0xFFFF + + override fun initialize() { + updateState() + selectChrPage(0, 0) + } + + private fun updateState() { + val page = outerPrg or (if (mode.bit2) 0 else innerPrg) + + when (mode and 0x03) { + 0 -> { + // 0: NROM-128: Same inner/outer 16 KiB bank at CPU $8000-$BFFF and $C000-$FFFF + selectPrgPage(0, page) + selectPrgPage(1, page) + } + 1 -> { + // 1: NROM-256: 32 kiB bank at CPU $8000-$FFFF (Selected inner/outer bank SHR 1) + selectPrgPage2x(0, page and 0xFE) + } + 2 -> { + // 2: UNROM: Inner/outer bank at CPU $8000-BFFF, fixed inner bank 7 within outer bank at $C000-$FFFF + selectPrgPage(0, page) + selectPrgPage(1, outerPrg or 7) + } + } + + mirroringType = if (mode.bit4) MirroringType.HORIZONTAL else MirroringType.VERTICAL + } + + override fun writeRegister(addr: Int, value: Int) { + if (addr >= 0x8000) { + innerPrg = value and 0x07 + updateState() + } else { + when (addr and 0xE001) { + 0x6000 -> { + mode = value and 0x0F + updateState() + } + 0x6001 -> { + outerPrg = value + updateState() + } + } + } + } +} diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc810544CA1.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc810544CA1.kt index f970b9af..b5c0fefe 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc810544CA1.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Bmc810544CA1.kt @@ -10,7 +10,7 @@ class Bmc810544CA1(console: Console) : Mapper(console) { override val chrPageSize = 0x2000 - override fun initialize() {} + override fun initialize() = Unit override fun reset(softReset: Boolean) { writeRegister(0x8000, 0) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/BmcNtd03.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/BmcNtd03.kt index 5c47cbc6..03caae63 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/BmcNtd03.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/BmcNtd03.kt @@ -10,7 +10,7 @@ class BmcNtd03(console: Console) : Mapper(console) { override val chrPageSize = 0x2000 - override fun initialize() {} + override fun initialize() = Unit override fun reset(softReset: Boolean) { writeRegister(0x8000, 0) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatDatabase.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatDatabase.kt index 0c7d985b..d8a02816 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatDatabase.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatDatabase.kt @@ -7,15 +7,13 @@ object CheatDatabase { const val FILENAME = "CheatDB.csv" - @JvmStatic private val ENTRIES = ArrayList(16384) - @JvmStatic private val LOG = LoggerFactory.getLogger(CheatDatabase::class.java) + private val ENTRIES = ArrayList(16384) + private val LOG = LoggerFactory.getLogger(CheatDatabase::class.java) - @JvmStatic operator fun get(crc: Long): List { return ENTRIES.filter { it.crc == crc } } - @JvmStatic fun load(data: Stream) { for (line in data) { if (line.isEmpty() || line.startsWith("#")) continue diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatInfo.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatInfo.kt index d4cd5db1..d04f3f7f 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatInfo.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatInfo.kt @@ -15,7 +15,6 @@ data class CheatInfo( companion object { - @JvmStatic fun parse(line: String): CheatInfo? { val parts = line.split(";") val hash = parts[0].also { if (it.isBlank()) return null } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatManager.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatManager.kt index 5d097012..93b68b38 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatManager.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/CheatManager.kt @@ -164,13 +164,13 @@ class CheatManager(private val console: Console) { private const val GAME_GENIE_LETTERS = "APZLGITYEOXUKSVN" - @JvmStatic private val GAME_GENIE_ADDRESS_BITS = intArrayOf(14, 13, 12, 19, 22, 21, 20, 7, 10, 9, 8, 15, 18, 17, 16) - @JvmStatic private val GAME_GENIE_VALUE_BITS = intArrayOf(3, 6, 5, 4, 23, 2, 1, 0) - @JvmStatic private val GAME_GENIE_VALUE_BITS_8 = intArrayOf(3, 6, 5, 4, 31, 2, 1, 0) - @JvmStatic private val GAME_GENIE_COMPARE_VALUE_BITS = intArrayOf(27, 30, 29, 28, 23, 26, 25, 24) + private val GAME_GENIE_ADDRESS_BITS = intArrayOf(14, 13, 12, 19, 22, 21, 20, 7, 10, 9, 8, 15, 18, 17, 16) + private val GAME_GENIE_VALUE_BITS = intArrayOf(3, 6, 5, 4, 23, 2, 1, 0) + private val GAME_GENIE_VALUE_BITS_8 = intArrayOf(3, 6, 5, 4, 31, 2, 1, 0) + private val GAME_GENIE_COMPARE_VALUE_BITS = intArrayOf(27, 30, 29, 28, 23, 26, 25, 24) // PAR - @JvmStatic private val PAR_SHIFT_VALUES = intArrayOf( + private val PAR_SHIFT_VALUES = intArrayOf( 3, 13, 14, 1, 6, 9, 5, 0, 12, 7, 2, 8, 10, 11, 4, // Address 19, 21, 23, 22, 20, 17, 16, 18, // Compare 29, 31, 24, 26, 25, 30, 27, 28, // Value diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Clockable.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Clockable.kt index f926b847..dc5ce3f1 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Clockable.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Clockable.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface Clockable { +fun interface Clockable { fun clock() } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Console.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Console.kt index 08c5895f..b1bb89cc 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Console.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Console.kt @@ -4,12 +4,11 @@ import br.tiagohm.nestalgia.core.EmulationFlag.* import br.tiagohm.nestalgia.core.NotificationType.* import br.tiagohm.nestalgia.core.Region.* import org.slf4j.LoggerFactory -import java.io.Closeable import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger import kotlin.random.Random -class Console(@JvmField val settings: EmulationSettings = EmulationSettings()) : Battery, Resetable, Closeable, Snapshotable, Runnable { +data class Console(@JvmField val settings: EmulationSettings = EmulationSettings()) : Battery, Resetable, AutoCloseable, Snapshotable, Runnable { private val pauseCounter = AtomicInteger(0) @@ -647,6 +646,6 @@ class Console(@JvmField val settings: EmulationSettings = EmulationSettings()) : companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(Console::class.java) + private val LOG = LoggerFactory.getLogger(Console::class.java) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlDevice.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlDevice.kt index 346a8e83..d2ae6af1 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlDevice.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlDevice.kt @@ -17,13 +17,13 @@ abstract class ControlDevice( open val keyboard = false - override fun reset(softReset: Boolean) {} + override fun reset(softReset: Boolean) = Unit protected fun isCurrentPort(addr: Int): Boolean { return port == (addr - 0x4016) } - protected open fun refreshStateBuffer() {} + protected open fun refreshStateBuffer() = Unit protected fun strobeOnRead() { if (strobe) refreshStateBuffer() @@ -96,9 +96,9 @@ abstract class ControlDevice( } } - open fun setStateFromInput() {} + open fun setStateFromInput() = Unit - open fun onAfterSetState() {} + open fun onAfterSetState() = Unit open fun hasControllerType(type: ControllerType): Boolean { return this.type == type @@ -128,9 +128,8 @@ abstract class ControlDevice( const val EXP_DEVICE_PORT_2 = 7 const val PORT_COUNT = 8 - @JvmStatic private val LOG = LoggerFactory.getLogger(ControlDevice::class.java) + private val LOG = LoggerFactory.getLogger(ControlDevice::class.java) - @JvmStatic internal fun swapButtons( device1: ControlDevice, button1: ControllerButton, device2: ControlDevice, button2: ControllerButton, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlManager.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlManager.kt index e977f035..6beb43bc 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlManager.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControlManager.kt @@ -5,9 +5,8 @@ import br.tiagohm.nestalgia.core.ControlDevice.Companion.EXP_DEVICE_PORT import br.tiagohm.nestalgia.core.ControllerType.* import br.tiagohm.nestalgia.core.MemoryAccessType.* import org.slf4j.LoggerFactory -import java.io.Closeable -open class ControlManager(protected val console: Console) : MemoryHandler, Resetable, Initializable, Snapshotable, Closeable { +open class ControlManager(protected val console: Console) : MemoryHandler, Resetable, Initializable, Snapshotable, AutoCloseable { private val inputProviders = HashSet() private val inputRecorders = HashSet() @@ -174,10 +173,10 @@ open class ControlManager(protected val console: Console) : MemoryHandler, Reset pollCounter++ } - protected open fun remapControllerButtons() {} + protected open fun remapControllerButtons() = Unit val hasKeyboard - get() = controlDevice(EXP_DEVICE_PORT)?.keyboard ?: false + get() = controlDevice(EXP_DEVICE_PORT)?.keyboard == true open fun openBusMask(port: Int): Int { // In the NES and Famicom, the top three (or five) bits are not driven, @@ -252,6 +251,6 @@ open class ControlManager(protected val console: Console) : MemoryHandler, Reset companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(ControlManager::class.java) + private val LOG = LoggerFactory.getLogger(ControlManager::class.java) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControllerHub.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControllerHub.kt index 52599711..355761a5 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControllerHub.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ControllerHub.kt @@ -53,6 +53,6 @@ abstract class ControllerHub( companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(ControllerHub::class.java) + private val LOG = LoggerFactory.getLogger(ControllerHub::class.java) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Cpu.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Cpu.kt index 6203f1d9..c5b1d049 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Cpu.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Cpu.kt @@ -1352,7 +1352,7 @@ class Cpu(private val console: Console) : Memory, Resetable, Initializable, Snap const val CLOCK_RATE_PAL = 1662607 const val CLOCK_RATE_DENDY = 1773448 - @JvmStatic private val ADDRESS_MODES = arrayOf( + private val ADDRESS_MODES = arrayOf( AddressMode.IMP, AddressMode.IND_X, AddressMode.NONE, AddressMode.IND_X, AddressMode.ZERO, AddressMode.ZERO, AddressMode.ZERO, AddressMode.ZERO, AddressMode.IMP, AddressMode.IMM, AddressMode.ACC, AddressMode.IMM, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/DatachBarcodeReader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/DatachBarcodeReader.kt index c9088d3f..28ab50c2 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/DatachBarcodeReader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/DatachBarcodeReader.kt @@ -128,7 +128,7 @@ class DatachBarcodeReader(console: Console) : ControlDevice(console, DATACH_BARC companion object { - @JvmStatic private val PREFIX_PARITY_TYPE = arrayOf( + private val PREFIX_PARITY_TYPE = arrayOf( intArrayOf(8, 8, 8, 8, 8, 8), intArrayOf(8, 8, 0, 8, 0, 0), intArrayOf(8, 8, 0, 0, 8, 0), intArrayOf(8, 8, 0, 0, 0, 8), intArrayOf(8, 0, 8, 8, 0, 0), intArrayOf(8, 0, 0, 8, 8, 0), @@ -136,7 +136,7 @@ class DatachBarcodeReader(console: Console) : ControlDevice(console, DATACH_BARC intArrayOf(8, 0, 8, 0, 0, 8), intArrayOf(8, 0, 0, 8, 0, 8), ) - @JvmStatic private val DATA_LEFT_ODD = arrayOf( + private val DATA_LEFT_ODD = arrayOf( intArrayOf(8, 8, 8, 0, 0, 8, 0), intArrayOf(8, 8, 0, 0, 8, 8, 0), intArrayOf(8, 8, 0, 8, 8, 0, 0), intArrayOf(8, 0, 0, 0, 0, 8, 0), intArrayOf(8, 0, 8, 8, 8, 0, 0), intArrayOf(8, 0, 0, 8, 8, 8, 0), @@ -144,7 +144,7 @@ class DatachBarcodeReader(console: Console) : ControlDevice(console, DATACH_BARC intArrayOf(8, 0, 0, 8, 0, 0, 0), intArrayOf(8, 8, 8, 0, 8, 0, 0), ) - @JvmStatic private val DATA_LEFT_EVEN = arrayOf( + private val DATA_LEFT_EVEN = arrayOf( intArrayOf(8, 0, 8, 8, 0, 0, 0), intArrayOf(8, 0, 0, 8, 8, 0, 0), intArrayOf(8, 8, 0, 0, 8, 0, 0), intArrayOf(8, 0, 8, 8, 8, 8, 0), intArrayOf(8, 8, 0, 0, 0, 8, 0), intArrayOf(8, 0, 0, 0, 8, 8, 0), @@ -152,7 +152,7 @@ class DatachBarcodeReader(console: Console) : ControlDevice(console, DATACH_BARC intArrayOf(8, 8, 8, 0, 8, 8, 0), intArrayOf(8, 8, 0, 8, 0, 0, 0), ) - @JvmStatic private val DATA_RIGHT = arrayOf( + private val DATA_RIGHT = arrayOf( intArrayOf(0, 0, 0, 8, 8, 0, 8), intArrayOf(0, 0, 8, 8, 0, 0, 8), intArrayOf(0, 0, 8, 0, 0, 8, 8), intArrayOf(0, 8, 8, 8, 8, 0, 8), intArrayOf(0, 8, 0, 0, 0, 8, 8), intArrayOf(0, 8, 8, 0, 0, 0, 8), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Debugger.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Debugger.kt index bd5d5c83..d66ba58d 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Debugger.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Debugger.kt @@ -1,10 +1,9 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger -class Debugger(private val console: Console) : Closeable { +data class Debugger(private val console: Console) : AutoCloseable { private val stepCount = AtomicInteger(-1) private val ppuStepCount = AtomicInteger(-1) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/DeltaModulationChannel.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/DeltaModulationChannel.kt index 2a9c1a18..5f2782ae 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/DeltaModulationChannel.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/DeltaModulationChannel.kt @@ -290,10 +290,10 @@ class DeltaModulationChannel( companion object { - @JvmStatic private val DMC_PERIOD_LOOKUP_TABLE_NTSC = + private val DMC_PERIOD_LOOKUP_TABLE_NTSC = shortArrayOf(428, 380, 340, 320, 286, 254, 226, 214, 190, 160, 142, 128, 106, 84, 72, 54) - @JvmStatic private val DMC_PERIOD_LOOKUP_TABLE_PAL = + private val DMC_PERIOD_LOOKUP_TABLE_PAL = shortArrayOf(398, 354, 316, 298, 276, 236, 210, 198, 176, 148, 132, 118, 98, 78, 66, 50) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Eeprom24C0X.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Eeprom24C0X.kt index 9161d505..d9edc324 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Eeprom24C0X.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Eeprom24C0X.kt @@ -1,8 +1,6 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -abstract class Eeprom24C0X(size: Int) : Battery, Closeable, Snapshotable { +abstract class Eeprom24C0X(size: Int) : Battery, AutoCloseable, Snapshotable { enum class Mode { IDLE, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/EmulationSettings.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/EmulationSettings.kt index 5e6b7918..b82b897c 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/EmulationSettings.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/EmulationSettings.kt @@ -398,10 +398,10 @@ class EmulationSettings : Snapshotable, Resetable { companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(EmulationSettings::class.java) + private val LOG = LoggerFactory.getLogger(EmulationSettings::class.java) // @formatter:off - @JvmStatic private val PALETTE_LUT = arrayOf( + private val PALETTE_LUT = arrayOf( /* 2C02 */ intArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63), /* 2C03 */ intArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 15, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 15, 62, 63), /* 2C04-0001 */ intArrayOf(53, 35, 22, 34, 28, 9, 29, 21, 32, 0, 39, 5, 4, 40, 8, 32, 33, 62, 31, 41, 60, 50, 54, 18, 63, 43, 46, 30, 61, 45, 36, 1, 14, 49, 51, 42, 44, 12, 27, 20, 46, 7, 52, 6, 19, 2, 38, 46, 46, 25, 16, 10, 57, 3, 55, 23, 15, 17, 11, 13, 56, 37, 24, 58), @@ -415,7 +415,7 @@ class EmulationSettings : Snapshotable, Resetable { /* 2C05-05 */ intArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 15, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 15, 62, 63), ) - @JvmStatic private val PPU_PALETTE_ARGB = arrayOf( + private val PPU_PALETTE_ARGB = arrayOf( /* 2C02 */ intArrayOf(0xFF666666.toInt(), 0xFF002A88.toInt(), 0xFF1412A7.toInt(), 0xFF3B00A4.toInt(), 0xFF5C007E.toInt(), 0xFF6E0040.toInt(), 0xFF6C0600.toInt(), 0xFF561D00.toInt(), 0xFF333500.toInt(), 0xFF0B4800.toInt(), 0xFF005200.toInt(), 0xFF004F08.toInt(), 0xFF00404D.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFADADAD.toInt(), 0xFF155FD9.toInt(), 0xFF4240FF.toInt(), 0xFF7527FE.toInt(), 0xFFA01ACC.toInt(), 0xFFB71E7B.toInt(), 0xFFB53120.toInt(), 0xFF994E00.toInt(), 0xFF6B6D00.toInt(), 0xFF388700.toInt(), 0xFF0C9300.toInt(), 0xFF008F32.toInt(), 0xFF007C8D.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFFFFEFF.toInt(), 0xFF64B0FF.toInt(), 0xFF9290FF.toInt(), 0xFFC676FF.toInt(), 0xFFF36AFF.toInt(), 0xFFFE6ECC.toInt(), 0xFFFE8170.toInt(), 0xFFEA9E22.toInt(), 0xFFBCBE00.toInt(), 0xFF88D800.toInt(), 0xFF5CE430.toInt(), 0xFF45E082.toInt(), 0xFF48CDDE.toInt(), 0xFF4F4F4F.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFFFFEFF.toInt(), 0xFFC0DFFF.toInt(), 0xFFD3D2FF.toInt(), 0xFFE8C8FF.toInt(), 0xFFFBC2FF.toInt(), 0xFFFEC4EA.toInt(), 0xFFFECCC5.toInt(), 0xFFF7D8A5.toInt(), 0xFFE4E594.toInt(), 0xFFCFEF96.toInt(), 0xFFBDF4AB.toInt(), 0xFFB3F3CC.toInt(), 0xFFB5EBF2.toInt(), 0xFFB8B8B8.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt()), /* 2C03 */ intArrayOf(0xFF6D6D6D.toInt(), 0xFF002491.toInt(), 0xFF0000DA.toInt(), 0xFF6D48DA.toInt(), 0xFF91006D.toInt(), 0xFFB6006D.toInt(), 0xFFB62400.toInt(), 0xFF914800.toInt(), 0xFF6D4800.toInt(), 0xFF244800.toInt(), 0xFF006D24.toInt(), 0xFF009100.toInt(), 0xFF004848.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFB6B6B6.toInt(), 0xFF006DDA.toInt(), 0xFF0048FF.toInt(), 0xFF9100FF.toInt(), 0xFFB600FF.toInt(), 0xFFFF0091.toInt(), 0xFFFF0000.toInt(), 0xFFDA6D00.toInt(), 0xFF916D00.toInt(), 0xFF249100.toInt(), 0xFF009100.toInt(), 0xFF00B66D.toInt(), 0xFF009191.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFFFFFFF.toInt(), 0xFF6DB6FF.toInt(), 0xFF9191FF.toInt(), 0xFFDA6DFF.toInt(), 0xFFFF00FF.toInt(), 0xFFFF6DFF.toInt(), 0xFFFF9100.toInt(), 0xFFFFB600.toInt(), 0xFFDADA00.toInt(), 0xFF6DDA00.toInt(), 0xFF00FF00.toInt(), 0xFF48FFDA.toInt(), 0xFF00FFFF.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFFFFFFFF.toInt(), 0xFFB6DAFF.toInt(), 0xFFDAB6FF.toInt(), 0xFFFFB6FF.toInt(), 0xFFFF91FF.toInt(), 0xFFFFB6B6.toInt(), 0xFFFFDA91.toInt(), 0xFFFFFF48.toInt(), 0xFFFFFF6D.toInt(), 0xFFB6FF48.toInt(), 0xFF91FF6D.toInt(), 0xFF48FFDA.toInt(), 0xFF91DAFF.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt()), /* 2C04-0001 */ intArrayOf(0xFFFFB6B6.toInt(), 0xFFDA6DFF.toInt(), 0xFFFF0000.toInt(), 0xFF9191FF.toInt(), 0xFF009191.toInt(), 0xFF244800.toInt(), 0xFF484848.toInt(), 0xFFFF0091.toInt(), 0xFFFFFFFF.toInt(), 0xFF6D6D6D.toInt(), 0xFFFFB600.toInt(), 0xFFB6006D.toInt(), 0xFF91006D.toInt(), 0xFFDADA00.toInt(), 0xFF6D4800.toInt(), 0xFFFFFFFF.toInt(), 0xFF6DB6FF.toInt(), 0xFFDAB66D.toInt(), 0xFF6D2400.toInt(), 0xFF6DDA00.toInt(), 0xFF91DAFF.toInt(), 0xFFDAB6FF.toInt(), 0xFFFFDA91.toInt(), 0xFF0048FF.toInt(), 0xFFFFDA00.toInt(), 0xFF48FFDA.toInt(), 0xFF000000.toInt(), 0xFF480000.toInt(), 0xFFDADADA.toInt(), 0xFF919191.toInt(), 0xFFFF00FF.toInt(), 0xFF002491.toInt(), 0xFF00006D.toInt(), 0xFFB6DAFF.toInt(), 0xFFFFB6FF.toInt(), 0xFF00FF00.toInt(), 0xFF00FFFF.toInt(), 0xFF004848.toInt(), 0xFF00B66D.toInt(), 0xFFB600FF.toInt(), 0xFF000000.toInt(), 0xFF914800.toInt(), 0xFFFF91FF.toInt(), 0xFFB62400.toInt(), 0xFF9100FF.toInt(), 0xFF0000DA.toInt(), 0xFFFF9100.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), 0xFF249100.toInt(), 0xFFB6B6B6.toInt(), 0xFF006D24.toInt(), 0xFFB6FF48.toInt(), 0xFF6D48DA.toInt(), 0xFFFFFF00.toInt(), 0xFFDA6D00.toInt(), 0xFF004800.toInt(), 0xFF006DDA.toInt(), 0xFF009100.toInt(), 0xFF242424.toInt(), 0xFFFFFF6D.toInt(), 0xFFFF6DFF.toInt(), 0xFF916D00.toInt(), 0xFF91FF6D.toInt()), @@ -430,7 +430,7 @@ class EmulationSettings : Snapshotable, Resetable { ) // @formatter:on - @JvmStatic val DEFAULT_PALETTE = intArrayOf( + internal val DEFAULT_PALETTE = intArrayOf( 0xFF666666.toInt(), 0xFF002A88.toInt(), 0xFF1412A7.toInt(), 0xFF3B00A4.toInt(), 0xFF5C007E.toInt(), 0xFF6E0040.toInt(), 0xFF6C0600.toInt(), 0xFF561D00.toInt(), 0xFF333500.toInt(), 0xFF0B4800.toInt(), 0xFF005200.toInt(), 0xFF004F08.toInt(), @@ -449,7 +449,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFB5EBF2.toInt(), 0xFFB8B8B8.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val UNSATURATED_PALETTE = intArrayOf( + internal val UNSATURATED_PALETTE = intArrayOf( 0xFF6B6B6B.toInt(), 0xFF001E87.toInt(), 0xFF1F0B96.toInt(), 0xFF3B0C87.toInt(), 0xFF590D61.toInt(), 0xFF5E0528.toInt(), 0xFF551100.toInt(), 0xFF461B00.toInt(), 0xFF303200.toInt(), 0xFF0A4800.toInt(), 0xFF004E00.toInt(), 0xFF004619.toInt(), @@ -468,7 +468,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFB7F0EE.toInt(), 0xFFBEBEBE.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val YUV_PALETTE = intArrayOf( + internal val YUV_PALETTE = intArrayOf( 0xFF666666.toInt(), 0xFF002A88.toInt(), 0xFF1412A7.toInt(), 0xFF3B00A4.toInt(), 0xFF5C007E.toInt(), 0xFF6E0040.toInt(), 0xFF6C0700.toInt(), 0xFF561D00.toInt(), 0xFF333500.toInt(), 0xFF0C4800.toInt(), 0xFF005200.toInt(), 0xFF004C18.toInt(), @@ -487,7 +487,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFB5EBF2.toInt(), 0xFFB8B8B8.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val NESTOPIA_PALETTE = intArrayOf( + internal val NESTOPIA_PALETTE = intArrayOf( 0xFF6D6D6D.toInt(), 0xFF002492.toInt(), 0xFF0000DB.toInt(), 0xFF6D49DB.toInt(), 0xFF92006D.toInt(), 0xFFB6006D.toInt(), 0xFFB62400.toInt(), 0xFF924900.toInt(), 0xFF6D4900.toInt(), 0xFF244900.toInt(), 0xFF006D24.toInt(), 0xFF009200.toInt(), @@ -506,7 +506,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFF92DBFF.toInt(), 0xFF929292.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val COMPOSITE_DIRECT_PALETTE = intArrayOf( + internal val COMPOSITE_DIRECT_PALETTE = intArrayOf( 0xFF656565.toInt(), 0xFF00127D.toInt(), 0xFF18008E.toInt(), 0xFF360082.toInt(), 0xFF56005D.toInt(), 0xFF5A0018.toInt(), 0xFF4F0500.toInt(), 0xFF381900.toInt(), 0xFF1D3100.toInt(), 0xFF003D00.toInt(), 0xFF004100.toInt(), 0xFF003B17.toInt(), @@ -525,7 +525,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFBFF1F1.toInt(), 0xFFB9B9B9.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val NES_CLASSIC_PALETTE = intArrayOf( + internal val NES_CLASSIC_PALETTE = intArrayOf( 0xFF60615F.toInt(), 0xFF000083.toInt(), 0xFF1D0195.toInt(), 0xFF340875.toInt(), 0xFF51055E.toInt(), 0xFF56000F.toInt(), 0xFF4C0700.toInt(), 0xFF372308.toInt(), 0xFF203A0B.toInt(), 0xFF0F4B0E.toInt(), 0xFF194C16.toInt(), 0xFF02421E.toInt(), @@ -544,7 +544,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFB9EAE9.toInt(), 0xFFABABAB.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val ORIGINAL_HARDWARE_PALETTE = intArrayOf( + internal val ORIGINAL_HARDWARE_PALETTE = intArrayOf( 0xFF6A6D6A.toInt(), 0xFF00127D.toInt(), 0xFF1E008A.toInt(), 0xFF3B007D.toInt(), 0xFF56005D.toInt(), 0xFF5A0018.toInt(), 0xFF4F0D00.toInt(), 0xFF381E00.toInt(), 0xFF203100.toInt(), 0xFF003D00.toInt(), 0xFF004000.toInt(), 0xFF003B1E.toInt(), @@ -563,7 +563,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFC4F6F6.toInt(), 0xFFBEC1BE.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val PVM_STYLE_PALETTE = intArrayOf( + internal val PVM_STYLE_PALETTE = intArrayOf( 0xFF696964.toInt(), 0xFF001774.toInt(), 0xFF28007D.toInt(), 0xFF3E006D.toInt(), 0xFF560057.toInt(), 0xFF5E0013.toInt(), 0xFF531A00.toInt(), 0xFF3B2400.toInt(), 0xFF2A3000.toInt(), 0xFF143A00.toInt(), 0xFF003F00.toInt(), 0xFF003B1E.toInt(), @@ -582,7 +582,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFFCAF3F3.toInt(), 0xFFBEBEB9.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val SONY_CXA_2025_PALETTE = intArrayOf( + internal val SONY_CXA_2025_PALETTE = intArrayOf( 0xFF585858.toInt(), 0xFF00238C.toInt(), 0xFF00139B.toInt(), 0xFF2D0585.toInt(), 0xFF5D0052.toInt(), 0xFF7A0017.toInt(), 0xFF7A0800.toInt(), 0xFF5F1800.toInt(), 0xFF352A00.toInt(), 0xFF093900.toInt(), 0xFF003F00.toInt(), 0xFF003C22.toInt(), @@ -601,7 +601,7 @@ class EmulationSettings : Snapshotable, Resetable { 0xFF91E4FE.toInt(), 0xFFACACAC.toInt(), 0xFF000000.toInt(), 0xFF000000.toInt(), ) - @JvmStatic val WAVEBEAM_PALETTE = intArrayOf( + internal val WAVEBEAM_PALETTE = intArrayOf( 0xFF6B6B6B.toInt(), 0xFF001B88.toInt(), 0xFF21009A.toInt(), 0xFF40008C.toInt(), 0xFF600067.toInt(), 0xFF64001E.toInt(), 0xFF590800.toInt(), 0xFF481600.toInt(), 0xFF283600.toInt(), 0xFF004500.toInt(), 0xFF004908.toInt(), 0xFF00421D.toInt(), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Emulator.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Emulator.kt index bfc2d569..a6fd04b7 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Emulator.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Emulator.kt @@ -2,7 +2,6 @@ package br.tiagohm.nestalgia.core import java.awt.image.BufferedImage import java.awt.image.DataBufferInt -import java.io.Closeable import java.io.InputStream import java.io.OutputStream import java.util.concurrent.ExecutorService @@ -17,7 +16,7 @@ data class Emulator( @JvmField val keyManager: KeyManager, @JvmField val inputProviders: Iterable, @JvmField val threadExecutor: ExecutorService = DEFAULT_THREAD_EXECUTOR, -) : NotificationListener, Resetable, Closeable { +) : NotificationListener, Resetable, AutoCloseable { private val emuThread = AtomicReference>() @@ -41,7 +40,7 @@ data class Emulator( emuThread.getAndSet(null)?.cancel(true) } - override fun processNotification(type: NotificationType, vararg data: Any?) {} + override fun processNotification(type: NotificationType, vararg data: Any?) = Unit fun load(rom: IntArray, name: String, fdsBios: IntArray = IntArray(0)): Boolean { return if (console.initialize(rom, name, true, fdsBios)) { @@ -250,6 +249,6 @@ data class Emulator( companion object { - @JvmStatic private val DEFAULT_THREAD_EXECUTOR = Executors.newSingleThreadExecutor(EmulatorThreadFactory) + private val DEFAULT_THREAD_EXECUTOR = Executors.newSingleThreadExecutor(EmulatorThreadFactory) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/FamilyTrainerMat.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/FamilyTrainerMat.kt index 6fe6fa9b..24da8c69 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/FamilyTrainerMat.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/FamilyTrainerMat.kt @@ -4,7 +4,7 @@ class FamilyTrainerMat(console: Console, type: ControllerType, keyMapping: KeyMa private var ignoreRows = 0 - override fun refreshStateBuffer() {} + override fun refreshStateBuffer() = Unit override fun read(addr: Int, type: MemoryOperationType): Int { return if (addr == 0x4017) { diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/FdsAudio.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/FdsAudio.kt index 94312be2..bc39e402 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/FdsAudio.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/FdsAudio.kt @@ -161,6 +161,6 @@ class FdsAudio(console: Console) : ExpansionAudio(console), Memory { companion object { - @JvmStatic private val WAVE_VOLUME_TABLE = intArrayOf(36, 24, 17, 14) + private val WAVE_VOLUME_TABLE = intArrayOf(36, 24, 17, 14) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameDatabase.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameDatabase.kt index 19b3e481..eeaa24c7 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameDatabase.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameDatabase.kt @@ -7,13 +7,11 @@ object GameDatabase { const val FILENAME = "NesDB.csv" - @JvmStatic private val ENTRIES = HashMap(8192) - @JvmStatic private val LOG = LoggerFactory.getLogger(GameDatabase::class.java) + private val ENTRIES = HashMap(8192) + private val LOG = LoggerFactory.getLogger(GameDatabase::class.java) - @JvmStatic operator fun get(crc: Long) = ENTRIES[crc] - @JvmStatic fun load(data: Stream) { for (line in data) { if (line.isEmpty() || line.startsWith("#")) continue diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameInfo.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameInfo.kt index f551c2d6..f5c2405d 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameInfo.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/GameInfo.kt @@ -110,7 +110,6 @@ data class GameInfo( companion object { - @JvmStatic fun parse(line: String): GameInfo { val parts = line.split(";", ",") diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ghostbusters63in1.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ghostbusters63in1.kt index c2093cc7..9716d11f 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ghostbusters63in1.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ghostbusters63in1.kt @@ -10,7 +10,7 @@ class Ghostbusters63in1(console: Console) : Mapper(console) { private var regs = IntArray(2) - override fun initialize() {} + override fun initialize() = Unit override fun reset(softReset: Boolean) { regs.fill(0) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/HashInfo.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/HashInfo.kt index 96653975..e60e90b2 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/HashInfo.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/HashInfo.kt @@ -20,6 +20,6 @@ data class HashInfo( companion object { - @JvmStatic val EMPTY = HashInfo() + val EMPTY = HashInfo() } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/INesLoader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/INesLoader.kt index 2087490c..ab520ab9 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/INesLoader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/INesLoader.kt @@ -5,9 +5,8 @@ import java.io.IOException object INesLoader { - @JvmStatic private val LOG = LoggerFactory.getLogger(INesLoader::class.java) + private val LOG = LoggerFactory.getLogger(INesLoader::class.java) - @JvmStatic fun load(rom: IntArray, name: String, preloadedHeader: NesHeader? = null): RomData { var dataSize = rom.size var offset = 0 diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Initializable.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Initializable.kt index 4f1aef98..bf3736a1 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Initializable.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Initializable.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface Initializable { +fun interface Initializable { fun initialize() } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputProvider.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputProvider.kt index b575a26c..5a05afec 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputProvider.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputProvider.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface InputProvider { +fun interface InputProvider { fun setInput(device: ControlDevice): Boolean } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputRecorder.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputRecorder.kt index 13a335d3..f57d2bfa 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputRecorder.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/InputRecorder.kt @@ -1,8 +1,6 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -interface InputRecorder : Closeable { +sealed interface InputRecorder : AutoCloseable { fun recordInput(devices: Iterable) } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/IpsPatcher.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/IpsPatcher.kt index 25e860c0..a3bf4009 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/IpsPatcher.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/IpsPatcher.kt @@ -5,10 +5,9 @@ import java.nio.IntBuffer object IpsPatcher { - @JvmStatic private val PATCH_BYTES = "PATCH".toByteArray(Charsets.US_ASCII) - @JvmStatic private val EOF_BYTES = "EOF".toByteArray(Charsets.US_ASCII) + private val PATCH_BYTES = "PATCH".toByteArray(Charsets.US_ASCII) + private val EOF_BYTES = "EOF".toByteArray(Charsets.US_ASCII) - @JvmStatic fun patch( ipsData: IntArray, input: IntArray, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/JalecoSs88006.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/JalecoSs88006.kt index 9ece4641..5a194cf4 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/JalecoSs88006.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/JalecoSs88006.kt @@ -136,6 +136,6 @@ class JalecoSs88006(console: Console) : Mapper(console) { companion object { - @JvmStatic private val IRQ_MASK = intArrayOf(0xFFFF, 0x0FFF, 0x00FF, 0x000F) + private val IRQ_MASK = intArrayOf(0xFFFF, 0x0FFF, 0x00FF, 0x000F) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Key.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Key.kt index 672c3a22..5657a023 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Key.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Key.kt @@ -2,15 +2,14 @@ package br.tiagohm.nestalgia.core import java.io.Serializable -interface Key : Serializable { +sealed interface Key : Serializable { val code: Int companion object { - @JvmStatic val UNDEFINED: Key = KeyboardKeys.UNDEFINED + val UNDEFINED: Key = KeyboardKeys.UNDEFINED - @JvmStatic fun of(code: Int): Key = if (code == 0) UNDEFINED else KeyboardKeys.MAPPED_ENTRIES[code]!! } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyMapping.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyMapping.kt index d7f10388..da8be23e 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyMapping.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyMapping.kt @@ -168,7 +168,6 @@ data class KeyMapping( companion object { - @JvmStatic fun wasd() = KeyMapping( KeyboardKeys.E, KeyboardKeys.Q, KeyboardKeys.W, KeyboardKeys.S, @@ -176,7 +175,6 @@ data class KeyMapping( KeyboardKeys.X, KeyboardKeys.Z, ) - @JvmStatic fun arrowKeys() = KeyMapping( KeyboardKeys.L, KeyboardKeys.K, KeyboardKeys.UP, KeyboardKeys.DOWN, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyboardKeys.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyboardKeys.kt index 1291c440..155cbade 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyboardKeys.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/KeyboardKeys.kt @@ -91,8 +91,7 @@ enum class KeyboardKeys(val description: String, override val code: Int) : Key { companion object { - @JvmStatic internal val ENTRIES = values() - @JvmStatic internal val MAPPED_ENTRIES = ENTRIES.associateBy { it.code } - @JvmStatic val SORTED_KEYS = ENTRIES.sortedBy { it.description } + internal val MAPPED_ENTRIES = entries.associateBy { it.code } + val SORTED_KEYS = entries.sortedBy { it.description } } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MMC3.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MMC3.kt index e8ce18a4..989bc7de 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MMC3.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MMC3.kt @@ -295,6 +295,6 @@ open class MMC3(console: Console) : Mapper(console) { companion object { - @JvmStatic protected val MEMORY_ACCESS_TYPES = arrayOf(NO_ACCESS, READ, WRITE, READ_WRITE) + internal val MEMORY_ACCESS_TYPES = arrayOf(NO_ACCESS, READ, WRITE, READ_WRITE) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper.kt index d4cd5da4..0096c82b 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper.kt @@ -8,13 +8,12 @@ import br.tiagohm.nestalgia.core.MirroringType.* import br.tiagohm.nestalgia.core.PrgMemoryType.* import br.tiagohm.nestalgia.core.PrgMemoryType.ROM import org.slf4j.LoggerFactory -import java.io.Closeable import kotlin.math.min import kotlin.random.Random // https://wiki.nesdev.com/w/index.php/Mapper -abstract class Mapper(@JvmField protected val console: Console) : Resetable, Battery, Peekable, MemoryHandler, Initializable, Clockable, Snapshotable, Closeable { +abstract class Mapper(@JvmField protected val console: Console) : Resetable, Battery, Peekable, MemoryHandler, Initializable, Clockable, Snapshotable, AutoCloseable { open val prgPageSize = 0 @@ -135,15 +134,15 @@ abstract class Mapper(@JvmField protected val console: Console) : Resetable, Bat private val chrMemoryOffset = IntArray(0x100) private val chrMemoryType = Array(0x100) { DEFAULT } - override fun close() {} + override fun close() = Unit - override fun reset(softReset: Boolean) {} + override fun reset(softReset: Boolean) = Unit - protected open fun writeRegister(addr: Int, value: Int) {} + protected open fun writeRegister(addr: Int, value: Int) = Unit protected open fun readRegister(addr: Int) = 0 - open fun updateRegion(region: Region) {} + open fun updateRegion(region: Region) = Unit override fun saveBattery() { if (hasBattery && mSaveRamSize > 0) { @@ -853,7 +852,7 @@ abstract class Mapper(@JvmField protected val console: Console) : Resetable, Bat return addr shr 8 } - open fun applySamples(buffer: ShortArray, sampleCount: Int, volume: Double) {} + open fun applySamples(buffer: ShortArray, sampleCount: Int, volume: Double) = Unit val dipSwitches get() = console.settings.dipSwitches and ((1 shl dipSwitchCount) - 1) @@ -934,16 +933,14 @@ abstract class Mapper(@JvmField protected val console: Console) : Resetable, Bat companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(Mapper::class.java) + private val LOG = LoggerFactory.getLogger(Mapper::class.java) - @JvmStatic private fun wrapPageNumber(page: Int, pageCount: Int): Int { // Can't use modulo for negative number because pageCount // is sometimes not a power of 2. (Fixes some Mapper 191 games). return if (page < 0) pageCount + page else page % pageCount } - @JvmStatic fun initialize( console: Console, rom: IntArray, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper043.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper043.kt index 14740983..0a8df57b 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper043.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper043.kt @@ -87,6 +87,6 @@ class Mapper043(console: Console) : Mapper(console) { companion object { - @JvmStatic private val LUT = intArrayOf(4, 3, 5, 3, 6, 3, 7, 3) + private val LUT = intArrayOf(4, 3, 5, 3, 6, 3, 7, 3) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper114.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper114.kt index 30d1f868..a0d97b43 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper114.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper114.kt @@ -73,6 +73,6 @@ class Mapper114(console: Console) : MMC3(console) { companion object { - @JvmStatic private val SECURITY = intArrayOf(0, 3, 1, 5, 6, 7, 2, 4) + private val SECURITY = intArrayOf(0, 3, 1, 5, 6, 7, 2, 4) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper121.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper121.kt index 84a886dd..cfeab437 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper121.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper121.kt @@ -142,6 +142,6 @@ class Mapper121(console: Console) : MMC3(console) { companion object { - @JvmStatic private val LOOKUP = intArrayOf(0x83, 0x83, 0x42, 0x00) + private val LOOKUP = intArrayOf(0x83, 0x83, 0x42, 0x00) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper123.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper123.kt index ae826a0a..96c30ae9 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper123.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper123.kt @@ -63,6 +63,6 @@ class Mapper123(console: Console) : MMC3(console) { companion object { - @JvmStatic private val SECURITY = intArrayOf(0, 3, 1, 5, 6, 7, 2, 4) + private val SECURITY = intArrayOf(0, 3, 1, 5, 6, 7, 2, 4) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper187.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper187.kt index 68632381..2b2f7c31 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper187.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper187.kt @@ -92,6 +92,6 @@ class Mapper187(console: Console) : MMC3(console) { companion object { - @JvmStatic private val SECURITY = intArrayOf(0x83, 0x83, 0x42, 0x00) + private val SECURITY = intArrayOf(0x83, 0x83, 0x42, 0x00) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper208.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper208.kt index e3610d7e..183b5669 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper208.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper208.kt @@ -63,7 +63,7 @@ class Mapper208(console: Console) : MMC3(console) { companion object { - @JvmStatic private val PROTECTION_LUT = intArrayOf( + private val PROTECTION_LUT = intArrayOf( 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x51, 0x41, 0x11, 0x01, 0x51, 0x41, 0x11, 0x01, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x59, 0x49, 0x19, 0x09, 0x59, 0x49, 0x19, 0x09, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper215.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper215.kt index 5e72841c..7fa33542 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper215.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper215.kt @@ -92,7 +92,7 @@ class Mapper215(console: Console) : MMC3(console) { companion object { - @JvmStatic private val LUT_REG = arrayOf( + private val LUT_REG = arrayOf( intArrayOf(0, 1, 2, 3, 4, 5, 6, 7), intArrayOf(0, 2, 6, 1, 7, 3, 4, 5), intArrayOf(0, 5, 4, 1, 7, 2, 6, 3), @@ -103,7 +103,7 @@ class Mapper215(console: Console) : MMC3(console) { intArrayOf(0, 1, 2, 3, 4, 5, 6, 7), ) - @JvmStatic private val LUT_ADDR = arrayOf( + private val LUT_ADDR = arrayOf( intArrayOf(0, 1, 2, 3, 4, 5, 6, 7), intArrayOf(3, 2, 0, 4, 1, 5, 6, 7), intArrayOf(0, 1, 2, 3, 4, 5, 6, 7), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper217.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper217.kt index 836e5085..e374d49c 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper217.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper217.kt @@ -110,6 +110,6 @@ class Mapper217(console: Console) : MMC3(console) { companion object { - @JvmStatic private val LUT = intArrayOf(0, 6, 3, 7, 5, 2, 4, 1) + private val LUT = intArrayOf(0, 6, 3, 7, 5, 2, 4, 1) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper219.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper219.kt index 00444033..c76d2b37 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper219.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper219.kt @@ -13,9 +13,9 @@ class Mapper219(console: Console) : MMC3(console) { selectChrPage8x(0, 0) } - override fun updatePrgMapping() {} + override fun updatePrgMapping() = Unit - override fun updateChrMapping() {} + override fun updateChrMapping() = Unit override fun writeRegister(addr: Int, value: Int) { if (addr < 0xA000) { diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper238.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper238.kt index b4823d63..9d24a6d9 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper238.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper238.kt @@ -43,6 +43,6 @@ class Mapper238(console: Console) : MMC3(console) { companion object { - @JvmStatic private val SECURITY_LUT = intArrayOf(0x00, 0x02, 0x02, 0x03) + private val SECURITY_LUT = intArrayOf(0x00, 0x02, 0x02, 0x03) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper244.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper244.kt index 40664f7d..8fbfa96a 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper244.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Mapper244.kt @@ -23,14 +23,14 @@ class Mapper244(console: Console) : Mapper(console) { companion object { - @JvmStatic private val LUT_PRG = arrayOf( + private val LUT_PRG = arrayOf( intArrayOf(0, 1, 2, 3), intArrayOf(3, 2, 1, 0), intArrayOf(0, 2, 1, 3), intArrayOf(3, 1, 2, 0), ) - @JvmStatic private val LUT_CHR = arrayOf( + private val LUT_CHR = arrayOf( intArrayOf(0, 1, 2, 3, 4, 5, 6, 7), intArrayOf(0, 2, 1, 3, 4, 6, 5, 7), intArrayOf(0, 1, 4, 5, 2, 3, 6, 7), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MapperFactory.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MapperFactory.kt index 209ab832..c9e3b00e 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MapperFactory.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MapperFactory.kt @@ -7,9 +7,8 @@ object MapperFactory { const val FDS_MAPPER_ID = 65535 - @JvmStatic private val LOG = LoggerFactory.getLogger(MapperFactory::class.java) + private val LOG = LoggerFactory.getLogger(MapperFactory::class.java) - @JvmStatic fun from(console: Console, data: RomData): Mapper { return when (val id = data.info.mapperId) { 0 -> NROM(console) @@ -257,6 +256,7 @@ object MapperFactory { 286 -> Bs5(console) 287 -> Bmc411120C(console) 288 -> Gkcx1(console) + 289 -> Bmc60311C(console) 290 -> BmcNtd03(console) 299 -> Bmc11160(console) 300 -> Bmc190in1(console) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Memory.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Memory.kt index a1f66511..27fab1fe 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Memory.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Memory.kt @@ -2,7 +2,7 @@ package br.tiagohm.nestalgia.core import br.tiagohm.nestalgia.core.MemoryOperationType.* -interface Memory { +sealed interface Memory { fun read(addr: Int, type: MemoryOperationType = MEMORY_READ) = 0 diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryHandler.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryHandler.kt index 9ed4ccd8..c9d37cb1 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryHandler.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryHandler.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface MemoryHandler : Memory, Peekable { +sealed interface MemoryHandler : Memory, Peekable { fun memoryRanges(ranges: MemoryRanges) } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryType.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryType.kt index 0d7eb7d7..c8d85058 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryType.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/MemoryType.kt @@ -1,3 +1,3 @@ package br.tiagohm.nestalgia.core -interface MemoryType \ No newline at end of file +sealed interface MemoryType diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ModulationChannel.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ModulationChannel.kt index 4acd20d5..3dace532 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/ModulationChannel.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/ModulationChannel.kt @@ -127,6 +127,6 @@ class ModulationChannel : FdsChannel() { private const val RESET = 0xFF - @JvmStatic private val MOD_LUT = intArrayOf(0, 1, 2, 4, RESET, -4, -2, -1) + private val MOD_LUT = intArrayOf(0, 1, 2, 4, RESET, -4, -2, -1) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Namco163.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Namco163.kt index e708d889..eb50aaf4 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Namco163.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Namco163.kt @@ -285,6 +285,6 @@ class Namco163(console: Console) : Mapper(console) { companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(Namco163::class.java) + private val LOG = LoggerFactory.getLogger(Namco163::class.java) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NesHeader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NesHeader.kt index 720418c0..e017d699 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NesHeader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NesHeader.kt @@ -206,6 +206,6 @@ data class NesHeader( companion object { - @JvmStatic val EMPTY = NesHeader() + val EMPTY = NesHeader() } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NoiseChannel.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NoiseChannel.kt index 86153aba..c78fef80 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NoiseChannel.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NoiseChannel.kt @@ -89,7 +89,7 @@ class NoiseChannel( companion object { - @JvmStatic val NOISE_PERIOD_LOOKUP_TABLE_NTSC = intArrayOf(4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068) - @JvmStatic val NOISE_PERIOD_LOOKUP_TABLE_PAL = intArrayOf(4, 8, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778) + internal val NOISE_PERIOD_LOOKUP_TABLE_NTSC = intArrayOf(4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068) + internal val NOISE_PERIOD_LOOKUP_TABLE_PAL = intArrayOf(4, 8, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationListener.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationListener.kt index 5c429fc4..9d5eef05 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationListener.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationListener.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface NotificationListener { +fun interface NotificationListener { fun processNotification(type: NotificationType, vararg data: Any?) } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationManager.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationManager.kt index 03292e87..a9304d9e 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationManager.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NotificationManager.kt @@ -1,8 +1,6 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -class NotificationManager : Closeable { +class NotificationManager : AutoCloseable { private val listeners = ArrayList() diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NsfMapper.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NsfMapper.kt index 17c10041..284a130e 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/NsfMapper.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/NsfMapper.kt @@ -5,7 +5,7 @@ class NsfMapper(console: Console) : Mapper(console) { override val dipSwitchCount: Int get() = TODO("Not yet implemented") - override fun initialize() {} + override fun initialize() = Unit override fun close() { console.settings.disableOverclocking = false diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/OpenBusHandler.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/OpenBusHandler.kt index 3fe41e6b..3e1c08c0 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/OpenBusHandler.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/OpenBusHandler.kt @@ -4,7 +4,7 @@ class OpenBusHandler : MemoryHandler { @JvmField var openBus = 0 - override fun memoryRanges(ranges: MemoryRanges) {} + override fun memoryRanges(ranges: MemoryRanges) = Unit override fun read(addr: Int, type: MemoryOperationType) = openBus diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Peekable.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Peekable.kt index 921f9e48..3f24e27e 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Peekable.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Peekable.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface Peekable { +sealed interface Peekable { fun peek(addr: Int) = 0 diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Pointer.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Pointer.kt index 633b50d5..e63144e0 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Pointer.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Pointer.kt @@ -59,6 +59,6 @@ open class Pointer( companion object { - @JvmStatic val NULL = Pointer(IntArray(0), 0) + internal val NULL = Pointer(IntArray(0), 0) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ppu.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ppu.kt index ab9b1f44..c2818437 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ppu.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Ppu.kt @@ -1670,10 +1670,10 @@ open class Ppu(private val console: Console) : MemoryHandler, Resetable, Initial const val PIXEL_COUNT = SCREEN_WIDTH * SCREEN_HEIGHT const val OAM_DECAY_CYCLE_COUNT = 3000L - @JvmStatic private val STATUS_REG_2C05E = intArrayOf(0x00, -1) - @JvmStatic private val STATUS_REG_NULL = intArrayOf(-1, -1) + private val STATUS_REG_2C05E = intArrayOf(0x00, -1) + private val STATUS_REG_NULL = intArrayOf(-1, -1) - @JvmStatic val PALETTE_BOOT_RAM = intArrayOf( + internal val PALETTE_BOOT_RAM = intArrayOf( 0x09, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x0D, // 0x08, 0x10, 0x08, 0x24, 0x00, 0x00, 0x04, 0x2C, // 0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, // diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Register.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Register.kt index c1253fa6..16794360 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Register.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Register.kt @@ -1,6 +1,6 @@ package br.tiagohm.nestalgia.core -interface Register { +sealed interface Register { val address: Int } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RenderingDevice.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RenderingDevice.kt index a1817d59..888ae21c 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RenderingDevice.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RenderingDevice.kt @@ -1,8 +1,6 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -interface RenderingDevice : Resetable, Closeable { +interface RenderingDevice : Resetable, AutoCloseable { fun updateFrame(buffer: IntArray, width: Int, height: Int) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomData.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomData.kt index 787e3a81..cbbbaed5 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomData.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomData.kt @@ -52,6 +52,6 @@ data class RomData( companion object { - @JvmStatic val EMPTY = RomData() + val EMPTY = RomData() } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomInfo.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomInfo.kt index 3bf5aac8..69df748b 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomInfo.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomInfo.kt @@ -28,6 +28,6 @@ data class RomInfo( companion object { - @JvmStatic val EMPTY = RomInfo() + val EMPTY = RomInfo() } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomLoader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomLoader.kt index 3d222b95..bf2179b2 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomLoader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/RomLoader.kt @@ -5,7 +5,6 @@ import java.util.* object RomLoader { - @JvmStatic fun load( rom: IntArray, name: String, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SaveStateManager.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SaveStateManager.kt index 2c861956..24e8dd57 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SaveStateManager.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SaveStateManager.kt @@ -4,7 +4,7 @@ import java.io.IOException class SaveStateManager(private val console: Console) : Snapshotable, Resetable { - override fun reset(softReset: Boolean) {} + override fun reset(softReset: Boolean) = Unit override fun saveState(s: Snapshot) { val data = Snapshot() diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Snapshot.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Snapshot.kt index d8a41a1d..d6850ee8 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Snapshot.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Snapshot.kt @@ -160,15 +160,13 @@ class Snapshot private constructor(private val data: MutableMap) : companion object { - @JvmStatic private val serialVersionUID = 1L + private val serialVersionUID = 1L - @JvmStatic fun from(source: InputStream): Snapshot { val stream = ObjectInputStream(source) return stream.readObject() as Snapshot } - @JvmStatic fun from(source: ByteArray): Snapshot { return from(ByteArrayInputStream(source)) } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SoundMixer.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SoundMixer.kt index 2c5cf547..2e54f86b 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SoundMixer.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SoundMixer.kt @@ -1,9 +1,8 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable import java.util.* -class SoundMixer(private val console: Console) : Resetable, Closeable, Snapshotable { +class SoundMixer(private val console: Console) : Resetable, AutoCloseable, Snapshotable { private var clockRate = 0 private val outputBuffer = ShortArray(MAX_SAMPLES_PER_FRAME) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SquareChannel.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SquareChannel.kt index 6f85138a..8ba2c977 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/SquareChannel.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/SquareChannel.kt @@ -206,7 +206,7 @@ open class SquareChannel( companion object { - @JvmStatic val DUTY_SEQUENCES = arrayOf( + @PublishedApi internal val DUTY_SEQUENCES = arrayOf( intArrayOf(0, 0, 0, 0, 0, 0, 0, 1), intArrayOf(0, 0, 0, 0, 0, 0, 1, 1), intArrayOf(0, 0, 0, 0, 1, 1, 1, 1), diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/StudyBoxData.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/StudyBoxData.kt index 2cfb45ce..d84a470d 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/StudyBoxData.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/StudyBoxData.kt @@ -25,6 +25,6 @@ data class StudyBoxData( companion object { - @JvmStatic val EMPTY = StudyBoxData() + val EMPTY = StudyBoxData() } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/TriangleChannel.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/TriangleChannel.kt index 72a0b3cf..d93cc994 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/TriangleChannel.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/TriangleChannel.kt @@ -113,7 +113,7 @@ class TriangleChannel( companion object { - @JvmStatic private val SEQUENCE = intArrayOf( + private val SEQUENCE = intArrayOf( 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Txc22211b.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Txc22211b.kt index b3a3915a..8ce99c8c 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Txc22211b.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Txc22211b.kt @@ -66,14 +66,12 @@ class Txc22211b(console: Console) : Mapper(console) { companion object { - @JvmStatic - private fun convertValue(v: Int): Int { - return (v and 0x01 shl 5) or - (v and 0x02 shl 3) or - (v and 0x04 shl 1) or - (v and 0x08 shr 1) or - (v and 0x10 shr 3) or - (v and 0x20 shr 5) - } + @Suppress("NOTHING_TO_INLINE") + private inline fun convertValue(v: Int) = (v and 0x01 shl 5) or + (v and 0x02 shl 3) or + (v and 0x04 shl 1) or + (v and 0x08 shr 1) or + (v and 0x10 shr 3) or + (v and 0x20 shr 5) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/UnifLoader.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/UnifLoader.kt index bd7dacf0..fa9a3e26 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/UnifLoader.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/UnifLoader.kt @@ -4,10 +4,8 @@ import java.io.IOException object UnifLoader { - @JvmStatic fun load(rom: IntArray, name: String) = read(rom, name) - @JvmStatic private fun read(rom: IntArray, name: String): RomData { // Skip header, version & null bytes, start reading at first chunk var offset = 32 diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Unl158B.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Unl158B.kt index 61fc6b14..6f0c16f3 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Unl158B.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Unl158B.kt @@ -66,6 +66,6 @@ class Unl158B(console: Console) : MMC3(console) { companion object { - @JvmStatic private val PROTECTION_LUT = intArrayOf(0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00) + private val PROTECTION_LUT = intArrayOf(0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VRC24.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VRC24.kt index 4d61a993..f821c21a 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VRC24.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VRC24.kt @@ -293,6 +293,6 @@ class VRC24(console: Console) : Mapper(console) { companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(VRC24::class.java) + private val LOG = LoggerFactory.getLogger(VRC24::class.java) } } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoDecoder.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoDecoder.kt index f5824ed8..ca2add26 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoDecoder.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoDecoder.kt @@ -1,11 +1,10 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable import java.util.concurrent.Semaphore import java.util.concurrent.atomic.AtomicBoolean import kotlin.concurrent.thread -class VideoDecoder(private val console: Console) : Closeable, Resetable { +class VideoDecoder(private val console: Console) : AutoCloseable, Resetable { private val stop = AtomicBoolean() private val decoder = DecoderVideoFilter(console) diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoFilter.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoFilter.kt index 259a84c1..939666ed 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoFilter.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoFilter.kt @@ -1,12 +1,10 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable - -interface VideoFilter : Closeable { +sealed interface VideoFilter : AutoCloseable { fun sendFrame(input: IntArray): IntArray fun takeScreenshot(): IntArray - override fun close() {} + override fun close() = Unit } diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoRenderer.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoRenderer.kt index 697d8f6b..bf8c8559 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoRenderer.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VideoRenderer.kt @@ -1,12 +1,11 @@ package br.tiagohm.nestalgia.core -import java.io.Closeable import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicBoolean import kotlin.concurrent.thread -class VideoRenderer(private val console: Console) : Closeable { +data class VideoRenderer(private val console: Console) : AutoCloseable { private var stop = AtomicBoolean(false) private var renderThread: Thread? = null diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VsControlManager.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VsControlManager.kt index 454d7404..6e97b7d4 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/VsControlManager.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/VsControlManager.kt @@ -141,7 +141,7 @@ class VsControlManager(console: Console) : ControlManager(console) { companion object { - @JvmStatic private val PROTECTION_DATA = arrayOf( + private val PROTECTION_DATA = arrayOf( intArrayOf( 0xFF, 0xBF, 0xB7, 0x97, 0x97, 0x17, 0x57, 0x4F, 0x6F, 0x6B, 0xEB, 0xA9, 0xB1, 0x90, 0x94, 0x14, diff --git a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Zapper.kt b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Zapper.kt index 52a62c04..e5553498 100644 --- a/core/src/main/kotlin/br/tiagohm/nestalgia/core/Zapper.kt +++ b/core/src/main/kotlin/br/tiagohm/nestalgia/core/Zapper.kt @@ -46,13 +46,12 @@ class Zapper( return 0 } - override fun write(addr: Int, value: Int, type: MemoryOperationType) {} + override fun write(addr: Int, value: Int, type: MemoryOperationType) = Unit companion object { const val AIM_OFFSCREEN_CUSTOM_KEY = 255 - @JvmStatic internal fun Ppu.isLight(mx: Int, my: Int, radius: Int): Boolean { val scanline = scanline val cycle = cycle diff --git a/core/src/test/kotlin/BlipInvarianceTest.kt b/core/src/test/kotlin/BlipInvarianceTest.kt index c8e121d4..0400806b 100644 --- a/core/src/test/kotlin/BlipInvarianceTest.kt +++ b/core/src/test/kotlin/BlipInvarianceTest.kt @@ -110,7 +110,6 @@ class BlipInvarianceTest : StringSpec() { private const val FRAME_LENGTH = 20 * OVERSAMPLE + OVERSAMPLE / 4 private const val BLIP_SIZE = (FRAME_LENGTH * 2) / OVERSAMPLE - @JvmStatic private fun Blip.addDeltas(offset: Int) { addDelta(FRAME_LENGTH / 2 + offset, 1000) addDelta(FRAME_LENGTH + offset + Blip.END_FRAME_EXTRA * OVERSAMPLE, 1000) diff --git a/core/src/test/kotlin/BlipSynthesisTest.kt b/core/src/test/kotlin/BlipSynthesisTest.kt index 7e5e9fa5..3e461b3e 100644 --- a/core/src/test/kotlin/BlipSynthesisTest.kt +++ b/core/src/test/kotlin/BlipSynthesisTest.kt @@ -132,7 +132,6 @@ class BlipSynthesisTest : StringSpec() { private const val OVERSAMPLE = Blip.BLIP_MAX_RATIO private const val BLIP_SIZE = 32 - @JvmStatic private fun Blip.endFrameAndReadSamples(): ShortArray { val buffer = ShortArray(BLIP_SIZE) endFrame(BLIP_SIZE * OVERSAMPLE) diff --git a/core/src/test/kotlin/InputTest.kt b/core/src/test/kotlin/InputTest.kt index 9d91814b..283b1e5a 100644 --- a/core/src/test/kotlin/InputTest.kt +++ b/core/src/test/kotlin/InputTest.kt @@ -103,7 +103,7 @@ class InputTest : NesTesterSpec() { companion object { - @JvmStatic private val NES_CONTROLLER_1P_STATES = mapOf( + private val NES_CONTROLLER_1P_STATES = mapOf( A to "537b3d6d36c0b6f555e07cf40bd2fc22", B to "607f6384c877ab00e7a6ad70193ad028", SELECT to "a32285236280acf49f4afb6f3ec85b71", @@ -114,7 +114,7 @@ class InputTest : NesTesterSpec() { RIGHT to "0271fe1978e6b4d3e402bea34aecc240", ) - @JvmStatic private val NES_CONTROLLER_2P_STATES = mapOf( + private val NES_CONTROLLER_2P_STATES = mapOf( A to "9154d60b6fb4fc5c0c7b2474c3d47476", B to "95e34fc822057b1d8c4735b153d83bbc", SELECT to "516fc022ab3819cf41a20e7ff67ca1ac", @@ -125,7 +125,7 @@ class InputTest : NesTesterSpec() { RIGHT to "b4ac3a3e51da3db7355fd94b919902c3", ) - @JvmStatic private val FOUR_SCORE_1P_STATES = mapOf( + private val FOUR_SCORE_1P_STATES = mapOf( A to "ec6b56f5df412e0221226ce17341a297", B to "c285c56048902ce36c29fe3dcd9dd366", SELECT to "bb65d0ba475a56eae5fe8701632ee873", @@ -136,7 +136,7 @@ class InputTest : NesTesterSpec() { RIGHT to "efa6c1076aa58df5afccbbea9c49e82d", ) - @JvmStatic private val FOUR_SCORE_2P_STATES = mapOf( + private val FOUR_SCORE_2P_STATES = mapOf( A to "0b819ae1a0915a0cf28cfcd6e9da2dec", B to "73eebf1864b855100b9384a642bd1f14", SELECT to "6c3b897d4261cdf04abc53cfde838429", @@ -147,7 +147,7 @@ class InputTest : NesTesterSpec() { RIGHT to "20ab5a4a987c3360d3fde35b945ecb11", ) - @JvmStatic private val FOUR_SCORE_3P_STATES = mapOf( + private val FOUR_SCORE_3P_STATES = mapOf( A to "e93154d7febf5dbc0f96da60a5ac8fa7", B to "a782582adb13d580c325a1771ac7b289", SELECT to "323b2346042b9244e8c9b1ee9fba6e8b", @@ -158,7 +158,7 @@ class InputTest : NesTesterSpec() { RIGHT to "cd52e2140483a40b79c5ced00f71fe45", ) - @JvmStatic private val FOUR_SCORE_4P_STATES = mapOf( + private val FOUR_SCORE_4P_STATES = mapOf( A to "dc032df0eac4d1583a89c0dc3b3f3d94", B to "e1445511bf982e797c873f66b5c41209", SELECT to "94ec14ef6b8745832dd66e9440ffce1c", @@ -169,12 +169,12 @@ class InputTest : NesTesterSpec() { RIGHT to "5845f30f1f27787e7047afba2774545f", ) - @JvmStatic private val FOUR_SCORE_PORT_STATES = arrayOf( + private val FOUR_SCORE_PORT_STATES = arrayOf( FOUR_SCORE_1P_STATES, FOUR_SCORE_2P_STATES, FOUR_SCORE_3P_STATES, FOUR_SCORE_4P_STATES, ) - @JvmStatic private val POWER_PAD_STATES = mapOf( + private val POWER_PAD_STATES = mapOf( B01 to "283dfab6057fa72bb34ee6db612cfd7e", B02 to "6630f862a952d31a8dd4a7f759f3910c", B03 to "4d51baedfd1d1dbf9b8280db1c71a39c", diff --git a/core/src/test/kotlin/IpsPatcherTest.kt b/core/src/test/kotlin/IpsPatcherTest.kt index 3ecc2f67..2d30e007 100644 --- a/core/src/test/kotlin/IpsPatcherTest.kt +++ b/core/src/test/kotlin/IpsPatcherTest.kt @@ -44,12 +44,12 @@ class IpsPatcherTest : StringSpec() { companion object { - @JvmStatic private val ORIG_DATA = intArrayOf( + private val ORIG_DATA = intArrayOf( 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, ) - @JvmStatic private val MOD_DATA = intArrayOf( + private val MOD_DATA = intArrayOf( 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 4, 3, 4, 5, 6, 7, 0, 1, 2, 3, 6, 6, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, ) diff --git a/core/src/test/kotlin/NesTester.kt b/core/src/test/kotlin/NesTester.kt index 1ace6989..e958a2fa 100644 --- a/core/src/test/kotlin/NesTester.kt +++ b/core/src/test/kotlin/NesTester.kt @@ -83,15 +83,15 @@ class NesTester(private val path: Path) { private object Speaker : AudioDevice { - override fun play(buffer: ShortArray, length: Int, sampleRate: Int, stereo: Boolean) {} + override fun play(buffer: ShortArray, length: Int, sampleRate: Int, stereo: Boolean) = Unit - override fun stop() {} + override fun stop() = Unit - override fun pause() {} + override fun pause() = Unit - override fun processEndOfFrame() {} + override fun processEndOfFrame() = Unit - override fun close() {} + override fun close() = Unit } private inner class Video : RenderingDevice { @@ -100,11 +100,11 @@ class NesTester(private val path: Path) { frameHashes.add(buffer.md5()) } - override fun render() {} + override fun render() = Unit - override fun reset(softReset: Boolean) {} + override fun reset(softReset: Boolean) = Unit - override fun close() {} + override fun close() = Unit } private inner class Controller : KeyManager { @@ -115,7 +115,7 @@ class NesTester(private val path: Path) { return pressed >= 1 } - override fun refreshKeyState() {} + override fun refreshKeyState() = Unit override var mouseX = 0 private set diff --git a/desktop/build.gradle.kts b/desktop/build.gradle.kts index a8c00e70..c76cc3a4 100644 --- a/desktop/build.gradle.kts +++ b/desktop/build.gradle.kts @@ -1,18 +1,15 @@ -import org.springframework.boot.gradle.tasks.bundling.BootJar import java.time.LocalDate import java.time.LocalTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { kotlin("jvm") - kotlin("kapt") id("maven-publish") id("com.github.gmazzo.buildconfig") - id("org.springframework.boot") version "3.3.3" - id("io.spring.dependency-management") version "1.1.6" - kotlin("plugin.spring") id("org.openjfx.javafxplugin") + id("com.gradleup.shadow") version "8.3.1" } dependencies { @@ -29,8 +26,6 @@ dependencies { implementation("com.badlogicgames.gdx:gdx-controllers:1.9.13") // 1.9.9 implementation("com.badlogicgames.gdx:gdx-jnigen:2.5.2") // 1.9.10 - implementation("org.springframework.boot:spring-boot-starter") - kapt("org.springframework:spring-context-indexer:6.1.12") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation(libs.logback) @@ -58,12 +53,15 @@ javafx { modules = listOf("javafx.controls", "javafx.fxml") } -tasks.withType { +tasks.withType { archiveFileName.set("nestalgia.jar") isZip64 = true + minimize { + exclude(dependency("org.openjfx:.*:.*")) + } manifest { - attributes["Start-Class"] = "br.tiagohm.nestalgia.desktop.MainKt" + attributes["Main-Class"] = "br.tiagohm.nestalgia.desktop.MainKt" } } diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Helper.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Helper.kt deleted file mode 100644 index 59cd5ff5..00000000 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Helper.kt +++ /dev/null @@ -1,11 +0,0 @@ -package br.tiagohm.nestalgia.desktop - -import java.util.* - -fun base64Encode(text: String): String { - return Base64.getEncoder().encodeToString(text.toByteArray()) -} - -fun base64Decode(text: String): String { - return String(Base64.getDecoder().decode(text.toByteArray())) -} diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Main.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Main.kt index 3402b475..69efdd4b 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Main.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/Main.kt @@ -1,30 +1,59 @@ package br.tiagohm.nestalgia.desktop +import br.tiagohm.nestalgia.core.Console +import br.tiagohm.nestalgia.core.EmulationSettings import br.tiagohm.nestalgia.desktop.app.Nestalgia +import br.tiagohm.nestalgia.desktop.app.Preferences +import br.tiagohm.nestalgia.desktop.gui.about.AboutWindow +import br.tiagohm.nestalgia.desktop.gui.cheats.CheatsWindow +import br.tiagohm.nestalgia.desktop.gui.home.HomeWindow +import br.tiagohm.nestalgia.desktop.gui.settings.SettingsWindow import javafx.application.Application -import oshi.PlatformEnum -import oshi.SystemInfo +import oshi.PlatformEnum.LINUX +import oshi.PlatformEnum.WINDOWS +import oshi.SystemInfo.getCurrentPlatform import java.nio.file.Path import java.util.* import javax.swing.filechooser.FileSystemView import kotlin.io.path.createDirectories +import kotlin.system.exitProcess -fun initAppDirectory(): Path? { - val appDirectory = when (SystemInfo.getCurrentPlatform()) { - PlatformEnum.LINUX -> { +// Paths +lateinit var appDir: Path +lateinit var screenshotDir: Path +lateinit var saveDir: Path + +// Application +lateinit var application: Application +val globalSettings = EmulationSettings() +val consoleSettings = EmulationSettings() +val console = Console(settings = consoleSettings) +lateinit var preferences: Preferences +lateinit var homeWindow: HomeWindow +val settingsWindow = SettingsWindow() +val cheatsWindow = CheatsWindow() +val aboutWindow = AboutWindow() + +private fun initAppDirectory() { + appDir = when (getCurrentPlatform()) { + LINUX -> { val userHomeDir = Path.of(System.getProperty("user.home")) Path.of("$userHomeDir", ".nestalgia") } - PlatformEnum.WINDOWS -> { + WINDOWS -> { val documentsDir = FileSystemView.getFileSystemView().defaultDirectory.path Path.of(documentsDir, "Nestalgia") } - else -> return null + else -> return exitProcess(1) } - appDirectory.createDirectories() - System.setProperty("app.dir", "$appDirectory") - return appDirectory + appDir.createDirectories() + System.setProperty("app.dir", "$appDir") +} + +private fun initializeSubDirectories() { + screenshotDir = Path.of("$appDir", "screenshots").createDirectories() + saveDir = Path.of("$appDir", "saves").createDirectories() } fun main(args: Array) { @@ -32,6 +61,9 @@ fun main(args: Array) { System.setProperty("prism.lcdtext", "false") initAppDirectory() + initializeSubDirectories() + + preferences = Preferences(Path.of("$appDir", "config.nst"), globalSettings) // Sets default locale to en_US. Locale.setDefault(Locale.ENGLISH) diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/App.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/App.kt deleted file mode 100644 index 500eb081..00000000 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/App.kt +++ /dev/null @@ -1,26 +0,0 @@ -package br.tiagohm.nestalgia.desktop.app - -import org.springframework.boot.CommandLineRunner -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.Bean -import org.springframework.context.annotation.ComponentScan -import org.springframework.scheduling.annotation.EnableAsync -import java.nio.file.Path -import kotlin.io.path.createDirectories - -@EnableAsync -@SpringBootApplication -@ComponentScan(basePackages = ["br.tiagohm.nestalgia.desktop"]) -class App : CommandLineRunner { - - @Bean - fun appDir(): Path = Path.of(System.getProperty("app.dir")) - - @Bean - fun screenshotDir(appDir: Path) = Path.of("$appDir", "screenshots").createDirectories() - - @Bean - fun saveDir(appDir: Path) = Path.of("$appDir", "saves").createDirectories() - - override fun run(vararg args: String?) {} -} diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Nestalgia.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Nestalgia.kt index c05e2049..7fc107f1 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Nestalgia.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Nestalgia.kt @@ -1,32 +1,23 @@ package br.tiagohm.nestalgia.desktop.app import br.tiagohm.nestalgia.core.CheatDatabase -import br.tiagohm.nestalgia.core.Console -import br.tiagohm.nestalgia.core.EmulationSettings import br.tiagohm.nestalgia.core.GameDatabase +import br.tiagohm.nestalgia.desktop.aboutWindow +import br.tiagohm.nestalgia.desktop.application +import br.tiagohm.nestalgia.desktop.cheatsWindow import br.tiagohm.nestalgia.desktop.gui.home.HomeWindow import br.tiagohm.nestalgia.desktop.helper.resource +import br.tiagohm.nestalgia.desktop.homeWindow +import br.tiagohm.nestalgia.desktop.settingsWindow import javafx.application.Application +import javafx.application.Platform import javafx.stage.Stage -import org.springframework.boot.runApplication -import org.springframework.context.ApplicationContextInitializer -import org.springframework.context.ConfigurableApplicationContext import kotlin.concurrent.thread class Nestalgia : Application() { override fun start(primaryStage: Stage) { - val context = runApplication(*parameters.raw.toTypedArray()) { - addInitializers(ApplicationContextInitializer { - val globalSettings = EmulationSettings() - val consoleSettings = EmulationSettings() - it.beanFactory.registerSingleton("hostServices", hostServices) - it.beanFactory.registerSingleton("primaryStage", primaryStage) - it.beanFactory.registerSingleton("globalSettings", globalSettings) - it.beanFactory.registerSingleton("consoleSettings", consoleSettings) - it.beanFactory.registerSingleton("console", Console(settings = consoleSettings)) - }) - } + application = this thread(isDaemon = true) { resource(GameDatabase.FILENAME)?.use { @@ -40,7 +31,12 @@ class Nestalgia : Application() { } } - val homeWindow = context.getBean(HomeWindow::class.java) + Platform.runLater(settingsWindow::setUp) + Platform.runLater(cheatsWindow::setUp) + Platform.runLater(aboutWindow::setUp) + + homeWindow = HomeWindow(primaryStage) + homeWindow.setUp() homeWindow.show() } } diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Preferences.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Preferences.kt index 83e2bdbe..3730f0aa 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Preferences.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/app/Preferences.kt @@ -4,22 +4,16 @@ import br.tiagohm.nestalgia.core.EmulationSettings import br.tiagohm.nestalgia.core.Snapshot import br.tiagohm.nestalgia.core.Snapshotable import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.stereotype.Component import java.nio.file.Path import kotlin.io.path.exists import kotlin.io.path.inputStream import kotlin.io.path.outputStream -@Component -class Preferences( - @Autowired appDir: Path, - @Autowired @Qualifier("globalSettings") val settings: EmulationSettings, +data class Preferences( + private val path: Path, + val settings: EmulationSettings, ) : Snapshotable { - private val path = Path.of("$appDir", "config.nst") - val recentlyOpened = arrayOfNulls(10) var loadRomDir = "" @@ -34,13 +28,13 @@ class Preferences( } } - final override fun saveState(s: Snapshot) { + override fun saveState(s: Snapshot) { s.write("settings", settings) s.write("recentlyOpened", recentlyOpened.map { "$it" }.toTypedArray()) s.write("loadRomDir", loadRomDir) } - final override fun restoreState(s: Snapshot) { + override fun restoreState(s: Snapshot) { s.readSnapshotable("settings", settings) s.readArray("recentlyOpened")?.map(Path::of)?.toTypedArray()?.copyInto(recentlyOpened) loadRomDir = s.readString("loadRomDir") @@ -54,6 +48,6 @@ class Preferences( companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(Preferences::class.java) + private val LOG = LoggerFactory.getLogger(Preferences::class.java) } } diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/audio/Speaker.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/audio/Speaker.kt index db6b32a2..f7d1ca40 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/audio/Speaker.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/audio/Speaker.kt @@ -164,7 +164,7 @@ data class Speaker(private val console: Console) : AudioDevice { pause.set(true) } - override fun processEndOfFrame() {} + override fun processEndOfFrame() = Unit private inline fun updateSoundSettings() { val sampleRate = console.settings.sampleRate diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/AbstractWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/AbstractWindow.kt index 35ac40b0..1308da5a 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/AbstractWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/AbstractWindow.kt @@ -3,7 +3,6 @@ package br.tiagohm.nestalgia.desktop.gui import br.tiagohm.nestalgia.desktop.gui.home.HomeWindow import br.tiagohm.nestalgia.desktop.helper.resource import br.tiagohm.nestalgia.desktop.helper.resourceUrl -import jakarta.annotation.PostConstruct import javafx.application.Platform import javafx.fxml.FXMLLoader import javafx.scene.Parent @@ -14,10 +13,9 @@ import javafx.stage.Stage import jfxtras.styles.jmetro.JMetro import jfxtras.styles.jmetro.JMetroStyleClass import jfxtras.styles.jmetro.Style -import java.io.Closeable import java.util.concurrent.atomic.AtomicBoolean -abstract class AbstractWindow : Closeable { +abstract class AbstractWindow : AutoCloseable { protected abstract val resourceName: String @@ -25,8 +23,7 @@ abstract class AbstractWindow : Closeable { private val showingAtFirstTime = AtomicBoolean(true) - @PostConstruct - protected fun setUp() { + fun setUp() { window.setOnShowing { if (showingAtFirstTime.compareAndSet(true, false)) { val loader = FXMLLoader(resourceUrl("screens/$resourceName.fxml")!!) diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/about/AboutWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/about/AboutWindow.kt index 74cdd0e3..ebf0fa5d 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/about/AboutWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/about/AboutWindow.kt @@ -4,9 +4,7 @@ import br.tiagohm.nestalgia.desktop.BuildConfig import br.tiagohm.nestalgia.desktop.gui.AbstractWindow import javafx.fxml.FXML import javafx.scene.control.Label -import org.springframework.stereotype.Component -@Component class AboutWindow : AbstractWindow() { override val resourceName = "About" diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/cheats/CheatsWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/cheats/CheatsWindow.kt index 5acc4f04..60018d14 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/cheats/CheatsWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/cheats/CheatsWindow.kt @@ -2,28 +2,23 @@ package br.tiagohm.nestalgia.desktop.gui.cheats import br.tiagohm.nestalgia.core.CheatDatabase import br.tiagohm.nestalgia.core.CheatInfo -import br.tiagohm.nestalgia.core.Console +import br.tiagohm.nestalgia.desktop.console import br.tiagohm.nestalgia.desktop.gui.AbstractWindow import javafx.fxml.FXML import javafx.scene.control.CheckBox import javafx.scene.control.ListCell import javafx.scene.control.ListView import javafx.util.Callback -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.stereotype.Component -@Component class CheatsWindow : AbstractWindow() { override val resourceName = "Cheats" - @Autowired private lateinit var console: Console - @FXML private lateinit var cheatsListView: ListView val selectedCheats = hashSetOf() - final var saved = false + var saved = false private set override fun onCreate() { diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/converters/ControllerButtonStringConverter.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/converters/ControllerButtonStringConverter.kt index 50523040..5b1717c3 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/converters/ControllerButtonStringConverter.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/converters/ControllerButtonStringConverter.kt @@ -12,7 +12,7 @@ object ControllerButtonStringConverter : StringConverter() { override fun fromString(text: String?) = null - @JvmStatic private val LABELS = mapOf( + private val LABELS = mapOf( StandardController.Button.A to "A", StandardController.Button.B to "B", StandardController.Button.UP to "Up", diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/home/HomeWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/home/HomeWindow.kt index ba7fa136..baa9503e 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/home/HomeWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/home/HomeWindow.kt @@ -3,17 +3,20 @@ package br.tiagohm.nestalgia.desktop.gui.home import br.tiagohm.nestalgia.core.* import br.tiagohm.nestalgia.core.ControllerType.* import br.tiagohm.nestalgia.core.MouseButton.* -import br.tiagohm.nestalgia.desktop.app.Preferences +import br.tiagohm.nestalgia.desktop.aboutWindow import br.tiagohm.nestalgia.desktop.audio.Speaker +import br.tiagohm.nestalgia.desktop.cheatsWindow +import br.tiagohm.nestalgia.desktop.console import br.tiagohm.nestalgia.desktop.gui.AbstractWindow -import br.tiagohm.nestalgia.desktop.gui.about.AboutWindow -import br.tiagohm.nestalgia.desktop.gui.cheats.CheatsWindow -import br.tiagohm.nestalgia.desktop.gui.settings.SettingsWindow import br.tiagohm.nestalgia.desktop.helper.resource import br.tiagohm.nestalgia.desktop.input.GamepadInputAction import br.tiagohm.nestalgia.desktop.input.GamepadInputListener import br.tiagohm.nestalgia.desktop.input.GamepadInputProvider import br.tiagohm.nestalgia.desktop.input.MouseKeyboard +import br.tiagohm.nestalgia.desktop.preferences +import br.tiagohm.nestalgia.desktop.saveDir +import br.tiagohm.nestalgia.desktop.screenshotDir +import br.tiagohm.nestalgia.desktop.settingsWindow import br.tiagohm.nestalgia.desktop.video.Television import javafx.beans.InvalidationListener import javafx.event.ActionEvent @@ -31,10 +34,6 @@ import javafx.stage.FileChooser import javafx.stage.FileChooser.* import javafx.stage.Stage import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.context.ConfigurableApplicationContext -import org.springframework.stereotype.Component import java.nio.file.NoSuchFileException import java.nio.file.Path import java.time.Instant @@ -44,21 +43,10 @@ import java.time.format.DateTimeFormatter import javax.imageio.ImageIO import kotlin.io.path.* -@Component -class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stage) : AbstractWindow(), - GamepadInputListener, NotificationListener, BatteryProvider { +data class HomeWindow(override val window: Stage) : AbstractWindow(), GamepadInputListener, NotificationListener, BatteryProvider { override val resourceName = "Home" - @Autowired private lateinit var console: Console - @Autowired private lateinit var preferences: Preferences - @Autowired private lateinit var saveDir: Path - @Autowired private lateinit var screenshotDir: Path - @Autowired private lateinit var settingsWindow: SettingsWindow - @Autowired private lateinit var cheatsWindow: CheatsWindow - @Autowired private lateinit var aboutWindow: AboutWindow - @Autowired private lateinit var configurableApplicationContext: ConfigurableApplicationContext - @FXML private lateinit var menuBar: MenuBar @FXML private lateinit var recentGamesMenu: Menu @FXML private lateinit var restoreStateMenu: Menu @@ -111,7 +99,6 @@ class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stag } override fun onClose() { - configurableApplicationContext.close() emulator.close() } @@ -131,9 +118,9 @@ class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stag } } - override fun onAction(action: GamepadInputAction) {} + override fun onAction(action: GamepadInputAction) = Unit - override fun processNotification(type: NotificationType, vararg data: Any?) {} + override fun processNotification(type: NotificationType, vararg data: Any?) = Unit override fun loadBattery(name: String): IntArray { val path = Path.of("$saveDir", name) @@ -142,7 +129,7 @@ class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stag LOG.info("loading battery. path={}", path) // TODO: Avoid read bytes. path.readBytes().toIntArray() - } catch (e: NoSuchFileException) { + } catch (_: NoSuchFileException) { LOG.warn("no battery found") IntArray(0) } catch (e: Throwable) { @@ -445,11 +432,10 @@ class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stag companion object { - @JvmStatic private val LOG = LoggerFactory.getLogger(HomeWindow::class.java) - @JvmStatic private val SPEEDS = intArrayOf(100, 200, 300, 50, 25) - @JvmStatic private val DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") + private val LOG = LoggerFactory.getLogger(HomeWindow::class.java) + private val SPEEDS = intArrayOf(100, 200, 300, 50, 25) + private val DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") - @JvmStatic private val MouseEvent.mouseButton get() = when (button) { MIDDLE -> MouseButton.MIDDLE @@ -457,7 +443,7 @@ class HomeWindow(@Autowired @Qualifier("primaryStage") override val window: Stag else -> LEFT } - @JvmStatic val FDS_BIOS by lazy { + internal val FDS_BIOS by lazy { resource(FdsBios.NINTENDO_FDS_FILENAME) ?.use { it.readBytes().toIntArray() } ?: IntArray(0) diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/SettingsWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/SettingsWindow.kt index 49883a28..10cef568 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/SettingsWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/SettingsWindow.kt @@ -5,12 +5,15 @@ import br.tiagohm.nestalgia.core.ControlDevice.Companion.EXP_DEVICE_PORT import br.tiagohm.nestalgia.core.ControlDevice.Companion.MAPPER_INPUT_PORT import br.tiagohm.nestalgia.core.ControllerType.* import br.tiagohm.nestalgia.core.EmulationFlag.* -import br.tiagohm.nestalgia.desktop.app.Preferences +import br.tiagohm.nestalgia.desktop.console +import br.tiagohm.nestalgia.desktop.consoleSettings +import br.tiagohm.nestalgia.desktop.globalSettings import br.tiagohm.nestalgia.desktop.gui.AbstractWindow import br.tiagohm.nestalgia.desktop.gui.converters.ConsoleTypeStringConverter import br.tiagohm.nestalgia.desktop.gui.converters.ControllerTypeStringConverter import br.tiagohm.nestalgia.desktop.gui.converters.RamPowerOnStateStringConverter import br.tiagohm.nestalgia.desktop.gui.settings.controllers.* +import br.tiagohm.nestalgia.desktop.preferences import javafx.event.ActionEvent import javafx.fxml.FXML import javafx.scene.Node @@ -19,21 +22,11 @@ import javafx.scene.control.CheckBox import javafx.scene.control.ChoiceBox import javafx.scene.control.Spinner import javafx.scene.layout.Pane -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.config.AutowireCapableBeanFactory -import org.springframework.stereotype.Component -@Component class SettingsWindow : AbstractWindow() { override val resourceName = "Settings" - @Autowired private lateinit var preferences: Preferences - @Autowired private lateinit var console: Console - @Autowired private lateinit var globalSettings: EmulationSettings - @Autowired private lateinit var consoleSettings: EmulationSettings - @Autowired private lateinit var beanFactory: AutowireCapableBeanFactory - @FXML private lateinit var profileChoiceBox: ChoiceBox @FXML private lateinit var fourScorePane: Pane @FXML private lateinit var twoFourPlayerAdapterPane: Pane @@ -322,8 +315,8 @@ class SettingsWindow : AbstractWindow() { 1 -> settings.port2.keyMapping EXP_DEVICE_PORT -> settings.expansionPort.keyMapping MAPPER_INPUT_PORT -> settings.mapperPort.keyMapping - -1 -> settings.subPort1[subPort - 1].keyMapping - -EXP_DEVICE_PORT -> settings.expansionSubPort[subPort - 1].keyMapping + -1 -> settings.subPort1[subPort].keyMapping + -EXP_DEVICE_PORT -> settings.expansionSubPort[subPort].keyMapping else -> return } @@ -346,11 +339,7 @@ class SettingsWindow : AbstractWindow() { else -> return } - with(window) { - beanFactory.autowireBean(this) - beanFactory.initializeBean(this, "portSettingsWindow") - showAndWait(this@SettingsWindow) - } + window.showAndWait(this@SettingsWindow) } @FXML @@ -407,7 +396,7 @@ class SettingsWindow : AbstractWindow() { companion object { - @JvmStatic private val TWO_PLAYER_ADAPTER_CONTROLLER_TYPES = listOf( + private val TWO_PLAYER_ADAPTER_CONTROLLER_TYPES = listOf( PACHINKO, SNES_MOUSE, SUBOR_MOUSE, VIRTUAL_BOY_CONTROLLER, ) } diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/controllers/StandardControllerSettingsWindow.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/controllers/StandardControllerSettingsWindow.kt index 747910bc..cba96168 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/controllers/StandardControllerSettingsWindow.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/gui/settings/controllers/StandardControllerSettingsWindow.kt @@ -76,7 +76,7 @@ open class StandardControllerSettingsWindow( companion object { - @JvmStatic private val PRESETS = mapOf( + private val PRESETS = mapOf( "WASD" to KeyMapping.wasd(), "ARROW" to KeyMapping.arrowKeys(), ) diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/input/GamepadInputProvider.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/input/GamepadInputProvider.kt index 0e16ce8f..bb7b7f68 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/input/GamepadInputProvider.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/input/GamepadInputProvider.kt @@ -9,14 +9,13 @@ import br.tiagohm.nestalgia.desktop.input.GamepadInputAction.* import com.studiohartman.jamepad.ControllerAxis import com.studiohartman.jamepad.ControllerButton import com.studiohartman.jamepad.ControllerManager -import java.io.Closeable import java.util.concurrent.atomic.AtomicBoolean import kotlin.concurrent.thread data class GamepadInputProvider( private val console: Console, private val listener: GamepadInputListener, -) : InputProvider, Closeable { +) : InputProvider, AutoCloseable { private val jamepad = ControllerManager(PORT_COUNT) private var jamepadThread: Thread? = null @@ -113,7 +112,7 @@ data class GamepadInputProvider( companion object { - @JvmStatic private val MAP_JAMEPAD_TO_NES = mapOf( + private val MAP_JAMEPAD_TO_NES = mapOf( ControllerButton.A to StandardController.Button.A, ControllerButton.B to StandardController.Button.B, ControllerButton.DPAD_DOWN to StandardController.Button.DOWN, diff --git a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/video/Television.kt b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/video/Television.kt index 3fc888bc..9ab39d6c 100644 --- a/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/video/Television.kt +++ b/desktop/src/main/kotlin/br/tiagohm/nestalgia/desktop/video/Television.kt @@ -30,7 +30,7 @@ class Television : CanvasPane(Ppu.SCREEN_WIDTH, Ppu.SCREEN_HEIGHT), RenderingDev } } - override fun reset(softReset: Boolean) {} + override fun reset(softReset: Boolean) = Unit - override fun close() {} + override fun close() = Unit } diff --git a/desktop/src/main/kotlin/javafx/scene/image/RenderedImage.kt b/desktop/src/main/kotlin/javafx/scene/image/RenderedImage.kt index d5450c8a..6516ae31 100644 --- a/desktop/src/main/kotlin/javafx/scene/image/RenderedImage.kt +++ b/desktop/src/main/kotlin/javafx/scene/image/RenderedImage.kt @@ -1,6 +1,6 @@ package javafx.scene.image -class RenderedImage( +data class RenderedImage( private val buffer: IntArray, private val width: Int, private val height: Int, @@ -12,6 +12,6 @@ class RenderedImage( companion object { - @JvmStatic private val PIXEL_FORMAT = PixelFormat.getIntArgbPreInstance() + private val PIXEL_FORMAT = PixelFormat.getIntArgbPreInstance() } } diff --git a/docs/index.html b/docs/index.html index 98bb100c..0c2fc8f8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -564,7 +564,7 @@
iNES
Legend
295 Supported mappers
-
0 Supported mappers (but not implemented yet)
+
36 Supported mappers (but not implemented yet)
0 Unsupported mappers (Licensed games)
15 Unsupported mappers (Bootlegs)
7 Unknown mappers (no known games)
@@ -582,7 +582,7 @@
UNIF
BMC-13in1JY110 BMC-190in1 BMC-411120-C - BMC-60311C + BMC-60311C BMC-64in1NoRepeat BMC-70in1 BMC-70in1B diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a79..d64cd491 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7fc84bec..1ed247ec 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-all.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cbb..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 6689b85b..7101f8e4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/FlatDialog.kt b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/FlatDialog.kt index 5b645557..ce4385a2 100644 --- a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/FlatDialog.kt +++ b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/FlatDialog.kt @@ -46,13 +46,11 @@ class FlatDialog : Dialog() { companion object { - @JvmStatic fun initDialog(dialog: Dialog<*>, iconless: Boolean) { dialog.title = "" initDialogIcon(dialog, iconless) } - @JvmStatic fun initDialogIcon(dialog: Dialog<*>, iconless: Boolean) { if (!iconless) return val stage = dialog.dialogPane.scene.window as Stage diff --git a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetro.kt b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetro.kt index ef2ed6f8..b761474c 100644 --- a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetro.kt +++ b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetro.kt @@ -127,11 +127,11 @@ class JMetro() { companion object { - @JvmStatic private val BASE_STYLESHEET_URL = + private val BASE_STYLESHEET_URL = Thread.currentThread().contextClassLoader.getResource("base.css")!!.toExternalForm() - @JvmStatic private val BASE_OTHER_LIBRARIES_STYLESHEET_URL = + private val BASE_OTHER_LIBRARIES_STYLESHEET_URL = Thread.currentThread().contextClassLoader.getResource("base-other-libraries.css")!!.toExternalForm() - @JvmStatic private val BASE_EXTRAS_STYLESHEET_URL = + private val BASE_EXTRAS_STYLESHEET_URL = Thread.currentThread().contextClassLoader.getResource("base-extras.css")!!.toExternalForm() } } diff --git a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetroStyleClass.kt b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetroStyleClass.kt index 51a469cd..5cf86baa 100644 --- a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetroStyleClass.kt +++ b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/JMetroStyleClass.kt @@ -8,7 +8,6 @@ object JMetroStyleClass { const val ALTERNATING_ROW_COLORS = "alternating-row-colors" const val TABLE_GRID_LINES = "column-grid-lines" - @JvmStatic fun addIfNotPresent(collection: MutableList, styleclass: String) { if (styleclass !in collection) { collection.add(styleclass) diff --git a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/TextFieldWithButtonSkin.kt b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/TextFieldWithButtonSkin.kt index 4ff16768..b4f31b3f 100644 --- a/jmetro/src/main/kotlin/jfxtras/styles/jmetro/TextFieldWithButtonSkin.kt +++ b/jmetro/src/main/kotlin/jfxtras/styles/jmetro/TextFieldWithButtonSkin.kt @@ -82,9 +82,9 @@ open class TextFieldWithButtonSkin(protected var textField: TextField) : TextFie rightButtonGraphic.isVisible = shouldBeVisible } - protected open fun onRightButtonPressed(event: MouseEvent) {} + protected open fun onRightButtonPressed(event: MouseEvent) = Unit - protected open fun onRightButtonReleased(event: MouseEvent) {} + protected open fun onRightButtonReleased(event: MouseEvent) = Unit override fun layoutChildren(x: Double, y: Double, w: Double, h: Double) { super.layoutChildren(x, y, w, h) @@ -112,7 +112,7 @@ open class TextFieldWithButtonSkin(protected var textField: TextField) : TextFie private const val RIGHT_BUTTON_VISIBLE_PROPERTY_NAME = "-right-button-visible" - @JvmStatic private val RIGHT_BUTTON_VISIBLE_META_DATA = object : CssMetaData( + private val RIGHT_BUTTON_VISIBLE_META_DATA = object : CssMetaData( RIGHT_BUTTON_VISIBLE_PROPERTY_NAME, BooleanConverter.getInstance(), true ) { @@ -127,7 +127,7 @@ open class TextFieldWithButtonSkin(protected var textField: TextField) : TextFie } } - @JvmStatic val STYLEABLES: List> + val STYLEABLES: List> init { val styleables = ArrayList(SkinBase.getClassCssMetaData())