Use the GameBoy Tile Designer and Map Builder
Contents
GameBoy Tile Designer
Overview
- the help menu is good.
- the numbers vertically ordered on the left-hand-side correspond to tile numbers
- the 0,1,2,3 boxes at the bottom correspond to the palette choice for the tiles.
Tile Designer defaults to the standard palette that we have been using i.e. the standard palette that is loaded in lines 47 and 48 of hello-world.asm:
ld a, %11100100 ; Window palette colors, from darkest to lightest ld [rBGP], a ; CLEAR THE SCREEN
- you can change the palette by pressing the down and up arrows to the left of the palette numbers
- the L and R to the left of the palette numbers correspond to what color is choosen on the tile when you click the left or right mouse button.
- to change what color you wish to place with the L or R mouse button, L or R click on the palette numbers
- the large grid is your tile design.
- the left icons/menu is fairly self-explanatory, and there is help available inside the application on these.
import/export
export from GBTD
make sure you save your tiles in GMTD's native format first. This is needed for when you want to edit the tiles later or use them in the map builder. After you have done this, it is easy to also export your tiles for use in your assembler code:
choose Export to... in the File menu. Here's a rundown of your choices in the dialog box that comes out:
filename is up to you. I'll assume you use Export.z80 for this example
choose RGBDS Assembly file (*.z80) as your file type
you can change the names of the section and the label, but for this example I'll assume you leave them as TileLabel and Tiles
Bank is not needed for our purposes
From, To is where you choose what tile numbers you want to export.
It is very important to fill this out with the correct tile range. The default range of 0, 0 is going to get you just the first tile.
For Format choose either Gameboy 4 color if you used shades of gray or Gameboy 2 color if you used just monochrome, like our ibmpc1.inc text font.
leave Counter set to none.
if you have any reason to refer to each tile individually (for example you want to load tiles 0-8 at one point and tiles 5-9 at a different point), leave Export tiles as one unit unchecked. Otherwise, check that box. In most cases you will want to check the box.
Compression and Decompression is a complication we won't need, so leave the GB-Compress data box unchecked.
choose ok and two files will be created: export.inc and export.z80.
Will will not need export.inc but export.z80 has got everything we need, so take a look at it so you have some intuition of what is going on.
using the exported tiles in your RGBDS assembler code
move the export.z80 file to the directory where your other include files and your assembly code is
add to your assembly code
INCLUDE "export.z80"
where your include files are referenced in your code.- load your tiles in your code. Here are some examples, but you may need to alter these slightly depending on whether or not you are also loading other tiles from another set. This code should be executed during initialization.
Exported as Gameboy 2 color:
ld hl, TileLabel ; You chose this name in the export dialog box of GBTD ld de, _VRAM ; _VRAM=$8000=tile pattern table 0. If you wish to load into tile pattern table 1, choose $8800 ld bc, 8*<number of tiles you wish to load> call mem_CopyMono ; load tile data
Exported as Gameboy 4 color:
ld hl, TileLabel ; You chose this name in the export dialog box of GBTD ld de, _VRAM ; _VRAM=$8000=tile pattern table 0. If you wish to load into tile pattern table 1, choose $8800 ld bc, 16*<number of tiles you wish to load> call mem_Copy ; load tile data
Gameboy Map Builder
this is only to get you started. Help within the app is excellent and should serve you well.
overview
go to Map Properties... in the File menu to load a tileset you created with GMTD
- you also set the size of your map here, be it 10x10, 20x18 or 32x32 tiles
I suggest and, for this example, I assume a 32x32 tile map. If your map is not 32 columns, you will need to change the assembler code example below when using the map in your code.
- you also set the size of your map here, be it 10x10, 20x18 or 32x32 tiles
- select the tile you want to place on the map by clicking it with either the L or R mouse button on the tile list.
- use the L mouse button to select tiles on the map. Hit the spacebar to change all the selected tiles on the map to the tile you selected in the tile list.
- use the R mouse button to change one tile on the map to the selected tile on the tile list.
import/export
export from GBMB
make sure you save your tiles in GMMB's native format first. This is needed for when you want to edit the map later. After you have done this, it is easy to also export your map for use in your assembler code:
choose Export to... in the File menu. Here's a rundown of your choices in the dialog box that comes out:
under the standard tab:
filename is up to you. I'll assume you use ExportMap.z80 for this example
choose RGBDS Assembly file (*.z80) as your file type
you can change the names of the section and the label, but for this example I'll assume you leave them as TileMapLabel and TileMap
Bank is not needed for our purposes
Split data allows you to add labels for easy referral between sets of blocks. For example, if you wanted a label between every line of 32 blogs, you would check the Split Data box and choose a block size of 32.
In this basic case we will leave Split data unchecked.
Leave change bank for each block unchecked. It will not be needed for all but the most memory-intensive apps.
Location format tab: there's a million ways we could do this but the simplest and most consistent with how we have handled maps in the past:
under Location format choose Property of [Tile number: Low 8]
choose map layout of Rows
Plane count: 1 plane (8 bits)
Plane Order: Tiles are continues (sic)
Tile offset: 0
now finally hit OK and let the magic happen...
GBMB will create ExportMap.inc and ExportMap.z80. We will not need ExportMap.inc but ExportMap.z80 has got everything we need, so take a look at it so you have some intuition of what is going on.
using the exported map in your RGBDS assembler code
- make sure you already have your assembler code to read the exported tiles as explained above in the GBTD section.
move the ExportMap.z80 file to the directory where your other include files and your assembly code is
add to your assembly code
INCLUDE "ExportMap.z80"
where your include files are referenced in your code.load your tiles in your code. Here are some examples, but you may need to alter these slightly depending on whether or not you are also loading other tiles from another set. This code should be executed after you load your tiles:
ld hl,TileMapLabel ; THIS IS THE LABEL NAME YOU CHOSE WHEN YOU EXPORTED FROM GBMB ld de, _SCRN0+0+(SCRN_VY_B*0) ; LOCATION IN BACKGROUN TILE MAP WHERE YOU WANT TO STARTING LOADING YOUR MAP DATA. WE ARE ASSUMING YOU WANT TO LOAD THE MAP DATA FROM THE UPPER LEFT (ROW 0 COLUMN 0) ld bc, 32*32 ; SIZE OF MAP DATA. IF YOU CHANGE THE NUMBER OF COLUMNS IN YOUR MAP DATA, THIS WILL NOT WORK. call mem_CopyVRAM ; DO THE MAGIC