[comp.sys.handhelds] HP48 Keybuffer Polling

ftg0673@tamsun.tamu.edu (Rick Grevelle) (05/02/91)

Polling the 48's keybuffer directly, through the use of an assembly language
program, is straight forward.  This routine exemplifies the process while
providing a utility for redefining the keyboard on a user level.  Unlike the
SYSTEM RPL routine #41F65h for KEYWAIT that actually puts the 48 in a low 
powered state, this routine loops continuously until a keystroke is detected,
after which the key's numerical value is returned to the stack.  Although
the routine can be easily modified to do so, it is not designed to recognize
any key combinations for Alhpa-shifted, Left-shifted, and Right-shifted
sequences as KEYWAIT does.  This is probably better suited for those who are
primarily interested in controlling the keyboard from machine code, for
this is the reason it was first developed.  The keyboard map should be self
explanatory.


Rick Grevelle




		---------------------------------------
		| ----------------------------------- |
		| |                                 | |
		| |                                 | |
		| |                                 | |
		| |                                 | |
		| |                                 | |
		| |                                 | |
		| |                                 | |
		| |                                 | |		
		|  ---------------------------------  |
		|                                     |
		| [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] |
		|                                     |
		| [ 7 ] [ 8 ] [ 9 ] [ 10] [ 11] [ 12] |
		|                                     |
		| [ 13] [ 14] [ 15] [ 16] [ 17] [ 18] |
		|                                     |
		| [ 19] [ 20] [ 21] [ 22] [ 23] [ 24] |
		|                                     |
		| [    25   ] [ 26] [ 27] [ 28] [ 29] |
		|                                     |
		| [128] [ 31 ] [ 32 ]  [ 33 ]  [ 34 ] |
		|                                     |
		| [ 64] [ 36 ] [ 37 ]  [ 38 ]  [ 39 ] |
		|                                     |
		| [192] [ 41 ] [ 42 ]  [ 42 ]  [ 44 ] |
		|                                     |
		| [ * ] [ 46 ] [ 47 ]  [ 48 ]  [ 49 ] |
		|                                     |
		---------------------------------------

		   * The attention key is disabled



			Keybuffer Polling


	d9d20	  data.a   #02d9d	; begin rpl
	ccd20	  data.a   #02dcc	; begin code
	97000	  data.a   #00079	; length

	8fb9760	  call.a   #0679b	; save registers

	1f3c607	  move.5   #706c3,d1	;\
	14f	  move.b   @d1,c	; kill alpha
	80887	  clrb     #7,c		; annunciator
	14d	  move.b   c,@d1	;/

	1fb0100	  move.5   #0010b,d1	;\
	14f	  move.b   @d1,c	; kill busy
	80884	  clrb     #4,c		; annunciator
	14d	  move.b   c,@d1	;/

poll:	1fbe407	  move.5   #704eb,d1	;\
	1534	  move.s   @d1,a	;
	1c0	  sub.a	   #1,d1	; poll buffer for keypress
	1574	  move.s   @d1,c	;
	942be	  breq.s   poll buffer	;/

	80df	  move.1   c,#f,p	; save offset

	b46	  inc.s    c		; nullify 
	1554	  move.s   c,@d1	; keypress

	137	  swap.a   c,d1		;\
	809	  add.a    p+1,c	; determine key location
	809	  add.a    p+1,c	;/

	20	  move.1   #0,p		; restore pointer
	135	  move.a   c,d1		; put address of key number in d1

	d2	  clr.a    c		;\
	14f	  move.b   @d1,c	; put key number in r0
	108	  move.w   c,r0		;/
	
	8f73560	  call.a   #06537	; push key number as system binary

	142	  move.a   @d0,a	;\
	164	  add.a    #5,d0	; continue rpl
	808c	  jump.a   @a		;/

	fbd81	  data.a   #18bdf	; system binary->real
	b2130	  data.a   #0312b	; end rpl



o  /
 \/
 /\  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o  \

KEYWAIT

%%HP: T(1)A(D)F(.);
"D9D20CCD20970008FB97601F3C60714F8088714D1FB010014F8088414D1FBE40
715341C01574942BE80DFB46155413780980920135D214F1088F735601421648
08CFBD81B2130EDB0"