git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

commit 3778e11683e2282bef51c0bf50c09af30ade4b94
parent e98e4b600284b8fc35547d8bcc2b546c9423ed7a
Author: Toxa <untoxa@mail.ru>
Date:   Wed, 18 Aug 2021 13:52:32 +0300

png2mtspr: basic support for SMS/GG (no disabling of flipping and 4bpp yet)

Diffstat:
Mgbdk-lib/examples/gg/metasprites/Makefile40+++++++++++++++++++++++-----------------
Dgbdk-lib/examples/gg/metasprites/sprite.c59-----------------------------------------------------------
Dgbdk-lib/examples/gg/metasprites/sprite.h9---------
Agbdk-lib/examples/gg/metasprites/sprite.png0
Mgbdk-lib/examples/sms/metasprites/Makefile40+++++++++++++++++++++++-----------------
Dgbdk-lib/examples/sms/metasprites/sprite.c59-----------------------------------------------------------
Dgbdk-lib/examples/sms/metasprites/sprite.h9---------
Agbdk-lib/examples/sms/metasprites/sprite.png0
Mgbdk-lib/include/gb/metasprites.h2++
Mgbdk-lib/include/sms/metasprites.h2++
Mgbdk-support/png2mtspr/png2mtspr.cpp16+++++++++++-----
11 files changed, 61 insertions(+), 175 deletions(-)

