diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-01 22:29:48 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-03-01 22:30:08 +0100 |
| commit | 2170ffa5346667c0f20b388d58a30d204c7bce47 (patch) | |
| tree | 33cb9ed8a770f77ecd881607eb19ac52f50bf1fd | |
| parent | 86c919b3de3ae993eae4334ff9f1e06b550d575f (diff) | |
| download | jetpac.nes-2170ffa5346667c0f20b388d58a30d204c7bce47.tar.gz jetpac.nes-2170ffa5346667c0f20b388d58a30d204c7bce47.zip | |
Allow the 'basic' algorithm to go up or down
This is in preparation to the 'homing' algorithm to re-use this one.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
| -rw-r--r-- | .nasm/segments.txt | 2 | ||||
| -rw-r--r-- | src/enemies.s | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/.nasm/segments.txt b/.nasm/segments.txt index 91d9ea5..c89718c 100644 --- a/.nasm/segments.txt +++ b/.nasm/segments.txt @@ -1,4 +1,4 @@ - HEADER: 16/16 (100%) -- ROM0: 5235/32762 (15.98%) +- ROM0: 5245/32762 (16.01%) - ROMV: 6/6 (100%) - ROM2: 8192/8192 (100%) diff --git a/src/enemies.s b/src/enemies.s index 07578b7..25f041b 100644 --- a/src/enemies.s +++ b/src/enemies.s @@ -439,7 +439,7 @@ ;; ;; |TTTT KK-D|; where: ;; | - ;; |- D: downwards if 1; upwards if 0 (just like the 'diagonal' algorithm). + ;; |- D: downwards if 1; upwards if 0. ;; |- K: movement kind (see the constants FALLING_VELOCITY_*). ;; |- T: timer. Whenever it reaches zero, then a vertical movement is done. ;; @@ -471,10 +471,17 @@ and #$F0 bne @update_extra_state - ;; Move downwards and reset the 'extra' state depending on the enemy - ;; kind. + ;; Move upwards/downwards and reset the 'extra' state depending on the + ;; enemy kind. + tya + and #$01 + beq @up inc Enemies::zp_enemies_pool_base + 1, x + jmp @compute_next_counter + @up: + dec Enemies::zp_enemies_pool_base + 1, x + @compute_next_counter: ;; Yes, doing an index on a pre-computed ROM table would've been faster, ;; but I need the 'x' register and I didn't feel like doing funny ;; dances when it's not so bad. @@ -716,7 +723,7 @@ ;; ;; |TTTT -AAD|; where: ;; | - ;; |- D: downwards if 1; upwards if 0 (just like the 'diagonal' algorithm). + ;; |- D: downwards if 1; upwards if 0. ;; |- AA: current algorithm: 00/11: stop; 01: horizontal; 10: diagonal. ;; |- T: timer for algorithm. Whenever it reaches zero the algorithm is changed. ;; @@ -870,7 +877,7 @@ ;; ;; |TTTT ttSD|; where: ;; | - ;; |- D: downwards if 1; upwards if 0 (just like the 'diagonal' algorithm). + ;; |- D: downwards if 1; upwards if 0. ;; |- S: state: 0: moving up/down; 01: homing. ;; |- tt: number of times TT has run out. When it reaches '11', then we ;; | change from the zero state to homing. |
