From: Lukas Krickl Date: Wed, 31 Dec 2025 12:09:29 +0000 (+0100) Subject: map: wip refactor map drawing X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=c9fe3975dcfa31a7f3edd9d28c54ec8e87c6c528;p=gbrg%2F.git map: wip refactor map drawing --- diff --git a/src/defs.s b/src/defs.s index 5b22335..419389a 100644 --- a/src/defs.s +++ b/src/defs.s @@ -122,8 +122,20 @@ .se 0 .de TT_EMPTY, 1 .de TT_OPEN, 1 + + ; tile p0 for TT_LOCKED + ; 0000nnnn: direction bits locked door (TF_SE, NE, WE, SE) + ; nnnn0000: lock level (0-15) .de TT_LOCKED, 1 +.de TT_WATER, 1 +.de TT_WATER_DEEP, 1 + + ; tile p0 for TT_LAVA + ; 0000nnnn: damage level +.de TT_LAVA, 1 + + ; tile flags0 .se 1 ; SOUTH EXIT @@ -135,6 +147,7 @@ ; EAST EXIT .de TF_EE, 8 + ; tile struct .se 0 .de t_type, 1 diff --git a/src/levels.s b/src/levels.s index 25da458..c63ed87 100644 --- a/src/levels.s +++ b/src/levels.s @@ -19,7 +19,13 @@ l1_acts: .db 0 ; terminate l1_tile_props: - maptpdef TT_LOCKED, 1, 0, 0, 0, 0 + maptpdef TT_LOCKED,\ + 1,\ + 0,\ + 0,\ + 0,\ + (1 << 4) | TF_SE + .db 0 ; terminate tile_banks_default: diff --git a/src/map.s b/src/map.s index f1a7530..c2378dd 100644 --- a/src/map.s +++ b/src/map.s @@ -508,6 +508,40 @@ map_full_draw_oam_clear: call OAMDMAFN ret + ; gets the direction vector + ; for the current player direction + ; inputs: + ; player actor direction + ; returns: + ; tle_dir_vector: set for all directions +_map_full_draw_get_dir_vector: + ld a, [player+act_dir] + and a, ACT_DIR_MASK + + cp a, SOUTH + jp z, @south + + cp a, NORTH + jp z, @north + + cp a, WEST + jp z, @west + + ; default case east +@east: + ret + +@south: + ret + +@north: + ret + +@west: + ret + + + ; draws a full map copy into the current map view buffer ; bsed on the current location the player is facing ; the map render buffer is then written to the screen @@ -521,9 +555,13 @@ map_full_draw_oam_clear: ; render_buffer: new map data to be drawn ; transferts to redraw state map_full_draw: - ; now we can draw the map + ; TODO: remove this call once all references to the + ; wram values are removed + ; now we can draw the map call map_full_draw_count_forward_attributes + call _map_full_draw_get_dir_vector + ld a, [tmp_map_forward] cp a, MAP_NO_DOOR jp z, @short_wall diff --git a/src/wram.s b/src/wram.s index 4bbb29e..70941ba 100644 --- a/src/wram.s +++ b/src/wram.s @@ -108,6 +108,10 @@ update_tile_ptr: .adv 2 render_buffer: .adv RENDER_BUF_TILES minimap_buffer: .adv 9 + ; TODO: refactor map draw to not use + ; these tmps or tile_near far etc + ; it should just use tile_direction_vector + ; to read tiles ahead tmp_map_forward: .adv 1 tmp_map_near_left_door: .adv 1 tmp_map_near_right_door: .adv 1 @@ -116,6 +120,7 @@ tmp_map_far_right_door: .adv 1 tmp_map_furthest_left_door: .adv 1 tmp_map_furthest_right_door: .adv 1 + ; tmeporary actor position backup tmp_act_y: .adv 1 tmp_act_x: .adv 1 @@ -125,5 +130,16 @@ tile_near: .adv 2 tile_far: .adv 2 tile_furthest: .adv 2 + ; current tile direction vector + ; y and x direction for player + ; this can be used to get all tiles ahead + ; by moving in the direction + ; mainly used for player attack direction and + ; rendering the first person view +tile_dir_vector_forward: .adv 2 +tile_dir_vector_back: .adv 2 +tile_dir_vector_left: .adv 2 +tile_dir_vector_right: .adv 2 + ; combat data combat: .adv combat_size