Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: SirCmpwn on September 19, 2010, 01:20:22 pm

Title: Wait For Keys
Post by: SirCmpwn on September 19, 2010, 01:20:22 pm
Hello,
What is a good Axe routine to wait for all keys to be released?
Title: Re: Wait For Keys
Post by: calc84maniac on September 19, 2010, 01:21:26 pm
While getKey(0)
End
Title: Re: Wait For Keys
Post by: calcdude84se on September 19, 2010, 01:27:57 pm
While getKey(0)
End

^++ This.
No better way to my knowledge ;D
Title: Re: Wait For Keys
Post by: SirCmpwn on September 19, 2010, 01:28:53 pm
Ah, I was using While getKey:End
Title: Re: Wait For Keys
Post by: Michael_Lee on September 19, 2010, 01:30:15 pm
You could add a DispGraphr inside that loop, so that if you're using grayscale or something, it'll still be smooth.
Title: Re: Wait For Keys
Post by: SirCmpwn on September 19, 2010, 01:31:06 pm
Right, that much I know.  And I usually use 4 level, so DispGraphrr would be more appropriate :)
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 19, 2010, 01:39:52 pm
While getKey(0)
End

That doesn't work in Doors CS, though. I believe I had issues with Mirage as well as WabbitEmu. but again maybe Axe Tunnel was using a slightly different code.
Title: Re: Wait For Keys
Post by: _player1537 on September 19, 2010, 07:18:22 pm
I have to do this in my code:
Code: [Select]
while getKey(0)
Pause 50
End
Otherwise it exits the loop randomly :O
Title: Re: Wait For Keys
Post by: Michael_Lee on September 19, 2010, 07:57:25 pm
I have to do this in my code:
Code: [Select]
while getKey(0)
Pause 50
End
Otherwise it exits the loop randomly :O

Really?
The loop is suppose to exit only when you release the key - are you sure you aren't accidentally letting go of a button?
Title: Re: Wait For Keys
Post by: Deep Toaster on September 19, 2010, 08:19:00 pm
Maybe you're not holding down a button when it starts. Try

Code: (Axe) [Select]
:Repeat getKey(0)
:End
:While getKey(0)
:End

and see if it works.
Title: Re: Wait For Keys
Post by: shmibs on September 19, 2010, 08:53:31 pm
I have to do this in my code:
Code: [Select]
while getKey(0)
Pause 50
End
Otherwise it exits the loop randomly :O

