Skip to content

Commit bc486a6

Browse files
zig-forJouramie
authored andcommitted
LADX: Text shuffle (ArchipelagoMW#2051)
1 parent 09547b2 commit bc486a6

File tree

5 files changed

+63
-32
lines changed

5 files changed

+63
-32
lines changed

worlds/ladx/LADXR/generator.py

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib.machinery
44
import os
55
import pkgutil
6+
from collections import defaultdict
67

78
from .romTables import ROMWithTables
89
from . import assembler
@@ -322,6 +323,22 @@ def gen_hint():
322323
if args.doubletrouble:
323324
patches.enemies.doubleTrouble(rom)
324325

326+
if ap_settings["text_shuffle"]:
327+
buckets = defaultdict(list)
328+
# For each ROM bank, shuffle text within the bank
329+
for n, data in enumerate(rom.texts._PointerTable__data):
330+
# Don't muck up which text boxes are questions and which are statements
331+
if type(data) != int and data and data != b'\xFF':
332+
buckets[(rom.texts._PointerTable__banks[n], data[len(data) - 1] == 0xfe)].append((n, data))
333+
for bucket in buckets.values():
334+
# For each bucket, make a copy and shuffle
335+
shuffled = bucket.copy()
336+
rnd.shuffle(shuffled)
337+
# Then put new text in
338+
for bucket_idx, (orig_idx, data) in enumerate(bucket):
339+
rom.texts[shuffled[bucket_idx][0]] = data
340+
341+
325342
if ap_settings["trendy_game"] != TrendyGame.option_normal:
326343

327344
# TODO: if 0 or 4, 5, remove inaccurate conveyor tiles

worlds/ladx/LADXR/patches/owl.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ def removeOwlEvents(rom):
1111
re.removeEntities(0x41)
1212
re.store(rom)
1313
# Clear texts used by the owl. Potentially reused somewhere o else.
14-
rom.texts[0x0D9] = b'\xff' # used by boomerang
1514
# 1 Used by empty chest (master stalfos message)
1615
# 8 unused (0x0C0-0x0C7)
1716
# 1 used by bowwow in chest
1817
# 1 used by item for other player message
1918
# 2 used by arrow chest messages
2019
# 2 used by tunics
21-
for idx in range(0x0BE, 0x0CE):
22-
rom.texts[idx] = b'\xff'
20+
21+
# Undoing this, we use it for text shuffle now
22+
#rom.texts[0x0D9] = b'\xff' # used by boomerang
23+
# for idx in range(0x0BE, 0x0CE):
24+
# rom.texts[idx] = b'\xff'
2325

2426

2527
# Patch the owl entity into a ghost to allow refill of powder/bombs/arrows

worlds/ladx/LADXR/patches/phone.py

+29-28
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,35 @@
22

33

44
def patchPhone(rom):
5-
rom.texts[0x141] = b""
6-
rom.texts[0x142] = b""
7-
rom.texts[0x143] = b""
8-
rom.texts[0x144] = b""
9-
rom.texts[0x145] = b""
10-
rom.texts[0x146] = b""
11-
rom.texts[0x147] = b""
12-
rom.texts[0x148] = b""
13-
rom.texts[0x149] = b""
14-
rom.texts[0x14A] = b""
15-
rom.texts[0x14B] = b""
16-
rom.texts[0x14C] = b""
17-
rom.texts[0x14D] = b""
18-
rom.texts[0x14E] = b""
19-
rom.texts[0x14F] = b""
20-
rom.texts[0x16E] = b""
21-
rom.texts[0x1FD] = b""
22-
rom.texts[0x228] = b""
23-
rom.texts[0x229] = b""
24-
rom.texts[0x22A] = b""
25-
rom.texts[0x240] = b""
26-
rom.texts[0x241] = b""
27-
rom.texts[0x242] = b""
28-
rom.texts[0x243] = b""
29-
rom.texts[0x244] = b""
30-
rom.texts[0x245] = b""
31-
rom.texts[0x247] = b""
32-
rom.texts[0x248] = b""
5+
# reenabled for text shuffle
6+
# rom.texts[0x141] = b""
7+
# rom.texts[0x142] = b""
8+
# rom.texts[0x143] = b""
9+
# rom.texts[0x144] = b""
10+
# rom.texts[0x145] = b""
11+
# rom.texts[0x146] = b""
12+
# rom.texts[0x147] = b""
13+
# rom.texts[0x148] = b""
14+
# rom.texts[0x149] = b""
15+
# rom.texts[0x14A] = b""
16+
# rom.texts[0x14B] = b""
17+
# rom.texts[0x14C] = b""
18+
# rom.texts[0x14D] = b""
19+
# rom.texts[0x14E] = b""
20+
# rom.texts[0x14F] = b""
21+
# rom.texts[0x16E] = b""
22+
# rom.texts[0x1FD] = b""
23+
# rom.texts[0x228] = b""
24+
# rom.texts[0x229] = b""
25+
# rom.texts[0x22A] = b""
26+
# rom.texts[0x240] = b""
27+
# rom.texts[0x241] = b""
28+
# rom.texts[0x242] = b""
29+
# rom.texts[0x243] = b""
30+
# rom.texts[0x244] = b""
31+
# rom.texts[0x245] = b""
32+
# rom.texts[0x247] = b""
33+
# rom.texts[0x248] = b""
3334
rom.patch(0x06, 0x2A8F, 0x2BBC, ASM("""
3435
; We use $DB6D to store which tunics we have. This is normally the Dungeon9 instrument, which does not exist.
3536
ld a, [$DC0F]

worlds/ladx/LADXR/pointerTable.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ def store(self, rom):
116116
rom.banks[ptr_bank][ptr_addr] = pointer & 0xFF
117117
rom.banks[ptr_bank][ptr_addr + 1] = (pointer >> 8) | 0x40
118118

119-
for n, s in enumerate(self.__data):
119+
data = list(enumerate(self.__data))
120+
data.sort(key=lambda t: type(t[1]) == int or -len(t[1]))
121+
122+
for n, s in data:
120123
if isinstance(s, int):
121124
pointer = s
122125
else:

worlds/ladx/Options.py

+8
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ class TradeQuest(DefaultOffToggle, LADXROption):
4343
display_name = "Trade Quest"
4444
ladxr_name = "tradequest"
4545

46+
class TextShuffle(DefaultOffToggle):
47+
"""
48+
[On] Shuffles all the text in the game
49+
[Off] (default) doesn't shuffle them.
50+
"""
51+
4652
class Rooster(DefaultOnToggle, LADXROption):
4753
"""
4854
[On] Adds the rooster to the item pool.
@@ -431,6 +437,7 @@ class AdditionalWarpPoints(DefaultOffToggle):
431437
'trendy_game': TrendyGame,
432438
'gfxmod': GfxMod,
433439
'palette': Palette,
440+
'text_shuffle': TextShuffle,
434441
'shuffle_nightmare_keys': ShuffleNightmareKeys,
435442
'shuffle_small_keys': ShuffleSmallKeys,
436443
'shuffle_maps': ShuffleMaps,
@@ -439,4 +446,5 @@ class AdditionalWarpPoints(DefaultOffToggle):
439446
'music_change_condition': MusicChangeCondition,
440447
'nag_messages': NagMessages,
441448
'ap_title_screen': APTitleScreen,
449+
442450
}

0 commit comments

Comments
 (0)