ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· PowerBASIC v3.20 ÚÄÄ´ DASoft ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ Copyright 1995 ³ DATE: 1995-10-01 ÇÄ· ³ ³ FILE NAME A-READER.DMO º by ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ º º ³ ³ º Don Schullian, Jr. º º ³ ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º º ³ A license is hereby granted to the holder to use this source code in º º ³ any program, commercial or otherwise, without receiving the express º º ³ permission of the copyright holder and without paying any royalties, º º ³ as long as this code is not distributed in any compilable format. º º ³ IE: source code files, PowerBASIC Unit files, and printed listings º º ÔÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º ³ .................................... º ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Welcome to the world of pixels! Throughout this section we will be referring to "Icons", "Planes", and "Buffers". Simply put an "Icon" is stored bit-map data for an image. An Icon is a 2 dimensional item but can be displayed on or captured from a color screen quite easily. That brings us to "Planes". Monochrome screens possess only 1 plane and are 2 dimensional. The CGA screen has 4 colors and as it requires two bits to count to 4 (0,1,2,3) there are 2 planes for the CGA screen. The VGA screen (12) has 16 colors and, applying the same logic, 4 planes. Easy hugh! When data is moved off of or onto a screen we use a "Buffer" to hold it. This buffer could be a BYTE array, WORD array, MEMORY or even a STRING. You may use whichever best suits your program(ing). Each of the buffers have 2bytes for the number of columns, 2bytes for the rows and XXbytes of data. Each pixel of the data represents a pixel on the screen (about). Just in case you've not noticed, all the screens are an exact number of BYTEs wide. A byte is the smallest unit that a language can easily manipulate. So, what's this gotta do with icons? Well, if your icon is 64 pixels wide instead of 65 and you PUT that icon at column 8 instead of column 7 it will be a lot faster job because bits don't have to be shifted from one byte to another to get the image into screen memory which can only accept a full byte at a time. Get it? These columns are called "byte binderies" and should be used as often as possible. Video memory is also arranged in planes with plane#1 following plane#0, etc. This, of course, is for color screens like CGA and VGA (monochrome has only 1 plane). Icons, as I have stated, are only 2 dimensional so how can we use a color screen? The most used icons are fonts/letters. These are usually PUT on the screen in one color over another color (background). If you know that you are only supposed to put those pixels in the icon that are "on" and the "on" color is Nø 14 then it is quite simple. When an icon has more than one color then you must start working with planes and when the icon, like a letter, must allow the background to show through then you must use a fifth plane called a MASK. Remember that the VGA screen has 4 planes and each plane is stored consecutively in memory. This is the reason for the PutPlane and GetPlane routines. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ < plane 3 76543210 - bit numbers ³ 4 0 ÚÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ < plane 2 ³ 5 1 ÚÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ < plane 1 ³ 6 2 ÚÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ < plane 0 (fig.12,302) ³ 7 3 The 4 planes in memory are stores consecutively and bits are put in the order as shown using the numbers. Remember that bits are counted right to left with bit 0 being the right-most. The gripe about SCREEN 12 is: "It has only 16 colors!". This is not exactly true! You can use 65,536 colors on your VGA screen but only 16 of them at once. If you are trying to recreate a Picasso then you are going to have some problems but simple games and applications should have absolutely no problems with only 16 colors. You can even do some very descent 3-D work by rearranging the values in the DAC register and using color masks to create visual effects. Try the 50/50 mix of the two blues one time! The thing I like best about SCREEN 12 is its popularity, resolution and universal standards. While I'm at it, there are also some cute little routines that allow manipulate icon data to create some "special effects". ShearIcon, when used with letters creates italics. Forward and backward facing italics can be created or, the "aspect" can be simply changed of an image by a quick pass through ShearIcon. Then there is BlowIcon which will make a bigger copy of what you've captured. All the routines that put, draw, or get things from the screen will accept "illegal" numbers like -10 and 800! When this happens that part of the icon is simply ignored. This handy trick allows you to make an icon slide onto or off of the screen without major bit shifting! There is also a SetViewWindow which allows you to manually set the area of the screen that will be affected while anywhere outside of the box is "off limits" to these routines! All the routines work on a LeftCol%, TopRow%, RightCol%, BottomRow% logic. These variables may be noted as X1%, Y1%, X2%, Y2% or C1%, R1% C2%, R2% depending on how the spirit moved me when I was writing it, but they all mean the same thing. Some of the routines will accept the addresses by sending the starting element of an array. The arrays are DIMed E%(0:3,0:xx), E%(0:3), E%(1:4,1:xx), E%(1:4) etc. This will keep the C1%, R1%, C2%, R2% info inline in memory and can be pulled off by the routines. DIM E%(3,10) : E%(0,0) = LeftCol% : E%(2,0) = RightCol% E%(1,0) = TopRow% : E%(3,0) = BottomRow% Do NOT make the mistake of diming the array E%(0:4,0:xx) as this leaves room for 5 elements for each box and not the required 4! The mouse is NOT supported in any of the routines in the DAS-NBV? libraries as it is a rare occasion, indeed, that only 1 of the routines would be called by itself. Usually you would call a group of them to create an image, draw a box, etc. Then, after you've got your box you have to print, draw or put something in it so you would be calling the mouse on/off all the time for no purpose. It would also knock off a few 1000s of a second and increase the code size, so, do your thing. Just remember: asm mov ax,&h01 ; turns the mouse on asm int &h33 'ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ and asm mov ax,&h02 asm int &h33 ; turns it off these 2 two-liners in ASM are about 60 bytes cheaper than calling MouseON and MouseOFF but you HAVE to use them in pairs or you will, at some time, loose the mouse And, last but not least, there is a plethora of second level stuff that will allow you to quickly draw 3D boxes, text boxes, print to the screen using your character sets and even some routines to draw stars, polygons, etc. There is even a large selection of two color/monochrome masks ready to use for backgrounds and borders. All five PutModes are supported by most of these routines. In short this library is a pretty complete package of graphics routines. Hope you find it as productive as I have!