Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)
You are not logged in.
Hello all, i have recently started to mess with GB programming. I've read quite a bit of technical information and thought i would be ready to finally code something.
I came up with this little hello world program:
include "inc/gbhw.inc" include "inc/ibmpc1.inc" SECTION "Vblank", ROM0[$0040] ret SECTION "LCDC", ROM0[$0048] ret SECTION "TimerOverflow", ROM0[$0050] ret SECTION "Serial", ROM0[$0058] ret SECTION "Joypad", ROM0[$0060] ret SECTION "Header", ROM0[$0100] nop jp Main Section "Logo", ROM0[$0104] DB $CE, $ED, $66, $66, $CC, $0D, $00, $0B DB $03, $73, $00, $83, $00, $0C, $00, $0D DB $00, $08, $11, $1F, $88, $89, $00, $0E DB $DC, $CC, $6E, $E6, $DD, $DD, $D9, $99 DB $BB, $BB, $67, $63, $6E, $0E, $EC, $CC DB $DD, $DC, $99, $9F, $BB, $B9, $33, $3E Section "Title", ROM0[$0134] db "title" Section "GBCComp", ROM0[$0143] DB $C0 Section "Data", ROM0 HELLO_TILES:: DB $00,$00,$00,$00,$00,$00,$00,$00 DB $00,$00,$00,$00,$00,$00,$00,$00 DB $C6,$C6,$C6,$C6,$C6,$C6,$FE,$FE DB $FE,$FE,$C6,$C6,$C6,$C6,$C6,$C6 DB $FE,$FE,$FE,$FE,$80,$80,$F8,$F8 DB $F8,$F8,$80,$80,$FE,$FE,$FE,$FE DB $C0,$C0,$C0,$C0,$C0,$C0,$C0,$C0 DB $C0,$C0,$C0,$C0,$FE,$FE,$FE,$FE DB $7C,$7C,$FE,$FE,$C6,$C6,$C6,$C6 DB $C6,$C6,$C6,$C6,$FE,$FE,$7C,$7C DB $C6,$C6,$C6,$C6,$C6,$C6,$C6,$C6 DB $D6,$D6,$D6,$D6,$FE,$FE,$6C,$6C DB $FC,$FC,$FE,$FE,$C6,$C6,$FC,$FC DB $FC,$FC,$C6,$C6,$C6,$C6,$C6,$C6 DB $FC,$FC,$FE,$FE,$C6,$C6,$C6,$C6 DB $C6,$C6,$C6,$C6,$FE,$FE,$FC,$FC DB $6C,$6C,$6C,$6C,$6C,$6C,$6C,$6C DB $6C,$6C,$6C,$6C,$00,$00,$6C,$6C HELLO_MAP:: DB $01,$02,$03,$03,$04,$00,$05,$04,$06,$03,$07,$08 SECTION "main", ROM0[$0150] WaitVBlank: ld a, [$ff44] cp 144 jp c, WaitVBlank ret LoadTiles: ld hl, HELLO_TILES ld de, _VRAM ld bc, 9*16 LoadTilesLoop: call WaitVBlank ld a, [hl] ld [de], a inc de inc hl dec bc ld a, b or c jr nz, LoadTilesLoop ret LoadMap: ld hl, HELLO_MAP ld de, $9800 ld c, 12 LoadMapLoop: call WaitVBlank ld a, [hl] ld [de], a inc de inc hl dec bc ld a, b or c jr nz,LoadMapLoop ret Main: ld sp, $ffff call LoadTiles call LoadMap .Wait: halt nop jr .Wait
The "LoadTiles" function seems to work fine, i can verify with bgb that the tiles end up in vram.
But every time "loadMap" writes a value to $9800 it simultaneously deletes a tile from the beginning of Vram ($8000)
It writes the value in the tilemap, but in never displays anything because by then, all the actual tiles are deleted ?
I just dont understand whats going on here.
Am i missing something ?
Last edited by thrawn235 (2018-03-26 11:43:40)
Offline
What looks like 'deleting' the tiles is most likely using them, but with no palette assigned. When tiles are used bgb changes their coloring to match the palette in use (or something like that).
ld a,%11100100 ; Set Palettes ldh [rBGP],a ldh [rOBP0],a ldh [rOBP1],a
Offline