Qbasicnews.com
October 15, 2019, 11:24:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: question about OUT & palette loading  (Read 3930 times)
toad
Member
*
Posts: 56


Coding since the 90's


WWW
« on: February 05, 2005, 05:45:46 PM »

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?
Logged

Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #1 on: February 05, 2005, 07:36:36 PM »

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
Logged

Antoni
toad
Member
*
Posts: 56


Coding since the 90's


WWW
« Reply #2 on: February 05, 2005, 08:52:22 PM »

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.

Logged

Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #3 on: February 05, 2005, 09:21:05 PM »

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).
Logged
toad
Member
*
Posts: 56


Coding since the 90's


WWW
« Reply #4 on: February 05, 2005, 10:45:14 PM »

hey thanks man.
Logged

na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #5 on: February 06, 2005, 09:55:39 AM »

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
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
toad
Member
*
Posts: 56


Coding since the 90's


WWW
« Reply #6 on: February 06, 2005, 11:15:10 AM »

haha, awesome. well you learn something every day. Palette Using... lol. simple stuff.
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!