Export individual animations and build them back into the ROM

This commit is contained in:
Ryan Dwyer 2021-02-12 22:24:51 +10:00
parent d74d72893a
commit a59640e34e
9 changed files with 3689 additions and 14 deletions

1
.gitignore vendored
View File

@ -6,6 +6,7 @@ extracted
src/assets/*.bin
src/assets/*.ctl
src/assets/*.tbl
src/assets/animations/*.bin
src/assets/files/audio/*.mp3
src/assets/files/bgdata/*.bin
src/assets/files/bgdata/*.seg

View File

@ -145,14 +145,16 @@ ASSET_FILES := \
$(patsubst src/assets/files/lang/$(ROMID)/%.c, $(B_DIR)/assets/files/L%Z, $(shell find src/assets/files/lang/$(ROMID) -name '*_str_[fgis].c')) \
$(B_DIR)/assets/files/ob/ob_mid.seg.o
ANIM_FILES := $(shell find src/assets/animations -name '*.bin')
SEQ_FILES := $(shell find src/assets/sequences -name '*.seq')
O_FILES := \
$(patsubst src/%.c, $(B_DIR)/%.o, $(C_FILES)) \
$(patsubst src/%.s, $(B_DIR)/%.o, $(S_FILES)) \
$(patsubst %, %.o, $(ASSET_FILES)) \
$(patsubst src/%.bin, $(B_DIR)/%.o, $(ANIM_FILES)) \
$(B_DIR)/assets/animations/list.o \
$(B_DIR)/assets/accessingpakZ.o \
$(B_DIR)/assets/animations.o \
$(B_DIR)/assets/copyrightZ.o \
$(B_DIR)/assets/files/list.o \
$(B_DIR)/assets/firingrange.o \
@ -252,9 +254,6 @@ $(B_DIR)/segments/%.bin: $(B_DIR)/stage2.bin
################################################################################
# Raw data segments
$(B_DIR)/assets/animations.o: src/assets/animations.bin
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/fonts/%.o: src/assets/fonts/%.bin
mkdir -p $(B_DIR)/assets/fonts
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
@ -420,6 +419,14 @@ $(B_DIR)/assets/sequences.bin: $(SEQ_FILES) src/assets/sequences/sequences.py
$(B_DIR)/assets/sequences.o: $(B_DIR)/assets/sequences.bin
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@
$(B_DIR)/assets/animations/%.o: src/assets/animations/%.bin
@mkdir -p $(dir $@)
TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@ 0x1
$(B_DIR)/assets/animations/list.o: src/assets/animations/list.c
@mkdir -p $(dir $@)
$(IDOCC) -c $(CFLAGS) $< -o $@
$(B_DIR)/boot/%.o: src/boot/%.c
@mkdir -p $(dir $@)
/usr/bin/env python3 tools/asmpreproc/asm-processor.py -O2 $< | $(IDOCC) -c $(CFLAGS) tools/asmpreproc/include-stdin.c -o $@

View File

@ -321,10 +321,17 @@ SECTIONS
*/
__rompos = _inflateSegmentRomEnd + ROMALLOCATION_GAME;
__refpos = .;
BEGIN_SEG(animations)
#define ANIM(id, filename) \
anim##id = . - __refpos; \
build/ROMID/assets/animations/filename (.data)
BEGIN_SEG(animations) SUBALIGN(1)
{
build/ROMID/assets/animations.o (.data);
#include "../src/assets/animations/list.ld"
. = ALIGN(0x10);
build/ROMID/assets/animations/list.o (.data);
}
END_SEG(animations)
@ -582,7 +589,7 @@ SECTIONS
BEGIN_SEG(copyright)
{
build/ROMID/copyrightZ.o (.data);
build/ROMID/assets/copyrightZ.o (.data);
}
END_SEG(copyright)
@ -597,7 +604,7 @@ SECTIONS
#if VERSION >= VERSION_NTSC_1_0
BEGIN_SEG(accessingpak)
{
build/ROMID/accessingpakZ.o (.data);
build/ROMID/assets/accessingpakZ.o (.data);
}
END_SEG(accessingpak)
#else

2422
src/assets/animations/list.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/**
* This file is included by the main linker map file (pd.ld).
*
* It is preprocessed using the C prepressor, so version constants can be used.
* It is preprocessed using the C preprocessor, so version constants can be used.
*
* A file macro is used here to allow easy listing of files. The arguments are:
*

View File

@ -6971,4 +6971,13 @@ union audioparam {
f32 f32;
};
struct animationdefinition {
u16 numkeyframes;
u16 numkeyframebytes;
void *data;
u16 unk08;
u8 unk0a;
u8 flags;
};
#endif

View File

@ -44,9 +44,21 @@ class Extractor:
self.write_asset('accessingpak.bin', data)
def extract_animations(self):
start = self.val('animations')
end = self.val('mpconfigs')
self.write_asset('animations.bin', self.rom[start:end])
segstart = self.val('animations')
segend = self.val('mpconfigs')
pos = segstart + 0x62bbe4
i = 0
while pos + 0xc <= segend:
datastart = int.from_bytes(self.rom[pos+4:pos+8], 'big')
dataend = int.from_bytes(self.rom[pos+4+0xc:pos+8+0xc], 'big')
data = self.rom[segstart+datastart:segstart+dataend]
self.write_asset('animations/%04x.bin' % i, data)
pos += 0xc
i += 1
def extract_audio(self):
sfxctl = self.val('sfxctl')

View File

@ -2,8 +2,12 @@
set -e
echo -e "\n.data\n.incbin \"$1\"\n.balign 0x10" > build/$ROMID/file-$$.s
INFILE="$1"
OUTFILE="$2"
ALIGN="${3:-0x10}"
$TOOLCHAIN-as -mabi=32 -mips2 -I src/include -EB -o "$2" build/$ROMID/file-$$.s
echo -e "\n.data\n.incbin \"$INFILE\"\n.balign $ALIGN" > build/$ROMID/file-$$.s
$TOOLCHAIN-as -mabi=32 -mips2 -I src/include -EB --no-pad-sections -o "$OUTFILE" build/$ROMID/file-$$.s
rm -f build/$ROMID/file-$$.s