Initial Commit

This commit is contained in:
2020-07-11 08:41:14 -05:00
parent 55c0f7f3cd
commit 1478a597cf
176 changed files with 11933 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# GBDK Playground
It has 16 kB of RAM, man.
## Samples
| [Blank](blank) | [Hello World](hello_world) | [Small Sprite](small_sprite) |
|:-------------------------:|:-------------------------------:|:--------------------------------:|
| ![](blank/screenshot.png) | ![](hello_world/screenshot.png) | ![](small_sprite/screenshot.png) |
| Minimum required code | Print `Hello World!` | Render small 8x8 sprite |
| [Big Sprite](big_sprite) | [Big Sprite Animation](big_sprite_animation) | [Input State](input_state) |
|:------------------------------:|:--------------------------------------------:|:-------------------------------:|
| ![](big_sprite/screenshot.png) | ![](big_sprite_animation/screenshot.gif) | ![](input_state/screenshot.png) |
| Render big 16x16 sprite | Animate big 16x16 sprite | Read joypad state |
| [Input Wait](input_wait) | [Move Sprite](move_sprite) | [Background](background) |
|:------------------------------:|:-------------------------------:|:-------------------------------:|
| ![](input_wait/screenshot.png) | ![](move_sprite/screenshot.gif) | ![](background/screenshot.png) |
| Wait for button input | Move a sprite using joypad | Render a full-screen background |
| [Window](window) | [Beep](beep) | [Simple SHMUP](simple_shmup) |
|:--------------------------:|:------------------------:|:--------------------------------:|
| ![](window/screenshot.png) | ![](beep/screenshot.png) | ![](simple_shmup/screenshot.png) |
| Renders a window | Make a sound | Very simple SHMUP |
| [Huge Sprite](huge_sprite) | [Drawing](drawing) | [Detect GB Type](detect_gb) |
|:-------------------------------:|:-------------------------------:|:----------------------------------:|
| ![](huge_sprite/screenshot.png) | ![](drawing/screenshot.png) | ![](detect_gb/screenshot.png) |
| Renders a huge 40x64 sprite | Built-in drawing functions | Detect which GB is being used |
| [Save RAM](save_ram) | [Font](font) | [Link](link) |
|:-------------------------------:|:-------------------------------:|:----------------------------------:|
| ![](save_ram/screenshot.png) | ![](font/screenshot.png) | ![](link/screenshot.png) |
| Save/load variables | Load a new font | Send/Receive data using link cable |
| [Color](color) | More coming soon... |
|:-------------------------------:|:----------------------------------:|
| ![](color/screenshot.png) | ![](docs/res/more_coming_soon.png) |
| Use palettes for Game Boy Color | Contributions are welcome! |

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = background.gb
OBJS = background.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf *.o *.lst

View File

@@ -0,0 +1,94 @@
# Background
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
Renders a full-screen background image.
## Source
```c
#include <gb/gb.h>
#include "bg_data.c"
#include "bg_data.map"
void main() {
```
First load the tile patterns in the Background Tile Pattern table. This
means that we load all the 8x8 images that make up our picture (131 of them
to be exact).
```c
set_bkg_data(0, 131, tiledata);
VBK_REG = 1;
VBK_REG = 0;
```
Then we set the tile pattern in the background tile table. The variable
`tilemap` contains an array of tile numbers that reference to the the tiles
we loaded previously using `set_bkg_data`.
Our image is `20` tiles wide and `18` tiles high, thus having a total of 360
tiles. How is that possible when we only loaded `131` tiles?
Well, that is because some in the image are identical. So instead the tile
is only saved once in the `tiledata` variable and reused multiple times in
the `tilemap` variable.
```c
set_bkg_tiles(0, 0, 20, 18, tilemap);
```
In order for the background to actually show up we call `SHOW_BKG`.
```c
SHOW_BKG;
DISPLAY_ON;
}
```

View File

@@ -0,0 +1,37 @@
// # Background
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
//
// Renders a full-screen background image.
//
// ## Source
#include <gb/gb.h>
#include "bg_data.c"
#include "bg_data.map"
void main() {
// First load the tile patterns in the Background Tile Pattern table. This
// means that we load all the 8x8 images that make up our picture (131 of them
// to be exact).
set_bkg_data(0, 131, tiledata);
VBK_REG = 1;
VBK_REG = 0;
// Then we set the tile pattern in the background tile table. The variable
// `tilemap` contains an array of tile numbers that reference to the the tiles
// we loaded previously using `set_bkg_data`.
//
// Our image is `20` tiles wide and `18` tiles high, thus having a total of 360
// tiles. How is that possible when we only loaded `131` tiles?
//
// Well, that is because some in the image are identical. So instead the tile
// is only saved once in the `tiledata` variable and reused multiple times in
// the `tilemap` variable.
set_bkg_tiles(0, 0, 20, 18, tilemap);
// In order for the background to actually show up we call `SHOW_BKG`.
SHOW_BKG;
DISPLAY_ON;
}

View File

