News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Carnivius

Raster question.

Started by Carnivius, 22:33, 23 September 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Carnivius

Does it take much cpu power to change the value of a colour as it goes down the screen.  So say the fullscreen is really just 1 of the 16 on-screen colours but is changed constantly down the screen.  Would that cause any slow down or other issues?   Just asking as to whether I need tiles for my gradient skylines in my games or if it's just one colour purely allocated for the sky and then changed (meaning I can have full control over the colours used in the gradient at any time and can change the lines in all sorts of ways).
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

MacDeath

#1
depends.

PLUS : there are specific raster interrupts so you are a bit more at ease to do this on any line.

exemple :

this is PLUS version on cartridge.


CPC (old) : if you do it anywhere, it may take time but there are 5 or 6 specific and well timed lines that allow to do it with not that much CPU time, need to be well synchronised with those specific lines. basically you divide the screen vertical in 6 equal zones . (approximately, need more accurate infos from a real coder of course)

One of the best exemple may be "the 5th axis" aka le cinquième axe.


but yeah, mode1.
when the game scrolls vertically you can see the raster zones that don't move on the screen.

other notable exemple : some James bond game "Leaving daylight (pun intended)


Basically many games would put some raster in mode1 just to get different colours from playground and HUD.

some games like PacMania or Black Tiger even abuses this : the game is in 2 colours but many useless rasters are added just for the score displays.


6 colours on screen... yeah it hurts.



adding insult to injury : you can even see ZXspectrum character artefacts clashes at some points.

list of game using the technique :
CPC-POWER, sauvegarde du patrimoine de l'Amstrad CPC

Most notable exempels are Switchblade and Stiker of in the crypt of Trogan.



real coders should explain more well the "zones limits" I guess.


Most of those xemples are in Mode1.

Actually Mode0 rarely need to apply this, and actually as there are a "lot" of colours in this mode, you may actually not notice at all.
still sometimes used for HUD as well.


Barbarian 2 per exemple :
the title zone of the screen has its own set of inks, because it actually changes the life gems colours via ink swap...

Barbarian 2 oddities...

this topic, despite not always related to you questions, explain how palette changes were quite used more often than meet the eyes.

Also many ink settings or palette screewups in "professionnal games" lol... suffered from a lot of C64 hastily ported (aka straight wrong palette set) because they would not redo the inks for every graphics.


Rasters - CPCWiki
Synchronising with the CRTC and display - CPCWiki

Fessor

Quote from: MacDeath on 23:20, 23 September 15
CPC (old) : if you do it anywhere, it may take time but there are 5 or 6 specific and well timed lines that allow to do it with not that much CPU time, need to be well synchronised with those specific lines. basically you divide the screen vertical in 6 equal zones . (approximately, need more accurate infos from a real coder of course)

AFAIK its done by utilizing the 300hz-Interrupt of the CPC.

andycadley

Quote from: Fessor on 03:39, 24 September 15
AFAIK its done by utilizing the 300hz-Interrupt of the CPC.

Indeed. To do it anywhere else on screen you basically have to start code at the nearest previous interrupt and then just burn CPU cycles delaying till the point you actually want (ok, if you're clever enough you might be able to do something practical but it's unlikely) so it starts to become a very expensive technique rather quickly.

It's a lot more viable on a Plus, both because of the more flexible raster interrupts and because you actually have enough different colours available in Mode 0 to make doing it worthwhile.

Optimus

Indeed on the plain CPC, doing it in the 6 interrupts per frame is minimal.
On the plus, you have the raster line interrupts but still, having to push all registers you use, change the colour, pop back registers every line is expensive. I haven't calculated how much yet, but when I was doing the Flappy UFO game, going less lines than 8 (like 4 or 2) would create problems with speed iirc, but of course that could be because I have other unoptimized code in that project. But change colors per 8 line is enough for a nice raster sky. At least I don't rememember exactly but I stayed at change color per 8 lines. Then you can of course change colors every line, but then not much time for the rest, and maybe then since you really do line per line stuff, it's better to do it the traditional NOP way rather than getting interrupt every line call. Now, the other good thing with CPC+ is you can use the line interrupt once to start you raster colors code wherever you want. On plain CPC, you should start in every 1/6th of screen interupts and if you wanted to start 10 lines later, you had to delay with NOPs (so you loose 10 lines) or run part of some sprite or gameplay code there. So, I guess Axis graphics is setup so that the 1/6th of screen splits fall exactly on the platforms graphics.

