gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 2e5805ebd83fb4860a9522c7b1c91a1ceb617cb7 parent 0ecb8aa3d035a4003e8461f8c1a32f7efee2c748 Author: Zal0 <cebolleto@gmail.com> Date: Fri, 29 Jan 2021 12:29:38 +0100 added png2mtspr to gbdk makefile, updated metasprite example Diffstat:
| M | Makefile | 7 | +++++++ |
| M | gbdk-lib/examples/gb/metasprites/Makefile | 23 | +++++++++++++++-------- |
| M | gbdk-lib/examples/gb/metasprites/metasprites.c | 75 | +++++++-------------------------------------------------------------------- |
| A | gbdk-lib/examples/gb/metasprites/sprite.png | 0 | |
| M | gbdk-support/png2mtspr/png2mtspr.cpp | 13 | +++++++------ |
5 files changed, 36 insertions(+), 82 deletions(-)
diff --git a/Makefile b/Makefile @@ -118,6 +118,8 @@ gbdk-support-build: @echo @echo Building bankpack @$(MAKE) -C $(GBDKSUPPORTDIR)/bankpack TOOLSPREFIX=$(TOOLSPREFIX) TARGETDIR=$(TARGETDIR)/ --no-print-directory + @echo Building png2mtspr + @$(MAKE) -C $(GBDKSUPPORTDIR)/png2mtspr @echo gbdk-support-install: gbdk-support-build $(BUILDDIR)/bin @@ -134,6 +136,9 @@ gbdk-support-install: gbdk-support-build $(BUILDDIR)/bin @echo Installing bankpack @cp $(GBDKSUPPORTDIR)/bankpack/bankpack $(BUILDDIR)/bin/bankpack$(EXEEXTENSION) @$(TARGETSTRIP) $(BUILDDIR)/bin/bankpack* + @echo Installing png2mtspr + @cp $(GBDKSUPPORTDIR)/png2mtspr/png2mtspr$(EXEEXTENSION) $(BUILDDIR)/bin/png2mtspr$(EXEEXTENSION) + @$(TARGETSTRIP) $(BUILDDIR)/bin/bankpack* @echo gbdk-support-clean: @@ -145,6 +150,8 @@ gbdk-support-clean: @echo @echo Cleaning bankpack @$(MAKE) -C $(GBDKSUPPORTDIR)/bankpack clean --no-print-directory + @echo Cleaning png2mtspr + @$(MAKE) -C $(GBDKSUPPORTDIR)/png2mtspr clean @echo # Rules for gbdk-lib diff --git a/gbdk-lib/examples/gb/metasprites/Makefile b/gbdk-lib/examples/gb/metasprites/Makefile @@ -1,17 +1,23 @@ -CC = ../../../bin/lcc -Wa-l -Wl-m -Wl-j +CC = ../../../bin/lcc +PNG2MTSPR = ../../../bin/png2mtspr -BINS = metasprites.gb +CFLAGS = -all: $(BINS) +BINS = metasprites.gb +PNGSOURCES = sprite.png +CSOURCES = $(PNGSOURCES:%.png=%.c) $(wildcard *.c) + +all: $(BINS) make.bat: Makefile @echo "REM Automatically generated from Makefile" > make.bat @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +sprite.c: sprite.png + $(PNG2MTSPR) $< -sh 48 -spr8x16 -c $@ -# Compile and link single file in one pass -%.gb: %.c - $(CC) -o $@ $< +$(BINS): $(CSOURCES) + $(CC) $(CFLAGS) -o $(BINS) $(CSOURCES) clean: - rm -f *.o *.lst *.map *.gb *~ *.rel *.cdb *.ihx *.lnk *.sym *.asm *.noi - + rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm $(PNGSOURCES:%.png=%.h) $(PNGSOURCES:%.png=%.c) + diff --git a/gbdk-lib/examples/gb/metasprites/metasprites.c b/gbdk-lib/examples/gb/metasprites/metasprites.c @@ -2,68 +2,7 @@ #include <gb/sgb.h> #include <gb/metasprites.h> -UINT8 sprite_data[] = { -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 metasprite0[] = { - { 0, 8, 0, 0}, { 0, 8, 2, 0}, { 0, 8, 4, 0}, { 0, 8, 6, 0}, { 0, 8, 8, 0}, { 0, 8, 0, 32}, - {16, -40, 10, 0}, { 0, 8, 12, 0}, { 0, 8, 14, 0}, { 0, 8, 16, 0}, { 0, 8, 16, 32}, { 0, 8, 18, 0}, { 0, 8, 20, 0}, - {16, -48, 22, 0}, { 0, 16, 24, 0}, { 0, 8, 26, 0}, { 0, 8, 28, 0}, { 0, 8, 30, 0}, { 0, 8, 32, 0}, - {metasprite_end} -}; -const metasprite_t metasprite1[] = { - { 0, 8, 0, 0}, { 0, 8, 2, 0}, { 0, 8, 4, 0}, { 0, 8, 6, 0}, { 0, 8, 8, 0}, { 0, 8, 0, 32}, - {16,-40, 10, 0}, { 0, 8, 12, 0}, { 0, 8, 14, 0}, { 0, 8, 16, 0}, { 0, 8, 16, 32}, { 0, 8, 18, 0}, { 0, 8, 34, 0}, - {16,-56, 36, 0}, { 0, 8, 38, 0}, { 0, 16, 24, 0}, { 0, 8, 26, 0}, { 0, 8, 28, 0}, { 0, 8, 30, 0}, { 0, 8, 40, 0}, - {metasprite_end} -}; -const metasprite_t metasprite2[] = { - { 0, 8, 0, 0}, { 0, 8, 2, 0}, { 0, 8, 4, 0}, { 0, 8, 6, 0}, { 0, 8, 8, 0}, { 0, 8, 0, 32}, - {16,-40, 10, 0}, { 0, 8, 12, 0}, { 0, 8, 14, 0}, { 0, 8, 16, 0}, { 0, 8, 16, 32}, { 0, 8, 18, 0}, { 0, 8, 42, 0}, - {16,-56, 44, 0}, { 0, 8, 46, 0}, { 0, 16, 24, 0}, { 0, 8, 26, 0}, { 0, 8, 28, 0}, { 0, 8, 30, 0}, { 0, 8, 48, 0}, - {metasprite_end} -}; -const metasprite_t metasprite3[] = { - { 0, 8, 0, 0}, { 0, 8, 2, 0}, { 0, 8, 4, 0}, { 0, 8, 6, 0}, { 0, 8, 8, 0}, { 0, 8, 0, 32}, - {16,-40, 10, 0}, { 0, 8, 12, 0}, { 0, 8, 14, 0}, { 0, 8, 16, 0}, { 0, 8, 16, 32}, { 0, 8, 18, 0}, { 0, 8, 34, 0}, - {16,-56, 50, 0}, { 0, 8, 52, 0}, { 0, 16, 24, 0}, { 0, 8, 26, 0}, { 0, 8, 28, 0}, { 0, 8, 30, 0}, { 0, 8, 40, 0}, - {metasprite_end} -}; -const metasprite_t metasprite4[] = { - { 0, 8, 0, 0}, { 0, 8, 2, 0}, { 0, 8, 4, 0}, { 0, 8, 6, 0}, { 0, 8, 8, 0}, { 0, 8, 0, 32}, - {16,-40, 10, 0}, { 0, 8, 12, 0}, { 0, 8, 14, 0}, { 0, 8, 16, 0}, { 0, 8, 16, 32}, { 0, 8, 18, 0}, { 0, 8, 20, 0}, - {16,-56, 54, 0}, { 0, 8, 52, 0}, { 0, 16, 24, 0}, { 0, 8, 26, 0}, { 0, 8, 28, 0}, { 0, 8, 30, 0}, { 0, 8, 32, 0}, - {metasprite_end} -}; -const metasprite_t * const metasprites[] = { metasprite0, metasprite1, metasprite2, metasprite3, metasprite4, metasprite3, metasprite2, metasprite1 }; +#include "sprite.h" const unsigned char pattern[] = {0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01}; @@ -134,7 +73,7 @@ void main(void) { jitter = 10; } if ((joypads.joy0 & J_B) && (!jitter) && (!hide)) { - idx++; if (idx >= 8) idx = 0; + idx++; if (idx >= (sizeof(sprite_metasprites) >> 1)) idx = 0; jitter = 10; } if ((joypads.joy0 & J_SELECT) && (!jitter) && (!hide)) { @@ -151,13 +90,13 @@ void main(void) { // hide or move sprite if (hide) - hide_metasprite(metasprites[idx], 0); + hide_metasprite(sprite_metasprites[idx], 0); else switch (rot) { - case 0: hiwater = move_metasprite(metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; - case 1: hiwater = move_metasprite_hflip(metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; - case 2: hiwater = move_metasprite_hvflip(metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; - case 3: hiwater = move_metasprite_vflip(metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; + case 0: hiwater = move_metasprite(sprite_metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; + case 1: hiwater = move_metasprite_hflip(sprite_metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; + case 2: hiwater = move_metasprite_hvflip(sprite_metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; + case 3: hiwater = move_metasprite_vflip(sprite_metasprites[idx], 0, 0, PosX >> 4, PosY >> 4); break; }; // hide rest of the hardware sprites, because amount of sprites differ between animation frames diff --git a/gbdk-lib/examples/gb/metasprites/sprite.png b/gbdk-lib/examples/gb/metasprites/sprite.png Binary files differ. diff --git a/gbdk-support/png2mtspr/png2mtspr.cpp b/gbdk-support/png2mtspr/png2mtspr.cpp @@ -231,17 +231,18 @@ int main(int argc, char *argv[]) } } - size_t slash_pos = output_filename.find_last_of('/'); - if(slash_pos == -1u) - slash_pos = output_filename.find_last_of('\\'); - size_t dot_pos = output_filename.find_last_of('.'); + int slash_pos = (int)output_filename.find_last_of('/'); + if(slash_pos == -1) + slash_pos = (int)output_filename.find_last_of('\\'); + int dot_pos = (int)output_filename.find_last_of('.'); - if(slash_pos == -1u) slash_pos = 0; - if(dot_pos == -1u) dot_pos = 0; + if(slash_pos == -1) slash_pos = -1; + if(dot_pos == -1) dot_pos = -1; string output_filename_h = output_filename.substr(0, dot_pos) + ".h"; string data_name = output_filename.substr(slash_pos + 1, dot_pos - 1 - slash_pos); replace(data_name.begin(), data_name.end(), '-', '_'); + printf("data_name:%s", data_name.c_str()); //load and decode png vector<unsigned char> buffer;
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.