home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / apple2 / 20159 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.1 KB  |  74 lines

  1. Newsgroups: comp.sys.apple2
  2. Path: sparky!uunet!newsstand.cit.cornell.edu!piccolo.cit.cornell.edu!crux3!jmk3
  3. From: jmk3@crux3.cit.cornell.edu (Jay Krell)
  4. Subject: getting a keypress
  5. Message-ID: <jmk3.716240567@crux1.cit.cornell.edu>
  6. Sender: news@piccolo.cit.cornell.edu (USENET News System)
  7. Nntp-Posting-Host: crux3.cit.cornell.edu
  8. Organization: Cornell Information Technologies
  9. Date: 11 Sep 92 19:42:47 GMT
  10. Lines: 62
  11.  
  12. >>But to the point.  Does there exist in Orca pascal a function that
  13. >>will return a keypress without waiting for return to be pressed?
  14.  
  15. (My first internet post, forgive me if I screw up.)
  16.  
  17. No, but the Calendar example CDA with Pascal shows how to read the
  18. keyboard directly, though rather incorrectly. I'm pretty sure it
  19. accesses a word of memory at a time ie - C000 and C001 which is in
  20. general not a good thing, and it is only for when the Event Manager
  21. isn't active.
  22.  
  23. Anyway, try something like this:
  24.  
  25. function ReadKey: integer; extern;
  26.  
  27.         ReadKey start
  28.                 pea     0
  29.                 _EMStatus
  30.                 pla
  31.                 beq     hardware
  32.         loop    ~GetNextEvent #$ffff,#EventRec
  33.         ; you might want to restrict the mask
  34.                 pla
  35.                 beq     noKey
  36.                 lda     what
  37.                 cmp     #keyDownEvt
  38.                 beq     key
  39.                 cmp     #autoKeyEvt
  40.                 bne     noKey
  41.         key     anop
  42.                 lda     message
  43.                 rtl
  44.         noKey   anop
  45.                 lda     #0
  46.                 rtl
  47.  
  48.         hardware        anop
  49.                 shortm
  50.         hloop   lda     >$E0C000
  51.                 bpl     noKey
  52.                 sta     >$E0C010
  53.                 and     #$7F
  54.                 longm
  55.                 rtl
  56.  
  57.         EventRec        anop
  58.         what    dw
  59.         message dl
  60.         when    dl
  61.         where   dl
  62.         mods    dw
  63.  
  64.                 end
  65.  
  66. NOTE: this routine originally waited for a keypress but I _just_
  67. modified it to not wait and return zero if there's no waiting keypress.
  68. So, it's _not_ tested.
  69.  
  70.  
  71. Jay
  72.  
  73. PS - Bryan 'Zak's SmartMacros are used here.
  74.