2 Commits

Author SHA1 Message Date
Hykilpikonna 91bed21747 [+] 4.7rc3 2022-11-13 00:45:54 -05:00
Hykilpikonna b402df8e1b [+] Old keyboard compatibility 2022-11-13 00:44:00 -05:00
3 changed files with 26 additions and 6 deletions
+2 -1
View File
@@ -11,6 +11,7 @@
* Switched to Gradle build system with Kotlin support
* Added `--open` command-line option to open a file on start
* Added **Keyboard++**: Enhanced keyboard events
* **Keyboard++** is still compatible with old keyboard's ASM code, even though it only repeats the last key down until the key is released.
* Refactored many classes in Kotlin
* A LOT of [optimizations](https://github.com/hykilpikonna/EMARS#optimizations)
@@ -21,7 +22,7 @@
## Modifications needed
1. To use **Bitmap Display++**, please add the following code at the end of each render loop:
1. To use **Bitmap Display++**, please add the following code at the end of each loop, after render but before sleep:
```asm
# Tell the display to update
+1 -1
View File
@@ -6,7 +6,7 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
version="4.7rc2"
version="4.7rc3"
repositories {
// Use Maven Central for resolving dependencies.
+23 -4
View File
@@ -73,7 +73,8 @@ class BitmapDisplay : AbstractMarsToolAndApplication
// Keyboard++
private var keyboardAddr: UInt = 0xFFFF0010u
private var displayUpdateAddr: UInt = 0xFFFF0008u
private var oldKeyboardAddr: UInt = 0xFFFF0000u
private var oldKeyboardLastPressed: Char = ' '
private var keyboardAttached = false
private lateinit var uiKeyboard: JTextField
@@ -149,7 +150,7 @@ class BitmapDisplay : AbstractMarsToolAndApplication
if (ac !is MemoryAccessNotice || ac.accessType != AccessNotice.WRITE) return
val addr = ac.address.toUInt()
// For the keyboard
// For the keyboard++
if (addr in keyboardAddr..keyboardAddr + 0x30u)
{
// Offset 0x01 or 0x11 or 0x21 bytes are for telling the keyboard that the events are received
@@ -201,6 +202,24 @@ class BitmapDisplay : AbstractMarsToolAndApplication
println("[Keyboard++] ${e.id} '${e.keyChar}' ${e.keyCode}")
val queue = pooledKeyEvents[offset]!!
// Old keyboard compatibility
synchronized(Globals.memoryAndRegistersLock)
{
if (e.id == KeyEvent.KEY_PRESSED)
{
oldKeyboardLastPressed = e.keyChar
Globals.memory.setWord(oldKeyboardAddr.toInt(), 1)
Globals.memory.setWord((oldKeyboardAddr + 4u).toInt(), e.keyChar.code)
}
if (e.id == KeyEvent.KEY_RELEASED && e.keyChar == oldKeyboardLastPressed)
{
oldKeyboardLastPressed = 0.toChar()
Globals.memory.setWord(oldKeyboardAddr.toInt(), 0)
Globals.memory.setWord((oldKeyboardAddr + 4u).toInt(), 0)
}
}
// Check for more than 7 key events queued
if (queue.size == 7) return
@@ -208,11 +227,11 @@ class BitmapDisplay : AbstractMarsToolAndApplication
queue.add(e)
// Add to memory
var addr = keyboardAddr + offset
println("[Keyboard++] Address ${addr.toHex(8)} set to ${queue.size} | ${addr.toHex(8)} set to ${e.keyCode} (${e.keyChar.toHex()})")
synchronized(Globals.memoryAndRegistersLock)
{
// Change 0x0: Number of events
var addr = keyboardAddr + offset
println("[Keyboard++] Address ${addr.toHex(8)} set to ${queue.size} | ${addr.toHex(8)} set to ${e.keyCode} (${e.keyChar.toHex()})")
Globals.memory.setByte(addr.toInt(), queue.size)
// Set the keycode