dittoes(i was getting a bit frustrated about it last night)...
Title: Re: Wait For Keys
Post by: nemo on September 19, 2010, 09:03:46 pm
getKey(0) is just really fast.. so without any pause between checking getKey(0) will mess things up. you should be okay with this:
Code: [Select]
While getKey(0)
Pause 3
End
Title: Re: Wait For Keys
Post by: ztrumpet on September 19, 2010, 09:58:53 pm
I generally add a Pause(50) also.
Title: Re: Wait For Keys
Post by: Quigibo on September 19, 2010, 10:54:31 pm
If you're in Full mode then the delay in the key routine is too quick to register the key-group switch.  Make sure you're in Normal mode when using direct key detection.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 19, 2010, 11:24:05 pm
Oh I see why there are issues now. Key delay was too short. Gonna have to fix Axe Tunnel at one point then...
Title: Re: Wait For Keys
Post by: ztrumpet on September 20, 2010, 04:19:51 pm
If you're in Full mode then the delay in the key routine is too quick to register the key-group switch.  Make sure you're in Normal mode when using direct key detection.
I'm in Normal mode and have to do it.
Title: Re: Wait For Keys
Post by: calcdude84se on September 20, 2010, 09:16:18 pm
Maybe we could have a getKey(#)r that uses the delay appropriate for 15MHz mode?
And yeah, it is annoying x.x
Title: Re: Wait For Keys
Post by: Deep Toaster on September 21, 2010, 07:37:04 pm
Maybe we could have a getKey(#)r that uses the delay appropriate for 15MHz mode?
And yeah, it is annoying x.x

Yeah, that'd be a great feature to add. I thought Axe'd done it already, though.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 22, 2010, 12:02:06 pm
Shouldn't you just do

Code: [Select]
Normal
While getkey(0)
Pause 3
End
Full

?

This is what we do with grayscale actually.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 22, 2010, 07:18:32 pm
Huh? I never heard about that. So we absolutely need a pause if we use grayscale?
Title: Re: Wait For Keys
Post by: Runer112 on September 22, 2010, 08:03:24 pm
No, he means if you're running a program at 15MHz, you have to similarly precede the DispGraphr(r) with Normal and put Full after it.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 22, 2010, 08:05:18 pm
Oh, got it.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 22, 2010, 11:24:27 pm
Yeah this is what I meant. We have to do the same thing with grayscale.
Title: Re: Wait For Keys
Post by: SirCmpwn on September 26, 2010, 08:58:25 am
This is hilarious.  I posted this hoping for a simple routine, but instead it turns into a two page mini-discussion about the best way to approach this, with 7 or 8 potential routines.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 10:59:37 am
2 pages? That's nothing. I've seen a topic asking for simpler routines turn into huge, 7-8 page argument on an almost unrelated subject.

EDIT: Soo, which routine are you going to use?
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 12:04:08 pm
This is hilarious.  I posted this hoping for a simple routine, but instead it turns into a two page mini-discussion about the best way to approach this, with 7 or 8 potential routines.
Yeah but no need to be a jerk about it either if that's your intention. People just thought it would be cool if Quigibo implemented a routine making it easier for people to get around the delay issues and discussed potential routines. You have to expect this to happen in help topics. I saw this happen a lot before.
Title: Re: Wait For Keys
Post by: qazz42 on September 26, 2010, 12:08:09 pm
This is hilarious.  I posted this hoping for a simple routine, but instead it turns into a two page mini-discussion about the best way to approach this, with 7 or 8 potential routines.

wow, the sarcasm is so intense, I can feel it radiating from my screen
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 12:50:12 pm
This is hilarious.  I posted this hoping for a simple routine, but instead it turns into a two page mini-discussion about the best way to approach this, with 7 or 8 potential routines.

wow, the sarcasm is so intense, I can feel it radiating from my screen

In that case ... please disregard my last post ;D
Title: Re: Wait For Keys
Post by: SirCmpwn on September 26, 2010, 02:34:27 pm
Err...
This is what I said in a PM with DJ:
I meant it more as praise than anything, that I can post requesting a simple routine, and the community strives to find the best possible way of doing it instead of just a quick reply.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 02:46:26 pm
That's what I thought.

Soo, which routine are you going to use?
Title: Re: Wait For Keys
Post by: qazz42 on September 26, 2010, 02:54:09 pm
lol, :)
Title: Re: Wait For Keys
Post by: ztrumpet on September 26, 2010, 02:56:59 pm
Soo, which routine are you going to use?
While {Lobesteritus_Ensues}
getKey->{The_Game}
End
Title: Re: Wait For Keys
Post by: Quigibo on September 26, 2010, 03:02:56 pm
By the way, adding a pause in a loop with a getkey doesn't actually do anything control-wise other than make the response time a little slower.  The pause needs to be internal in the getkey routine itself (which I have fixed now).
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 03:14:00 pm
Do you mean pause and getkey will be merged? I am not too sure what you mean by being internal in the getkey routine :(
Title: Re: Wait For Keys
Post by: calcdude84se on September 26, 2010, 03:51:45 pm
Quigibo, does that mean something like the getKey(#)r I suggested, or am I misunderstanding?
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 04:17:16 pm
You mean getKey(#) will have the pause built-in from now on, right? So no messing with Pause for keypresses :D

EDIT: Oh, yeah, you're right, Quigibo. Even if we added a pause, it wouldn't affect anything since the getKey routine's already done.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 04:43:11 pm
Oh I see now what he meant. It would be nice if we could make the pause internal.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 04:44:38 pm
It has to be, anyway. So what was the problem earlier? Did the getKey(#) routine simply not have a pause, so the key codes could turn out wrong or something?
Title: Re: Wait For Keys
Post by: calc84maniac on September 26, 2010, 04:47:40 pm
I think it didn't have a long enough pause for 15MHz mode.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 04:57:45 pm
I think in Wabbitemu, this also happened in 6 Mhz mode. One of player1537 program (his first contest entry I think) had that problem. Wabbitemu migth have handled key detection differently or something.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 04:59:29 pm
Could Wabbit be running too fast? It seems to be, even for 6 MHz now.
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 05:03:47 pm
Yeah I heard people saying it has been running a bit faster. However, in 6 MHz mode I didn't notice.
Title: Re: Wait For Keys
Post by: ztrumpet on September 26, 2010, 06:00:15 pm
In 6mhz mode on my calc (an 84+SE letter M) I need to add extra Pauses when doing loops like this:
While getKey(54)
End
(I must do While getKey(54):Pause 40:End.  Please note the 40 isn't exact, it's the first number that I tried, and it works, so... :))
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 06:00:50 pm
What happens if you don't? Does it not register the keypresses?
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 06:08:17 pm
I assume so. Isn't a smaller delay enough, though? Personally I would hate if the delay was too long because then the game starts slowing down, which is bad if you are using grayscale.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 06:09:12 pm
By the way, how does the Pause command work? Does it loop NOPs?
Title: Re: Wait For Keys
Post by: ztrumpet on September 26, 2010, 06:17:24 pm
What happens if you don't? Does it not register the keypresses?
Yeah, like if I'm holding down 2nd it'll go on sometimes. :(

I assume so. Isn't a smaller delay enough, though? Personally I would hate if the delay was too long because then the game starts slowing down, which is bad if you are using grayscale.
I use loops like this in areas like the main menu of Jump!.  Try holding down 2nd on the main menu. :)
Title: Re: Wait For Keys
Post by: Quigibo on September 26, 2010, 07:34:44 pm
The "Pause" command is a a loop of "djnz $+0" commands which is equivalent to about 850 nop's per pause number.

The original getkey(#) command waited 8 clock cycles which I think is enough for 6MHz.  getkey(0) was a separate routine which only waited 4 clock cycles.  I have now merged the 2 into a single command that waits 13 clock cycles which might be enough for 15MHz.  As a result, the getkey routine is a little larger, but each call to getkey(0) is 3 bytes less now, so the program size would actually go down if you were using it more than once.
Title: Re: Wait For Keys
Post by: Deep Toaster on September 26, 2010, 07:35:55 pm
What happens if you don't? Does it not register the keypresses?
Yeah, like if I'm holding down 2nd it'll go on sometimes. :(

I see. And I see why adding a pause would work: It wouldn't register the first keypress moment, but after the Pause, it starts registering.

The "Pause" command is a a loop of "djnz $+0" commands which is equivalent to about 850 nop's per pause number.

The original getkey(#) command waited 8 clock cycles which I think is enough for 6MHz.  getkey(0) was a separate routine which only waited 4 clock cycles.  I have now merged the 2 into a single command that waits 13 clock cycles which might be enough for 15MHz.  As a result, the getkey routine is a little larger, but each call to getkey(0) is 3 bytes less now, so the program size would actually go down if you were using it more than once.

Got it, and thanks. When do you think you'll update?
Title: Re: Wait For Keys
Post by: calcdude84se on September 26, 2010, 09:05:13 pm
Well, 8 clock cycles times 15MHz/6MHz is 20 clock cycles... 13 still might not be enough...
Good luck making it work!
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 09:25:12 pm
I wonder if 20 would start being a bit slow when a game in particular checks for about 20 keys every loop? It might be nice if in 6 MHz the amount of clock cycles was kept lower in 6 MHz mode. You would have to make the parser detect which getkey commands are placed after Full and which ones are placed after Normal or something like that, though. Disregard my comment if the slow down is not noticeable when Getkey() is used in large amounts in one loop, though.
Title: Re: Wait For Keys
Post by: calcdude84se on September 26, 2010, 09:28:32 pm
Well, the main problem is that you can't tell whether or not you're currently in Full mode, and doing so would take more than 8 (and possibly 20) clock cycles. Maybe a getKey(#)r like I suggested could alleviate that by at least giving programmers the option?
And it shouldn't be too noticeable unless speed is very important.
Title: Re: Wait For Keys
Post by: Quigibo on September 26, 2010, 09:56:04 pm
The speed is negligible.  If you checked for 80 key presses, it would be the same as an extra "Pause 1" which means each key would only add about 1/80th of a pause number.  The main reason I've been avoiding it is because it makes the code larger and having separate routines makes it even worse.  So at this point I think I'll just add an extra byte to give it a total of 20 clock cycles regardless of speed.  This should settle the matter.
Title: Re: Wait For Keys
Post by: calcdude84se on September 26, 2010, 09:58:12 pm
Sounds good; can't wait for a release! :D
Title: Re: Wait For Keys
Post by: DJ Omnimaga on September 26, 2010, 10:20:05 pm
Oh wow, disregard my comment, then. If the speed is this negligible, 20 clock cycles should be ok. Keep up the good work Quigibo :)