EarthBound/ASM/Controller Input Routines

From Data Crystal
< EarthBound
Revision as of 02:41, 24 January 2024 by Xkeeper (talk | contribs) (Xkeeper moved page EarthBound:ASM:Controller Input Routines to EarthBound/ASM/Controller Input Routines: normalize subpages and titles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a sub-page of EarthBound/ASM.

$C083B8-$C083C0: Clear controller playback/record

Clears all controller playback and record status bit flags stored in $7E007B.

$C083C1-$C083E2: Start controller record

Begins recording controller data to a table at the input pointer. See record table format. Initializes relevant memory including setting the record active bit flag in $7E007B.

Note: In an unmodified EarthBound ROM, this appears to only ever be called from a subroutine within the debug block.

Inputs

  • $0e..$11: Long pointer to start of record table

$C083E3-$C0841A: Start controller playback

If playback is not already active, begins overriding controller data per the table at the input pointer. See record table format. Initializes relevant memory including setting the playback active bit flag in $7E007B.

Inputs

  • $0e..$11: Long pointer to start of record table

$C0841B-$C08455: Read raw controller data (or playback)

Write controller data to $7E0077 and $7E0079.

If playback is not active (as indicated by the playback active bit flag in $7E007B), reads the actual controller data using SNES controller automatic read.

If playback is active, sets the data per the controller playback memory and updates the memory accordingly. See record table format. Clears the playback active bit flag on reaching the end of the record table.

Note: Subroutine expects to always be called with Data Bank set to #$00 and Data Page set to #$0000.

$C08456-$C08495: Record controller data

If the record active bit flag in $7E007B is set, records the last read controller data to controller record memory. See record table format.

Note: Subroutine expects to always be called with Data Bank set to #$00 and Data Page set to #$0000.

$C08496-$C08500: Read and analyze controller data

Waits for controller automatic read to complete by polling the SNES Standard Controller Enable flag. Reads raw controller data (or playback) using the subroutine at $C0841B. Records controller data using the subroutine at $C08456. Sets the new controller data bits not set in the last frame to $7E006D and $7E006F. Sets all controller data (masked to the bits expected to be relevant for a normal SNES controller) to $7E0065 and $7E0067.

If controller data is different from that at the last frame, sets $7E0069 and $7E006B to the new bits not set in the last frame. Otherwise, sets $7E0069 and $7E006B to #$0000 until the controller data has been stable for 15 frames, and then it repulses the set controller data bits ever 4 frames.

If $7e436c is zero, OR's the controller2 data from $7E0067, $7E006B, and $7E006F to the controller1 data in $7E0065, $7E0069, and $7E006D respectively.

If new controller1 data has been set in $7E006D, increments $7E0A34.

Note: Subroutine expects to always be called with Data Bank set to #$00 and Data Page set to #$0000.