@@ -0,0 +1,142 @@
/*
Advanced PCX to GameBoy converter v2.15
Tiles data
Original PCX File : "BG_DATA.PCX"
Number of Tiles : 131
TileMap Size : 20x18
*/
unsigned const char tiledata[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xDF,0xDF,0xC1,0xC1,0xC0,0xC0,0xC0,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x3F,0x3F,0x0F,0x0F,0x01,0x01,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x1F,0x1F,
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,0xFE,0xFE,0xF8,0xF8,
0xFE,0xFE,0xFC,0xFC,0xF8,0xF8,0xF0,0xF0,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x07,0x07,0x07,0x07,0x0F,0x0F,
0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x0F,0x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,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x0C,0x0C,0x18,0x18,
0x01,0x01,0x03,0x03,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x1F,0x1F,
0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x30,0x30,0x20,0x20,0x20,0x20,
0x0C,0x0C,0x18,0x18,0x10,0x10,0x20,0x20,0x60,0x60,0x40,0x40,0xC0,0xC0,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x02,0x02,0x04,0x04,
0x30,0x30,0x20,0x20,0x60,0x60,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x02,0x02,0x06,0x06,
0x40,0x40,0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x02,0x02,0x06,0x06,0x08,0x08,0x18,0x18,0x30,0x30,0x60,0x60,0x40,0x40,
0x08,0x08,0x18,0x18,0x30,0x30,0x60,0x60,0x40,0x40,0xC0,0xC0,0x80,0x80,0x00,0x00,
0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x30,0x30,0x20,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x03,0x03,0x02,0x02,0x06,0x06,0x04,0x04,0x08,0x08,0x18,0x18,
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x02,0x06,0x06,0x04,0x04,0x0C,0x0C,0x18,0x18,0x10,0x10,0x20,0x20,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x20,0x20,0x18,0x18,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0xC0,0xC0,0x80,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,
0x60,0x60,0x40,0x40,0x40,0x40,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x0C,0x0C,0x02,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x60,0x60,0x18,0x18,0x04,0x04,0x03,0x03,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x30,0x30,0x20,0x20,0x40,0x40,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x10,0x10,0x10,0x10,0x20,0x20,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x60,0x60,0x30,0x30,0x18,0x18,0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x60,0x60,
0x1F,0x1F,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x04,0x04,
0x40,0x40,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1C,0x1C,0x06,0x06,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0xC0,0x70,0x70,0x1C,0x1C,0x07,0x07,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x60,0x60,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,
0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x40,0x40,
0x0C,0x0C,0x08,0x08,0x10,0x10,0x10,0x10,0x30,0x30,0x60,0x60,0x40,0x40,0x40,0x40,
0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,
0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x10,
0x00,0x00,0x00,0x00,0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x30,0x30,0x08,0x08,
0x1F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x02,0x02,
0x10,0x10,0x20,0x20,0x60,0x60,0x40,0x40,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0x60,0x60,0x38,0x38,0x0C,0x0C,0x07,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0x30,0x30,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,
0x02,0x02,0x04,0x04,0x08,0x08,0x18,0x18,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x40,
0x18,0x18,0x06,0x06,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x20,0x20,0x1C,0x1C,0x06,0x06,0x03,0x03,
0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x78,0x78,0x07,0x07,
0xC0,0xC0,0x60,0x60,0x30,0x30,0x08,0x08,0x0E,0x0E,0x03,0x03,0x01,0x01,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0xC0,0x40,0x40,0x60,0x60,0x30,0x30,0x0C,0x0C,0x02,0x02,0x03,0x03,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,
0x18,0x18,0x0E,0x0E,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0x38,0x38,0x0E,0x0E,0x03,0x03,0x00,0x00,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,
0x02,0x02,0x04,0x04,0x08,0x08,0x18,0x18,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,
0x38,0x38,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x38,0x38,0x06,0x06,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x01,0x01,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x0F,0x0F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,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FF,0xFF,0xFF,
0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x80,0xF8,0xF8,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x03,0x03,0x01,0x01,0xE1,0xE1,0xF8,0xF8};

Binary file not shown.

View File

@@ -0,0 +1,2 @@
docco -t ../docs/res/readme_c.jst -o ./ background.c
mv background.html README.md

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = beep.gb
OBJS = beep.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Beep
![](screenshot.png)
Demonstrates how to play a simple SFX sound.

View File

