3

For the GBA, I am under the impression that there are two ways to detect a button event:

  • Enable IRQs and set up a handler for the button event

  • Get a button's state (via the input bitmap) during the vblank period

Which of these two techniques was typically used, and why? What factors would lead a game developer to choose one technique over the other, if neither one of them is "the one right way"?

Did this also apply to older Nintendo handhelds like the GB/GBC, and newer ones like the NDS?

8
  • 2
    Both, as it's up to each developer what fits the situation in his ha game. There is neither a law nor a programming inquisition enforcing it. You may want to ask for a specific game.
    – Raffzahn
    Feb 22 at 0:11
  • @Raffzahn I've updated my question to ask more generally what factors determine which technique would be used. As for specific games, let's say games like: Crazy Taxy: Catch a Ride, Pokemon Ruby/Sapphire/Emerald, The Legend of Zelda: A Link to the Past. Or might they all be different?
    – forest
    Feb 22 at 0:11
  • 2
    Personal preference, game structure, libraries, pick your favourite one. Checking at a certain point in frame code will be most easy for simple games, while an interrupt handler comes easy when building a/on a more sophisticated framework.
    – Raffzahn
    Feb 22 at 0:15
  • Could even be both. IRQs for things where you want to be sure you count every button press and checking the state during the vblank for things like controlling character motion on a world map where you just care about whether the button is held at the moment when it's time to increment the world clock. I know that if you run the PC game Evoland under a version of Wine where you have to switch its runtime (which I remember being AIR or EXE-exported Flash) to software rendering to get it to run, it'll chug and your character will "over-walk" proportional to how long you held the button.
    – ssokolow
    Feb 22 at 0:26
  • @ssokolow PC games handle it much differently than a console game (it's usually either always interrupts in the case of PS/2 keyboard, or kHz-level polling for a USB keyboard).
    – forest
    Feb 22 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.