參考資訊:
https://bgb.bircd.org/
https://github.com/mrombout/gbdk_playground
http://gbdk.sourceforge.net/doc/html/book01.html
Tile設定
void set_bkg_data(UBYTE first_tile, UBYTE nb_tiles, unsigned char *data);
第一個參數是Tile位置(0~255)
第二個參數是需要複製多少個Tile像素(0代表256個),每個Tile像素是8x8(16 Bytes)
第三個參數是Tile來源位置
Tile指定
void set_bkg_tiles(UBYTE x, UBYTE y, UBYTE w, UBYTE h, unsigned char *tiles);
第一個參數是x位置
第二個參數是y位置
第三個參數是Tile寬(W)的數量
第四個參數是Tile高(H)的數量
第五個參數是Tile Map,大小必須是WxH,Map描述Tile的索引
main.c
#include <gb/gb.h>
unsigned char tile[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
};
unsigned char map[] = {
1, 0, 1, 1, 0, 1,
};
void main(void)
{
VBK_REG = 0;
set_bkg_data(0, 2, tile);
set_bkg_tiles(0, 8, 6, 1, map);
SHOW_BKG;
}
完成