From NerdConsole
Jump to navigationJump to search

As with nearly all game systems, joysticks are how users get input into NerdConsole. NerdConsole uses standard SNES controllers because they are easy to find and in my opinion, excellent. They have enough buttons to allow for flexibility when defining how your game uses them while not so many as to be complicated.

Regardless of which port is being used, the joysticks all work in the same way. A pattern of latching the button state and then reading the data 1-bit at a time. For additional information check out Register - Input.

When reading controllers, the buttons are always read in a specific order.

SNES Button Order

Order Button
1 B
2 Y
3 Select
4 Start
5 Up
6 Down
7 Left
8 Right
9 A
10 X
11 L
12 R

The pattern for reading joysticks is:

  1. Set the latch signal to 1 and then back to 0.
  2. Read the button state of the B button.
  3. Set the clock signal to 1 and then back to 0.
  4. Read the state of the next button.
  5. Return to 3 if not done.