diff --git a/.vscode/settings.json b/.vscode/settings.json index a294c02..d5d9423 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,13 +5,25 @@ "DEVKITARM", "DEVKITPPC", "devkitpro", + "distro", + "EEPROM", + "EWRAM", "Gameboy", + "IWRAM", "memmap", "mgba", "mtab", + "multiboot", "pacman", + "PALBANK", + "Photoshop", "Requantize", + "screenblock", + "screenblocks", "tilemap", + "tilemaps", + "tileset", + "Tonc", "Tonclib", "Usenti" ] diff --git a/projects/Gameboy/setup.html b/projects/Gameboy/setup.html index b2f770a..435bb13 100644 --- a/projects/Gameboy/setup.html +++ b/projects/Gameboy/setup.html @@ -8,7 +8,6 @@

Game Boy Development

average person.

-

@@ -296,7 +295,7 @@

Game Boy Development

- Images on the GBA are composed of tiles and palettes. The palette is simply a list of the colors used in an image. The pixel values in the image are indices of the palette. The image is broken into 8x8 pixel segments called tiles. The tiles form a bitmap of the image. + Images on the GBA are composed of tiles and palettes. The palette is simply an array of the colors used in an image. The pixel values in the image are indices of the palette. The image is broken into 8x8 pixel segments called tiles. The tiles form a bitmap of the image.

@@ -441,7 +440,7 @@

2. Tiles

- +

So remember how I was just saying VRAM is divided into 16KB chunks called charblocks and the first 4 charblocks are for background tiles? Yeah that's not exactly the whole story. VRAM is actually divided into both charblocks and screenblocks. Each screenblock is 2048 bytes (0x800) long, giving 32 screenblocks in the first 4 charblocks. Charblocks and screenblocks use the same addresses in memory. This means they overlap. @@ -526,4 +525,102 @@

2. Tiles

#define se_mem ((SCREENBLOCK*)MEM_VRAM) +
+ + +
+

+ To create our sprite, we first need to draw it. I prefer to use Photoshop for this but there are many tools available and you cant really go wrong. Just remember your sprite must be a set size. I will list the possible sizes below: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
shape\size 00 01 10 11 +
008x8 16x16 32x32 64x64 +
0116x8 32x8 32x16 64x32 +
108x16 8x32 16x32 32x64 +
+ +

+ Once we have created our sprite image, we need to use a tool called Usenti to convert it to C code. I will provide a sprite that I made of my friend Will for you to use as an example: +

+ +
+ +
+ +

+ Simply download this file, and open it in Usenti. You should see a window that looks like this: +

+ +
+ +
+ +

+ You first want to make sure you have the correct number of colors by selecting Palette > Requantize. My sprite only uses 8 colors so I will type 8. You can use up to 16 colors in 4bPP or up to 256 in 8bPP. Next, you'll want to reorder your palette by selecting Palette > Sort. I like to sort my palette by ascending brightness beginning from color 0 and ending at color 15. Keep in mind that the first color in your palette is considered transparent. I usually use black for this. +

+ +

+ If you want to save your sprite for further editing in the future: I suggest you save it as a bmp file. To do this: you must select File > Save As. I will save my file as Will.bmp. When prompted: you want to select a bit depth of 4 (assuming you are using 4BPP Mode). +

+ +

+ Now for the scary part: You want to export your image as GBA Source Code by selecting Image > Export and the choose a destination. You will see the following window appear: +

+ +
+ +
+ +

+ Don't panic this is actually really simple. We want to select all the options that describe how we want our sprite to be formatted. First, select Gfx and ensure that tile is selected and you're using 4bpp mode. There is also an option for compression but I could never get that to work properly. +

+

+ Next, under the Meta/Obj section: select the aspect ratio of your sprite. My sprite is square image made of 4x4 tiles (32x32 pixels). For the Pal section: simply select the number of colors you need to use. My sprite uses 8 colors. Next, you want to make sure h file is selected under the File section. +

+

+ You may choose to represent your data as either: u8, u16, or u32. Functionally, this makes no difference since your data will still be the same regardless of how you store it. This is more a question of readability. I personally like u16 since colors are represented as 16 bit values. Once you are done, click OK and Usenti will export two files: + Will.c and Will.h. These need to be copied to the source and include folders of your workspace respectively. Now that we have the data, we need to write some code to get the sprite displayed on the GBA! +

+ +
+ + +
+
\ No newline at end of file