From d1c70c8118e53f28bc2cfe3de64f7c30762c8b33 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 10 May 2023 08:01:48 +0100 Subject: Removed subroutine as it is more readable like this --- game/entities.asm | 190 +++++++++++++++++++++++++----------------------------- 1 file changed, 87 insertions(+), 103 deletions(-) (limited to 'game/entities.asm') diff --git a/game/entities.asm b/game/entities.asm index fa9d8fd..aaab135 100644 --- a/game/entities.asm +++ b/game/entities.asm @@ -23,37 +23,44 @@ entities_erase_next: bz jmp entities_erase_done - ; write, no transparent - ld y, 1 - push y + ; settings mode + ld y, 128 + ld b, 0xb0 + port b, y + + ; setup + inc b - ; dst: x + ; addr: bg data + ld y, 0 + port b, y + ld y, [sp + 0] + port b, y + + ; x inc x bo inc a ld y, [a : x] - push y + port b, y - ; dst: y + ; y inc x bo inc a ld y, [a : x] - push y - - ; src: saved bg - ld y, [sp + 3] - push y - ld y, 0 - push y + port b, y - call entities_blt + ; 16x16 + ld y, 16 + port b, y + port b, y - pop y - pop y - pop y - pop y - pop y + ; blit + dec b + ; write, no transparent + ld y, 1 + port b, y ; next entity add x, 5 @@ -132,102 +139,59 @@ entities_draw_next: inc x bo inc a - ; save x addr for later - push a - push x - - ; save bg - - ; read, no transparent - ld y, 4 - push y - - ; dst: x ld y, [a : x] + ; x coord push y - ; dst: y inc x bo inc a ld y, [a : x] + ; y coord push y - ; dst: save bg - ld y, [sp + 5] - push y - ld y, 0 - push y - - call entities_blt - - pop y - pop y - pop y - pop y - pop y - - ; draw sprite - - ; x addr - pop x - pop a - - ; write, transparent - ld y, 3 - push y - - ; dst: x - ld y, [a : x] - push y - - ; dst: y inc x bo inc a - ld y, [a : x] - push y + ; a : x points to sprite data - ; src: the sprite - inc x - bo - inc a - ld y, [a : x] - inc x - bo - inc a - ld b, [a : x] - push b - push y + ; get gb data - call entities_blt + ; settings mode + ld y, 128 + ld b, 0xb0 + port b, y - pop y - pop y - pop y - pop y - pop y + ; setup + inc b - ; next entity - add x, 3 - bo - inc a + ; addr: bg data saving space + ld y, 0 + port b, y + ld y, [sp + 2] + port b, y - pop b - inc b - push b + ; x + ld y, [sp + 1] + port b, y - jmp entities_draw_next + ; y + ld y, [sp + 0] + port b, y -entities_draw_done: - pop a - ret + ; 16x16 + ld y, 16 + port b, y + port b, y + + ; blit + dec b + ; read, no transparent + ld y, 4 + port b, y + + ; draw sprite -; sp: write mode -; y coord -; x coord -; addr -entities_blt: ; settings mode ld y, 128 ld b, 0xb0 @@ -236,17 +200,21 @@ entities_blt: ; setup inc b - ; addr - ld y, [sp + 2] + ; addr: sprite data + ld y, [a : x] port b, y - ld y, [sp + 3] + inc x + bo + inc a + ld y, [a : x] port b, y ; x - ld y, [sp + 5] + ld y, [sp + 1] port b, y + ; y - ld y, [sp + 4] + ld y, [sp + 0] port b, y ; 16x16 @@ -256,8 +224,24 @@ entities_blt: ; blit dec b - ; write mode - ld y, [sp + 6] + ; writw, transparent + ld y, 3 port b, y - ret + pop y + pop y + + ; next entity + add x, 3 + bo + inc a + + pop b + inc b + push b + + jmp entities_draw_next + +entities_draw_done: + pop a + ret -- cgit v1.2.3