Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question about OUT & palette loading
#1
Code:
SUB ChangePalette (PaletteArray&())
    DIM RGBval(0 TO 255, 0 TO 2)
    FOR n = 0 TO 255
        c& = PaletteArray&(n)
        B = c& \ 65536: c& = c& - B * 65536
        G = c& \ 256: c& = c& - G * 256
        r = c&
        RGBval(n, 0) = r
        RGBval(n, 1) = G
        RGBval(n, 2) = B
    NEXT n

    'Write colours directly to the video card.
    'unsure of the need for the WAIT statement.
    'WAIT &H3DA, &H8, &H8: WAIT &H3DA, &H8
    FOR n = 0 TO 255
        OUT &H3C8, n            'Select attribute.
        OUT &H3C9, RGBval(n, 0) 'Write red.
        OUT &H3C9, RGBval(n, 1) 'Write green.
        OUT &H3C9, RGBval(n, 2) 'Write blue.
    NEXT n
END SUB
'-------------------------------------------------------------------------------
SUB Init.PaletteData (Filename$, PaletteArray&())
    REDIM PaletteArray&(0 TO 255)
    IF Filename$ <> "" THEN
        FileNo = FREEFILE
        OPEN Filename$ FOR BINARY AS #FileNo
        FOR n = 0 TO 255
            GET #FileNo, , colour&
            PaletteArray&(n) = colour&
        NEXT n
        CLOSE #FileNo
    END IF
END SUB

something about the latest (.11b) version of FBC has caused my 256 color palette to load oddly. instead of loading the colors in the right order, it seams to load them in a different way. at a glance, it looks like all the colors are there, but not in the gradient rows i put them in; they are all scattered and mixed. is it the OUT statement?
Reply
#2
In noticed it too..

I ported an old raycaster of mine that uses OUT and gradients, the colors are more saturated in FB than in QB
Antoni
Reply
#3
yeah. this palette should be a set of visible gradients. look how it cuts them up into sections, like on the red, and the grayscale at the very bottom. miniature gradients... but not only that, there shouldn't be bits of green mixed with the purple. so it does other odd things too.

[Image: palerror.gif]
Reply
#4
I found what's causing this. The code for OUT is shifting RGB values up from 6 bit to 8 bit, which is fine, but then it's treating the values as if they're still 6 bit...

I've commited a simple fix (changed a 2 to a 0 in two lines) that makes it work, I hope Angelo won't mind.

For now you can just use the palette command to set the palette instead. You should anyway, because OUT is slower (it simply passes the values you give it on to the palette command).
Reply
#5
hey thanks man.
Reply
#6
I think OUT shouldn't be used. Let it there just to make old code compilable, but when you code something new, do use PALETTE. Why? Just style. In Windows, that OUT stuff has no true meaning, it's just some kind of wrappin' emulation technique just for backwards compatibility.

New programs coded specifically for FB should use PALETTE, so when people see source codes they don't have to wonder what the hell is doing the program with the ports from windows Wink

Toad, your SUB could have been a lot shorter:

PALETTE USING Palettearray&(0)

Wink
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#7
haha, awesome. well you learn something every day. Palette Using... lol. simple stuff.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)