Skip to content

Commit b44c152

Browse files
authored
Merge branch '2dos:dev' into dev
2 parents 9ef7de2 + 578d1cb commit b44c152

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1719
-1228
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[bumpversion]
22
commit = True
33
tag = False
4-
current_version = 4.7.4
4+
current_version = 4.8.0
55

66
[bumpversion:file:version.py]
77
search = version = "{current_version}"

base-hack/Build/adjust_exits.py

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import zlib
55
from typing import BinaryIO
66

7-
from BuildEnums import TableNames
7+
from BuildEnums import TableNames, Maps
88
from BuildLib import intf_to_float, main_pointer_table_offset
99

1010
new_caves_portal_coords = [120.997, 50, 1182.974]
@@ -193,9 +193,12 @@ def adjustExits(fh):
193193
coords.append(int(intf_to_float(int.from_bytes(fg.read(4), "big"))))
194194
coords[1] += 5
195195
exit_coords.append(coords.copy())
196-
if map_index == 0x22:
196+
if map_index == Maps.Isles:
197197
# Isles
198198
exit_coords.append([2524, 1724, 3841]) # Top of Krem Isles
199+
elif map_index == Maps.Galleon:
200+
# Galleon
201+
exit_coords.append([2886, 1249, 1121]) # Mech Fish Exit
199202
if os.path.exists(temp_file):
200203
os.remove(temp_file)
201204
exit_additions.append(exit_coords.copy())
@@ -225,6 +228,75 @@ def adjustExits(fh):
225228
fg.write(shortToUshort(exit["x"]).to_bytes(2, "big"))
226229
fg.write(shortToUshort(exit["y"]).to_bytes(2, "big"))
227230
fg.write(shortToUshort(exit["z"]).to_bytes(2, "big"))
231+
exit_count = 0
232+
data = None
233+
with open(file_name, "rb") as fg:
234+
data = fg.read()
235+
exit_count = int(len(data) / 10)
236+
if exit_count == 0:
237+
data = bytes(bytearray([0] * 10))
238+
default_exit = 0
239+
if map_index == Maps.Japes:
240+
default_exit = 15
241+
elif map_index == Maps.Fungi:
242+
default_exit = 27
243+
default_start = default_exit * 10
244+
print("Rewriting exit file:", map_index, data)
245+
with open(file_name, "wb") as fg:
246+
fg.write(data[default_start : default_start + 10])
247+
fg.write(exit_count.to_bytes(2, "big"))
248+
fg.write(data)
228249
if os.path.exists(file_name):
229250
if os.path.getsize(file_name) == 0:
230251
os.remove(file_name)
252+
253+
254+
class LoadingZone:
255+
"""Class to store information regarding a loading zone."""
256+
257+
def __init__(self, x: int, y: int, z: int, radius: int, height: int, map_id: Maps, exit: int):
258+
"""Initialize with given parameters."""
259+
self.x = x
260+
self.y = y
261+
self.z = z
262+
self.radius = radius
263+
self.height = height
264+
if height is None:
265+
self.height = 0xFFFF
266+
self.map_id = map_id
267+
self.exit = exit
268+
269+
def writeZone(self, fh: BinaryIO):
270+
"""Write data to file."""
271+
for value in (self.x, self.y, self.z):
272+
v = value
273+
if value < 0:
274+
v += 0x10000
275+
fh.write(v.to_bytes(2, "big"))
276+
fh.write(self.radius.to_bytes(2, "big")) # 0x6
277+
fh.write(self.height.to_bytes(2, "big")) # 0x8
278+
fh.write((1).to_bytes(2, "big")) # 0xA
279+
fh.write((1).to_bytes(2, "big")) # 0xC
280+
fh.write((1).to_bytes(1, "big")) # 0xE
281+
fh.write((0).to_bytes(1, "big")) # 0XF
282+
LZ_TYPE = 9
283+
fh.write(LZ_TYPE.to_bytes(2, "big"))
284+
fh.write(self.map_id.to_bytes(2, "big"))
285+
fh.write(self.exit.to_bytes(2, "big"))
286+
TRANSITION_TYPE = 0
287+
fh.write(TRANSITION_TYPE.to_bytes(2, "big"))
288+
for _ in range(0x38 - 0x18):
289+
fh.write((0).to_bytes(1, "big"))
290+
291+
292+
mech_fish_triggers = [
293+
LoadingZone(360, 70, 92, 50, None, Maps.Galleon, 34),
294+
]
295+
296+
297+
def addMechFishLZ():
298+
"""Add mech fish loading zone to the trigger file."""
299+
with open("mech_fish_triggers.bin", "wb") as fh:
300+
fh.write(len(mech_fish_triggers).to_bytes(2, "big"))
301+
for trigger in mech_fish_triggers:
302+
trigger.writeZone(fh)

base-hack/Build/build.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# Patcher functions for the extracted files
2020
from patch_text import writeNoExpPakMessages
2121
import portal_instance_script
22-
from adjust_exits import adjustExits
22+
from adjust_exits import adjustExits, addMechFishLZ
2323
from adjust_zones import modifyTriggers
2424
from BuildClasses import File, HashIcon, ModelChange, ROMPointerFile, TextChange
2525
from BuildEnums import ChangeType, CompressionMethods, TableNames, TextureFormat, ExtraTextures, Maps
@@ -917,7 +917,20 @@
917917
)
918918
file_dict.append(File(name="Fungi Geometry", pointer_table_index=TableNames.MapGeometry, file_index=Maps.Fungi, source_file="geo_fungi.bin", target_compressed_size=0x1A558))
919919
for x in range(221):
920-
file_dict.append(File(name=f"Zones for map {x}", pointer_table_index=TableNames.Triggers, file_index=x, source_file=f"lz{x}.bin", target_compressed_size=0x850, do_not_recompress=True))
920+
if x == Maps.GalleonMechFish:
921+
file_dict.append(
922+
File(
923+
name=f"Zones for map {x}",
924+
pointer_table_index=TableNames.Triggers,
925+
file_index=x,
926+
source_file="mech_fish_triggers.bin",
927+
target_compressed_size=0x850,
928+
do_not_recompress=True,
929+
do_not_extract=True,
930+
)
931+
)
932+
else:
933+
file_dict.append(File(name=f"Zones for map {x}", pointer_table_index=TableNames.Triggers, file_index=x, source_file=f"lz{x}.bin", target_compressed_size=0x850, do_not_recompress=True))
921934
# Setup
922935
setup_expansion_size = 0x2580
923936
for x in range(221):
@@ -1584,12 +1597,23 @@
15841597
data.do_not_recompress = True
15851598
file_dict.append(data)
15861599

1600+
addMechFishLZ()
15871601
with open(ROMName, "rb") as fh:
15881602
adjustExits(fh)
15891603

15901604
for x in range(216):
15911605
if os.path.exists(f"exit{x}.bin"):
1592-
file_dict.append(File(name=f"Map {x} Exits", pointer_table_index=TableNames.Exits, file_index=x, source_file=f"exit{x}.bin", do_not_compress=True, do_not_delete_source=True))
1606+
file_dict.append(
1607+
File(
1608+
name=f"Map {x} Exits",
1609+
pointer_table_index=TableNames.Exits,
1610+
file_index=x,
1611+
source_file=f"exit{x}.bin",
1612+
do_not_compress=True,
1613+
do_not_delete_source=True,
1614+
do_not_extract=True,
1615+
)
1616+
)
15931617

