From: Lukas Krickl Date: Sun, 11 Jan 2026 11:12:29 +0000 (+0100) Subject: wip: map rendering X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=257828ef0370c786c0cb0e13067a8108326db571;p=gbrg%2F.git wip: map rendering --- diff --git a/TODO.md b/TODO.md index d8cd3c7..415a83e 100644 --- a/TODO.md +++ b/TODO.md @@ -15,6 +15,13 @@ # Combat +# Magic + +- scrolls can be found +- scrolls are single use +- if enough in is available the player can learn the spell +- there are 5 spell slots + # Equipment # UI diff --git a/src/debug.s b/src/debug.s index d0e6309..822b0a8 100644 --- a/src/debug.s +++ b/src/debug.s @@ -1,49 +1,2 @@ #define DEBUG_FONT_START 0xD0 -debug_draw_player_pos: - ld a, 2 - call oamalloc - - ld de, player+act_pos_y - - ; draw y - - ; y pos - ld a, 128 - ld [hl+], a - - ; x pos - ld a, 32 - ld [hl+], a - - ; tile - ld a, [de] - add a, DEBUG_FONT_START - ld [hl+], a - - ; flags - xor a, a - ld [hl+], a - - ; draw x - - ; y pos - ld a, 128 - ld [hl+], a - - ; x pos - ld a, 40 - ld [hl+], a - - ; tile - inc de - ld a, [de] - add a, DEBUG_FONT_START - ld [hl+], a - - ; flags - xor a, a - ld [hl+], a - - - ret diff --git a/src/map.s b/src/map.s index 95727bb..b2eb76e 100644 --- a/src/map.s +++ b/src/map.s @@ -253,8 +253,6 @@ map_get_tile: map_full_draw_oam_clear: ; first clear nearby actors from oam call shadow_oam_clear - ; draw UI again - call compass_draw call next_vblank_wait ; dma empty oam call OAMDMAFN @@ -264,9 +262,7 @@ map_full_draw_oam_clear: ; draws a full map copy into the current map view buffer - ; based on the current location the player is facing - ; the map render buffer is then written to the screen - ; draws rooms ahead of the player back to front + ; draws the are around the players viewport ; inputs: ; [map] ; returns: @@ -274,8 +270,6 @@ map_full_draw_oam_clear: ; transferts to redraw state map_full_draw: @done: - call minimap_full_draw - ; 4) go to render state call update_render ret diff --git a/src/player.s b/src/player.s index a004581..4075728 100644 --- a/src/player.s +++ b/src/player.s @@ -67,6 +67,10 @@ player_init: ld hl, player_attr ld bc, attr_size call memset + + ; set default view + ld a, 5 + ld [player_viewport], a ret diff --git a/src/ui.s b/src/ui.s index 697c7a6..c3fcb3e 100644 --- a/src/ui.s +++ b/src/ui.s @@ -33,129 +33,6 @@ ui_update: ; draws the entire UI ; only call during blank ui_draw: - ; draw map border - - ; draw minimap to ui - ld hl, SCRN1 + 32 * 2 + 16 - ld de, 29 ; offset for next row - - ; row 0 - ld a, [minimap_buffer] - ld [hl+], a - - ld a, [minimap_buffer+1] - ld [hl+], a - - ld a, [minimap_buffer+2] - ld [hl+], a - - ; row 1 - add hl, de - ld a, [minimap_buffer+3] - ld [hl+], a - - ld a, [minimap_buffer+4] - ld [hl+], a - - ld a, [minimap_buffer+5] - ld [hl+], a - - ; row 2 - add hl, de - ld a, [minimap_buffer+6] - ld [hl+], a - - ld a, [minimap_buffer+7] - ld [hl+], a - - ld a, [minimap_buffer+8] - ld [hl+], a - - ret - - ; draws a single minimap tile based on the player's position - ; inputs: - ; $1: y offset - ; $2: x offset - ; returns: - ; writes into minimap_buffer at the offset -#macro minimap_draw_tile -.beginscope - ld a, [player+act_pos_y] - add a, $1 & 0xFF - ld b, a - - ld a, [player+act_pos_x] - add a, $2 & 0xFF - ld c, a - - call map_get_tile - ; hl = tile - - inc hl ; hl = tile flags - ld a, [hl] ; load tile information - add a, 0x60 ; tile offset for map tiles - - ; 0/0 is the center of the minimap - ; so +4 and then offset by $1 and $2 - ld [minimap_buffer+4+($1*3)+$2], a -.endscope -#endmacro - - ; redraws the minimap - ; into a 3x3 minimap buffer -minimap_full_draw: - minimap_draw_tile 0, 0 - minimap_draw_tile 0, 1 - - minimap_draw_tile 1, 0 - minimap_draw_tile 1, 1 - - minimap_draw_tile -1, 1 - minimap_draw_tile 1, -1 - minimap_draw_tile -1, -1 - - minimap_draw_tile 0, -1 - minimap_draw_tile -1, 0 - ret -compass_tiles: - .db TILE_SOUTH, TILE_NORTH, TILE_WEST, TILE_EAST - - ; draws the players current facing direction - ; as a compass -compass_draw: - ld a, 1 - call oamalloc - - ; y - ld a, WINDOW_Y + 40 - ld [hl+], a - - ; x - ld a, WINDOW_X+137 - ld [hl+], a - - ; tile - push hl - ld a, [player+act_dir] - and a, ACT_DIR_MASK - - ld d, 0 - ld e, a - ld hl, compass_tiles - add hl, de - ld a, [hl] ; a = tile - pop hl - ld [hl+], a - - ; flags - xor a, a - ld [hl], a - -#ifdef DEBUG_UI - call debug_draw_player_pos -#endif - ret diff --git a/src/update.s b/src/update.s index 44204c3..112cb7e 100644 --- a/src/update.s +++ b/src/update.s @@ -8,7 +8,6 @@ update_game: ; player should update even in debug mode call player_update - call compass_draw ; tick rng every frame call rand diff --git a/src/wram.s b/src/wram.s index 110f822..82e08cb 100644 --- a/src/wram.s +++ b/src/wram.s @@ -76,6 +76,7 @@ srand: .adv 2 player_attr: .adv attr_size player_exp: .adv 2 player_level: .adv 1 +player_viewport: .adv 1 actors: player: .adv act_size