home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Big Blue Disk 11
/
bbd11.zip
/
BIOSDEMO.CHN
(
.txt
)
< prev
next >
Wrap
Turbo Pascal Chain module
|
1987-06-23
|
23KB
|
231 lines
$ PRESS [ SPACE BAR ] TO CONTINUE:
)ROM BIOS VIDEO INTERRUPT 10h DEMO PROGRAM
by: Joel Ellis Rea
This program will demonstrate some of the capabilities of the ROM BIOS video
Nfunctions, all called via INTerrupt 10h. For each function, I will review the
Opurpose of the function, the calling sequence, and the effect you will see with
Neach demo. Then you simply press the space bar as advised to see the effect.
O Those of you interested in seeing how this is done may examine the text file
Mnamed "BIOSDEMO.PAS" on Disk #2. It is the complete Turbo Pascal source code
Nfor this demo program, minus the descriptive text such as you are reading now.
NFeel free to use any of the PROCEDUREs and/or FUNCTIONs in your own programs.
N You have only an MDA or compatible. Since the MDA has only one BIOS-usable
Ovideo mode (the Monochrome 80x25 text mode, BIOS Mode 07h), we will not be able
=to demonstrate the BIOS video function 00h, "Set Video Mode".
N Your PCjr has the same basic capabilities as the CGA, with some extra modes
Oand features (such as assignable colors). However, the hardware ports and reg-
Oisters are not the same as the CGA. But the ROM BIOS handles all the necessary
#interfacing for its own interrupts.
L You have both a color video board and an MDA (or compatible), but you are
Jcurrently using the MDA. Since the MDA has only one BIOS-usable mode (the
NMonochrome 80x25 text mode, BIOS Mode 07h), we will not be able to demonstrate
Lthe BIOS video function 00h, "Set Video Mode", until you re-run this program
Fafter using the "MODE C080" MS-DOS command to enable your color board.
M Your currently-active video equipment is BIOS-compatible to the CGA in its
Mbasic capabilities. The rest of our demos will treat it as a CGA, even if it
isn't one.
J For our first demo, we will use the BIOS video function 00h ("Set Video
NMode") to switch to a 40-column screen. We will do this by setting mode #01h,
"40x25 color text".
( Welcome to 40-column color text mode.
'By doing the same code we just did, but
'with a "$03" instead of a "$01", we can
&return to BIOS Video Mode #03h, "80x25
Color Text".
K For our next demo, we will use the BIOS video function #01h, "Set Cursor
MType" to create several different cursor appearences. This function sets the
Mtop and bottom scan lines of the cursor, relative to the top scan line of the
Pcharacter cells. For our demonstration, we will first make the cursor invisible
Pby setting both the top and bottom scan lines to their maximum value of 31 (1Fh)
Owhich is way below the bottom of the characters! Then, we will make the cursor
Ointo a full box by setting the top scan line to 0 and leaving the bottom at 31.
JFinally, we set the cursor back to normal by setting the top scan line to
and the bottom scan line to
N BIOS video function #02h ("Set Cursor Position") is used to move the cursor
Nto any row or column on any of up to 8 text pages (0-7). The BIOS keeps track
Nof the cursor positions separately for up to 8 text pages. Only if the cursor
Oposition of the currently displayed page is changed are the CRTC Cursor Address
Nregisters updated. For our demo, I will simply move the cursor about randomly
Oon the screen when you press the space bar. Press it a second time to stop the
cursor movements.
O BIOS video function #03h ("Read Cursor Position") places the cursor position
Nfor the page specified by Register BH into Registers DH (row) and DL (column).
MIn addition, it also returns the starting and ending scan lines of the cursor
Nitself in Registers CH and CL, respectively. (Now you know how this demo knew
Mwhat shape to restore the cursor to after changing it in the demonstration of
NBIOS function #01, "Set Cursor Type".) For the demonstration, the cursor will
Obe moved randomly about on the screen. The current cursor status will be shown
4continuously. Press the space bar to exit the demo.
O BIOS video function #05h ("Set display page") selects which of the available
Pvideo pages to display. Note that many other functions allow specification of a
Nvideo page, but those are for which page to USE, not DISPLAY. This allows one
Npage to be displayed while another is being "built", allowing for very smooth,
Gvery fast display changes. The desired page is placed in Register AL.
N Because you are using an MDA, you can only have one display page. Thus, we
Pwill not be able to demonstrate this function until you re-run this program with
'your color video adapter board enabled.
M Because you have only an MDA which has only one diplay page, we cannot demo
this function on your system.
L For your PCjr, this function is a little more complex than with other PCs.
KRather than just setting the display page as specified in Register AL, this
Jfunction has 4 separate sub-functions, selected by Register AL as follows:
K$80 reads the current CRT and CPU page settings, $81 sets the CPU page, $82
Lsets the CRT page, and $83 sets both the CRT and CPU pages. The CRT page is
Lthe high byte of the starting segment address of the memory to be displayed.
LThe CPU page in the high byte of the starting segment address of main memory
Nto be mapped into the 16K area starting at segment $B800, thus making the PCjr
Mlook like an ordinary PC with CGA to programs which aren't PCjr-specific. In
Laddition, the PCjr also understands the ordinary version of the call, with a
Msimple page number in Register AL. We will not demonstrate the PCjr-specific
subfunctions in this program.
M For our demonstration, we will briefly display the current contents of all
N80x25 text pages allowed on your video board. Except for Page 0, we will fill
them with the page number.
N BIOS video functions 06h ("Initialize Window or Scroll Window Contents Up")
Mand 07h ("Initialize Window or Scroll Window Contents Down") are identical in
Lpurpose and register usage, except for the direction of the scroll (if any).
MThey are not only responsible for vertical screen scrolling, but for clearing
Mthe screen as well. The registers on entry are as follows: AL is the number
Oof lines to scroll. BH is the attribute to fill the vacated lines with. CH is
OY coordinate of the upper left corner of the window, while CL is the X coordin-
Oate of the upper left corner. DH is the Y coordinate of the lower right corner
Pof the window, while DL is the X coordinate of the lower left corner. It may be
Oeasier to think of CH as the top row, DH as the bottom row, CL as the left edge
Ocolumn, and DL as the right edge column of the window. To affect the full area
Pof the screen, set CH to 0, DH to 24 (18h), CL to 0, and DL to 79 (4Fh) if in 80
Ocolumn text mode or DL to 39 (27h) if in 40 column text mode. Note that if the
Fnumber of lines to scroll (AL) is zero, the window is simply cleared.
P For our demonstration, we will set up a window such that the top line (CH) is
P4, the bottom line is 19, the left edge is 9 and the right edge is 69. In other
Owords, 5 unaffected lines above and below the window, and 10 unaffected columns
Pto the left and right of it. This will be scrolled 1 line down, 2 up, 3 down, 4
Pup, etc. until the window is erased. There will be a
second pause between the
Nscrolls. The blanking attribute will be light cyan on a dark blue background.
L BIOS video function 08h ("Read Attribute and Character at Cursor") is the
Npreferred means of examining the screen contents when compatibility is of high
Limportance. You can select any available video page, not just the one being
Ldisplayed currently. Usually, you will move the cursor to the desired posi-
Ktion using function 02h before using this function. The only register that
Kneeds to be set before the call is BH, which holds the desired page number.
OAfter the call, AL holds the ASCII code, and AH the attribute, of the character
6at the current cursor position on the specified page.
N For the demonstration, we will move the cursor about randomly as we did for
Ofunctions 02h and 03h, but at the bottom we will display the ASCII code and the
)attribute at the current cursor location.
M BIOS video function 09h ("Write Attribute and Character at Cursor") is one
Kmeans of writing text on the screen. 09h expects its character code in AL,
Mand the attribute in BL. Register CX specifies a "replication factor", which
Nallows a row of the same character and attribute to be displayed with a single
Mcall. For most purposes, CX is set to 1. Do NOT set it to 0! Note that 09h
Mdoes NOT move the cursor, nor does it see anything special about such charac-
Mters as Return, Linefeed, Backspace or Bell. The shapes for those characters
Nare displayed the same as for any other character. When writing more than one
Mcharacter with 09h, you MUST move the cursor yourself with function 02h. You
/can use any video page by specifying it in BH.
N For graphics modes, the "attribute" in BL for function 09h is a "draw mode"
Oinstead of an attribute. The low-order N bits of BL, where N is the power that
O2 is raised to to get the number of colors allowed in the current mode, acts as
Ka "mask", with which the pixels are ANDed before plotting. This causes the
Ncharacters to be plotted in the color specified by those N bits, if high-order
Obit of BL is reset (0). If said high-order bit is indeed reset, the results of
Pthe AND with the "mask" simply replaces what is on the screen, thus plotting the
Mcharacter on a clear background. If the high-order bit is set, however, then
Lthe results of the AND is then XORed with the screen contents at the cursor.
OThis allows text to be re-drawn on top of itself (also in XOR mode) to actually
Merase itself and restore the former screen contents automatically! This is a
Lvery useful feature for displaying transient messages in a graphics program.
N We will demonstrate only the text-mode aspects of this function at present.
NIn this demonstration, we will display all the screen codes and all the attri-
Mbutes, one attribute per code. In other words, ASCII code 41h (65, "A") will
Mdisplay in attribute 41h, or deep blue on deep red. Keep a lookout for those
Mcharacters which aren't easy to display any other way short of direct access
Lto the display buffer memory (not very compatible) -- i. e. Bell, Backspace,
Linefeed and Return.
M BIOS video function 0Ah ("Write Character Only at Cursor") is identical to
Lexcept for the fact that, in text modes, register BL (attribute) is ignored.
NInstead of specifying an attribute, the new character has the attribute of the
Kcharacter which was previously at that location. For the demo, we will use
Pfunction 09h to display 256 "x"'s with random attributes, then overlay them with
Mall the ASCII codes in sequence, but with function 0Ah, so that they keep the
#attributes which were there before.
L BIOS function 0Bh ("Set Color Palette") sets the CGA Palette port (or the
Lequivalent on the PCjr and EGA). It has two subfunctions, controlled by the
MBH register. If BH is 0, the low four bits of the Palette port are set, thus
Ksetting the border color in the CGA text or 16-color modes, the background/
Kborder color in the 4-color graphics modes, and the foreground color in the
M2-color hi-res modes. The desired color is in BL. If BH is 1, then function
O0Bh instead sets the palette used in the 320x200 color graphics mode (BIOS mode
N04h on the CGA) to one of two standard palettes, specified in BL. If BL is 0,
Lthe Green/Red/Brown palette is selected. If BL is 1, the Cyan/Magenta/White
Ppalette is selected. We will demonstrate both subfunctions here. For the demo,
Pwe will first cycle through the text border colors. Then we will switch to BIOS
LMode 04h (320x200 color graphics) and then proceed to write some text in all
Othree foreground colors, then use the second subfunction to toggle the palette.
This is a color palette test.
M BIOS video function 0Ch ("Write graphics pixel") is the basic dot-plotting
Jfunction on which most graphics which use the BIOS are based. Register AL
Mholds the desired color. Like text plotting, if the high-bit of the color is
Oset, the pixel is plotted in XOR mode. Register CX holds the X coordinate, and
Oregister DX holds the Y coordinate. Our demo is a random kaleidoscope-type dot
pattern.
K BIOS video function 0Dh ("Read Graphics Pixel") is used to determine the
Ocolor of the pixel at a specified X/Y graphics coordinate. Among other things,
Kthis function can be used to sense the edges of an area for a fill or paint
Lroutine, to determine collisions in an arcade game, etc. It is quite simple
Mto use: simply place the X-coordinate in CX and the Y-coordinate in DX, call
Lthe interrupt, and the color will be found in Register AL. For our demo, we
Mwill fill the medium-res graphics screen with a diagonally-striped pattern of
Oall four colors. We will then pick random pixels and display their coordinates
Pand color at the bottom of the screen. We will use XOR mode to flash the pixel.
J BIOS video function 0Eh ("Write Text in 'Teletype' Mode") is a somewhat
L"smarter" function than 0Ah ("Write Character Only at Cursor"). Unlike that
Ofunction and function 09h ("Write Character and Attribute at Cursor"), this one
NDOES move the cursor afterwards! For most characters, it moves the cursor one
Ospace to the right. If the cursor is already in the rightmost column, it moves
Nthe first column of the next line, or of the same line if it was on the bottom
Nline of the screen, in which case the screen scrolls one line. It also recog-
7nizes and acts upon the following special ASCII codes:
3Dec Hex ASCII Full Name "Teletype" Action
K 7 07 BEL Bell Speaker beeps at 800Hz for
second on an
G IBM-PC. Others may beep differently.
O 8 08 BS Back Space Cursor moves one position to the left. If it
N is already at the leftmost position, it does
+ not move.
O 10 0A LF Line Feed Cursor moves one line down. If it is already
O at the bottom line, the cursor does not move,
I but the screen scrolls up one one line.
N 13 0D CR Carriage Return Cursor moves to the leftmost position on the
/ current line.
N One thing it does NOT do is to place attributes. Like 0Ah (but unlike 09h)
Mit uses the same attribute which was already at the cursor position. This is
Nthe function that MS-DOS uses for most screen output. It actually calls func-
Ptions 02h ("Set Cursor Position"), 06h ("Initialize Window or Scroll Window Con-
Mtents Up") and 0Ah ("Write Character Only at Cursor") to do its "dirty work".
PIt will NOT display the shapes for the four "special" characters, since it gives
Pthem special functions instead. Upon entry, register AL holds the desired ASCII
Lcode, BH holds the desired display page, and BL holds the color code for the
2graphics modes only. No information is returned.
N The demonstration will be a simple typewriter simulator. As you type keys,
Pfunction 0Eh will be called to "echo" them. When done, press any non-ASCII key,
>such as a Function key, an Arrow key, an Alt-combination, etc.
J BIOS video function 0Fh ("Get Current Display Mode") is the last of the
Jstandard video functions. No registers need to be set up to hold any data
Nbefore the call, but the following registers hold data upon return: AL is the
Mcurrent BIOS mode number (as per function 00h), AL is the number of character
Pcolumns per line in the current mode, and BH is the active display page number.
C For our demonstration, we will simply display that information:
Current BIOS video mode:
# of character columns:
Active display page:
N We hope you enjoyed and benefited from this little demonstration of the ROM
LBIOS video functions available to intermediate programmers. We know that we
Menjoyed bringing it to you. We suggest you try running it on various systems
Owith various video capabilities, as this program senses the video hardware con-
figuration and acts accordingly.
RETURN.CHN
N BIOS video functions 0Bh ("Set Color Palette"), 0Ch ("Write Graphics Pixel")
Oand 0Dh ("Read Graphics Pixel") are useless on an MDA, so they will be skipped.
JRe-run this demo with your color graphics card enabled to see these demos.