0 Members and 2 Guests are viewing this topic.
Been struggling with this for a while now; the principle I'm looking for is simple and straightforward: react to the last button pressed, regardless of whatever else might be pressed or released.So if you press '1', it perorms 'Label1' once, even if you have 2-9 held down at the same time already, or release random other buttons that were being held down before. Push the button, perform thát routine once. Nóthing more, nothing less. I'm sure there must be a simple way to do this, but... I'm newby. If anyone has any tips on how to do this, it'd be greatly appreciated!Thanks alot in advance.
Repeat getKey(15)If getKey(34) and A=/=1 //getKey(34) is the one buttonsub(1)EndIf getKey(26) and A =/=1 //getKey(26) is the 2 buttonsub(2)End.Repeat If loop for getKeys# 18 (3), 35 (4), 27 (5), 19 (6), 36 (7), 28 (8), 20 (9), Then finish it with!If getKey and A=10->AEndEndReturn //Keeps the program from running the subroutines from after the Repeat loop is cancelledLbl 1blah //This should include a 1->A also, to keep from repeatingEndLbl 2blah //Same hereEnd.Write the rest of subroutines, make sure they have 1 ->A
It's in the assembly subforum, so axe code won't help him..I suggest you can keep something like a key table that keeps track of all keys currently pressed, and updates when a new one is pressed.
I guess you could compile axe, then just optimize it a lot... but that seems inefficient
tracePressed: push af set 0, c bit 0, b PUSH BC jr nz, traceIsHeld LD A, 58 LD (CheckYequ), A LD (CheckWindow), A LD (CheckZoom), A LD (CheckTrace), A LD (CheckGraph), A LD A, -58 ; LD (ButtonPressed), A ; CALL CheckYSprites ;you can ignore these in each loop, I just want this to be performed with the appropriate number stored in (ButtonPressed) jp graphDonetraceIsHeld: LD A, 58 ; LD (xpos), A ; CALL sprendcall ; also ignore this, it's just something for the rest of the script. LD A, (CheckTrace) CP 58 JP z, graphdone LD A, 58 LD (CheckTrace), A LD A, -58 LD (ButtonPressed), A CALL CheckYSprites jr graphDonezoomPressed: push af set 0, c bit 0, b PUSH BC jr nz, zoomIsHeld LD A, 44 LD (CheckYequ), A LD (CheckWindow), A LD (CheckZoom), A LD (CheckTrace), A LD (CheckGraph), A LD A, -44 LD (ButtonPressed), A CALL CheckYSprites jr graphDonezoomIsHeld: LD A, 44 LD (xpos), A CALL sprendcall LD A, (CheckZoom) CP 44 JR z, graphdone LD A, 44 LD (CheckZoom), A LD A, -44 LD (ButtonPressed), A CALL CheckYSprites jr graphDonegraphPressed: push af set 0, c bit 0, b PUSH BC jr nz, graphIsHeld LD A, 72 LD (CheckYequ), A LD (CheckWindow), A LD (CheckZoom), A LD (CheckTrace), A LD (CheckGraph), A LD A, -72 LD (ButtonPressed), A CALL CheckYSprites jr graphDonegraphIsHeld: CALL graphsprshow LD A, (CheckGraph) CP 72 JR z, graphdone LD A, 72 LD (CheckGraph), A LD A, -72 LD (ButtonPressed), A CALL CheckYSpritesgraphDone: pop bc pop af retwindowPressed: push af set 0, c bit 0, b PUSH BC jr nz, windowIsHeld LD A, 30 LD (CheckYequ), A LD (CheckWindow), A LD (CheckZoom), A LD (CheckTrace), A LD (CheckGraph), A LD A, -30 LD (ButtonPressed), A CALL CheckYSprites jr graphDonewindowIsHeld: LD A, 30 LD (xpos), A CALL sprendcall LD A, (CheckWindow) CP 30 JR z, graphdone LD A, 30 LD (CheckWindow), A LD A, -30 LD (ButtonPressed), A CALL CheckYSprites jr graphDoneYequPressed: push af set 0, c bit 0, b PUSH BC jr nz, YequIsHeld LD A, 16 LD (CheckYequ), A LD (CheckWindow), A LD (CheckZoom), A LD (CheckTrace), A LD (CheckGraph), A LD A, -16 LD (ButtonPressed), A CALL CheckYSprites jr graphDoneYequIsHeld: LD A, 16 LD (xpos), A CALL sprendcall LD A, (CheckYequ) CP 16 JR z, graphdone LD A, 16 LD (CheckYequ), A LD A, -16 LD (ButtonPressed), A CALL CheckYSprites jp graphDone