#define UI_TILE_WIDTH 32
#define UI_TILE_HEIGHT 4
-
+
+ ; player position offset to get center of tile
+#define PLAYER_TILE_OFFSET 8
#define MAP_W 16
#define MAP_H 16
#define MAP_TILES (MAP_W * MAP_H)
call ui_draw_all
ret
+ ; updates UI
+ ; checks if a UI draw is required
+ ; usually this occurs when
+ ; the player cursor enters a new tile
+ui_update:
+ ; check y
+ ld a, [ui_prev_tile_y]
+ ld b, a
+ ld a, [player+act_pos_y]
+ add a, PLAYER_TILE_OFFSET
+ div16 a
+ ld [ui_prev_tile_y], a
+ cp a, b ; are they differnet?
+ jr nz, @draw_new REL
+
+ ; check x
+ ld a, [ui_prev_tile_x]
+ ld b, a
+ ld a, [player+act_pos_x]
+ add a, PLAYER_TILE_OFFSET
+ div16 a
+ ld [ui_prev_tile_x], a
+ cp a, b ; ar they dfifernet?
+ ret z ; no need to proceed
+
+@draw_new:
+
+ call ui_request_draw
+ ret
+
+ ; requests a draw
+ ; for UI information about the current tile
+ui_request_draw:
+ ret
+
; draws the entire UI
; only call during blank
ui_draw_all: