From: Lukas Krickl Date: Wed, 2 Oct 2024 16:12:12 +0000 (+0200) Subject: Added test player movement X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=aa200d9c81ad42337dbd17e3b02f3874b2711833;p=gbrg%2F.git Added test player movement --- diff --git a/src/player.s b/src/player.s index ac4d0b9..b89e7d0 100644 --- a/src/player.s +++ b/src/player.s @@ -13,25 +13,56 @@ 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