Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Runer112 on November 01, 2010, 11:43:36 pm

Title: A GetKey that doesn't wait?
Post by: Runer112 on November 01, 2010, 11:43:36 pm
Is there such a thing? I know there are things like GetCSC and direct port input, but I'm wondering if GetKey has a non-waiting equivalent that also uses the A/keyExtend output format.
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 01, 2010, 11:49:00 pm
No.  I'm not sure how you would want such a routine to work, but no, it does not exist.  If you have stuff to do in the background while GetKey is running, you can use a cursor hook, GetKey hook, or silent link hook, as appropriate.
Title: Re: A GetKey that doesn't wait?
Post by: Runer112 on November 01, 2010, 11:57:23 pm
Dang, I have no idea how to use hooks... Anyone know of a good guide explaining how hooks work? Or anyone want to post a whirlwind tour of hooks?
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 02, 2010, 12:40:54 am
It's... a bit complicated.  Maybe it would help if you could explain what exactly you're trying to do.
Title: Re: A GetKey that doesn't wait?
Post by: Builderboy on November 02, 2010, 01:01:32 am
Isn't there a BCALL somewhere that does exactly that? ???
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 02, 2010, 01:05:38 am
Uh... no.  Not what he was asking.  There's GetCSC, which he mentioned, and GetK (BASIC's getKey), which he didn't.  Both of those routines return raw scancodes; they don't handle the shift keys, contrast control, APD, 2nd+Off, TIKB, or silent link.
Title: Re: A GetKey that doesn't wait?
Post by: Builderboy on November 02, 2010, 01:17:08 am
ahhh gotcha, i only dabble in Asm so i wasn't 100% sure ^^ thanks for the clarification!
Title: Re: A GetKey that doesn't wait?
Post by: Runer112 on November 02, 2010, 10:24:10 am
It's... a bit complicated.  Maybe it would help if you could explain what exactly you're trying to do.

I just want to make a program that can work while waiting for key inputs and accepts key inputs in the A/keyExtend format.
Title: Re: A GetKey that doesn't wait?
Post by: Deep Toaster on November 02, 2010, 11:38:17 am
Dang, I have no idea how to use hooks... Anyone know of a good guide explaining how hooks work? Or anyone want to post a whirlwind tour of hooks?

thepenguin77 gave me a quick guide earlier: http://ourl.ca/7566/131643
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 02, 2010, 10:21:03 pm
I just want to make a program that can work while waiting for key inputs and accepts key inputs in the A/keyExtend format.

You said that already.  The question is why.  For example, "I'm writing a game in which the user needs to type the answers to trivia questions in l33tspeak, while simultaneously using the arrow keys to dodge attacks from a giant lava monster."  Or "I'm writing a text editor where all the O's are actually eyes, that follow the cursor around the screen and blink at random intervals."
Title: Re: A GetKey that doesn't wait?
Post by: Runer112 on November 02, 2010, 10:32:17 pm
More like the second. The background processes won't be very intensive, maybe static/slightly dynamic grayscale displaying at most.
Title: Re: A GetKey that doesn't wait?
Post by: Builderboy on November 02, 2010, 10:32:31 pm
Both of those need to be made right now
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 02, 2010, 10:53:43 pm
For grayscale, you might be able to make it work with a GetKey hook, but for accurate timing I'd think you'd want to use an IM 2 handler.  To make grayscale look good, you generally want to have consistent timing regardless of whatever else is going on in your program, and regardless of whether the user is pressing keys.  I didn't think of mentioning IM 2 handlers before, but that might be the way to go.

On the other hand, a GetKey hook requires less memory to set up.
Title: Re: A GetKey that doesn't wait?
Post by: calc84maniac on November 02, 2010, 11:08:46 pm
If I remember correctly, if you press the ON key during _getKey a flag is set which causes exactly what you want. If you set this flag manually, it might just work.
Title: Re: A GetKey that doesn't wait?
Post by: Runer112 on November 02, 2010, 11:11:58 pm
Yeah, I might not bother with hooks or anything and just set up the program to run in an interrupt with a GetKeyRetOff running outside the interrupt.
Title: Re: A GetKey that doesn't wait?
Post by: FloppusMaximus on November 02, 2010, 11:15:16 pm
If I remember correctly, if you press the ON key during _getKey a flag is set which causes exactly what you want. If you set this flag manually, it might just work.
That's an interesting point.  I'm not sure if that would work or not.

(If not, a trivial GetKey hook could do the same thing.)
Title: Re: A GetKey that doesn't wait?
Post by: calc84maniac on November 02, 2010, 11:22:08 pm
This seems to work:
Code: [Select]
set onInterrupt,(iy+onFlags)
bcall(_GetKey)
Title: Re: A GetKey that doesn't wait?
Post by: DJ Omnimaga on November 02, 2010, 11:32:27 pm
One thing I would like to point out is that everyone has to start somewhere and can do mistakes and snapping at people for not understanding something or a question or missing a bit of information in a post is generally not a welcome behavior on the forums, regardless of if it comes from an experienced or inexperienced programmer. It goes against the goal of the community and big risks can be taken in long terms if that happens too often.

I haven't followed every help topic thoroughly but in this one I noticed two posts had some rather onobxious responses to other messages.