# relocations.txt - game data moved to a bigger home (applied by relocate.py; gen.py applies it too).
#
#   move <from> <to> <new address>   every address in [from, to) in the generated code moves to
#                                    new address + (address - from); the whole range keeps its layout
#   imm <instruction> <old> <new>    a constant in one instruction (a count or a limit)
#
# Addresses are the running game's (0x01xxxxxx). Moved data goes above 64MB, in memory the
# original game never had (GUEST_MEM_SIZE in rt/rt.h).

# League tables: 80 of 0x67B bytes at 0x1152698. A game with more than three leagues can need
# more (each league some, the European competitions 36); "alloctabs 1" ends the game when they
# run out. Moved to 0x4000000 with room for 127 - the most a table number can be, as the game
# keeps it in a signed byte. (Two references read the bytes just before the first table: the
# end of "table -1", used with numbers from 1.) Saved games keep the first 80 where they were;
# the rest go on the end of the file (rt/overrides.c, hook_save_more_tables).
move 0x01152696 0x01172d08 0x04000000
# the table allocator (0x69e90) looks no further than table 79
imm 0x01069ea9 0x4f 0x7e
imm 0x01069ed9 0x4f 0x7e

# The competition calendar: one byte per day (32), month (13) and competition - which days each
# competition has taken - at 0x1562c60, for 50 competitions: day * 0x28a + month * 0x32 + number.
# The leagues each have several competitions (divisions, cups) and their numbers follow the leagues
# chosen; with six or more big leagues they pass 49, and a 50th's entries fall on the next month's
# competition 0 - its round dates never get set and the fixture search for its first round runs
# for ever (the Charity Shield news on the first day, again and again). Now 128 competitions
# (0x80 a month, 0x680 a day: 0xd000 bytes) at 0x4040000; the reads at 0x1562c5d take the dword
# ending at a byte. Saves keep the 50-competition copy where it was, and the whole calendar goes on
# the end of the file (rt/overrides.c, calendar_pack and hook_save_calendar).
move 0x01562c5d 0x01567da0 0x0403fffd
imm 0x01035682 0x28a 0x680
imm 0x0103568f 0x32 0x80
imm 0x010357e4 0x28a 0x680
imm 0x010357f1 0x32 0x80
imm 0x01035baf 0x28a 0x680
imm 0x01035bc6 0x32 0x80
imm 0x01035c43 0x28a 0x680
imm 0x01035c50 0x32 0x80
imm 0x0104161c 0x28a 0x680
imm 0x0104162c 0x32 0x80
imm 0x010416ae 0x28a 0x680
imm 0x010416be 0x32 0x80
imm 0x0104260d 0x28a 0x680
imm 0x0104261a 0x32 0x80
imm 0x010ab33a 0x28a 0x680
imm 0x010ab347 0x32 0x80
imm 0x010abdbb 0x28a 0x680
imm 0x010abdc8 0x32 0x80
imm 0x010adf14 0x28a 0x680
imm 0x010adf21 0x32 0x80
imm 0x010b12c8 0x28a 0x680
imm 0x010b12d5 0x32 0x80
imm 0x010b1ceb 0x28a 0x680
imm 0x010b1cf8 0x32 0x80
imm 0x010b3938 0x28a 0x680
imm 0x010b3945 0x32 0x80
imm 0x010b6062 0x28a 0x680
imm 0x010b606f 0x32 0x80
imm 0x010b6869 0x28a 0x680
imm 0x010b6876 0x32 0x80
imm 0x010b8852 0x28a 0x680
imm 0x010b885f 0x32 0x80
imm 0x010b92ba 0x28a 0x680
imm 0x010b92c7 0x32 0x80
# cleared for a new game (0x3ff2c: memset of the whole calendar)
imm 0x0103ff53 0x5140 0xd000

# Competitions: 50 records of 0x7D4 bytes at 0x1172d08 - the leagues' divisions and cups, the
# European and international competitions. Each league chosen adds several, and with six or more
# big leagues there are more than 50; the 51st onwards then share memory with the work area that
# follows (0x118b470: the league fixture template, rebuilt for each league), so their round dates
# are wiped and the first-round fixture search never ends. Moved to 0x4070000 with room for 128 -
# a competition's number is a signed byte too. Saves write them one by one, as many as there are.
move 0x01172d08 0x0118b470 0x04070000

