A86: Re: Key Presses


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

A86: Re: Key Presses



I've used this before:
 
up:
 ld a,($c008)   ;load contrast into a
 cp 31            ;see if it's top
 jr z,getkey     ;if it is go back to the getkey loop
 inc a             ;if it isn't, increment it
 jr changecont ;get another key
down:
 ld a,($c008)  ;"
 cp 1             ;see if it is-
 jr c,getkey    ;less than one, and go to getkey loop if so
 dec a           ;else decrement it
changecont:
 out (2),a       ;actually change the contrast
 
the reason we check to see if it is at the top or bottom allowed, is because it will just loop and screw your contrast until a reset
----- Original Message -----
From: Bryan Kam
To: assembly-86@lists.ticalc.org
Sent: Saturday, December 04, 1999 2:45 PM
Subject: A86: Key Presses

Hello all you smart ASM programmers,
 
    I'm a newbie at this and I'm having trouble reading multiple keypresses.  I am reading the presses by writing to port 1 and reading from port 1 and I can read one key just fine, but I've heard that one can read more than one key press with the ports, but I am unsure how to do this.  Is reading the port the best way to do this or is _getky or _getkey better?  I'm trying to let them press +, -, or exit.  Here's my code:
 
Getkeypress:
    ld a,%01111101
    out (1),a
    nop
    nop
    in a,(1)
    bit 1,a
    jr nz, Getkeypress
 
    After that code it goes on to something that will change the contrast up, but I want to know how to make little routines for inc-ing the contrast, dec-ing the contrast, and ret-ing to the OS.
    Am I making sense?
 
Bryan

References: