Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- from Build import Patch, braindead
- import struct, os.path
- b = bytes.fromhex
- UL = lambda v: struct.pack(">L", v & 0xFFFFFFFF)
- UH = lambda v: struct.pack(">H", v & 0xFFFF)
- AH = lambda v: struct.pack(">H", ((v >> 16) | bool(v & 0x8000)) & 0xFFFF)
- name = os.path.splitext(os.path.basename(__file__))[0]
- path = lambda *args: os.path.join(os.path.dirname(__file__), *args)
- # Would be kinda nice to write up filetables for these to automate regional patches.
- source = path("007 - GoldenEye (USA).n64")
- filename = path(f"{name}.n64")
- # .: Patches :.
- # Patch dependency fields left unused. Assume all listed are interdependent.
- patches = [
- Patch(name="Recycle Control Style Lock", ver = 1.0,
- desc = "Reuses 8002B558. This eliminates any problem with solo settings clobbering MP settings. Six flags per player remain unused.",
- patch =(# 01 -> 80040A84 Look Up/Down Reverse/Upright
- # 02 -> 80040AB4 Look Ahead Off/On
- # 7F0104A0: w/i reset MP options for selected scenario
- ('0', 0x44FD0, 8),
- # Dirty fixes to force lock value.
- ('d', 0x4551C, b("24080001")), # 7F0109EC
- ('d', 0x461E0, b("24180001")), # 7F0116B0
- # Initialize to 0.
- # 7F00B9E8: initialize menu 05: file select screen
- ('d', 0x40525, b("03")),
- ('d', 0x4052C, b("AC60B558")),
- ('d', 0x40531, b("62")),
- ('d', 0x40535, b("60")),
- ),
- ),
- Patch(name="menu 11 interface: control style", ver = 1.0,
- desc = "Menu interface. Two-controller styles are removed.",
- patch =(# 7F013698 0x481C8 loop per player
- ('d', 0x481A6, UH(0x63)),
- ('d', 0x481C8, b("824E0000 11C0000A 02202025 0C0030EB 24054000 1040004C 3C048006 A2400000 8C843720 240500C7 0C002382 00003025 02202025 2405FFFE 0C00312D 03C03025 26540020 868A0002 004A8024 2401FFFF 10410002 A6800002 50400001 A6810002 2A01FFFF 14200004 02202025 0C0030EB 24050202 10400004 82620003 244CFFFF 318C0003 A26C0003 1E000004 02202025 0C0030EB 24050101 10400004 82620003 24480001 31080003 A2680003 02202025 2405FFFE 0C00314A 03C03025 868A0000 004A8024 2401FFFF 10410002 A6800000 50400001 A6810000 02202025 0C0030EB 24050C0C 2A01FFFF 14200007 240CFFFF 30410404 14200004 30410808 1E000002 240C0001 10200006 3C018003 00310823 8022B55B 004C6021 318C0003 A02CB55B 02202025 0C0030EB 3405B000 10400006 3C048006 A25E0000 8C843720 240500C7 0C002382 00003025")),
- # Close the pocket. 0xFC unused.
- ('d', 0x4840C, b('82')),
- ('d', 0x48425, b('73')),
- ('d', 0x4842A, UH(-0x5A)),
- ('s', 0x4840C, 0x481C8 + 0x148, 0xA4),
- ),
- ),
- Patch(name="menu 11 constructor: control style", ver = 1.0,
- desc = "Menu constructor. Requires the two string IDs are both EVEN numbers! An OR wouldn't work otherwise.",
- patch =(# Executed in order written.
- ('d', 0x4857A, UH(0x79)),
- ('d', 0x485A8, b('0FC04F22')), # Splits setting flags into registers.
- ('d', 0x48628, b('2631')), # p->DL is reusing V0, kinda dodgy to begin with.
- ('d', 0x48678, b('AE2DFFF8')),
- ('d', 0x486AC, b('AE2FFFFC')),
- ('d', 0x486B0, b("3C188007 00160880 0301C021 83099740 0015C843 34049D1D 03332821 AFA50074 15200004 02203825 0FC04F2D 26460028 00403825 3C0E8007 00160880 01C17021 81CF97BB 3C048003 2646003E 8FA50074 000FC080 00982021 0FC04F2D 9484B4F0 00403825 3C048004 00962023 80840A87 2646004E 8FA50074 0FC04F2D 34849D2E 00403825 3C048004 00962023 80840AB7 2646005D 8FA50074 0FC04F2D 34849D30 8FA800CC 26D60001 16C8FF96 00408825")),
- ('s', 0x4886C, 0x486B0 + 0xB0, 0x3C),
- # Utilize the freed space for some subfunctions.
- # *) 7F013C88 0x487B8 copy MP look settings to player registers (0x2C)
- ('d', 0x487B8, b('3C018003 8C22B558 3C030101 34630101 00020842 00431024 00231824 3C018004 AC220A84 03E00008 AC230AB4')),
- # *) 7F013CB4 0x487E4 V0 = p->DL; print textID A0 centered at (A1, A2) (0xC4)
- ('d', 0x487E4, b('27BDFFC8 AFBF0034 AFA70044 AFA60040 0FC30776 AFA5003C 3C018004 8C2A0EB4 AFA20038 27A4002C 27A50030 00403025 8C270EB8 AFA00014 0FC2BA63 AFAA0010 8FA5003C 8FA2002C 8FA60040 8FA30030 00021043 00C23023 00031843 00A32823 AFA5002C 0C001107 AFA60030 0C00110B AFA2001C AFA20020 0FC2B366 8FA40044 3C018004 8C2D0EB8 8C2C0EB4 240B00FF AFAB0018 00402025 27A5002C 27A60030 8FA70038 AFA00024 AFA00028 AFAD0010 0FC025D8 AFAC0014 8FBF0034 03E00008 27BD0038')),
- ),
- ),
- Patch(name="Look Settings in MP", ver = 1.0,
- desc = "Applies look-ahead and upright/reverse in MP matches.",
- patch =(# w/i MP conditional in 7F0793EC.
- ('d', 0xADF48, b('AFA20010 3C038008 8C6EA0B0 0FC04F22 ADC20430 00000000 00000000 0FC29374 8FA40010')),
- ),
- ),
- Patch(name="Reg getter/setter", ver = 1.0,
- desc = "Reduces a couple functions to add player# support to the set/get functions.",
- patch =(## Leaving out the setter for now. It complicates the solo watch menu unnecessarily and it's okay for solo to clobber the settings.
- ## # 7F0A4D74 0xD98A4 (reduced; 0x34)
- ## ('d', 0xD98A4, b('AFBFFFFC 0C002E7E 27BDFFE8 28410002 14200004 00000000 0FC29370 00000000 28410004 8FBF0014 27BD0018 03E00008 38220001')),
- ## # 7F0A4DAC 0xD98DC partial: V0[player] = A0 (0x14)
- ## ('d', 0x486B0, b('3C038008 8C63A0B8 00431023 03E00008 A0440003')),
- ## ('d', 0xD9978, b('0BC2936B 2422')), # player look up/down setter
- ## ('d', 0xD99A8, b('0BC2936B 2422')), # player look-ahead setter
- # 7F0A4DD4 0xD9904 (reduced; 0x48)
- ('d', 0xD9904, b('8C63A0B0 44842000 3C198005 AC642A58 468021A0 2402000A AC642A5C E4662A60 8F3984D0 57200001 2402000E 00440019 240B0001 00004012 00084823 AC692A64 03E00008 AC6B2A68')),
- # 7F0A4E24 0xD9954 partial: V0 = V0[player] (0x14)
- ('d', 0xD9954, b('3C038008 8C63A0B8 00431023 03E00008 90420003')),
- ('d', 0xD996C, b('0BC29389 24')), # player look up/down getter
- ('d', 0xD999C, b('0BC29389 24')), # player look-ahead getter
- ## # 7F0A9ABC: A single manual read in solo watch menu page 2...
- ## ('d', 0xDE5EC, b('81CE0A87')),
- ## # 7F0AB9FC: a few more in solo watch menu page 3...
- ## ('d', 0xE04D4, b('8102000B')),
- ## ('d', 0xE052C, b('8102000B')),
- ## ('d', 0xE05A0, b('8102000B')),
- ),
- ),
- ]
- file_replacements = (
- # Filename f/ table, offset, data type, ..., bytes-like object or filename.
- ("LtitleE.rz", 0x8F5F20, 'bin', 'insert', 'LtitleZ.rz'),
- )
- # .: Run Me :.
- def main():
- braindead(name)
- input("Press Enter to quit.")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment