understanding by seeing if my code works as expected. In this
case it did almost on the first try... Yahoo... Still a lot more
to learn.
Hope this might be useful to someone else struggling to understand the layout.
Its in BASIC so should be easily readable.
Code: Select all
REM DEMONSTRATES USING VPOKE TO CHANGE THE VERA PALLETTE COLORS
REM R%,G%,B% HOLD R,G,B PALLETTE VALUES (0-15)
REM PC POINTS TO THE PALLETTE ENTRY (0-255)
REM
REM FOLLOWING CODE DRAWS A RECTANGLE IN COLOR $FF
REM THEN PALLETTE CHANGES THROUGH RED, GREEN AND BLUE.
REM THE PALLETTE CHANGING CODE IS A GOSUB AT LINE 20300
10 SCREEN $80
20 RECT 0,0,319,239,$10
30 RECT 50,50,90,90, $FF
35 PC = $FF: REM PC IS PALLETTE ENTRY TO CHANGE
REM RED PALLETTE
40 FOR I = 0 TO 15
50 R%=I:G%=0:B%=0
60 GOSUB 20300
70 SLEEP 5
80 NEXT I
REM GREEN PALLETTE
90 FOR I = 0 TO 15
95 R%=0:G%=I:B%=0
100 GOSUB 20300
105 SLEEP 5
110 NEXT I
REM BLUE PALLETTE
120 FOR I = 0 TO 15
130 R%=0:G%=0:B%=I
140 GOSUB 20300
145 SLEEP 5
150 NEXT I
REM GRAYSCALE
155 FOR I = 0 TO 15
160 R%=I:G%=I:B%=I
165 GOSUB 20300
170 SLEEP 5
175 NEXT I
190 INPUT X$
200 SCREEN 0:END
20300 IF R%>=0 AND R%<=15 AND G%>=0 AND G%<=15 AND B%>=0 AND B%<=15 THEN 20330
20310 PRINT "PALLETTE INVALID":END
20330 B1 = (G%*16) + B% : REM FIRST BYTE HAS UPPER AND LOWER NIBBLE.... G & B
REM IF I WAS USING C IT WOULD BE ........ B1 = (G << 4) | B)
20500 VPOKE 1,$FA00+(PC*2),B1
20510 VPOKE 1,$FA00+((PC*2)+1),R%
20520 RETURN