參考資訊:
https://bgb.bircd.org/
https://github.com/gbdev/rgbds
https://github.com/sinamas/gambatte
https://github.com/lancekindle/DMGreport
每個像素使用2bits表示(4個顏色),相較於BG,OAM使用00代表透明顏色,因此,OAM只能顯示3個顏色
每一個Palette有4個顏色可以設定,共有8個Palette可以使用
每個顏色由15bits組成
設定的方式則是透過OCPS(設定位址)、OCPD(設定資料)
main.s
OAMRAM equ $fe00 LCDC equ $ff40 LCDCF_OBJ8 equ %00000000 LCDCF_OBJON equ %00000010 section "vblank", rom0[$0040] reti section "lcdc", rom0[$0048] reti section "timer", rom0[$0050] reti section "serial", rom0[$0058] reti section "joypad", rom0[$0060] reti section "entry", rom0[$0100] nop jp _start section "header", rom0[$0104] db $ce, $ed, $66, $66, $cc, $0d, $00, $0b, $03, $73, $00, $83, $00, $0c, $00, $0d db $00, $08, $11, $1f, $88, $89, $00, $0e, $dc, $cc, $6e, $e6, $dd, $dd, $d9, $99 db $bb, $bb, $67, $63, $6e, $0e, $ec, $cc, $dd, $dc, $99, $9f, $bb, $b9, $33, $3e db "0123456789abcde" db $80 db 0, 0 db 0 db 0 db 0 db 0 db 1 db $33 db 0 db 0 dw 0 _start: di ld a, [LCDC] or LCDCF_OBJON or LCDCF_OBJ8 ld [LCDC], a ld d, 32 ld bc, tile ld hl, $8000 copy_tile: ld a, [bc] ld [hl+], a inc bc dec d jr nz, copy_tile ld b, 0 ld hl, color copy_palette: ld a, b ld [$ff6a], a ld a, [hl] ld [$ff6b], a inc hl inc b ld a, b cp 8 jr nz, copy_palette ld hl, OAMRAM + 0 ld [hl], 30 ld hl, OAMRAM + 1 ld [hl], 30 ld hl, OAMRAM + 2 ld [hl], 1 ld hl, OAMRAM + 3 ld [hl], 0 jp @ color: dw $7fff dw $001f dw $03e0 dw $7c00 tile: db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000 db %11111111 db %00000000
設定OBJ0的位置(y:30, x:30)、CHR(1)、屬性(0),CHR其實就是一般稱呼的Tile,而Sprite則是由Tile組合而成的圖形
完成