Carnivius

Hm, I guess I should just forget the idea then.

Thanks for the info, folks. :)


Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

Singaja

You guys have great knowledge on the subject, we could really use a wiki page summing up what you know. Especially the eye-candy examples  MacDeath provided. I also found the Barbarian 2 thread super interesting. Btw is there a game in mode 0 where the extra colors can be noticed. Obviously the Batman demo is doing magic on displaying lots of colors (aka mode 5) but I reckon it's way more complicated and probably not that useful for a game.

andycadley

Quote from: Optimus on 11:24, 24 September 15
Indeed on the plain CPC, doing it in the 6 interrupts per frame is minimal.
On the plus, you have the raster line interrupts but still, having to push all registers you use, change the colour, pop back registers every line is expensive. I haven't calculated how much yet, but when I was doing the Flappy UFO game, going less lines than 8 (like 4 or 2) would create problems with speed iirc, but of course that could be because I have other unoptimized code in that project. But change colors per 8 line is enough for a nice raster sky. At least I don't rememember exactly but I stayed at change color per 8 lines. Then you can of course change colors every line, but then not much time for the rest, and maybe then since you really do line per line stuff, it's better to do it the traditional NOP way rather than getting interrupt every line call. Now, the other good thing with CPC+ is you can use the line interrupt once to start you raster colors code wherever you want. On plain CPC, you should start in every 1/6th of screen interupts and if you wanted to start 10 lines later, you had to delay with NOPs (so you loose 10 lines) or run part of some sprite or gameplay code there. So, I guess Axis graphics is setup so that the 1/6th of screen splits fall exactly on the platforms graphics.
Yeah, can be expensive although using the alternate registers rather than the stack can help. As can using a DMA list (constructed to start at a specific scan line) to generate a sequence of interrupts spaced as required rather than reprogramming the PRI register each time.

MacDeath

#8
I agree the "raster techniques" oriented pages are not really user friendly not very illustrated or documented.

QuoteHm, I guess I should just forget the idea then.
depends... if your screen and level design can match the "no CPU raster lines" then why not... this enable to gain a few colours on screen, but can't get same gradiants as on ST or Amiga or even CPC Plus...
If the game has vertical scrolling this may not help as well and the ink for rasters colour change shouldn't be used by sprites.

for games without scrollings, this could be great indeed.


QuoteSo, I guess Axis graphics is setup so that the 1/6th of screen splits fall exactly on the platforms graphics.
all of this was quite undocumented so coders would do it grossely... and often actually loose some CPU.

I think Brian Beuken, a game dev from the time (Rastan Saga) told us about those interrupts and so on. they were experimenting despite having no time for that.

hello


Concerning Mode0 and use of such thing :
as the CPC palette is quite limited, the interrupts were mostly used to get 2 parts of the screen in different video modes.

Also many "C64 ports" would sacrifice actual colours on screen, and CPC has quite some limitations in the colours you can display (27) and many of them look very the same (many light green shades)

while Barbarian2 actually uses very different ink sets between title zone and playfield, there are no real extra added colours on the screen.

the Score zone palette :


the game zone palette :


actually many Barbarian2 screens only offer 12-14 colours on screen.. perhaps even less sometimes... depending on the colours for monster of the screen or the background displayed.

Palace Software were heavy users of palette swaps. so they would put differently paletted zones on the screen, but would put many as doubles or somewhat apparently unused.
because they made heavy use of recoded graphics datas...
datas are often in 2bits per pixels then converted via some lookup table for the colours.
So I guess you get some specification and the need to have inks as doubles here and there.
They were also probably having no time to check the palettes compeltely hence those "invisible graphics"...

