From 2a9dba45c2219757dccb249737d504b922f4451e Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 10 May 2023 12:18:27 +0100 Subject: Add frame support, updated sprite --- game/entities.asm | 54 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) (limited to 'game/entities.asm') diff --git a/game/entities.asm b/game/entities.asm index fd79825..6116624 100644 --- a/game/entities.asm +++ b/game/entities.asm @@ -63,7 +63,7 @@ entities_erase_next: port b, y ; next entity - add x, 5 + add x, 6 bo inc a @@ -90,7 +90,7 @@ entities_update_next: push a push x - add x, 5 + add x, 6 bo inc a @@ -117,7 +117,7 @@ entities_update_next: pop a ; next entity - add x, 7 + add x, 8 bo inc a @@ -137,6 +137,8 @@ entities_draw_next: bz jmp entities_draw_done + ; two local variables to keep x, y coord + inc x bo inc a @@ -154,9 +156,9 @@ entities_draw_next: inc x bo inc a - ; a : x points to sprite data + ; a : x points to the frame - ; get gb data + ; save bg data ; settings mode ld y, 128 @@ -201,15 +203,53 @@ entities_draw_next: ; setup inc b - ; addr: sprite data + ; prepare some local variables + + ; frame ld y, [a : x] - port b, y + inc x + bo + inc a + push y + + ; sprite addr + ld y, [a : x] + push y inc x bo inc a ld y, [a : x] + push y + + ; frame number + ld b, [sp + 2] +entity_draw_frame: + dec b + bo + jmp entity_draw_frame_done + + ; calculate frame + ld y, [sp + 0] + inc y + ld [sp + 0], y + jmp entity_draw_frame + +entity_draw_frame_done: + + ; settings port + ld b, 0xb1 + + ; addr: sprite data + ld y, [sp + 1] + port b, y + ld y, [sp + 0] port b, y + ; free local variables + pop y + pop y + pop y + ; x ld y, [sp + 1] port b, y -- cgit v1.2.3