@@ -0,0 +1,31 @@
#include <gb/gb.h>
#include <gb/drawing.h>
void main() {
NR50_REG = 0xFF;
NR51_REG = 0xFF;
NR52_REG = 0x80;
gotogxy(1, 1);
gprintf("====== Beep ======");
gotogxy(2, 3);
gprintf("Press any button");
while(1) {
UBYTE joypad_state = joypad();
if(joypad_state) {
NR10_REG = 0x38U;
NR11_REG = 0x70U;
NR12_REG = 0xE0U;
NR13_REG = 0x0AU;
NR14_REG = 0xC6U;
NR51_REG |= 0x11;
delay(200);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = big_sprite.gb
OBJS = big_sprite.o sprite.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,178 @@
# Big Sprite
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
Renders a big sprite of 16x16. Since the Game Boy hardware does not directly
support sprites that large
## Source
Start by including `gb/gb.h` this file defines most important functions you
are going to need when develop Game Boy games.
```c
#include <gb/gb.h>
```
The `sprite.c` file defines the sprite data in the form of an unsigned char
array. Most of the time you want to generate this file using tools such as
GBTD.
```c
#include "sprite.c"
void main() {
```
Set the sprite size to 8x16 pixels, two tiles one above the other. Internally
sets bit 2 of the LCDC register to 1.
```c
SPRITES_8x16;
```
Loads the tile patterns stored in `sprite` into the Sprite Tile Pattern
table.
* first parameter `0` determines at which position we should start loading.
* second parameter `4` determines how many tiles we want to loading
* third parameter `sprite` sets the variable to load from
This means that we are loading 4 tiles starting at 0 from the variable
sprite.
```c
set_sprite_data(0, 4, sprite);
```
Tell sprite `0` to display sprite `0`. Since we are loading 8x16 tiles this
will make sprite 0 show tile `0` and tile `1`.
```c
set_sprite_tile(0, 0);
```
Finally move a sprite to a position that we can see.
```c
move_sprite(0, 75, 75);
```
We want to display a 16x16 sprite. Unfortunately the Game Boy hardware does
not directly support a sprite that large. So in order to have a sprite of
that size we are simply displaying two 8x16 tiles next to each other!
Since we've already loaded our entire sprite in line 16 we can now simply
tell sprite `1` to display our second sprite. Again, since we are displaying
8x16 tiles this statement will display tile `2` and tile `3`.
```c
set_sprite_tile(1, 2);
```
In order to form the illusion of a bigger sprite we display the second tile
directly next to the other simply by offsetting the position 8 pixels to the
right.
```c
move_sprite(1, 75 + 8, 75);
```
As always, in order for the sprites to display we need to call
`SHOW_SPRITES` once.
```c
SHOW_SPRITES;
}
```

View File

@@ -0,0 +1,51 @@
// # Big Sprite
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
//
// Renders a big sprite of 16x16. Since the Game Boy hardware does not directly
// support sprites that large
//
// ## Source
// Start by including `gb/gb.h` this file defines most important functions you
// are going to need when develop Game Boy games.
#include <gb/gb.h>
// The `sprite.c` file defines the sprite data in the form of an unsigned char
// array. Most of the time you want to generate this file using tools such as
// GBTD.
#include "sprite.c"
void main() {
// Set the sprite size to 8x16 pixels, two tiles one above the other. Internally
// sets bit 2 of the LCDC register to 1.
SPRITES_8x16;
// Loads the tile patterns stored in `sprite` into the Sprite Tile Pattern
// table.
//
// * first parameter `0` determines at which position we should start loading.
// * second parameter `4` determines how many tiles we want to loading
// * third parameter `sprite` sets the variable to load from
//
// This means that we are loading 4 tiles starting at 0 from the variable
// sprite.
set_sprite_data(0, 4, sprite);
// Tell sprite `0` to display sprite `0`. Since we are loading 8x16 tiles this
// will make sprite 0 show tile `0` and tile `1`.
set_sprite_tile(0, 0);
// Finally move a sprite to a position that we can see.
move_sprite(0, 75, 75);
// We want to display a 16x16 sprite. Unfortunately the Game Boy hardware does
// not directly support a sprite that large. So in order to have a sprite of
// that size we are simply displaying two 8x16 tiles next to each other!
//
// Since we've already loaded our entire sprite in line 16 we can now simply
// tell sprite `1` to display our second sprite. Again, since we are displaying
// 8x16 tiles this statement will display tile `2` and tile `3`.
set_sprite_tile(1, 2);
// In order to form the illusion of a bigger sprite we display the second tile
// directly next to the other simply by offsetting the position 8 pixels to the
// right.
move_sprite(1, 75 + 8, 75);
// As always, in order for the sprites to display we need to call
// `SHOW_SPRITES` once.
SHOW_SPRITES;
}

View File

@@ -0,0 +1,2 @@
docco -t ../docs/res/readme_c.jst -o ./ big_sprite.c
mv big_sprite.html README.md

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,38 @@
/*
SPRITE.C
Tile Source File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 16 x 16
Tiles : 0 to 0
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 sprite[] =
{
0xFF,0xFF,0x80,0x80,0x80,0x80,0x81,0x81,
0x83,0x83,0x87,0x87,0x81,0x81,0x81,0x81,
0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
0x83,0x83,0x87,0x87,0x80,0x80,0xFF,0xFF,
0xFF,0xFF,0x01,0x01,0xC1,0xC1,0xC1,0xC1,
0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,
0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,
0xE1,0xE1,0xF1,0xF1,0x01,0x01,0xFF,0xFF
};
/* End of SPRITE.C */

View File

@@ -0,0 +1,31 @@
/*
SPRITE.H
Include File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 16 x 16
Tiles : 0 to 0
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 spriteBank 0
/* Start of tile array. */
extern unsigned char sprite[];
/* End of SPRITE.H */

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = big_sprite_animation.gb
OBJS = big_sprite_animation.o cards.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Big Sprite Animation
![](screenshot.gif)
Renders a big 16x16 animated sprite of 2 frames using a delay of 500.

View File

@@ -0,0 +1,21 @@
#include <gb/gb.h>
#include "cards.c"
void main() {
SPRITES_8x16;
set_sprite_data(0, 8, cards);
set_sprite_tile(0, 0);
move_sprite(0, 75, 75);
set_sprite_tile(1, 2);
move_sprite(1, 75 + 8, 75);
SHOW_SPRITES;
while(1) {
set_sprite_tile(0, 4);
set_sprite_tile(1, 6);
delay(500);
set_sprite_tile(0, 0);
set_sprite_tile(1, 2);
delay(500);
}
}

View File

@@ -0,0 +1,46 @@
/*
CARDS.C
Tile Source File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 16 x 16
Tiles : 0 to 1
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 cards[] =
{
0xFF,0xFF,0x80,0x80,0x80,0x80,0x81,0x81,
0x83,0x83,0x87,0x87,0x81,0x81,0x81,0x81,
0x81,0x81,0x81,0x81,0x81,0x81,0x81,0x81,
0x83,0x83,0x87,0x87,0x80,0x80,0xFF,0xFF,
0xFF,0xFF,0x01,0x01,0xC1,0xC1,0xC1,0xC1,
0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,
0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,0xC1,
0xE1,0xE1,0xF1,0xF1,0x01,0x01,0xFF,0xFF,
0xFF,0xFF,0x80,0x80,0x83,0x83,0x87,0x87,
0x8E,0x8E,0x8C,0x8C,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x81,0x81,0x83,0x83,
0x87,0x87,0x8F,0x8F,0x80,0x80,0xFF,0xFF,
0xFF,0xFF,0x01,0x01,0xC1,0xC1,0xE1,0xE1,
0x71,0x71,0x31,0x31,0x31,0x31,0x31,0x31,
0x71,0x71,0xE1,0xE1,0xC1,0xC1,0x81,0x81,
0xF1,0xF1,0xF1,0xF1,0x01,0x01,0xFF,0xFF
};
/* End of CARDS.C */

View File

@@ -0,0 +1,31 @@
/*
CARDS.H
Include File.
Info:
Form : All tiles as one unit.
Format : Gameboy 4 color.
Compression : None.
Counter : None.
Tile size : 16 x 16
Tiles : 0 to 1
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 cardsBank 0
/* Start of tile array. */
extern unsigned char cards[];
/* End of CARDS.H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = blank.gb
OBJS = blank.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,35 @@
# Blank
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
This example contains the minimal amount of code needed to create a working
Game Boy game. Though not a very exciting one.
## Source
All a GBDK game needs to compile and run (any C-program, in fact) is a main
function. This is the entry point into your program.
```c
void main() {
}
```

View File

@@ -0,0 +1,13 @@
// # Blank
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
//
// This example contains the minimal amount of code needed to create a working
// Game Boy game. Though not a very exciting one.
//
// ## Source
// All a GBDK game needs to compile and run (any C-program, in fact) is a main
// function. This is the entry point into your program.
void main() {
}

View File

@@ -0,0 +1,2 @@
docco -t ../docs/res/readme_c.jst -o ./ blank.c
mv blank.html README.md

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-yp0x143=0x80
BIN = color.gbc
OBJS = color.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Color
![](screenshot.png)
Demonstrates how to use palettes and create a Game Boy Color ROM.

View File

@@ -0,0 +1,142 @@
/*
Advanced PCX to GameBoy converter v2.15
Tiles data
Original PCX File : "BG_DATA.PCX"
Number of Tiles : 131
TileMap Size : 20x18
*/
unsigned const char tiledata[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xDF,0xDF,0xC1,0xC1,0xC0,0xC0,0xC0,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0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,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xE0,0xE0,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFC,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0xE0,0xE0,0xC0,0xC0,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,0x01,0x01,
0x0F,0x0F,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFE,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x40,0xC0,0xC0,0x80,0x80,
0xFF,0xFF,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xF0,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x0C,0x0C,0x18,0x18,
0x01,0x01,0x03,0x03,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x1F,0x1F,
0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x30,0x30,0x20,0x20,0x20,0x20,
0x0C,0x0C,0x18,0x18,0x10,0x10,0x20,0x20,0x60,0x60,0x40,0x40,0xC0,0xC0,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x02,0x02,0x04,0x04,
0x30,0x30,0x20,0x20,0x60,0x60,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x7F,0x7F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x02,0x02,0x06,0x06,
0x40,0x40,0xC0,0xC0,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x02,0x02,0x06,0x06,0x08,0x08,0x18,0x18,0x30,0x30,0x60,0x60,0x40,0x40,
0x08,0x08,0x18,0x18,0x30,0x30,0x60,0x60,0x40,0x40,0xC0,0xC0,0x80,0x80,0x00,0x00,
0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0x04,0x04,0x08,0x08,0x08,0x08,0x10,0x10,0x30,0x30,0x20,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x03,0x03,0x02,0x02,0x06,0x06,0x04,0x04,0x08,0x08,0x18,0x18,
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x02,0x02,0x06,0x06,0x04,0x04,0x0C,0x0C,0x18,0x18,0x10,0x10,0x20,0x20,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x20,0x20,0x18,0x18,
0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,
0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0xC0,0xC0,0x80,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,
0x60,0x60,0x40,0x40,0x40,0x40,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x0C,0x0C,0x02,0x02,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x60,0x60,0x18,0x18,0x04,0x04,0x03,0x03,
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x30,0x30,0x20,0x20,0x40,0x40,
0x02,0x02,0x06,0x06,0x0C,0x0C,0x08,0x08,0x18,0x18,0x10,0x10,0x10,0x10,0x20,0x20,
0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x60,0x60,0x30,0x30,0x18,0x18,0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x60,0x60,
0x1F,0x1F,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x02,0x04,0x04,
0x40,0x40,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1C,0x1C,0x06,0x06,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xC0,0xC0,0x70,0x70,0x1C,0x1C,0x07,0x07,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x60,0x60,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,
0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x40,0x40,
0x0C,0x0C,0x08,0x08,0x10,0x10,0x10,0x10,0x30,0x30,0x60,0x60,0x40,0x40,0x40,0x40,
0x00,0x00,0x01,0x01,0x01,0x01,0x03,0x03,0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,
0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x01,0x01,0x01,0x01,0x01,0x02,0x02,0x04,0x04,0x04,0x04,0x08,0x08,0x10,0x10,
0x00,0x00,0x00,0x00,0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x40,0x40,0x30,0x30,0x08,0x08,
0x1F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
0x08,0x08,0x10,0x10,0x20,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x02,0x02,
0x10,0x10,0x20,0x20,0x60,0x60,0x40,0x40,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,
0x0E,0x0E,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0x60,0x60,0x38,0x38,0x0C,0x0C,0x07,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0x30,0x30,
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,
0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,
0x02,0x02,0x04,0x04,0x08,0x08,0x18,0x18,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x40,
0x18,0x18,0x06,0x06,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x20,0x20,0x1C,0x1C,0x06,0x06,0x03,0x03,
0x03,0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x01,0x02,0x02,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0x78,0x78,0x07,0x07,
0xC0,0xC0,0x60,0x60,0x30,0x30,0x08,0x08,0x0E,0x0E,0x03,0x03,0x01,0x01,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,
0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0xC0,0x40,0x40,0x60,0x60,0x30,0x30,0x0C,0x0C,0x02,0x02,0x03,0x03,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,
0x18,0x18,0x0E,0x0E,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xE0,0xE0,0x38,0x38,0x0E,0x0E,0x03,0x03,0x00,0x00,
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F,
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0x80,0x80,
0x02,0x02,0x04,0x04,0x08,0x08,0x18,0x18,0x10,0x10,0x20,0x20,0x20,0x20,0x40,0x40,
0x38,0x38,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x38,0x38,0x06,0x06,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0xC0,0xC0,0x40,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
0x07,0x07,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x01,0x01,0x01,0x00,0x00,
0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0x01,0x03,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x0F,0x0F,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x1F,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0xF0,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xF8,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xFE,0xFE,
0xFF,0xFF,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x1F,0x1F,
0xFF,0xFF,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFC,0xFC,0xFD,0xFD,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x03,0x1F,0x1F,0x7F,0x7F,0xFF,0xFF,
0x00,0x00,0x03,0x03,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x80,0xF8,0xF8,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x0F,0x0F,0x0F,0x0F,0x07,0x07,0x07,0x07,0x03,0x03,0x01,0x01,0xE1,0xE1,0xF8,0xF8};

View File

@@ -0,0 +1,39 @@
#include <gb/gb.h>
#include <gb/cgb.h> // Include cgb functions
// Background taken from 'background' example
#include "bg_data.c"
#include "bg_data.map"
// Sprite taken from 'small_sprite' example
const unsigned char sprite[] =
{
0x7E,0x7E,0x99,0x99,0x81,0x81,0xA5,0xA5,
0x81,0x81,0xDB,0xDB,0xC3,0xC3,0x3C,0x3C
};
// These palettes replace the default palette with the appropriate colors. See cgb.h for more defined colors.
UWORD bkgPalette[] = {
RGB_PURPLE, RGB_BLACK, RGB_ORANGE, RGB_BROWN
};
UWORD sprPalette[] = {
RGB_GREEN, RGB_BLUE, RGB_RED, RGB_YELLOW
};
void main(void){
set_bkg_palette(0, 1, bkgPalette); // UBYTE first_palette, UBYTE nb_palettes, UWORD *rgb_data
set_bkg_data(0, 131, tiledata);
set_bkg_tiles(0, 0, 20, 18, tilemap);
SHOW_BKG;
set_sprite_palette(0, 1, sprPalette); // UBYTE first_palette, UBYTE nb_palettes, UWORD *rgb_data
set_sprite_data(0, 1, sprite);
set_sprite_tile(0, 0);
move_sprite(0, 50, 50);
SHOW_SPRITES;
DISPLAY_ON;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,16 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = detect_gb.gb
OBJS = detect_gb.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,5 @@
# Detect GB
![](screenshot.png)
Detect which GB is being used/emulated.

View File

@@ -0,0 +1,21 @@
#include <gb/gb.h>
#include <stdio.h>
extern UBYTE _cpu;
void main() {
switch (_cpu) {
case 0x01:
printf("DMG or SGB");
break;
case 0xFF:
printf("POCKET or SGB2");
break;
case 0x11:
printf("COLOR");
break;
default:
printf("OTHER");
break;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,15 @@
<% for (var i = 0, l = sections.length; i<l; i++) { %>
<% var section = sections[i]; %>
<%= section.docsText %>
<% if (!(/^\s*$/).test(section.codeText)) { %>
```c
<%= section.codeText %>
```
<% } %>
<% } %>

View File

@@ -0,0 +1,16 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = drawing.gb
OBJS = drawing.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,5 @@
# Drawing
![](screenshot.png)
Demonstrates built-in GBDK drawing functions. Operate the D-Pad to use the plot function to draw on the screen. Press the A Button to change plot point colors (Black, White, Dark Gray, Light Gray). Press the B button to clear the screen.

View File

@@ -0,0 +1,41 @@
#include <gb/gb.h>
#include <gb/drawing.h>
UINT8 x = 1, y = 1, i = 3, j, f;
void main() {
color(BLACK, WHITE, SOLID); // forecolor, backcolor, mode [Colors: WHITE (0), LTGREY (1), DKGREY(2), BLACK (3)]
circle(100, 60, 30, M_FILL); // x, y, radius, style (M_FILL or M_NOFILL)
line(40, 40, 50, 50); // x1, y1, x2, y2
box(120, 125, 125, 135, M_NOFILL); // x1, y1, x2, y2, style (M_FILL or M_NOFILL)
plot_point(3, 4); // Plot a single pixel on the screen
gotogxy(18, 15); // Places you at these coordinates
gprintf("Hi"); // When using the drawing library you must use gprintf instead of printf
while (1) {
if (joypad() == J_UP && y != 0)
y--;
if (joypad() == J_DOWN && y != 143)
y++;
if (joypad() == J_LEFT && x != 0)
x--;
if (joypad() == J_RIGHT && x != 159)
x++;
if (joypad() == J_A) { // Change colors
waitpadup();
i++;
if (i > 3)
i = 0;
}
if (joypad() == J_B) { // Function to 'clear' the screen
for (j = 0; j < 20; j++) { // GB screen is 20 columns wide and 18 columns tall
for (f = 0; f < 18; f++) {
gotogxy(j, f);
wrtchr(' '); // Use wrtchr to place a character when using the drawing library
}
}
}
plot(x, y, i, SOLID); // Draws a pixel on the screen (x, y, color, mode)
delay(10);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,16 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = font.gb
OBJS = font.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,5 @@
# Font
![](screenshot.png)
Demonstrates how to switch from the default font. Be careful when using/loading fonts as they are loaded into VRAM and may overwrite tiles you're using. Built-in fonts include: font_spect, font_italic, font_ibm, font_min.

View File

@@ -0,0 +1,9 @@
#include <stdio.h>
#include <gb/gb.h>
#include <gb/font.h>
void main() {
font_init(); // Initialize font
font_set(font_load(font_spect)); // Set and load the font
printf("New font!");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = hello_world.gb
OBJS = hello_world.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,95 @@
# Hello World
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
Prints `Hello World!` to the screen using GBDK's `printf` function.
## Source
Includes `<gb/gb.h>`. This file contains all Gameboy specific functions.
It's the one you're going to use the most.
```c
#include <gb/gb.h>
```
Includes `<stdio.h>` it contains funtions for basic file/console input and
output.
```c
#include <stdio.h>
```
A C program always starts by calling the `main()` function. If you are
unfamiliar with this I suggest reading up on C first.
```c
void main() {
```
Prints the string `Hello World!` to the screen. Internally it uses the
background layer to do so as you can see in the VRAM of your favorite
emulator.
```c
printf("Hello World!");
```
Using `\n` you can create a new line. In this case it is used to create some
space between the previous sentence and the next.
```c
printf("\n\nPress Start");
}
```

View File

@@ -0,0 +1,3 @@
docco -t ../docs/res/readme_c.jst -o ./ hello_world.c
mv hello_world.html README.md

View File

@@ -0,0 +1,24 @@
// # Hello World
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
//
// Prints `Hello World!` to the screen using GBDK's `printf` function.
//
// ## Source
// Includes `<gb/gb.h>`. This file contains all Gameboy specific functions.
// It's the one you're going to use the most.
#include <gb/gb.h>
// Includes `<stdio.h>` it contains funtions for basic file/console input and
//output.
#include <stdio.h>
// A C program always starts by calling the `main()` function. If you are
// unfamiliar with this I suggest reading up on C first.
void main() {
// Prints the string `Hello World!` to the screen. Internally it uses the
// background layer to do so as you can see in the VRAM of your favorite
// emulator.
printf("Hello World!");
// Using `\n` you can create a new line. In this case it is used to create some
// space between the previous sentence and the next.
printf("\n\nPress Start");
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = huge_sprite.gb
OBJS = huge_sprite.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~ *.lst *.map

View File

@@ -0,0 +1,99 @@
# Huge Sprite
<div style="text-align: center"><img src="screenshot.png" alt="" /></div>
Render a huge 40x64 sprite that can be moved around with the D-pad.
## Source
```c
#include <gb/gb.h>
#include <types.h>
#include "sprite.h"
#include "bg.h"
#define SPR_WIDTH 8
#define SPR_HEIGHT 5
#define TOTAL_SPR SPR_WIDTH * SPR_HEIGHT
UINT8 x = 64;
UINT8 y = 96;
void render_huge_sprite() {
UINT8 i, j;
UINT8 sprite_index;
set_sprite_tile(0, 1);
for(i = 0; i < SPR_WIDTH; ++i) {
for(j = 0; j < SPR_HEIGHT; ++j) {
sprite_index = i * SPR_HEIGHT + j;
set_sprite_tile(sprite_index, sprite_index);
move_sprite(sprite_index, x + (j * 8), y + (i * 8));
}
}
}
void load_background() {
set_bkg_data(0, 2, bg_tile_data);
set_bkg_tiles(0, 0, 20, 18, bg_map_data);
}
void move_huge_sprite(UINT8 nx, UINT8 ny) {
UINT8 i, lx, ly;
lx = 0;
ly = 0;
for(i = 0; i < 40; i++) {
if(lx == 40) {
lx = 0;
ly += 8;
}
move_sprite(i, nx + lx, ny + ly);
lx += 8;
}
}
void move_right() {
move_huge_sprite(++x, y);
}
void move_left() {
move_huge_sprite(--x, y);
}
void main() {
SPRITES_8x8;
set_sprite_data(0, 40, sprite_tile_data);
render_huge_sprite();
load_background();
SHOW_SPRITES;
SHOW_BKG;
while(1) {
if(joypad() & J_RIGHT) {
move_right();
}
if(joypad() & J_LEFT) {
move_left();
}
delay(10);
}
}
```

View File

@@ -0,0 +1,67 @@
// ///////////////////////
// // //
// // File Attributes //
// // //
// ///////////////////////
// Filename: bg.png
// Pixel Width: 144px
// Pixel Height: 160px
// WARNING: Width of input image padded 3px to 144px
// /////////////////
// // //
// // Constants //
// // //
// /////////////////
const int bg_tile_map_size = 0x0168;
const int bg_tile_map_width = 0x12;
const int bg_tile_map_height = 0x14;
const int bg_tile_data_size = 0x20;
const int bg_tile_count = 0x0168;
// ////////////////
// // //
// // Map Data //
// // //
// ////////////////
const unsigned char bg_map_data[] ={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
};
// /////////////////
// // //
// // Tile Data //
// // //
// /////////////////
const unsigned char bg_tile_data[] ={
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x01,0x01,
0x80,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

View File

@@ -0,0 +1,2 @@
docco -t ../docs/res/readme_c.jst -o ./ huge_sprite.c -c ""
mv huge_sprite.html README.md

View File

@@ -0,0 +1,84 @@
// # Huge Sprite
// <div style="text-align: center"><img src="screenshot.png" alt="" /></div>
//
// Render a huge 40x64 sprite that can be moved around with the D-pad.
//
// ## Source
#include <gb/gb.h>
#include <types.h>
#include "sprite.h"
#include "bg.h"
#define SPR_WIDTH 8
#define SPR_HEIGHT 5
#define TOTAL_SPR SPR_WIDTH * SPR_HEIGHT
UINT8 x = 64;
UINT8 y = 96;
void render_huge_sprite() {
UINT8 i, j;
UINT8 sprite_index;
set_sprite_tile(0, 1);
for(i = 0; i < SPR_WIDTH; ++i) {
for(j = 0; j < SPR_HEIGHT; ++j) {
sprite_index = i * SPR_HEIGHT + j;
set_sprite_tile(sprite_index, sprite_index);
move_sprite(sprite_index, x + (j * 8), y + (i * 8));
}
}
}
void load_background() {
set_bkg_data(0, 2, bg_tile_data);
set_bkg_tiles(0, 0, 20, 18, bg_map_data);
}
void move_huge_sprite(UINT8 nx, UINT8 ny) {
UINT8 i, lx, ly;
lx = 0;
ly = 0;
for(i = 0; i < 40; i++) {
if(lx == 40) {
lx = 0;
ly += 8;
}
move_sprite(i, nx + lx, ny + ly);
lx += 8;
}
}
void move_right() {
move_huge_sprite(++x, y);
}
void move_left() {
move_huge_sprite(--x, y);
}
void main() {
SPRITES_8x8;
set_sprite_data(0, 40, sprite_tile_data);
render_huge_sprite();
load_background();
SHOW_SPRITES;
SHOW_BKG;
while(1) {
wait_vbl_done();
if(joypad() & J_RIGHT) {
move_right();
}
if(joypad() & J_LEFT) {
move_left();
}
delay(10);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@@ -0,0 +1,82 @@
// ///////////////////////
// // //
// // File Attributes //
// // //
// ///////////////////////
// Filename: sprite.png
// Pixel Width: 40px
// Pixel Height: 64px
// /////////////////
// // //
// // Constants //
// // //
// /////////////////
const int sprite_tile_map_size = 0x28;
const int sprite_tile_map_width = 0x05;
const int sprite_tile_map_height = 0x08;
const int sprite_tile_data_size = 0x0280;
const int sprite_tile_count = 0x28;
// ////////////////
// // //
// // Map Data //
// // //
// ////////////////
const unsigned char sprite_map_data[] ={
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27
};
// /////////////////
// // //
// // Tile Data //
// // //
// /////////////////
const unsigned char sprite_tile_data[] ={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x1F,0x1F,
0x00,0x00,0x01,0x01,0x0F,0x0F,0x1F,0x1F,0x7F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x80,0x80,0xE0,0xE0,0xF0,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xE0,0xE0,0xF0,0xF0,0xF0,0xF0,
0x07,0x07,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0E,0x0F,0x0E,0x0F,0x0F,0x0E,0x02,0x03,
0xFD,0xFF,0xDE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0xF0,0xF0,0xE8,0xE8,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x01,0x02,0x03,0x03,0x0C,0x0F,0x10,0x3E,0x21,0x15,0x2A,0x20,0x5F,0x8A,0xF5,
0x4D,0xB3,0x69,0xB6,0x39,0xE6,0x09,0xF6,0x53,0xAC,0x19,0xE6,0xBD,0x42,0xFC,0x03,
0xB7,0x4F,0x7B,0x87,0xFD,0x03,0xFE,0x01,0xFF,0x00,0xFF,0x00,0xFE,0x01,0xFB,0x04,
0xE8,0xE8,0xE4,0xE4,0xF4,0xF4,0x70,0xF0,0xB0,0x70,0xD8,0x38,0xD8,0x38,0xD8,0x38,
0x00,0x00,0x01,0x01,0x01,0x02,0x01,0x02,0x05,0x06,0x07,0x04,0x03,0x0C,0x1B,0x14,
0xB7,0xC8,0x77,0x88,0xFB,0x04,0xFB,0x04,0xFA,0x05,0xFB,0x04,0xF9,0x06,0xFB,0x04,
0xFA,0x05,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,
0xF7,0x08,0x6F,0x90,0xAF,0x50,0xBF,0x40,0xBF,0x40,0x3F,0xC0,0xAF,0x50,0x3F,0xC0,
0xDC,0x3C,0xFC,0x1C,0xFC,0x1C,0xFE,0x1E,0xFE,0x1E,0xFE,0x1E,0xFF,0x1F,0xFF,0x1F,
0x0F,0x10,0x19,0x26,0x10,0x2F,0x3F,0x40,0x3F,0x40,0xFF,0x80,0x7F,0x80,0x3E,0x41,
0xFD,0x02,0xFE,0x01,0xFF,0x00,0x4F,0xB0,0xC3,0x7C,0x08,0xF7,0x9F,0xE0,0xBE,0xC1,
0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFC,0x03,0x33,0xCC,0x4F,0xB0,0xBF,0xC0,
0xB7,0x48,0xB7,0x48,0xFF,0x00,0x9F,0x78,0x77,0xF8,0x17,0xE8,0x9F,0x60,0x4F,0xB0,
0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xEF,0x1F,0xFF,0x1F,0xEF,0x1F,0xFF,0x1F,0xFF,0x1F,
0x06,0x19,0x00,0x03,0x01,0x01,0x00,0x01,0x01,0x00,0x01,0x02,0x01,0x02,0x03,0x00,
0x3C,0xC3,0x3C,0xC3,0xBC,0xC3,0x1E,0xE1,0xA0,0x5F,0xFF,0x00,0xFF,0x00,0xFF,0x00,
0x7F,0x80,0xFF,0x00,0xFE,0x01,0xFF,0x00,0x04,0xFB,0xEF,0x10,0xFF,0x00,0xEF,0x10,
0xBF,0x40,0x3F,0xC0,0x9F,0x60,0x1F,0xE0,0x4F,0xB0,0x40,0xBF,0x5F,0xAF,0xDF,0x2F,
0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0xFF,0x1F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1005 B

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = input_state.gb
OBJS = input_state.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Input State
![](screenshot.png)
Prints the pressed button every 100ms.

View File

@@ -0,0 +1,41 @@
#include <stdio.h>
#include <gb/gb.h>
void main() {
while(1) {
switch(joypad()) {
case J_LEFT:
printf("Left!\n");
delay(100);
break;
case J_RIGHT:
printf("Right!\n");
delay(100);
break;
case J_UP:
printf("Up!\n");
delay(100);
break;
case J_DOWN:
printf("Down!\n");
delay(100);
break;
case J_START:
printf("Start!\n");
delay(100);
break;
case J_SELECT:
printf("Select!\n");
delay(100);
break;
case J_A:
printf("A!\n");
delay(100);
break;
case J_B:
printf("B!\n");
delay(100);
break;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = input_wait.gb
OBJS = input_wait.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Input Wait
![](screenshot.png)
Demonstrates how to wait for key pressed and releases.

View File

@@ -0,0 +1,15 @@
#include <stdio.h>
#include <gb/gb.h>
void main() {
while(1) {
printf("Press Start\n\n");
waitpad(J_START);
printf("Please hold down A!\n\n");
waitpad(J_A);
printf("Holding down A!\n\n");
waitpadup();
printf("Tired already?\n\n\n");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = link.gb
OBJS = link.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Link
![](screenshot.png)
Demonstrates how to use the Link Cable to send and receive bytes.

View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <gb/gb.h>
void main(void) {
printf("A: Send\nB: Receive\n\n");
_io_out = 1;
while (1) {
if (joypad() == J_A) {
waitpadup();
send_byte(); // send _io_out
printf("Sending...\n");
while (_io_status == IO_SENDING); // Wait for Send
if (_io_status == IO_IDLE) // If IO status returns to Idle then success
printf("Sent %d\n", (int)_io_out);
else
printf("Error\n"); // Else print error code
_io_out++;
}
if (joypad() == J_B) {
waitpadup();
receive_byte(); // receive _io_in
printf("Receiving...\n");
while (_io_status == IO_RECEIVING); // Wait for Receive
if (_io_status == IO_IDLE) // If IO status returns to Idle then success
printf("Received %d\n", (int)_io_in);
else
printf("Error\n"); // Else print error
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = move_sprite.gb
OBJS = move_sprite.o ufo.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,6 @@
# Move Sprite
![](screenshot.gif)
Demonstrates how to move a sprite using the d-pad.

View File

@@ -0,0 +1,37 @@
#include <gb/gb.h>
#include "ufo.c"
void main() {
int x = 55;
int y = 75;
SPRITES_8x8;
set_sprite_data(0, 0, ufo);
set_sprite_tile(0, 0);
move_sprite(0, x, y);
SHOW_SPRITES;
while(1) {
if(joypad() & J_RIGHT) {
x++;
move_sprite(0, x, y);
delay(10);
}
if(joypad() & J_LEFT) {
x--;
move_sprite(0, x, y);
delay(10);
}
if(joypad() & J_UP) {
y--;
move_sprite(0, x, y);
delay(10);
}
if(joypad() & J_DOWN) {
y++;
move_sprite(0, x, y);
delay(10);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,32 @@
/*
UFO.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 0
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 ufo[] =
{
0x5A,0x3C,0xE3,0x42,0x7C,0x99,0xEB,0xA5,
0xFB,0xA5,0x66,0x99,0xE7,0x42,0x5A,0x3C
};
/* End of UFO.C */

Binary file not shown.

View File

@@ -0,0 +1,31 @@
/*
UFO.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 0
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 ufoBank 0
/* Start of tile array. */
extern unsigned char ufo[];
/* End of UFO.H */

View File

@@ -0,0 +1,16 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m -Wl-yt3 -Wl-yo4 -Wl-ya4
BIN = save_ram.gb
OBJS = save_ram.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,5 @@
# Save RAM
![](screenshot.png)
Demonstrates how to load and save variables. Using Save RAM requires additional compiler arguments.

View File

@@ -0,0 +1,22 @@
#include <stdio.h>
#include <gb/gb.h>
char *saved = (char *)0xa000; // Pointer to memory address
int *num = (int *)0xa001;
void main()
{
ENABLE_RAM_MBC1; // Enable RAM
if (saved[0] != 's') { // Check to see if the variable's ever been saved before
num[0]=0; // Assign the variable an initial value
saved[0] = 's'; // Assign saved an 's' value so the if statement isn't executed on next load
}
printf("The value of num is: %d\n", num[0]);
num[0]++; // Increment so on next load there's a new number
DISABLE_RAM_MBC1; // Disable RAM
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -0,0 +1,17 @@
AS = lcc -c
CC = lcc -Wa-l -Wl-m
BIN = simple_shmup.gb
OBJS = simple_shmup.o bank2.o bank3.o
all: $(BIN)
%.s: %.ms
maccer -o $@ $<
$(BIN): $(OBJS)
$(CC) -o $(BIN) $(OBJS)
clean:
rm -rf $(BIN) $(OBJS) *~

View File

@@ -0,0 +1,8 @@
# Simple SHMUP
![](screenshot.png)
A simple side-scrolling shoot 'em up game. This example uses several small
sprites, a scrolling background and a full-screen image.
Tutorial: [How to write a simple side scrolling game in GBDK](https://pastebin.com/F3tHLj68) by Jason

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,154 @@
#include <gb/gb.h>
#include <gb/drawing.h>
#include <rand.h>
const UBYTE badguy_ai[] = {
32, 32, 33, 34, 35, 35, 36, 37,
38, 38, 39, 40, 41, 41, 42, 43,
44, 44, 45, 46, 46, 47, 48, 48,
49, 50, 50, 51, 51, 52, 53, 53,
54, 54, 55, 55, 56, 56, 57, 57,
58, 58, 58, 59, 59, 60, 60, 60,
61, 61, 61, 61, 62, 62, 62, 62,
62, 63, 63, 63, 63, 63, 63, 63,
63, 63, 63, 63, 63, 63, 63, 63,
62, 62, 62, 62, 62, 61, 61, 61,
61, 60, 60, 60, 59, 59, 59, 58,
58, 57, 57, 56, 56, 55, 55, 54,
54, 53, 53, 52, 52, 51, 50, 50,
49, 49, 48, 47, 47, 46, 45, 44,
44, 43, 42, 42, 41, 40, 39, 39,
38, 37, 36, 36, 35, 34, 33, 33,
32, 31, 30, 29, 29, 28, 27, 26,
26, 25, 24, 23, 23, 22, 21, 20,
20, 19, 18, 18, 17, 16, 16, 15,
14, 14, 13, 12, 12, 11, 11, 10,
9, 9, 8, 8, 7, 7, 6, 6,
6, 5, 5, 4, 4, 4, 3, 3,
3, 2, 2, 2, 1, 1, 1, 1,
1, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 2, 2,
2, 3, 3, 3, 4, 4, 4, 5,
5, 5, 6, 6, 7, 7, 8, 8,
9, 9, 10, 11, 11, 12, 12, 13,
14, 14, 15, 16, 16, 17, 18, 18,
19, 20, 20, 21, 22, 23, 23, 24,
25, 26, 26, 27, 28, 29, 29, 30
};
UBYTE playing, joypad_state;
UBYTE player_x, player_y;
UBYTE badguy_x, badguy_y, badguy_z, badguy_offset;
UBYTE player_shot_x, player_shot_y, player_shot_z;
void update_graphics(void) {
disable_interrupts();
scroll_bkg(1, 0);
move_sprite(0, player_x, player_y);
move_sprite(1, badguy_x, badguy_y);
move_sprite(2, player_shot_x, player_shot_y);
enable_interrupts();
}
void update_joypad(void) {
joypad_state = joypad();
if(joypad_state & J_LEFT) {
if(player_x > 8)
player_x--;
}
if(joypad_state & J_RIGHT) {
if(player_x < 160)
player_x++;
}
if(joypad_state & J_UP) {
if(player_y > 16)
player_y--;
}
if(joypad_state & J_DOWN) {
if(player_y < 152)
player_y++;
}
if(joypad_state & J_A) {
if(player_shot_z == 0) {
player_shot_z = 1;
player_shot_x = player_x;
player_shot_y = player_y;
}
}
if(player_shot_z == 1) {
player_shot_x = player_shot_x + 2;
if(player_shot_x > 240) {
player_shot_x = 250;
player_shot_y = 250;
player_shot_z = 0;
}
}
}
void update_badguy(void) {
badguy_x = badguy_x - 1;
if(badguy_x > 240) {
badguy_offset = rand();
while(badguy_offset > 134) {
badguy_offset = rand();
}
badguy_x = 239;
}
badguy_y = badguy_offset + badguy_ai[badguy_z];
badguy_z++;
}
void collision_detection(void) {
if(player_shot_y > badguy_y - 4) {
if(player_shot_y < badguy_y + 4) {
if(player_shot_x > badguy_x - 4) {
if(player_shot_x < badguy_x + 4) {
player_shot_z = 0;
player_shot_x = 250;
player_shot_y = 250;
badguy_x = 255;
}
}
}
}
if(player_y > badguy_y - 4) {
if(player_y < badguy_y + 4) {
if(player_x > badguy_x - 4) {
if(player_x < badguy_x + 4) {
playing = 0;
delay(1000);
}
}
}
}
}
void do_gameplay(void) {
playing = 1;
player_x = GRAPHICS_WIDTH / 2;
player_y = GRAPHICS_HEIGHT / 2;
while(playing == 1) {
update_joypad();
update_badguy();
collision_detection();
delay(10);
}
}

View File

@@ -0,0 +1,90 @@
#include <gb/gb.h>
#include "bg_title.c"
#include "bg_title.map"
#include "bg_tile.c"
#include "spr_tiles.c"
const UBYTE gamemap[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
const UWORD bgpal[] = {
RGB(0, 0, 0), RGB(10, 10, 10), RGB(20, 20, 20), RGB(30, 30, 30),
};
const UWORD spritepal[] = {
RGB(0, 0, 0), RGB(10, 10, 10), RGB(20, 20, 20), RGB(30, 30, 30),
};
void draw_title_screen(void) {
wait_vbl_done();
DISPLAY_OFF;
set_bkg_data(0, 255, bg_title_tiledata);
set_bkg_tiles(0, 0, 20, 18, bg_title_tilemap);
SHOW_BKG;
HIDE_WIN;
HIDE_SPRITES;
wait_vbl_done();
DISPLAY_ON;
waitpad(255);
}
void load_game_tiles(void) {
wait_vbl_done();
DISPLAY_OFF;
set_bkg_data(0, 1, BGTile);
set_bkg_tiles(0, 0, 32, 32, gamemap);
set_bkg_palette(0, 1, &bgpal[0]);
set_sprite_data(0, 3, SpriteTiles);
set_sprite_tile(0, 0);
set_sprite_tile(1, 1);
set_sprite_tile(2, 2);
SPRITES_8x8;
SHOW_SPRITES;
SHOW_BKG;
DISPLAY_ON;
}

View File

@@ -0,0 +1,32 @@
/*
BG_TILE.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 0
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. */
const unsigned char BGTile[] =
{
0xFF,0xFF,0xFB,0xFB,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0x7F,0x7F,0xF7,0xF7,0xFF,0xFF
};
/* End of BG_TILE.C */

View File

@@ -0,0 +1,31 @@
/*
BG_TILE.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 0
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 BGTileBank 0
/* Start of tile array. */
extern unsigned char BGTile[];
/* End of BG_TILE.H */

View File

@@ -0,0 +1,170 @@
/*
Advanced PCX to GameBoy converter v2.15
Tiles data
Original PCX File : "BG.PCX"
Number of Tiles : 159
TileMap Size : 20x18
*/
const unsigned char bg_title_tiledata[] = {
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,0x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F,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFC,0xFC,0x3F,0x3F,0x3F,0x3F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x78,0x78,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xF8,0xF8,0xFE,0xFE,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x7F,0x7F,0x0F,0x0F,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};

View File

@@ -0,0 +1,8 @@
echo off
lcc -Wa-l -Wl-m -Wl-j -c -o simple_shmup.o simple_shmup.c
lcc -Wa-l -Wl-m -Wl-j -Wf-bo2 -c -o bank2.o bank2.c
lcc -Wa-l -Wl-m -Wl-j -Wf-bo3 -c -o bank3.o bank3.c
lcc -Wa-l -Wl-m -Wl-j -Wl-yt0x01 -Wl-yo4 -o simple_shmup.gb simple_shmup.o bank2.o bank3.o
rem -Wl-yp0x143=0x80

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,58 @@
#include <gb/gb.h>
#include <rand.h>
#include <stdio.h>
// bank 0
void vblint(void);
// bank 2
void update_graphics(void);
void do_gameplay(void);
void update_joypad(void);
void update_badguy(void);
void collision_detection(void);
// bank 3
void draw_title_screen(void);
void load_game_tiles(void);
fixed seed;
// main
void main() {
seed.b.l = DIV_REG;
SWITCH_ROM_MBC1(3);
draw_title_screen();
seed.b.h = DIV_REG;
initrand(seed.w);
load_game_tiles();
disable_interrupts();
add_VBL(vblint);
SWITCH_ROM_MBC1(2);
enable_interrupts();
do_gameplay();
reset();
}
void vblint(void) {
SWITCH_ROM_MBC1(2);
update_graphics();
}

View File

@@ -0,0 +1,36 @@
/*
SPR_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 2
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. */
const unsigned char SpriteTiles[] =
{
0x40,0x40,0xE0,0xA0,0xFE,0x80,0xC8,0xB8,
0x8C,0xF4,0x96,0xEA,0xA9,0xD7,0xFF,0xFF,
0x02,0x40,0xC5,0xA3,0xE5,0xBB,0xF5,0xAB,
0xF5,0xAB,0xF5,0xAB,0xFD,0xBB,0x42,0x42,
0x00,0x00,0x00,0x18,0x18,0x3C,0x3C,0x66,
0x3C,0x66,0x18,0x3C,0x00,0x18,0x00,0x00
};
/* End of SPR_TILES.C */

Some files were not shown because too many files have changed in this diff Show More