PICO8 - strange way to record HEX number

180 Views Asked by At

I am trying to understand how specific script (fade function) works in PICO8:

function fade()
  fadep=split("0xffff.8,0xfffe.8,0xffec.8,0xfec8.8,0xec80.8,0xc800.8,0x8000.8,0x0.8")
  for i=0,64 do
    fillp(fadep[flr(i/(32/#fadep))+1])
    rectfill(0,0,127,127,0)
    flip()
  end
end

I understand that split() function splits the number in argument separated by comma (by default) and we will get 8 HEX numbers like first one "0xffff.8". As far as I know HEX numbers starts with "0x", but what means this ".8" at the end? Thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

In the function filp per the wiki

Alternatively, you can set the pattern to make the off bits transparent (showing what is drawn underneath). To do this, add 0b0.1, or 0x0.8 if using hex, to the pattern value

It explicitly sets the off bits to be transparent as explained in the fillp write up

The color parameter to the drawing functions (such as circfill()) can set two colors, to be used for the on bits (1's) and off bits (0's) of the pattern. The four lower bits of the color value are the "on" color, and the higher bits are the "off" color. For example, to draw the on bits as light blue (12, or 0xc) and the off bits as dark blue (1), set the color to 0x1c (28).

That's the fractional portion of a hex number. You can also use the fractional portion on the decimal and binary representations.

The notation is a bit odd, but thanks for asking that was a fun one to learn.