what is a raster interrupt and how do i code one?

2

jpospTynker 2025-07-18 21:51 (Edited)

read title. also, how do i stop sprites and cells from wrapping around from the top when they get too far off the screen.


was8bit 2025-07-18 21:57 (Edited)

Go here...

https://lowresnx.inutilis.com/topic.php?id=3737

And pay attention how sprite coordinates differ from cell image coordinates...

.... then simply read a sprites coordinates as it move, and restrain how far it goes


was8bit 2025-07-18 21:58

Raster interupt is something totally different...


wryhode 2025-07-18 21:59 (Edited)

Raster interrupts are SO neat and useful! To use them here is also very simple:


  1. Define a SUB that takes a single argument (RASTER). E.g. SUB RASTERFX(RASTER). The RASTER argument will be the line number of the screen that is about to be drawn. (0 - 127)
  2. Write whatever code you want to run for each line as it gets drawn to the screen. One drawback is that they have to be very small (<54 cycles iirc). For example, you can make the background wavy with: SCROLL 0, SIN(RASTER / 40) * 8, 0
  3. For the raster sub to be executed, you need to 'register' it with: ON RASTER CALL {name of your SUB}
  4. Profit!!


wryhode 2025-07-18 22:04 (Edited)

Sprites overflow because their position is stored as a byte, which wraps to 0 when over 255. You can prevent this in code by checking if the coordinate the sprite is getting drawn to is within the screen coordinates.

yeah, or listen to was8bit!


Log in to reply.