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] 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