Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!mattd From: mattd@Apple.COM (Matt Deatherage) Newsgroups: comp.sys.apple2 Subject: Re: Orca/C bug? Message-ID: <53317@apple.Apple.COM> Date: 24 May 91 22:48:57 GMT References: <9105221206.AA02966@apple.com> <1991May22.225351.13303@ux1.cso.uiuc.edu> Organization: Apple Computer Inc., Cupertino, CA Lines: 51 In article <1991May22.225351.13303@ux1.cso.uiuc.edu> jb10320@uxa.cso.uiuc.edu (Jawaid Bazyar) writes: > > getkey()? There is no getkey defined as part of the C standard. >Perhaps you mean getchar()... getchar() (and in fact all of the >C I/O routines) buffer input- in this particular case, the >line you're typing. Many systems have a way to put the I/O >routines in a 'raw' mode, so you can get single characters >at a time, but I don't believe Orca/C supports this. >Here's a little routine that will wait for and get a character >from the keyboard (sorry, no cursor displayed- but you can >set one up by printing an inverse space). > >char getkey() >{ >char c = 0; > > asm { > sep 0x20 >loop: > lda 0xE1C000 > bpl loop > and #0x7f > sta c > lda 0xE1C010 > rep 0x20 > } > return (char) c; >} > > Yes, it's assembly, but I've been using this for a couple >years with no problem. > >-- >Jawaid Bazyar | "Twenty seven faces- with their eyes turned to (Sorry for all the quoting, I thought it appropriate) This routine will fail if the Event Manager is started. With the Event Manager on, the system has a heartbeat task that reads the keyboard and puts the key in the event queue (it would be keyboard interrupts if those worked right). So if you ever do EMStartUp, be careful that you don't use this subroutine or you might have to hit several keys to get one. (Under the Event Manager, just ask GetNextEvent for the next key-down event.) -- ============================================================================ Matt Deatherage, Developer Technical | The opinions expressed herein are Support, Apple Computer, Inc. | not those of Apple Computer, and Personal mail only, please. Thanks. | shame on you for thinking otherwise. ^^^^^^^^ Technical questions are not personal. Please post them instead. ============================================================================