10 border 0:cls
12 for i=22528 to 22528+767:poke i,int(rnd*128):next i
20 print at 2,1;ink 8;"transparency test - ink"
21 print at 3,1;paper 8;"transparency test - paper"
22 print at 5,1;ink 9;paper 8;"contrast test - ink"
23 print at 6,1;paper 9;ink 8;"contrast test - paper"
99 pause 0
and the result is this (imagemagick thumbnail link below):
while the tokenized version (using the zx-spectrum interpreter) seems to behave as predicted, the zxbasic-compiler version seems to take wrongly colour 9 (contrast) as colour 1 (blue).
what i'm seeing is that, somehow, zxbasic-compiler is not writing at the 23697 address (please check if i'm wrong), the bits 4 and 5 for ink (0x30), and 6 and 7 (0xC0) for paper - what contrast seems to do is, considering ink is 0 when paper is at least 4 (checking the green bit seems to be enough), and 7 when below 4 - and the same for paper related to ink (i just don't know why in the system variables it were using two bits instead of one, but i think this is up to that one coded the zx-spectrum rom) - i think when using '9' on 'ink' or 'paper' commands, these bits are switched on, and between '0' and '8' they are switched off, with some kind of 'bor' (0x30 for ink or 0xC0 for paper) or 'band' (0xCF for ink or 0x3F for paper)
i think now i found why this part of my library 'print64x32.bas' were not working:
if (peek (23697) band 16)<>0 then:v6=(v5 band 248) bor ((1-(v5 band 32)/32)*7):end if :'- colour 9 - ink
if (peek (23697) band 64)<>0 then:v6=(v5 band 199) bor ((1-(v5 band 4)/4)*56):end if :'- colour 9 - paper