CPCWiki forum

General Category => Programming => Topic started by: Carnivius on 16:29, 04 October 15

Title: pixel effects.
Post by: Carnivius on 16:29, 04 October 15
In some games such as Beyond the Ice Palace there are effects where a lot of coloured pixels appear when something happens (in that game's case when enemies are killed), I just wondered what is going on there because I would have assumed if they were sprites it would slow down a lot but the game maintains a fairly steady speed even with scrolling.  So what is going on?
Title: Re: pixel effects.
Post by: MacDeath on 16:41, 04 October 15

they explode in colourfull particles.

this was sometimes used for games.




can't really tell how it is done exactly.

actually many impressive games used this technique.
a common pattern between the 3 games : all coded by David Perry. I guess it was his stuff, he probably reused code.

Trantor and Savage sometimes feel like sharing the same "engine".
must be some kind of starfield or particle effect.

CPC-POWER, sauvegarde du patrimoine de l'Amstrad CPC (http://www.cpc-power.com/index.php?page=staff&lenom=David%20PERRY)

David Perry did great CPC games in nice Mode0 with a lot of "particle effects" indeed.
Title: Re: pixel effects.
Post by: arnoldemu on 16:43, 04 October 15
I am guessing here because I haven't looked at the code, but my guess is based on how I would do it.

For drawing a sprite this involves:
1. conversion of x,y coordinates to screen memory address
2. clipping the sprite so only the visible rectangle is on the screen (applies if sprite is partially hidden by the border or a panel)
3. reading from screen, masking, applying sprite pixels and writing back to screen for each byte
4. when we get to the end of the line calculate the memory address for the next line down the screen.

For drawing pixels:
1. you could convert x,y to screen memory address
2. clip pixel - of screen means to skip 3.
3. you then draw the pixel

There is much less work for drawing the pixels. And things like clipping are much quicker. drawing the pixel is much quicker too. if the background is a single colour you can OR it to the screen (avoiding a read of the screen, mask, combine and writing back). You can also avoid calculating screen address. You could store the path as a sequence or memory addresses which you add to the start position.

Title: Re: pixel effects.
Post by: Axelay on 17:14, 04 October 15
Something else which would help with the CPU time in those David Perry games is that only one pixel explosion is ever in play at once.  If a new one begins, any existing one is ended prematurely.
Title: Re: pixel effects.
Post by: ||C|-|E|| on 21:06, 04 October 15
I always found David Perry games exceptional form the technical point of view and I am curious about the technique as well.
Title: Re: pixel effects.
Post by: McKlain on 21:47, 04 October 15
Another one of his games with particles:

Title: Re: pixel effects.
Post by: TFM on 21:52, 04 October 15
Quote from: Carnivac on 16:29, 04 October 15
In some games such as Beyond the Ice Palace there are effects where a lot of coloured pixels appear when something happens (in that game's case when enemies are killed), I just wondered what is going on there because I would have assumed if they were sprites it would slow down a lot but the game maintains a fairly steady speed even with scrolling.  So what is going on?


These game are NOT spectrum ports.
Title: Re: pixel effects.
Post by: ||C|-|E|| on 21:55, 04 October 15
Another game that has this, although slower (the effect can slow down the action) is Exolon. However, Exolon uses sprites...

Exolon - Amstrad CPC - YouTube (https://www.youtube.com/watch?v=aJs5m-GQpzs)
Title: Re: pixel effects.
Post by: AMSDOS on 22:06, 04 October 15
In "The Eternal Light" there's a pixel explosion effect when the evil black blobs have been shot. "The Eternal Light" is using Sprites Alive, so the effect must essentially be an segment of code that a RSX is pointing to. @Morri (http://www.cpcwiki.eu/forum/index.php?action=profile;u=95) might be able to provide which RSX is being used.
Title: Re: pixel effects.
Post by: Morri on 22:39, 04 October 15
Quote from: AMSDOS on 22:06, 04 October 15
In "The Eternal Light" there's a pixel explosion effect when the evil black blobs have been shot. "The Eternal Light" is using Sprites Alive, so the effect must essentially be an segment of code that a RSX is pointing to. @Morri (http://www.cpcwiki.eu/forum/index.php?action=profile;u=95) might be able to provide which RSX is being used.
Yes, this was a sprites alive feature. The RSX command was |explode. Below is from the manual. I don't think it is as impressive as Dave Perry's games.

|EXPLODE,spr,spot,inc,lim,del
This command will make a sprite explode on the screen. Whilst the explosion is taking place everything on the screen will stop moving until the explosion dies down.
spr is the sprite that is to explode, it must be on the screen.
spot is the number of pixels that are put on the screen before the explosion expands.
inc is the size of the increase of the explosion in pixels.
lim is the maximum size of the explosion in pixels.
del is a delay to slow the explosion down.
Title: Re: pixel effects.
Post by: McKlain on 22:47, 04 October 15
So now we know that David Perry and Rafaelle Cecco knew how to do this  ;D
Title: Re: pixel effects.
Post by: andycadley on 22:50, 04 October 15
If you look at Beyond the Ice Palace closely, the pixels appear to change colour as they pass over the background, which is a sure fire sign they're probably just XOR'd onto the screen. From memory that's also how Sprites Alive did it. That certainly helps to keep the effect cost down, whilst being barely noticeable when there's plenty of action going on and the explosion is multi coloured.
Title: Re: pixel effects.
Post by: ||C|-|E|| on 23:11, 04 October 15
Another one... Cybernoid I and II.

Cybernoid the fighting machine - Amstrad CPC - YouTube (https://www.youtube.com/watch?v=YCZ6km5rNW4)

In Cybernoid it is very impressive. There is even a volcano. Of course, is Rafaelle Cecco again...
Title: Re: pixel effects.
Post by: TFM on 23:17, 04 October 15
A bunch of MODE 0 dots are easy to handle, because to display it you have to write only one byte. Sprites are more complex, one needs to calculate to the next scan line and always keep the end of the V-RAM in mind. Of course one can work around, but still its way more coplex than a pixel storm.


Odiesoft did show that very nicely (in MODE 1 though):

Snowfall on CPC - YouTube (http://youtu.be/VtVYaQuDw5c?t=32)

Title: Re: pixel effects.
Post by: AMSDOS on 23:37, 04 October 15
Quote from: Morri on 22:39, 04 October 15
Yes, this was a sprites alive feature. The RSX command was |explode. Below is from the manual. I don't think it is as impressive as Dave Perry's games.

|EXPLODE,spr,spot,inc,lim,del
This command will make a sprite explode on the screen. Whilst the explosion is taking place everything on the screen will stop moving until the explosion dies down.
spr is the sprite that is to explode, it must be on the screen.
spot is the number of pixels that are put on the screen before the explosion expands.
inc is the size of the increase of the explosion in pixels.
lim is the maximum size of the explosion in pixels.
del is a delay to slow the explosion down.


Yes I must confess I forgot about everything stopping when the explosion takes place. I just thought there's a similar process occurring.


I recall Dizzy exploding in Fast Food when the monsters catch up with them and they don't seem to stop when Dizzy is in explosion sequence, I can only guess some conditional thing is occurring which is letting the rest of the game to function.
Sprites Alive might be using some Loop which is enforced until the condition is reached, rather than doing it one step at a time.
Title: Re: pixel effects.
Post by: andycadley on 08:03, 05 October 15
Quote from: AMSDOS on 23:37, 04 October 15

Yes I must confess I forgot about everything stopping when the explosion takes place. I just thought there's a similar process occurring.


I recall Dizzy exploding in Fast Food when the monsters catch up with them and they don't seem to stop when Dizzy is in explosion sequence, I can only guess some conditional thing is occurring which is letting the rest of the game to function.
Sprites Alive might be using some Loop which is enforced until the condition is reached, rather than doing it one step at a time.

To not stop the entire game, it's just a matter of doing a small amount of movement each game frame. That's not really easy to do with an RSX type approach, short of mucking around with timers and trying to compensate for overlapping explosions, so it's not much of a surprise the command just doesn't stop till the explosion is over. It's a very BASIC way of doing things.
Title: Re: pixel effects.
Post by: robcfg on 10:55, 05 October 15
My 2 cents on the subject:


The colorful explosion is always made of square or rectangular bricks, so my guess is that they were blitting from a random memory area, most probably code or variables.
Title: Re: pixel effects.
Post by: Optimus on 15:44, 05 October 15
Tubaruba also did it.
Title: Re: pixel effects.
Post by: MacDeath on 18:14, 05 October 15
I guess some Shooters/ Defender clones did this as well.

Need to be checked but I suspect David Perry to mostly use byte based mask/things...

DanDare3 is actually "character based" but the "explosion seem to use quarters of characters (4x4 mode1 pixel sized things) which is a clever way to get things running a bit smoother in the Character based engine.

Ninja turtle : some sprites really display some black pixels here and there indicationthey are masked at bytes, not pixels (as for Antiriad's sprites).

Bytes can be addressed so it is better CPU wise than mode0 pixel wise or any real pixel wise thing... good way to cut the way.


Some straight "speccy character" engine such as AMC can get nice result but lack in smoothness.
check attack of Zombi monster as well (nice modern exemple, cross-deved for Z80's MSX/Speccy/CPC).
Or even R-Type, somewhat (still smooth scrolling tiles effect inside the 8x8 grid, for the backgrounds only)

I always think that a pure "quarter character" based game engine is still to be done to see if this would be both fast and smooth on a CPC, or just do-able and valid choice...

Title: Re: pixel effects.
Post by: Carnivius on 12:23, 10 October 15
Thanks people.  Gives me a better idea of what the CPC is capable of. Some folks believe stuff like that is impossible on the 8-bits due to looking like far too many sprites all moving fast at once but it's nice to show them that it is indeed possible and was even back then.


And damn I love Dan Dare 3. Such colourful, bold, chunky fun graphics, lots of those explosion effects and even a parallax star field in the background.   Dave Perry certainly had CPC skills.
Title: Re: pixel effects.
Post by: ||C|-|E|| on 12:43, 10 October 15
Then, he would do it again with Global Gladiators, Earthworm Jim and, MDK... he always was very very skilled. Too bad that he is not programming with his own hands anymore, or programming at all. He is really rich and moved to other things.
Powered by SMFPacks Menu Editor Mod