EarthBound/ASM/Controller Input Routines: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
(Start creating page)
 
m (Xkeeper moved page EarthBound:ASM:Controller Input Routines to EarthBound/ASM/Controller Input Routines: normalize subpages and titles)
 
(4 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{subpage|game=EarthBound}}
{{subpage|game=EarthBound}}


==<tt>$C083B8-$C083C0</tt>: Clear joypad playback/record==
==<tt>$C083B8-$C083C0</tt>: Clear controller playback/record==
Clears all input playback and record status bit flags stored in [[EarthBound:Joypad input memory#$7E007B|<tt>$7E007B</tt>]].
Clears all controller playback and record status bit flags stored in [[EarthBound:Controller input memory#$7E007B|<tt>$7E007B</tt>]].


==<tt>$C083C1-$C083E2</tt>: Start joypad record==
==<tt>$C083C1-$C083E2</tt>: Start controller record==
Begins recording joypad data to a table at the input pointer. See [[EarthBound:Joypad input memory#Record table format|record table format]]. Initializes relevant [[EarthBound:Joypad input memory|memory]] including setting the record active bit flag in [[EarthBound:Joypad input memory#$7E007B|<tt>$7E007B</tt>]].
Begins recording controller data to a table at the input pointer. See [[EarthBound:Controller input memory#Record table format|record table format]]. Initializes relevant [[EarthBound:Controller input memory|memory]] including setting the record active bit flag in [[EarthBound:Controller input memory#$7E007B|<tt>$7E007B</tt>]].


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


===Inputs===
===Inputs===
* <tt>$0e..$11</tt>: Long pointer to start of record table
* <tt>$0e..$11</tt>: Long pointer to start of record table


==<tt>$C083E3-$C0841A</tt>: Start joypad playback==
==<tt>$C083E3-$C0841A</tt>: Start controller playback==
If playback is not already active, begins overriding joypad data per the table at the input pointer. See [[EarthBound:Joypad input memory#Record table format|record table format]]. Initializes relevant [[EarthBound:Joypad input memory|memory]] including setting the playback active bit flag in [[EarthBound:Joypad input memory#$7E007B|<tt>$7E007B</tt>]].
If playback is not already active, begins overriding controller data per the table at the input pointer. See [[EarthBound:Controller input memory#Record table format|record table format]]. Initializes relevant [[EarthBound:Controller input memory|memory]] including setting the playback active bit flag in [[EarthBound:Controller input memory#$7E007B|<tt>$7E007B</tt>]].


===Inputs===
===Inputs===
* <tt>$0e..$11</tt>: Long pointer to start of record table
* <tt>$0e..$11</tt>: Long pointer to start of record table


[[Category:EarthBound:ASM|Joypad Input Routines]]
==<tt>$C0841B-$C08455</tt>: Read raw controller data (or playback)<span class="anchor" id="$C0841B"></span>==
Write controller data to [[EarthBound:Controller input memory#$7E0077|<tt>$7E0077</tt>]] and [[EarthBound:Controller input memory#$7E0079|<tt>$7E0079</tt>]].
 
If playback is not active (as indicated by the playback active bit flag in [[EarthBound:Controller input memory#$7E007B|<tt>$7E007B</tt>]]), reads the actual controller data using [https://snes.nesdev.org/wiki/Controller_reading SNES controller automatic read].
 
If playback is active, sets the data per the controller playback [[EarthBound:Controller input memory|memory]] and updates the memory accordingly. See [[EarthBound:Controller input memory#Record table format|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.''
 
==<tt>$C08456-$C08495</tt>: Record controller data<span class="anchor" id="$C08456"></span>==
If the record active bit flag in [[EarthBound:Controller input memory#$7E007B|<tt>$7E007B</tt>]] is set, records the last read controller data to controller record [[EarthBound:Controller input memory|memory]]. See [[EarthBound:Controller input memory#Record table format|record table format]].
 
''Note: Subroutine expects to always be called with Data Bank set to #$00 and Data Page set to #$0000.''
 
==<tt>$C08496-$C08500</tt>: Read and analyze controller data==
Waits for controller automatic read to complete by polling the [https://snes.nesdev.org/wiki/MMIO_registers#HVBJOY SNES Standard Controller Enable flag]. Reads raw controller data (or playback) using the subroutine at [[#$C0841B|$C0841B]]. Records controller data using the subroutine at [[#$C08456|$C08456]]. Sets the new controller data bits not set in the last frame to [[EarthBound:Controller input memory#$7E006D|<tt>$7E006D</tt>]] and [[EarthBound:Controller input memory#$7E006F|<tt>$7E006F</tt>]]. Sets all controller data (masked to the bits expected to be relevant for a normal SNES controller) to [[EarthBound:Controller input memory#$7E0065|<tt>$7E0065</tt>]] and [[EarthBound:Controller input memory#$7E0067|<tt>$7E0067</tt>]].
 
If controller data is different from that at the last frame, sets [[EarthBound:Controller input memory#$7E0069|<tt>$7E0069</tt>]] and [[EarthBound:Controller input memory#$7E006B|<tt>$7E006B</tt>]] to the new bits not set in the last frame. Otherwise, sets <tt>$7E0069</tt> and <tt>$7E006B</tt> to <tt>#$0000</tt> until the controller data has been stable for 15 frames, and then it repulses the set controller data bits ever 4 frames.
 
If <tt>$7e436c</tt> is zero, OR's the controller2 data from [[EarthBound:Controller input memory#$7E0067|<tt>$7E0067</tt>]], [[EarthBound:Controller input memory#$7E006B|<tt>$7E006B</tt>]], and [[EarthBound:Controller input memory#$7E006F|<tt>$7E006F</tt>]] to the controller1 data in [[EarthBound:Controller input memory#$7E0065|<tt>$7E0065</tt>]], [[EarthBound:Controller input memory#$7E0069|<tt>$7E0069</tt>]], and [[EarthBound:Controller input memory#$7E006D|<tt>$7E006D</tt>]] respectively.
 
If new controller1 data has been set in [[EarthBound:Controller input memory#$7E006D|<tt>$7E006D</tt>]], increments <tt>$7E0A34</tt>.
 
''Note: Subroutine expects to always be called with Data Bank set to #$00 and Data Page set to #$0000.''
 
[[Category:EarthBound:ASM|Controller Input Routines]]
{{Internal Data|game=EarthBound}}
{{Internal Data|game=EarthBound}}
{{stub}}

Latest revision as of 02:41, 24 January 2024

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.