# Known Bugs
- When moving a player sometimes gains an extra pixel
+- When loading a map sometimes a double load is caused
- When moving off-screen NORTH the movement behaves weird
- Map loads can occur when the player is moving off a door tile
ld e, a ; d = player x
div16 e ; d = player x tile
+ dec hl ; hl = player_y
+
; compare to expected positions to decide what to do
- ; 0/0 == north
xor a, a ; a = 0
- ; player_y (d) == 0
+ ; player_y (d) == 0 (NORTH)
cp a, d
jr nz, @not_north REL
+ ; set new player position
+ ld a, 0x60
+ ld [hl], a ; player_y = 0x60 after going NORTH
+
; load north as direction
ld a, NORTH
jp room_goto
@not_north:
+ ; player_x (e) == 0 (WEST)
+ cp a, e
+ jr nz, @not_west REL
+
+ ld a, 0x80
+ inc hl ; hl = player_x
+ ld [hl], a ; player_x = 0x80 after going WEST
+
+ ; load WEST as direction
+ ld a, WEST
+ jp room_goto
+@not_west:
+
+ ld a, 9 ; tile 9 == EAST
+ ; player_x (e) == 9 (EAST)
+ cp a, e
+ jr nz, @not_east REL
+
+ ld a, 0x10
+ inc hl ; hl = player_x
+ ld [hl], a ; player_x = 0x10 after going EAST
+
+ ; load EAST as direction
+ ld a, EAST
+ jp room_goto
+@not_east:
+
+ ld a, 7 ; tile 7 == SOUTH
+ ; player_y (d_ == 7 (SOUTH)
+ cp a, d
+ jr nz, @not_south REL
+
+ ld a, 0x10
+ ld [hl], a ; player_y = 0x10 after going SOUTH
+
+ ; load SOUTH as direction
+ ld a, SOUTH
+ jp room_goto
+@not_south:
+
; default use special exit
ld a, EXIT_SPECIAL
; no need to jmp in default case