Convert directly referenced entity lists

This commit is contained in:
octorock 2021-10-24 16:13:01 +02:00
parent a924f2821b
commit 21e3e54c5f
10 changed files with 21719 additions and 15566 deletions

View File

@ -64,10 +64,50 @@
.2byte 0x00, 0x00 .2byte 0x00, 0x00
.endm .endm
.macro entity_raw type:req, subtype:req, collision=0, unknown:req, paramA=0, paramB=0, x=0, y=0, paramC=0
.byte \type | ((\collision) << 4)
.byte \unknown
.byte \subtype
.byte \paramA
.4byte \paramB
.2byte \x
.2byte \y
.4byte \paramC
.endm
.macro manager subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=9, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro object_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=6, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro enemy_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=3, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro npc_raw subtype:req, collision=0, unknown=0x4f, paramA=0, paramB=0, x=0, y=0, script:req
entity_raw type=7, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\script
.endm
.macro projectile_raw subtype:req, collision=0, unknown=0xf, paramA=0, paramB=0, x=0, y=0, paramC=0
entity_raw type=4, subtype=\subtype, collision=\collision, unknown=\unknown, paramA=\paramA, paramB=\paramB, x=\x, y=\y, paramC=\paramC
.endm
.macro entity_list_end .macro entity_list_end
.byte 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.endm .endm
.macro tile_entity_list_end
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.endm
.macro tile_entity type:req, paramA=0, paramB=0, paramC=0, paramD=0
.byte \type, \paramA
.2byte \paramB, \paramC, \paramD
.endm
.macro chest type, id, item, subnum, tileset_id .macro chest type, id, item, subnum, tileset_id
.2byte (\map_x) << 4 .2byte (\map_x) << 4
.2byte (\map_y) << 4 .2byte (\map_y) << 4

10755
assets.json

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -610,7 +610,7 @@ script_080122EC:
DoPostScriptAction 0x000b DoPostScriptAction 0x000b
Call sub_08061FB0 Call sub_08061FB0
Call sub_08061F94 Call sub_08061F94
LoadRoomEntityList gUnk_080F2758 LoadRoomEntityList gUnk_additional2_HouseInteriors2_Percy
DoPostScriptAction 0x0008 DoPostScriptAction 0x0008
Wait 0x003c Wait 0x003c
PlaySound SFX_SECRET PlaySound SFX_SECRET

View File

@ -56,18 +56,7 @@ def parse_map(non_matching_funcs):
if dir == 'src': if dir == 'src':
src_data += size src_data += size
elif dir == 'data': elif dir == 'data':
subdir = filepath.split('/')[1] data += size
#print(subdir)
if subdir == 'sound':
src_data += size
elif subdir == 'map':
src_data += size
elif subdir == 'animations':
src_data += size
elif subdir == 'strings.o':
src_data += size
else:
data += size
elif line.startswith(' '): elif line.startswith(' '):
arr = line.split() arr = line.split()

2474
src/room.c

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ from assets.frame_obj_lists import FrameObjLists
from assets.extra_frame_offsets import ExtraFrameOffsets from assets.extra_frame_offsets import ExtraFrameOffsets
from assets.animation import Animation from assets.animation import Animation
from assets.exit_list import ExitList from assets.exit_list import ExitList
from assets.entity_list import EntityList
verbose = False verbose = False
@ -134,6 +135,9 @@ def extract_assets(variant, assets_folder):
elif mode == 'exit_list': elif mode == 'exit_list':
exit_list = ExitList(path, start, size, options) exit_list = ExitList(path, start, size, options)
exit_list.extract_binary(baserom) exit_list.extract_binary(baserom)
elif mode == 'entity_list':
entity_list = EntityList(path, start, size, options)
entity_list.extract_binary(baserom)
elif mode != '': elif mode != '':
print(f'Asset type {mode} not yet implemented') print(f'Asset type {mode} not yet implemented')

View File

@ -0,0 +1,39 @@
from assets.base import BaseAsset, Reader
class EntityList(BaseAsset):
def __init__(self, path: str, addr: int, size: int, options: any) -> None:
super().__init__(path, addr, size, options)
def extract_binary(self, rom: bytearray) -> None:
reader = Reader(rom[self.addr:self.addr+self.size])
lines = []
while reader.cursor + 15 < self.size:
type_and_unknowns = reader.read_u8()
type = type_and_unknowns & 0x0F
unknown_1 = (type_and_unknowns & 0xF0) >> 4
unknowns = reader.read_u8()
unknown_2 = unknowns & 0x0F
unknown_3 = (unknowns & 0xF0) >> 4
subtype = reader.read_u8()
params_a = reader.read_u8()
params_b = reader.read_u32()
params_c = reader.read_u32()
params_d = reader.read_u32()
if type_and_unknowns == 0xff: # End of list
lines.append(f'\t.4byte 0xff, 0, 0, 0 @terminator\n')
break
lines.append(f'\t.byte {type_and_unknowns}, {unknowns}, {subtype}, {params_a}\n')
lines.append(f'\t.4byte {params_b}, {params_c}, {params_d}\n')
# TODO resolve pointers in here
if reader.cursor < self.size:
lines.append(f'@ unaccounted bytes\n')
while reader.cursor < self.size:
lines.append(f'.byte {reader.read_u8()}\n')
assert(self.path.endswith('.bin'))
path = self.path[0:-4] + '.s'
with open(path, 'w') as file:
file.writelines(lines)

View File

@ -24,7 +24,7 @@ class ExitList(BaseAsset):
unknown_5 = reader.read_u16() unknown_5 = reader.read_u16()
padding_1 = reader.read_u16() padding_1 = reader.read_u16()
if transition_type == 0xffff: if transition_type == 0xffff:
lines.append(f'\t.2byte 0xffff, 0, 0, 0,0,0,0,0,0,0 @ terminator\n') lines.append(f'\t.4byte 0xffff, 0,0,0,0 @ terminator\n')
break break
lines.append(f'\t.2byte {transition_type} @ transition_type\n') lines.append(f'\t.2byte {transition_type} @ transition_type\n')
lines.append(f'\t.2byte {x_pos}, {y_pos} @ pos\n') lines.append(f'\t.2byte {x_pos}, {y_pos} @ pos\n')