HERCBIOS.ASM PAGE 1 THIS SYSTEM IS SHAREWARE, THEREFORE, IF YOU LIKE THIS PROGRAM, FIND IT USEFUL, AND DECIDE TO USE IT, THEN YOU MUST SEND A $5.00 LICENCE FEE U.S. TO: Douglas McDaniels 2627 Arlington Dr #101 Alexandria VA 22306 U.S.A. Hercbios is Copywrite 1988 by Douglas McDaniels. HOWEVER, HERCBIOS HAS BEEN RELEASED AS SHAREWARE, SO YOU MAY MAKE ALL THE COPIES THAT YOU WANT, GIVE THEM TO YOUR FRIENDS, AND YOU MAY PLACE THIS SYSTEM ON BULLETIN BOARDS.(HBIOSARC.EXE is the recomended format) First, what is HERCBIOS.COM ? All the major video graphics boards for the IBM P.C. series and compatibles, with the single exception of the Hercules Monochrome Graphics Adapter, have a built in ROM BIOS (accessed though INT 10H) that provides the video primitive functions such as the capability to put a character on the screen. DOS uses these functions to implement its teletype style interface, and these video ROM BIOS functions are also accessed by many applications programs. There is no reason why video ROM BIOS functions should not be provided for the Hercules Monochrome Graphics Adapter as well, and that is what HERCBIOS.COM does. Using HERCBIOS.COM you can now have a 43 line by 90 column text mode for your M.G.A (Hercules compatable) board, and those application programs that use only BIOS calls for compatibility should run under this mode. You may be wondering what mode number I have decided to use for the Hercules board. All the IBM video modes have a number associated with them, for example monochrome text mode is mode number 7, while C.G.A text mode is mode number 3. The decision is quite easy. IBM has started at 0, and has worked its way up to mode 20 or so. The negative numbers have not been touched by anyone yet, so now is the time to do so. I have chosen mode -2 (or 254) as the Hercules monochrome graphics mode, reserving mode -1 for special use. Note that this leaves room for a whole series of negative mode numbers for use by other non-IBM board manufacturers, and also for negative modes that provide extensions to the INT 10H functions of already existing modes. This program also implements a mode mapping feature, allowing the user to redirect program requests for an IBM mode to a request to change to one of the negative, non-IBM modes (the special mode -1 is involved in this feature, see the documentation for video function 00h and the assembly listing for program MODEMAP ) __________________________________________________ HERCBIOS.ASM PAGE 2 Here are general user instructions and general comments on the use of HERCBIOS.COM: To install the program you simply run it, by entering HERCBIOS 43, HERCBIOS 29, or HERCBIOS followed by some other number at the Dos prompt.(The meaning of the command line argument is explained later. See also the description of INT 10H function 08h) But to make use of it you must also load the pixel maps. I have provided an accompanying mini-program ASCITABL.COM which loads the ASCII pixel bit maps for IBM computers and true compatibles, and the Dos program GRAFTABL.COM loads the graphics pixel maps for those with Dos 3.x. Just run HERCBIOS.COM, ASCITABL.COM and GRAFTABL.COM in any order. For those who are still using Dos 2.x, I have provided a program called GRAFCHAR.COM which duplicates the function of GRAFTABL.COM. Also, for machines which are not really very IBM compatible, ASCITABL.COM may not work. I have therefore provided an alternate program ASCICHAR.COM which should work even on those machines, its disadvantage being that it takes up more RAM than ASCITABL.COM since it must explicitly load the pixel maps, while ASCITABL.COM makes use of the pixel maps that are supposed to be already present in the ROM BIOS. A word about mini-program ASCITABL.COM, this program simply points INT 44H (the interrupt reserved by IBM for just this purpose) to point to the 8x8 ASCII pixel maps, which on IBM and true compatibles are always located at 0F000:0FA6E, and I have hard coded this vector in ASCITABL.COM. To change into the Hercules mode you could use EGAMODE.COM (as provided by the ZIFF DAVIS Publishing company) but you will probably want to use the mini-program CHANGE.COM (included) for this purpose since it allows the user to decide whether or not to map in the second graphics page, leaving it out in order to provide for the presence of a CGA card. In order to change to Hercules monochrome graphics mode, run the mini-program CHANGE.COM . If you provide a command line argument of 0 (.i.e. type CHANGE.COM 0 ) then the second graphics page (page 1) will be suppressed to allow a CGA compatible card to reside in your system at the same time as your Hercules compatible card. To return to text only mode, in order, for example, to run programs that write directly to the screen simply run TEXT.COM, which will return your system to video mode 7 (IBM monochrome text only mode) __________________________________________________ HERCBIOS.ASM PAGE 3 In order to select, at the Dos prompt, the number of rows displayed on the screen, I have provided the mini-programs ROWS43.COM, ROWS29.COM, and ROWS25.COM. Those users with ANSI.SYS installed should run ROWS25.COM right off, since ANSI.SYS requires that there be only 25 rows on the screen. For those who chose not to use ANSI.SYS (and its utility is very limited) running ROWS43.COM will put 43 rows on the screen when in Hercules monochrome graphics mode, and running ROWS29.COM will return the display to the default value of 29 rows on the screen. (Note that you will probably want to clear the screen right after running these programs since previously written rows are not altered) A caution about CLS: The CLS command provided with Dos will suppress the alternate graphics page, since when ANSI.SYS is not installed, CLS clears the screen by issuing a change mode command to the currently active video mode. Therefore, I have provided two clearscreen mini-programs CLS0.COM and CLS1.COM which clear the screen, the latter permitting the existence of the alternate graphics page, the former suppressing it. Returning to the command line argument of HERCBIOS, we see in the description of function 08H that it reserves enough RAM to store the character codes for the read character function for the number of rows specified in the argument. No space is reserved to store character attributes (however, an algorithm is used that determines if the attribute is inverse video by examining the pixel patterns on the screen. This algorithm works for all but a very few of the more esoteric characters). Note that line drawing functions are included with these BIOS functions. I have included the Turbo C program DAZZLE which demonstrates the efficiency of the line drawing routines. Try it! (But be sure to use CHANGE to change into the new bios mode before running DAZZLE) All names of products used here are trademarks or registered trademarks of their respective owners. This brings us to the actual INT 10H AH functions themselves. Here follows a writeup of all the supported functions, along with the features specific to this implementation. __________________________________________________ HERCBIOS.ASM PAGE 4 SET VIDEO MODE (Function 00H) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²°°°BL°°° AH = 00H CX:²²²CH²²²²²²CL²²² AL = Video mode to select DX:°°°DH°°°°°°DL°°° BH = Number of highest graphics page to be mapped into memory.(Currently for AL = 254 only) °°°°°°°SP°°°°°°° CH = IBM mode number to map (AL = 255 only) °°°°°°°BP°°°°°°° CL = Translation for future requests for mode in CH °°°°°°°SI°°°°°°° (AL = 255 only) °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° Exceptions and Comments: When AL = 255 a special mode mapping feature is invoked. Any future requests for the mode contained in CH will be translated into a request for the mode number contained in CL. Also, the current mode will be changed to mode 7 (monochrome text only) as a side effect. Furthermore, if mode 254 is placed in CL, then the Get_Current_Display_Mode function request when in mode 254 will return the mode number in CL from then on, instead of 254. To undo a mode mapping, simply use this function to remap the mode to itself. It would probably be undesirable to put 255 into CH or CL however, unless you are quite sure that you know what you are doing. ______________________________________________________ SET CURSOR TYPE (Function 01H) AX:²²²AH²²²°°°AL°°° CALL BX:°°°BH°°°°°°BL°°° AH = 01H CX:²²²CH²²²²²²CL²²² CH = Starting line within character cell for cursor DX:°°°DH°°°°°°DL°°° CL = Ending line within character cell for cursor °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° __________________________________________________ HERCBIOS.ASM PAGE 5 Exceptions and Comments: The default setting for mode 254 is CH = 06 and CL = 07. This will place the cursor at the bottom of the usual ASCII characters, and two scan lines tall. For mode 254 the bottom of the cursor must fit within the character cell, which is 12 scan lines if the number of rows on the screen in less than 30, otherwise 8 scan lines. The cursor does not blink. ____________________________ SET CURSOR POSITION (Function 02H) AX:²²²AH²²²°°°AL°°° CALL BX:²²²BH²²²°°°BL°°° AH = 02H CX:°°°CH°°°°°°CL°°° BH = Page number DX:²²²DH²²²²²²DL²²² DH = Row DL = Column °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° Exceptions and Comments: There is a separate cursor associated with both page 0 and page 1. This function sets the cursor for the page contained in BH (0 or 1). For mode 254, DH contains the row and may run from 0 to 42, or from 0 to 28, depending on how many rows to display on the screen have been selected. DL may run from 0 to 89 for mode 254. _________________________________________________________ __________________________________________________ HERCBIOS.ASM PAGE 6 READ CURSOR POSITION (Function 03H) AX:²²²AH²²²°°°AL°°° CALL BX:²²²BH²²²°°°BL°°° AH = 03H CX:²²²CH²²²²²²CL²²² BH = Page number (see function 02H) DX:²²²DH²²²²²²DL²²² °°°°°°°SP°°°°°°° RETURN °°°°°°°BP°°°°°°° CH = Starting line for cursor °°°°°°°SI°°°°°°° CL = Ending line for cursor °°°°°°°DI°°°°°°° DH = Cursor's row DL = Cursor's column °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° ______________________________________________ SET DISPLAYED PAGE (Function 05H) AX:²²²AH²²²²²²AL²²² CALL BX:°°°BH°°°°°°BL°°° AH = 05H CX:°°°CH°°°°°°CL°°° AL = Page number DX:°°°DH°°°°°°DL°°° °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° Exceptions and Comments: For mode 254 there are two displayable pages, page 0 and page 1. Users of this function should make sure that page 1 has been mapped into memory before trying to make use of it. ____________________________________________ __________________________________________________ HERCBIOS.ASM PAGE 7 SCROLL UP (Function 06H) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²°°°BL°°° AH = 06H CX:²²²CH²²²²²²CL²²² BH = Attribute for blanked area DX:²²²DH²²²²²²DL²²² CH = Top left row of window CL = Top left column of window °°°°°°°SP°°°°°°° DH = Bottom right row of window °°°°°°°BP°°°°°°° DL = Bottom right column of window °°°°°°°SI°°°°°°° AL = Lines to scroll °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° Exceptions and Comments: If bits 0 to 2 are blank and either bit 4,5, or 6 is set then the attribute is treated as inverse video, and a solid block is used as a fill character. If AL = 0, then the window is blanked. ___________________________________________________________ SCROLL DOWN (Function 07H) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²°°°BL°°° AH = 07H CX:²²²CH²²²²²²CL²²² BH = Attribute for blanked area DX:²²²DH²²²²²²DL²²² CH = Top left row of window CL = Top left column of window °°°°°°°SP°°°°°°° DH = Bottom right row of window °°°°°°°BP°°°°°°° DL = Bottom right column of window °°°°°°°SI°°°°°°° AL = Lines to scroll °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° __________________________________________________ HERCBIOS.ASM PAGE 8 Exceptions and Comments: If bits 0 to 2 are blank and either bit 4,5, or 6 is set then the attribute is treated as inverse video, and a solid block is used as a fill character. If AL = 0, then the window is blanked. ___________________________________________________________ READ CHARACTER AND ATTRIBUTE AT CURSOR (Function 08H) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²°°°BL°°° AH = 08H CX:°°°CH°°°°°°CL°°° BH = Page (must be zero in any graphics mode, DX:°°°DH°°°°°°DL°°° including mode 254) °°°°°°°SP°°°°°°° RETURN °°°°°°°BP°°°°°°° AH = Attribute (See note below) [***updated**] °°°°°°°SI°°°°°°° AL = ASCII character code °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° Exceptions and Comments When installing HERCBIOS, you may follow the program name with an optional command line argument consisting of a number from 0 to 43. This number reserves enough RAM to store the ASCII character codes for the number of rows that you specified starting from the top down. If a program issues a get_char (function 08H) request for a character in a row higher than you specified in the command line argument, then the ASCII value for a space character is returned instead. This function is used only by programs that read from the screen. It is usually apparent to the user that he is using a program that does this, so if the user knows that he will not be using any programs that read from the screen in mode 254, then the user can invoke HERCBIOS without any command line argument, which will not reserve any space for the get_character buffer. This can save the user up to 43*90 = 3870 bytes, which is almost 4Kb. Also, for mode 254, xor'ed characters do not currently update the get_char buffer. The correct normal/inverse attribute will be returned through the use of an algorithm that determins whether or not a character is normal or inverse video directly from the screen pixels. The algorithm returns the correct attribute for all except characters, 177,178,219,220, and 222, and in 43 row mode a few of the funny characters in the range 0 to 31 are also misread. This should be sufficient for all but the most unusual screen reading requirements. __________________________________________________ HERCBIOS.ASM PAGE 9 WRITE CHARACTER (USING ATTRIBUTE) AT CURSOR (Function 09H) Note: For mode 254, this is the same function provided by Function 0AH. AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²²²²BL²²² AH = 09H/(also AH = 0AH) CX:²²²CH²²²²²²CL²²² AL = Character to write DX:°°°DH°°°°°°DL°°° BH = Page BL = Attribute °°°°°°°SP°°°°°°° CX = Replication factor °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° Exceptions and Comments For mode 254, if bit 7 of BL is set, the character will be xor'ed into the display. If bits 0 to 2 of BL are blank and either bit 4,5, or 6 of BL is set then the attribute is treated as inverse video. If bit 3 of BL is set, and bit 7 is not set, then the character is Or'ed into the display. Xor'ed characters do not update the get_char buffer. Also, if more characters are written with a CX greater than 1 than will fit on what remains of the current column, then the result is unpredictable. ______________ WRITE PIXEL (Function 0CH) AX:²²²AH²²²²²²AL²²² CALL BX:°°°BH°°°°°°BL°°° AH = 0CH CX:²²²CH²²²²²²CL²²² CX = Column (for mode 254: 0 to 719) DX:²²²DH²²²²²²DL²²² DX = Row (for mode 254: 0 to 347) AL = Pixel color (see below) °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° RETURN °°°°°°°SI°°°°°°° None °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° __________________________________________________ HERCBIOS.ASM PAGE 10 Exceptions and Comments If bit 7 of AL is set, the pixel will be xor'ed into the screen. For mode 254, the allowable colors are 0 and 1 for black and green (or amber, white ect.) If higher colors are used, additional pixels will be placed on the screen near the selected dot, but in an unspecified fashion. The currently displayed video page is used. ____________________________________________________ READ PIXEL ON SCREEN (Function 0DH) AX:²²²AH²²²²²²AL²²² CALL BX:°°°BH°°°°°°BL°°° AH = 0CH CX:²²²CH²²²²²²CL²²² CX = Column (for mode 254: 0 to 719) DX:²²²DH²²²²²²DL²²² DX = Row (for mode 254: 0 to 347) °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° RETURN °°°°°°°SI°°°°°°° AL = Pixel color (0 or 1 for mode 254) °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° WRITE CHARACTER IN TTY MODE (Function 0EH) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²²²²BL²²² AH = 0EH CX:°°°CH°°°°°°CL°°° AL = Character to write DX:°°°DH°°°°°°DL°°° BH = Page BL = Attribute °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° None °°°°°°°ES°°°°°°° __________________________________________________ HERCBIOS.ASM PAGE 11 Exceptions and Comments For mode 254, if bit 7 of BL is set, the character will be xor'ed into the display. If bits 0 to 2 of BL are blank and either bit 4,5, or 6 of BL is set then the attribute is treated as inverse video. Xor'ed characters do not update the get_char buffer. Bell, backspace, linefeed and carriage return characters are acted upon, and the cursor is advanced appropriately. Linewrap is also provided (90 characters per column) _________________________________________ GET MODE (Function 0FH) AX:²²²AH²²²²²²AL²²² CALL BX:²²²BH²²²°°°BL°°° AH = 0FH CX:°°°CH°°°°°°CL°°° DX:°°°DH°°°°°°DL°°° °°°°°°°SP°°°°°°° °°°°°°°BP°°°°°°° °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° RETURN °°°°°°°SS°°°°°°° AL = Current video mode °°°°°°°ES°°°°°°° BH = Active video page ----------------------------------------- GET ROWS (Function 20H/11H) AX:²²²AH²²²°°°AL°°° CALL BX:°°°BH°°°°°°BL°°° AH = 11H or 20H CX:²²²CH²²²²²²CL²²² DX:°°°DH°°°²²²DL²²² °°°°°°°SP°°°°°°° RETURN °°°°°°°BP°°°°°°° DL = Number of rows seen on screen °°°°°°°SI°°°°°°° CX = Number of scan lines per character °°°°°°°DI°°°°°°° (Unique to non IBM video modes) °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° __________________________________________________ HERCBIOS.ASM PAGE 12 ----------------------------------------- GET SIZE (Function 21H/19H) AX:²²²AH²²²°°°AL°°° CALL BX:°°°BH°°°°°°BL°°° AH = 19H or 21H CX:²²²CH²²²²²²CL²²² DX:²²²DH²²²²²²DL²²² °°°°°°°SP°°°°°°° RETURN °°°°°°°BP°°°°°°° DX = Number of pixel rows on screen °°°°°°°SI°°°°°°° CX = Number of pixel columns on screen °°°°°°°DI°°°°°°° (unique to non IBM video modes) °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° ----------------------------------------------------- SET NUMBER OF ROWS ON SCREEN (Function 22H/1AH) AX:²²²AH²²²²²²AL²²² CALL BX:°°°BH°°°°°°BL°°° AH = 1AH or 22H CX:°°°CH°°°°°°CL°°° AL = Number of rows to set on screen (Unique to non DX:°°°DH°°°°°°DL°°° IBM video modes) °°°°°°°SP°°°°°°° RETURN °°°°°°°BP°°°°°°° None °°°°°°°SI°°°°°°° °°°°°°°DI°°°°°°° °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° °°°°°°°ES°°°°°°° ---------------------------------------------- MOVE TO POINT, PREPARE TO DRAW LINE (Function 23H) (Unique to non IBM video modes) AX:²²²AH²²²²²²AL²²² CALL BX:°°°BH°°°°°°BL°°° AH = 23H CX:²²²CH²²²²²²CL²²² AL = Color and style of line to be drawn, 0 = black DX:²²²DH²²²²²²DL²²² 1 = green/white/amber ,129 = XOR line into screen __________________________________________________ HERCBIOS.ASM PAGE 13 °°°°°°°SP°°°°°°° CX = X coordinate of start of line (0 to 719 for °°°°°°°BP°°°°°°° Hercules and compatibles) °°°°°°°SI°°°°°°° DX = Y coordinate of start of line (0 to 347 for °°°°°°°DI°°°°°°° Hercules and compatables) °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° RETURN °°°°°°°ES°°°°°°° None ------------------------------------------------------- DRAW LINE (Function 23H) (Unique to non IBM video modes) AX:²²²AH²²²°°°AL°°° CALL BX:°°°BH°°°°°°BL°°° AH = 24H CX:²²²CH²²²²²²CL²²² DX:²²²DH²²²²²²DL²²² °°°°°°°SP°°°°°°° CX = X coordinate of end of line (0 to 719 for °°°°°°°BP°°°°°°° Hercules and compatibles) °°°°°°°SI°°°°°°° DX = Y coordinate of end of line (0 to 347 for °°°°°°°DI°°°°°°° Hercules and compatables) °°°°°°°DS°°°°°°° °°°°°°°SS°°°°°°° RETURN °°°°°°°ES°°°°°°° None Exceptions and Comments The start of the line is either set by a move command (function 23H), or else defaults to the end of the last line drawn, thus successive draw commands can be used to draw polygons with no need for any move commands for all but the first point of the polygon to be drawn. The style of the line (white, black, or XOR) is set by the last issued move command until changed by another move command. __________________________________________________ HERCBIOS.ASM PAGE 14 ------------------------------------------- Sincerely, Douglas McDaniels __________________________________________________