Barbarian 1&2, antiriad... many Palace software exemples actually, if not all.

Multi-palette sprites


Antiriad is actually at 11-13 colours per screen most of times... (should be verified) even less... like 10 sometimes. so yeah, Mode0 is not always 16 colours...  :laugh:

Optimus

I was thinking some years ago about the game Knytt Stories and how something similar would fit the Mode 1 resolution with regular changes in the palette. The idea was for 2 of the colors to change palette per line, so you have these moody smooth rastery faded mountain background over raster skies. And then maybe change palette in a single color every 3 or 4 bytes for the tile renderer, to have unique colored tiles. Maybe the sprites would have the 4th color or share the 3rd and 4th color with the tiles (could make speccy artifacts? Afterall your sprite cannot enter a tile, so you might be safe. You could also make effect of darkenning sprites when entering a cave or when sprite goes into water, it also gets blueish, like transparent). So the idea was that I can't do this fullscreen, so I select a wide screen display, more width than normal CPC but quite less height, maybe 128 or 100 lines, and then the lines that are above or below this display can be used to render the small knytt sprite like sprites and other minimal effects on the main display. When the rasterbeam is on the display, I start my unrolled codes that out the colors from a display list, modifying the code values in a list of unrolled OUTs to do this faster (maybe something like what andycadley mentioned). So, those display lines are fully taken, but there is 60% of CPU outside for sprite rendering and other stuff.


But I never managed to start this..

Carnivius

I'm a bit confused.  What are the 6 interrupts you can change colours on the old CPC?   What y-positions are they?
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

Axelay

Quote from: Carnivac on 15:08, 26 September 15
I'm a bit confused.  What are the 6 interrupts you can change colours on the old CPC?   What y-positions are they?


They're the 300hz interupt, which occurs 6 times per screen refresh.  The screen is 312 lines high at 50hz, so the interrupts occur 52 lines apart.  You can see where those interrupts occur if you use WinAPE, select Debug, Registers and tick the Int Highlight box. Only five are 'visible' because one occurs during vertical sync.   

Carnivius

Quote from: Axelay on 15:29, 26 September 15

They're the 300hz interupt, which occurs 6 times per screen refresh.  The screen is 312 lines high at 50hz, so the interrupts occur 52 lines apart.  You can see where those interrupts occur if you use WinAPE, select Debug, Registers and tick the Int Highlight box. Only five are 'visible' because one occurs during vertical sync.   

Thanks!  Had a look and they're much too far apart for what I had in mind but I shall keep this knowledge for if it comes useful in the future.   :)
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

tastefulmrship

#13
Quote from: Carnivac on 15:42, 26 September 15
Thanks!  Had a look and they're much too far apart for what I had in mind but I shall keep this knowledge for if it comes useful in the future.   :)
The trick is to work out the timing between each interupt. Tell it to change colour A to WHITE, sit doing nothing for a while, change it to BLUE, keep going until you've changd all the colours you need. Then wait for the next interupt and keep going. My last release at Reset#20 was my first attempt at rasters (and multi-MODE and screen-swapping). The result looks decent, but requires little other than a huge number of NOPs.

It just requires a little patience and to be able to do other things (in game terms; sprites, keyboard handling ,etc) while you wait for the next "line" you want to recolour.

As always, if I can do it (and I have no talent AT ALL), then anyone can do it!




EDIT: The image is of an old version of the normal sized (ie not overscan) screen! Also, I've attached the source for it as well, so you can see where the timing for each line occurs and where I wait for the interupts (HALT command). The code is really crass, but that fits with my style, so... ^_^



Carnivius

Quote from: SuTeKH/Epyteor on 16:33, 26 September 15
The trick is to work out the timing between each interupt. Tell it to change colour A to WHITE, sit doing nothing for a while, change it to BLUE, keep going until you've changd all the colours you need. Then wait for the next interupt and keep going. My last release at Reset#20 was my first attempt at rasters (and multi-MODE and screen-swapping). The result looks decent, but requires little other than a huge number of NOPs.

