From 5e593a62fbfb631068772d1589d556c8a998142e Mon Sep 17 00:00:00 2001 From: Martin Griffin Date: Fri, 19 Aug 2022 04:07:25 +0100 Subject: [PATCH] Ignore num_tiles if it would truncate non-transparent tiles (#1729) --- graphics/battle_transitions/rayquaza.png | Bin 2308 -> 2074 bytes graphics/battle_transitions/regis.png | Bin 231 -> 256 bytes graphics/picture_frame/lobby.png | Bin 666 -> 719 bytes graphics_file_rules.mk | 222 +++++++++++------------ tools/gbagfx/gfx.c | 32 +++- tools/gbagfx/gfx.h | 8 +- tools/gbagfx/main.c | 9 +- tools/gbagfx/options.h | 2 + 8 files changed, 154 insertions(+), 119 deletions(-) diff --git a/graphics/battle_transitions/rayquaza.png b/graphics/battle_transitions/rayquaza.png index 5c3a914749b5f85021200c247847848369b313e9..00df7d741515db4ec8447efa05ff6ea1d47782ad 100644 GIT binary patch delta 2072 zcmV+z2i}2c=0wK~#9!?VK@k-8K-0i3@13 zRU)PEj4qIw=m0LFK221oirRE}r6=9MO94JH0XsI}mIvru zaK~|C=Yl1@&?wVCbuMszT}>)rQ_nor7b8Hm;C?J{6nJ71aO48Iy4q=&uuB4*7VL&T z#TxMS1mL(}hkv>h)xy_P0BV6dsCW0H*T-ugfL&ng?~EgcTKIYbKrPViw_{3Qj)38M z0GJyHpkJz?2Q|Sw7GEpC4;Y}Hii_KAOB!4sy8m0k;Tn=L14*aDM@w3+`P2zI8MKVBKcqXg{|A z&@>;{YiQe@8I?mHDN}$SCn7DNy9FAs_5l?FoKM_j-yRK6bvwWxFEn77Q0=t?ur9!W zbqDBMKmdG-0MQ&pC@PF^b3w7&f1n>u+1;Cfp$_3bXp>ACa;psL8P##zr34Xlr0m10g^`VvE#|sib zcY%@M#|u&uxbe<1zCW*^c%h2^ z8Ug^+?;-#>=5 z24Jl#wlD?Y$u{Mk#~jWNKL1Nd@z zIX?dE%mdtn0IwZDdx<2R83{eWb-@VeXMeT<@Gp|^w~;Uanjl~#v=IqO!0U~PFcuJy zpbK_$NeFP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NOYQNPFQ zNMfgz^0+>)Qc*h%Ua$pB&Ig_*68L|VZw7&18EfE(+c&ru2KWx(;7##$<-3;6=VN6D zp$67o6!)E3)_`Wx?|t&hI(L4J)iYj%|%Op_iqvJ&S1j20bv>$R0G?bh<>FdUApM{U)7!{V)^Z2R07WW^>uzIn>8j3 ziQNbS64OFXv;a+Aq}O^hz833gBKV~SRf-3S979t~w;7)iXxHucIxQmzT#aHG%8(DA z;wRBNwH#!Mw2wdjC4wV!Q7-$YlilIV^{pGs({8_bQN+>guE2Z}GFnGO__^hBg$Dgv z!Zn?;biz(|SeJfCJrF?v`x{qbyUhf#d_q zBtx%fwh|=codec~!Dh%=*z_h*+TUbgF-!<{3%`(5%hBKNOb9dx(!{NIwpQt-8x?)O zT%T4;HH=2L;&c0?EtpVaWwXo8zRI%q$L?;N3H@2g z6Br+@TlZWg28#fL$AKlD)uM+M%1*c}bgr~$Pe_9Vj+GCe$5kokSEWF=lSolxWILqP z2&o#J2wWeUS5y)#CWSDr`RCr6pn5sae}QqWu{`gi3wl%zB{?p2wHtgQDzL)ip1mfu z$6-Tq1`g%;Ho61_L{*6#1E1t+r|%c&z;i>F0Vauo7Be6mYj&$jr$9NowFX$fso@J+ z1a5644>8{=JVZF7B*o_JwPVoFv-|EjAWiH2rH=-nqwoOqbDS4qc*|M5@aXy>B`nA&CC zrAx=s-B7bbe@M5b?olyNoz!|4)(WF(O=j*ZaW4b9$KCJm8N!sD7oRu@C1$ECMwh71 XK88E{zfJ4-Z}05h>E>|TjwkpR*N^R3 diff --git a/graphics/battle_transitions/regis.png b/graphics/battle_transitions/regis.png index a0831073746388464d2a66d223c6d51f3a4d5d78..4926b165b75f73f915aeadab416d23942e95a6ee 100644 GIT binary patch delta 239 zcmVi}0Ey;Ma)r p04Ea8M4rmH7kD%AZshGOVh5LV7pxn662kxh002ovPDHLkV1mF9YF_{V delta 214 zcmV;{04e`~0_Opc8Gir(0026Xu z@7p*HO#g-X-#9%F9uuh`aXNV>5i}0$N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*0dNU5z@!>@*~D@{ z)B=7APzCU4mH<7mkhK*+TEUp$GHWN87ROPw0{8(b1pN|K9mFbkw(C7t+TrH zbjpGJP$i&htd{|WvEGOAlxupE-Y|rb6#g+nE^*EtUIx22H@j7 z<_frdc8?8hbKd`5s*L8HU~gH?f1{J0}zK&#$gvg#G&}VK-VQaYFMy diff --git a/graphics_file_rules.mk b/graphics_file_rules.mk index 42b1e6d74..3335179d1 100644 --- a/graphics_file_rules.mk +++ b/graphics_file_rules.mk @@ -64,31 +64,31 @@ $(CASTFORMGFXDIR)/shiny.gbapal: $(CASTFORMGFXDIR)/shiny_normal_form.gbapal \ ### Tilesets ### $(TILESETGFXDIR)/secondary/petalburg/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 159 + $(GFX) $< $@ -num_tiles 159 -Wnum_tiles $(TILESETGFXDIR)/secondary/rustboro/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 498 + $(GFX) $< $@ -num_tiles 498 -Wnum_tiles $(TILESETGFXDIR)/secondary/dewford/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 503 + $(GFX) $< $@ -num_tiles 503 -Wnum_tiles $(TILESETGFXDIR)/secondary/slateport/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 504 + $(GFX) $< $@ -num_tiles 504 -Wnum_tiles $(TILESETGFXDIR)/secondary/mauville/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 503 + $(GFX) $< $@ -num_tiles 503 -Wnum_tiles $(TILESETGFXDIR)/secondary/lavaridge/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 450 + $(GFX) $< $@ -num_tiles 450 -Wnum_tiles $(TILESETGFXDIR)/secondary/fortree/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 493 + $(GFX) $< $@ -num_tiles 493 -Wnum_tiles $(TILESETGFXDIR)/secondary/pacifidlog/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 504 + $(GFX) $< $@ -num_tiles 504 -Wnum_tiles $(TILESETGFXDIR)/secondary/sootopolis/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 328 + $(GFX) $< $@ -num_tiles 328 -Wnum_tiles SOOTOPOLISANIMDIR := $(TILESETGFXDIR)/secondary/sootopolis/anim @@ -125,169 +125,169 @@ $(SOOTOPOLISANIMDIR)/stormy_water/7.4bpp: $(SOOTOPOLISANIMDIR)/stormy_water/7_ky @cat $^ >$@ $(TILESETGFXDIR)/secondary/battle_frontier_outside_west/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 508 + $(GFX) $< $@ -num_tiles 508 -Wnum_tiles $(TILESETGFXDIR)/secondary/battle_frontier_outside_east/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 508 + $(GFX) $< $@ -num_tiles 508 -Wnum_tiles $(TILESETGFXDIR)/primary/building/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 502 + $(GFX) $< $@ -num_tiles 502 -Wnum_tiles $(TILESETGFXDIR)/secondary/shop/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 502 + $(GFX) $< $@ -num_tiles 502 -Wnum_tiles $(TILESETGFXDIR)/secondary/pokemon_center/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 478 + $(GFX) $< $@ -num_tiles 478 -Wnum_tiles $(TILESETGFXDIR)/secondary/cave/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 425 + $(GFX) $< $@ -num_tiles 425 -Wnum_tiles $(TILESETGFXDIR)/secondary/pokemon_school/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 278 + $(GFX) $< $@ -num_tiles 278 -Wnum_tiles $(TILESETGFXDIR)/secondary/pokemon_fan_club/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 319 + $(GFX) $< $@ -num_tiles 319 -Wnum_tiles $(TILESETGFXDIR)/secondary/unused_1/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 17 + $(GFX) $< $@ -num_tiles 17 -Wnum_tiles $(TILESETGFXDIR)/secondary/meteor_falls/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 460 + $(GFX) $< $@ -num_tiles 460 -Wnum_tiles $(TILESETGFXDIR)/secondary/oceanic_museum/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 319 + $(GFX) $< $@ -num_tiles 319 -Wnum_tiles $(TILESETGFXDIR)/secondary/cable_club/unknown_tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 120 + $(GFX) $< $@ -num_tiles 120 -Wnum_tiles $(TILESETGFXDIR)/secondary/seashore_house/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 312 + $(GFX) $< $@ -num_tiles 312 -Wnum_tiles $(TILESETGFXDIR)/secondary/pretty_petal_flower_shop/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 345 + $(GFX) $< $@ -num_tiles 345 -Wnum_tiles $(TILESETGFXDIR)/secondary/pokemon_day_care/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 355 + $(GFX) $< $@ -num_tiles 355 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/brown_cave/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/brown_cave/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/tree/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/tree/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/shrub/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/shrub/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/blue_cave/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/blue_cave/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/yellow_cave/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/yellow_cave/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/red_cave/unused_tiles.4bpp: $(TILESETGFXDIR)/secondary/secret_base/red_cave/tiles.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/brown_cave/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/tree/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/shrub/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/blue_cave/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/yellow_cave/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/secret_base/red_cave/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 83 + $(GFX) $< $@ -num_tiles 83 -Wnum_tiles $(TILESETGFXDIR)/secondary/inside_of_truck/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 62 + $(GFX) $< $@ -num_tiles 62 -Wnum_tiles $(TILESETGFXDIR)/secondary/contest/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 430 + $(GFX) $< $@ -num_tiles 430 -Wnum_tiles $(TILESETGFXDIR)/secondary/lilycove_museum/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 431 + $(GFX) $< $@ -num_tiles 431 -Wnum_tiles $(TILESETGFXDIR)/secondary/lab/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 500 + $(GFX) $< $@ -num_tiles 500 -Wnum_tiles $(TILESETGFXDIR)/secondary/underwater/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 500 + $(GFX) $< $@ -num_tiles 500 -Wnum_tiles $(TILESETGFXDIR)/secondary/generic_building/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 509 + $(GFX) $< $@ -num_tiles 509 -Wnum_tiles $(TILESETGFXDIR)/secondary/mauville_game_corner/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 469 + $(GFX) $< $@ -num_tiles 469 -Wnum_tiles $(TILESETGFXDIR)/secondary/unused_2/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 150 + $(GFX) $< $@ -num_tiles 150 -Wnum_tiles $(TILESETGFXDIR)/secondary/rustboro_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 60 + $(GFX) $< $@ -num_tiles 60 -Wnum_tiles $(TILESETGFXDIR)/secondary/dewford_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 61 + $(GFX) $< $@ -num_tiles 61 -Wnum_tiles $(TILESETGFXDIR)/secondary/lavaridge_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 54 + $(GFX) $< $@ -num_tiles 54 -Wnum_tiles $(TILESETGFXDIR)/secondary/petalburg_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 148 + $(GFX) $< $@ -num_tiles 148 -Wnum_tiles $(TILESETGFXDIR)/secondary/fortree_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 61 + $(GFX) $< $@ -num_tiles 61 -Wnum_tiles $(TILESETGFXDIR)/secondary/mossdeep_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 82 + $(GFX) $< $@ -num_tiles 82 -Wnum_tiles $(TILESETGFXDIR)/secondary/sootopolis_gym/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 484 + $(GFX) $< $@ -num_tiles 484 -Wnum_tiles $(TILESETGFXDIR)/secondary/trick_house_puzzle/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 294 + $(GFX) $< $@ -num_tiles 294 -Wnum_tiles $(TILESETGFXDIR)/secondary/inside_ship/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 342 + $(GFX) $< $@ -num_tiles 342 -Wnum_tiles $(TILESETGFXDIR)/secondary/elite_four/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 505 + $(GFX) $< $@ -num_tiles 505 -Wnum_tiles $(TILESETGFXDIR)/secondary/battle_frontier/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 310 + $(GFX) $< $@ -num_tiles 310 -Wnum_tiles $(TILESETGFXDIR)/secondary/battle_factory/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 424 + $(GFX) $< $@ -num_tiles 424 -Wnum_tiles $(TILESETGFXDIR)/secondary/battle_pike/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 382 + $(GFX) $< $@ -num_tiles 382 -Wnum_tiles $(TILESETGFXDIR)/secondary/mirage_tower/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 420 + $(GFX) $< $@ -num_tiles 420 -Wnum_tiles $(TILESETGFXDIR)/secondary/mossdeep_game_corner/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 95 + $(GFX) $< $@ -num_tiles 95 -Wnum_tiles $(TILESETGFXDIR)/secondary/island_harbor/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 503 + $(GFX) $< $@ -num_tiles 503 -Wnum_tiles $(TILESETGFXDIR)/secondary/trainer_hill/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 374 + $(GFX) $< $@ -num_tiles 374 -Wnum_tiles $(TILESETGFXDIR)/secondary/navel_rock/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 420 + $(GFX) $< $@ -num_tiles 420 -Wnum_tiles $(TILESETGFXDIR)/secondary/battle_frontier_ranking_hall/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 136 + $(GFX) $< $@ -num_tiles 136 -Wnum_tiles $(TILESETGFXDIR)/secondary/mystery_events_house/tiles.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 509 + $(GFX) $< $@ -num_tiles 509 -Wnum_tiles @@ -335,13 +335,13 @@ graphics/title_screen/pokemon_logo.gbapal: %.gbapal: %.pal $(GFX) $< $@ -num_colors 224 graphics/pokemon_jump/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 63 + $(GFX) $< $@ -num_tiles 63 -Wnum_tiles graphics/pokenav/region_map.8bpp: %.8bpp: %.png - $(GFX) $< $@ -num_tiles 233 + $(GFX) $< $@ -num_tiles 233 -Wnum_tiles $(MISCGFXDIR)/japanese_hof.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 29 + $(GFX) $< $@ -num_tiles 29 -Wnum_tiles $(BATINTGFXDIR)/textbox.gbapal: $(BATINTGFXDIR)/textbox_0.gbapal \ $(BATINTGFXDIR)/textbox_1.gbapal @@ -385,10 +385,10 @@ $(UNUSEDGFXDIR)/redyellowgreen_frame.bin: $(UNUSEDGFXDIR)/red_frame.bin \ @cat $^ >$@ $(UNUSEDGFXDIR)/color_frames.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 353 + $(GFX) $< $@ -num_tiles 353 -Wnum_tiles $(BATINTGFXDIR)/unused_window2bar.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 5 + $(GFX) $< $@ -num_tiles 5 -Wnum_tiles $(JPCONTESTGFXDIR)/composite_1.4bpp: $(JPCONTESTGFXDIR)/frame_1.4bpp \ $(JPCONTESTGFXDIR)/floor.4bpp \ @@ -404,7 +404,7 @@ $(JPCONTESTGFXDIR)/composite_2.4bpp: $(JPCONTESTGFXDIR)/interface.4bpp \ @cat $^ >$@ $(JPCONTESTGFXDIR)/voltage.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 36 + $(GFX) $< $@ -num_tiles 36 -Wnum_tiles $(BTLANMSPRGFXDIR)/ice_crystals.4bpp: $(BTLANMSPRGFXDIR)/ice_crystals_0.4bpp \ $(BTLANMSPRGFXDIR)/ice_crystals_1.4bpp \ @@ -426,13 +426,13 @@ $(BTLANMSPRGFXDIR)/spark.4bpp: $(BTLANMSPRGFXDIR)/spark_0.4bpp \ @cat $^ >$@ $(MASKSGFXDIR)/unused_level_up.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 14 + $(GFX) $< $@ -num_tiles 14 -Wnum_tiles $(BATTRANSGFXDIR)/vs_frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 16 + $(GFX) $< $@ -num_tiles 16 -Wnum_tiles graphics/party_menu/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 62 + $(GFX) $< $@ -num_tiles 62 -Wnum_tiles $(TYPESGFXDIR)/move_types.4bpp: $(types:%=$(TYPESGFXDIR)/%.4bpp) $(contest_types:%=$(TYPESGFXDIR)/contest_%.4bpp) @cat $^ >$@ @@ -443,29 +443,29 @@ $(TYPESGFXDIR)/move_types.gbapal: $(TYPESGFXDIR)/move_types_1.gbapal \ @cat $^ >$@ graphics/bag/menu.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 53 + $(GFX) $< $@ -num_tiles 53 -Wnum_tiles $(RAYQUAZAGFXDIR)/scene_2/rayquaza.8bpp: %.8bpp: %.png - $(GFX) $< $@ -num_tiles 227 + $(GFX) $< $@ -num_tiles 227 -Wnum_tiles $(RAYQUAZAGFXDIR)/scene_2/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 313 + $(GFX) $< $@ -num_tiles 313 -Wnum_tiles $(RAYQUAZAGFXDIR)/scene_3/rayquaza.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 124 + $(GFX) $< $@ -num_tiles 124 -Wnum_tiles $(RAYQUAZAGFXDIR)/scene_3/rayquaza_tail_fix.4bpp: $(RAYQUAZAGFXDIR)/scene_3/rayquaza_tail.4bpp cp $< $@ head -c 12 /dev/zero >> $@ $(RAYQUAZAGFXDIR)/scene_4/streaks.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 19 + $(GFX) $< $@ -num_tiles 19 -Wnum_tiles $(RAYQUAZAGFXDIR)/scene_4/rayquaza.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 155 + $(GFX) $< $@ -num_tiles 155 -Wnum_tiles graphics/picture_frame/lobby.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 86 + $(GFX) $< $@ -num_tiles 86 -Wnum_tiles $(ROULETTEGFXDIR)/roulette_tilt.4bpp: $(ROULETTEGFXDIR)/shroomish.4bpp \ $(ROULETTEGFXDIR)/tailow.4bpp @@ -478,10 +478,10 @@ $(ROULETTEGFXDIR)/wheel_icons.4bpp: $(ROULETTEGFXDIR)/wynaut.4bpp \ @cat $^ >$@ $(BATTRANSGFXDIR)/regis.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 53 + $(GFX) $< $@ -num_tiles 53 -Wnum_tiles $(BATTRANSGFXDIR)/rayquaza.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 938 + $(GFX) $< $@ -num_tiles 938 -Wnum_tiles $(BATTRANSGFXDIR)/frontier_square_1.4bpp: $(BATTRANSGFXDIR)/frontier_squares_blanktiles.4bpp \ $(BATTRANSGFXDIR)/frontier_squares_1.4bpp @@ -504,20 +504,20 @@ $(SLOTMACHINEGFXDIR)/reel_time_gfx.4bpp: $(SLOTMACHINEGFXDIR)/reel_time_pikachu. @cat $^ >$@ graphics/birch_speech/unused_beauty.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 822 + $(GFX) $< $@ -num_tiles 822 -Wnum_tiles ### Pokémon Storage System ### $(WALLPAPERGFXDIR)/forest/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 55 + $(GFX) $< $@ -num_tiles 55 -Wnum_tiles $(WALLPAPERGFXDIR)/forest/tiles.4bpp: $(WALLPAPERGFXDIR)/forest/frame.4bpp $(WALLPAPERGFXDIR)/forest/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/city/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 52 + $(GFX) $< $@ -num_tiles 52 -Wnum_tiles $(WALLPAPERGFXDIR)/city/tiles.4bpp: $(WALLPAPERGFXDIR)/city/frame.4bpp $(WALLPAPERGFXDIR)/city/bg.4bpp @cat $^ >$@ @@ -526,97 +526,97 @@ $(WALLPAPERGFXDIR)/desert/tiles.4bpp: $(WALLPAPERGFXDIR)/desert/frame.4bpp $(WAL @cat $^ >$@ $(WALLPAPERGFXDIR)/savanna/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 45 + $(GFX) $< $@ -num_tiles 45 -Wnum_tiles $(WALLPAPERGFXDIR)/savanna/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 23 + $(GFX) $< $@ -num_tiles 23 -Wnum_tiles $(WALLPAPERGFXDIR)/savanna/tiles.4bpp: $(WALLPAPERGFXDIR)/savanna/frame.4bpp $(WALLPAPERGFXDIR)/savanna/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/crag/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 49 + $(GFX) $< $@ -num_tiles 49 -Wnum_tiles $(WALLPAPERGFXDIR)/crag/tiles.4bpp: $(WALLPAPERGFXDIR)/crag/frame.4bpp $(WALLPAPERGFXDIR)/crag/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/volcano/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 56 + $(GFX) $< $@ -num_tiles 56 -Wnum_tiles $(WALLPAPERGFXDIR)/volcano/tiles.4bpp: $(WALLPAPERGFXDIR)/volcano/frame.4bpp $(WALLPAPERGFXDIR)/volcano/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/snow/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 57 + $(GFX) $< $@ -num_tiles 57 -Wnum_tiles $(WALLPAPERGFXDIR)/snow/tiles.4bpp: $(WALLPAPERGFXDIR)/snow/frame.4bpp $(WALLPAPERGFXDIR)/snow/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/cave/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 55 + $(GFX) $< $@ -num_tiles 55 -Wnum_tiles $(WALLPAPERGFXDIR)/cave/tiles.4bpp: $(WALLPAPERGFXDIR)/cave/frame.4bpp $(WALLPAPERGFXDIR)/cave/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/beach/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 46 + $(GFX) $< $@ -num_tiles 46 -Wnum_tiles $(WALLPAPERGFXDIR)/beach/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 23 + $(GFX) $< $@ -num_tiles 23 -Wnum_tiles $(WALLPAPERGFXDIR)/beach/tiles.4bpp: $(WALLPAPERGFXDIR)/beach/frame.4bpp $(WALLPAPERGFXDIR)/beach/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/seafloor/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 54 + $(GFX) $< $@ -num_tiles 54 -Wnum_tiles $(WALLPAPERGFXDIR)/seafloor/tiles.4bpp: $(WALLPAPERGFXDIR)/seafloor/frame.4bpp $(WALLPAPERGFXDIR)/seafloor/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/river/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 51 + $(GFX) $< $@ -num_tiles 51 -Wnum_tiles $(WALLPAPERGFXDIR)/river/bg.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 11 + $(GFX) $< $@ -num_tiles 11 -Wnum_tiles $(WALLPAPERGFXDIR)/river/tiles.4bpp: $(WALLPAPERGFXDIR)/river/frame.4bpp $(WALLPAPERGFXDIR)/river/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/sky/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 45 + $(GFX) $< $@ -num_tiles 45 -Wnum_tiles $(WALLPAPERGFXDIR)/sky/tiles.4bpp: $(WALLPAPERGFXDIR)/sky/frame.4bpp $(WALLPAPERGFXDIR)/sky/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/polkadot/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 54 + $(GFX) $< $@ -num_tiles 54 -Wnum_tiles $(WALLPAPERGFXDIR)/polkadot/tiles.4bpp: $(WALLPAPERGFXDIR)/polkadot/frame.4bpp $(WALLPAPERGFXDIR)/polkadot/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/pokecenter/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 35 + $(GFX) $< $@ -num_tiles 35 -Wnum_tiles $(WALLPAPERGFXDIR)/pokecenter/tiles.4bpp: $(WALLPAPERGFXDIR)/pokecenter/frame.4bpp $(WALLPAPERGFXDIR)/pokecenter/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/machine/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 33 + $(GFX) $< $@ -num_tiles 33 -Wnum_tiles $(WALLPAPERGFXDIR)/machine/tiles.4bpp: $(WALLPAPERGFXDIR)/machine/frame.4bpp $(WALLPAPERGFXDIR)/machine/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/plain/frame.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 18 + $(GFX) $< $@ -num_tiles 18 -Wnum_tiles $(WALLPAPERGFXDIR)/plain/tiles.4bpp: $(WALLPAPERGFXDIR)/plain/frame.4bpp $(WALLPAPERGFXDIR)/plain/bg.4bpp @cat $^ >$@ $(WALLPAPERGFXDIR)/friends_frame1.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 57 + $(GFX) $< $@ -num_tiles 57 -Wnum_tiles $(WALLPAPERGFXDIR)/friends_frame2.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 57 + $(GFX) $< $@ -num_tiles 57 -Wnum_tiles $(WALLPAPERGFXDIR)/zigzagoon/tiles.4bpp: $(WALLPAPERGFXDIR)/friends_frame1.4bpp $(WALLPAPERGFXDIR)/zigzagoon/bg.4bpp @cat $^ >$@ @@ -667,13 +667,13 @@ $(WALLPAPERGFXDIR)/whiscash/tiles.4bpp: $(WALLPAPERGFXDIR)/friends_frame2.4bpp $ @cat $^ >$@ $(OBJEVENTGFXDIR)/pics/effects/unknown_4F6D38/0.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 11 + $(GFX) $< $@ -num_tiles 11 -Wnum_tiles $(INTERFACEGFXDIR)/selector_outline.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 8 + $(GFX) $< $@ -num_tiles 8 -Wnum_tiles $(BATTRANSGFXDIR)/frontier_logo_center.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 43 + $(GFX) $< $@ -num_tiles 43 -Wnum_tiles @@ -695,19 +695,19 @@ $(PKNAVOPTIONSGFXDIR)/options.4bpp: $(PKNAVOPTIONSGFXDIR)/hoenn_map.4bpp \ @cat $^ >$@ $(PKNAVGFXDIR)/header.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 53 + $(GFX) $< $@ -num_tiles 53 -Wnum_tiles $(PKNAVGFXDIR)/device_outline.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 53 + $(GFX) $< $@ -num_tiles 53 -Wnum_tiles $(PKNAVGFXDIR)/match_call/ui.4bpp: %.4bpp: %.png - $(GFX) $< $@ -num_tiles 13 + $(GFX) $< $@ -num_tiles 13 -Wnum_tiles $(POKEDEXGFXDIR)/region_map.8bpp: %.8bpp: %.png - $(GFX) $< $@ -num_tiles 232 + $(GFX) $< $@ -num_tiles 232 -Wnum_tiles $(POKEDEXGFXDIR)/region_map_affine.8bpp: %.8bpp: %.png - $(GFX) $< $@ -num_tiles 233 + $(GFX) $< $@ -num_tiles 233 -Wnum_tiles $(STARTERGFXDIR)/birch_help.4bpp: $(STARTERGFXDIR)/birch_bag.4bpp $(STARTERGFXDIR)/birch_grass.4bpp @cat $^ >$@ diff --git a/tools/gbagfx/gfx.c b/tools/gbagfx/gfx.c index 4e85953fd..832e9bb39 100644 --- a/tools/gbagfx/gfx.c +++ b/tools/gbagfx/gfx.c @@ -397,7 +397,7 @@ void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int free(buffer); } -void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors) +void WriteImage(char *path, enum NumTilesMode numTilesMode, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors) { int tileSize = bitDepth * 8; @@ -424,7 +424,8 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m FATAL_ERROR("The specified number of tiles (%d) is greater than the maximum possible value (%d).\n", numTiles, maxNumTiles); int bufferSize = numTiles * tileSize; - unsigned char *buffer = malloc(bufferSize); + int maxBufferSize = maxNumTiles * tileSize; + unsigned char *buffer = malloc(maxBufferSize); if (buffer == NULL) FATAL_ERROR("Failed to allocate memory for pixels.\n"); @@ -433,17 +434,36 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m switch (bitDepth) { case 1: - ConvertToTiles1Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles1Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); break; case 4: - ConvertToTiles4Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles4Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); break; case 8: - ConvertToTiles8Bpp(image->pixels, buffer, numTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); + ConvertToTiles8Bpp(image->pixels, buffer, maxNumTiles, metatilesWide, metatileWidth, metatileHeight, invertColors); break; } - WriteWholeFile(path, buffer, bufferSize); + bool zeroPadded = true; + for (int i = bufferSize; i < maxBufferSize && zeroPadded; i++) { + if (buffer[i] != 0) + { + switch (numTilesMode) + { + case NUM_TILES_IGNORE: + break; + case NUM_TILES_WARN: + fprintf(stderr, "Ignoring -num_tiles %d because tile %d contains non-transparent pixels.\n", numTiles, 1 + i / tileSize); + zeroPadded = false; + break; + case NUM_TILES_ERROR: + FATAL_ERROR("Tile %d contains non-transparent pixels.\n", 1 + i / tileSize); + break; + } + } + } + + WriteWholeFile(path, buffer, zeroPadded ? bufferSize : maxBufferSize); free(buffer); } diff --git a/tools/gbagfx/gfx.h b/tools/gbagfx/gfx.h index edb9e62c4..f1dbfcf4f 100644 --- a/tools/gbagfx/gfx.h +++ b/tools/gbagfx/gfx.h @@ -44,8 +44,14 @@ struct Image { bool isAffine; }; +enum NumTilesMode { + NUM_TILES_IGNORE, + NUM_TILES_WARN, + NUM_TILES_ERROR, +}; + void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); -void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); +void WriteImage(char *path, enum NumTilesMode numTilesMode, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); void FreeImage(struct Image *image); void ReadGbaPalette(char *path, struct Palette *palette); void WriteGbaPalette(char *path, struct Palette *palette); diff --git a/tools/gbagfx/main.c b/tools/gbagfx/main.c index cf3031696..5d4faacab 100644 --- a/tools/gbagfx/main.c +++ b/tools/gbagfx/main.c @@ -77,7 +77,7 @@ void ConvertPngToGba(char *inputPath, char *outputPath, struct PngToGbaOptions * ReadPng(inputPath, &image); - WriteImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette); + WriteImage(outputPath, options->numTilesMode, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette); FreeImage(&image); } @@ -179,6 +179,7 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a char *outputFileExtension = GetFileExtensionAfterDot(outputPath); int bitDepth = outputFileExtension[0] - '0'; struct PngToGbaOptions options; + options.numTilesMode = NUM_TILES_IGNORE; options.numTiles = 0; options.bitDepth = bitDepth; options.metatileWidth = 1; @@ -203,6 +204,12 @@ void HandlePngToGbaCommand(char *inputPath, char *outputPath, int argc, char **a if (options.numTiles < 1) FATAL_ERROR("Number of tiles must be positive.\n"); } + else if (strcmp(option, "-Wnum_tiles") == 0) { + options.numTilesMode = NUM_TILES_WARN; + } + else if (strcmp(option, "-Werror=num_tiles") == 0) { + options.numTilesMode = NUM_TILES_ERROR; + } else if (strcmp(option, "-mwidth") == 0) { if (i + 1 >= argc) diff --git a/tools/gbagfx/options.h b/tools/gbagfx/options.h index 3b038f572..250b72345 100644 --- a/tools/gbagfx/options.h +++ b/tools/gbagfx/options.h @@ -4,6 +4,7 @@ #define OPTIONS_H #include +#include "gfx.h" struct GbaToPngOptions { char *paletteFilePath; @@ -18,6 +19,7 @@ struct GbaToPngOptions { struct PngToGbaOptions { int numTiles; + enum NumTilesMode numTilesMode; int bitDepth; int metatileWidth; int metatileHeight;