Subversion Repositories Spectranet

[/] [trunk/] [rom/] [ui_input.asm] - Blame information for rev 68

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 68 winston
;The MIT License
2
;
3
;Copyright (c) 2008 Dylan Smith
4
;
5
;Permission is hereby granted, free of charge, to any person obtaining a copy
6
;of this software and associated documentation files (the "Software"), to deal
7
;in the Software without restriction, including without limitation the rights
8
;to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
;copies of the Software, and to permit persons to whom the Software is
10
;furnished to do so, subject to the following conditions:
11
;
12
;The above copyright notice and this permission notice shall be included in
13
;all copies or substantial portions of the Software.
14
;
15
;THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
;IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
;FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
;AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
;LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
;OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
;THE SOFTWARE.
22
 
23
; User Interface input routines - handling the keyboard.
24
; The keyboard routines use the main ZX ROM to decode key strokes.
25
; They are designed to hopefully work without needing the ZX ROM itself to
26
; have initialized (and so can work when the Spectranet has run its RESET
27
; routine, but before the ZX ROM has done the same).
28
; The routines are designed to work regardless of the maskable interrupt
29
; state.
30
 
31
;===========================================================================
32
; Definitions - special keys returned by K_DECODE (and therefore F_getkey)
33
KEY_TRUEVID     equ 0x04
34
KEY_INVVID      equ 0x05
35
KEY_CAPSLOCK    equ 0x06
36
KEY_EDIT        equ 0x07
37
KEY_LEFT        equ 0x08
38
KEY_RIGHT       equ 0x09
39
KEY_DOWN        equ 0x0A
40
KEY_UP          equ 0x0B
41
KEY_BACKSPACE   equ 0x0C
42
KEY_ENTER       equ 0x0D
43
KEY_EXTEND      equ 0x0E
44
KEY_GRAPH       equ 0x0F
45
 
46
;===========================================================================
47
; F_getkey:
48
; Waits for a key to be pressed, and returns the key in A.
49
; The routine returns the key on keydown. The calling routine should then
50
; wait for keyup before getting the next key.
51
F_getkey
52
.loop
53
        rst CALLBAS
54
        defw ZX_KEY_SCAN        ; scan the keyboard
55
        rst CALLBAS
56
        defw ZX_K_TEST          ; test for key press
57
        jr nc, .loop
58
        ld e, a                 ; partially decoded key is in A, copy it to E
59
        ld d, 8                 ; not in 'K' cursor mode
60
        ld c, 0                 ; FLAGS = 0
61
        rst CALLBAS
62
        defw ZX_K_DECODE        ; decode keypress into actual ascii value
63
        ret
64
 
65
;===========================================================================
66
; F_keyup:
67
; Waits for the keyboard not being pressed anywhere that will generate
68
; a character.
69
F_keyup
70
.loop
71
        rst CALLBAS
72
        defw ZX_KEY_SCAN        ; scan the keyboard
73
        rst CALLBAS
74
        defw ZX_K_TEST
75
        jr c, .loop             ; carry set = key being pressed
76
        ret
77