Skip to content

Instantly share code, notes, and snippets.

@bbayles
Created December 1, 2024 04:09
Show Gist options
  • Select an option

  • Save bbayles/e7a2737e3319ac152ed496583333c84a to your computer and use it in GitHub Desktop.

Select an option

Save bbayles/e7a2737e3319ac152ed496583333c84a to your computer and use it in GitHub Desktop.
from itertools import permutations
# Words filtered from /usr/share/dict/words plus the code
# phrases here: https://hiddenpalace.org/Tony_Hawk%27s_Pro_Skater_2_(March_2000_demo)
WORDS = """\
C
CD
CDCXL
CL
CLUR
CLURCLUR
CR
CRCTR
CRCTRS
CRST
CRUD
CRULT
CRUST
CRUSTS
CRUX
CS
CSTUD
CU
CUD
CUDS
CULL
CULLS
CULT
CULTS
CUR
CURD
CURDS
CURL
CURLS
CURS
CURST
CURT
CUSS
CUT
CUTCUT
CUTS
CUUL
D
DD
DDD
DDDD
DDT
DDTDDT
DLR
DLRDLR
DR
DRUUL
DSTRUC
DU
DUCT
DUCTS
DUD
DUDS
DUDXS
DULL
DULLDULL
DULLS
DULUX
DUR
DUSCU
DUST
DUSTS
DUSTUR
L
LL
LLL
LLLL
LR
LS
LSTUD
LT
LTD
LU
LULL
LULLS
LULU
LUST
LUSTS
LUX
R
RCRD
RCRDRCRD
RD
RR
RRR
RRRR
RS
RSTUD
RU
RUL
RULS
RULUR
RUSS
RUST
RUSTS
RUT
RUTS
RUUL
RUULS
RX
S
SC
SCR
SCRSCR
SCRT
SCRTCRCTR
SCRX
SCTR
SCUD
SCUDS
SCULL
SCULLS
SCUTR
SCUTUR
SCX
SCXUD
SLSL
SLU
SLUR
SLURS
SLUSL
SLUT
SLUTS
SLUUU
SR
ST
STRUDL
STRUT
STRUTS
STU
STUD
STUDS
SUDS
SULUCT
SUX
T
TC
TCXS
TDCS
TL
TRUSS
TRUST
TRUSTRULS
TRUSTS
TS
TST
TULL
TURD
TURDS
TUST
TUSTS
TUSTUR
TUT
TUTU
TUTUS
TUTUXSX
TUX
TUXD
TXT
TXTUDU
U
UCD
UR
URDU
US
UU
UUU
UUUU
X
XCTTXLCDSTL
XLUX
XS
XSL
XST
XSTUD
XSX
XTC
XTCCULT
XUT
XUTXUT
XXX
XXXSTUD
XXXX
XXXXL
XXXXS
XXXXX""".splitlines()
button_map = {
"S": (0x03185332, 0x80FE4187),
"X": (0xB87610DB, 0xDE098401),
"C": (0xDEADBEEF, 0xFE3010F3),
"T": (0x31415926, 0x7720DE42),
"L": (0x93FE1682, 0x92551072),
"D": (0x776643D1, 0x0901D3E8),
"R": (0xAB432901, 0x88D3A109),
"U": (0x01234567, 0x34859F3A),
}
# The game cares about 32 bits for some codes and 64 for others
targets = {
(0x6DC02D1E, None): None,
(0x33523575, 0x34AB2931): None,
(0x209FB3AD, None): None,
(0x0E2B0DC3, None): None,
(0x0517F426, None): None,
(0x17B941B1, None): None,
(0x2B85A8DF, None): None,
(0x2AB86343, 0xE94E5FA1): None,
(0x317F1F9D, 0x553DC48B): None,
(0x31E3487B, None): None,
(0x522A8B6C, None): None,
(0x45A930EF, None): None,
(0x39BEDF78, 0xACAE70A1): None,
(0x46F27698, None): None,
(0x5DF28F1E, 0x20C49738): None,
(0x5B445BB0, None): None,
(0x5EE13E0D, None): None,
(0x6083C9B6, None): None,
(0xA9411EE9, None): None,
(0xC0A8F966, 0xDFA4B839): None,
(0xB130BFC4, 0x7CFF03F2): None,
(0xAB93B12C, None): None,
(0xC0998C91, None): None,
(0xDEBF473A, None): None,
(0xD7DDA9E0, 0x8F37160D): None,
(0xF4301A14, None): None,
(0xFB29F028, None): None,
(0x87AE8F70, None): None,
(0x763A0DAE, None): None,
(0x70153315, None): None,
(0x8112BF6A, 0x1A348CCC): None,
(0x9B70C632, None): None,
(0x943ED118, 0xDDBA0D98): None,
(0xA3E2DCE2, 0x7A6115CE): None,
(0xA8A606AD, 0x8786EF73): None,
}
def get_button_stream():
for r in range(1, 4 + 1):
for p in permutations(WORDS * 3, r):
yield "".join(p)
def main():
found = 0
seen = set()
for code_buttons in get_button_stream():
value_1 = 0x0
value_2 = 0x0
for button in code_buttons:
x, y = button_map[button]
value_1 = (((((value_1 ^ x) << 1) ^ ((value_1 ^ x) >> 0x1F))) * 0x209) & 0xFFFFFFFF
value_2 = (((((value_2 ^ y ^ value_1) >> 8) << 1) ^ (value_2 ^ y)) >> 0x1F) & 0xFFFFFFFF
for combined in [(value_1, None), (value_1, value_2)]:
if (combined in targets) and (targets[combined] is None):
targets[combined] = "".join(code_buttons)
print(
"".join(code_buttons),
format(combined[0], "08x"),
format(combined[1] or 0, "08x"),
)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment