I've always liked the effect used to draw the laser firing in Jetpac. I started wondering how it was done, so I slowed the game down in an emulator and tried to work it out.
As far as I can tell, it's a line drawn partly as a solid line, partly with long dashes, and partly with smaller dashes. The line is drawn a bit longer for each frame, up to a maximum length. Once the line drawing has started, it's completed in that place regardless of whether the player moves or not. I'm not quite sure what happens when you hold the fire key down and several lines are drawn together. It's not easy to see what's going on.
I'd quite like to reproduce the effect but I'm not really sure where to start. Can anyone give me any pointers? And would it be possible, do you think, to make it omnidirectional, as opposed to simply horizontal?
Algorithm for Jetpac's lasers
Algorithm for Jetpac's lasers
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Re: Algorithm for Jetpac's lasers
I remember wondering this very same thing a while back.
It's a pretty cool firing sequence, seems so advanced compared to the single-shot-moving-across-the-screen that you'd expect from a lot of arcade games of its time.
Has anyone disassembled Jetpac? I'd be surprised if they hadn't..(!)
It's a pretty cool firing sequence, seems so advanced compared to the single-shot-moving-across-the-screen that you'd expect from a lot of arcade games of its time.
Has anyone disassembled Jetpac? I'd be surprised if they hadn't..(!)
My Speccy site: thirdharmoniser.com
Re: Algorithm for Jetpac's lasers
My google-fu might not be up to scratch - I can't find a disassembly.
Re: Algorithm for Jetpac's lasers
s'ok, I doubt I'd understand it.
The graphical sequence looks like the sort of thing that should be expressible in BASIC, but I can't quite get my head around where to start with it.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Re: Algorithm for Jetpac's lasers
I wonder if it uses three or four moving 'shots', one drawing the solid line and leaving a trail behind it, the next one drawing the long dash and leaving a trail as it goes, then the shorter dash, and finally something printing an empty space to delete everything.
Though it could be re-drawing the whole thing every time with just a counter to indicate how much of it is which pattern.
It's able to stop short when it hits something. It also doesn't seem to have any XOR effects of disappearing when it overlaps an explosion. If it was XORed, one laser would be constantly deleting another anyway.
Anyone know how the sprites are drawn and deleted in JetPac?
Though it could be re-drawing the whole thing every time with just a counter to indicate how much of it is which pattern.
It's able to stop short when it hits something. It also doesn't seem to have any XOR effects of disappearing when it overlaps an explosion. If it was XORed, one laser would be constantly deleting another anyway.
Anyone know how the sprites are drawn and deleted in JetPac?
Re: Algorithm for Jetpac's lasers
Looking closely at some screenshot's, it's very peculiar - a good featured disassembly might be interesting.
My guess is it ORs a sprites onto the screen, then ANDs the inverse of the sprite up to delete it, then ORs it into its new position. Rather than XOR to draw and XOR to erase.
My guess is it ORs a sprites onto the screen, then ANDs the inverse of the sprite up to delete it, then ORs it into its new position. Rather than XOR to draw and XOR to erase.