# Fixtures: 300 date blocks of 0x695 bytes at 0x197f6a4 - up to 120 fixtures of 14 bytes, then the
# date (0x690-0x692) and how many fixtures there are (word at 0x693). Six or more leagues can have
# more than 120 matches on one Saturday ("addfix 2" ended the game); all nine need more than 127.
# Now 250 a date: blocks of 0xdb1 with the footer at 0xdac, at 0x4100000 (0x100b6c bytes). (The 16 bytes past 0x19fad3f belong to the next table, which starts inside
# the last block's footer; it stays where it is.) Saves keep the 120-a-date copy where it was and
# the whole lot goes on the end of the file (rt/overrides.c, fixtures_pack and hook_save_calendar).
blocks 0x0197f69c 0x019fad3f 0x0197f6a4 0x690 0xdac 0x04100000
# the instructions that go from one date block to another (day * 0x695)
imm 0x0103cfa5 0x695 0xdb1
imm 0x0103d118 0x695 0xdb1
imm 0x0103e0c1 0x695 0xdb1
imm 0x0103e124 0x695 0xdb1
imm 0x0103e349 0x695 0xdb1
imm 0x0103e854 0x695 0xdb1
imm 0x0103eb45 0x695 0xdb1
imm 0x0103f162 0x695 0xdb1
imm 0x0103f311 0x695 0xdb1
imm 0x0103f7a1 0x695 0xdb1
imm 0x0103f7e1 0x695 0xdb1
imm 0x0103f9a9 0x695 0xdb1
imm 0x0103fa84 0x695 0xdb1
imm 0x0103ffe5 0x695 0xdb1
imm 0x0104004f 0x695 0xdb1
imm 0x01040133 0x695 0xdb1
imm 0x01040a50 0x695 0xdb1
imm 0x01040ba3 0x695 0xdb1
imm 0x01040c16 0x695 0xdb1
imm 0x01040caf 0x695 0xdb1
imm 0x01040d29 0x695 0xdb1
imm 0x01040d82 0x695 0xdb1
imm 0x01040db2 0x695 0xdb1
imm 0x01040e01 0x695 0xdb1
imm 0x01040e33 0x695 0xdb1
imm 0x01040e7d 0x695 0xdb1
imm 0x01040ed1 0x695 0xdb1
imm 0x01040f41 0x695 0xdb1
imm 0x01040f89 0x695 0xdb1
imm 0x01041153 0x695 0xdb1
imm 0x0104119c 0x695 0xdb1
imm 0x0104187d 0x695 0xdb1
imm 0x0104192d 0x695 0xdb1
imm 0x01041b6f 0x695 0xdb1
imm 0x01042148 0x695 0xdb1
imm 0x010421c8 0x695 0xdb1
imm 0x0104224a 0x695 0xdb1
imm 0x01042300 0x695 0xdb1
imm 0x01042361 0x695 0xdb1
imm 0x010423c4 0x695 0xdb1
imm 0x010425c0 0x695 0xdb1
imm 0x010427b0 0x695 0xdb1
imm 0x01042ce4 0x695 0xdb1
imm 0x0104394d 0x695 0xdb1
imm 0x0104398a 0x695 0xdb1
imm 0x010441eb 0x695 0xdb1
imm 0x010443b5 0x695 0xdb1
imm 0x01044487 0x695 0xdb1
imm 0x01044524 0x695 0xdb1
imm 0x0104455e 0x695 0xdb1
imm 0x0104d89a 0x695 0xdb1
imm 0x0104db4f 0x695 0xdb1
imm 0x010532fc 0x695 0xdb1
imm 0x0105335f 0x695 0xdb1
imm 0x0105339f 0x695 0xdb1
imm 0x010534d9 0x695 0xdb1
imm 0x01053603 0x695 0xdb1
imm 0x01053882 0x695 0xdb1
imm 0x01053e84 0x695 0xdb1
imm 0x010540a1 0x695 0xdb1
imm 0x0106d17a 0x695 0xdb1
imm 0x010762cc 0x695 0xdb1
imm 0x0107858f 0x695 0xdb1
imm 0x01078652 0x695 0xdb1
imm 0x0107873d 0x695 0xdb1
imm 0x010787e1 0x695 0xdb1
imm 0x01099328 0x695 0xdb1
imm 0x010ae388 0x695 0xdb1
imm 0x010ae407 0x695 0xdb1
imm 0x010ae47e 0x695 0xdb1
imm 0x010ae503 0x695 0xdb1
# "addfix 2": a date may have fixtures 0..119, now 0..249
imm 0x0104005f 0x77 0xf9
# cleared for a new game (0x3ff2c)
imm 0x0103ff42 0x7b69c 0x100b6c

