  
                         The Coding Sheets
۲   ߲                Issue Number 2 - 07/05/1995
>mu>     ܲ           An Introduction to Graphics in Pascal
        ܰ

Note - Some understanding of the "Mem" command in pascal would be helpful
in understanding this article.  But it will be explained in a later issue for
those who do not understand it.

 The Wonderful World of Mode 13h 

This time around I will mainly be explaining mode 13 graphics (320x200x256).
There are various graphics libraries available on most BBSes.  But they
do you no good if you want to have an understanding of how to deal with 
video memory or a some of the hardware aspects of the VGA card.  

Now to cut the shit and get on with the information....

VGA - The Basics
   
In case you have been locked up in a closet for a few years, VGA stands for 
Video Graphics Adapter.  This is basically implying that you can attain
video quality pictures with only 256 colors - now that is debatable but you
can do some pretty cool graphics effects in mode 13. 

In pascal, it is EASY to start mode 13. Just use this line of code and you
in it....

--------------------------------

Asm  Mov Ax,13h; Int 10h; End;

(Int 10h is the assembly command to activate Interupt 10)
(Interupt 10 is the PC Display interupt                 )
--------------------------------

So with your program now in VGA, it is time to calculate where to put the 
pixels on screen.  Ok, for this demonstration, we will have two variables,
Variable "X" and "Y".  Within the resolution of 320x200 you can figure where
to put the pixels with this simple equation:

(If you have any questions regarding the use of this, see the next example ) 

                              (Y) * 320 + (X)

The memory setup for mode 13 is what makes it so easy it program for. It is 
basically handled like a 64000 byte array(ie, a WORD variable). The starting
memory location is A000:0000.  So if you were going to put a white dot
directly in the middle of the screen at x(160) and y(100), it would be the 
following....

--------------------------------

Mem[$A000:(100)*320+(100)]:= 15;

(This is using Pascal's Mem command... there is also MemW and MemL)
(MemW is for dealing with word size variables and MemL is for     )
(longint size variables)
--------------------------------

This is the code that we have so far...

--------------------------------
Var
  x,y: Integer

Begin
   x:= 160;
   y:= 100;
   Asm Mov Ax, 13h; Int 10h; End; {Switches display to 320x200x256 - Mode 13}
   Mem[$A000:(x)*320+(y)]:= 15; {Puts a white dot in the middle of the screen}
End.
--------------------------------

Now the variable X can equal any number between 1 to 320 and variable Y can
equal any number between 1 and 200.

Thats about it for this installment of The Coding Sheets.


Look for future issues from TCS ranging from general C programming to 
advanced biaxel scaling and rotation on multiple graphics plains. Till then

Know the code....
    Black IcE [TCS]


  You can contact The Coding Syndicate at :                               
    Virtual Utopia 303-695-9287                                           
  We need distros, coders, artists and musicians. Please contact us. NOW! 




