Loading PAL files in QBasic

For the LoadPal subroutine to work, the main program must contain the TYPE definition for Trgb. As there is no byte type in QBasic, STRING * 1 has been used instead:

TYPE Trgb
r AS STRING * 1
g AS STRING * 1
b AS STRING * 1
END TYPE

The following is a subroutine from the file BLD.BAS that loads a PAL file into the screen's palette:

'Loads a palette file (of record type Trgb) into colors
DEFINT A-Z
SUB LoadPal (f$)
DIM clr AS Trgb

c = 0
palfile = FREEFILE
OPEN f$ FOR RANDOM AS #palfile LEN = LEN(clr)
WHILE NOT EOF(palfile)
GET #palfile, , clr
OUT &H3C8, c
OUT &H3C9, ASC(clr.r)
OUT &H3C9, ASC(clr.g)
OUT &H3C9, ASC(clr.b)

c = c + 1
IF c > 255 THEN GOTO skip
WEND

skip:
CLOSE #palfile
END SUB

See Advanced BSV & PAL techniques for information about loading multiple PAL files

See the PAL file format page for PAL file structure

For more information about manipulating the QBasic palette, see www.qb45.com

For loading & drawing BSV files in screen 13, see the loading BSV files page.

Back to contents page

BSV Babel is copyright Trelsoft freeware.