diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-10 12:18:27 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-10 12:18:27 +0100 |
commit | 2a9dba45c2219757dccb249737d504b922f4451e (patch) | |
tree | 9780e6e70ef5b6b7ac8aec5869b9679810024c03 | |
parent | c1e83a23774fff30a257466e19b1237b3b78b055 (diff) | |
download | tr8vm-2a9dba45c2219757dccb249737d504b922f4451e.tar.gz tr8vm-2a9dba45c2219757dccb249737d504b922f4451e.zip |
Add frame support, updated sprite
-rw-r--r-- | game/assets/player.png | bin | 7775 -> 12406 bytes | |||
-rw-r--r-- | game/entities.asm | 54 | ||||
-rw-r--r-- | game/main.asm | 2 | ||||
-rw-r--r-- | game/player.asm | 26 |
4 files changed, 74 insertions, 8 deletions
diff --git a/game/assets/player.png b/game/assets/player.png Binary files differindex 13b7242..2e10235 100644 --- a/game/assets/player.png +++ b/game/assets/player.png 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 diff --git a/game/main.asm b/game/main.asm index 3062ead..68d1267 100644 --- a/game/main.asm +++ b/game/main.asm @@ -63,6 +63,8 @@ entities: .db ET_PLAYER ; x, y .db 0, 0 + ; frame + .db 0 .dw player_sprite .dw player_update diff --git a/game/player.asm b/game/player.asm index 4a6537f..0e44411 100644 --- a/game/player.asm +++ b/game/player.asm @@ -44,5 +44,29 @@ player_update: ld [a : x], y - ret + ; update frame + inc x + bo + inc a + + ; base frame + ld y, 0 + + ; both left and right + and b, 48 + cmp b, 48 + bz + jmp player_store_frame + + ; left + bit b, 4 + bz + ld y, 2 + ; right + bit b, 5 + bz + ld y, 1 +player_store_frame: + ld [a : x], y + ret |