aboutsummaryrefslogtreecommitdiff
path: root/src/enemies.s
Commit message (Collapse)AuthorAgeFilesLines
* Try to initialize enemies on unique Y coordinatesMiquel Sabaté Solà2026-03-221-1/+1
| | | | | | | | | | | | That is, our PRNG algorithm is so stupid that sometimes it cycles into the same value multiple times. While play testing, sometimes we were so unlucky that we got all enemies on the same Y screen coordinate. As funny as these situations can be, this shouldn't happen, so I have introduced an (awesomely named) function that makes a harder effort at finding a unique random number. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Rename init_x() to init_enemy_x()Miquel Sabaté Solà2026-03-111-4/+4
| | | | | | | This is just a minor fix for an overstep from commit 270d60d58d3e ("Rename scoped variables without being redundant"). Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Apply a correction on enemy movement for PALMiquel Sabaté Solà2026-03-111-42/+80
| | | | | | | | | | We cannot just "inc"/"dec" for enemy movement, but we have to apply an overstep on PAL every 5 frames in order to be equivalent to the NTSC version. This has been abstracted away on a macro that just does "inc"/"dec" on NTSC, but does this proper "adc"/"sbc" instructions with a helper memory region which is updated every 5 frames. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Move some variables into another memory regionMiquel Sabaté Solà2026-03-071-5/+5
| | | | | | | | The zp_player_tile_* variables fit perfectly with the space that is left in the $0x memory region. This allows for a more contiguous space (e.g. on $Cx) for other elements to come (e.g. items). Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Ramp up the revive counter for enemiesMiquel Sabaté Solà2026-03-071-1/+1
| | | | | | | This way it feels more like a swarm of enemies and you don't have any resting time. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix documentation error on the 'chase' algorithmMiquel Sabaté Solà2026-03-071-1/+1
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Bump up to 4 enemies per screenMiquel Sabaté Solà2026-03-061-6/+6
| | | | | | | | This is more similar to the original game, and it's a bit more fun. In order to do so some variables had to move into another memory page, but that's fine as we have plenty. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Make more things operate on SIZEOF_POOL_ITEMMiquel Sabaté Solà2026-03-061-8/+8
| | | | | | | Out of consistency, let's use it, and this way experimenting with the amount of enemies per screen won't be as painful. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Convert enemy vs bullet collision into a loopMiquel Sabaté Solà2026-03-061-6/+4
| | | | | | | | The fact that unrolling the loop was easier or faster was a plain lie from my lazyness. Convert it into a proper loop just so we can experiment with adding more enemies in one screen. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix bounce up for cross enemiesMiquel Sabaté Solà2026-03-061-11/+1
| | | | | | | | | Some old code was checking on the kind of level and skipping the bottom check if it was a half-sized enemy. However, the 'bounce' algorithm is not used by any half-sized enemy. Thus, the check can be removed entirely. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Rename scoped variables without being redundantMiquel Sabaté Solà2026-03-061-134/+134
| | | | | | | Some variables had the same name of the scope in their names as well. Remove this redundancy everywhere. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Check for enemy death after its movementMiquel Sabaté Solà2026-03-061-0/+9
| | | | | | | | | Some enemies might die right after moving (e.g. asteroids exploding into the ground). In these cases, there's no point on checking for player collision. Moreover, this also avoids the corner case of having two explosions on a single death. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Small savings on re-using untouched registersMiquel Sabaté Solà2026-03-061-8/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Improve documentation on Enemies::zp_current_tilesMiquel Sabaté Solà2026-03-061-10/+17
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix a cycling bug when shooting carelesslyMiquel Sabaté Solà2026-03-061-0/+13
| | | | | | | | | | | | | | | | When shooting like crazy and killing random enemies, after a while a cycling bug would appear which would make enemies to turn in weird directions, die unexpectedly, and other weird shenanigans. This comes back to commit 7c493ba3f338 ("Improve a bit the performance on enemy death"), which removed the saving/restoring of the value on the 'y' register. That being said, this register was actually being needed at least by Bullets::update(), so in certain situations this register might have a bad value (e.g. via the Explosions::create() call). Fixes: 7c493ba3f338 ("Improve a bit the performance on enemy death") Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Remove the pool size from enemiesMiquel Sabaté Solà2026-03-051-13/+0
| | | | | | It was never read anyways, so let's drop it. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Make enemies more colorfulMiquel Sabaté Solà2026-03-051-10/+40
| | | | | | | Each enemy also has its own palette upon creation. This way we add more variety as it was on the original game. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Improve a bit the performance on enemy deathMiquel Sabaté Solà2026-03-051-8/+2
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Don't be too tight on the player's feet for collisionMiquel Sabaté Solà2026-03-051-3/+6
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add collision with the playerMiquel Sabaté Solà2026-03-041-3/+105
| | | | | | | This allows for explosions to run after making the player to disappear, and it re-runs the entering scene timer. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Let enemies die whenever they touch a bulletMiquel Sabaté Solà2026-03-031-1/+84
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add a pool of explosion effectsMiquel Sabaté Solà2026-03-031-3/+22
| | | | | | | For now this only applies to enemies, but it's general enough so it can target any given coordinate, and hence any given object. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Allow enemies to revive after a given timeMiquel Sabaté Solà2026-03-031-18/+32
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Move enemy initialization into its own functionMiquel Sabaté Solà2026-03-021-3/+16
| | | | | | This will be useful whenever we implement the re-appearance of enemies. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Implement de 'chase' algorithmMiquel Sabaté Solà2026-03-021-36/+246
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Improve some comments in enemies.sMiquel Sabaté Solà2026-03-021-4/+4
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Check for all corners on the 'basic' algorithmMiquel Sabaté Solà2026-03-011-17/+25
| | | | | | | | | | There were still some gaps where the check was failing, and trying to be smart about it was going the "it's too complex for what I need here" route. Hence, just go to the good old dumb algorithm of "check all corners". For now the performance has not dropped, so let's hope that we don't have to re-visit this one. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix bottom collision for fighter jet 1sMiquel Sabaté Solà2026-03-011-2/+9
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Finish up the 'homing' algorithmMiquel Sabaté Solà2026-03-011-15/+21
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Allow the 'basic' algorithm to go up or downMiquel Sabaté Solà2026-03-011-5/+12
| | | | | | This is in preparation to the 'homing' algorithm to re-use this one. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Remove the usage to zp_enemy_arg in most placesMiquel Sabaté Solà2026-02-281-73/+30
| | | | | | | | | | | | | | Everywhere except the 'basic' algorithm don't really need this argument. In the beginning I was using it to define some custom velocities, but in the end tweaking the inner timer on the 'extra' value for all enemies turned out to be more productive. Hence, remove this usage almost everywhere and make the code simpler as a side-effect. The usage on 'basic' is still under revision, just to check if 'homing' really needs to set a special argument whenever the 'homing' attack needs this sort of behavior. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Move the 'extra' initialization to a functionMiquel Sabaté Solà2026-02-281-51/+53
| | | | | | | | This allows us to be able to initialize each enemy separately, giving a more random appearance to it all. This will also come in handy whenever we want to make enemies re-appear. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Make 'basic' more true to the original gameMiquel Sabaté Solà2026-02-271-22/+44
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Initial implementation for the homing algorithmMiquel Sabaté Solà2026-02-271-2/+119
| | | | | | | Not the whole thing has been implemented, as it needs a rebump on the 'basic' algorithm so I can re-use it for 'homing' as well. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Set the enemy pool size on 'init_pool' loop's initMiquel Sabaté Solà2026-02-131-4/+3
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Implement the 'erratic' algorithm for enemiesMiquel Sabaté Solà2026-02-131-4/+173
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Fix sprites and waves for fighter jetsMiquel Sabaté Solà2026-02-121-6/+6
| | | | | | | I apparently got them all messed up. Let's put them as they were originally. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Implement the 'bounce' algorithm for enemiesMiquel Sabaté Solà2026-02-121-7/+202
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Initial iteration of enemy movementMiquel Sabaté Solà2026-02-121-33/+317
| | | | | | | For now only the basic algorithm has been written, but the framework for adding the rest has also been written down. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Improve the "other" states from fighter jetsMiquel Sabaté Solà2026-02-101-4/+4
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Allocate all enemies on sprite cyclingMiquel Sabaté Solà2026-02-101-0/+6
| | | | | | | The previous commit only tackled the first enemy, this one handles the "rest_o_enemies" code flow, which was entirely missing. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* enemies: add inner movement and facing logicMiquel Sabaté Solà2026-02-101-18/+231
| | | | | | | | | Enemies now have the ability to be displayed on screen, face at the direction that they were assigned to at random during initialization time, and they also have a timer that dictates some inner movement, similarly as it happened in the original game. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Add missing enemy tile definitionsMiquel Sabaté Solà2026-02-031-4/+36
| | | | Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Adapt the code to play well with nasm's asanMiquel Sabaté Solà2025-12-151-1/+1
| | | | | | | The address sanitizer from nasm provides quite a few goodies, so let's adapt the code more to it to benefit from those. Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
* Initialize enemies at a random Y coordinateMiquel Sabaté Solà2025-05-161-1/+3
| | | | | | | | | The randomness comes from a pre-computed table of "random" numbers. This is of course the most simple technique you can come across a code base for the NES/Famicom, but for the purposes of this game is good enough and (most importantly) fast. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
* Add the skeleton code for enemiesMiquel Sabaté Solà2025-05-151-0/+58
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>