-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfix_one_thing.py
115 lines (90 loc) · 3.38 KB
/
fix_one_thing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from utils import TYPESET_ROM_PATH
from rominfo import file_location
#RED_PLANET_OFFSET = 0x7d882
#GOLD_DRAGON_OFFSET = 0x3b346 # should be the offset after "the Devil's minions, at least...", and point to the first 0d0a afterwards
with open(TYPESET_ROM_PATH, 'r+b') as f:
buffer = f.read()
"""
Chapter 2
"""
red_planet_offset = buffer.find(b'red\n planet." ')
red_planet_offset += 0x0f
f.seek(red_planet_offset, 0)
f.write(b' ')
distant_future_offset = buffer.find(b'\'In the distant future')
distant_future_offset -= 2
print distant_future_offset
f.seek(distant_future_offset, 0)
f.write(b' \n')
"""
Chapter 3
"""
# Ch3 Intimidate pronouns fix
hohoho_offset = buffer.find(b'"Hoh-hoh-hoh-hoh!"')
hohoho_offset += 0x16
f.seek(hohoho_offset, 0)
sail_string = b'\nYou spread out your sail to appear larger\x00'
stunned_string = b'\nIt was shocked and stunned\x00'
f.write(sail_string)
f.write(stunned_string)
# change pointers too
sail_pointer_offset = file_location['ST3.EXE'] + 0x440d
sail_pointer_string = b'\x2b\x39' # TODO: Definitely gotta change these.
stunned_pointer_offset = file_location['ST3.EXE'] + 0x4420
stunned_pointer_string = b'\x56\x39' # TODO: And this.
f.seek(sail_pointer_offset, 0)
f.write(sail_pointer_string)
f.seek(stunned_pointer_offset, 0)
f.write(stunned_pointer_string)
"""
Chapter 5
"""
# Fix mistakenly indented string
fur_offset = buffer.find(b'"Fur?')
fur_offset -= 3
f.seek(fur_offset, 0)
f.write(b'\x13\x0a\x00')
# ST5S3 Onslaught pronouns fix
st5s3_space_offset = file_location['ST5S3.EXE'] + 0x4d59
punches_offset = st5s3_space_offset
punches_string = b'\nAnd also nimbly rained punches upon it\x00'
f.seek(punches_offset, 0)
f.write(punches_string)
punches_pointer_offset = file_location['ST5S3.EXE'] + 0x2572
punches_pointer_string = b'\x79\x10'
f.seek(punches_pointer_offset, 0)
f.write(punches_pointer_string)
# Fix impatient Procompsognathus text in Ch4
delighted_offset = buffer.find(b'is delighted!')
delighted_offset += 14
f.seek(delighted_offset, 0)
f.write('\x13')
# Overrwrite extraneous newline
clockwise_offset = buffer.find(b'rotation." ')
clockwise_offset += 12 # yeah, decimal 12
f.seek(clockwise_offset, 0)
f.write(b' ')
# Replace an <END> 'line break' with a space, to make the next line indent properly.
#desolation_offset = buffer.find(b'beauty. The desolation')
#desolation_offset += 0x16
#f.seek(desolation_offset, 0)
#f.write(b'\x0a')
# Replace <WAIT><LN> with <LN><WAIT>.
atlantis_army_offset = buffer.find(b' Atlantis army..."')
atlantis_army_offset += 0x12
f.seek(atlantis_army_offset, 0)
f.write(b'\x0a\x13')
"""
SEND.DAT
"""
# SEND.DAT fixes
gold_dragon_offset = buffer.find(b'the Devil\'s minions')
gold_dragon_offset += 0x22
f.seek(gold_dragon_offset, 0)
f.write(b' ')
green_dragon_offset = buffer.find(b'might stumble upon it.')
green_dragon_offset += 0x16
f.seek(green_dragon_offset, 0)
f.write(b' \x0d\n')
print hex(red_planet_offset), hex(distant_future_offset), hex(gold_dragon_offset), hex(green_dragon_offset), hex(hohoho_offset)
# replace ("stumble upon it...0d0a20" with "stumble upon it...200d0a")