upgrade kotlin sdk version, optimized hex number output

This commit is contained in:
Irmen de Jong 2020-03-07 01:17:48 +01:00
parent 7522d3cb3b
commit 0670a85f88
3 changed files with 15 additions and 16 deletions

View File

@ -6,7 +6,7 @@ import kotlin.math.max
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
kotlin("jvm") version "1.3.61"
kotlin("jvm") version "1.3.70"
`maven-publish`
application
id("org.jetbrains.dokka") version "0.10.0"
@ -32,6 +32,9 @@ allprojects {
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

View File

@ -2,20 +2,16 @@ package razorvine.ksim65
import razorvine.ksim65.components.Address
fun hexW(number: Address, allowSingleByte: Boolean = false): String {
val msb = number ushr 8
val lsb = number and 0xff
return if (msb == 0 && allowSingleByte) hexB(lsb)
else hexB(msb)+hexB(lsb)
}
fun hexW(number: Int, allowSingleByte: Boolean = false) =
if(allowSingleByte && (number and 0xff00 == 0)) {
number.toString(16).padStart(2, '0')
} else {
number.toString(16).padStart(4, '0')
}
fun hexB(number: Short): String = hexB(number.toInt())
fun hexB(number: Int): String {
val hexdigits = "0123456789abcdef"
val loNibble = number and 15
val hiNibble = (number and 65535) ushr 4
return hexdigits[hiNibble].toString()+hexdigits[loNibble]
}
fun hexB(number: Int) = number.toString(16).padStart(2, '0')
fun hexB(number: Short) = hexB(number.toInt())
typealias BreakpointHandler = (cpu: Cpu6502, pc: Address) -> Cpu6502.BreakpointResultAction

View File

@ -33,7 +33,7 @@ class TestDisassembler {
val cpu = Cpu65C02()
val disassembler = Disassembler(cpu)
val memory = Ram(0, 0x0fff)
val source = javaClass.classLoader.getResource("disassem_r65c02.bin").readBytes()
val source = javaClass.classLoader.getResource("disassem_r65c02.bin")?.readBytes()!!
memory.load(source, 0x0200)
val disassem = disassembler.disassemble(memory.data, 0x0200..0x0250, 0)
assertEquals(0x251, disassem.second)
@ -80,7 +80,7 @@ ${'$'}0250 00 brk""", result)
val cpu = Cpu65C02()
val disassembler = Disassembler(cpu)
val memory = Ram(0, 0x0fff)
val source = javaClass.classLoader.getResource("disassem_wdc65c02.bin").readBytes()
val source = javaClass.classLoader.getResource("disassem_wdc65c02.bin")?.readBytes()!!
memory.load(source, 0x200)
val disassem = disassembler.disassemble(memory.data, 0x0200..0x0215, 0)
assertEquals(0x216, disassem.second)