ld [hl+], a
- ret
-
- ; debug draws a tile based on player position
- ; inputs:
- ; $1: y offset
- ; $2: x offset
- ; hl: oam ptr
- ; returns:
- ; hl: next oam ptr
-#macro debug_draw_tile
- ld de, player+act_pos_y
- ld a, [de]
- inc de
- add a, $1 & 0xFF
-
- ld b, a ; b = y
- ld a, [de]
- add a, $2 & 0xFF
- ld c, a ; c = x
-
- push hl
- call map_get_tile
- push hl
- pop de ; de = tile
- inc de ; de = tile flags
-
- pop hl ; hl = oam
-
- ; y pos
- ld a, 136 + $1 * 8
- ld [hl+], a
-
- ; x pos
- ld a, 136 + $2 * 8
- ld [hl+], a
-
- ; tile
- ld a, [de]
- add a, 0x60 ; tile offset for debug tiles
- ld [hl+], a
-
- ; flags
- xor a, a
- ld [hl+], a
-
-#endmacro
-
- ; draws the tiles around the player
- ; only draws the exit flags
-debug_draw_map:
- ld a, 9
- call oamalloc
-
- debug_draw_tile -1, 0
- debug_draw_tile 0, 0
- debug_draw_tile 1, 0
-
- debug_draw_tile 0, -1
- debug_draw_tile 0, 1
-
- debug_draw_tile 1, 1
- debug_draw_tile -1, 1
-
- debug_draw_tile -1, -1
- debug_draw_tile 1, -1
-
ret
#define UI_TILE_NAME SCRN1+33
-#define TILE_SOUTH 0xEC
-#define TILE_NORTH 0xE7
-#define TILE_EAST 0xDE
-#define TILE_WEST 0xF0
+#define TILE_SOUTH 0xF9
+#define TILE_NORTH 0xFA
+#define TILE_EAST 0xFC
+#define TILE_WEST 0xFB
; one tile after 'Z'
#define UI_WINDOW_BACKGROUND 0xF4
-
; draws the entire UI
; only call during blank
ui_draw:
+
+ ; draw minimap to ui
+ ld hl, SCRN1 + 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:
ld [hl+], a
; x
- ld a, 64
+ ld a, 138
ld [hl+], a
; tile
#ifdef DEBUG_UI
call debug_draw_player_pos
- call debug_draw_map
#endif
ret