Extract g_Rooms for all the overlays

This commit is contained in:
Luciano Ciccariello 2023-03-13 20:56:36 +00:00
parent 7004380fc4
commit 137f4b80c2
20 changed files with 70 additions and 24 deletions

View File

@ -1,5 +1,9 @@
{
"editor.formatOnSave": true,
"python.formatting.autopep8Args": [
"--ignore",
"E402"
],
"search.useIgnoreFiles": false,
"search.exclude": {
"**/.git": true,

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -26,6 +27,8 @@ segments:
subalign: 2
subsegments:
- [0x0, data]
- [0x12D4, roomdef, g_Rooms]
- [0x1300, data]
- [0xD42C, rodata]
- [0xD600, c]
- [0x1C704, rodata]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -33,6 +34,8 @@ segments:
- [0x650, rodata]
- [0x660, rodata]
- [0x770, rodata]
- [0x1498, roomdef, g_Rooms]
- [0x14AC, rodata]
- [0x16C0, rodata]
- [0x11770, rodata]
- [0x117A0, rodata]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -27,6 +28,7 @@ segments:
subsegments:
- [0x0, rodata]
- [0xE40, rodata]
- [0x1130, roomdef, g_Rooms]
- [0x11D4, rodata] # assets/st/mad/0.objlayout
# - [0x11E8, rodata] # assets/st/mad/1.objlayout
# - [0x1206, rodata] # assets/st/mad/2.objlayout

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -43,6 +44,8 @@ segments:
- [0x3AC0, rodata]
- [0x3AF0, rodata]
- [0x3B30, rodata]
- [0x3CC4, roomdef, g_Rooms]
- [0x3DC8, rodata]
- [0x4CE0, rodata]
- [0x373E0, rodata]
- [0x373E8, rodata]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -45,6 +46,8 @@ segments:
- [0x3580, rodata]
- [0x3720, rodata]
- [0x3760, rodata]
- [0x3A7C, roomdef, g_Rooms]
- [0x3B68, rodata]
- [0x31EA0, rodata]
- [0x31FB0, rodata]
- [0x3208C, .rodata, 4997C]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -33,6 +34,8 @@ segments:
- [0x2220, rodata]
- [0x2600, rodata]
- [0x2710, rodata]
- [0x272C, roomdef, g_Rooms]
- [0x2830, rodata]
- [0x2840, rodata]
- [0x2850, rodata]
- [0x30790, rodata]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"
@ -29,6 +30,8 @@ segments:
- [0x4E0, rodata]
- [0x5E0, rodata]
- [0x10A0, rodata]
- [0x11AC, roomdef, g_Rooms]
- [0x1228, rodata]
- [0x8C88, rodata]
- [0x8D78, rodata]
- [0x8DF0, c]

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".rodata"
- ".text"

View File

@ -14,6 +14,7 @@ options:
find_file_boundaries: yes
use_legacy_include_asm: no
migrate_rodata_to_functions: no
extensions_path: tools/splat_ext
section_order:
- ".data"
- ".rodata"
@ -31,6 +32,8 @@ segments:
- [0x770, data]
- [0x990, data]
- [0xAB0, data]
- [0x2060, roomdef, g_Rooms]
- [0x2084, data]
#- [0x3D1C, cmp]
- [0x487C, data]
#- [0x17F80, cmp]

View File

@ -15,7 +15,7 @@ g_eBreakableExplosionTypes = 0x8018066C;
g_eBreakableanimSets = 0x80180674;
g_eBreakableBlendModes = 0x80180684;
D_801809EC = 0x801809EC;
g_stRooms = 0x80181130;
g_Rooms = 0x80181130;
g_pStrObjLayout0 = 0x801811D4;
g_pStrObjLayout1 = 0x801811E8;
g_pStrObjLayout2 = 0x80181206;

View File

@ -1,4 +1,5 @@
g_SpriteBanks = 0x80180040;
g_Rooms = 0x801812D4;
Random = 0x80190E4C;
DestroyEntity = 0x80194264;
AllocEntity = 0x80194AD4;

View File

@ -4,6 +4,7 @@ g_eBreakableAnimations = 0x80180610;
g_eBreakableHitboxes = 0x80180630;
g_eBreakableExplosionTypes = 0x80180638;
g_eBreakableanimSets = 0x80180640;
g_Rooms = 0x80181498;
g_eBreakableBlendModes = 0x80180650;
Update = 0x80196FC0;
CreateEntityFromCurrentEntity = 0x80199608;

View File

@ -8,7 +8,7 @@ g_eBreakableExplosionTypes = 0x80180E78;
g_eBreakableanimSets = 0x80180E80;
g_eBreakableBlendModes = 0x80180E90;
c_GoldPrizes = 0x80182460;
g_stRooms = 0x80183CC4;
g_Rooms = 0x80183CC4;
EntityBreakable = 0x801B7A64;
EntityWargExplosionPuffOpaque = 0x801C14B8;
Random = 0x801C184C;

View File

@ -7,6 +7,7 @@ g_eBreakableHitboxes = 0x80180E48;
g_eBreakableExplosionTypes = 0x80180E50;
g_eBreakableanimSets = 0x80180E58;
g_eBreakableBlendModes = 0x80180E68;
g_Rooms = 0x80183A7C;
EntityBreakable = 0x801B26FC;
EntityShuttingWindow = 0x801B2C20;
EntityCavernDoorLever= 0x801B3E84;

View File

@ -1,6 +1,7 @@
g_SpriteBanks = 0x80180040;
c_GoldPrizes = 0x80181D14;
c_HeartPrizes = 0x80181DA4;
g_Rooms = 0x8018272C;
EntityBreakable = 0x801B0EEC;
Random = 0x801B94D4;
Update = 0x801B9504;

View File

@ -1,3 +1,4 @@
g_SpriteBanks = 0x80180040;
g_Rooms = 0x801811AC;
Update = 0x8018A198;
func_801951F0 = 0x801951F0;

View File

@ -2,6 +2,7 @@ g_SpriteBanks = 0x80180040;
PfnEntityUpdates = 0x801804B8;
g_isSecretStairsButtonPressed = 0x8018089C;
g_isDraculaFirstFormDefeated = 0x8018090C;
g_Rooms = 0x80182060;
D_80183D1C = 0x80183D1C;
D_80197F80 = 0x80197F80;
D_8019A40C = 0x8019A40C;

View File

@ -8,7 +8,6 @@ class PSXSegCmp(N64Segment):
def __init__(self, rom_start, rom_end, type, name, vram_start, args, yaml):
super().__init__(rom_start, rom_end, type, name, vram_start, args=args, yaml=yaml),
self.name = self.get_symbol_name()
print(f"{vram_start:X}: {self.name}")
# does splat provide this without extracting the symbols for every file?
# this might become extremely inefficient over time.

View File

@ -9,30 +9,12 @@ from pathlib import Path
sys.path.append(f"{os.getcwd()}/tools/n64splat")
sys.path.append(f"{os.getcwd()}/tools/splat_ext")
from util import options
from util import options, log
from segtypes.n64.segment import N64Segment
item_size = 0x8 # sizeof(RoomHeader)
def parse_roomdef(data: bytearray) -> list:
count = int(len(data) / item_size)
items = []
for i in range(0, count):
item = {
"left": data[i * item_size + 0],
"top": data[i * item_size + 1],
"right": data[i * item_size + 2],
"bottom": data[i * item_size + 3],
"tileLayoutId": data[i * item_size + 4],
"tilesetId": data[i * item_size + 5],
"objGfxId": data[i * item_size + 6],
"objLayoutId": data[i * item_size + 7],
}
items.append(item)
return items
def serialize_roomdef(content: str) -> bytearray:
obj = json.loads(content)
item_count = len(obj)
@ -48,7 +30,7 @@ def serialize_roomdef(content: str) -> bytearray:
data[i * item_size + 5] = item["tilesetId"]
data[i * item_size + 6] = item["objGfxId"]
data[i * item_size + 7] = item["objLayoutId"]
data[byte_size - 4] = 0x40 # marks the end of the room array
data[byte_size - 4] = 0x40 # marks the end of the room array
return data
@ -66,10 +48,41 @@ class PSXSegRoomdef(N64Segment):
path = self.src_path()
path.parent.mkdir(parents=True, exist_ok=True)
data = parse_roomdef(rom_bytes[self.rom_start:self.rom_end])
data = self.parse_roomdef(rom_bytes[self.rom_start:self.rom_end])
with open(path, "w") as f:
f.write(json.dumps(data, indent=4))
def parse_roomdef(self, data: bytearray) -> list:
count = int(len(data) / item_size)
expected_data_size = count * item_size + 4
if len(data) != expected_data_size:
log.write(
f"data for '{self.name}' is {expected_data_size - len(data)} too long. Data might look incorrect.", status="warn")
items = []
for i in range(0, count):
if data[i * item_size + 0] == 64:
log.write(
f"data for '{self.name}' includes the array terminator. Try reducing the size of the subsegment.", status="warn")
item = {
"left": data[i * item_size + 0],
"top": data[i * item_size + 1],
"right": data[i * item_size + 2],
"bottom": data[i * item_size + 3],
"tileLayoutId": data[i * item_size + 4],
"tilesetId": data[i * item_size + 5],
"objGfxId": data[i * item_size + 6],
"objLayoutId": data[i * item_size + 7],
}
items.append(item)
if data[count * item_size] != 64:
log.write(
f"data for '{self.name}' does not end with a terminator.", status="warn")
return items
if __name__ == "__main__":
input_file_name = sys.argv[1]