The source code for VGAlib3
What follows is the DEFINITION MODULE for the VGAlib3 library for FST Modula-2. Check out the general page about this subject here.
Getting started with the module
DEFINITION MODULE VgaLib3; (* This is FREE software, as described in the GNU General Public Licences. Therefore it comes WITH THE FULL SOURCES. Please feel free to improve this code when necessary. You OWN this code. I am not Bill Gates. I would appreciate that people let in this message when extending this library, as a small tribute to me (for laying the foundation). In case people need extra information, contact me via: snail mail: Jan Verhoeven, NL-5012 GH 272 electronic mail: email@example.com I remain full copyrights to these sources. If you want to send me a small "thanks", please send me a postcard of your hometown to the above shown snailmail address. Yes it is in code; the internal code of our national mail deliverer. Use this software at your own risk. Please find yourself a GNU GPL if you are in any doubt. I use these functions for all my own software, but there is NO GUARANTEE OF ANY KIND covering it. *) TYPE COLOUR = (black, blue, green, cyan, red, pink, brown, white, GREY, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE); WinData = RECORD TopX, TopY, Width, Height, CurX, CurY, DeltaX, DeltaY, Indent : CARDINAL; BoxCol, TexCol, BckCol, MnuCol : COLOUR; END; CONST ChrWid = 9;
Differences with the previous version
So far the declarations of public variables. I defined the colours as a SET in the TYPE section. This enables us in the rest of the program to use these colournames directly in the sources of our own programs. I made a simplification here in that it would have been better to do it as follows:
TYPE COLOURS = (black, blue, green, cyan, red, pink, brown, white, GREY, BLUE, GREEN, CYAN, RED, MAGENTA, YELLOW, WHITE); COLOUR = SET OF COLOURS;Consider it a challenge to recompile the VGAlib package with this improvement. It is now also easier to export the colours to other programs.
The CONST 'ChrWid' defines the amount of white-space (in pixels) between characters.
What follows is the DEFINITION part of the library. Normally this is the only readable file that a programmer sees when he buys or norrows libraries. The DEF file and the M2O object file are handed over to third parties. The MOD file, containing the sourcecode, is kept secret for many reasons.
The actual definitions are
PROCEDURE SetVGA (NewMode : CARDINAL) : CARDINAL; (* Set VGA mode 12h: 640 x 480 x 16. *) PROCEDURE SetColour (Foreground, Background : COLOUR); (* Set colour to work with. *) PROCEDURE SetMask (Mask : CHAR); (* Set up mask for plotting in VGA memory. *) PROCEDURE Plot (VAR InWin : WinData); (* Plot one point in VGA memory to (X,Y). *) PROCEDURE UnPlot (VAR InWin : WinData); (* Erase one pixel in VGA memory. *) PROCEDURE DrawH (VAR InWin : WinData; Flag : BOOLEAN); (* Draw a horizontal line from (X,Y) for DeltaX pixels. *) PROCEDURE DrawV (VAR InWin : WinData); (* Draw a vertical line from (X,Y) for DeltaY pixels. *) PROCEDURE PlotChar (VAR InWin : WinData; Character : CHAR); (* Print Character starting on memory location Pos. *) PROCEDURE PlotText (VAR InWin : WinData; String : ARRAY OF CHAR); (* Print a string of text to the screen. *) PROCEDURE MakeBox (InWin : WinData); (* Make a box on screen starting at (TopX, TopY) with sizes DeltaX and DeltaY. *) PROCEDURE Center (InWin : WinData; String : ARRAY OF CHAR); (* Center a line of text in InWin box. *) PROCEDURE ClickBar (InWin : WinData; String : ARRAY OF CHAR; VAR ClickPoints : ARRAY OF CARDINAL); (* Center a line of text in InWin box and mark the clickpoints for the mouse. *) PROCEDURE EraseBox (InWin : WinData); (* Erase inside the InWin box. *) PROCEDURE FillBox (InWin : WinData); (* Fill inside the InWin box. *) PROCEDURE WriteNumber (VAR InWin : WinData; Num, Len : CARDINAL); (* Print CARDINAL Num on screen, right justified in Len positions. *) END VgaLib3.
What's new in the improved VGAlib3
Well, in the new VGAlib3 library the SetText function is removed. It is made redundant because I changed the SetVGA function:
PROCEDURE SetVGA (NewMode : CARDINAL) : CARDINAL; (* Set VGA to NewMode and return previous mode to caller *)
Page created sometime and