This of course broke various components
; $2: register containing scroll
; a: tile position
#macro tile_to_scrn
- mul16 a
add a, $1
sub a, $2
#endmacro
call ui_request_redraw
ret
+
+ ; same as map_get_tile
+ ; but also divides the b/c input by 16
+map_get_tile_div16:
+ div16 b
+ div16 c
; gets the tile at a y/x position
; inputs:
; write y and x positions
ld a, b
+ mul16 a
ld [hl+], a
ld a, c
+ mul16 a
ld [hl], a
pop_all
ld de, act_pos_y
add hl, de
ld a, b
+ mul16 a
ld [hl+], a ; write y
ld a, c
+ mul16 a
ld [hl], a ; write x
ld de, player_unit
; first read the current tile
call unit_get_pos
- call map_get_tile
+ call map_get_tile_div16
push af ; store for later use
; a = tile flags
ld c, a
xor a, a
ld [hl], a ; clear cf
- call map_get_tile
+ call map_get_tile_div16
pop de
; schedule animation
ld a, [hl] ; hl = x pos
ld c, a ; c = x pos
- call map_get_tile
+ call map_get_tile_div16
; a = flags
ld b, a ; b = flags for later use
and a, CF_EXIT
push bc
push hl ; save hl = rt cf value
- call map_get_tile
+ call map_get_tile_div16
; set flags result
pop hl
ld [hl], a ; store last cf
pop de
ret z
- dec a
+ sub a, 16
ld [hl], a
call play_walk_noise
cp a, MAP_H - 1 ; lower bound
ret z
- inc a
+ add a, 16
ld [hl], a
call play_walk_noise
cp a, 0 ; left bound
ret z
- dec a
+ sub a, 16
ld [hl], a
call play_walk_noise
cp a, MAP_W - 1 ; right bound
ret z
- inc a
+ add a, 16
ld [hl], a
call play_walk_noise
; y position scroll
ld a, [hl+]
+ div16 a
; max y
cp a, 0x0E
; x position scroll
ld a, [hl]
+ div16 a
; max x
cp a, 0x0B