Jump to content

Photo

Detecting long-presses


2 replies to this topic

#1 nsn OFFLINE  

nsn

    Combat Commando

  • 2 posts

Posted Wed Feb 22, 2017 10:54 AM

Hi!

 

I need a second "gesture" in my game (to switch between different display modes), and I don't want players to have to reach for any of the h/w switches on the console - so I want to detect whenever the player presses the fire button for a significant duration (say 500ms?)

 

Are there any best practices to do this? Preferably w/o using a byte of ram for counting frames?

 

I'm using plain assembler, no bAtari basic

 

thanks!



#2 ZackAttack OFFLINE  

ZackAttack

    Moonsweeper

  • 491 posts
  • Location:Orlando, FL US

Posted Wed Feb 22, 2017 2:42 PM

I think you have to count frames. For 500ms it's only 5 bits though. Just increment the variable every frame. And with $e0 if button isn't pressed. If count exceeds threshold switch modes. You could make $20 the flag for displaying the other mode so you switch modes for free once it counts to 32 frames. Then you can and with $C0 regardless of the display mode and releasing the button switches back to the original mode.

#3 nsn OFFLINE  

nsn

    Combat Commando

  • Topic Starter
  • 2 posts

Posted Thu Feb 23, 2017 9:06 AM

OK, I'll just count frames then ;)

 

thanks for the quick answer!






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users