# The clubs' byte for each competition: 50 of them in each club record (+0x9E, club * 0x5BA from
# 0x1585268). More than 50 competitions (six or more big leagues) ran into the club's next fields
# (+0xD0...) - all nine crashed in the August of their first season (a divide error at 0x6a299).
# Now a club-sized block of its own for each club at 0x4600000 (club * 0x5BA + competition), with
# room for 128. Every instruction that indexes it by competition moves there: the byte ones at
# +0x9E, and the four that read it as a dword from +0x9B (the byte at +0x9B itself is another field
# and stays). Saves keep the first 50 in the club records as well, and the whole lot goes on the
# end of TMDATA (rt/overrides.c, hook_save_club_comps).
imm 0x0102513f 0x1585306 0x4600000
imm 0x0102528f 0x1585306 0x4600000
imm 0x01033ad3 0x1585306 0x4600000
imm 0x01033af2 0x1585306 0x4600000
imm 0x01033b0b 0x1585306 0x4600000
imm 0x01052e7b 0x1585306 0x4600000
imm 0x0106bd6d 0x1585306 0x4600000
imm 0x0106bffb 0x1585306 0x4600000
imm 0x01099d4d 0x1585306 0x4600000
imm 0x01099ee6 0x1585306 0x4600000
imm 0x01099f82 0x1585306 0x4600000
imm 0x0109a039 0x1585306 0x4600000
imm 0x0109a0cf 0x1585306 0x4600000
imm 0x0109a186 0x1585306 0x4600000
imm 0x0109a21c 0x1585306 0x4600000
imm 0x0109a2d5 0x1585306 0x4600000
imm 0x0109a36b 0x1585306 0x4600000
imm 0x0109a422 0x1585306 0x4600000
imm 0x0109a4b8 0x1585306 0x4600000
imm 0x0109a56f 0x1585306 0x4600000
imm 0x0109a604 0x1585306 0x4600000
imm 0x0109a6be 0x1585306 0x4600000
imm 0x0109a754 0x1585306 0x4600000
imm 0x0109a825 0x1585306 0x4600000
imm 0x0109a8e9 0x1585306 0x4600000
imm 0x0109a9a1 0x1585306 0x4600000
imm 0x0109aa37 0x1585306 0x4600000
imm 0x0109ab1d 0x1585306 0x4600000
imm 0x0109abf7 0x1585306 0x4600000
imm 0x0109ace8 0x1585306 0x4600000
imm 0x0109ada6 0x1585306 0x4600000
imm 0x0109adac 0x1585306 0x4600000
imm 0x0109da2b 0x1585306 0x4600000
imm 0x0109e17c 0x1585306 0x4600000
imm 0x0109e346 0x1585306 0x4600000
imm 0x0109e3ce 0x1585306 0x4600000
imm 0x0109e3d4 0x1585306 0x4600000
imm 0x01052e49 0x1585303 0x45ffffd
imm 0x0106a204 0x1585303 0x45ffffd
imm 0x0106a275 0x1585303 0x45ffffd
imm 0x0108c8bc 0x1585303 0x45ffffd

# Players: 10000 records of 0x168 at 0x11f3de0 (they end where the calendar began), and the byte map of
# used ids that genfictplyr scans, move above the 80MB of the rest, with room for 16000 (0x3e80).
# The map is 0x270e bytes up to the next variable; 16000 bytes here.
move 0x011f3de0 0x01562c5d 0x05000000
move 0x011ea0b8 0x011ec7c6 0x05600000
imm 0x010665b8 0x270f 0x3e7f       # genfictplyr: the last id it may use
imm 0x0103a57d 0x2710 0x3e80       # load_pldata 2: the table is full
imm 0x0105583d 0x2710 0x3e80       # a player id is in range
imm 0x0103c0eb 0x270f 0x3e7f       # creat_plhist: one empty history record per possible id
# Lists with one entry per player, sized for 10000 in the original:
# a search list of (id word, double) at 0x11d0820, filled by a loop over every player (now at 0x5610000)
move 0x011d081e 0x011e8ebe 0x0560fffe
# three lists [3][10000] of 4 bytes at 0x1567da0 (players grouped by status), now [3][16000]
move 0x01567da0 0x01585260 0x05640000
imm 0x01047175 0x9c40 0xfa00
imm 0x01047cf7 0x9c40 0xfa00
imm 0x01047d6a 0x9c40 0xfa00
# Match ids: each match played in a season gets one (14 bits in its fixture) and a record of 0x887
# bytes in mchfax; 7000 a season in the original, and nine leagues play about 8600 league games alone
imm 0x01053e53 0x1b58 0x3e80       # playfix 1: no id left
imm 0x0103bdd3 0x1b57 0x3e7f       # the empty mchfax file has a record for every id
