experimental/forumfix.py

Download file

Release 2026-11-04-r2 · SHA256 9c5a6c0dd39599e90628a29effd3b2f37c97f80339f77376ef3ad38a5c8a9dc8 · Click a line number for a direct link.

1"""NHL94 forum fixes (2026-10-28): see forumfix.s and the notes. Byte-checked patches."""2ORIGIN = 0x2EF000345def install(data, assemble, patch):6    code = assemble('forumfix', ORIGIN)7    assert len(code) < 0x4008    patch(ORIGIN, b'\xFF' * len(code), code)9    jsr = lambda a: bytes.fromhex('4eb9') + a.to_bytes(4, 'big')10    nop = bytes.fromhex('4e71')11    # 1 goalie lock: passmode .findplayer skips goalies (position 0) but not players off the ice12    #   (position -1, e.g. in the penalty box): tst.w $34(a1) / beq.w .next -> ble.w .next13    patch(0xBD02, bytes.fromhex('6700'), bytes.fromhex('6f00'))14    # 2 runaway speed15    patch(0xAC12, bytes.fromhex('082b000000626700000474 09'.replace(' ', '')), jsr(ORIGIN) + nop * 3)16    # 3 penalty shot: no goal after the award whistle, no ghost puck17    patch(0xED96, bytes.fromhex('4278b7724278b774'), jsr(ORIGIN + 4) + nop)18    patch(0xEF92, bytes.fromhex('08ab00010062'), jsr(ORIGIN + 8))19    # 4 wingers and centres on offence react with Offensive Awareness ($6A), not Defensive ($6B)20    #   (asswingo / asscentero: move.b aidef(a3),temp1(a3))21    patch(0xD0DE, bytes.fromhex('176b006b0040'), bytes.fromhex('176b006a0040'))22    patch(0xD2D6, bytes.fromhex('176b006b0040'), bytes.fromhex('176b006a0040'))2324    # Cached plain-patched input predates the patch.py fixes: apply them here too.25    # Fallback pass scan must reject position -1, as the native scan does above.26    old_scan = bytes.fromhex('4a69003467000040082900020063')27    at = data.find(old_scan, 0x2FF180, 0x2FF200)28    assert at >= 0, 'unexpected cached goalie fallback scan'29    patch(at + 4, bytes.fromhex('6700'), bytes.fromhex('6f00'))30    patch(0xBF54, jsr(0x2FF140), jsr(ORIGIN + 12))31