diff --git a/gbdk-lib/examples/gg/metasprites/Makefile b/gbdk-lib/examples/gg/metasprites/Makefile @@ -1,30 +1,36 @@ -CC = ../../../bin/lcc -mz80:gg -Wm-yoA -Wa-l -Wl-j +LCC = ../../../bin/lcc +PNG2MTSPR = ../../../bin/png2mtspr -BINS = metasprites.gg +CFLAGS = -mz80:gg -all: $(BINS) +# Output name for compiled ROM +BINS = metasprites.gg -ASRC = $(wildcard *.s) -CSRC = $(wildcard *.c) +# Add entries here to have them converted into metasprites +PNGSOURCES = sprite.png +PNG_CSOURCES = $(PNGSOURCES:%.png=%.c) +PNG_CHEADERS = $(PNGSOURCES:%.png=%.h) -OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o) +# List of all C source files except those generated by png2mtspr +CSOURCES = $(filter-out $(PNGSOURCES:%.png=%.c), $(wildcard *.c)) + +all: $(BINS) compile.bat: Makefile @echo "REM Automatically generated from Makefile" > compile.bat @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat -# Compile and link single file in one pass - -%.o: %.c - $(CC) -c -o $@ $< +# Use png2mtspr to convert the png into C formatted metasprite data +# -sh 48 : Sets sprite height to 48 (width remains automatic) +# -spr8x16 : Use 8x16 hardware sprites +# -c ... : Set C output file +%.c: %.png + $(PNG2MTSPR) $< -sh 48 -spr8x16 -plat sms -c $@ -%.o: %.s - $(CC) -c -o $@ $< +# Compile all C sources, including converted png metasprites +$(BINS): $(CSOURCES) $(PNG_CSOURCES) + $(LCC) $(CFLAGS) -o $(BINS) $(CSOURCES) $(PNG_CSOURCES) -$(BINS): $(OBJS) - $(CC) -Wm-yS -o $@ $^ - rm -f *.map *.noi *.ihx *.lst clean: - rm -f *.o *.lst *.map *.gg *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi - + rm -f *.o *.lst *.map *.gg *.ihx *.sym *.cdb *.adb *.asm $(PNG_CHEADERS) $(PNG_CSOURCES) diff --git a/gbdk-lib/examples/gg/metasprites/sprite.c b/gbdk-lib/examples/gg/metasprites/sprite.c @@ -1,59 +0,0 @@ -//AUTOGENERATED FILE FROM png2mtspr - -#include <sms/sms.h> -#include <sms/metasprites.h> - -const UINT8 sprite_data[896] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x0d,0x0e,0x1f,0x10,0x3f,0x20,0x3f,0x20, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0xfd,0xfe,0x3f,0xc0,0xff,0x0c,0xff,0x13,0xf7,0x08,0xc1,0x3e, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x9f,0xe0,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x80,0xff,0x40, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0,0xcf,0x3f,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0x3c,0xfc,0xf3,0x0f,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, -0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x23,0x3d,0x23,0x5e,0x61,0x5e,0x61,0x7c,0x43,0x78,0x47,0x79,0x47,0xbb,0xc7,0xb3,0xcf,0xf2,0x8e,0xf4,0x8c, -0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xcf,0x30,0xff,0x08,0xbf,0xc4,0xe7,0xdc,0x07,0xfc,0x02,0xff,0x03,0xff,0x00,0xff,0x87,0xff,0xff,0xff,0xc1,0xc1,0x01,0x01,0x00,0x00, -0xff,0x20,0x7f,0xa0,0x7f,0x90,0xff,0x10,0xff,0x10,0xdf,0x30,0xff,0x60,0xbf,0xc0,0xbd,0xc2,0x3c,0xc3,0x7e,0x81,0xff,0x80,0xff,0x80,0xbf,0xc0,0xff,0xc0,0xff,0xc0, -0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x3f,0xc0,0x07,0xf8,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x40,0xff,0x40,0xff, -0xfe,0x02,0xfe,0x02,0xfd,0x03,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x00,0x7f,0x80,0x7f,0x80,0xff,0x00,0xfe,0x01,0xff,0x01,0xfd,0x03,0xfd,0x03,0x79,0x87,0x71,0x8f, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xe0,0x20,0x60,0xa0,0x60,0xa0,0xa0,0xe0, -0xf4,0x8c,0xf4,0x8c,0xb4,0xcc,0xb8,0xc8,0xb8,0xc8,0x78,0x48,0x78,0x48,0x78,0x48,0x74,0x4c,0x5c,0x64,0x3c,0x24,0x3e,0x22,0x19,0x17,0x0b,0x0f,0x06,0x06,0x00,0x00, -0xdf,0xe0,0x7f,0x60,0x7e,0x61,0x6e,0x71,0x7e,0x71,0x7c,0x73,0x70,0x7f,0x78,0x7f,0x78,0x7f,0x78,0x7f,0x7c,0x7f,0x7c,0x7f,0x7c,0x7f,0xfb,0xfc,0xfb,0xfc,0x0f,0x0f, -0x70,0xff,0x4f,0xcf,0x41,0xc1,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x10,0xf0,0x10,0xf0,0x90,0x70,0xd0,0x30,0xe0,0xe0, -0x02,0xff,0xfe,0xff,0xfe,0xff,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, -0x01,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x82,0xfe,0x82,0xfe,0xc2,0xfe,0xc2,0xfe,0x42,0x7e,0x42,0x7e,0x42,0x7e,0x81,0xff,0xb9,0xc7,0xfd,0x83,0xfe,0xfe, -0x50,0x70,0x50,0x70,0x50,0x70,0x50,0x70,0x30,0x30,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xc0,0x40,0xe0,0x20,0x60,0xa0,0xb0,0xd0,0x70,0x50,0x50,0x70, -0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xf4,0x8c,0xf4,0x8c,0xf4,0x8c,0x78,0x88,0xe8,0x18,0xf0,0x10,0xf0,0x10,0xf0,0x10,0x70,0x90,0xf0,0x90,0xe8,0x98,0x78,0x48,0x64,0x5c,0x2c,0x3c,0x18,0x18,0x00,0x00, -0x38,0x28,0x38,0x28,0x28,0x38,0x18,0x18,0x18,0x18,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xe0,0x20,0xe0,0x20,0xf0,0x90,0xb0,0xd0,0x78,0x48,0x34,0x2c, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x03,0x02,0x05,0x06,0x07,0x04,0x07,0x04,0x07,0x04,0x07,0x04,0x05,0x06,0x03,0x02,0x02,0x03,0x01,0x01,0x00,0x00, -0x74,0x8c,0xf4,0x0c,0xe8,0x18,0xf8,0x18,0xd0,0x30,0xe0,0x20,0xc0,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0xc0,0x40,0xc0,0x40,0xc0,0xc0,0xc0,0x00,0x00, -0x1c,0x14,0x0e,0x0a,0x07,0x05,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x07,0x04,0x07,0x04,0x0f,0x08,0x0f,0x09,0x15,0x1b,0x1e,0x12,0x1e,0x12,0x1a,0x16,0x12,0x1e,0x1e,0x1e,0x00,0x00, -0x74,0x8c,0xf4,0x0c,0xe8,0x18,0xf8,0x18,0xd0,0x30,0xe0,0x20,0xc0,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x07,0x04,0x0b,0x0c,0x0f,0x08,0x1f,0x11,0x1e,0x12,0x2a,0x36,0x3c,0x24,0x24,0x3c,0x28,0x38,0x38,0x38,0x00,0x00 -}; - -const metasprite_t sprite_metasprite0[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 20}, {16, -48, 22}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 32}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite1[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 34}, {16, -56, 36}, {0, 8, 38}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 40}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite2[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 42}, {16, -56, 44}, {0, 8, 46, 0}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 48}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite3[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 34}, {16, -56, 50}, {0, 8, 52}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 40}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite4[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 20}, {16, -56, 54}, {0, 8, 52}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 32}, {metasprite_end} -}; - -const metasprite_t* const sprite_metasprites[5] = { - sprite_metasprite0, sprite_metasprite1, sprite_metasprite2, sprite_metasprite3, sprite_metasprite4 -}; diff --git a/gbdk-lib/examples/gg/metasprites/sprite.h b/gbdk-lib/examples/gg/metasprites/sprite.h @@ -1,9 +0,0 @@ -//AUTOGENERATED FILE FROM png2mtspr -#define sprite_TILE_H 16 -#define sprite_WIDTH 64 -#define sprite_HEIGHT 48 -#define sprite_PIVOT_X 32 -#define sprite_PIVOT_Y 24 - -extern const UINT8 sprite_data[896]; -extern const metasprite_t* const sprite_metasprites[5]; diff --git a/gbdk-lib/examples/gg/metasprites/sprite.png b/gbdk-lib/examples/gg/metasprites/sprite.png Binary files differ. diff --git a/gbdk-lib/examples/sms/metasprites/Makefile b/gbdk-lib/examples/sms/metasprites/Makefile @@ -1,30 +1,36 @@ -CC = ../../../bin/lcc -mz80:sms -Wm-yoA -Wa-l -Wl-j +LCC = ../../../bin/lcc +PNG2MTSPR = ../../../bin/png2mtspr -BINS = metasprites.sms +CFLAGS = -mz80:sms -all: $(BINS) +# Output name for compiled ROM +BINS = metasprites.sms -ASRC = $(wildcard *.s) -CSRC = $(wildcard *.c) +# Add entries here to have them converted into metasprites +PNGSOURCES = sprite.png +PNG_CSOURCES = $(PNGSOURCES:%.png=%.c) +PNG_CHEADERS = $(PNGSOURCES:%.png=%.h) -OBJS = $(CSRC:%.c=%.o) $(ASRC:%.s=%.o) +# List of all C source files except those generated by png2mtspr +CSOURCES = $(filter-out $(PNGSOURCES:%.png=%.c), $(wildcard *.c)) + +all: $(BINS) compile.bat: Makefile @echo "REM Automatically generated from Makefile" > compile.bat @make -sn | sed y/\\//\\\\/ | grep -v make >> compile.bat -# Compile and link single file in one pass - -%.o: %.c - $(CC) -c -o $@ $< +# Use png2mtspr to convert the png into C formatted metasprite data +# -sh 48 : Sets sprite height to 48 (width remains automatic) +# -spr8x16 : Use 8x16 hardware sprites +# -c ... : Set C output file +%.c: %.png + $(PNG2MTSPR) $< -sh 48 -spr8x16 -plat sms -c $@ -%.o: %.s - $(CC) -c -o $@ $< +# Compile all C sources, including converted png metasprites +$(BINS): $(CSOURCES) $(PNG_CSOURCES) + $(LCC) $(CFLAGS) -o $(BINS) $(CSOURCES) $(PNG_CSOURCES) -$(BINS): $(OBJS) - $(CC) -Wm-yS -o $@ $^ - rm -f *.map *.noi *.ihx *.lst clean: - rm -f *.o *.lst *.map *.sms *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi - + rm -f *.o *.lst *.map *.sms *.ihx *.sym *.cdb *.adb *.asm $(PNG_CHEADERS) $(PNG_CSOURCES) diff --git a/gbdk-lib/examples/sms/metasprites/sprite.c b/gbdk-lib/examples/sms/metasprites/sprite.c @@ -1,59 +0,0 @@ -//AUTOGENERATED FILE FROM png2mtspr - -#include <sms/sms.h> -#include <sms/metasprites.h> - -const UINT8 sprite_data[896] = { -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x0d,0x0e,0x1f,0x10,0x3f,0x20,0x3f,0x20, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0xfd,0xfe,0x3f,0xc0,0xff,0x0c,0xff,0x13,0xf7,0x08,0xc1,0x3e, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x7f,0x9f,0xe0,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x80,0xff,0x40, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xf0,0xcf,0x3f,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xc0,0x3c,0xfc,0xf3,0x0f,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00, -0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x20,0x3f,0x23,0x3d,0x23,0x5e,0x61,0x5e,0x61,0x7c,0x43,0x78,0x47,0x79,0x47,0xbb,0xc7,0xb3,0xcf,0xf2,0x8e,0xf4,0x8c, -0xc0,0x3f,0xc0,0x3f,0xc0,0x3f,0xcf,0x30,0xff,0x08,0xbf,0xc4,0xe7,0xdc,0x07,0xfc,0x02,0xff,0x03,0xff,0x00,0xff,0x87,0xff,0xff,0xff,0xc1,0xc1,0x01,0x01,0x00,0x00, -0xff,0x20,0x7f,0xa0,0x7f,0x90,0xff,0x10,0xff,0x10,0xdf,0x30,0xff,0x60,0xbf,0xc0,0xbd,0xc2,0x3c,0xc3,0x7e,0x81,0xff,0x80,0xff,0x80,0xbf,0xc0,0xff,0xc0,0xff,0xc0, -0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x3f,0xc0,0x07,0xf8,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0xff,0x40,0xff,0x40,0xff, -0xfe,0x02,0xfe,0x02,0xfd,0x03,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x00,0x7f,0x80,0x7f,0x80,0xff,0x00,0xfe,0x01,0xff,0x01,0xfd,0x03,0xfd,0x03,0x79,0x87,0x71,0x8f, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xc0,0x40,0xc0,0x40,0xe0,0x20,0x60,0xa0,0x60,0xa0,0xa0,0xe0, -0xf4,0x8c,0xf4,0x8c,0xb4,0xcc,0xb8,0xc8,0xb8,0xc8,0x78,0x48,0x78,0x48,0x78,0x48,0x74,0x4c,0x5c,0x64,0x3c,0x24,0x3e,0x22,0x19,0x17,0x0b,0x0f,0x06,0x06,0x00,0x00, -0xdf,0xe0,0x7f,0x60,0x7e,0x61,0x6e,0x71,0x7e,0x71,0x7c,0x73,0x70,0x7f,0x78,0x7f,0x78,0x7f,0x78,0x7f,0x7c,0x7f,0x7c,0x7f,0x7c,0x7f,0xfb,0xfc,0xfb,0xfc,0x0f,0x0f, -0x70,0xff,0x4f,0xcf,0x41,0xc1,0x40,0xc0,0x40,0xc0,0x40,0xc0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x20,0xe0,0x10,0xf0,0x10,0xf0,0x90,0x70,0xd0,0x30,0xe0,0xe0, -0x02,0xff,0xfe,0xff,0xfe,0xff,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x1f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x00,0x00, -0x01,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x01,0xff,0x82,0xfe,0x82,0xfe,0xc2,0xfe,0xc2,0xfe,0x42,0x7e,0x42,0x7e,0x42,0x7e,0x81,0xff,0xb9,0xc7,0xfd,0x83,0xfe,0xfe, -0x50,0x70,0x50,0x70,0x50,0x70,0x50,0x70,0x30,0x30,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xc0,0x40,0xe0,0x20,0x60,0xa0,0xb0,0xd0,0x70,0x50,0x50,0x70, -0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0xf4,0x8c,0xf4,0x8c,0xf4,0x8c,0x78,0x88,0xe8,0x18,0xf0,0x10,0xf0,0x10,0xf0,0x10,0x70,0x90,0xf0,0x90,0xe8,0x98,0x78,0x48,0x64,0x5c,0x2c,0x3c,0x18,0x18,0x00,0x00, -0x38,0x28,0x38,0x28,0x28,0x38,0x18,0x18,0x18,0x18,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x40,0xc0,0xc0,0x40,0xe0,0x20,0xe0,0x20,0xf0,0x90,0xb0,0xd0,0x78,0x48,0x34,0x2c, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x03,0x02,0x05,0x06,0x07,0x04,0x07,0x04,0x07,0x04,0x07,0x04,0x05,0x06,0x03,0x02,0x02,0x03,0x01,0x01,0x00,0x00, -0x74,0x8c,0xf4,0x0c,0xe8,0x18,0xf8,0x18,0xd0,0x30,0xe0,0x20,0xc0,0x40,0x40,0xc0,0x80,0x80,0x80,0x80,0x80,0x80,0x40,0xc0,0x40,0xc0,0x40,0xc0,0xc0,0xc0,0x00,0x00, -0x1c,0x14,0x0e,0x0a,0x07,0x05,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x07,0x04,0x07,0x04,0x0f,0x08,0x0f,0x09,0x15,0x1b,0x1e,0x12,0x1e,0x12,0x1a,0x16,0x12,0x1e,0x1e,0x1e,0x00,0x00, -0x74,0x8c,0xf4,0x0c,0xe8,0x18,0xf8,0x18,0xd0,0x30,0xe0,0x20,0xc0,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x03,0x03,0x02,0x07,0x04,0x0b,0x0c,0x0f,0x08,0x1f,0x11,0x1e,0x12,0x2a,0x36,0x3c,0x24,0x24,0x3c,0x28,0x38,0x38,0x38,0x00,0x00 -}; - -const metasprite_t sprite_metasprite0[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 20}, {16, -48, 22}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 32}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite1[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 34}, {16, -56, 36}, {0, 8, 38}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 40}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite2[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 42}, {16, -56, 44}, {0, 8, 46, 0}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 48}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite3[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 34}, {16, -56, 50}, {0, 8, 52}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 40}, {metasprite_end} -}; - -const metasprite_t sprite_metasprite4[] = { - {-24, -24, 0}, {0, 8, 2}, {0, 8, 4}, {0, 8, 6}, {0, 8, 8}, {0, 8, 0}, {16, -40, 10}, {0, 8, 12}, {0, 8, 14}, {0, 8, 16}, {0, 8, 16}, {0, 8, 18}, {0, 8, 20}, {16, -56, 54}, {0, 8, 52}, {0, 16, 24}, {0, 8, 26}, {0, 8, 28}, {0, 8, 30}, {0, 8, 32}, {metasprite_end} -}; - -const metasprite_t* const sprite_metasprites[5] = { - sprite_metasprite0, sprite_metasprite1, sprite_metasprite2, sprite_metasprite3, sprite_metasprite4 -}; diff --git a/gbdk-lib/examples/sms/metasprites/sprite.h b/gbdk-lib/examples/sms/metasprites/sprite.h @@ -1,9 +0,0 @@ -//AUTOGENERATED FILE FROM png2mtspr -#define sprite_TILE_H 16 -#define sprite_WIDTH 64 -#define sprite_HEIGHT 48 -#define sprite_PIVOT_X 32 -#define sprite_PIVOT_Y 24 - -extern const UINT8 sprite_data[896]; -extern const metasprite_t* const sprite_metasprites[5]; diff --git a/gbdk-lib/examples/sms/metasprites/sprite.png b/gbdk-lib/examples/sms/metasprites/sprite.png Binary files differ. diff --git a/gbdk-lib/include/gb/metasprites.h b/gbdk-lib/include/gb/metasprites.h @@ -83,6 +83,8 @@ typedef struct metasprite_t { } metasprite_t; #define metasprite_end -128 +#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt),(a)} +#define METASPR_TERM {metasprite_end} extern const void * __current_metasprite; extern uint8_t __current_base_tile; diff --git a/gbdk-lib/include/sms/metasprites.h b/gbdk-lib/include/sms/metasprites.h @@ -55,6 +55,8 @@ typedef struct metasprite_t { } metasprite_t; #define metasprite_end -128 +#define METASPR_ITEM(dy,dx,dt,a) {(dy),(dx),(dt)} +#define METASPR_TERM {metasprite_end} extern const void * __current_metasprite; extern uint8_t __current_base_tile; diff --git a/gbdk-support/png2mtspr/png2mtspr.cpp b/gbdk-support/png2mtspr/png2mtspr.cpp @@ -201,6 +201,7 @@ int main(int argc, char *argv[]) printf("-spr8x8 use SPRITES_8x8 (default: SPRITES_8x16)\n"); printf("-spr8x16 use SPRITES_8x16 (default: SPRITES_8x16)\n"); printf("-b <bank> bank (default 0)\n"); + printf("-plat <plat> platform (default gb)\n"); return 0; } @@ -210,7 +211,8 @@ int main(int argc, char *argv[]) int pivot_x = 0xFFFFFF; int pivot_y = 0xFFFFFF; tile_h = 16; - string output_filename = argv[1]; + string output_filename = argv[1]; + string plat = "gb"; output_filename = output_filename.substr(0, output_filename.size() - 4) + ".c"; int bank = 0; @@ -253,6 +255,10 @@ int main(int argc, char *argv[]) { bank = atoi(argv[++ i]); } + else if(!strcmp(argv[i], "-plat")) + { + plat = argv[++ i]; + } } int slash_pos = (int)output_filename.find_last_of('/'); @@ -304,7 +310,7 @@ int main(int argc, char *argv[]) fprintf(file, "#define __%s_H_INCLUDE\n", data_name.c_str()); fprintf(file, "\n"); fprintf(file, "#include <stdint.h>\n"); - fprintf(file, "#include <gb/metasprites.h>\n"); + fprintf(file, "#include <%s/metasprites.h>\n", plat.c_str()); fprintf(file, "\n"); fprintf(file, "#define %s_TILE_H %d\n", data_name.c_str(), tile_h); fprintf(file, "#define %s_WIDTH %d\n", data_name.c_str(), sprite_w); @@ -331,7 +337,7 @@ int main(int argc, char *argv[]) fprintf(file, "//AUTOGENERATED FILE FROM png2mtspr\n\n"); fprintf(file, "#include <stdint.h>\n"); - fprintf(file, "#include <gb/metasprites.h>\n"); + fprintf(file, "#include <%s/metasprites.h>\n", plat.c_str()); fprintf(file, "\n"); if(bank) { @@ -360,9 +366,9 @@ int main(int argc, char *argv[]) fprintf(file, "\t"); for(MetaSprite::iterator it2 = (*it).begin(); it2 != (*it).end(); ++ it2) { - fprintf(file, "{%d, %d, %d, %d}, ", (*it2).offset_y, (*it2).offset_x, (*it2).offset_idx, (*it2).props); + fprintf(file, "METASPR_ITEM(%d, %d, %d, %d), ", (*it2).offset_y, (*it2).offset_x, (*it2).offset_idx, (*it2).props); } - fprintf(file, "{metasprite_end}\n"); + fprintf(file, "METASPR_TERM\n"); fprintf(file, "};\n\n"); }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.