-
Notifications
You must be signed in to change notification settings - Fork 1
EasyInput
Robert Kennedy edited this page Apr 25, 2016
·
2 revisions
EasyInput is used to handle keyboard input easily for games made in Easy68K assembly.
Note - EasyInput does not currently support more than one use of the macro.
You have to first copy the file to your project directory then you can include the EasyInput.X68 file at the top of your source code using the following code.
INCLUDE 'EasyInput.X68'
Now you can using the "getKeyInput" macro in the following manner:
getKeyInput <WASD>
Following this macro you must use the "ifKey#" macros and "endIfKey" macros to encapsulate your code.
ifKey1
; Your code
endIfKey
The keys are read from left to right so "" will return W as 1, A as 2, S as 3, and D as 4. This means you can read anywhere from 1 to 4 inputs such as "" instead of "".
Here is the complete code for reading 4 key inputs:
getKeyInput <WASD>
ifKey1
; Your code for W
endIfKey
ifKey2
; Your code for A
endIfKey
ifKey3
; Your code for S
endIfKey
ifKey4
; Your code for D
endIfKey
INCLUDE 'EasyInput.x68'
ORG $1000
START: ; first instruction of program
inputLoop
getKeyInput <WASD>
ifKey1
LEA str1,A1
MOVE.B #13,D0
TRAP #15
endIfKey
ifKey2
LEA str2,A1
MOVE.B #13,D0
TRAP #15
endIfKey
ifKey3
LEA str3,A1
MOVE.B #13,D0
TRAP #15
endIfKey
ifKey4
LEA str4,A1
MOVE.B #13,D0
TRAP #15
endIfKey
MOVE.W #$FF00,D1
MOVE.B #11,D0
TRAP #15
BRA inputLoop
SIMHALT ; halt simulator
str1 dc.b 'Key 1 Is Being Pressed.',0
str2 dc.b 'Key 2 Is Being Pressed.',0
str3 dc.b 'Key 3 Is Being Pressed.',0
str4 dc.b 'Key 4 Is Being Pressed.',0
END START ; last line of source