Re: A82: Port 1, the keyboard port.


[Prev][Next][Index][Thread]

Re: A82: Port 1, the keyboard port.



GSGolfNut@aol.com writes:
>Tell me if this routine for checking the keyboard port is correct.
> ld a, %01111100 ; masks out all keys except
> out (1), a            ;ENTER + - * / ^ CLEAR UP DOWN LEFT RIGHT
> in a, (1)              ;Returns the bits read from the keypad 

You might want to check if no keys are being pressed here to speed up the
program. Oh, and a interesting note pointed outto me by Sam Davies. If
you do the following, the flags are updated.

	ld C, 1
	out (C), A
	in A, (C)

This will help you check for No Keys.

> push AF             ;af saved in stack
> bit 6, a               ;load bit 6 of a into a
> jr nz, quit            ; if a is 1 the key pressed is clear, jump to
quit
> pop AF               ;reload AF from the stack

Make sure you include pop AF in the quit label. What I do is:

Pop_Quit: 
	pop AF
Quit:
	RET

If you don't do this, people will be unhappy 'cuse your program will
crash their calcs. =)

> push AF             ;store AF back into the stack
> bit 2, a               ;load bit 2 of a into a
> jr nz, move_right  ; if a is 1 the key pressed is right, jump to move
right
> pop AF               ;reload AF from the stack

Okay, here you'd probably want a conditional CALL to Move_Right, not a
jump. It's a lot less messier. 


> bit 1, a                ; load bit 1 of a into a
> jr nz, move_left    ; if  a is 1 the key pressed is left, jump to move
left

Nothing wrong here. It's better to make the last bit you test a jump to
make things faster. Just remember to have a jump back to the main loop
from the end of the Move_Left routine and afte the jump to the routine
and you're all set!

>I got the keypad port information from 82ports.txt.
>BTW thanks for the display port routine Dines. What does RCL L do?

He meant RLC L, not RCL. It's a 8 bit rotation (no carry) left. 

> How much faster is writing 16 bits directly to the display port 
>rather than
>using      
> Dines's point_on and point_off

Considerably faster, mostly because FIND_PIXEL is used in the Point_On
and Off and it's a really slow routine. Avoid it at all costs when you
want speed! =)

>                  Dark Light Enterprises
>               Hurting programmers around the world
>                  Just Kidding Thomas!!!


Hehehehehe

	-Scoobie



References: