gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit a0132b91d1c30966efbbd78f3a24b61bbebe344a parent 97fe5268258f74776eed513fb640159a8460f8bd Author: Toxa <56631470+untoxa@users.noreply.github.com> Date: Wed, 17 Feb 2021 11:55:59 +0300 Merge pull request #139 from bbbbbr/develop_templates Docs + Examples: Add Getting Started doc section and Templates Diffstat:
18 files changed, 728 insertions(+), 10 deletions(-)
diff --git a/docs/pages/coding_guidelines.md b/docs/pages/coding_guidelines.md @@ -3,6 +3,8 @@ # Learning C / C fundamentals Writing games and other programs with GBDK will be much easier with a basic understanding of the C language. In particular, understanding how to use C on "Embedded Platforms" (small computing systems, such as the Game Boy) can help you write better code (smaller, faster, less error prone) and avoid common pitfals. + +@anchor docs_c_tutorials ## General C tutorials - https://www.learn-c.org/ - https://www.tutorialspoint.com/cprogramming/index.htm @@ -24,6 +26,17 @@ In addition to understanding the C language it's important to learn how the Game The following guidelines can result in better code for the Game Boy, even though some of the guidance may be contrary to typical advice for general purpose computers that have more resources and speed. +## Tools + +@anchor const_gbtd_gbmb +### GBTD / GBMB, Arrays and the "const" keyword +__Important__: The old @ref gbtd_gbmb "GBTD/GBMB" fails to include the `const` keyword when exporting to C source files for GBDK. That causes arrays to be created in RAM instead of ROM, which wastes RAM, uses a lot of ROM to initialize the RAM arrays and slows the compiler down a lot. + +__Use of @ref toxa_gbtd_gbmb "toxa's updated GBTD/GBMB" is highly recommended.__ + +If you wish to use the original tools, you must add the `const` keyword every time the graphics are re-exported to C source files. + + ## Variables - Use 8-bit values as much as possible. They will be much more efficient and compact than 16 and 32 bit types. @@ -35,7 +48,8 @@ The following guidelines can result in better code for the Game Boy, even though - Global and local static variables are generally more efficient than local non-static variables (which go on the stack and are slower and can result in slower code). - - `const` keyword: Use const for arrays, structs and variables with read-only (constant) data. It will reduce ROM, RAM and CPU usage significantly. Non-`const` values are loaded from ROM into RAM inefficiently, and there is no benefit in loading them into the limited available RAM if they aren't going to be changed. + - @anchor const_array_data + `const` keyword: Use const for arrays, structs and variables with read-only (constant) data. It will reduce ROM, RAM and CPU usage significantly. Non-`const` values are loaded from ROM into RAM inefficiently, and there is no benefit in loading them into the limited available RAM if they aren't going to be changed. - For calculated values that don't change, pre-compute results once and store the result. Using lookup-tables and the like can improve speed and reduce code size. Macros can sometimes help. It may be beneficial to do the calculations with an outside tool and then include the result as C code in a const array. diff --git a/docs/pages/docs_index.md b/docs/pages/docs_index.md @@ -1,15 +1,22 @@ @mainpage General Documentation +@anchor docs_index +- @subpage docs_getting_started - @subpage docs_links_and_tools - @subpage docs_using_gbdk - @subpage docs_coding_guidelines - @subpage docs_rombanking_mbcs - @subpage docs_toolchain -- @subpage docs_sample_programs +- @subpage docs_example_programs - @subpage docs_migrating_versions - @subpage docs_releases + +# Introduction +Welcome to GBDK-2020! The best thing to do is head over to the @ref docs_getting_started "Getting Started" section to get up and running. + + # About the Documentation This documentation is partially based on material written by the original GBDK authors in 1999 and updated for GBDK-2020. The API docs are automatically generated from the C header files using Doxygen. diff --git a/docs/pages/getting_started.md b/docs/pages/getting_started.md @@ -0,0 +1,55 @@ +@page docs_getting_started Getting Started + + +Follow the steps in this section to start using GBDK-2020. + + +# 1. Compile Example projects +Make sure your GBDK-2020 installation is working correctly by compiling some of the included @ref docs_example_programs "example projects". + +Navigate to the example projects folder (`"examples/gb/"` under your GBDK-2020 install folder) and open a command line. Then type: + + make + +This should build all of the examples sequentially. You can also navigate into an individual example project's folder and build it by typing `make`. + +If everything works and there are no errors reported each example sub-folder should have it's on .gb ROM file. + + +# 2. Use a Template +__To create a new project use a template!__ + +There are template projects included in the @ref docs_example_programs "GBDK example projects" to help you get up and running. Their folder names start with `template_`. + +1. Copy one of the template folders to a new folder name + +2. If you moved the folder out of the GBDK examples then you __must__ update the `GBDK` path variable and/or the path to `LCC` in the `Makefile` or `make.bat` so that it will still build correctly. + +3. Type `make` on the command line in that folder to verify it still builds. + +4. Open main.c to start making changes. + + +# 3. If you use GBTD / GBMB, get the fixed version +If you plan to use GBTD / GBMB for making graphics, make sure to get the version with the `const` fix and other improvements. See @ref const_gbtd_gbmb. + + +# 4. Review Coding Guidelines +Take a look at the @ref docs_coding_guidelines "coding guidelines", even if you have experience writing software for other platforms. There is important information to help you get good results and performance on the Game Boy. + +If you haven't written programs in C before, check the @ref docs_c_tutorials "C tutorials section". + + +# 5. Try a GBDK Tutorial +You might want to start off with a guided GBDK tutorial from the @ref links_gbdk_tutorials "GBDK Tutorials section". + + - __Note:__ Tutorials (or parts of them) may be based on the older GBDK from the 2000's before it was updated to be GBDK-2020. The general principals are all the same, but the setup and parts of the @ref docs_toolchain "toolchain" (compiler/etc) may be somewhat different and some links may be outdated (pointing to the old GBDK or old tools). + + +# 6. Read up! +- It is strongly encouraged to read more @ref docs_index "GBDK-2020 General Documentation". +- Learn about the Game Boy hardware by reading through the @ref Pandocs technical reference. + + +# 7. Need help? +Check out the links for @ref links_help_and_community "online community and support". + diff --git a/docs/pages/links_and_tools.md b/docs/pages/links_and_tools.md @@ -10,6 +10,15 @@ This is a brief list of useful tools and information. It is not meant to be comp http://sdcc.sourceforge.net +@anchor links_help_and_community +# Getting Help + - GBDK Discord community: + https://github.com/Zal0/gbdk-2020/#discord-servers + + - Game Boy discussion forum: + https://gbdev.gg8.se/forums/ + + @anchor links_gameboy_docs # Game Boy Documentation - @anchor Pandocs @@ -23,7 +32,7 @@ This is a brief list of useful tools and information. It is not meant to be comp https://gbdev.io/list.html -@anchor links_tutorials +@anchor links_gbdk_tutorials # Tutorials - @anchor tutorials_gamingmonsters __Gaming Monsters Tutorials__ @@ -34,12 +43,20 @@ This is a brief list of useful tools and information. It is not meant to be comp @anchor links_graphic # Graphics Tools - - @anchor gbmb + - @anchor gbtd_gbmb + @anchor gbmb @anchor gbtd __Game Boy Tile Designer and Map Builder (GBTD / GBMB)__ Sprite / Tile editor and Map Builder that can export to C that works with GBDK. - https://github.com/untoxa/GBTD_GBMB (updated version with improvements and fixes) - http://www.devrs.com/gb/hmgd/intro.html (original tools) + + - @anchor toxa_gbtd_gbmb + __Use this updated version:__ (has const export fixed and other improvments): + https://github.com/untoxa/GBTD_GBMB + + - This older version is __not recommended__: + http://www.devrs.com/gb/hmgd/intro.html (old, original tools) + + - A GIMP plugin for import/export: https://github.com/bbbbbr/gimp-tilemap-gb (GIMP plugin to read/write GBR/GBM files) - @anchor Tilemap_Studio diff --git a/docs/pages/sample_programs.md b/docs/pages/sample_programs.md @@ -1,7 +1,7 @@ -@page docs_sample_programs GBDK Sample Programs +@page docs_example_programs GBDK Example Programs -GBDK includes several sample programs both in C and in assembly. They are located in the examples directory, and in its subdirectories. They can be built by typing make in the correnponding directory. +GBDK includes several example programs both in C and in assembly. They are located in the examples directory, and in its subdirectories. They can be built by typing `make` in the correnponding directory. # banks (various projects) @@ -109,4 +109,3 @@ The space example is an assembly program that demonstrates the use of sprites, w SELECT : Basic fading effect - diff --git a/docs/pages/toolchain.md b/docs/pages/toolchain.md @@ -30,7 +30,7 @@ To see individual arguments and options for a tool, run that tool from the comma - How do I set the ROM @ref MBC type? - See @ref setting_mbc_and_rom_ram_banks - <!-- --> + <!-- --> - What do these kinds of warnings / errors mean? `WARNING: possibly wrote twice at addr 4000 (93->3E)` @@ -39,6 +39,14 @@ To see individual arguments and options for a tool, run that tool from the comma You may have a overflow in one of your ROM banks. If there is more data allocated to a bank than it can hold it then will spill over into the next bank. The warnings are generated by @ref ihxcheck during conversion of an .ihx file into a ROM file. See the section @ref docs_rombanking_mbcs for more details about how banks work and what their size is. You may want to use a tool such as @ref romusage to calculate the amount of free and used space. + <!-- --> + +- Why is the compiler so slow, or why did it suddenly get much slower? + - This may happen if you have large initialized arrays declared without the `const` keyword. It's important to use the const keyword for read-only data. See @ref const_gbtd_gbmb and @ref const_array_data + <!-- --> + +- What flags should be enabled for debugging? + - You can use the @ref lcc_debug "lcc debug flag" @anchor toolchain_changing_important_addresses @@ -135,6 +143,11 @@ It can be used to invoke all the tools needed for building a rom. If preferred, the individual tools can be called directly. - the `-v` flag can be used to show the exact steps lcc executes for a build - lcc can compile, link and generate a binary in a single pass: `lcc -o somerom.gb somesource.c` +- @anchor lcc_debug + lcc now has a `-debug` flag that will turn on the following recommended flags for debugging + - `--debug` for sdcc (lcc equiv: `-Wf-debug`) + - `-y` enables .cdb output for @ref sdldgb (lcc equiv: `-Wl-y`) + - `-j` enables .noi output for @ref sdldgb (lcc equiv: `-Wl-j`) @anchor sdcc diff --git a/gbdk-lib/examples/gb/template_minimal/Makefile b/gbdk-lib/examples/gb/template_minimal/Makefile @@ -0,0 +1,33 @@ +# +# Simple Makefile that compiles all .c and .s files in the same folder +# + +# If you move this project you can change the directory +# to match your GBDK root directory (ex: GBDK_HOME = "C:/GBDK/" +GBDK_HOME = "../../../" + +LCC = $(GBDK_HOME)bin/lcc + +# You can uncomment the line below to turn on debug output +# LCC = $(LCC) -debug + +# You can set the name of the .gb ROM file here +PROJECTNAME = "Example" + +BINS = $(PROJECTNAME).gb +CSOURCES := $(wildcard *.c) +ASMSOURCES := $(wildcard *.s) + +all: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile and link all source files in a single call to LCC +$(BINS): $(CSOURCES) $(ADMSOURCES) + $(LCC) -o $@ $< + +clean: + rm -f *.o *.lst *.map *.gb *.ihx *.sym *.cdb *.adb *.asm + diff --git a/gbdk-lib/examples/gb/template_minimal/Readme.md b/gbdk-lib/examples/gb/template_minimal/Readme.md @@ -0,0 +1,7 @@ + +An minimal template project with a Makefile that only compiles files in the same directory + +The Makefile will automatically detect and compile new source files as long +as they are placed in the same directory as the Makefile + + diff --git a/gbdk-lib/examples/gb/template_minimal/main.c b/gbdk-lib/examples/gb/template_minimal/main.c @@ -0,0 +1,16 @@ +#include <gb/gb.h> + + +void main(void) +{ + // Loop forever + while(1) { + + + // Game main loop processing goes here + + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +} diff --git a/gbdk-lib/examples/gb/template_subfolders/Makefile b/gbdk-lib/examples/gb/template_subfolders/Makefile @@ -0,0 +1,56 @@ +# +# 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 = "../../../" + +LCC = $(GBDK_HOME)bin/lcc + +# You can uncomment the line below to turn on debug output +# LCC = $(LCC) -debug + +# You can set the name of the .gb ROM file here +PROJECTNAME = "Example" + +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: $(BINS) + +make.bat: Makefile + @echo "REM Automatically generated from Makefile" > make.bat + @make -sn | sed y/\\//\\\\/ | grep -v make >> make.bat + +# Compile .c files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.c + $(LCC) $(CFLAGS) -c -o $@ $< + +# Compile .c files in "res/" to .o object files +$(OBJDIR)/%.o: $(RESDIR)/%.c + $(LCC) $(CFLAGS) -c -o $@ $< + +# Compile .s assembly files in "src/" to .o object files +$(OBJDIR)/%.o: $(SRCDIR)/%.s + $(LCC) $(CFLAGS) -c -o $@ $< + +# If needed, compile .c files i n"src/" to .s assembly files +# (not required if .c is compiled directly to .o) +$(OBJDIR)/%.s: $(SRCDIR)/%.c + $(LCC) $(CFLAGS) -S -o $@ $< + +# Link the compiled object files into a .gb ROM file +$(BINS): $(OBJS) + $(LCC) $(CFLAGS) -o $(BINS) $(OBJS) + +clean: +# rm -f *.gb *.ihx *.cdb *.adb *.noi *.map + rm -f $(OBJDIR)/*.* + diff --git a/gbdk-lib/examples/gb/template_subfolders/Readme.md b/gbdk-lib/examples/gb/template_subfolders/Readme.md @@ -0,0 +1,18 @@ + +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 + + +== Sprite and Background tiles from: == + +https://sondanielson.itch.io/gameboy-simple-rpg-tileset +"Licence is under CCA so you can use these assets both privately and commercially" +"You are free to use them as is or modify them to your liking. All i ask is you credit me if you do use them please :)" + diff --git a/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbm b/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbm Binary files differ. diff --git a/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbr b/gbdk-lib/examples/gb/template_subfolders/res/dungeon_32x32.gbr Binary files differ. diff --git a/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.c b/gbdk-lib/examples/gb/template_subfolders/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/gbdk-lib/examples/gb/template_subfolders/res/dungeon_map.h b/gbdk-lib/examples/gb/template_subfolders/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/gbdk-lib/examples/gb/template_subfolders/res/dungeon_tiles.c b/gbdk-lib/examples/gb/template_subfolders/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,0x9B,0x88,0x9B,0x88,0x8B,0x98, + 0x80,0xFF,0x61,0xFF,0x7F,0xFF,0x3F,0xF0, + 0x38,0xEF,0x34,0xEF,0x33,0xEF,0x73,0xEF, + 0x80,0xF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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,0xFF,0xFF, + 0x7F,0x80,0x00,0x00,0x00,0x00,0xFF,0xFF, + 0xD9,0x91,0xD9,0x51,0x39,0x31,0xF1,0xF9, + 0xE9,0x19,0x05,0x05,0x03,0x03,0x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b/template_subfolders/res/dungeon_tiles.h b/gbdk-lib/examples/gb/template_subfolders/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/gbdk-lib/examples/gb/template_subfolders/src/main.c b/gbdk-lib/examples/gb/template_subfolders/src/main.c @@ -0,0 +1,30 @@ +#include <gb/gb.h> +#include "../res/dungeon_map.h" +#include "../res/dungeon_tiles.h" + + +void init_gfx() { + // Load Background tiles and then map + set_bkg_data(0, 79u, dungeon_tiles); + set_bkg_tiles(0, 0, 32u, 32u, dungeon_mapPLN0); + + // Turn the background map on to make it visible + SHOW_BKG; +} + + +void main(void) +{ + init_gfx(); + + // Loop forever + while(1) { + + + // Game main loop processing goes here + + + // Done processing, yield CPU and wait for start of next frame + wait_vbl_done(); + } +}
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.