1
0
mirror of https://github.com/irmen/ksim65.git synced 2025-02-13 11:31:28 +00:00

tweaks and update to kotlin 2.1

This commit is contained in:
Irmen de Jong 2024-12-21 04:17:42 +01:00
parent 1ae85f5966
commit 5809a54ba4
6 changed files with 40 additions and 29 deletions

2
.idea/kotlinc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="2.0.20" />
<option name="version" value="2.1.0" />
</component>
</project>

23
.idea/libraries/KotlinJavaRuntime.xml generated Normal file
View File

@ -0,0 +1,23 @@
<component name="libraryTable">
<library name="KotlinJavaRuntime" type="repository">
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21" />
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.0.21/kotlin-stdlib-jdk8-2.0.21.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.21/kotlin-stdlib-2.0.21.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.0.21/kotlin-stdlib-jdk7-2.0.21.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.0.21/kotlin-stdlib-jdk8-2.0.21-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.21/kotlin-stdlib-2.0.21-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.0.21/kotlin-stdlib-jdk7-2.0.21-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.0.21/kotlin-stdlib-jdk8-2.0.21-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.0.21/kotlin-stdlib-2.0.21-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.0.21/kotlin-stdlib-jdk7-2.0.21-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -4,23 +4,12 @@ import kotlin.math.max
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
kotlin("jvm") version "2.0.20"
kotlin("jvm") version "2.1.0"
`maven-publish`
application
java
}
/*
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
*/
kotlin {
jvmToolchain(17)
}
allprojects {
val versionProps = Properties().also {
it.load(File("$projectDir/src/main/resources/version.properties").inputStream())
@ -69,12 +58,6 @@ tasks {
systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
maxParallelForks = max(1, Runtime.getRuntime().availableProcessors()/2)
}
// withType<KotlinCompile> {
// compilerOptions {
// jvmTarget.set(JvmTarget.JVM_11)
// }
// }
}

View File

@ -1096,8 +1096,8 @@ open class Cpu6502 : BusComponent() {
return false
}
protected fun iCmp(operandOverride: Int? = null): Boolean {
val fetched = operandOverride ?: getFetched()
protected fun iCmp(): Boolean {
val fetched = getFetched()
regP.C = regA >= fetched
regP.Z = regA == fetched
regP.N = ((regA-fetched) and 0b10000000) != 0
@ -1307,8 +1307,9 @@ open class Cpu6502 : BusComponent() {
return false
}
protected open fun iSbc(operandOverride: Int? = null): Boolean {
val operand = operandOverride ?: getFetched()
protected fun iSbc(): Boolean = iSbc2(getFetched())
protected open fun iSbc2(operand: Int): Boolean {
val tmp = (regA-operand-if (regP.C) 0 else 1) and 0xffff
regP.V = (regA xor operand) and (regA xor tmp) and 0b10000000 != 0
if (regP.D) {
@ -1454,14 +1455,19 @@ open class Cpu6502 : BusComponent() {
private fun iDcp(): Boolean {
val data = (read(fetchedAddress)-1) and 0xff
write(fetchedAddress, data)
iCmp(data)
// this part is the same as Cmp
regP.C = regA >= data
regP.Z = regA == data
regP.N = ((regA-data) and 0b10000000) != 0
return false
}
private fun iIsc(): Boolean {
val data = (read(fetchedAddress)+1) and 0xff
write(fetchedAddress, data)
iSbc(data)
iSbc2(data)
return false
}

View File

@ -684,11 +684,10 @@ class Cpu65C02 : Cpu6502() {
return false
}
override fun iSbc(operandOverride: Int?): Boolean {
override fun iSbc2(value: Int): Boolean {
// see http://www.6502.org/tutorials/decimal_mode.html
// and https://sourceforge.net/p/vice-emu/code/HEAD/tree/trunk/vice/src/65c02core.c#l1205
// (the implementation below is based on the code used by Vice)
val value = operandOverride ?: getFetched()
var tmp = (regA-value-if (regP.C) 0 else 1) and 0xffff
regP.V = (regA xor tmp) and (regA xor value) and 0b10000000 != 0
if (regP.D) {

View File

@ -240,11 +240,11 @@ class Test6502CpuBasics {
return result
}
override fun iSbc(operandOverride: Int?): Boolean {
override fun iSbc2(operandOverride: Int): Boolean {
// NES cpu doesn't have BCD mode
val decimal = regP.D
regP.D = false
val result = super.iSbc(operandOverride)
val result = super.iSbc2(operandOverride)
regP.D = decimal
return result
}