VIEWTGA by VLA

═════════════════───────────────              ──────────────══════════════════

    Well, it's your ol'buddy Lithium here with another in our series of 
Assembly Language programs for you beginners.  This is a simple littel file
that will load up a 320x200 TGA file and dump it on the VGA segment.  And
Abra-Kadabra, Presto-Chango you got yourself a niffty picture on the screen.

Files In This Zip


    So you ask, how is this incredible feat prformed?  First the TGA format.

TGA Format


0 - 17  

        18 byte Header

12      dw  X size of the picture
14      dw  Y size of the picture

        I don't know what the rest of the header is, but basicly identifies
        it as a TGA file


18  -786    
        768 byte Palette

        It's in BGR format (Blue, Green, Red) Flipped from the way you
        need it to display on the screen.  Each intensity is multipled
        by 4.  So you want to each byte by 4 before putting it on the
        VGA palette


786 - (X*Y+786) 

        The Picture

        Starting right after the palette, it's just a straight dump of the
        screen.  Each byte holds a value 0-255 that refers to a color in
        the palette, say color number 100 is RGB (255,0,255) Purple, that's
        what that pixel is.

    So this is the way the program works.  First it gets the filename off
the command line, using the CLSUB.ASM file, procedure GetCommandLine.
We use that filename to load the file.  If none were given, we exit and tell
the user of the error.  So, then we load the header, and get the size of the
picture (This viewer will only display 320x200 pictures)  With that done, we
load the palette.  Remember, it's reversed, so we'll have to fix that later.
Then we load the rest of the file directly onto the VGA Segment.  This is why
it only works with 320x200, since we are displaying in 320x200 mode.  Then
we flip the palette and divide each byte by 4, write it to the VGA palette
and then wait for a key press.  Then we exit.

    This program uses TASM's IDEAL mode, you will need Borland's Turbo 
Assemble and Linker to compile this program.