home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.apple2
- Path: sparky!uunet!newsstand.cit.cornell.edu!piccolo.cit.cornell.edu!crux3!jmk3
- From: jmk3@crux3.cit.cornell.edu (Jay Krell)
- Subject: getting a keypress
- Message-ID: <jmk3.716240567@crux1.cit.cornell.edu>
- Sender: news@piccolo.cit.cornell.edu (USENET News System)
- Nntp-Posting-Host: crux3.cit.cornell.edu
- Organization: Cornell Information Technologies
- Date: 11 Sep 92 19:42:47 GMT
- Lines: 62
-
- >>But to the point. Does there exist in Orca pascal a function that
- >>will return a keypress without waiting for return to be pressed?
-
- (My first internet post, forgive me if I screw up.)
-
- No, but the Calendar example CDA with Pascal shows how to read the
- keyboard directly, though rather incorrectly. I'm pretty sure it
- accesses a word of memory at a time ie - C000 and C001 which is in
- general not a good thing, and it is only for when the Event Manager
- isn't active.
-
- Anyway, try something like this:
-
- function ReadKey: integer; extern;
-
- ReadKey start
- pea 0
- _EMStatus
- pla
- beq hardware
- loop ~GetNextEvent #$ffff,#EventRec
- ; you might want to restrict the mask
- pla
- beq noKey
- lda what
- cmp #keyDownEvt
- beq key
- cmp #autoKeyEvt
- bne noKey
- key anop
- lda message
- rtl
- noKey anop
- lda #0
- rtl
-
- hardware anop
- shortm
- hloop lda >$E0C000
- bpl noKey
- sta >$E0C010
- and #$7F
- longm
- rtl
-
- EventRec anop
- what dw
- message dl
- when dl
- where dl
- mods dw
-
- end
-
- NOTE: this routine originally waited for a keypress but I _just_
- modified it to not wait and return zero if there's no waiting keypress.
- So, it's _not_ tested.
-
-
- Jay
-
- PS - Bryan 'Zak's SmartMacros are used here.
-