參考資訊:
https://bgb.bircd.org/
https://github.com/mrombout/gbdk_playground
http://gbdk.sourceforge.net/doc/html/book01.html
GBDK裡面的Sprite指的就是Object Attribute Memory(OAM),而Tile指的則是Character RAM(單位是8x8 Pixels)
Tile設定
void set_sprite_data(UBYTE first_tile, UBYTE nb_tiles, unsigned char *data);
第一個參數是Tile位置(0~255)
第二個參數是需要複製多少個Tile像素(0代表256個),每個Tile像素是8x8(16 Bytes)
第三個參數是Tile來源位置
Title指定
void set_sprite_tile(UBYTE nb, UBYTE tile);
第一個參數是OAM的索引(0~39)
第二個參數是Tile位置(0~255)
main.c
#include <gb/gb.h>
unsigned char sprite[] = {
0x7e, // .xxxxxx.
0x7e, // .xxxxxx.
0x99, // x..xx..x
0x99, // x..xx..x
0x81, // x......x
0x81, // x......x
0xa5, // x.x..x.x
0xa5, // x.x..x.x
0x81, // x......x
0x81, // x......x
0xdb, // xx.xx.xx
0xdb, // xx.xx.xx
0xc3, // xx....xx
0xc3, // xx....xx
0x3c, // ..xxxx..
0x3c // ..xxxx..
};
void main(void)
{
SPRITES_8x8;
set_sprite_data(0, 1, sprite);
set_sprite_tile(0, 0);
move_sprite(0, 50, 50);
SHOW_SPRITES;
}
完成