From: Lukas Krickl Date: Thu, 30 Oct 2025 10:22:55 +0000 (+0100) Subject: map: Added tile draw routine X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=6738d2530ab908eac4e621ff04d681e843bc1747;p=gbrg%2F.git map: Added tile draw routine --- diff --git a/src/map.s b/src/map.s index 4e41567..831d41f 100644 --- a/src/map.s +++ b/src/map.s @@ -23,12 +23,13 @@ map_load: push de call map_tiles_load pop de + + call map_full_draw call lcd_on call vblank_wait call enableinterrupts - call map_full_draw call player_init call ui_init @@ -158,11 +159,62 @@ map_tile_banks_load: #endmacro + ; draws a tile + ; to the screen + ; inputs: + ; hl: tile + ; b/c: y/x position +map_draw_tile: + ; find tile to draw + ld de, t_tile + add hl, de + + ; load tile into a + ld a, [hl] ; a = tile + push af ; save tile gfx + + ld hl, SCRN0 + ld de, MAP_W + + ; skip y loop if b is 0 + ld a, b + cp a, 0 + jr z, @skip_y REL + +@y_loop: + add hl, de + dec b + jr nz, @y_loop REL +@skip_y: + + ld d, 0 + ld e, c + add hl, de ; hl = SCRN location + + pop af + ld [hl], a + + ret + + ; draws 16 tiles + ; inputs: + ; hl: start tile + ; b: y position +map_draw_row: + ret + ; draws a full page of the currently selected map - ; waits for blank between each row ; inputs: ; [map] map_full_draw: + ld bc, MAP_TILES + ld hl, tiles + + push hl + ld bc, 0 + call map_draw_tile + pop hl + ret ; nop map rotuine