| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,39 @@ |
| 1 |
+; Author: Pawel Jablonski |
|
| 2 |
+; E-mail: pj@xirx.net |
|
| 3 |
+; WWW: xirx.net |
|
| 4 |
+; GIT: git.xirx.net |
|
| 5 |
+; |
|
| 6 |
+; License: You can use this code however you like |
|
| 7 |
+; but leave information about the original author. |
|
| 8 |
+; Code is free for non-commercial and commercial use. |
|
| 9 |
+ |
|
| 10 |
+include io.asm |
|
| 11 |
+ |
|
| 12 |
+; No arguments |
|
| 13 |
+; Return: |
|
| 14 |
+; A - key code |
|
| 15 |
+external .xKeyboardGetChar: |
|
| 16 |
+ call .xKeyboardIsDataReady |
|
| 17 |
+ ; Wait until keyboard buffer has not data |
|
| 18 |
+ cmp 0, A |
|
| 19 |
+ je .xKeyboardGetChar |
|
| 20 |
+ ; Set keyboard register |
|
| 21 |
+ mov 0, A |
|
| 22 |
+ call .xIOSetRegister |
|
| 23 |
+ ; Read keyboard register |
|
| 24 |
+ call .xIORead |
|
| 25 |
+ ret |
|
| 26 |
+ |
|
| 27 |
+; No arguments |
|
| 28 |
+; Return: |
|
| 29 |
+; A - status (0 - empty, 1 - ready to read) |
|
| 30 |
+external .xKeyboardIsDataReady: |
|
| 31 |
+ ; Get keyboard interrupt bit |
|
| 32 |
+ in A |
|
| 33 |
+ and 0b00100000, A |
|
| 34 |
+ cmp 0, A |
|
| 35 |
+ jne .xKeyboardIsDataReady_ready |
|
| 36 |
+ ret |
|
| 37 |
+.xKeyboardIsDataReady_ready: |
|
| 38 |
+ mov 1, A |
|
| 39 |
+ ret |