Thanks for that, @steve3000.
Archie documentation of the time (often treating it as effectively a fixed palette or just said it wasn't possible to redefine individual colours without impacting others - but didn't explain why).
I've come across a few threads along those lines.
To work out pixel values to GCOL and TINT, I wrote this years ago:
Great, I've used your technique in a new version of my Colour Space demo:
Code: Select all
10 MODE 13:OFF
15 DIM iBlock% 8, oBlock% 4, gcols% 256, tints% 256
20 DATA 0,0,0,0,0,2,0,0,4,0,0,6
30 DATA 0,2,0,0,2,2,0,2,4,0,2,6
40 DATA 4,0,0,4,0,2,4,0,4,4,0,6
50 DATA 4,2,0,4,2,2,4,2,4,4,2,6
60 FOR entry%=0 TO 15:READ b%,g%,r%:VDU 19,entry%,16,r%*16,g%*16,b%*16:NEXT
65 !iBlock%=148:!(iBlock%+4)=-1:REM ScreenStart
70 SYS &31,iBlock%,oBlock%
80 PRINT iBlock%, oBlock%, !iBlock%, !(iBlock%+4), !oBlock%
90 screen%=!oBlock%
100 FOR rgb%=0 TO 255
110 ?screen%=rgb%
120 ?(gcols%+rgb%)=POINT(0,1020):?(tints%+rgb%)=TINT(0,1020)
170 NEXT
200 FOR y%=0 TO 15:FOR x%=0 TO 15
210 c%=y%*16+x%:REM c% is BGGgbRrr, need BGGRbgrr
220 rgb%=(c% AND &eb)+((c% AND 4)<<2)+((c% AND 16)>>2)
230 GCOL ?(gcols%+rgb%) TINT ?(tints%+rgb%)
240 PLOT 68,x%<<5,988-(y%<<5):PLOT 97,32,32
300 NEXT:NEXT
310 PRINT TAB(0,17);
Which generates this:
It's a massive step forward because it means I can now use standard graphics commands instead of having to poke to the screen.
I printed it out to begin with, so I can see there's a pattern. TINT is the bottom 2 bits as expected. The POINT value involves some kind of bit shifting, which I haven't figured out, but I'm not sure it matters, because the quickest translation technique is just to index via rgb%. In the next version I'll make it a bit simpler to translate, by making rgb% order RrrGGgBb instead of BGGRbgrr (by changing line 110 to convert to BGGRbgrr and line 220 to convert to BbGGgRrr). In my notation here, capital letter components denote the direct palette bits (BGGR) and lower-case denotes the colour components mapped to palette entries (bgrr).
Then I can add a simple DEFPROCrgbSet(rgb%), DEFFNtoRgb(r%, g%, b%)=(r%<<5)+(g%<<2)+b% and DEFPROCrgbCol(r%, g%, b%) to make it a bit more usable.