From e3a4f8d7b40b6795352aaf864405503d418fdf0d Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:43:05 -0700 Subject: [PATCH 1/6] .gitignore --- .gitignore | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ff781cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +local.properties +build +.idea +*.iml +.gradle +.kobalt +kobaltBuild +kobalt/out +lib/kotlin-* +target/* + From f9a3c4a89a852211ab589e10a8073c49cbfb83b2 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:43:24 -0700 Subject: [PATCH 2/6] Trim down build file --- build.gradle.kts | 48 ++++++++---------------------------------------- 1 file changed, 8 insertions(+), 40 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c45e553..39cdc08 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,17 +2,8 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -buildscript { - repositories { - jcenter() - mavenCentral() - maven { setUrl("https://plugins.gradle.org/m2") } - } - - dependencies { - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72") - } -} +fun DependencyHandler.impl(vararg dep: Any) = dep.forEach { implementation(it) } +fun DependencyHandler.testImpl(vararg dep: Any) = dep.forEach { testImplementation(it) } plugins { java @@ -29,31 +20,12 @@ repositories { } object This { - val version = "0.1" - val groupId = "com.beust" val artifactId = "chip8" - val description = "A CHIP8 emulator" - val url = "https://github.com/cbeust/chip8" - val scm = "github.com/cbeust/chip8.git" - - // Should not need to change anything below - val issueManagementUrl = "https://$scm/issues" - val isSnapshot = version.contains("SNAPSHOT") -} - -allprojects { - group = This.groupId - version = This.version } dependencies { - listOf(kotlin("stdlib"), "com.beust:jcommander:1.72").forEach { - implementation(it) - } - - listOf(kotlin("test"), "org.testng:testng:7.0.0", "org.assertj:assertj-core:3.10.0").forEach { - testImplementation(it) - } + impl(kotlin("stdlib"), "com.beust:jcommander:1.72") + testImpl(kotlin("test"), "org.testng:testng:7.0.0", "org.assertj:assertj-core:3.10.0") } val test by tasks.getting(Test::class) { @@ -68,16 +40,12 @@ tasks { named("shadowJar") { archiveBaseName.set(This.artifactId) mergeServiceFiles() -// excludes = listOf("META-INF/*.DSA", "META-INF/*.RSA", "META-INF/*.SF") manifest { attributes(mapOf( - "Implementation-Title" to rootProject.name, - "Implementation-Version" to rootProject.version, - "Implementation-Vendor-Id" to rootProject.group, - // attributes "Build-Time": ZonedDateTime.now(ZoneId.of("UTC")) - // .format(DateTimeFormatter.ISO_ZONED_DATE_TIME) -// "Built-By" to java.net.InetAddress.localHost.hostName, - "Created-By" to "Gradle "+ gradle.gradleVersion, + "Implementation-Title" to rootProject.name, + "Implementation-Version" to rootProject.version, + "Implementation-Vendor-Id" to rootProject.group, + "Created-By" to "Gradle "+ gradle.gradleVersion, "Main-Class" to "com.beust.cedlinks.MainKt")) } } From a484b0ee8a0fc65e7e596b2c42abbc30784b70df Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:54:01 -0700 Subject: [PATCH 3/6] Comment --- src/main/kotlin/com/beust/chip8/Ops.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/beust/chip8/Ops.kt b/src/main/kotlin/com/beust/chip8/Ops.kt index 583f2f4..d0391ed 100644 --- a/src/main/kotlin/com/beust/chip8/Ops.kt +++ b/src/main/kotlin/com/beust/chip8/Ops.kt @@ -3,8 +3,10 @@ package com.beust.chip8 import kotlin.random.Random /** - * An Op is made of two bytes which is sliced into four nibbles. These nibbles are then used - * to determine the op and its data. + * An Op is made of two bytes which are sliced into four nibbles. These nibbles are then used + * to determine the op and its data. Bytes get sliced differently depending on the opcode. The base + * class offers some convenience functions to access these nibbles but makes them lazy since ops + * will need different ones and we don't want to do unnecessary work. */ sealed class Op(val computer: Computer, val nib: Nibbles) { protected val nnn by lazy { nib.val3(nib.b1, nib.b2, nib.b3) } From 8cd6a16568eecae0a2775c287006203c299325eb Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 24 Aug 2020 00:09:09 -0700 Subject: [PATCH 4/6] Cleaned up. --- build.gradle.kts | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 39cdc08..c3e2c3d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,5 @@ @file:Suppress("MayBeConstant") -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - fun DependencyHandler.impl(vararg dep: Any) = dep.forEach { implementation(it) } fun DependencyHandler.testImpl(vararg dep: Any) = dep.forEach { testImplementation(it) } @@ -9,7 +7,6 @@ plugins { java id("org.jetbrains.kotlin.jvm") version "1.3.72" application - id("com.github.johnrengelman.shadow") version "5.2.0" id("org.openjfx.javafxplugin") version "0.0.8" } @@ -19,6 +16,11 @@ repositories { maven { setUrl("https://plugins.gradle.org/m2") } } +version = 0.3 +group = "com.beust.chip8" + +defaultTasks(ApplicationPlugin.TASK_RUN_NAME) + object This { val artifactId = "chip8" } @@ -28,26 +30,13 @@ dependencies { testImpl(kotlin("test"), "org.testng:testng:7.0.0", "org.assertj:assertj-core:3.10.0") } -val test by tasks.getting(Test::class) { - useTestNG() -} - application { mainClassName = "com.beust.chip8.MainKt" } tasks { - named("shadowJar") { - archiveBaseName.set(This.artifactId) - mergeServiceFiles() - manifest { - attributes(mapOf( - "Implementation-Title" to rootProject.name, - "Implementation-Version" to rootProject.version, - "Implementation-Vendor-Id" to rootProject.group, - "Created-By" to "Gradle "+ gradle.gradleVersion, - "Main-Class" to "com.beust.cedlinks.MainKt")) - } + withType { + useTestNG() } } From dc9bc73529d2b7018d94a8fd8f98ff22b82ee2c1 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 24 Aug 2020 00:10:18 -0700 Subject: [PATCH 5/6] Added mnemonic and pause/pause to resume. --- src/main/kotlin/com/beust/chip8/Main.kt | 10 +++++++--- src/main/resources/main.fxml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/beust/chip8/Main.kt b/src/main/kotlin/com/beust/chip8/Main.kt index 517a79b..7283841 100644 --- a/src/main/kotlin/com/beust/chip8/Main.kt +++ b/src/main/kotlin/com/beust/chip8/Main.kt @@ -45,7 +45,7 @@ class MyFxApp : Application() { // Computer is paused // Update the pause button label - pauseButton?.text = if (newVal) "Resume" else "Pause" + pauseButton?.text = if (newVal) "_Resume" else "_Pause" // Display the disassembly updateDisassembly(disassembly!!, computer.disassemble()) @@ -187,10 +187,14 @@ class MyFxApp : Application() { exitProcess(0) } KeyCode.P -> { - computer.pause() + if (computer.paused) { + computer.start() + } else { + computer.pause() + } } else -> { - if (computer.paused) computer.start() + if (computer.paused && event.code != KeyCode.ALT) computer.start() else { try { val key = Integer.parseInt(event.code.char, 16) diff --git a/src/main/resources/main.fxml b/src/main/resources/main.fxml index f4c3db9..99e45bd 100644 --- a/src/main/resources/main.fxml +++ b/src/main/resources/main.fxml @@ -26,7 +26,7 @@ -