CODINGLISTINGS ★ Colour Swapping|Popular Computing Weekly) ★

Graphic - Colour Swapping (Popular Computing Weekly)Coding Listings
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Animate your figures by colour swapping on the 464 -from J W Constable

Colour swapping is a technique possible on machines such as the Amstrad and BBC that allows the colour of 'pens'that have been used to print or draw to be changed. On the Amstrad the technique works like this. Pens one to IS are used to draw - for instance - 15 adjacent, parallel lines. Then all Pens are filled with Ink the same colour as the Paper which in this case will be set to zero (let us say that this background is black). This means that all the coloured lines effectively disappear as far as the eye is concerned. However, they are actually still there but coloured black.

Now if the Ink in each Pen in turn is changed to, let us say, blue and then back to black again, a single line appears to move across the screen. If this process is now extended to pictures or various stages of a rotating shape then the result is very fast animation. The Lissajous Figures program is one which uses this colour swapping technique. The plotting can be speeded up by increasing the Step rate in Line 140, but the larger it gets the more the lines start to break up. The animation can be speeded up or slowed down by altering the 'wait' loops in Lines 230 and 270.

For this particular plot, as half of the pattern repeats itself going in the opposite direction it is possible to draw twice the amount of positions of the figure in half a cycle, and then step backwards through the colours in the animation section as well as forwards to complete the second half of the rotation. To see what I mean delete Lines 250 to 280 to see just half the cycle.
Line 150 may be altered and experimented with to produce different Lissajous figures or plots of other functions, but the associated lines and for/ Next loops must be changed to customise the program to produce the best effect for the new function, as they were with this example.

When using the technique two main things must be remembered. Firstly, whatever is plotted must only have 15 stages (although the Lissajous Figures program effectively has 30 because half of it is repeated). This is because 15 is the maximum number of Pens allowed in Mode 0 excluding one Pen for the Paper or background.

Secondly, if one part of a plotted shape is superimposed on another part of a previous shape in the previous Pen, then that part of the previous shape will be overwritten and lost, so try to avoid this. You can see what I mean from the early stages of the Figures program. The problem is more pronounced in Mode 0 where the pixels are bigger and more likely to overlap, so if the thing that you are animating can be done with a total of four Pens (including one background or Paper Pen) then use Mode 1.

The On Break Cosub statements in Line 60 and 300 are to prevent the program from being stopped and leaving the user with an unusable set of Inks -a common problem when breaking out of a program that uses colour swapping. The Call &BBFF resets the Pen Inks to default values. I found the Mode 1 command necessary because the machine code call appears to corrupt Mode 0 by mixing it with Mode 1. Delete the Mode 1 in Line 300 to see what I mean.

I leave you with the second program which I think is more impressive.

PopularComputingWeekly850829

★ PUBLISHER: POPULAR COMPUTING WEEKLY
★ YEAR: 1985
★ AUTHOR: J.W.Constable

 

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Coding » Comment Contruire une RSX (CPC Revue)
» Coding » Adresses principales de la ROM inférieure CPC 6128
» Coding Src's » David Wild PD desktop RSX library
» Coding » Clefs1 29 Adr Hirom 464
» Coding » L'assembleur en Douceur (4/x) : Etude des différentes bases par l'hexadécimal et le B.C.D. (Micro-Mag)
» Coding » CAT-Syndrom
Je participe au site:

» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 077 millisecondes et consultée 2524 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.