' This only works with BAM modes 23 to 27 (which use rgb colors)
' Not meant to be used with any other modes (which use predefined colors associated to color numbers)

SUB RgbaPset(x,y,r,g,b,a)
    c = POINT(x,y)
    c$ = RIGHT$("000000" + HEX$(c), 6)
    cr = VAL("0x" + LEFT$(c$,2))
    cg = VAL("0x" + MID$(c$,3,2))
    cb = VAL("0x" + RIGHT$(c$,2))
    PSET(x,y), _RGB( [cr * (255-a)/255 + r * a / 255], _
                     [cg * (255-a)/255 + g * a / 255], _
                     [cb * (255-a)/255 + b * a / 255] )
END SUB

SCREEN 27

LINE (0,0) - (400,400), &h0000ff ,BF

FOR this_x = 50 to 160
    FOR this_y = 50 to 160
        RgbaPset(this_x,this_y,255,255,0,255)
    NEXT this_y
NEXT this_x

FOR this_x = 110 to 250
    FOR this_y = 110 to 250
        RgbaPset(this_x,this_y,255,255,0,155)
    NEXT this_y
NEXT this_x