Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Yeong on March 18, 2011, 08:09:20 pm
-
Like, pressing [2nd], and then [ALPHA], and then [MODE] quickly, but not at the same time.
I can't think of an routine for it...
-
:0→K . No keys pressed yet
:Lbl LP . Loop until the three keys are pressed in order
:If getKey(54) . If 2ND is pressed
:→K . The first key's been pressed
:ElseIf getKey(48) . Otherwise, if ALPHA is pressed
:!If K-1 . If the first key's been pressed
:+2→K . Two keys have been pressed
:End . End the If
:ElseIf getKey(55) . Otherwise, if MODE is pressed
:!If K-2 . If the first two keys have already been pressed
:Goto LE . We're done
:End . End the If
:End . End the testing
:Goto LP . Go back to main loop
:Lbl LE . We're done!
-
!If getKey(1)
Goto END:End
Pause 50
!If getKey(2)
Goto END:End
Pause 50
...
Lbl END
Disp "EPIC FAILURE"
.CLEAR RAM
Asm(ABCDEF)
-
You could start a timer on [2nd], then checking said timer on [MODE] if you were quick enough.
(Uhh did I got ninja'd?)
-
:0→K
:Lbl LP
:If getKey(54)
:→K
:ElseIf getKey(48)
:!If K-1
:+2→K
:End
:ElseIf getKey(55)
:!If K-2
:Goto LE
:End
:End
:Goto LP
:Lbl LE
What does ->K itself do?
*yay. 500th post
-
:0→K
:Lbl LP
:If getKey(54)
:→K
:ElseIf getKey(48)
:!If K-1
:+2→K
:End
:ElseIf getKey(55)
:!If K-2
:Goto LE
:End
:End
:Goto LP
:Lbl LE
What does ->K itself do?
*yay. 500th post
Whatever was left in HL is stored to K. In this case, after If getKey(54), HL holds 1 if it's true. So you can just store that straight to K to save a couple of bytes.
After If getKey(48), it's the same, but you add 1 so you store a 2 to HL.
-
wait you could do that? :o
I just started to learn Axe.
-
wait you could do that? :o
I just started to learn Axe.
Yep, Axe is great for weird syntax :D If it's weird, chances are it's optimized.
Since you're new to Axe, though, guess I should do a more basic example... I edited my post with comments, anyway.
-
Even though im new to axe, i can see what binder's code do... O.O
-
It doesn't let you do anything else while waiting for the key, though, and you must hold down the keys long enough for it to work.
EDIT: Just realized something: My code actually does allow the user to press all three buttons at once. Here:
:0→K . No keys pressed yet
:Lbl LP . Loop until the three keys are pressed in order
:While getKey(54) . If 2ND is pressed, don't register any other keys
:→K . The first key's been pressed
:End . End this loop
:While getKey(48) . Otherwise, if ALPHA is pressed, still don't register other keys
:!If K-1 . If the first key's been pressed
:+2→K . Two keys have been pressed
:End . End the If
:End . End that loop
:While getKey(55) . Otherwise, if MODE is pressed (you get the drift)
:!If K-2 . If the first two keys have already been pressed
:Goto LE . We're done
:End . End the If
:End . End the final loop
:Goto LP . Go back to main loop
:Lbl LE . We're done!
Should work better. It pauses while you're holding down the keys, though.