player_update:
; update
+ ; d: player_y
+ ; e: player_x
+
; input handling
input_held BTNDOWN
jr z, @notdown REL
-
- ld de, player_y
- add hl, de
+
+ ; hl = player_y
ld a, [hl]
inc a
ld [hl], a
@notdown:
+
+ input_held BTNUP
+ jr z, @notup REL
+
+ ; hl = player_y
+ ld a, [hl]
+ dec a
+ ld [hl], a
+@notup:
+
+ ; store y in d
+ ; and inc hl
+ ld a, [hl+]
+ ld d, a
+
+ input_held BTNLEFT
+ jr z, @notleft REL
+
+ ; hl = player_x
+ ld a, [hl]
+ dec a
+ ld [hl], a
+@notleft:
+
+ input_held BTNRIGHT
+ jr z, @notright REL
+ ; hl = player_x
+ ld a, [hl]
+ inc a
+ ld [hl], a
+@notright:
+
; drawing
- ; d: player_y
- ; e: player_x
- ld a, [hl+]
- ld d, a
- ld a, [hl+]
+ ; sotre x in e
+ ld a, [hl]
ld e, a
; obj 1