It just requires a little patience and to be able to do other things (in game terms; sprites, keyboard handling ,etc) while you wait for the next "line" you want to recolour.

As always, if I can do it (and I have no talent AT ALL), then anyone can do it!




EDIT: The image is of an old version of the normal sized (ie not overscan) screen! Also, I've attached the source for it as well, so you can see where the timing for each line occurs and where I wait for the interupts (HALT command). The code is really crass, but that fits with my style, so... ^_^


Oh right. That gradient at the bottom of the image looks almost exactly the same as the one in my RoboCop: Prime game, colours and all.  So is that a raster effect creating that there cos if so then it's exactly what I was looking for? 


I don't know what an asm file is or how to use it. :P
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

tastefulmrship

#15
Quote from: Carnivac on 17:11, 26 September 15
Oh right. That gradient at the bottom of the image looks almost exactly the same as the one in my RoboCop: Prime game, colours and all.  So is that a raster effect creating that there cos if so then it's exactly what I was looking for? 
Yeah. If you turn the "rasters" off, you will see that the screen is just a standard 160x200 screen, but with precise timing I changed the background and border colours per line to create the illusion of a large (ie overscan) screen. So yes, it's pretty much what you were asking for. HOWEVER, it does require precise timing and will reduce the frame-time for sprites, keyboard handling, etc. The 5th Axis proves, however, that it is possible to have a decent game using multiple "palettes".

As far as the gradient is concerned; I did have the #07 colour in my original version (ie the one I posted the screen from above), but the one I released (or not) at ReSeT#20 had it removed. It's one of the standard CPC palette choices I remembered from the past... and by that I mean from ANTIRIAD! Some amazing colour choices in that game! Amazing!


EDIT: Note, that this raster effect has to occur EVERY frame; if you want to use double-buffering that takes, for example, two frames to display the screen layout, you have to make sure the raster is displayed twice before swapping screen locations. And, again, timing has to be precise!


Quote from: Carnivac on 17:11, 26 September 15
I don't know what an asm file is or how to use it. :P
You can view it in WinAPE (press F3, load it. Then press F9 to assemble. Type CALL &A000 in the main CPC window to view the screen) or in any text editor of your choice (I use NOTEPAD in Windows, for example). The code may not mean a lot, but you can see there are a lot of loops that do nothing and NOPs; these are the areas where the CPC is just doing nothing before changing the colour again for the next line.

The HALT command basically waits until the next interupt occurs (those bands you mentioned earlier) and so you can wait a little longer until you get to the line you want, then change colour. WinAPE is great for testing as you can RUN test code almost instantly. Having a real machine is also handy, so you can tell where the rasters start top and bottom of the screen appear on a real CTM monitor (hence the big block of #01 at the top and #25 at the bottom if viewed in an emulator).

Carnivius

Ah ok.  So maybe not in a game that's high in action with various sprites and stuff but for a simpler platform game like Roland of Sherwood it may work out fine.   And also any parts of a game that aren't taxing on cpu such as title screens and menus could make use of it.  Thanks!
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

tastefulmrship

#17
Quote from: Carnivac on 10:55, 27 September 15
Ah ok.  So maybe not in a game that's high in action with various sprites and stuff but for a simpler platform game like Roland of Sherwood it may work out fine.   And also any parts of a game that aren't taxing on cpu such as title screens and menus could make use of it.  Thanks!
Indeed. But, it depends on how many sprites (enemies, pickups, Roland, enemy/player shots, animated backgrounds) you want animated on each screen, of course; they may eat up a lot of frame-time. Maybe limiting the number of animated sprites for outside screens (where the background raster "skyline" is visible) and then ramping up the moving little critters for inside screens where the rasters would be invisible anyway. Maybe even using "fake rasters" (ie sprites coloured the same as the "skyline") for the windows to make it look like you're still displaying them.
Remember; using rasters for the outside screens also frees up a number of PENs to use on sprites, making the screen a lot more colourful.

And yes, title-screens were where you'd see a lot of rasters used back in the day; James Higgins (Ocean) is one programmer to look out for (The Vindicator, Daley Thompson's Olympic Challenge, Bad Dudes Vs Dragon-Ninja, etc).



