generated from rnentjes/kotlin-server-web-undertow
Refactor: Restructure project package hierarchy and add initial implementation for assembler instructions, shell commands, and exception handling.
This commit is contained in:
28
src/jvmMain/kotlin/mtmc/emulator/MTMCIO.kt
Normal file
28
src/jvmMain/kotlin/mtmc/emulator/MTMCIO.kt
Normal file
@@ -0,0 +1,28 @@
|
||||
package mtmc.emulator
|
||||
|
||||
import java.util.*
|
||||
|
||||
class MTMCIO {
|
||||
var value: Int = 0
|
||||
|
||||
internal enum class Buttons(val mask: Int) {
|
||||
UP(128),
|
||||
DOWN(64),
|
||||
LEFT(32),
|
||||
RIGHT(16),
|
||||
START(8),
|
||||
SELECT(4),
|
||||
B(2),
|
||||
A(1)
|
||||
}
|
||||
|
||||
fun keyPressed(key: String) {
|
||||
val button = Buttons.valueOf(key.uppercase(Locale.getDefault()))
|
||||
value = value or button.mask
|
||||
}
|
||||
|
||||
fun keyReleased(key: String) {
|
||||
val button = Buttons.valueOf(key.uppercase(Locale.getDefault()))
|
||||
value = value and button.mask.inv()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user