From 114998e6064249bf4b4e223e751b42fce1840bc1 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:43:05 -0700 Subject: [PATCH 1/3] .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 6c9a9318760f4373ce45a4fd39c29cc76ec500eb Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:43:24 -0700 Subject: [PATCH 2/3] 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 eef11a3474b200b61234f290538c06e472061b44 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sun, 23 Aug 2020 14:54:01 -0700 Subject: [PATCH 3/3] 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) }