Ega/Vga

 BBS: Inland Empire Archive
Date: 11-28-92 (20:08)             Number: 362
From: LEE MADAJCZYK                Refer#: NONE
  To: JAMES FRAZEE                  Recvd: NO  
Subj: Ega/Vga                        Conf: (2) Quik_Bas
 JF>   Is there a program to convert .PCX into a .BSV file. I found
 JF> out finally how easy it is too BLOAD a .BSV file and If I can
 JF> convert a .PCX into a .BSV it would be easier.
 JF>
 JF>   Now if someone can give me code to load a 16 color .PCX file
 JF> as a menu for a game,let me know,please.

Here you go.... (I stole this from SOMEWHERE....)

     'PCX SAVE & PCX LOAD FOR EGA SCREEN 9 (640 x 350, 16 COLOR)
     'BY G.C.HARDER, RE-ENGINEERED FROM C SOURCE IN
     ' "FRACTAL PROGRAMMING IN C"

     DEFINT A-Z
     DECLARE SUB PCXSave (File$, Pal.Array%())
     DECLARE SUB PCXLoad (File$, Pal.Array%())

     FileName$ = "Demo4.PCX"
     SCREEN 9, 0, 1, 0
     DIM Pal.Array%(15)
     FOR I% = 0 TO 15: READ Pal.Array%(I%): NEXT
     CLS
     LOCATE 25, 30: PRINT "Loading " + FileName$;

     PCXLoad FileName$, Pal.Array%()
     'default Palette Colors
     DATA 0,1,2,3,4,5,20,7,56,57,58,59,60,61,62,63


SUB PCXLoad (File$, Pal.Array%()) STATIC
        SCREEN 9, 0, 0, 0: OPEN File$ FOR BINARY AS #1: SEEK #1, 17
        DIM Byte AS STRING * 1
        FOR I% = 0 TO 15
           GET #1, , Byte: red% = ASC(Byte) / 85
           GET #1, , Byte: green% = ASC(Byte) / 85
           GET #1, , Byte: Blue% = ASC(Byte) / 85
           red% = ((red% AND 1) * 32) OR ((red% AND 2) * 2)
           green% = ((green% AND 1) * 16) OR (green% AND 2)
           Blue% = ((Blue% AND 1) * 8) OR ((Blue% AND 2) \ 2)
           Hue% = red% OR green% OR Blue%: Pal.Array%(I%) = Hue%
        NEXT
        PALETTE USING Pal.Array%(0): SEEK #1, 129: DEF SEG = &HA000
        FOR k% = 0 TO 349
           A$ = INKEY$: IF A$ = CHR$(27) THEN END
           Addr% = 80 * k%: Line.end% = Addr% + 80: J% = 1
           DO WHILE J% <= 4
              B% = J%
              IF J% = 3 THEN B% = 4
              IF J% = 4 THEN B% = 8
              OUT &H3C4, 2: OUT &H3C5, B%
              GET #1, , Byte: Byte.1% = ASC(Byte)
              IF (Byte.1% AND 192) <> 192 THEN
                 POKE Addr%, Byte.1%: Addr% = Addr% + 1
                 IF Addr% >= Line.end% THEN Addr% = 80 * k%: J% = J% + 1
              ELSE
                 Byte.1% = Byte.1% AND 63
                 GET #1, , Byte: Byte.2% = ASC(Byte)
                 FOR M% = 1 TO Byte.1%
                    B% = J%
                    IF J% = 3 THEN B% = 4
                    IF J% = 4 THEN B% = 8
                    OUT &H3C4, 2: OUT &H3C5, B%: POKE Addr%, Byte.2%
                    Addr% = Addr% + 1
                    IF Addr% >= Line.end% THEN Addr% = 80 * k%: J% = J% + 1
                 NEXT
              END IF
           LOOP
        NEXT
        OUT &H3C4, 2: OUT &H3C5, &HF: DEF SEG ': CLOSE #1

     END SUB


Hope this helps. After you load your file, just BSAVE it. If you
want the PCX saving routine, or anyone else for that matter, give
me a ring!

                                    Lee Madajczyk
                                    Quantum Software

... OFFLINE 1.40 * Difference between a virus & Windows? Viruses don't fail.
--- GEcho 1.00/beta+
 * Origin:  Infinity   -=[HST]=- (1:280/5)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET