The color cycling technique allows you to define an image whose color palette has the characteristic that part of it can be defined as a cycle of consecutive colors, resulting in an effect of movement or animation.
The example par excellence is “Waterfall” file that came as a demo in NEOCrhome, one of the first programs that allowed this effect that was common in Atari ST and Commodore Amiga.
In the QL we have a very limited color palette in the classic 4 and 8 color modes, and this does not allow us very realistic effects, but something can be done. Without a doubt in other color modes, with some machine code, the effect would be much better than what I show here as a result:
To achieve this effect, we must start from two premises:
1.- SuperBASIC has a command called RECOL that changes the screen colors that we indicate. For the default colors from 0 to 7 we can decide that these will be replaced on the screen by another color from 0 to 7. For example, we can change the color blue from white, as seen below, with 'n' being the chosen channel.
Code: Select all
RECOL #n, 0,7,2,3,4,5,6,1
What it does is swap colors on the screen. For animations, we must make sure that, when using RECOL, we exchange colors, as in this case, color 1 for color 7, and color 7 for color 1. Otherwise it may happen that different colors on the screen end up being the same.
2.- SuperBASIC allows defining windows that we can associate with a channel. In this way we can define rectangular areas on which to apply RECOL. In this example two areas have been used as seen in the image. In this way we can save the rest of the image and act only on the area on which we are going to use RECOL.
Those areas of the screen with irregular edges must be worked in such a way that the colors used are not affected by the RECOL, as is the case with the edges of the waterfall. This is the starting image.
Surely using the FLASH command other interesting effects can be achieved, but this would mean creating a more accurate mask for changing colors.
This is the code that allows this color change.
Code: Select all
100 MODE 8
110 LBYTES mdv1_scrs_cascada_scr, 131072
120 ch1 = 3: ch2 = 4
130 OPEN #ch1, scr_148x145a232x29
140 OPEN #ch2, scr_512x82a0x174
150 REPeat loop
160 RECOL #ch1,0,7,2,3,4,5,6,1
170 RECOL #ch2,0,7,2,3,4,5,6,1
180 IF INKEY$ <> "": EXIT loop
190 PAUSE 10
200 END REPeat loop
210 CLOSE #ch1: CLOSE #ch2
Other uses of RECOL
In this other example, RECOL is used to simulate a trail on the screen. a bouncing ball is shown, leaving a colored tail behind it.
This is the program:
Code: Select all
100 MODE 8: ch = 3
110 OPEN #ch, scr_
120 axw = 400: ayw = 200
130 WINDOW #ch, 512,256,0,0
140 PAPER #ch, 1: CLS #ch
150 WINDOW #ch, axw, ayw, INT ((512-axw) / 2), INT ((256-ayw) / 2)
160 PAPER #ch, 0: CLS #ch
170 INK #ch, 7
180 SCALE #ch, ayw, 0.0
190 axw = INT (X_Scale (ayw, axw, ayw))
200 r = 6: d = 4
210 x = INT (axw / 2)
220 y = INT (ayw / 2)
230 iz = 0: ab = 0
240 ix = 1: iy = 1
260 REPeat loop
270 RECOL #ch, 0,0,1,2,3,4,5,6
280 FILL #ch, 1
290 CIRCLE #ch, x, y, r
300 FILL #ch, 0
310 x = x + (d * ix): y = y + (d * iy)
320 IF x> axw OR x <0 THEN ix = -ix
330 IF y> ayw OR y <0 THEN iy = -iy
340 REMark PAUSE
350 END REPeat loop
370 DEFine FuNction X_Scale (y_scale, wide, high)
380 RETurn .7411765 * y_scale * wide / high
390 END DEFine X_Scale
I don't know if this technique has been used in the QL at any time, but it can be a starting point for a cover or basic game.