CONTROLLER SETUP

From NeoGeo Development Wiki
Revision as of 11:01, 19 January 2016 by Freem (talk | contribs) (small changes)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

CONTROLLER_SETUP ($C004D4): sets up controllers

Warning: register contents aren't preserved! Used registers varies.

Detects controllers configuration and sets inputs status byte accordingly.

Range of supported devices and detection method varies depending on system type and System ROM revision.

Status bytes

Status byte is the first byte of the input register into BIOS RAM (ex. BIOS_P1STATUS ( $10FD94) for P1). It is used by SYSTEM_IO to correctly read devices.

Possible values are:

  • 0 - No connection (dealt as standard controller)
  • 1 - Standard controller
  • 2 - Expanded controller (4P mode)
  • 3 - Mahjong controller
  • 4 - Keyboard

MVS

MVS setup is very straightforward: if hard dip 3 is set, BIOS_P1STATUS is set to 3, else status byte is set to 0 for all players.

NEO•GEO / NEO•GEO CD

NEO•GEO controller setup is much more elaborate, looking for 6 different devices. (standard controller, mahjong, 4P adapter, keyboard, plus 2 unknown devices)

The bios writes various configurations on controller outputs, then checks back controller status (for example a standard controller returns button D pressed when OUT3 is set to 1). Checked button can be either D/C/Select/Start.

Resulting status bytes are stored into a preset table:

(neo-epo bios)
C16A44: 02 02 00 00, 00 02 00 00, 02 00 00 00, 00 00 00 00
C16A54: 00 00 00 00, 01 00 01 00, 00 01 00 01, 01 01 01 01
C16A64: 03 03 00 00, 00 03 00 00, 03 00 00 00, 00 00 00 00
C16A74: 01 01 03 03, 01 01 01 03, 01 01 03 01, 01 01 01 01
C16A84: 03 03 00 00, 00 03 00 00, 03 00 00 00, 00 00 00 00
C16A94: 04 04 00 00, 00 04 00 00, 04 00 00 00, 00 00 00 00

Software runs 6 consecutive checks. All of then are done, regardless if a previous device does match or not, however a status byte isn't overwritten if not 0.

This means 1st check has top priority, 6th has lowest.

Output status, checked button and resulting status bytes (P1-4) are:

outputs config (binary) button checked P1 & P2 match P2 match P1 match no match tested device
1st check 100 100 D 02 02 00 00 00 02 00 00 02 00 00 00 00 00 00 00 standard controller
2nd check 001 001, then 101 101 C 00 00 00 00 01 00 01 00 00 01 00 01 01 01 01 01 unknown device
3rd check 011 011, then 111 111 D 03 03 00 00 00 03 00 00 03 00 00 00 00 00 00 00 unknown device
4th check 110 110 D 01 01 03 03 01 01 01 03 01 01 03 01 01 01 01 01 early 4P adapter ?
5th check 100 100 SELECT 03 03 00 00 00 03 00 00 03 00 00 00 00 00 00 00 Mahjong controller
6th check 100 100 START 04 04 00 00 00 04 00 00 04 00 00 00 00 00 00 00 Keyboard
  • All status bytes are decreased between 4th & 5th step.
  • Keep in mind there's an inverter between outputs and controller ports, writing 101 in the output register actually outputs 010 on the port.