NEXT: Multi-MODE??? - MODE 1 for the score-board, MODE 0 for the play-area. Again, easy to do, but requires timing.


Carnivius

Sounds good. :)


Not sure about mixing Mode 1 and 0.  I know a lot of games did it but it always bugged me somewhat.  I like overall screen pixel-size consistency. :)
Favorite CPC games: Count Duckula 3, Oh Mummy Returns, RoboCop Resurrection, Tankbusters Afterlife

andycadley

I'm always reluctant to say "impossible" because that tends to be proven wrong. Pulling of similar multicolour effects on the Spectrum is equally time consuming (indeed probably more so) and yet in recent years generic multi colour engines like Bifrost and Nirvana have been created that have allowed developers to push the boundaries of what once was deemed possible:



And people keep pushing that even further, and start doing stuff like this:



So who knows what similar techniques might achieve for CPC games? I'd still say the key limitation in Mode 0 is actually how few extra colours you can get, which limits the overall value. It's probably a much more interesting prospect in Mode 1.

tastefulmrship

#20
Quote from: andycadley on 13:08, 27 September 15
So who knows what similar techniques might achieve for CPC games? I'd still say the key limitation in Mode 0 is actually how few extra colours you can get, which limits the overall value. It's probably a much more interesting prospect in Mode 1.
Indeed. MODE 1 is where rasters really come into their own. SyX's MODE 5 is a prime example of the technique and, most recently, Grim & Barjack's Mammoth image (1st at ReSeT#20).

I've attached a very-early build of my Feud Trainer (that I really need to finish at some point). The bottom section of the screen will have a rasterised vertical scroller for the CHEATs. I'm still in the process of programming all that... as well as a huge number of other little projects I started and never got around to finishing!

Anyway, the Feud screen is a MODE 1 version of the Amiga/AtariST loading screen. The BULLDOG and STE logos have rasters that overlap the candle flame (more precise timing, there). The flame will be animated in the final version. The FEUD logo has a simple rainbow-raster effect. The music is a little more up-to-date version of David Whittaker's AY classic (that is STILL regarded as better than the SID version).



(In WinAPE; F3, load the .asm file, F9. Close assembler window.)


Singaja

Another example of Mode 1 is Saboteur 2 , I'm currently playing around with it:


chinnyhill10

Quote from: SuTeKH/Epyteor on 13:20, 27 September 15
Indeed. MODE 1 is where rasters really come into their own. SyX's MODE 5 is a prime example of the technique and, most recently, Grim & Barjack's Mammoth image (1st at ReSeT#20).

I've attached a very-early build of my Feud Trainer (that I really need to finish at some point). The bottom section of the screen will have a rasterised vertical scroller for the CHEATs. I'm still in the process of programming all that... as well as a huge number of other little projects I started and never got around to finishing!

Anyway, the Feud screen is a MODE 1 version of the Amiga/AtariST loading screen. The BULLDOG and STE logos have rasters that overlap the candle flame (more precise timing, there). The flame will be animated in the final version. The FEUD logo has a simple rainbow-raster effect. The music is a little more up-to-date version of David Whittaker's AY classic (that is STILL regarded as better than the SID version).



(In WinAPE; F3, load the .asm file, F9. Close assembler window.)


I hope you can run that by the Pickfords before you release it. I know they were annoyed how bad a recent "improvement" of Amaurote was on the Spectrum because it ruined the games aesthetics.
--
ChinnyVision - Reviews Of Classic Games Using Original Hardware
chinnyhill10 - YouTube

Powered by SMFPacks Menu Editor Mod