From 87023d8be28950109c52679d77a179e623dfd78f Mon Sep 17 00:00:00 2001 From: Alex Bates <16batesa@gmail.com> Date: Tue, 10 Nov 2020 11:25:36 +0000 Subject: [PATCH 1/4] vscode: don't clang-tidy include/PR/*.h --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index c2b3c50402..809179e010 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,6 +10,9 @@ "-D_LANGUAGE_C", "-DSCRIPT(...)={}", ], + "clang-tidy.blacklist": [ + "include/PR" + ], "git.ignoreLimitWarning": true, "search.exclude": { "build": true, From 87cc5ed9995a3366594caf1cd15df79c2ac727e7 Mon Sep 17 00:00:00 2001 From: Alex Bates <16batesa@gmail.com> Date: Wed, 11 Nov 2020 13:52:04 +0000 Subject: [PATCH 2/4] match npc sprites --- .gitignore | 1 + .vscode/settings.json | 3 + Makefile | 28 +- sources.mk | 2 + tools/Makefile | 2 +- tools/compile_npc_sprite.py | 115 ++++++++ tools/compile_npc_sprites.py | 32 +++ tools/n64splat | 2 +- tools/sort_symbol_addrs.py | 0 tools/splat.yaml | 506 +++++++++++++++++++---------------- 10 files changed, 447 insertions(+), 244 deletions(-) create mode 100755 tools/compile_npc_sprite.py create mode 100755 tools/compile_npc_sprites.py mode change 100644 => 100755 tools/sort_symbol_addrs.py diff --git a/.gitignore b/.gitignore index 349671fabe..142a6f16dd 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ settings.mk /bin /img /msg +/sprite diff --git a/.vscode/settings.json b/.vscode/settings.json index 809179e010..7a8a3ed59a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,4 +18,7 @@ "build": true, "docs/doxygen": true, }, + "python.autoComplete.extraPaths": [ + "./tools" + ], } diff --git a/Makefile b/Makefile index cf93519fb9..7b8d121758 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,8 @@ LD_SCRIPT := $(TARGET).ld LD_MAP := $(BUILD_DIR)/$(TARGET).map ASSETS_BIN := $(BUILD_DIR)/bin/assets/assets.bin MSG_BIN := $(BUILD_DIR)/msg.bin -GENERATED_HEADERS := include/ld_addrs.h +NPC_BIN := $(BUILD_DIR)/sprite/npc.bin +GENERATED_HEADERS := include/ld_addrs.h include/npc_animations.h ### Tools ### @@ -99,14 +100,14 @@ submodules: git submodule update --init --recursive split: - rm -rf bin img - $(SPLAT) --modes bin Yay0 PaperMarioMapFS PaperMarioMessages img + rm -rf bin msg img sprite + $(SPLAT) --modes ld bin Yay0 PaperMarioMapFS PaperMarioMessages img PaperMarioNpcSprites split-%: - $(SPLAT) --modes $* --verbose + $(SPLAT) --modes ld $* --verbose split-all: - rm -rf bin img + rm -rf bin msg img sprite $(SPLAT) --modes all test: $(ROM) @@ -198,11 +199,24 @@ $(MSG_BIN): $(MESSAGES) @echo "building $@" @$(PYTHON) tools/compile_messages.py $@ /dev/null $(MESSAGES) $(MSG_BIN:.bin=.o): $(MSG_BIN) - @mkdir -p $(shell dirname $@) $(LD) -r -b binary -o $@ $< -$(LD_SCRIPT): $(SPLAT_YAML) +# Sprites +$(foreach npc, $(NPC_SPRITES), $(eval sprite/npc/$(npc): $(shell find sprite/npc/$(npc) -type f))) # dependencies +NPC_DIRS := $(foreach npc, $(NPC_SPRITES), $(BUILD_DIR)/sprite/npc/$(npc)) +$(BUILD_DIR)/sprite/npc/%: sprite/npc/% @mkdir -p $(shell dirname $@) + $(PYTHON) tools/compile_npc_sprite.py $@ $< +$(NPC_BIN): $(foreach dir, $(NPC_DIRS), $(dir).Yay0) tools/compile_npc_sprites.py + @mkdir -p $(shell dirname $@) + @echo "building $@" + @$(PYTHON) tools/compile_npc_sprites.py $@ $(foreach dir, $(NPC_DIRS), $(dir).Yay0) +$(NPC_BIN:.bin=.o): $(NPC_BIN) + $(LD) -r -b binary -o $@ $< +include/npc_animations.h: $(NPC_DIRS) + @echo "TODO" + +$(LD_SCRIPT): $(SPLAT_YAML) $(SPLAT) --modes ld $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) diff --git a/sources.mk b/sources.mk index 2d3efdad4e..488dd9a935 100644 --- a/sources.mk +++ b/sources.mk @@ -58,5 +58,7 @@ ASSETS := \ MESSAGES := $(shell find msg -type f -name "*.msg") +NPC_SPRITES := world_goombario world_kooper world_bombette world_parakarry world_bow world_watt world_sushi world_lakilester battle_goombario battle_kooper battle_bombette battle_parakarry battle_bow battle_watt battle_sushi battle_lakilester kooper_without_shell world_eldstar world_mamar world_skolar world_muskular world_misstar world_klevar world_kalmar battle_eldstar battle_mamar battle_skolar battle_muskular battle_misstar battle_klevar battle_kalmar twink jr_troopa spiked_jr_troopa spiked_para_jr_troopa mage_jr_troopa para_jr_troopa goomba spiked_goomba paragoomba koopa_troopa para_troopa fuzzy bob_omb bullet_bill bill_blaster monty_mole cleft pokey battle_bandit buzzy_beetle swooper stone_chomp putrid_piranha piranha_plant sentinel world_clubba battle_clubba shy_guy groove_guy sky_guy pyro_guy spy_guy medi_guy fuzzipede jungle_guy heart_plant hurt_plant m_bush bubble kent_c_koopa dayzee lakitu spiny bzzap ruff_puff spike_top duplighost albino_dino blooper baby_blooper gulpit dry_bones thrown_bone bony_beetle magikoopa flying_magikoopa world_koopatrol koopatrol hammer_bros bush_basic bush_blocky bush_dry bush_leafy bush_matted world_kammy battle_kammy goomba_bros goomba_king spiky_goomnut dark_toad koopa_bros buzzar tutankoopa chain_chomp world_tubba battle_tubba tubbas_heart big_lantern_ghost shy_squad_guy marshal_guy stilt_guy stilt_guy_unfold shy_stack_guy shy_stack_unfold shy_stack_damage shy_stack_rock general_guy general_guy_bomb tank_guy lava_piranha_head petit_piranha lava_bud huff_n_puff tuff_puff monstar crystal_king world_bowser battle_bowser luigi toad three_sisters vanna_t toad_kid toad_guard harry_t toad_minister postmaster conductor_toad train_station_toad fishmael artist_toad koopa koopa_without_shell world_bob_omb whacka dryite mouser boo yoshi yoshi_kid raven bubulb penguin shiver_toad world_bandit goompapa goombaria goomama goompa goomma the_master chan lee merlon chet_rippo rowf minh_t russ_t tayce_t fice_t bartender chanterelle rip_cheato chuck_quizmo merluvlee merlar merlow star_kid kolorado_wife koopa_koot kolorado battle_kolorado archeologist nomadimouse world_merlee battle_merlee disguised_moustafa moustafa oaklie bootler yakkey gourmet_guy village_leader leaders_friend rafael_raven tolielup gate_flower petunia posie lily rosie sun lakilulu ninji mayor_penguin mayor_penguin_wife penguin_patrol herringway merle star_rod fire coin parade_peach parade_koopas parade_burnt_bowser parade_luigi parade_partners parade_yoshis parada_kolorados parade_chicks parade_ice_show parade_toads parade_batons parade_drums parade_flags parade_horns parade_tubba_balloon parade_wizards parade_mario parade_shy_guys parade_twink leaf + # Image settings $(BUILD_DIR)/img/battle/text_action_command_ratings.ia4.png: IMG_FLAGS = --flip-y diff --git a/tools/Makefile b/tools/Makefile index d3edc74d33..9e40ad25ca 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -2,7 +2,7 @@ default: all all: Yay0compress -Yay0compress: +Yay0compress: gcc Yay0compress.c -O3 -o Yay0compress clean: diff --git a/tools/compile_npc_sprite.py b/tools/compile_npc_sprite.py new file mode 100755 index 0000000000..c98f29953d --- /dev/null +++ b/tools/compile_npc_sprite.py @@ -0,0 +1,115 @@ +#! /usr/bin/python3 + +from sys import argv, path +from pathlib import Path +import os +path.append(os.path.join(os.path.dirname(__file__), "n64splat")) +from n64splat.segtypes.PaperMarioNpcSprites import Sprite +from convert_image import pack_color, iter_in_groups + +if __name__ == "__main__": + if len(argv) != 3: + print("usage: compile_npc_sprite.py [OUTBIN] [DIR]") + exit(1) + + _, outfile, sprite_dir = argv + + try: + sprite = Sprite.from_dir(Path(sprite_dir)) + except AssertionError as e: + print("error:", e) + exit(1) + + with open(outfile, "wb") as f: + f.seek(0x10) # leave space for header + + # leave space for animation offset list + f.seek((len(sprite.animations) + 1) * 4, 1) + animation_offsets = [] + + # write animations + for i, components in enumerate(sprite.animations): + animation_offsets.append(f.tell()) + + # leave space for component offset list + f.seek((len(components) + 1) * 4, 1) + component_offsets = [] + + for comp in components: + offset = f.tell() + + for command in comp.commands: + f.write(command.to_bytes(2, byteorder="big")) + + f.seek(f.tell() % 4, 1) + component_offsets.append(f.tell()) + + f.write(offset.to_bytes(4, byteorder="big")) + f.write((len(comp.commands) * 2).to_bytes(2, byteorder="big")) + f.write(comp.x.to_bytes(2, byteorder="big")) + f.write(comp.y.to_bytes(2, byteorder="big")) + f.write(comp.z.to_bytes(2, byteorder="big")) + + next_anim = f.tell() + + # write component offset list + f.seek(animation_offsets[i]) + component_offsets.append(-1) + for offset in component_offsets: + f.write(offset.to_bytes(4, byteorder="big", signed=True)) + + f.seek(next_anim) + + # palettes start 8-byte aligned + if (f.tell() & 7) == 4: + f.seek(4, 1) + + # write palettes + palette_offsets = [] + for i, palette in enumerate(sprite.palettes): + palette_offsets.append(f.tell()) + for rgba in palette: + if rgba[3] not in (0, 0xFF): + print("error: translucent pixels not allowed in palette {sprite.palette_names[i]}") + exit(1) + + color = pack_color(*rgba) + f.write(color.to_bytes(2, byteorder="big")) + + # write images/rasters + image_offsets = [] + for image in sprite.images: + offset = f.tell() + + for a, b in iter_in_groups(image.raster, 2): + byte = (a << 4) | b + f.write(byte.to_bytes(1, byteorder="big")) + + image_offsets.append(f.tell()) + + f.write(offset.to_bytes(4, byteorder="big")) + f.write(bytes([image.width, image.height, image.palette_index, 0xFF])) + + # write image offset list + image_offset_list_offset = f.tell() + image_offsets.append(-1) + for offset in image_offsets: + f.write(offset.to_bytes(4, byteorder="big", signed=True)) + + # write palette offset list + palette_offset_list_offset = f.tell() + palette_offsets.append(-1) + for offset in palette_offsets: + f.write(offset.to_bytes(4, byteorder="big", signed=True)) + + # write header + f.seek(0) + f.write(image_offset_list_offset.to_bytes(4, byteorder="big")) + f.write(palette_offset_list_offset.to_bytes(4, byteorder="big")) + f.write(sprite.max_components.to_bytes(4, byteorder="big")) + f.write(sprite.num_variations.to_bytes(4, byteorder="big")) + + # write animation offset list + animation_offsets.append(-1) + for offset in animation_offsets: + f.write(offset.to_bytes(4, byteorder="big", signed=True)) diff --git a/tools/compile_npc_sprites.py b/tools/compile_npc_sprites.py new file mode 100755 index 0000000000..4f7f52ba1c --- /dev/null +++ b/tools/compile_npc_sprites.py @@ -0,0 +1,32 @@ +#! /usr/bin/python3 + +from sys import argv + +if __name__ == "__main__": + if len(argv) < 4: + print("usage: compile_npc_sprites.py [OUTBIN] [INFILES]") + exit(1) + + _, outfile, *infiles = argv + + with open(outfile, "wb") as f: + offsets = [] + + f.seek(4 * (len(infiles) + 1)) + + for filename in infiles: + with open(filename, "rb") as spritef: + offsets.append(f.tell()) + f.write(spritef.read()) + + # align + while f.tell() % 8 != 0: + f.write(bytes([0])) + + print(f"{0x19E67B8 + f.tell():X}") + + offsets.append(f.tell()) + + f.seek(0) + for offset in offsets: + f.write(offset.to_bytes(4, byteorder="big")) diff --git a/tools/n64splat b/tools/n64splat index 6106762b05..0ff02cd473 160000 --- a/tools/n64splat +++ b/tools/n64splat @@ -1 +1 @@ -Subproject commit 6106762b0561e40a640c11852a17bb87963c7ba8 +Subproject commit 0ff02cd4734c26c7ae03aee4a0374a774b3b097b diff --git a/tools/sort_symbol_addrs.py b/tools/sort_symbol_addrs.py old mode 100644 new mode 100755 diff --git a/tools/splat.yaml b/tools/splat.yaml index 79dbc8d832..c09f514197 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -7022,241 +7022,277 @@ segments: - [0x19E5758, "Yay0"] - [0x19E5950, "Yay0"] - [0x19E62A0, "Yay0"] - - [0x19E67B2, "bin"] - - [0x19E6B60, "Yay0"] - - [0x19E7528, "Yay0"] - - [0x19E9778, "Yay0"] - - [0x19EAF38, "Yay0"] - - [0x19EC4E0, "Yay0"] - - [0x19EDD30, "Yay0"] - - [0x19EEB18, "Yay0"] - - [0x19F0070, "Yay0"] - - [0x19F15A0, "Yay0"] - - [0x19F26D8, "Yay0"] - - [0x19F5390, "Yay0"] - - [0x19F7398, "Yay0"] - - [0x19FA128, "Yay0"] - - [0x19FCAE8, "Yay0"] - - [0x19FED70, "Yay0"] - - [0x1A00958, "Yay0"] - - [0x1A02D00, "Yay0"] - - [0x1A04400, "Yay0"] - - [0x1A05550, "Yay0"] - - [0x1A06390, "Yay0"] - - [0x1A06F98, "Yay0"] - - [0x1A07B68, "Yay0"] - - [0x1A0A0A0, "Yay0"] - - [0x1A0ACC8, "Yay0"] - - [0x1A0B780, "Yay0"] - - [0x1A0BBE0, "Yay0"] - - [0x1A0C000, "Yay0"] - - [0x1A0C438, "Yay0"] - - [0x1A0C860, "Yay0"] - - [0x1A0D1E8, "Yay0"] - - [0x1A0D5B0, "Yay0"] - - [0x1A0D970, "Yay0"] - - [0x1A0EF00, "Yay0"] - - [0x1A13920, "Yay0"] - - [0x1A15850, "Yay0"] - - [0x1A183F8, "Yay0"] - - [0x1A1A608, "Yay0"] - - [0x1A1C5E8, "Yay0"] - - [0x1A1D6D0, "Yay0"] - - [0x1A1E478, "Yay0"] - - [0x1A1F370, "Yay0"] - - [0x1A226B0, "Yay0"] - - [0x1A249B8, "Yay0"] - - [0x1A25E78, "Yay0"] - - [0x1A27FF0, "Yay0"] - - [0x1A28BE0, "Yay0"] - - [0x1A29680, "Yay0"] - - [0x1A2BC68, "Yay0"] - - [0x1A2E120, "Yay0"] - - [0x1A2F3F8, "Yay0"] - - [0x1A31D18, "Yay0"] - - [0x1A33AB0, "Yay0"] - - [0x1A35BB8, "Yay0"] - - [0x1A369A8, "Yay0"] - - [0x1A39600, "Yay0"] - - [0x1A3B018, "Yay0"] - - [0x1A3C310, "Yay0"] - - [0x1A3FCC8, "Yay0"] - - [0x1A423D8, "Yay0"] - - [0x1A449C0, "Yay0"] - - [0x1A46568, "Yay0"] - - [0x1A49340, "Yay0"] - - [0x1A4AC88, "Yay0"] - - [0x1A4D7E8, "Yay0"] - - [0x1A4E028, "Yay0"] - - [0x1A4FA60, "Yay0"] - - [0x1A531D0, "Yay0"] - - [0x1A53D48, "Yay0"] - - [0x1A56C80, "Yay0"] - - [0x1A58F58, "Yay0"] - - [0x1A5A5A8, "Yay0"] - - [0x1A62B40, "Yay0"] - - [0x1A641F8, "Yay0"] - - [0x1A666F0, "Yay0"] - - [0x1A68870, "Yay0"] - - [0x1A6C630, "Yay0"] - - [0x1A6D5A0, "Yay0"] - - [0x1A6EF50, "Yay0"] - - [0x1A70FF0, "Yay0"] - - [0x1A74FC0, "Yay0"] - - [0x1A78A40, "Yay0"] - - [0x1A79900, "Yay0"] - - [0x1A7D798, "Yay0"] - - [0x1A7EEA0, "Yay0"] - - [0x1A7EFD8, "Yay0"] - - [0x1A83450, "Yay0"] - - [0x1A85668, "Yay0"] - - [0x1A87958, "Yay0"] - - [0x1A8BF98, "Yay0"] - - [0x1A8FE28, "Yay0"] - - [0x1A93EA0, "Yay0"] - - [0x1A94188, "Yay0"] - - [0x1A94480, "Yay0"] - - [0x1A946A8, "Yay0"] - - [0x1A94A00, "Yay0"] - - [0x1A94C58, "Yay0"] - - [0x1A98D98, "Yay0"] - - [0x1A9BA80, "Yay0"] - - [0x1A9DB68, "Yay0"] - - [0x1AA0048, "Yay0"] - - [0x1AA0698, "Yay0"] - - [0x1AA1008, "Yay0"] - - [0x1AA6D58, "Yay0"] - - [0x1AAD600, "Yay0"] - - [0x1AB1BF0, "Yay0"] - - [0x1AB2368, "Yay0"] - - [0x1ABA290, "Yay0"] - - [0x1AC14A8, "Yay0"] - - [0x1AC3910, "Yay0"] - - [0x1ACBC98, "Yay0"] - - [0x1ACE058, "Yay0"] - - [0x1ACF910, "Yay0"] - - [0x1AD06D8, "Yay0"] - - [0x1AD0B98, "Yay0"] - - [0x1AD1E90, "Yay0"] - - [0x1AD2348, "Yay0"] - - [0x1AD27F8, "Yay0"] - - [0x1AD28A8, "Yay0"] - - [0x1AD44F0, "Yay0"] - - [0x1AD4758, "Yay0"] - - [0x1AD57C0, "Yay0"] - - [0x1AD9D50, "Yay0"] - - [0x1ADA498, "Yay0"] - - [0x1ADCFC0, "Yay0"] - - [0x1AE2168, "Yay0"] - - [0x1AE2EA0, "Yay0"] - - [0x1AE6A58, "Yay0"] - - [0x1AEB778, "Yay0"] - - [0x1AF4958, "Yay0"] - - [0x1AFCB18, "Yay0"] - - [0x1AFF748, "Yay0"] - - [0x1B00640, "Yay0"] - - [0x1B01390, "Yay0"] - - [0x1B01C08, "Yay0"] - - [0x1B02128, "Yay0"] - - [0x1B02970, "Yay0"] - - [0x1B03118, "Yay0"] - - [0x1B03C18, "Yay0"] - - [0x1B045E8, "Yay0"] - - [0x1B04FC0, "Yay0"] - - [0x1B05998, "Yay0"] - - [0x1B06C88, "Yay0"] - - [0x1B07C48, "Yay0"] - - [0x1B09440, "Yay0"] - - [0x1B0B290, "Yay0"] - - [0x1B0B9A0, "Yay0"] - - [0x1B0C548, "Yay0"] - - [0x1B0CAC0, "Yay0"] - - [0x1B0D130, "Yay0"] - - [0x1B0EB80, "Yay0"] - - [0x1B10CC0, "Yay0"] - - [0x1B129A0, "Yay0"] - - [0x1B13548, "Yay0"] - - [0x1B16420, "Yay0"] - - [0x1B17128, "Yay0"] - - [0x1B17840, "Yay0"] - - [0x1B19318, "Yay0"] - - [0x1B1A030, "Yay0"] - - [0x1B1B8C8, "Yay0"] - - [0x1B1BC88, "Yay0"] - - [0x1B1C7A0, "Yay0"] - - [0x1B1CD28, "Yay0"] - - [0x1B21C48, "Yay0"] - - [0x1B23290, "Yay0"] - - [0x1B253E0, "Yay0"] - - [0x1B26660, "Yay0"] - - [0x1B283F8, "Yay0"] - - [0x1B29C60, "Yay0"] - - [0x1B2A688, "Yay0"] - - [0x1B2B3E8, "Yay0"] - - [0x1B2C8D8, "Yay0"] - - [0x1B2D7B0, "Yay0"] - - [0x1B2E328, "Yay0"] - - [0x1B2ED60, "Yay0"] - - [0x1B2FA18, "Yay0"] - - [0x1B31A18, "Yay0"] - - [0x1B33000, "Yay0"] - - [0x1B34098, "Yay0"] - - [0x1B34928, "Yay0"] - - [0x1B34C00, "Yay0"] - - [0x1B35480, "Yay0"] - - [0x1B36440, "Yay0"] - - [0x1B38748, "Yay0"] - - [0x1B39A98, "Yay0"] - - [0x1B3A2E8, "Yay0"] - - [0x1B3A818, "Yay0"] - - [0x1B3C488, "Yay0"] - - [0x1B3CAC8, "Yay0"] - - [0x1B3D0A0, "Yay0"] - - [0x1B3D920, "Yay0"] - - [0x1B3F060, "Yay0"] - - [0x1B40048, "Yay0"] - - [0x1B40720, "Yay0"] - - [0x1B49570, "Yay0"] - - [0x1B4C3E8, "Yay0"] - - [0x1B4DEA0, "Yay0"] - - [0x1B4FD98, "Yay0"] - - [0x1B50CD8, "Yay0"] - - [0x1B51B08, "Yay0"] - - [0x1B54258, "Yay0"] - - [0x1B580A0, "Yay0"] - - [0x1B5A248, "Yay0"] - - [0x1B5BB88, "Yay0"] - - [0x1B5CC90, "Yay0"] - - [0x1B5E968, "Yay0"] - - [0x1B5ED88, "Yay0"] - - [0x1B608C0, "Yay0"] - - [0x1B625F8, "Yay0"] - - [0x1B633D0, "Yay0"] - - [0x1B64878, "Yay0"] - - [0x1B657E0, "Yay0"] - - [0x1B65A08, "Yay0"] - - [0x1B65E50, "Yay0"] - - [0x1B66238, "Yay0"] - - [0x1B69580, "Yay0"] - - [0x1B6C318, "Yay0"] - - [0x1B6DD98, "Yay0"] - - [0x1B6F150, "Yay0"] - - [0x1B71618, "Yay0"] - - [0x1B72890, "Yay0"] - - [0x1B73B08, "Yay0"] - - [0x1B747B8, "Yay0"] - - [0x1B76E30, "Yay0"] - - [0x1B78EC0, "Yay0"] - - [0x1B79A20, "Yay0"] - - [0x1B79F08, "Yay0"] - - [0x1B7AA08, "Yay0"] - - [0x1B7B008, "Yay0"] - - [0x1B7BB50, "Yay0"] - - [0x1B7EC68, "Yay0"] - - [0x1B7FF48, "Yay0"] - - [0x1B81E88, "Yay0"] - - [0x1B82058, "Yay0"] - - [0x1B82202, "bin"] + - start: 0x19E67B8 + type: PaperMarioNpcSprites + files: + - name: world_goombario + frames: + - walk1 + - still + - walk2 + - pain + - headbonk + - still_copy1 + - still_copy2 + - jump + - talk1 + - talk2 + - jump_copy + - fall + - happy1 + - happy2 + - read_paper + palettes: + - default + - poisoned + - inactive + - electrified + - burnt + animations: + - still + - idle + - walk + - run + - jump + - fall + - headbonk # centered at 0,0,0 rather than at base of sprite + - pain + - talk + - celebrate + - read_paper + - world_kooper + - world_bombette + - world_parakarry + - world_bow + - world_watt + - world_sushi + - world_lakilester + - battle_goombario + - battle_kooper + - battle_bombette + - battle_parakarry + - battle_bow + - battle_watt + - battle_sushi + - battle_lakilester + - kooper_without_shell + - world_eldstar + - world_mamar + - world_skolar + - world_muskular + - world_misstar + - world_klevar + - world_kalmar + - battle_eldstar + - battle_mamar + - battle_skolar + - battle_muskular + - battle_misstar + - battle_klevar + - battle_kalmar + - twink + - jr_troopa + - spiked_jr_troopa + - spiked_para_jr_troopa + - mage_jr_troopa + - para_jr_troopa + - goomba + - spiked_goomba + - paragoomba + - koopa_troopa + - para_troopa + - fuzzy + - bob_omb + - bullet_bill + - bill_blaster + - monty_mole + - cleft + - pokey + - battle_bandit + - buzzy_beetle + - swooper + - stone_chomp + - putrid_piranha + - piranha_plant + - sentinel + - world_clubba + - battle_clubba + - shy_guy + - groove_guy + - sky_guy + - pyro_guy + - spy_guy + - medi_guy + - fuzzipede + - jungle_guy + - heart_plant + - hurt_plant + - m_bush + - bubble + - kent_c_koopa + - dayzee + - lakitu + - spiny + - bzzap + - ruff_puff + - spike_top + - duplighost + - albino_dino + - blooper + - baby_blooper + - gulpit + - dry_bones + - thrown_bone + - bony_beetle + - magikoopa + - flying_magikoopa + - world_koopatrol + - koopatrol + - hammer_bros + - bush_basic + - bush_blocky + - bush_dry + - bush_leafy + - bush_matted + - world_kammy + - battle_kammy + - goomba_bros + - goomba_king + - spiky_goomnut + - dark_toad + - koopa_bros + - buzzar + - tutankoopa + - chain_chomp + - world_tubba + - battle_tubba + - tubbas_heart + - big_lantern_ghost + - shy_squad_guy + - marshal_guy + - stilt_guy + - stilt_guy_unfold + - shy_stack_guy + - shy_stack_unfold + - shy_stack_damage + - shy_stack_rock + - general_guy + - general_guy_bomb + - tank_guy + - lava_piranha_head + - petit_piranha + - lava_bud + - huff_n_puff + - tuff_puff + - monstar + - crystal_king + - world_bowser + - battle_bowser + - luigi + - toad + - three_sisters + - vanna_t + - toad_kid + - toad_guard + - harry_t + - toad_minister + - postmaster + - conductor_toad + - train_station_toad + - fishmael + - artist_toad + - koopa + - koopa_without_shell + - world_bob_omb + - whacka + - dryite + - mouser + - boo + - yoshi + - yoshi_kid + - raven + - bubulb + - penguin + - shiver_toad + - world_bandit + - goompapa + - goombaria + - goomama + - goompa + - goomma + - the_master + - chan + - lee + - merlon + - chet_rippo + - rowf + - minh_t + - russ_t + - tayce_t + - fice_t + - bartender + - chanterelle + - rip_cheato + - chuck_quizmo + - merluvlee + - merlar + - merlow + - star_kid + - kolorado_wife + - koopa_koot + - kolorado + - battle_kolorado + - archeologist + - nomadimouse + - world_merlee + - battle_merlee + - disguised_moustafa + - moustafa + - oaklie + - bootler + - yakkey + - gourmet_guy + - village_leader + - leaders_friend + - rafael_raven + - tolielup + - gate_flower + - petunia + - posie + - lily + - rosie + - sun + - lakilulu + - ninji + - mayor_penguin + - mayor_penguin_wife + - penguin_patrol + - herringway + - merle + - star_rod + - fire + - coin + - parade_peach + - parade_koopas + - parade_burnt_bowser + - parade_luigi + - parade_partners + - parade_yoshis + - parada_kolorados + - parade_chicks + - parade_ice_show + - parade_toads + - parade_batons + - parade_drums + - parade_flags + - parade_horns + - parade_tubba_balloon + - parade_wizards + - parade_mario + - parade_shy_guys + - parade_twink + - leaf + - [0x1B82208, bin] - start: 0x1B83000 type: PaperMarioMessages files: From e0daee1bb8df2eecc58382fa551f8d3731afc483 Mon Sep 17 00:00:00 2001 From: Alex Bates <16batesa@gmail.com> Date: Wed, 11 Nov 2020 16:33:55 +0000 Subject: [PATCH 3/4] generate sprite animation headers --- .gitignore | 1 + Makefile | 24 +-- include/enums.h | 235 ----------------------------- include/map.h | 6 +- include/types.h | 3 + src/world/area_kmr/kmr_12/events.c | 41 ++--- tools/compile_npc_sprites.py | 2 - tools/gen_sprite_animations_h.py | 44 ++++++ tools/n64splat | 2 +- tools/splat.yaml | 65 +++++++- 10 files changed, 149 insertions(+), 274 deletions(-) create mode 100755 tools/gen_sprite_animations_h.py diff --git a/.gitignore b/.gitignore index 142a6f16dd..3301686d06 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ settings.mk /build/ /docs/doxygen/ /include/ld_addrs.h +/include/sprite/ # Assets /bin diff --git a/Makefile b/Makefile index 7b8d121758..0bb422ad1d 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ LD_MAP := $(BUILD_DIR)/$(TARGET).map ASSETS_BIN := $(BUILD_DIR)/bin/assets/assets.bin MSG_BIN := $(BUILD_DIR)/msg.bin NPC_BIN := $(BUILD_DIR)/sprite/npc.bin -GENERATED_HEADERS := include/ld_addrs.h include/npc_animations.h +GENERATED_HEADERS := include/ld_addrs.h include/sprite ### Tools ### @@ -137,7 +137,7 @@ $(BUILD_DIR)/%.c.o: %.c $(MDEPS) | $(GENERATED_HEADERS) $(CPP) $(CPPFLAGS) -o - $(CPPMFLAGS) $< | iconv --from UTF-8 --to SHIFT-JIS | $(CC) $(CFLAGS) -o - | $(OLD_AS) $(OLDASFLAGS) -o $@ - # Compile C files (with DSL macros) -$(foreach cfile, $(DSL_C_FILES), $(BUILD_DIR)/$(cfile).o): $(BUILD_DIR)/%.c.o: %.c $(MDEPS) tools/compile_dsl_macros.py | include/ld_addrs.h +$(foreach cfile, $(DSL_C_FILES), $(BUILD_DIR)/$(cfile).o): $(BUILD_DIR)/%.c.o: %.c $(MDEPS) tools/compile_dsl_macros.py | $(GENERATED_HEADERS) @mkdir -p $(shell dirname $@) $(CPP) $(CPPFLAGS) -o - $< $(CPPMFLAGS) | $(PYTHON) tools/compile_dsl_macros.py | iconv --from UTF-8 --to SHIFT-JIS | $(CC) $(CFLAGS) -o - | $(OLD_AS) $(OLDASFLAGS) -o $@ - @@ -202,19 +202,23 @@ $(MSG_BIN:.bin=.o): $(MSG_BIN) $(LD) -r -b binary -o $@ $< # Sprites -$(foreach npc, $(NPC_SPRITES), $(eval sprite/npc/$(npc): $(shell find sprite/npc/$(npc) -type f))) # dependencies -NPC_DIRS := $(foreach npc, $(NPC_SPRITES), $(BUILD_DIR)/sprite/npc/$(npc)) -$(BUILD_DIR)/sprite/npc/%: sprite/npc/% +$(foreach npc, $(NPC_SPRITES), $(eval $(BUILD_DIR)/sprite/npc/$(npc):: $(shell find sprite/npc/$(npc) -type f))) # dependencies +NPC_DIRS := $(foreach npc, $(NPC_SPRITES), sprite/npc/$(npc)) +NPC_YAY0 := $(foreach npc, $(NPC_SPRITES), $(BUILD_DIR)/sprite/npc/$(npc).Yay0) +$(BUILD_DIR)/sprite/npc/%:: sprite/npc/% tools/compile_npc_sprite.py @mkdir -p $(shell dirname $@) $(PYTHON) tools/compile_npc_sprite.py $@ $< -$(NPC_BIN): $(foreach dir, $(NPC_DIRS), $(dir).Yay0) tools/compile_npc_sprites.py +$(NPC_BIN): $(NPC_YAY0) tools/compile_npc_sprites.py @mkdir -p $(shell dirname $@) @echo "building $@" - @$(PYTHON) tools/compile_npc_sprites.py $@ $(foreach dir, $(NPC_DIRS), $(dir).Yay0) + @$(PYTHON) tools/compile_npc_sprites.py $@ $(NPC_YAY0) $(NPC_BIN:.bin=.o): $(NPC_BIN) $(LD) -r -b binary -o $@ $< -include/npc_animations.h: $(NPC_DIRS) - @echo "TODO" +include/sprite/npc/%.h: sprite/npc/%/SpriteSheet.xml tools/gen_sprite_animations_h.py + @mkdir -p $(shell dirname $@) + @echo "building $@" + @$(PYTHON) tools/gen_sprite_animations_h.py $@ sprite/npc/$* $(NPC_DIRS) +include/sprite: $(foreach dir, $(NPC_DIRS), include/$(dir).h) $(LD_SCRIPT): $(SPLAT_YAML) $(SPLAT) --modes ld @@ -240,7 +244,7 @@ include/ld_addrs.h: $(BUILD_DIR)/$(LD_SCRIPT) ### Make Settings ### -.PHONY: clean test setup submodules split $(ROM) +.PHONY: clean test setup submodules split $(ROM) include/sprite .DELETE_ON_ERROR: .SECONDARY: .PRECIOUS: $(ROM) %.Yay0 diff --git a/include/enums.h b/include/enums.h index 4669f119bf..02c49eca46 100644 --- a/include/enums.h +++ b/include/enums.h @@ -25,241 +25,6 @@ typedef s8 PartnerId; #define PartnerId_GOOMBARIA 0x0A #define PartnerId_TWINK 0x0B -typedef UNK_TYPE SpriteId; -#define SpriteId_WORLD_GOOMBARIO 0x00000001 -#define SpriteId_WORLD_KOOPER 0x00000002 -#define SpriteId_WORLD_BOMBETTE 0x00000003 -#define SpriteId_WORLD_PARAKARRY 0x00000004 -#define SpriteId_WORLD_BOW 0x00000005 -#define SpriteId_WORLD_WATT 0x00000006 -#define SpriteId_WORLD_SUSHI 0x00000007 -#define SpriteId_WORLD_LAKILESTER 0x00000008 -#define SpriteId_BATTLE_GOOMBARIO 0x00000009 -#define SpriteId_BATTLE_KOOPER 0x0000000A -#define SpriteId_BATTLE_BOMBETTE 0x0000000B -#define SpriteId_BATTLE_PARAKARRY 0x0000000C -#define SpriteId_BATTLE_BOW 0x0000000D -#define SpriteId_BATTLE_WATT 0x0000000E -#define SpriteId_BATTLE_SUSHI 0x0000000F -#define SpriteId_BATTLE_LAKILESTER 0x00000010 -#define SpriteId_KOOPER_WITHOUT_SHELL 0x00000011 -#define SpriteId_WORLD_ELDSTAR 0x00000012 -#define SpriteId_WORLD_MAMAR 0x00000013 -#define SpriteId_WORLD_SKOLAR 0x00000014 -#define SpriteId_WORLD_MUSKULAR 0x00000015 -#define SpriteId_WORLD_MISSTAR 0x00000016 -#define SpriteId_WORLD_KLEVAR 0x00000017 -#define SpriteId_WORLD_KALMAR 0x00000018 -#define SpriteId_BATTLE_ELDSTAR 0x00000019 -#define SpriteId_BATTLE_MAMAR 0x0000001A -#define SpriteId_BATTLE_SKOLAR 0x0000001B -#define SpriteId_BATTLE_MUSKULAR 0x0000001C -#define SpriteId_BATTLE_MISSTAR 0x0000001D -#define SpriteId_BATTLE_KLEVAR 0x0000001E -#define SpriteId_BATTLE_KALMAR 0x0000001F -#define SpriteId_TWINK 0x00000020 -#define SpriteId_JR_TROOPA 0x00000021 -#define SpriteId_SPIKED_JR_TROOPA 0x00000022 -#define SpriteId_SPIKED_PARA_JR_TROOPA 0x00000023 -#define SpriteId_MAGE_JR_TROOPA 0x00000024 -#define SpriteId_PARA_JR_TROOPA 0x00000025 -#define SpriteId_GOOMBA 0x00000026 -#define SpriteId_SPIKED_GOOMBA 0x00000027 -#define SpriteId_PARAGOOMBA 0x00000028 -#define SpriteId_KOOPA_TROOPA 0x00000029 -#define SpriteId_PARA_TROOPA 0x0000002A -#define SpriteId_FUZZY 0x0000002B -#define SpriteId_BOMBOMB 0x0000002C -#define SpriteId_BULLET_BILL 0x0000002D -#define SpriteId_BILL_BLASTER 0x0000002E -#define SpriteId_MONTY_MOLE 0x0000002F -#define SpriteId_CLEFT 0x00000030 -#define SpriteId_POKEY 0x00000031 -#define SpriteId_BANDIT 0x00000032 -#define SpriteId_BUZZY_BEETLE 0x00000033 -#define SpriteId_SWOOPER 0x00000034 -#define SpriteId_STONE_CHOMP 0x00000035 -#define SpriteId_PUTRID_PIRANHA 0x00000036 -#define SpriteId_PIRANHA_PLANT 0x00000037 -#define SpriteId_SENTINEL 0x00000038 -#define SpriteId_WORLD_CLUBBA 0x00000039 -#define SpriteId_BATTLE_CLUBBA 0x0000003A -#define SpriteId_SHY_GUY 0x0000003B -#define SpriteId_GROOVE_GUY 0x0000003C -#define SpriteId_SKY_GUY 0x0000003D -#define SpriteId_PYRO_GUY 0x0000003E -#define SpriteId_SPY_GUY 0x0000003F -#define SpriteId_MEDI_GUY 0x00000040 -#define SpriteId_FUZZIPEDE 0x00000041 -#define SpriteId_JUNGLE_GUY 0x00000042 -#define SpriteId_HEART_PLANT 0x00000043 -#define SpriteId_HURT_PLANT 0x00000044 -#define SpriteId_M_BUSH 0x00000045 -#define SpriteId_BUBBLE 0x00000046 -#define SpriteId_KENT_C_KOOPA 0x00000047 -#define SpriteId_DAYZEE 0x00000048 -#define SpriteId_LAKITU 0x00000049 -#define SpriteId_SPINY 0x0000004A -#define SpriteId_BZZAP 0x0000004B -#define SpriteId_RUFF_PUFF 0x0000004C -#define SpriteId_SPIKE_TOP 0x0000004D -#define SpriteId_DUPLIGHOST 0x0000004E -#define SpriteId_ALBINO_DINO 0x0000004F -#define SpriteId_BLOOPER 0x00000050 -#define SpriteId_BABY_BLOOPER 0x00000051 -#define SpriteId_GULPIT 0x00000052 -#define SpriteId_DRY_BONES 0x00000053 -#define SpriteId_THROWN_BONE 0x00000054 -#define SpriteId_BONY_BEETLE 0x00000055 -#define SpriteId_MAGIKOOPA 0x00000056 -#define SpriteId_FLYING_MAGIKOOPA 0x00000057 -#define SpriteId_WORLD_KOOPATROL 0x00000058 -#define SpriteId_KOOPATROL 0x00000059 -#define SpriteId_HAMMER_BROS 0x0000005A -#define SpriteId_BUSH_BASIC 0x0000005B -#define SpriteId_BUSH_BLOCKY 0x0000005C -#define SpriteId_BUSH_DRY 0x0000005D -#define SpriteId_BUSH_LEAFY 0x0000005E -#define SpriteId_BUSH_MATTED 0x0000005F -#define SpriteId_WORLD_KAMMY 0x00000060 -#define SpriteId_BATTLE_KAMMY 0x00000061 -#define SpriteId_GOOMBA_BROS 0x00000062 -#define SpriteId_GOOMBA_KING 0x00000063 -#define SpriteId_SPIKY_GOOMNUT 0x00000064 -#define SpriteId_DARK_TOAD 0x00000065 -#define SpriteId_KOOPA_BROS 0x00000066 -#define SpriteId_BUZZAR 0x00000067 -#define SpriteId_TUTANKOOPA 0x00000068 -#define SpriteId_CHAIN_CHOMP 0x00000069 -#define SpriteId_WORLD_TUBBA 0x0000006A -#define SpriteId_BATTLE_TUBBA 0x0000006B -#define SpriteId_TUBBAS_HEART 0x0000006C -#define SpriteId_BIG_LANTERN_GHOST 0x0000006D -#define SpriteId_SHY_SQUAD_GUY 0x0000006E -#define SpriteId_MARSHAL_GUY 0x0000006F -#define SpriteId_STILT_GUY 0x00000070 -#define SpriteId_STILT_GUY_UNFOLD 0x00000071 -#define SpriteId_SHY_STACK_GUY 0x00000072 -#define SpriteId_SHY_STACK_UNFOLD 0x00000073 -#define SpriteId_SHY_STACK_DAMAGE 0x00000074 -#define SpriteId_SHY_STACK_ROCK 0x00000075 -#define SpriteId_GENERAL_GUY 0x00000076 -#define SpriteId_GENERAL_GUY_BOMB 0x00000077 -#define SpriteId_TANK_GUY 0x00000078 -#define SpriteId_LAVA_PIRANHA_HEAD 0x00000079 -#define SpriteId_PETIT_PIRANHA 0x0000007A -#define SpriteId_LAVA_BUD 0x0000007B -#define SpriteId_HUFF_N_PUFF 0x0000007C -#define SpriteId_TUFF_PUFF 0x0000007D -#define SpriteId_MONSTAR 0x0000007E -#define SpriteId_CRYSTAL_KING 0x0000007F -#define SpriteId_WORLD_BOWSER 0x00000080 -#define SpriteId_BATTLE_BOWSER 0x00000081 -#define SpriteId_LUIGI 0x00000082 -#define SpriteId_TOAD 0x00000083 -#define SpriteId_THREE_SISTERS 0x00000084 -#define SpriteId_VANNA_T 0x00000085 -#define SpriteId_TOAD_KID 0x00000086 -#define SpriteId_TOAD_GUARD 0x00000087 -#define SpriteId_HARRY_T 0x00000088 -#define SpriteId_TOAD_MINISTER 0x00000089 -#define SpriteId_POSTMASTER 0x0000008A -#define SpriteId_CONDUCTOR_TOAD 0x0000008B -#define SpriteId_TRAIN_STATION_TOAD 0x0000008C -#define SpriteId_FISHMAEL 0x0000008D -#define SpriteId_ARTIST_TOAD 0x0000008E -#define SpriteId_KOOPA 0x0000008F -#define SpriteId_KOOPA_WITHOUT_SHELL 0x00000090 -#define SpriteId_WORLD_BOMBOMB 0x00000091 -#define SpriteId_WHACKA 0x00000092 -#define SpriteId_DRYITE 0x00000093 -#define SpriteId_MOUSER 0x00000094 -#define SpriteId_BOO 0x00000095 -#define SpriteId_YOSHI 0x00000096 -#define SpriteId_YOSHI_KID 0x00000097 -#define SpriteId_RAVEN 0x00000098 -#define SpriteId_BUBULB 0x00000099 -#define SpriteId_PENGUIN 0x0000009A -#define SpriteId_SHIVER_TOAD 0x0000009B -#define SpriteId_ALT_BANDIT 0x0000009C -#define SpriteId_GOOMPAPA 0x0000009D -#define SpriteId_GOOMBARIA 0x0000009E -#define SpriteId_GOOMAMA 0x0000009F -#define SpriteId_GOOMPA 0x000000A0 -#define SpriteId_GOOMMA 0x000000A1 -#define SpriteId_THE_MASTER 0x000000A2 -#define SpriteId_CHAN 0x000000A3 -#define SpriteId_LEE 0x000000A4 -#define SpriteId_MERLON 0x000000A5 -#define SpriteId_CHET_RIPPO 0x000000A6 -#define SpriteId_ROWF 0x000000A7 -#define SpriteId_MINH_T 0x000000A8 -#define SpriteId_RUSS_T 0x000000A9 -#define SpriteId_TAYCE_T 0x000000AA -#define SpriteId_FICE_T 0x000000AB -#define SpriteId_BARTENDER 0x000000AC -#define SpriteId_CHANTERELLE 0x000000AD -#define SpriteId_RIP_CHEATO 0x000000AE -#define SpriteId_CHUCK_QUIZMO 0x000000AF -#define SpriteId_MERLUVLEE 0x000000B0 -#define SpriteId_MERLAR 0x000000B1 -#define SpriteId_MERLOW 0x000000B2 -#define SpriteId_STAR_KID 0x000000B3 -#define SpriteId_KOLORADO_WIFE 0x000000B4 -#define SpriteId_KOOPA_KOOT 0x000000B5 -#define SpriteId_KOLORADO 0x000000B6 -#define SpriteId_BATTLE_KOLORADO 0x000000B7 -#define SpriteId_ARCHEOLOGIST 0x000000B8 -#define SpriteId_NOMADIMOUSE 0x000000B9 -#define SpriteId_WORLD_MERLEE 0x000000BA -#define SpriteId_BATTLE_MERLEE 0x000000BB -#define SpriteId_DISGUISED_MOUSTAFA 0x000000BC -#define SpriteId_MOUSTAFA 0x000000BD -#define SpriteId_OAKLIE 0x000000BE -#define SpriteId_BOOTLER 0x000000BF -#define SpriteId_YAKKEY 0x000000C0 -#define SpriteId_GOURMET_GUY 0x000000C1 -#define SpriteId_VILLAGE_LEADER 0x000000C2 -#define SpriteId_LEADERS_FRIEND 0x000000C3 -#define SpriteId_RAFAEL_RAVEN 0x000000C4 -#define SpriteId_TOLIELUP 0x000000C5 -#define SpriteId_GATE_FLOWER 0x000000C6 -#define SpriteId_PETUNIA 0x000000C7 -#define SpriteId_POSIE 0x000000C8 -#define SpriteId_LILY 0x000000C9 -#define SpriteId_ROSIE 0x000000CA -#define SpriteId_SUN 0x000000CB -#define SpriteId_LAKILULU 0x000000CC -#define SpriteId_NINJI 0x000000CD -#define SpriteId_MAYOR_PENGUIN 0x000000CE -#define SpriteId_MAYOR_PENGUIN_WIFE 0x000000CF -#define SpriteId_PENGUIN_PATROL 0x000000D0 -#define SpriteId_HERRINGWAY 0x000000D1 -#define SpriteId_MERLE 0x000000D2 -#define SpriteId_STAR_ROD 0x000000D3 -#define SpriteId_FIRE 0x000000D4 -#define SpriteId_COIN 0x000000D5 -#define SpriteId_PARADE_PEACH 0x000000D6 -#define SpriteId_PARADE_KOOPAS 0x000000D7 -#define SpriteId_PARADE_BURNT_BOWSER 0x000000D8 -#define SpriteId_PARADE_LUIGI 0x000000D9 -#define SpriteId_PARADE_PARTNERS 0x000000DA -#define SpriteId_PARADE_YOSHIS 0x000000DB -#define SpriteId_PARADA_KOLORADOS 0x000000DC -#define SpriteId_PARADE_CHICKS 0x000000DD -#define SpriteId_PARADE_ICE_SHOW 0x000000DE -#define SpriteId_PARADE_TOADS 0x000000DF -#define SpriteId_PARADE_BATONS 0x000000E0 -#define SpriteId_PARADE_DRUMS 0x000000E1 -#define SpriteId_PARADE_FLAGS 0x000000E2 -#define SpriteId_PARADE_HORNS 0x000000E3 -#define SpriteId_PARADE_TUBBA_BALLOON 0x000000E4 -#define SpriteId_PARADE_WIZARDS 0x000000E5 -#define SpriteId_PARADE_MARIO 0x000000E6 -#define SpriteId_PARADE_SHY_GUYS 0x000000E7 -#define SpriteId_PARADE_TWINK 0x000000E8 -#define SpriteId_LEAF 0x000000E9 - typedef s32 SongID; #define Song_TOAD_TOWN 0x00000000 #define Song_NORMAL_BATTLE 0x00000002 diff --git a/include/map.h b/include/map.h index 8f17fd2fb6..79e58b73b8 100644 --- a/include/map.h +++ b/include/map.h @@ -163,8 +163,6 @@ typedef struct StatDrop { { F16(100), F16(30), attempts, F16(40) }, \ } -#define ANIMATION(sprite, palette, anim) ((sprite << 16) + (palette << 8) + anim) - #define OVERRIDE_MOVEMENT_SPEED(speed) (speed * 32767) #define NO_OVERRIDE_MOVEMENT_SPEED OVERRIDE_MOVEMENT_SPEED(-1) @@ -185,9 +183,9 @@ typedef struct StaticNPC { /* 0x0DC */ s16 maxCoinBonus; /* 0x0DE */ char unk_DE[2]; /* 0x0E0 */ s32 movement[48]; // TODO: type - /* 0x1A0 */ s32 animations[16]; + /* 0x1A0 */ NpcAnimID animations[16]; /* 0x1E0 */ char unk_1E0[8]; - /* 0x1E8 */ UNK_PTR extraAnimations; + /* 0x1E8 */ NpcAnimID* extraAnimations; /* 0x1EC */ MessageID tattle; } StaticNpc; // size = 0x1F0 diff --git a/include/types.h b/include/types.h index 298e297e4d..9721241a66 100644 --- a/include/types.h +++ b/include/types.h @@ -13,4 +13,7 @@ typedef s32 FormationID; #define FORMATION_ID(section, stage, index) ((section << 16) + (stage << 8) + index) +typedef s32 NpcAnimID; +#define NPC_ANIM(sprite, palette, anim) ((_NPC_SPRITE_##sprite << 16) + (_NPC_PALETTE_##sprite##_##palette << 8) + _NPC_ANIM_##sprite##_##anim) + #endif diff --git a/src/world/area_kmr/kmr_12/events.c b/src/world/area_kmr/kmr_12/events.c index dd6e0e3b3e..44e6095e23 100644 --- a/src/world/area_kmr/kmr_12/events.c +++ b/src/world/area_kmr/kmr_12/events.c @@ -1,4 +1,5 @@ #include "kmr_12.h" +#include "sprite/npc/goomba.h" Script M(ExitWest) = EXIT_WALK_SCRIPT(60, 0, "kmr_07", 1); Script M(ExitEast) = EXIT_WALK_SCRIPT(60, 1, "kmr_11", 0); @@ -85,7 +86,7 @@ Script M(GoombaIdle) = SCRIPT({ sleep 1 SetSelfVar(0, FALSE) - SetNpcAnimation(NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 13)) + SetNpcAnimation(NpcId_SELF, NPC_ANIM(goomba, normal, fake_mushroom)) // TODO: work out why palette 0 is used here EnableNpcShadow(NpcId_SELF, FALSE) SetSelfEnemyFlagBits(0x00000020, TRUE) @@ -104,15 +105,15 @@ Script M(GoombaIdle) = SCRIPT({ SetNpcRotation(NpcId_SELF, 0, SI_VAR(0), 0) sleep 1 } - SetNpcAnimation(NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 0)) + SetNpcAnimation(NpcId_SELF, NPC_ANIM(goomba, normal, still)) loop 9 { SI_VAR(0) += 10.0 SetNpcRotation(NpcId_SELF, 0, SI_VAR(0), 0) sleep 1 } - SetNpcAnimation(NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 7)) + SetNpcAnimation(NpcId_SELF, NPC_ANIM(goomba, normal, dizzy)) sleep 20 - SetNpcAnimation(NpcId_SELF, ANIMATION(SpriteId_GOOMBA, 0, 1)) + SetNpcAnimation(NpcId_SELF, NPC_ANIM(goomba, normal, idle)) PlaySoundAtNpc(NpcId_SELF, 248, 0) func_802CFE2C(NpcId_SELF, 8192) func_802CFD30(NpcId_SELF, 5, 6, 1, 1, 0) @@ -166,22 +167,22 @@ StaticNpc M(goombaNpc) = { /* flying? */ TRUE, }, .animations = { - ANIMATION(SpriteId_GOOMBA, 0, 1), - ANIMATION(SpriteId_GOOMBA, 0, 2), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 1), - ANIMATION(SpriteId_GOOMBA, 0, 1), - ANIMATION(SpriteId_GOOMBA, 0, 5), - ANIMATION(SpriteId_GOOMBA, 0, 5), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), - ANIMATION(SpriteId_GOOMBA, 0, 3), + NPC_ANIM(goomba, normal, idle), + NPC_ANIM(goomba, normal, walk), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, idle), + NPC_ANIM(goomba, normal, idle), + NPC_ANIM(goomba, normal, pain), + NPC_ANIM(goomba, normal, pain), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), + NPC_ANIM(goomba, normal, run), }, }; diff --git a/tools/compile_npc_sprites.py b/tools/compile_npc_sprites.py index 4f7f52ba1c..19bb8a82f8 100755 --- a/tools/compile_npc_sprites.py +++ b/tools/compile_npc_sprites.py @@ -23,8 +23,6 @@ if __name__ == "__main__": while f.tell() % 8 != 0: f.write(bytes([0])) - print(f"{0x19E67B8 + f.tell():X}") - offsets.append(f.tell()) f.seek(0) diff --git a/tools/gen_sprite_animations_h.py b/tools/gen_sprite_animations_h.py new file mode 100755 index 0000000000..d27a3e88f6 --- /dev/null +++ b/tools/gen_sprite_animations_h.py @@ -0,0 +1,44 @@ +#! /usr/bin/python3 + +from sys import argv, path +from pathlib import Path +import os +path.append(os.path.join(os.path.dirname(__file__), "n64splat")) +from n64splat.segtypes.PaperMarioNpcSprites import Sprite + +if __name__ == "__main__": + if len(argv) < 4: + print("usage: gen_sprite_animations_h.py [OUT] [DIR] [ALLDIRS]") + exit(1) + + _, outfile, sprite_dir, *alldirs = argv + + with open(outfile, "w") as f: + # get sprite index + s = alldirs.index(sprite_dir) + 1 + assert s >= 1 + + sprite_dir = Path(sprite_dir) + + sprite = Sprite.from_dir(sprite_dir, read_images=False) + sprite_name = sprite_dir.stem + + f.write(f"#ifndef _SPRITE_{sprite_name.upper()}_H_\n") + f.write(f"#define _SPRITE_{sprite_name.upper()}_H_\n") + f.write("\n") + f.write('#include "types.h"\n') + f.write("\n") + + f.write(f"#define _NPC_SPRITE_{sprite_name} 0x{s:02X}\n") + + seen_palette_names = set() + for p, palette_name in enumerate(sprite.palette_names): + if palette_name not in seen_palette_names: + seen_palette_names.add(palette_name) + f.write(f"#define _NPC_PALETTE_{sprite_name}_{palette_name} 0x{p:02X}\n") + + for a, name in enumerate(sprite.animation_names): + f.write(f"#define _NPC_ANIM_{sprite_name}_{name} 0x{a:02X}\n") + + f.write("\n") + f.write("#endif\n") diff --git a/tools/n64splat b/tools/n64splat index 0ff02cd473..686be7cf19 160000 --- a/tools/n64splat +++ b/tools/n64splat @@ -1 +1 @@ -Subproject commit 0ff02cd4734c26c7ae03aee4a0374a774b3b097b +Subproject commit 686be7cf19780b5dd619e0f51bb071f721b05b9a diff --git a/tools/splat.yaml b/tools/splat.yaml index c09f514197..fbbaf252cb 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -7043,7 +7043,7 @@ segments: - happy2 - read_paper palettes: - - default + - normal - poisoned - inactive - electrified @@ -7096,7 +7096,68 @@ segments: - spiked_para_jr_troopa - mage_jr_troopa - para_jr_troopa - - goomba + - name: goomba + frames: + - still + - lean_left + - lean_right + - pain1 + - pain2 + - jump + - open_mouth + - open_mouth_wide + - sleep + - dizzy1 + - dizzy2 + - dizzy3 + - dizzy4 + - burn_pain1 + - burn_pain2 + - burn_dead + - tense + - fake_plant + - fake_mushroom + - electrocute + palettes: + - normal + - red # unused + - hyper + - blue # unused + - gloomba + - poisoned + - poisoned + - poisoned + - poisoned + - poisoned + - unk_purple_status + - unk_purple_status + - unk_purple_status + - unk_purple_status + - unk_purple_status + - electrified + - electrified + - electrified + - electrified + - electrified + - burnt + - fake_mushroom + - fake_plant + animations: + - still + - idle + - walk + - run + - headbonk # centered at 0,0,0 rather than at base of sprite + - pain + - dead + - dizzy + - asleep + - burn_pain + - burn_dead + - pre_headbonk # centered at 0,0,0 rather than at base of sprite + - fake_plant + - fake_mushroom + - electrocute - spiked_goomba - paragoomba - koopa_troopa From 744b12ebe6b6cad4866596c290b8277803685de9 Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Thu, 19 Nov 2020 09:54:36 +0000 Subject: [PATCH 4/4] split 0x1E00000 extra sprites bin --- tools/splat.yaml | 1 + tools/splat_ext/PaperMarioNpcSprites.py | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/splat.yaml b/tools/splat.yaml index a71fd3b031..a87605a9b8 100644 --- a/tools/splat.yaml +++ b/tools/splat.yaml @@ -7411,6 +7411,7 @@ segments: - quiz/options - end/credits - [0x1C84D30, bin] + - [0x1E00000, bin] # sprites here; Star Rod considers this a copy of sprite/npc.bin, but that doesnt appear to be true - [0x1E40000, PaperMarioMapFS] - [0x27FEE22, "bin"] - [0x2800000] diff --git a/tools/splat_ext/PaperMarioNpcSprites.py b/tools/splat_ext/PaperMarioNpcSprites.py index 4097955232..718b6a0e3d 100644 --- a/tools/splat_ext/PaperMarioNpcSprites.py +++ b/tools/splat_ext/PaperMarioNpcSprites.py @@ -1,4 +1,3 @@ -import os from segtypes.segment import N64Segment from pathlib import Path from util import Yay0decompress