From ba8946c29c897bc85d1e850d1f0fab3bf5831301 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 18 Sep 2019 21:14:00 +0200 Subject: [PATCH] keyboard input --- build.gradle.kts | 2 +- .../kotlin/razorvine/examplemachine/GUI.kt | 6 +++--- src/main/resources/vmdemo.asm | 8 ++++++-- src/main/resources/vmdemo.prg | Bin 1096 -> 1096 bytes 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 406dd28..2e26001 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,7 +59,7 @@ tasks.named("test") { maxParallelForks = max(1, Runtime.getRuntime().availableProcessors() / 2) } -tasks.withType() { +tasks.withType { kotlinOptions.jvmTarget = "1.8" } diff --git a/src/main/kotlin/razorvine/examplemachine/GUI.kt b/src/main/kotlin/razorvine/examplemachine/GUI.kt index 2d11133..bab3701 100644 --- a/src/main/kotlin/razorvine/examplemachine/GUI.kt +++ b/src/main/kotlin/razorvine/examplemachine/GUI.kt @@ -3,13 +3,14 @@ package razorvine.examplemachine import razorvine.ksim65.Cpu6502 import java.awt.* import java.awt.image.BufferedImage -import java.util.ArrayDeque import javax.imageio.ImageIO import javax.swing.event.MouseInputListener import razorvine.ksim65.IHostInterface import razorvine.ksim65.components.MemoryComponent import java.awt.event.* +import java.util.* import javax.swing.* +import javax.swing.Timer /** @@ -324,6 +325,7 @@ class MainWindow(title: String) : JFrame(title), KeyListener, MouseInputListener pack() requestFocusInWindow() setLocationRelativeTo(null) + setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, mutableSetOf()) isVisible = true } @@ -343,8 +345,6 @@ class MainWindow(title: String) : JFrame(title), KeyListener, MouseInputListener // keyboard events: override fun keyTyped(event: KeyEvent) { - println(event) - println("[${event.keyChar}]") keyboardBuffer.add(event.keyChar) while (keyboardBuffer.size > 8) keyboardBuffer.pop() diff --git a/src/main/resources/vmdemo.asm b/src/main/resources/vmdemo.asm index f2e7e58..6442a0e 100644 --- a/src/main/resources/vmdemo.asm +++ b/src/main/resources/vmdemo.asm @@ -41,7 +41,7 @@ start jmp + _title1 .text "**** COMMODORE 64 BASIC V2 ****", 10, 10, " 64K RAM SYSTEM 38911 BASIC BYTES FREE", 10, 10, "READY.",10,0 -_text2 .text 10,"Nah, only joking, this is not a weird C-64.",10,"This is a working fantasy virtual 8-bit 6502 machine though!",10 +_text2 .text 10,"Nah, only joking, this is not a weird C-64.",10,"This is a working fantasy 8-bit 6502 machine though!",10 .text "Type some stuff on the keyboard, use the mouse (with Left button/Right button)", 10, "to draw/erase pixels.",10,10,0 _text3 .text "Mouse drawing and keyboard scanning: done in main program loop.",10 .text "Time displayed at the bottom of the screen: done in timer IRQ.",10,10,0 @@ -56,7 +56,11 @@ _text3 .text "Mouse drawing and keyboard scanning: done in main program loop.",1 ;--------- draw with mouse mousedraw - sta MOUSE+5 ; sample position and buttons + lda KEYBOARD + beq + ; no key + sta DISPLAY+$a + ++ sta MOUSE+5 ; sample position and buttons lda MOUSE+0 sta DISPLAY+3 lda MOUSE+1 diff --git a/src/main/resources/vmdemo.prg b/src/main/resources/vmdemo.prg index a7be87085fca4e766d166f9063c502dc5e7cfd7d..1930bc92262b42caeec02bdec8fc18d5e843904c 100644 GIT binary patch delta 51 zcmV-30L=f$2*?PKHv!X;IGVBA4gn5Qpb;Pk6RiN$@B@ts(39=~CkxO@kj<$8jR(;1 J#xRRVQjI{4*>>Rpb;Pk6O--%Ckxn0kkzRGjR(;1 J&a)r_C;|am6PEx0