home *** CD-ROM | disk | FTP | other *** search
- * Intelligent Get_Key function for Personal Pascal
- *
- * Written by Keith Ledbetter 6-Sept-87
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
-
- .globl GET_KEY
-
-
- gemdos equ 1
- bios equ 13
- xbios equ 14
- kbd equ 2
-
-
-
-
- * From Pascal: Function Get_Key: Char;
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
- GET_KEY: clr.l d0 ;so I'm paranoid...
- move.w #kbd,-(sp) ;from keyboard
- move.w #2,-(sp) ;function #2
- trap #bios
- addq.l #4,sp
-
- move.l d0,d1 ;d0=(shr(d0,8) | (d0 & $ffff)
- lsr.l #8,d0
- and.l #$ffff,d1
- or.l d1,d0
-
-
- * see if this keypress is in the table
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- move.l #keytable,a0 ;a0 points to table
- lkuploop: move.w (a0)+,d1
- cmp.w #0,d1 ;end of table?
- beq lk_eot ;yep..
- cmp.w d0,d1 ;key match?
- beq lk_found ;yes..
- addq.l #2,a0 ;inc pointer
- bra lkuploop ; and keep cooking..
-
- lk_found: move.w (a0),d0 ;return the function key
- rts ; value from the table.
-
- lk_eot: and.w #$7f,d0 ;if not in the table, just
- rts ; strip it and return it.
-
- .even
-
- keytable: dc.w $3b00,201 ;F1
- dc.w $3c00,202 ;F2
- dc.w $3d00,203
- dc.w $3e00,204
- dc.w $3f00,205
- dc.w $4000,206
- dc.w $4100,207
- dc.w $4200,208
- dc.w $4300,209
- dc.w $4400,210 ;F10
-
- dc.w $5400,211 ;F11
- dc.w $5500,212
- dc.w $5600,213
- dc.w $5700,214
- dc.w $5800,215
- dc.w $5900,216
- dc.w $5A00,217
- dc.w $5B00,218
- dc.w $5C00,219
- dc.w $5D00,220 ;F20
-
- dc.w $4b00,221 ;left arrow
- dc.w $4d00,222 ;right arrow
- dc.w $7300,223 ;^left arrow
- dc.w $7400,224 ;^right arrow
- dc.w $537f,225 ;delete
- dc.w $5200,226 ;insert
-
- dc.w $6100,227 ;undo
- dc.w $6200,228 ;help
- dc.w $4700,229 ;clear/home
- dc.w $4737,230 ;shift clear/home
- dc.w $5230,231 ;shift insert
-
- dc.w $4B34,232 ;shift left arrow
- dc.w $4838,233 ;shift up arrow
- dc.w $4D36,234 ;shift right arrow
- dc.w $5032,235 ;shift down arrow
-
- dc.w 0,0
-
- .end
-