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, I am new to programming with Assembly and I was trying to load a few rows of tiles onto the screen. The tiles do load onto the screen and are displayed but some tiles are missing in very specific patterns on the screen. I am not sure what is wrong, here is the code I am using if anyone can help:
begin: di ; Disable Interrupts ld sp , $fffe ; Initialise Stack Pointer call stop_lcd ; Need to stop the LCD to write to display ; Load tiles into vram ld de, $8010 ld hl, Tiles ld b, $10 call CopyTiles ; Set tilemap stuff ld de, $9800 ld hl, BGMap ld b, $A0 call CopyMap call init_registers ei jp Done stop_lcd: ld a , (R_LY) cp 145 jr nz , stop_lcd ld a , (R_LY) res 7 , a ld (R_LY) , a ret Done: nop jp Done CopyTiles: ld a, (hl) ld (de), a inc de inc hl dec b jr nz, CopyTiles ret CopyMap: ld a, (hl) ld (de), a inc de inc hl dec b jr nz, CopyMap ret init_registers: ; Initialise Registers ld a, $00 xor a ld (R_SCX), a ld (R_SCY), a ld a , %11100100 ; Standard Palette Colours ld (R_BGP), a ld a , %10010011 ; LCD On, Tile Map 0, Window Off, TDT 1, BGTM 0, 8x8, sprite off, BG On ld (R_LCDC), a ret Tiles: db $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff db $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff db $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff db $ff, $ff, $ff, $ff, $ff, $ff, $ff, $ff BGMap: db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Last edited by nitro2k01 (2023-12-27 10:51:15)
Offline
The issue is your code for disabling the LCD, which writes to the wrong register. The pattern you're seeing is the time when VRAM is inaccessible because the screen is rendering.
ld a , (R_LCDC) res 7 , a ld (R_LCDC) , a
Last edited by nitro2k01 (2023-12-27 10:59:37)
Online
Thank you, It works great now!
Offline