Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tony Hawk's Motion (USA) missing motion pak #74

Open
benderscruffy opened this issue Jun 20, 2017 · 1 comment · May be fixed by #2183
Open

Tony Hawk's Motion (USA) missing motion pak #74

benderscruffy opened this issue Jun 20, 2017 · 1 comment · May be fixed by #2183
Labels
addon missing emulation of a hardware add-on

Comments

@benderscruffy
Copy link

cannot play the game as it is mising the motion pak
tony hawk s motion usa -0

@Arisotura Arisotura added the addon missing emulation of a hardware add-on label Dec 21, 2018
@xperia64
Copy link
Contributor

The Motion Pack used in this game contains a Kionix 3-axis accelerometer, and an ATTiny13 MCU.

For the following, I will be calling the VDD35 pin of the GBA slot Pin 1, and GND Pin 32:

  • Pins 14 and 15 (AD8 and AD9) are pulled to ground on this pack, such that a 16-bit read of GBA ROM space should return 0xFCFF
    • This should make the game recognize the Pack up until the menus
  • Pins 22 and 23 (A16 and A17) output 2-bit packets of data from the ATTiny13 to the NDS
  • Pin 30 (/CS2) is used to clock the state of the ATTiny13
    • When the NDS reads from GBA SRAM space, the lower 2 bits of the data read are the 2-bit packet sent by the ATTiny13
    • When the SRAM space read completes and /CS2 is deasserted/pulsed, the ATTiny13 advances state and queues up the next 2 bits
      • I'm not quite clear under what conditions /CS2 is asserted/deasserted by the DS, but doing multiple reads sequential reads in my homebrew did seem to clock the /CS2 line as needed

The protocol used by the ATTiny13 is a simple 17-state loop, where each state is responsible for outputting 2 bits:

  • 0b00
  • 0xFF over 4 states (big endian, upper 2 bits first; so (0xFF>>6)&3, then (0xFF>>4)&3, etc)
  • 8-bit x-axis acceleration over 4 states
  • 8-bit y-axis acceleration over 4 states
  • 8-bit z-axis acceleration over 4 states

To convert an input acceleration in g's to the 8-bit units of this pack, use the following equation:
output_accel = min(0xFE, max(0, int((input_accel * 0.660V/g+1.65V) * 256 / 3.3V)))
These values were obtained from the datasheets of the chips.

The output on each accelerometer axis must be clamped between 0x0 and 0xFE inclusive, as 0xFF is likely reserved for synchronization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon missing emulation of a hardware add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants