OSDN Git Service

Masked out scancode in KEY.
[fig-forth-68000/fig-forth-68000.git] / iotest.s
1 * Some Q&D stuff to test BIOS console routines.
2
3
4         BRA.W test
5
6         DS.L    $100
7 STACK   EQU     *
8         DS.L    $100
9 PSTACK  EQU     *
10         DS.L    8       ; buffer zone
11 PSP     EQUR    A6
12
13
14 HELLO   DC.B    'Greetings.',$0A,$0D,0
15 PROMPT  DC.B    'Hit a key.',0
16
17
18 BIOSCALL        EQU     13
19
20 CONSOLE         EQU     2
21 IKBD            EQU     4
22
23
24 bconstat        EQU     1
25 bconin          EQU     2
26 bconout         EQU     3
27 bcostat         EQU     8
28 kbshift         EQU     11
29
30 kshftrt         EQU     1
31 kshftlft        EQU     2
32 kshftctl        EQU     4
33 kshftalt        EQU     8
34 kshftcaps       EQU     16
35 kshftrbtn       EQU     32
36 kshftlbtn       EQU     64
37 kshftunu        EQU     128
38
39
40         EVEN
41 * ( --- flag )
42 * 0 for not ready, -1 for ready for a character
43 conoutstat:
44         MOVE.W  #CONSOLE,-(SP)
45         MOVE.W  #bcostat,-(SP)
46         TRAP    #BIOSCALL
47         MOVE.W  D0,-(PSP)
48         LEA     4(SP),SP        ; keep the flags
49         RTS
50
51 * ( ch --- )
52 conoutch:
53         BSR.S   conoutstat
54         TST.W   (PSP)+
55         BEQ.S   conoutch        ; wait
56         MOVE.L  (PSP)+,D0
57         MOVE.W  D0,-(SP)
58         MOVE.W  #CONSOLE,-(SP)
59         MOVE.W  #bconout,-(SP)
60         TRAP    #BIOSCALL
61         LEA     6(SP),SP
62         RTS
63
64 * ( str --- )
65 conoutstr:
66         MOVE.L  (PSP),A0
67         CLR.L   D0
68         MOVE.B  (A0)+,D0
69         MOVEM.L A0,(PSP)        ; update the pointer, keep the flags
70         BEQ.S   conoutstrx
71         MOVE.L  D0,-(PSP)
72         BSR.S   conoutch
73         BRA.S   conoutstr
74 conoutstrx:
75         LEA     4(PSP),PSP
76         RTS
77
78 * ( --- status )
79 * 0 for not ready, -1 for ready
80 coninstat:
81         MOVE.W  #CONSOLE,-(SP)
82         MOVE.W  #bconstat,-(SP)
83         TRAP    #BIOSCALL
84         MOVE.W  D0,-(PSP)
85         LEA     4(SP),SP        ; keep the flags
86         RTS
87
88 * ( --- scancode:ch )
89 * Waits for character
90 coninch:
91         MOVE.W  #CONSOLE,-(SP)
92         MOVE.W  #bconin,-(SP)
93         TRAP    #BIOSCALL
94         MOVE.L  D0,-(PSP)       ; scancode in high word
95         LEA     4(SP),SP
96         RTS
97
98 * ( --- scancode:ch|0 )
99 coninnow:
100         BSR.S   coninstat
101         MOVE.W  (PSP),-(PSP)    ; duplicate flag word
102         BEQ.S   coninnowx       ; if not ready, don't wait
103         BSR.S   coninch
104         MOVE.L  (PSP)+,(PSP)    ; store scancode:ch
105 coninnowx:
106         RTS
107
108
109 test:
110         LEA     STACK(PC),SP
111         LEA     PSTACK(PC),PSP
112         LEA     HELLO(PC),A0
113         MOVE.L  A0,-(PSP)
114         BSR.W   conoutstr
115         LEA     PROMPT(PC),A0
116         MOVE.L  A0,-(PSP)
117         BSR.W   conoutstr
118 testkeys:
119         BSR.S   coninch
120         MOVE.L  (PSP),D7
121         BSR.W   conoutch
122         CMP.B   #$20,D7
123         BHS.S   testvisible
124         MOVE.L  #'^',-(PSP)
125         BSR.W   conoutch
126         MOVE.L  D7,D6
127         ADD.B   #'@',D6
128         MOVE.L  D6,-(PSP)
129         BSR.W   conoutch
130 testvisible:
131         CMP.B   #'q',D7
132         BNE.S   testkeys
133         CLR.L   D7
134         MOVE.L  D7,D6
135 testnowaitl:
136         MOVE.L  D7,-(PSP)
137         BSR.W   conoutch
138         BSR.S   coninnow
139         MOVE.L  (PSP)+,D1
140         BNE.S   testnowaitx
141 testnowpause:
142         ADD.W   #1,D6
143         BNE.S   testnowpause    ; busy wait
144         ADD.B   #1,D7
145         BRA.S   testnowaitl
146 * and quit
147 testnowaitx:
148         MOVE.L  D1,-(PSP)
149         BSR.W   conoutch
150         clr.w   -(sp)
151         trap    #1                      quick exit
152