mirror of https://github.com/zeldaret/tmc.git
Split asset config into multiple files
This commit is contained in:
parent
1eb15e495a
commit
dbb3eb700e
|
@ -185,7 +185,7 @@ _080197DC:
|
|||
ldr r1, [r4]
|
||||
ldr r0, _08019808 @ =0x7FFFFFFF
|
||||
ands r1, r0
|
||||
ldr r0, _0801980C @ =gAssets
|
||||
ldr r0, _0801980C @ =gMapData
|
||||
adds r1, r1, r0
|
||||
ldr r2, [r4, #8]
|
||||
adds r0, r2, #0
|
||||
|
@ -201,7 +201,7 @@ _080197DC:
|
|||
b _0801982E
|
||||
.align 2, 0
|
||||
_08019808: .4byte 0x7FFFFFFF
|
||||
_0801980C: .4byte gAssets
|
||||
_0801980C: .4byte gMapData
|
||||
_08019810:
|
||||
adds r0, r1, #0
|
||||
adds r1, r3, #0
|
||||
|
|
|
@ -762,7 +762,7 @@ _0801DE46:
|
|||
beq _0801DEE0
|
||||
ldr r2, _0801DEF8 @ =0x040000D4
|
||||
ldr r0, [r4, #4]
|
||||
ldr r1, _0801DEFC @ =gAssets
|
||||
ldr r1, _0801DEFC @ =gMapData
|
||||
adds r0, r0, r1
|
||||
str r0, [r2]
|
||||
ldr r0, _0801DF00 @ =gUnk_02019EE0
|
||||
|
@ -847,7 +847,7 @@ _0801DEEA:
|
|||
pop {r4, r5, r6, r7, pc}
|
||||
.align 2, 0
|
||||
_0801DEF8: .4byte 0x040000D4
|
||||
_0801DEFC: .4byte gAssets
|
||||
_0801DEFC: .4byte gMapData
|
||||
_0801DF00: .4byte gUnk_02019EE0
|
||||
_0801DF04: .4byte 0x84000100
|
||||
_0801DF08: .4byte gAreaRoomHeaders
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
*
|
||||
!*.json
|
||||
!.gitignore
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -4,7 +4,7 @@
|
|||
.section .rodata
|
||||
.align 2
|
||||
|
||||
gAssets:: @ 08324AE4
|
||||
gMapData:: @ 08324AE4
|
||||
.include "data/assets.s"
|
||||
.align 2
|
||||
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
@ programmable wave samples
|
||||
|
||||
gUnk_08A11BAC:: @ 08A11BAC
|
||||
.incbin "voicegroups/gUnk_08A11BAC.bin"
|
||||
.incbin "programmable_wave_samples/gUnk_08A11BAC.bin"
|
||||
|
||||
gUnk_08A11BDC:: @ 08A11BDC
|
||||
.incbin "voicegroups/gUnk_08A11BDC.bin"
|
||||
.incbin "programmable_wave_samples/gUnk_08A11BDC.bin"
|
||||
|
||||
gUnk_08A11C0C:: @ 08A11C0C
|
||||
.incbin "voicegroups/gUnk_08A11C0C.bin"
|
||||
.incbin "programmable_wave_samples/gUnk_08A11C0C.bin"
|
||||
|
||||
gUnk_08A11C1C:: @ 08A11C1C
|
||||
.incbin "voicegroups/gUnk_08A11C1C.bin"
|
||||
.incbin "programmable_wave_samples/gUnk_08A11C1C.bin"
|
||||
|
|
|
@ -3757,37 +3757,6 @@ voicegroup033:: @ 08A07394
|
|||
voice_directsound 60, 0, gUnk_08A84DCC, 255, 0, 255, 165
|
||||
voice_directsound 60, 0, gUnk_08A5496C, 255, 0, 255, 165
|
||||
|
||||
@ .ifdef EU
|
||||
@ @ TODO only small differences
|
||||
@ .incbin "voicegroups/voicegroup033_EU.bin"
|
||||
@ .4byte 0x2
|
||||
@ .incbin "voicegroups/voicegroup033_1_EU.bin"
|
||||
@ .else
|
||||
@ .incbin "voicegroups/voicegroup033_2_USA-JP-DEMO_USA-DEMO_JP.bin"
|
||||
@ .4byte gUnk_08A12ED0
|
||||
@ .incbin "voicegroups/voicegroup033_3_USA-JP-DEMO_USA-DEMO_JP.bin"
|
||||
@ .endif
|
||||
@ .4byte gUnk_08A16610
|
||||
@ .ifdef EU
|
||||
@ @ TODO only small differences
|
||||
@ .incbin "voicegroups/voicegroup033_4_EU.bin"
|
||||
@ .else
|
||||
@ .incbin "voicegroups/voicegroup033_5_USA-JP-DEMO_USA-DEMO_JP.bin"
|
||||
@ .endif
|
||||
@ .4byte gUnk_08A12ED0
|
||||
@ .ifdef EU
|
||||
@ @ TODO only small differences
|
||||
@ .incbin "voicegroups/voicegroup033_6_EU.bin"
|
||||
@ .else
|
||||
@ .incbin "voicegroups/voicegroup033_7_USA-JP-DEMO_USA-DEMO_JP.bin"
|
||||
@ .endif
|
||||
@ .4byte gUnk_08A1A54C
|
||||
@ .incbin "voicegroups/voicegroup033_8.bin"
|
||||
@ .4byte gUnk_08A84DCC
|
||||
@ .incbin "voicegroups/voicegroup033_9.bin"
|
||||
@ .4byte gUnk_08A5496C
|
||||
@ .incbin "voicegroups/voicegroup033_10.bin"
|
||||
|
||||
voicegroup034:: @ 08A07610
|
||||
voice_square_1 60, 0, 0, 2, 0, 0, 15, 0
|
||||
voice_square_1 60, 0, 0, 2, 0, 0, 15, 0
|
||||
|
|
|
@ -5,7 +5,7 @@ extern void LoadPalettes(const u8*, s32, s32);
|
|||
|
||||
extern u16 gMetatilesBottom[];
|
||||
extern u16 gMetatilesTop[];
|
||||
extern u8 gAssets;
|
||||
extern u8 gMapData;
|
||||
|
||||
extern const u8 gUnk_020176E0[];
|
||||
|
||||
|
@ -13,7 +13,7 @@ void sub_0807C960(void* dest, u32 offset) {
|
|||
void* src;
|
||||
|
||||
if (offset != -1) {
|
||||
src = &gAssets + (offset & 0x7fffffff);
|
||||
src = &gMapData + (offset & 0x7fffffff);
|
||||
if ((u32)dest >> 0x18 == 6) {
|
||||
LZ77UnCompVram(src, (void*)dest);
|
||||
} else {
|
||||
|
|
|
@ -35,111 +35,116 @@ def extract_assets(variant, assets_folder):
|
|||
with open(baserom_path, 'rb') as file:
|
||||
baserom = bytearray(file.read())
|
||||
|
||||
config_modified = os.path.getmtime('assets.json')
|
||||
# json_modified = os.path.getmtime('assets.json')
|
||||
# if json_modified < config_modified:
|
||||
# print('Convert yaml to json...', flush=True)
|
||||
# subprocess.check_call('cat assets.yaml | yq . > assets.json', shell=True)
|
||||
|
||||
with open('assets.json') as file:
|
||||
current_offset = 0
|
||||
#print('Parsing yaml...', flush=True)
|
||||
#assets = yaml.safe_load(file)
|
||||
#print('done', flush=True)
|
||||
print('Parsing json...', flush=True)
|
||||
assets = json.load(file)
|
||||
print('done', flush=True)
|
||||
for asset in assets:
|
||||
if 'offsets' in asset: # Offset definition
|
||||
if variant in asset['offsets']:
|
||||
current_offset = asset['offsets'][variant]
|
||||
elif 'path' in asset: # Asset definition
|
||||
# Handle all json config files in the assets folder
|
||||
configs = [x for x in os.listdir('assets') if x.endswith('.json')] # TODO this would break with a folder that is named .json
|
||||
|
||||
if 'variants' in asset:
|
||||
if variant not in asset['variants']:
|
||||
# This asset is not used in the current variant
|
||||
continue
|
||||
print(configs)
|
||||
|
||||
path = os.path.join(assets_folder, asset['path'])
|
||||
for config in configs:
|
||||
path = os.path.join('assets', config)
|
||||
config_modified = os.path.getmtime(path)
|
||||
|
||||
extract_file = False
|
||||
with open(path) as file:
|
||||
current_offset = 0
|
||||
#print('Parsing yaml...', flush=True)
|
||||
#assets = yaml.safe_load(file)
|
||||
#print('done', flush=True)
|
||||
print(f'Parsing {config}...', flush=True)
|
||||
assets = json.load(file)
|
||||
print('done', flush=True)
|
||||
for asset in assets:
|
||||
if 'offsets' in asset: # Offset definition
|
||||
if variant in asset['offsets']:
|
||||
current_offset = asset['offsets'][variant]
|
||||
elif 'path' in asset: # Asset definition
|
||||
|
||||
if os.path.isfile(path):
|
||||
file_modified = os.path.getmtime(path)
|
||||
if file_modified < config_modified:
|
||||
if 'variants' in asset:
|
||||
if variant not in asset['variants']:
|
||||
# This asset is not used in the current variant
|
||||
continue
|
||||
|
||||
path = os.path.join(assets_folder, asset['path'])
|
||||
|
||||
extract_file = False
|
||||
|
||||
if os.path.isfile(path):
|
||||
file_modified = os.path.getmtime(path)
|
||||
if file_modified < config_modified:
|
||||
if verbose:
|
||||
print(f'{path} was created before the config was modified.')
|
||||
extract_file = True
|
||||
# TODO Extract when source file (depends on type) was modified after target file
|
||||
#print(f'{file_modified} {config_modified}')
|
||||
else:
|
||||
if verbose:
|
||||
print(f'{path} was created before the config was modified.')
|
||||
print(f'{path} does not yet exist.')
|
||||
extract_file = True
|
||||
# TODO Extract when source file (depends on type) was modified after target file
|
||||
#print(f'{file_modified} {config_modified}')
|
||||
else:
|
||||
if verbose:
|
||||
print(f'{path} does not yet exist.')
|
||||
extract_file = True
|
||||
|
||||
|
||||
if extract_file:
|
||||
if verbose:
|
||||
print(f'Extracting {path}...')
|
||||
start = 0
|
||||
if 'start' in asset:
|
||||
# Apply offset to the start of the USA variant
|
||||
start = asset['start'] + current_offset
|
||||
elif 'starts' in asset:
|
||||
# Use start for the current variant
|
||||
start = asset['starts'][variant]
|
||||
if extract_file:
|
||||
if verbose:
|
||||
print(f'Extracting {path}...')
|
||||
|
||||
mode = ''
|
||||
if 'type' in asset:
|
||||
mode = asset['type']
|
||||
start = 0
|
||||
if 'start' in asset:
|
||||
# Apply offset to the start of the USA variant
|
||||
start = asset['start'] + current_offset
|
||||
elif 'starts' in asset:
|
||||
# Use start for the current variant
|
||||
start = asset['starts'][variant]
|
||||
|
||||
Path(os.path.dirname(path)).mkdir(parents=True, exist_ok=True)
|
||||
mode = ''
|
||||
if 'type' in asset:
|
||||
mode = asset['type']
|
||||
|
||||
if 'size' in asset: # The asset has a size and want to be extracted first.
|
||||
size = asset['size'] # TODO can different sizes for the different variants ever occur?
|
||||
Path(os.path.dirname(path)).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(path, 'wb') as output:
|
||||
output.write(baserom[start:start+size])
|
||||
# If an asset has no size, the extraction tool reads the baserom iself.
|
||||
if 'size' in asset: # The asset has a size and want to be extracted first.
|
||||
size = asset['size'] # TODO can different sizes for the different variants ever occur?
|
||||
|
||||
options = asset['options'] if 'options' in asset else []
|
||||
with open(path, 'wb') as output:
|
||||
output.write(baserom[start:start+size])
|
||||
# If an asset has no size, the extraction tool reads the baserom iself.
|
||||
|
||||
if mode == 'tileset':
|
||||
extract_tileset(path)
|
||||
elif mode == 'palette':
|
||||
extract_palette(path)
|
||||
elif mode == 'graphic':
|
||||
extract_graphic(path, options)
|
||||
elif mode == 'midi':
|
||||
extract_midi(path, baserom_path, start, options)
|
||||
elif mode == 'aif':
|
||||
extract_aif(path, options)
|
||||
elif mode == 'palette_group':
|
||||
palette_group = PaletteGroup(path, start, size, options)
|
||||
palette_group.extract_binary(baserom)
|
||||
elif mode == 'gfx_group':
|
||||
gfx_group = GfxGroup(path, start, size, options)
|
||||
gfx_group.extract_binary(baserom)
|
||||
elif mode == 'fixed_type_gfx':
|
||||
fixed_type_gfx = FixedTypeGfx(path, start, size, options)
|
||||
fixed_type_gfx.extract_binary(baserom)
|
||||
elif mode == 'frame_obj_lists':
|
||||
frame_obj_lists = FrameObjLists(path, start, size, options)
|
||||
frame_obj_lists.extract_binary(baserom)
|
||||
elif mode == 'extra_frame_offsets':
|
||||
extra_frame_offsets = ExtraFrameOffsets(path, start, size, options)
|
||||
extra_frame_offsets.extract_binary(baserom)
|
||||
elif mode == 'animation':
|
||||
animation = Animation(path, start, size, options)
|
||||
animation.extract_binary(baserom)
|
||||
elif mode == 'exit_list':
|
||||
exit_list = ExitList(path, start, size, options)
|
||||
exit_list.extract_binary(baserom)
|
||||
elif mode == 'entity_list':
|
||||
entity_list = EntityList(path, start, size, options)
|
||||
entity_list.extract_binary(baserom)
|
||||
elif mode != '':
|
||||
print(f'Asset type {mode} not yet implemented')
|
||||
options = asset['options'] if 'options' in asset else []
|
||||
|
||||
if mode == 'tileset':
|
||||
extract_tileset(path)
|
||||
elif mode == 'palette':
|
||||
extract_palette(path)
|
||||
elif mode == 'graphic':
|
||||
extract_graphic(path, options)
|
||||
elif mode == 'midi':
|
||||
extract_midi(path, baserom_path, start, options)
|
||||
elif mode == 'aif':
|
||||
extract_aif(path, options)
|
||||
elif mode == 'palette_group':
|
||||
palette_group = PaletteGroup(path, start, size, options)
|
||||
palette_group.extract_binary(baserom)
|
||||
elif mode == 'gfx_group':
|
||||
gfx_group = GfxGroup(path, start, size, options)
|
||||
gfx_group.extract_binary(baserom)
|
||||
elif mode == 'fixed_type_gfx':
|
||||
fixed_type_gfx = FixedTypeGfx(path, start, size, options)
|
||||
fixed_type_gfx.extract_binary(baserom)
|
||||
elif mode == 'frame_obj_lists':
|
||||
frame_obj_lists = FrameObjLists(path, start, size, options)
|
||||
frame_obj_lists.extract_binary(baserom)
|
||||
elif mode == 'extra_frame_offsets':
|
||||
extra_frame_offsets = ExtraFrameOffsets(path, start, size, options)
|
||||
extra_frame_offsets.extract_binary(baserom)
|
||||
elif mode == 'animation':
|
||||
animation = Animation(path, start, size, options)
|
||||
animation.extract_binary(baserom)
|
||||
elif mode == 'exit_list':
|
||||
exit_list = ExitList(path, start, size, options)
|
||||
exit_list.extract_binary(baserom)
|
||||
elif mode == 'entity_list':
|
||||
entity_list = EntityList(path, start, size, options)
|
||||
entity_list.extract_binary(baserom)
|
||||
elif mode != '':
|
||||
print(f'Asset type {mode} not yet implemented')
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue