diff --git a/.gitignore b/.gitignore index f1827ba..59515ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .DS_Store **/obj -*/gbdk +**/gbdk # Prerequisites *.d diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..b1f27e8 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ce94c0a --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "files.associations": { + "*.md": "markdown", + "stdio.h": "c", + "gb.h": "c", + "font.h": "c", + "smiley.h": "c", + "character.h": "c", + "metasprites.h": "c", + "blankscreen.h": "c", + "underwater_map.h": "c", + "collision.h": "c", + "common.h": "c", + "actor.h": "c" + } +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..02c67b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,62 @@ +# +# A Makefile that compiles all .c and .s files in "src" and "res" +# subdirectories and places the output in a "obj" subdirectory +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = gbdk + +LCC = $(GBDK_HOME)bin/lcc + +# You can set flags for LCC here +# For example, you can uncomment the line below to turn on debug output +# LCCFLAGS += -debug # Uncomment to enable debug output +# LCCFLAGS += -v # Uncomment for lcc verbose output + + +# You can set the name of the .gb ROM file here +PROJECTNAME = Submarine + +SRCDIR = src +OBJDIR = obj +RESDIR = res +BINS = $(OBJDIR)/$(PROJECTNAME).gb +CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c))) $(foreach dir,$(RESDIR),$(notdir $(wildcard $(dir)/*.c))) +ASMSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.s))) +OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o) $(ASMSOURCES:%.s=$(OBJDIR)/%.o) + +all: prepare $(BINS) + +compile.bat: Makefile + @echo "REM Automatically generated from Makefile" > compile.bat + @make -sn | sed y/\\//\\\\/ | sed s/mkdir\ -p\/mkdir\/ | grep -v make >> compile.bat + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(LCCFLAGS) -c -o $@ $< + +# If needed, compile .c files in "src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(LCCFLAGS) -S -o $@ $< + +# Link the compiled object files into a .gb ROM file +$(BINS): $(OBJS) + $(LCC) $(LCCFLAGS) -o $(BINS) $(OBJS) + +prepare: + mkdir -p $(OBJDIR) + +clean: +# rm -f *.gb *.ihx *.cdb *.adb *.noi *.map + rm -f $(OBJDIR)/*.* + diff --git a/README.md b/README.md index aac1f9d..a362f33 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,11 @@ -# gameboy-submarine - A gameboy game developed with gbdk +# A template project with a Makefile that supports sub-directories. + +The Makefile will automatically detect and compile new source files when they are added to the "src" and "res" directories. + +Project directories + +- src: Main program source files (.c, .h, .s) can go here +- res: Program graphics and audio source files (.c, .h, .s) can go here +- obj: Compiled ROM (.gb) and debug files go in this directory + +Must have gbdk-2020 in a folder named "gbdk" in the root folder. diff --git a/compile.bat b/compile.bat new file mode 100644 index 0000000..6f2725b --- /dev/null +++ b/compile.bat @@ -0,0 +1,15 @@ +REM Automatically generated from Makefile +mkdir obj +gbdk\bin\lcc -c -o obj\main.o src\main.c +gbdk\bin\lcc -c -o obj\actor.o src\actor.c +gbdk\bin\lcc -c -o obj\collision.o src\collision.c +gbdk\bin\lcc -c -o obj\submarine_sprites.o res\submarine_sprites.c +gbdk\bin\lcc -c -o obj\alphabet.o res\alphabet.c +gbdk\bin\lcc -c -o obj\blankScreen.o res\blankScreen.c +gbdk\bin\lcc -c -o obj\helloWorld.o res\helloWorld.c +gbdk\bin\lcc -c -o obj\hud.o res\hud.c +gbdk\bin\lcc -c -o obj\underwater_tiles.o res\underwater_tiles.c +gbdk\bin\lcc -c -o obj\underwater_map.o res\underwater_map.c +gbdk\bin\lcc -c -o obj\tileset.o res\collision-test\tileset.c +gbdk\bin\lcc -c -o obj\tilemap.o res\collision-test\tilemap.c +gbdk\bin\lcc -o obj\Submarine.gb obj\main.o obj\actor.o obj\collision.o obj\submarine_sprites.o obj\alphabet.o obj\blankScreen.o obj\helloWorld.o obj\hud.o obj\underwater_tiles.o obj\underwater_map.o obj\tileset.o obj\tilemap.o diff --git a/res/alphabet.c b/res/alphabet.c new file mode 100644 index 0000000..b5d1d97 --- /dev/null +++ b/res/alphabet.c @@ -0,0 +1,125 @@ +/* + + ALPHABET.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 47 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +unsigned char alphabet[] = + { + 0x7C, 0x7C, 0x86, 0x86, 0x8A, 0x8A, 0x92, 0x92, + 0xA2, 0xA2, 0xC2, 0xC2, 0x7C, 0x7C, 0x00, 0x00, + 0x10, 0x10, 0x30, 0x30, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x7C, 0x7C, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x02, 0x02, 0x1C, 0x1C, + 0x60, 0x60, 0x80, 0x80, 0xFE, 0xFE, 0x00, 0x00, + 0xFE, 0xFE, 0x04, 0x04, 0x18, 0x18, 0x04, 0x04, + 0x02, 0x02, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0x0C, 0x0C, 0x14, 0x14, 0x24, 0x24, 0x44, 0x44, + 0x84, 0x84, 0xFE, 0xFE, 0x04, 0x04, 0x00, 0x00, + 0xFC, 0xFC, 0x80, 0x80, 0xFC, 0xFC, 0x02, 0x02, + 0x02, 0x02, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0x7C, 0x7C, 0x80, 0x80, 0x80, 0x80, 0xFC, 0xFC, + 0x82, 0x82, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0xFE, 0xFE, 0x82, 0x82, 0x04, 0x04, 0x08, 0x08, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x7C, 0x7C, + 0x82, 0x82, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x7E, 0x7E, + 0x02, 0x02, 0x02, 0x02, 0x7C, 0x7C, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, + 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x08, 0x2E, 0x2E, 0xF8, 0xF8, 0x28, 0x28, + 0x3E, 0x3E, 0xE8, 0xE8, 0x20, 0x20, 0x00, 0x00, + 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, + 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x00, 0x00, + 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, + 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, + 0x3C, 0x3C, 0x42, 0x42, 0x02, 0x02, 0x0C, 0x0C, + 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x9A, 0x9A, 0xAA, 0xAA, + 0xBC, 0xBC, 0x80, 0x80, 0x7C, 0x7C, 0x00, 0x00, + 0x38, 0x38, 0x44, 0x44, 0x82, 0x82, 0x82, 0x82, + 0xFE, 0xFE, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + 0xFC, 0xFC, 0x82, 0x82, 0x82, 0x82, 0xFC, 0xFC, + 0x82, 0x82, 0x82, 0x82, 0xFC, 0xFC, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0xF8, 0xF8, 0x84, 0x84, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x84, 0x84, 0xF8, 0xF8, 0x00, 0x00, + 0xFE, 0xFE, 0x80, 0x80, 0x80, 0x80, 0xFC, 0xFC, + 0x80, 0x80, 0x80, 0x80, 0xFE, 0xFE, 0x00, 0x00, + 0xFE, 0xFE, 0x80, 0x80, 0x80, 0x80, 0xFC, 0xFC, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x80, 0x80, 0x80, 0x80, + 0x8E, 0x8E, 0x82, 0x82, 0x7E, 0x7E, 0x00, 0x00, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0xFE, 0xFE, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + 0x7C, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x7C, 0x7C, 0x00, 0x00, + 0x1E, 0x1E, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x84, 0x84, 0x78, 0x78, 0x00, 0x00, + 0x84, 0x84, 0x88, 0x88, 0x90, 0x90, 0xF0, 0xF0, + 0x88, 0x88, 0x84, 0x84, 0x82, 0x82, 0x00, 0x00, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x7E, 0x7E, 0x00, 0x00, + 0x82, 0x82, 0xC6, 0xC6, 0xAA, 0xAA, 0x92, 0x92, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + 0x82, 0x82, 0xC2, 0xC2, 0xA2, 0xA2, 0x92, 0x92, + 0x8A, 0x8A, 0x86, 0x86, 0x82, 0x82, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0xFC, 0xFC, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0xFC, 0xFC, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + 0x7C, 0x7C, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, + 0x8A, 0x8A, 0x84, 0x84, 0x7A, 0x7A, 0x00, 0x00, + 0xFC, 0xFC, 0x82, 0x82, 0x82, 0x82, 0x84, 0x84, + 0xF8, 0xF8, 0x84, 0x84, 0x82, 0x82, 0x00, 0x00, + 0x7C, 0x7C, 0x80, 0x80, 0x80, 0x80, 0x7C, 0x7C, + 0x02, 0x02, 0x02, 0x02, 0xFC, 0xFC, 0x00, 0x00, + 0xFE, 0xFE, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x7C, 0x7C, 0x00, 0x00, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, + 0xAA, 0xAA, 0xC6, 0xC6, 0x82, 0x82, 0x00, 0x00, + 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, + 0x28, 0x28, 0x44, 0x44, 0x82, 0x82, 0x00, 0x00, + 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + 0xFE, 0xFE, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, + 0x20, 0x20, 0x40, 0x40, 0xFE, 0xFE, 0x00, 0x00, + 0x1C, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x1C, 0x1C, 0x00, 0x00, + 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, + 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x00, 0x00, + 0x70, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x70, 0x70, 0x00, 0x00, + 0x10, 0x10, 0x28, 0x28, 0x44, 0x44, 0x82, 0x82, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0x00, 0x00}; + +/* End of ALPHABET.C */ diff --git a/res/alphabet.h b/res/alphabet.h new file mode 100644 index 0000000..5cca50a --- /dev/null +++ b/res/alphabet.h @@ -0,0 +1,31 @@ +/* + + ALPHABET.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 47 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + + +/* Bank of tiles. */ +#define alphabetBank 0 +/* Start of tile array. */ +extern unsigned char alphabet[]; + +/* End of ALPHABET.H */ diff --git a/res/blankScreen.c b/res/blankScreen.c new file mode 100644 index 0000000..b37d59a --- /dev/null +++ b/res/blankScreen.c @@ -0,0 +1,19 @@ +unsigned char blankScreen[] = + { + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30}; \ No newline at end of file diff --git a/res/blankScreen.h b/res/blankScreen.h new file mode 100644 index 0000000..060e41e --- /dev/null +++ b/res/blankScreen.h @@ -0,0 +1,6 @@ +/* Bank of tiles. */ +#define blankScreenBank 0 +/* Start of tile array. */ +extern unsigned char blankScreen[]; + +/* End of ALPHABET.H */ \ No newline at end of file diff --git a/res/collision-test/tilemap.c b/res/collision-test/tilemap.c new file mode 100644 index 0000000..1d42363 --- /dev/null +++ b/res/collision-test/tilemap.c @@ -0,0 +1,33 @@ +//AUTOGENERATED FILE FROM png2asset + +#include +#include +#include + +BANKREF(tilemap) + +const palette_color_t tilemap_palettes[4] = { + RGB8(255,255,255), RGB8(212,212,212), RGB8(138,138,138), RGB8( 0, 0, 0) + +}; + +const unsigned char tilemap_map[360] = { + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x07,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x09,0x09,0x09,0x07,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x05,0x09,0x09,0x09,0x09,0x09,0x00,0x00,0x06,0x09,0x09,0x09,0x08,0x00,0x00, + 0x00,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x06,0x09,0x09,0x09,0x01,0x00,0x00,0x00,0x00,0x00,0x02,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, +}; diff --git a/res/collision-test/tilemap.h b/res/collision-test/tilemap.h new file mode 100644 index 0000000..b442241 --- /dev/null +++ b/res/collision-test/tilemap.h @@ -0,0 +1,27 @@ +//AUTOGENERATED FILE FROM png2asset +#ifndef METASPRITE_tilemap_H +#define METASPRITE_tilemap_H + +#include +#include +#include + +#define tilemap_TILE_ORIGIN 0 +#define tilemap_TILE_W 8 +#define tilemap_TILE_H 8 +#define tilemap_WIDTH 160 +#define tilemap_HEIGHT 144 +#define tilemap_TILE_COUNT 0 +#define tilemap_PALETTE_COUNT 1 +#define tilemap_COLORS_PER_PALETTE 4 +#define tilemap_TOTAL_COLORS 4 +#define tilemap_MAP_ATTRIBUTES 0 + +BANKREF_EXTERN(tilemap) + +extern const palette_color_t tilemap_palettes[4]; + +extern const unsigned char tilemap_map[360]; +#define tilemap_map_attributes tilemap_map + +#endif diff --git a/res/collision-test/tileset.c b/res/collision-test/tileset.c new file mode 100644 index 0000000..73617e5 --- /dev/null +++ b/res/collision-test/tileset.c @@ -0,0 +1,56 @@ +//AUTOGENERATED FILE FROM png2asset + +#include +#include +#include + +BANKREF(tileset) + +const palette_color_t tileset_palettes[4] = { + RGB8(255,255,255), RGB8(212,212,212), RGB8(138,138,138), RGB8( 0, 0, 0) + +}; + +const uint8_t tileset_tiles[160] = { + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0x7f,0x7f,0x3f,0x3f, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xfe,0xfe,0xfc,0xfc, + 0xfc,0xfc,0xfe,0xfe, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0x3f,0x3f,0x7f,0x7f, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0x3c,0x3c,0x7e,0x7e, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xfc,0xfc,0xfe,0xfe, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xfe,0xfe,0xfc,0xfc, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0x7e,0x7e,0x3c,0x3c, + 0x3f,0x3f,0x7f,0x7f, + 0xff,0xff,0xff,0xff, + 0xff,0xff,0xff,0xff, + 0x7f,0x7f,0x3f,0x3f, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00 + }; + diff --git a/res/collision-test/tileset.h b/res/collision-test/tileset.h new file mode 100644 index 0000000..530783b --- /dev/null +++ b/res/collision-test/tileset.h @@ -0,0 +1,25 @@ +//AUTOGENERATED FILE FROM png2asset +#ifndef METASPRITE_tileset_H +#define METASPRITE_tileset_H + +#include +#include +#include + +#define tileset_TILE_ORIGIN 0 +#define tileset_TILE_W 8 +#define tileset_TILE_H 8 +#define tileset_WIDTH 80 +#define tileset_HEIGHT 8 +#define tileset_TILE_COUNT 10 +#define tileset_PALETTE_COUNT 1 +#define tileset_COLORS_PER_PALETTE 4 +#define tileset_TOTAL_COLORS 4 + +BANKREF_EXTERN(tileset) + +extern const palette_color_t tileset_palettes[4]; +extern const uint8_t tileset_tiles[160]; + + +#endif diff --git a/res/dungeon_32x32.gbm b/res/dungeon_32x32.gbm new file mode 100644 index 0000000..7418854 Binary files /dev/null and b/res/dungeon_32x32.gbm differ diff --git a/res/dungeon_32x32.gbr b/res/dungeon_32x32.gbr new file mode 100644 index 0000000..ba5ca53 Binary files /dev/null and b/res/dungeon_32x32.gbr differ diff --git a/res/dungeon_map.c b/res/dungeon_map.c new file mode 100644 index 0000000..b1617ee --- /dev/null +++ b/res/dungeon_map.c @@ -0,0 +1,133 @@ +/* + + DUNGEON_MAP.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 32 x 32 + Tile set : dungeon_32x32.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define dungeon_mapWidth 32 +#define dungeon_mapHeight 32 +#define dungeon_mapBank 0 + +#define dungeon_map dungeon_mapPLN0 +const unsigned char dungeon_mapPLN0[] = +{ + 0x0A,0x0B,0x07,0x05,0x06,0x04,0x07,0x03,0x04,0x07, + 0x03,0x04,0x07,0x08,0x09,0x01,0x0A,0x0B,0x07,0x07, + 0x03,0x04,0x07,0x03,0x04,0x07,0x03,0x04,0x03,0x0C, + 0x08,0x09,0x0D,0x0E,0x0F,0x12,0x13,0x11,0x0F,0x10, + 0x11,0x0F,0x10,0x11,0x0F,0x14,0x15,0x01,0x0D,0x0E, + 0x0F,0x0F,0x10,0x11,0x0F,0x10,0x11,0x0F,0x10,0x11, + 0x10,0x16,0x14,0x15,0x17,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01, + 0x1B,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x1D,0x1E,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x21,0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x23,0x24,0x25,0x24,0x26, + 0x00,0x00,0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00, + 0x00,0x23,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x00, + 0x27,0x28,0x17,0x18,0x00,0x00,0x00,0x19,0x2B,0x2C, + 0x2D,0x20,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x19,0x2B,0x2C,0x2D,0x20,0x00,0x00, + 0x00,0x00,0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x21, + 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x21,0x15,0x01, + 0x0D,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00, + 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x30, + 0x31,0x32,0x33,0x20,0x00,0x00,0x00,0x21,0x22,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1F,0x1C, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x34,0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x27, + 0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x19,0x1A,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20,0x00,0x00, + 0x00,0x00,0x21,0x22,0x1B,0x20,0x00,0x00,0x00,0x21, + 0x22,0x01,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00, + 0x00,0x19,0x1A,0x01,0x37,0x38,0x24,0x26,0x00,0x00, + 0x00,0x23,0x24,0x24,0x25,0x24,0x39,0x3A,0x3B,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20, + 0x00,0x00,0x00,0x21,0x22,0x01,0x3C,0x3D,0x2D,0x20, + 0x00,0x00,0x00,0x19,0x2B,0x3E,0x3F,0x3E,0x40,0x41, + 0x42,0x01,0x1B,0x20,0x00,0x00,0x00,0x00,0x21,0x22, + 0x1F,0x1C,0x00,0x00,0x00,0x27,0x15,0x01,0x01,0x01, + 0x1F,0x1C,0x00,0x00,0x00,0x21,0x22,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x0D,0x20,0x00,0x00,0x00,0x00, + 0x19,0x1A,0x1F,0x1C,0x00,0x00,0x00,0x30,0x31,0x0B, + 0x03,0x07,0x33,0x20,0x00,0x00,0x00,0x30,0x31,0x08, + 0x09,0x01,0x0A,0x0B,0x07,0x0B,0x33,0x20,0x00,0x00, + 0x00,0x00,0x21,0x22,0x1F,0x1C,0x00,0x00,0x00,0x34, + 0x35,0x0F,0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x34, + 0x35,0x14,0x15,0x01,0x0D,0x0E,0x0F,0x0F,0x10,0x36, + 0x00,0x00,0x00,0x00,0x19,0x22,0x29,0x2A,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x43,0x44,0x2E,0x2F, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x45,0x46, + 0x1B,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x31,0x32, + 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x21,0x22,0x37,0x38,0x24,0x24,0x24,0x24,0x24,0x25, + 0x24,0x39,0x24,0x25,0x24,0x26,0x00,0x00,0x00,0x34, + 0x35,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x24, + 0x24,0x24,0x3A,0x3B,0x3C,0x3D,0x3E,0x3E,0x3E,0x3E, + 0x3E,0x3F,0x3E,0x40,0x3E,0x2C,0x2D,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x2B,0x41,0x3E,0x3E,0x41,0x42,0x01,0x01,0x01,0x01, + 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x1F,0x1C, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x21,0x22,0x01,0x01,0x01,0x01,0x01,0x0A,0x0B, + 0x07,0x03,0x07,0x03,0x04,0x07,0x03,0x04,0x0B,0x0B, + 0x33,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x30,0x31,0x0B,0x07,0x03,0x08,0x09, + 0x0D,0x0E,0x0F,0x10,0x0F,0x10,0x11,0x0F,0x10,0x11, + 0x10,0x0F,0x10,0x36,0x00,0x00,0x00,0x23,0x24,0x25, + 0x24,0x26,0x00,0x00,0x00,0x34,0x35,0x10,0x0F,0x10, + 0x14,0x15,0x1F,0x1C,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19, + 0x2B,0x2C,0x2D,0x20,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x27,0x28,0x1F,0x1C,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x27,0x28,0x01,0x17,0x18,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x19,0x1A,0x1B,0x20,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x19,0x1A,0x01,0x1F,0x1C,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x47,0x48, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x21,0x22,0x01,0x1B,0x20, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x22, + 0x37,0x38,0x49,0x4A,0x4B,0x24,0x39,0x24,0x24,0x24, + 0x25,0x24,0x39,0x24,0x24,0x39,0x25,0x3A,0x3B,0x01, + 0x37,0x38,0x24,0x25,0x24,0x39,0x24,0x25,0x24,0x39, + 0x3A,0x3B,0x3C,0x3D,0x4C,0x4D,0x4E,0x3E,0x40,0x3E, + 0x3E,0x3E,0x3F,0x3E,0x40,0x3E,0x3E,0x40,0x3F,0x41, + 0x42,0x01,0x3C,0x3D,0x3E,0x3F,0x3E,0x40,0x3E,0x3F, + 0x3E,0x40,0x41,0x42 +}; + +/* End of DUNGEON_MAP.C */ diff --git a/res/dungeon_map.h b/res/dungeon_map.h new file mode 100644 index 0000000..ac54824 --- /dev/null +++ b/res/dungeon_map.h @@ -0,0 +1,28 @@ +/* + + DUNGEON_MAP.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 32 x 32 + Tile set : dungeon_32x32.gbr + Plane count : 1 plane (8 bits) + Plane order : Planes are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define dungeon_mapWidth 32 +#define dungeon_mapHeight 32 +#define dungeon_mapBank 0 + +#define dungeon_map dungeon_mapPLN0 +extern const unsigned char dungeon_mapPLN0[]; + +/* End of DUNGEON_MAP.H */ diff --git a/res/dungeon_tiles.c b/res/dungeon_tiles.c new file mode 100644 index 0000000..0620196 --- /dev/null +++ b/res/dungeon_tiles.c @@ -0,0 +1,188 @@ +/* + + DUNGEON_TILES.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 78 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +const unsigned char dungeon_tiles[] = +{ + 0x00,0xFF,0x00,0xFF,0x00,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, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, + 0xFF,0xFF,0x08,0x08,0x08,0x08,0xEB,0x1C, + 0xFF,0xFF,0x80,0x80,0xFF,0x80,0xFF,0x80, + 0xFF,0xFF,0x10,0x10,0x10,0x10,0xD7,0x38, + 0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0xFF,0x78,0x37,0xF3,0x6F,0x67,0xDF, + 0xCF,0xFF,0x4F,0x7F,0xDF,0x7F,0xDF,0x7F, + 0xFF,0xFF,0x1E,0xEC,0xCF,0xF6,0xE6,0xFB, + 0xF3,0xFF,0xF2,0xFE,0xFB,0xFE,0xFB,0xFE, + 0xFF,0xFF,0x90,0x90,0x90,0x90,0xD7,0xB8, + 0xFF,0xFF,0x80,0x80,0xFF,0x80,0xFF,0x80, + 0xFF,0xFF,0x00,0x00,0x00,0x00,0x7F,0x80, + 0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0xFF,0x03,0x03,0x05,0x05,0xE9,0x19, + 0xF1,0xF9,0x39,0x31,0xD9,0x51,0xD9,0x91, + 0xFF,0xFF,0xC0,0xC0,0xA0,0xA0,0x97,0x98, + 0x8F,0x9F,0x9C,0x8C,0x9B,0x8A,0x9B,0x89, + 0xFF,0xFF,0x00,0x00,0x00,0x00,0xFE,0x01, + 0xFF,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00, + 0xFF,0xFF,0x09,0x09,0x09,0x09,0xEB,0x1D, + 0xFF,0xFF,0x81,0x81,0xFF,0x81,0xFF,0x81, + 0x9B,0x88,0x9B,0x88,0x9B,0x88,0x9B,0x88, + 0x9B,0x88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xF7,0x8F,0xF7,0x8F,0xF8, + 0x90,0xFF,0xA0,0xFF,0xC0,0xFF,0xFF,0xFF, + 0x01,0xFF,0x03,0xFF,0xFF,0xFF,0xFF,0x04, + 0x04,0xFF,0x04,0xFF,0x0E,0xFF,0xFF,0xFF, + 0xB1,0xEF,0x71,0xEF,0xF1,0xEF,0xF1,0x1F, + 0x09,0xFF,0x05,0xFF,0x03,0xFF,0xFF,0xFF, + 0x8B,0x98,0x9B,0x88,0x9B,0x88,0x9B,0x88, + 0x9B,0x88,0x9B,0x88,0x9B,0x88,0x9B,0x88, + 0x73,0xEF,0x33,0xEF,0x34,0xEF,0x38,0xEF, + 0x3F,0xF0,0x7F,0xFF,0x61,0xFF,0x80,0xFF, + 0xFF,0xFF,0x33,0xFF,0x11,0xFF,0x11,0xFF, + 0xFF,0x11,0xFF,0xFF,0x83,0xFF,0x01,0xFF, + 0xCE,0xF7,0xCC,0xF7,0x2C,0xF7,0x1C,0xF7, + 0xFC,0x0F,0xFE,0xFF,0x86,0xFF,0x01,0xFF, + 0xD1,0x19,0xD9,0x11,0xD9,0x11,0xD9,0x11, + 0xD9,0x11,0xD9,0x11,0xD9,0x11,0xD9,0x11, + 0x9B,0x89,0x9B,0x8A,0x9C,0x8C,0x8F,0x9F, + 0x97,0x98,0xA0,0xA0,0xC0,0xC0,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0xFF, + 0xFE,0x01,0x00,0x00,0x00,0x00,0xFF,0xFF, + 0xFF,0x01,0xFF,0x01,0x01,0x01,0xFF,0xFF, + 0xD7,0x38,0x10,0x10,0x10,0x10,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0x00,0x00,0xFF,0xFF, + 0xEB,0x1C,0x08,0x08,0x08,0x08,0xFF,0xFF, + 0xFF,0x01,0xFF,0x01,0x01,0x01,0xFF,0xFF, + 0xEB,0x1D,0x09,0x09,0x09,0x09,0xFF,0xFF, + 0xFF,0x00,0xFF,0x00,0x00,0x00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FE,0xFB,0xFE,0xF2,0xFE,0xF3,0xFF, + 0xE6,0xFB,0xCF,0xF6,0x1E,0xEC,0xFF,0xFF +}; + +/* End of DUNGEON_TILES.C */ diff --git a/res/dungeon_tiles.h b/res/dungeon_tiles.h new file mode 100644 index 0000000..f93486f --- /dev/null +++ b/res/dungeon_tiles.h @@ -0,0 +1,103 @@ +/* + + DUNGEON_TILES.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 78 + + Palette colors : Included. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + + +/* Bank of tiles. */ +#define dungeon_tilesBank 0 + +/* Super Gameboy palette 0 */ +#define dungeon_tilesSGBPal0c0 0 +#define dungeon_tilesSGBPal0c1 0 +#define dungeon_tilesSGBPal0c2 22528 +#define dungeon_tilesSGBPal0c3 44 + +/* Super Gameboy palette 1 */ +#define dungeon_tilesSGBPal1c0 6076 +#define dungeon_tilesSGBPal1c1 8935 +#define dungeon_tilesSGBPal1c2 6596 +#define dungeon_tilesSGBPal1c3 5344 + +/* Super Gameboy palette 2 */ +#define dungeon_tilesSGBPal2c0 6076 +#define dungeon_tilesSGBPal2c1 8935 +#define dungeon_tilesSGBPal2c2 6596 +#define dungeon_tilesSGBPal2c3 5344 + +/* Super Gameboy palette 3 */ +#define dungeon_tilesSGBPal3c0 6076 +#define dungeon_tilesSGBPal3c1 8935 +#define dungeon_tilesSGBPal3c2 6596 +#define dungeon_tilesSGBPal3c3 5344 + +/* Gameboy Color palette 0 */ +#define dungeon_tilesCGBPal0c0 26620 +#define dungeon_tilesCGBPal0c1 14096 +#define dungeon_tilesCGBPal0c2 10662 +#define dungeon_tilesCGBPal0c3 2112 + +/* Gameboy Color palette 1 */ +#define dungeon_tilesCGBPal1c0 6076 +#define dungeon_tilesCGBPal1c1 8935 +#define dungeon_tilesCGBPal1c2 6596 +#define dungeon_tilesCGBPal1c3 5344 + +/* Gameboy Color palette 2 */ +#define dungeon_tilesCGBPal2c0 6076 +#define dungeon_tilesCGBPal2c1 8935 +#define dungeon_tilesCGBPal2c2 6596 +#define dungeon_tilesCGBPal2c3 5344 + +/* Gameboy Color palette 3 */ +#define dungeon_tilesCGBPal3c0 6076 +#define dungeon_tilesCGBPal3c1 8935 +#define dungeon_tilesCGBPal3c2 6596 +#define dungeon_tilesCGBPal3c3 5344 + +/* Gameboy Color palette 4 */ +#define dungeon_tilesCGBPal4c0 6076 +#define dungeon_tilesCGBPal4c1 8935 +#define dungeon_tilesCGBPal4c2 6596 +#define dungeon_tilesCGBPal4c3 5344 + +/* Gameboy Color palette 5 */ +#define dungeon_tilesCGBPal5c0 6076 +#define dungeon_tilesCGBPal5c1 8935 +#define dungeon_tilesCGBPal5c2 6596 +#define dungeon_tilesCGBPal5c3 5344 + +/* Gameboy Color palette 6 */ +#define dungeon_tilesCGBPal6c0 6076 +#define dungeon_tilesCGBPal6c1 8935 +#define dungeon_tilesCGBPal6c2 6596 +#define dungeon_tilesCGBPal6c3 5344 + +/* Gameboy Color palette 7 */ +#define dungeon_tilesCGBPal7c0 6076 +#define dungeon_tilesCGBPal7c1 8935 +#define dungeon_tilesCGBPal7c2 6596 +#define dungeon_tilesCGBPal7c3 5344 +/* Start of tile array. */ +extern const const unsigned char dungeon_tiles[]; + +/* End of DUNGEON_TILES.H */ diff --git a/res/helloWorld.c b/res/helloWorld.c new file mode 100644 index 0000000..50be412 --- /dev/null +++ b/res/helloWorld.c @@ -0,0 +1,30 @@ +/* + + HELLOWORLD.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 10 x 2 + Tile set : C:\users\normanbos\Desktop\alphabet.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define helloWorldWidth 10 +#define helloWorldHeight 2 +#define helloWorldBank 0 + +unsigned char helloWorld[] = + { + 0x30, 0x30, 0x18, 0x15, 0x1C, 0x1C, 0x1F, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x27, 0x1F, 0x22, 0x1C, 0x14, 0x30, 0x30, 0x30}; + +/* End of HELLOWORLD.C */ diff --git a/res/helloWorld.h b/res/helloWorld.h new file mode 100644 index 0000000..b5f18cf --- /dev/null +++ b/res/helloWorld.h @@ -0,0 +1,27 @@ +/* + + HELLOWORLD.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 10 x 2 + Tile set : C:\users\normanbos\Desktop\alphabet.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define helloWorldWidth 10 +#define helloWorldHeight 2 +#define helloWorldBank 0 + +extern unsigned char helloWorld[]; + +/* End of HELLOWORLD.H */ diff --git a/res/hud.c b/res/hud.c new file mode 100644 index 0000000..4100fa2 --- /dev/null +++ b/res/hud.c @@ -0,0 +1,30 @@ +/* + + HUD.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 1 + Tile set : C:\users\normanbos\Desktop\alphabet.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define hudWidth 20 +#define hudHeight 1 +#define hudBank 0 + +unsigned char hud[] = + { + 0x30, 0x0B, 0x31, 0x14, 0x15, 0x20, 0x24, 0x18, 0x0A, 0x00, + 0x00, 0x00, 0x31, 0x1F, 0x0A, 0x09, 0x09, 0x30, 0x0B, 0x30}; + +/* End of HUD.C */ diff --git a/res/hud.h b/res/hud.h new file mode 100644 index 0000000..781cb7b --- /dev/null +++ b/res/hud.h @@ -0,0 +1,27 @@ +/* + + HUD.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 20 x 1 + Tile set : C:\users\normanbos\Desktop\alphabet.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define hudWidth 20 +#define hudHeight 1 +#define hudBank 0 + +extern unsigned char hud[]; + +/* End of HUD.H */ diff --git a/res/submarine_sprites.c b/res/submarine_sprites.c new file mode 100644 index 0000000..e963f81 --- /dev/null +++ b/res/submarine_sprites.c @@ -0,0 +1,75 @@ +/* + + SUBMARINE.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 12 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ +#include +/* Start of tile array. */ +unsigned char submarine_tileset[] = + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, + 0x07, 0x07, 0x04, 0x07, 0x04, 0x07, 0x0B, 0x0F, + 0x6F, 0x68, 0x57, 0x79, 0xE7, 0x9A, 0xA7, 0xDA, + 0x91, 0xFF, 0x78, 0x7F, 0x6F, 0x6F, 0x07, 0x07, + 0x00, 0x00, 0x80, 0xC0, 0x80, 0x80, 0x80, 0x80, + 0x60, 0xE0, 0xA0, 0x60, 0xB0, 0x70, 0xDE, 0xFE, + 0xF3, 0x11, 0xE1, 0x91, 0xFD, 0x51, 0xFD, 0x51, + 0x8D, 0xF9, 0x06, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x07, 0x07, 0x04, 0x07, 0x04, 0x07, 0x0B, 0x0F, + 0x0F, 0x08, 0x17, 0x19, 0xE7, 0xFA, 0xE7, 0x9A, + 0xF1, 0xFF, 0x18, 0x1F, 0x0F, 0x0F, 0x07, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, + 0x60, 0xE0, 0xA0, 0x60, 0xB0, 0x70, 0xDE, 0xFE, + 0xF3, 0x11, 0xE1, 0x91, 0xFD, 0x51, 0xFD, 0x51, + 0x8D, 0xF9, 0x06, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, + 0x07, 0x07, 0x04, 0x07, 0x04, 0x07, 0x0B, 0x0F, + 0x8F, 0x88, 0x97, 0x99, 0xE7, 0xFA, 0xE7, 0x9A, + 0xF1, 0xFF, 0x98, 0x9F, 0x8F, 0x8F, 0x07, 0x07, + 0x00, 0x00, 0x80, 0xC0, 0x80, 0x80, 0x80, 0x80, + 0x60, 0xE0, 0xA0, 0x60, 0xB0, 0x70, 0xDE, 0xFE, + 0xF3, 0x11, 0xE1, 0x91, 0xFD, 0x51, 0xFD, 0x51, + 0x8D, 0xF9, 0x06, 0xFE, 0xFC, 0xFC, 0xF8, 0xF8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +/* Metatile index */ +const unsigned char submarine_tilemap[] = + { + 0x00, 0x02, 0x01, 0x03}; + +// Create the metasprite structure for the character +const metasprite_t submarine_metasprite[] = { + {.dy = -8, .dx = -8, .dtile = 0, .props = 0}, + {.dy = 0, .dx = 8, .dtile = 2, .props = 0}, + {.dy = 8, .dx = -8, .dtile = 1, .props = 0}, + {.dy = 0, .dx = 8, .dtile = 3, .props = 0}, + METASPR_TERM}; + +const metasprite_t submarine_metasprite2[] = { + {.dy = -8, .dx = -8, .dtile = 0, .props = 0}, + {.dy = 0, .dx = 8, .dtile = 2, .props = 0}, + {.dy = 8, .dx = -8, .dtile = 5, .props = 0}, + {.dy = 0, .dx = 8, .dtile = 3, .props = 0}, + METASPR_TERM}; + +/* End of SUBMARINE.C */ diff --git a/res/submarine_sprites.h b/res/submarine_sprites.h new file mode 100644 index 0000000..01ce4fd --- /dev/null +++ b/res/submarine_sprites.h @@ -0,0 +1,36 @@ +/* + + SUBMARINE.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 12 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ +#include +/* Bank of tiles. */ +#define submarineBank 0 +/* Start of tile array. */ +extern const unsigned char submarine_tileset[]; +/* Metatile index */ +extern const unsigned char submarine_tilemap[]; +// Create the metasprite structure for the character +extern const metasprite_t submarine_metasprite[]; + +extern const metasprite_t submarine_metasprite2[]; + +/* End of SUBMARINE.H */ diff --git a/res/underwater_map.c b/res/underwater_map.c new file mode 100644 index 0000000..46fb619 --- /dev/null +++ b/res/underwater_map.c @@ -0,0 +1,64 @@ +/* + + UNDERWATER_MAP.C + + Map Source File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\users\normanbos\Desktop\underwater-tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define underwater_mapWidth 20 +#define underwater_mapHeight 18 +#define underwater_mapBank 0 + +unsigned char underwater_map[] = + { + 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, + 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, 0x10, 0x12, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x14, 0x16, + 0x14, 0x16, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x1C, 0x1E, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x1D, 0x1F, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x20, 0x22, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x1C, 0x1E, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x21, 0x23, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x1D, 0x1F, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x08, 0x24, 0x26, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x24, 0x26, 0x08, 0x18, 0x18, + 0x18, 0x18, 0x09, 0x25, 0x27, 0x0B, 0x09, 0x0B, 0x09, 0x0B, + 0x09, 0x0B, 0x09, 0x0B, 0x09, 0x25, 0x27, 0x0B, 0x18, 0x18, + 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, + 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, 0x04, 0x05, + 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, + 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07, 0x06, 0x07}; + +/* End of UNDERWATER_MAP.C */ diff --git a/res/underwater_map.h b/res/underwater_map.h new file mode 100644 index 0000000..df7f230 --- /dev/null +++ b/res/underwater_map.h @@ -0,0 +1,27 @@ +/* + + UNDERWATER_MAP.H + + Map Include File. + + Info: + Section : + Bank : 0 + Map size : 20 x 18 + Tile set : C:\users\normanbos\Desktop\underwater-tiles.gbr + Plane count : 1 plane (8 bits) + Plane order : Tiles are continues + Tile offset : 0 + Split data : No + + This file was generated by GBMB v1.8 + +*/ + +#define underwater_mapWidth 20 +#define underwater_mapHeight 18 +#define underwater_mapBank 0 + +extern unsigned char underwater_map[]; + +/* End of UNDERWATER_MAP.H */ diff --git a/res/underwater_tiles.c b/res/underwater_tiles.c new file mode 100644 index 0000000..b9dc120 --- /dev/null +++ b/res/underwater_tiles.c @@ -0,0 +1,111 @@ +/* + + UNDERWATER_TILES.C + + Tile Source File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 40 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + +/* Start of tile array. */ +unsigned char underwater_tiles[] = + { + 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, + 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, + 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, + 0x00, 0x20, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x04, 0x00, 0x20, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x7E, 0x3C, 0xC3, 0xC3, 0x30, 0x00, 0xC0, 0x00, + 0xE3, 0x00, 0x98, 0x00, 0x6F, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0x3F, 0x1E, 0xE1, 0xE1, 0x18, 0x00, 0x61, 0x00, + 0x93, 0x00, 0x7F, 0x00, 0x19, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0xFF, 0x00, 0x00, 0xE9, 0x86, 0x80, 0xFF, + 0xC6, 0xFF, 0xFD, 0xF9, 0xFE, 0x70, 0xFF, 0x80, + 0xFF, 0x90, 0xDF, 0x58, 0xEF, 0x8F, 0xFF, 0x8F, + 0xFF, 0xC4, 0xFD, 0xF8, 0xFE, 0x70, 0xFF, 0x80, + 0xFF, 0xFF, 0x00, 0x00, 0x48, 0x26, 0x01, 0xFE, + 0x01, 0xFF, 0xB7, 0xFF, 0x7F, 0x5E, 0xBF, 0x00, + 0xFF, 0x00, 0xF1, 0x60, 0xEE, 0xC0, 0xFF, 0x20, + 0xFF, 0x33, 0xFF, 0x3F, 0x7F, 0x1E, 0xBF, 0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x87, 0x78, 0x87, 0x78, + 0x07, 0xF8, 0x0F, 0xF0, 0x0F, 0xF0, 0x1F, 0xE0, + 0x1F, 0xE0, 0x1F, 0xE0, 0x3F, 0xC0, 0x3F, 0xC0, + 0xE0, 0x1F, 0xE0, 0x1F, 0xF0, 0x0F, 0xF8, 0x07, + 0xFC, 0x03, 0xFC, 0x03, 0xFE, 0x01, 0xFC, 0x03, + 0xF9, 0xFE, 0x00, 0x07, 0x00, 0x03, 0x00, 0x21, + 0x00, 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0C, + 0x7F, 0x80, 0x7F, 0x80, 0x1F, 0xE0, 0x1F, 0xE0, + 0x0F, 0xF0, 0x0F, 0xF0, 0x0F, 0xF0, 0x8F, 0x70, + 0x1F, 0xFF, 0x00, 0xC0, 0x00, 0x84, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x84, 0x00, 0xC0, 0x00, 0x60, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +/* End of UNDERWATER_TILES.C */ diff --git a/res/underwater_tiles.h b/res/underwater_tiles.h new file mode 100644 index 0000000..dd68d57 --- /dev/null +++ b/res/underwater_tiles.h @@ -0,0 +1,31 @@ +/* + + UNDERWATER_TILES.H + + Include File. + + Info: + Form : All tiles as one unit. + Format : Gameboy 4 color. + Compression : None. + Counter : None. + Tile size : 8 x 8 + Tiles : 0 to 40 + + Palette colors : None. + SGB Palette : None. + CGB Palette : None. + + Convert to metatiles : No. + + This file was generated by GBTD v2.2 + +*/ + + +/* Bank of tiles. */ +#define underwater_tilesBank 0 +/* Start of tile array. */ +extern unsigned char underwater_tiles[]; + +/* End of UNDERWATER_TILES.H */ diff --git a/src/actor.c b/src/actor.c new file mode 100644 index 0000000..21a9e85 --- /dev/null +++ b/src/actor.c @@ -0,0 +1,238 @@ +#include +#include +#include +#include +#include "collision.h" +#include "actor.h" + +//! Hierher gehören noch weiter Attribute. is_moving, direction, hitpoints, etc. +//! Oder besser: den Actor struct kann ich als Basis nehmen und evtl. extenden für verschiedene types (Player, Enemy, Pickup etc.) + +// A structure of the actor +/* typedef struct Actor +{ + uint8_t sprite_id; // The starting ID of the sprite for this actor. Remaining sprites should follow in sequency + uint8_t sprite_tile_width; // The number of tiles wide this sprite is + uint8_t sprite_tile_height; // The number tiles high this sprite is + uint8_t sprite_frame; // The total number of animated sprites + uint8_t sprite_current_frame; // The current frame the sprite is on + uint8_t tilemap_start; // The start index where the tiles start for this sprite + uint8_t x; // The sprite x position (top left) + uint8_t y; // The sprite y position (top left) + uint8_t next_x; // The future sprite x position (top left) + uint8_t next_y; // The future sprite y position (top left) + int8_t dx; // The sprite x moving direction + int8_t dy; // The sprite y moving direction + uint8_t velocity_x; // The current speed of travel in the X direction + uint8_t velocity_y; // The current speed of travel in the y direction + bool is_facing_right; // The direction the player sprite is facing + bool is_moving; // Is the actor moving or not + const unsigned char *tilemap; // A pointer to the tilemap (may be obsolete with metasprite) + const metasprite_t *metasprite; // A pointer to the metasprite +} Actor; */ + +//! die load_sprite_frame wird mit dem move_metasprite_ex gar nicht mehr benutzt! +/* void load_sprite_frame(Actor *actor, uint8_t frame) +{ + // Set current frame + actor->sprite_current_frame = frame; + + // Get total sprites + uint8_t spriteCount = actor->sprite_tile_width * actor->sprite_tile_height; + + for (uint8_t i = 0; i != spriteCount; i++) + { + set_sprite_tile(actor->sprite_id + i, actor->tilemap[actor->tilemap_start + i + (frame * spriteCount)]); + } +} */ + +void move_actor(Actor *actor, uint8_t x, uint8_t y) // Evtl. sollte is_moving hier mit übergeben werden +{ + + // Set actors new position + // actor->x = x; + // actor->y = y; + + // actor->x = actor->next_x; + // actor->y = actor->next_y; + + // Move the metasprite + if (actor->is_facing_right) + { + move_metasprite_ex(actor->metasprite, 0, 0, 0, x + 8, y + 16); + } + if (!actor->is_facing_right) + { + // flip the metasprite horizontally when is_facing_right is TRUE + move_metasprite_flipx(actor->metasprite, 0, 0, 0, x + 8, y + 16); + } +} + +void scroll_actor(Actor *actor) +{ + + uint8_t playerIsMoving = actor->dx != 0 || actor->dy != 0; + + // If the player is moving at all + // We'll handle horizontall and vertical movement separately + // Handling them separately enables a sliding motion against walls + if (playerIsMoving) + { + + // If we are moving horizontally + if (actor->dx != 0) + { + + // Check the tiles on our side + uint8_t solid = + world_position_is_solid(actor->next_x + actor->dx * PLAYER_HALF_WIDTH, actor->y - PLAYER_HALF_HEIGHT) || + world_position_is_solid(actor->next_x + actor->dx * PLAYER_HALF_WIDTH, actor->y) || + world_position_is_solid(actor->next_x + actor->dx * PLAYER_HALF_WIDTH, actor->y + PLAYER_HALF_HEIGHT); + + // printf("%u\n", world_position_is_solid(actor->x + actor->dx * PLAYER_HALF_WIDTH, actor->y - PLAYER_HALF_HEIGHT)); + + // If none are solid + if (!solid) + // if (solid != 0) + { + + // Update the player's x position + // actor->x += x; + actor->x = actor->next_x; + } + } + + // If we are moving vertically + if (actor->dy != 0) + { + + // Check the tiles above or below us + uint8_t solid = + world_position_is_solid(actor->x + PLAYER_HALF_WIDTH, actor->next_y + actor->dy * PLAYER_HALF_HEIGHT) || + world_position_is_solid(actor->x, actor->next_y + actor->dy * PLAYER_HALF_HEIGHT) || + world_position_is_solid(actor->x - PLAYER_HALF_WIDTH, actor->next_y + actor->dy * PLAYER_HALF_HEIGHT); + + // If none are solid + if (!solid) + // if (solid != 0) + { + + // Update the player's y position + // actor->y += y; + actor->y = actor->next_y; + } + } + + // actor->x += x; + // actor->y += y; + + move_actor(actor, actor->x, actor->y); + } +} + +void move_actor_with_joypad(Actor *actor) +{ + // Read buttons + uint8_t buttons = joypad(); + + bool is_moving_x = FALSE; + bool is_moving_y = FALSE; + + actor->dx = 0; + actor->dy = 0; + + if (buttons & J_LEFT) + { + actor->is_facing_right = FALSE; + is_moving_x = TRUE; + actor->next_x -= 1; + actor->dx = -1; + } + else if (buttons & J_RIGHT) + { + actor->is_facing_right = TRUE; + is_moving_x = TRUE; + actor->next_x += 1; + actor->dx = 1; + } + else + { + is_moving_x = FALSE; + } + + if (buttons & J_UP) + { + is_moving_y = TRUE; + actor->next_y -= 1; + actor->dy = -1; + } + else if (buttons & J_DOWN) + { + is_moving_y = TRUE; + actor->next_y += 1; + actor->dy = 1; + } + else + { + is_moving_y = FALSE; + } + + if (is_moving_x || is_moving_y) + { + actor->is_moving = TRUE; + } + else + { + actor->is_moving = FALSE; + } + + scroll_actor(actor); +} + +void setup_actor(Actor *actor, uint8_t sprite_id, uint8_t tile_width, uint8_t tile_height, uint8_t tilemap_start, uint8_t total_frames, bool is_facing_right, const unsigned char *tilemap, const metasprite_t *metasprite) +{ + + // Set initial X + actor->x = 80; + + // Set initial Y + actor->y = 90; + + // Set initial next X + actor->next_x = 80; + // Set initial next Y + actor->next_y = 90; + + // Set horizontal direction of + actor->is_facing_right = is_facing_right; + + // Set if the actor is moving + actor->is_moving = FALSE; + + // Store pointer to tilemap + actor->tilemap = tilemap; + + // Set tile start position (in tileset) + actor->tilemap_start = tilemap_start; + + // Set player sprite ID + actor->sprite_id = sprite_id; + + // Set size + actor->sprite_tile_width = tile_width; + actor->sprite_tile_height = tile_height; + + // Set number of frames + actor->sprite_frame = total_frames; + + // Make sure to start at frame 1 + actor->sprite_current_frame = 0; + + // Move to built in metasprite methods + // load_sprite_frame(actor, 0); + + // Store pointer to metasprite + actor->metasprite = metasprite; + + move_actor(actor, actor->x, actor->y); +} \ No newline at end of file diff --git a/src/actor.h b/src/actor.h new file mode 100644 index 0000000..7d6497b --- /dev/null +++ b/src/actor.h @@ -0,0 +1,39 @@ +#include +#include +#include +#include +#include "collision.h" + +//! Hierher gehören noch weiter Attribute. is_moving, direction, hitpoints, etc. +//! Oder besser: den Actor struct kann ich als Basis nehmen und evtl. extenden für verschiedene types (Player, Enemy, Pickup etc.) + +// A structure of the actor +typedef struct Actor +{ + uint8_t sprite_id; // The starting ID of the sprite for this actor. Remaining sprites should follow in sequency + uint8_t sprite_tile_width; // The number of tiles wide this sprite is + uint8_t sprite_tile_height; // The number tiles high this sprite is + uint8_t sprite_frame; // The total number of animated sprites + uint8_t sprite_current_frame; // The current frame the sprite is on + uint8_t tilemap_start; // The start index where the tiles start for this sprite + uint8_t x; // The sprite x position (top left) + uint8_t y; // The sprite y position (top left) + uint8_t next_x; // The future sprite x position (top left) + uint8_t next_y; // The future sprite y position (top left) + int8_t dx; // The sprite x moving direction + int8_t dy; // The sprite y moving direction + uint8_t velocity_x; // The current speed of travel in the X direction + uint8_t velocity_y; // The current speed of travel in the y direction + bool is_facing_right; // The direction the player sprite is facing + bool is_moving; // Is the actor moving or not + const unsigned char *tilemap; // A pointer to the tilemap (may be obsolete with metasprite) + const metasprite_t *metasprite; // A pointer to the metasprite +} Actor; + +void move_actor(Actor *actor, uint8_t x, uint8_t y); + +void scroll_actor(Actor *actor); + +void move_actor_with_joypad(Actor *actor); + +void setup_actor(Actor *actor, uint8_t sprite_id, uint8_t tile_width, uint8_t tile_height, uint8_t tilemap_start, uint8_t total_frames, bool is_facing_right, const unsigned char *tilemap, const metasprite_t *metasprite); \ No newline at end of file diff --git a/src/collision.c b/src/collision.c new file mode 100644 index 0000000..88be968 --- /dev/null +++ b/src/collision.c @@ -0,0 +1,49 @@ +#include +#include + +#include "../res/underwater_tiles.h" +#include "../res/underwater_map.h" +#include "../res/collision-test/tileset.h" +#include "../res/collision-test/tilemap.h" + +#define SOLID 1 +#define PLAYER_HALF_WIDTH 8 +#define PLAYER_HALF_HEIGHT 8 +#define GRID_NODE_SIZE 8 +#define NUMBER_OF_SOLID_TILES 9 + +#define TILEMAP_WIDTH_IN_TILES (tilemap_WIDTH >> 3) +#define TILEMAP_HEIGHT_IN_TILES (tilemap_HEIGHT >> 3) + +// uint16_t playerX, playerY; + +uint8_t world_position_is_solid(uint16_t x, uint16_t y) +{ + + // Bit-shifting would be faster here + uint16_t column = x / GRID_NODE_SIZE; + + // Make sure the tile is in proper bounds + if (column >= TILEMAP_WIDTH_IN_TILES) + return TRUE; + + uint16_t row = y / GRID_NODE_SIZE; + + // Make sure the tile is in proper bounds + if (row >= TILEMAP_HEIGHT_IN_TILES) + return TRUE; + + uint16_t tilemapIndex = column + row * TILEMAP_WIDTH_IN_TILES; + + uint8_t tileIsSolid = FALSE; + + // Get the tilset tile in our tilemap + uint8_t tilesetTile = tilemap_map[tilemapIndex]; + + // In our tileset, the solid tiles always come first. + // There are 10 tiles. The first 9 are solid + // this makes it fast & easy to determine if a tile is solid or not + tileIsSolid = tilesetTile < NUMBER_OF_SOLID_TILES; + + return tileIsSolid; +} \ No newline at end of file diff --git a/src/collision.h b/src/collision.h new file mode 100644 index 0000000..b8a70c7 --- /dev/null +++ b/src/collision.h @@ -0,0 +1,13 @@ +#include +#include + +#define SOLID 1 +#define PLAYER_MOVE_SPEED 10 +#define PLAYER_HALF_WIDTH 8 +#define PLAYER_HALF_HEIGHT 8 +#define GRID_NODE_SIZE 8 +#define NUMBER_OF_SOLID_TILES 9 + +// extern uint16_t playerX, playerY; + +uint8_t world_position_is_solid(uint16_t x, uint16_t y); diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..6e399b5 --- /dev/null +++ b/src/main.c @@ -0,0 +1,166 @@ +#include +#include + +#include "../res/alphabet.h" +#include "../res/blankScreen.h" +#include "../res/hud.h" +#include "../res/underwater_tiles.h" +#include "../res/underwater_map.h" +#include "../res/submarine_sprites.h" +#include "../res/collision-test/tileset.h" +#include "../res/collision-test/tilemap.h" + +#include "actor.h" +// #include "input.h" +#include "collision.h" + +Actor submarine; + +uint8_t two_frame_counter = 0; +uint8_t two_frame_real_value = 0; + +#define TILEMAP_WIDTH_IN_TILES (tilemap_WIDTH >> 3) +#define TILEMAP_HEIGHT_IN_TILES (tilemap_HEIGHT >> 3) + +// generic frame counter function +// from https://laroldsjubilantjunkyard.com/tutorial/rpg-style-movement-in-gbdk/ +void update_two_frame_counter(void) +{ + two_frame_counter += 1; + two_frame_real_value = two_frame_counter >> 3; + + // printf("%d\n", two_frame_counter); + // Stop & reset if the value is over 2 + if (two_frame_real_value >= 2) + { + two_frame_real_value = 0; + two_frame_counter = 0; + } +} + +//! Switch metasprite on certain frames. Could be heavily improved to take props for actor->spriteFrames and more +//! Should be called in some UpdateActor(&actor) Function +void animate_actor(Actor *actor, int8_t two_frame_counter) +{ + if (actor->is_moving) + { + if (two_frame_counter == 3) + { + actor->metasprite = submarine_metasprite; + } + + if (two_frame_counter == 9) + { + actor->metasprite = submarine_metasprite2; + } + } + else + { + actor->metasprite = submarine_metasprite; + move_actor(actor, actor->x, actor->y); // Necessary to trigger the metasprite change + } +} + +//! Die HUD Funktion muss ich reparieren, damit die immer in der Lage ist, die richtigen Tiles anzuzeigen +void show_hud(void) +{ + // Load tiles to the window layer + set_win_tiles(0, 0, 20, 1, hud); + + // Move the window layer down to the last tile row. + move_win(7, 136); + SHOW_WIN; +} + +//! This has to be refactored! A function with fixed values makes little sense. +void shiftBGTiles(void) +{ +#define VRAM_OFFSET 48 // Change this to your desired offset + + int map_size = 20 * 18; // Get the size of the map array + + for (int i = 0; i < map_size; i++) + { + underwater_map[i] += VRAM_OFFSET; + } +} + +void init(void) +{ + + // shiftBGTiles(); + + // Load HUD tiles + // set_bkg_data(0, 48, alphabet); + // Load background tiles after HUD tiles + // set_bkg_data(48, 40, underwater_tiles); + + // Use the 'blankScreen' array to write background tiles starting at 0,0 (tile positions) + // and for 20 tiles in width and 18 tiles in height + // set_bkg_tiles(0, 0, 20, 18, blankScreen); // Setting the first tile of alphabet to blank would be more efficient. + + // set_bkg_tiles(0, 0, 20, 18, underwater_map); + + set_bkg_data(0, tileset_TILE_COUNT, tileset_tiles); + + set_bkg_tiles(0, 0, TILEMAP_WIDTH_IN_TILES, TILEMAP_HEIGHT_IN_TILES, tilemap_map); + + // Fill tileset bank 0 with 4 actor tiles + set_sprite_data(0, 8, submarine_tileset); + + //! Prüfen, welche variables für das metasprite überhaupt noch benötigt werden + // Setup player actor + setup_actor( + // player + &submarine, + // Sprite ID: 0 + 0, + // 2x2 meta-sprite + 2, 2, + // Tiles start at 0 + 0, + // Total animated frames + 4, + // Set is_facing_right bool + TRUE, + // pointer to the tilemap + submarine_tilemap, + // pointer to the metasprite + submarine_metasprite); + + // MoveCharacter(&submarine, 80, 90); + + // Show the HUD + // show_hud(); + + SHOW_BKG; + SHOW_SPRITES; + // SPRITES_8x16; + DISPLAY_ON; + + // move_metasprite_ex(submarine_metasprite, 0, 0, 0, 80, 80); +} + +void main(void) +{ + + init(); + + // Main loop + while (1) + { + + update_two_frame_counter(); + animate_actor(&submarine, two_frame_counter); + + // Move the actor with the joypad + move_actor_with_joypad(&submarine); + // joypad_input(&submarine); + + // Wait for next frame + wait_vbl_done(); + + // Done processing, yield CPU and wait for start of next frame + vsync(); + } +} \ No newline at end of file