-
-
Save bbayles/7f3f415fecf506db54bce2dc88984f78 to your computer and use it in GitHub Desktop.
Extract button codes for Jet Moto 3 on PlayStation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from struct import unpack | |
| # 2 bytes per ASCII letter, located at 0x8008bd90 in memory. | |
| button_data = ( | |
| b"\x14\x00\x88\x00\x20\x00\x00\x40\x04\x80\x08\x80\x18\x00\x08\x20\x04\x20\x28" | |
| b"\x00\x48\x00\x00\x80\x44\x00\x08\x40\x24\x00\x04\x10\x84\x00\x00\x20\x80\x00" | |
| b"\x10\x00\x00\x10\x08\x10\x04\x40\x40\x00\x11\x00\x41\x00" | |
| ) | |
| unpacked_data = unpack(f"<{len(button_data) // 2}H", button_data) | |
| pattern_map = dict(zip("ABCDEFGHIJKLMNOPQRSTUVWXYZ", unpacked_data)) | |
| pattern_map["."] = 0x0100 | |
| # PlayStation byte pattern-to-button name mapping. | |
| button_map = { | |
| 0x0001: "L2", | |
| 0x0002: "R2", | |
| 0x0004: "L1", | |
| 0x0008: "R1", | |
| 0x0100: "Select", | |
| 0x0200: "L3", | |
| 0x0400: "R3", | |
| 0x0800: "Start", | |
| 0x0010: "Triangle", | |
| 0x0020: "Circle", | |
| 0x0040: "X", | |
| 0x0080: "Square", | |
| 0x1000: "Up", | |
| 0x2000: "Right", | |
| 0x4000: "Down", | |
| 0x8000: "Left", | |
| } | |
| # Code phrases, located at 0x80098d64 in memory. | |
| all_codes = [ | |
| "EVERYTHING", | |
| "ALLTRAC", | |
| "RACE", | |
| "STUNT", | |
| "SEASONS", | |
| "CAMTV", | |
| "CAMLOCK", | |
| "CAMROLL", | |
| "ALLCAM", | |
| "COP", | |
| "GRANNY", | |
| "INSANE.", | |
| "FLAP.", | |
| "FLOAT.", | |
| "ROCKET.", | |
| "HEAL.", | |
| "INFINIT.", | |
| "TURBO.", | |
| "CAMTV.", | |
| "CAMLOCK.", | |
| "CAMROLL.", | |
| "ALLCAM.", | |
| "AUTO.", | |
| ] | |
| def get_code_buttons(code_letters): | |
| code_combos = [] | |
| for letter in code_letters: | |
| letter_pattern = pattern_map[letter] | |
| letter_combo = [] | |
| for button_pattern, button_name in button_map.items(): | |
| if letter_pattern & button_pattern: | |
| letter_combo.append(button_name) | |
| code_combos.append("+".join(letter_combo)) | |
| return ", ".join(code_combos) | |
| # Translate each code phrases letters into binary patterns and then into button names. | |
| for code_letters in all_codes: | |
| code_buttons = get_code_buttons(code_letters) | |
| print(code_letters, code_buttons, sep="\t") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment