Algorithm for Jetpac's lasers

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
dfzx
Manic Miner
Posts: 676
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Algorithm for Jetpac's lasers

Post by dfzx »

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?
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.
User avatar
Morkin
Bugaboo
Posts: 3261
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Algorithm for Jetpac's lasers

Post by Morkin »

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..(!)
My Speccy site: thirdharmoniser.com
Nomad
Manic Miner
Posts: 600
Joined: Thu Dec 28, 2017 12:38 pm

Re: Algorithm for Jetpac's lasers

Post by Nomad »

My google-fu might not be up to scratch - I can't find a disassembly.
dfzx
Manic Miner
Posts: 676
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Algorithm for Jetpac's lasers

Post by dfzx »

Nomad wrote: Wed Apr 04, 2018 11:29 am My google-fu might not be up to scratch - I can't find a disassembly.
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.
User avatar
Joefish
Rick Dangerous
Posts: 2048
Joined: Tue Nov 14, 2017 10:26 am

Re: Algorithm for Jetpac's lasers

Post by Joefish »

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?
User avatar
Joefish
Rick Dangerous
Posts: 2048
Joined: Tue Nov 14, 2017 10:26 am

Re: Algorithm for Jetpac's lasers

Post by Joefish »

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.
Post Reply