15941618
# Force all geo files to not be compressed
15951619
expanded_tables = {

base-hack/asm/functions/system.asm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@
7878
.definelabel regularFrameLoop, 0x805FC2B0
7979
.definelabel wipeMallocSpace, 0x80611690
8080
.definelabel inDKTV, 0x807142D8
81-
.definelabel handleGamemodes, 0x80712BD4
81+
.definelabel handleGamemodes, 0x80712BD4
82+
.definelabel handleRaisedGalleonWater, 0x806C9658

base-hack/asm/hookcode/io.asm

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,15 @@ setFlag_ItemRando:
117117
jal updateFlag
118118
addiu $a3, $zero, 1
119119
j 0x80731300
120-
nop
120+
nop
121+
122+
adjustExitRead:
123+
bgez $a0, adjustExitRead_checkCount
124+
nop
125+
j 0x806C97F0
126+
nop
127+
128+
adjustExitRead_checkCount:
129+
lui $v0, hi(ExitCount)
130+
j 0x806C97E8
131+
lbu $v0, lo(ExitCount) ($v0)

base-hack/asm/objects.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
.importobj "obj/src_misc_cutscene_remove.o"
4343
.importobj "obj/src_misc_enemies.o"
4444
.importobj "obj/src_misc_enemy_drop_table.o"
45+
.importobj "obj/src_misc_exit_parser.o"
4546
.importobj "obj/src_misc_file_screen.o"
4647
.importobj "obj/src_misc_hard_mode.o"
4748
.importobj "obj/src_misc_helm_hurry.o"

base-hack/asm/symbols.asm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@
159159
.definelabel PathData, 0x807FDBF8
160160
.definelabel MapProperties, 0x807FBB64
161161

162+
.definelabel DefaultExit, 0x807FC908
163+
162164
.definelabel TriggerArray, 0x807FDCB4
163165
.definelabel TriggerSize, 0x807FDCB0
164166
.definelabel CastleCannonPointer, 0x807F5BE8
@@ -270,4 +272,6 @@
270272
.definelabel RambiArenaComboSize, 0x8002D92C
271273
.definelabel RambiArenaComboChain, 0x8002DEF0
272274

273-
.definelabel StoredOrangeCount, 0x80029FA4
275+
.definelabel StoredOrangeCount, 0x80029FA4
276+
277+
.definelabel EnvironmentFog, 0x807F7360
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
{
2+
"id": 14,
3+
"behav_9C": 0,
4+
"ignore": false,
5+
"output_version": 2,
6+
"script": [
7+
{
8+
"conditions": [
9+
{"function":1,"inverted":false,"parameters":[1,0,0]}
10+
],
11+
"executions": [
12+
{"function":7,"parameters":[32,100,10]}
13+
]
14+
},
15+
{
16+
"conditions": [
17+
{"function":1,"inverted":false,"parameters":[20,0,0]}
18+
],
19+
"executions": [
20+
{"function":7,"parameters":[32,100,10]},
21+
{"function":96,"parameters":[13,0,0]},
22+
{"function":1,"parameters":[21,0,0]}
23+
]
24+
},
25+
{
26+
"conditions": [
27+
{"function":1,"inverted":false,"parameters":[21,0,0]}
28+
],
29+
"executions": [
30+
{"function":7,"parameters":[32,100,10]}
31+
]
32+
},
33+
{
34+
"conditions": [
35+
{"function":1,"inverted":false,"parameters":[30,0,0]}
36+
],
37+
"executions": [
38+
{"function":97,"parameters":[42,0,0]},
39+
{"function":3,"parameters":[0,120,0]},
40+
{"function":1,"parameters":[31,0,0]}
41+
]
42+
},
43+
{
44+
"conditions": [
45+
{"function":1,"inverted":false,"parameters":[31,0,0]},
46+
{"function":4,"inverted":false,"parameters":[0,0,0]}
47+
],
48+
"executions": [
49+
{"function":88,"parameters":[30,51,0]},
50+
{"function":7,"parameters":[125,0,14]},
51+
{"function":1,"parameters":[32,0,0]}
52+
]
53+
},
54+
{
55+
"conditions": [
56+
{"function":1,"inverted":false,"parameters":[3,1,0]}
57+
],
58+
"executions": [
59+
{"function":97,"parameters":[40,0,0]},
60+
{"function":5,"parameters":[15,10,0]},
61+
{"function":84,"parameters":[15,1,0]},
62+
{"function":1,"parameters":[4,1,0]}
63+
]
64+
},
65+
{
66+
"conditions": [
67+
{"function":1,"inverted":false,"parameters":[3,1,0]}
68+
],
69+
"executions": [
70+
{"function":1,"parameters":[40,0,0]}
71+
]
72+
},
73+
{
74+
"conditions": [
75+
{"function":1,"inverted":false,"parameters":[40,0,0]},
76+
{"function":34,"inverted":false,"parameters":[15,0,0]}
77+
],
78+
"executions": [
79+
{"function":3,"parameters":[0,150,0]},
80+
{"function":1,"parameters":[41,0,0]}
81+
]
82+
},
83+
{
84+
"conditions": [
85+
{"function":1,"inverted":false,"parameters":[41,0,0]},
86+
{"function":4,"inverted":false,"parameters":[0,0,0]}
87+
],
88+
"executions": [
89+
{"function":7,"parameters":[125,0,14]},
90+
{"function":1,"parameters":[42,0,0]}
91+
]
92+
}
93+
]
94+
}

base-hack/include/common_structs.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,7 +1739,7 @@ typedef struct RandomSwitchesSetting {
17391739

17401740
typedef struct LZREntrance {
17411741
/* 0x000 */ unsigned char map;
1742-
/* 0x001 */ unsigned char exit;
1742+
/* 0x001 */ char exit;
17431743
} LZREntrance;
17441744

17451745
typedef struct ROMFlags {
@@ -2328,4 +2328,30 @@ typedef struct move_overlay_paad {
23282328
/* 0x050 */ mtx_item matrix_1;
23292329
/* 0x090 */ int timer;
23302330
/* 0x094 */ actorData* shop_owner;
2331-
} move_overlay_paad;
2331+
} move_overlay_paad;
2332+
2333+
typedef struct SingleExitStruct {
2334+
/* 0x000 */ short x;
2335+
/* 0x002 */ short y;
2336+
/* 0x004 */ short z;
2337+
/* 0x006 */ unsigned char player_angle;
2338+
/* 0x007 */ unsigned char camera_angle;
2339+
/* 0x008 */ unsigned char autowalk;
2340+
/* 0x009 */ unsigned char size;
2341+
} SingleExitStruct;
2342+
2343+
typedef struct FogMapping {
2344+
/* 0x000 */ rgb rgb;
2345+
/* 0x003 */ unsigned char map_index;
2346+
/* 0x004 */ short fog_entry;
2347+
/* 0x006 */ short fog_cap;
2348+
} FogMapping;
2349+
2350+
typedef struct FogData {
2351+
/* 0x000 */ unsigned char enabled;
2352+
/* 0x001 */ rgb rgb;
2353+
/* 0x004 */ unsigned char opacity;
2354+
/* 0x005 */ char pad5;
2355+
/* 0x006 */ short entry_range;
2356+
/* 0x008 */ short cap_range;
2357+
} FogData;

base-hack/include/dk64.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ extern int cstring_strlen(char* str);
9393
extern void copyFunc(int rom_offset, int size, void* write_location);
9494
extern void* getMapData(data_indexes data_idx, int _index, char compressbyte0, char compressbyte1);
9595
extern void loadSetup(void* setup_file, int unk0, int unk1);
96+
extern void handleRaisedGalleonWater(maps map);
9697
extern int getParentDataIndex(int map);
9798
extern void WarpToDKTV(void);
9899
extern void initHelmTimer(void);
@@ -798,6 +799,9 @@ extern char_spawner_paad* ActorPaad;
798799
extern float unkFloatArray[7];
799800
extern float BackflipVelArray[7];
800801

802+
extern SingleExitStruct DefaultExit;
803+
extern FogData EnvironmentFog;
804+
801805
//hack data
802806
extern int TestVariable;
803807
extern char LoadedHooks;

0 commit comments

Comments
 (0)