home *** CD-ROM | disk | FTP | other *** search
/ Big Blue Disk 11 / bbd11.zip / BIOSDEMO.CHN (.txt) < prev    next >
Turbo Pascal Chain module  |  1987-06-23  |  23KB  |  231 lines

  1. $  PRESS [ SPACE BAR ] TO CONTINUE:  
  2. )ROM BIOS VIDEO INTERRUPT 10h DEMO PROGRAM
  3. by:  Joel Ellis Rea
  4.    This program will demonstrate some of the capabilities of the ROM BIOS video
  5. Nfunctions, all called via INTerrupt 10h.  For each function, I will review the
  6. Opurpose of the function, the calling sequence, and the effect you will see with
  7. Neach demo.  Then you simply press the space bar as advised to see the effect.
  8. O   Those of you interested in seeing how this is done may examine the text file
  9. Mnamed "BIOSDEMO.PAS" on Disk #2.  It is the complete Turbo Pascal source code
  10. Nfor this demo program, minus the descriptive text such as you are reading now.
  11. NFeel free to use any of the PROCEDUREs and/or FUNCTIONs in your own programs.
  12. N   You have only an MDA or compatible.  Since the MDA has only one BIOS-usable
  13. Ovideo mode (the Monochrome 80x25 text mode, BIOS Mode 07h), we will not be able
  14. =to demonstrate the BIOS video function 00h, "Set Video Mode".
  15. N   Your PCjr has the same basic capabilities as the CGA, with some extra modes
  16. Oand features (such as assignable colors).  However, the hardware ports and reg-
  17. Oisters are not the same as the CGA.  But the ROM BIOS handles all the necessary
  18. #interfacing for its own interrupts.
  19. L   You have both a color video board and an MDA (or compatible), but you are
  20. Jcurrently using the MDA.  Since the MDA has only one BIOS-usable mode (the
  21. NMonochrome 80x25 text mode, BIOS Mode 07h), we will not be able to demonstrate
  22. Lthe BIOS video function 00h, "Set Video Mode", until you re-run this program
  23. Fafter using the "MODE C080" MS-DOS command to enable your color board.
  24. M   Your currently-active video equipment is BIOS-compatible to the CGA in its
  25. Mbasic capabilities.  The rest of our demos will treat it as a CGA, even if it
  26. isn't one.
  27. J   For our first demo, we will use the BIOS video function 00h ("Set Video
  28. NMode") to switch to a 40-column screen.  We will do this by setting mode #01h,
  29. "40x25 color text".
  30. (   Welcome to 40-column color text mode.
  31. 'By doing the same code we just did, but
  32. 'with a "$03" instead of a "$01", we can
  33. &return to BIOS Video Mode #03h, "80x25
  34. Color Text".
  35. K   For our next demo, we will use the BIOS video function #01h, "Set Cursor
  36. MType" to create several different cursor appearences.  This function sets the
  37. Mtop and bottom scan lines of the cursor, relative to the top scan line of the
  38. Pcharacter cells.  For our demonstration, we will first make the cursor invisible
  39. Pby setting both the top and bottom scan lines to their maximum value of 31 (1Fh)
  40. Owhich is way below the bottom of the characters!  Then, we will make the cursor
  41. Ointo a full box by setting the top scan line to 0 and leaving the bottom at 31.
  42. JFinally, we set the cursor back to normal by setting the top scan line to 
  43. and the bottom scan line to 
  44. N   BIOS video function #02h ("Set Cursor Position") is used to move the cursor
  45. Nto any row or column on any of up to 8 text pages (0-7).  The BIOS keeps track
  46. Nof the cursor positions separately for up to 8 text pages.  Only if the cursor
  47. Oposition of the currently displayed page is changed are the CRTC Cursor Address
  48. Nregisters updated.  For our demo, I will simply move the cursor about randomly
  49. Oon the screen when you press the space bar.  Press it a second time to stop the
  50. cursor movements.
  51. O   BIOS video function #03h ("Read Cursor Position") places the cursor position
  52. Nfor the page specified by Register BH into Registers DH (row) and DL (column).
  53. MIn addition, it also returns the starting and ending scan lines of the cursor
  54. Nitself in Registers CH and CL, respectively.  (Now you know how this demo knew
  55. Mwhat shape to restore the cursor to after changing it in the demonstration of
  56. NBIOS function #01, "Set Cursor Type".)  For the demonstration, the cursor will
  57. Obe moved randomly about on the screen.  The current cursor status will be shown
  58. 4continuously.  Press the space bar to exit the demo.
  59. O   BIOS video function #05h ("Set display page") selects which of the available
  60. Pvideo pages to display.  Note that many other functions allow specification of a
  61. Nvideo page, but those are for which page to USE, not DISPLAY.  This allows one
  62. Npage to be displayed while another is being "built", allowing for very smooth,
  63. Gvery fast display changes.  The desired page is placed in Register AL.
  64. N   Because you are using an MDA, you can only have one display page.  Thus, we
  65. Pwill not be able to demonstrate this function until you re-run this program with
  66. 'your color video adapter board enabled.
  67. M  Because you have only an MDA which has only one diplay page, we cannot demo
  68. this function on your system.
  69. L  For your PCjr, this function is a little more complex than with other PCs.
  70. KRather than just setting the display page as specified in Register AL, this
  71. Jfunction has 4 separate sub-functions, selected by Register AL as follows:
  72. K$80 reads the current CRT and CPU page settings, $81 sets the CPU page, $82
  73. Lsets the CRT page, and $83 sets both the CRT and CPU pages.  The CRT page is
  74. Lthe high byte of the starting segment address of the memory to be displayed.
  75. LThe CPU page in the high byte of the starting segment address of main memory
  76. Nto be mapped into the 16K area starting at segment $B800, thus making the PCjr
  77. Mlook like an ordinary PC with CGA to programs which aren't PCjr-specific.  In
  78. Laddition, the PCjr also understands the ordinary version of the call, with a
  79. Msimple page number in Register AL.  We will not demonstrate the PCjr-specific
  80. subfunctions in this program.
  81. M  For our demonstration, we will briefly display the current contents of all 
  82. N80x25 text pages allowed on your video board.  Except for Page 0, we will fill
  83. them with the page number.
  84. N   BIOS video functions 06h ("Initialize Window or Scroll Window Contents Up")
  85. Mand 07h ("Initialize Window or Scroll Window Contents Down") are identical in
  86. Lpurpose and register usage, except for the direction of the scroll (if any).
  87. MThey are not only responsible for vertical screen scrolling, but for clearing
  88. Mthe screen as well.  The registers on entry are as follows:  AL is the number
  89. Oof lines to scroll.  BH is the attribute to fill the vacated lines with.  CH is
  90. OY coordinate of the upper left corner of the window, while CL is the X coordin-
  91. Oate of the upper left corner.  DH is the Y coordinate of the lower right corner
  92. Pof the window, while DL is the X coordinate of the lower left corner.  It may be
  93. Oeasier to think of CH as the top row, DH as the bottom row, CL as the left edge
  94. Ocolumn, and DL as the right edge column of the window.  To affect the full area
  95. Pof the screen, set CH to 0, DH to 24 (18h), CL to 0, and DL to 79 (4Fh) if in 80
  96. Ocolumn text mode or DL to 39 (27h) if in 40 column text mode.  Note that if the
  97. Fnumber of lines to scroll (AL) is zero, the window is simply cleared.
  98. P   For our demonstration, we will set up a window such that the top line (CH) is
  99. P4, the bottom line is 19, the left edge is 9 and the right edge is 69.  In other
  100. Owords, 5 unaffected lines above and below the window, and 10 unaffected columns
  101. Pto the left and right of it.  This will be scrolled 1 line down, 2 up, 3 down, 4
  102. Pup, etc. until the window is erased.  There will be a 
  103.  second pause between the
  104. Nscrolls.  The blanking attribute will be light cyan on a dark blue background.
  105. L   BIOS video function 08h ("Read Attribute and Character at Cursor") is the
  106. Npreferred means of examining the screen contents when compatibility is of high
  107. Limportance.  You can select any available video page, not just the one being
  108. Ldisplayed currently.  Usually, you will move the cursor to the desired posi-
  109. Ktion using function 02h before using this function.  The only register that
  110. Kneeds to be set before the call is BH, which holds the desired page number.
  111. OAfter the call, AL holds the ASCII code, and AH the attribute, of the character
  112. 6at the current cursor position on the specified page.
  113. N   For the demonstration, we will move the cursor about randomly as we did for
  114. Ofunctions 02h and 03h, but at the bottom we will display the ASCII code and the
  115. )attribute at the current cursor location.
  116. M   BIOS video function 09h ("Write Attribute and Character at Cursor") is one
  117. Kmeans of writing text on the screen.  09h expects its character code in AL,
  118. Mand the attribute in BL.  Register CX specifies a "replication factor", which
  119. Nallows a row of the same character and attribute to be displayed with a single
  120. Mcall.  For most purposes, CX is set to 1.  Do NOT set it to 0!  Note that 09h
  121. Mdoes NOT move the cursor, nor does it see anything special about such charac-
  122. Mters as Return, Linefeed, Backspace or Bell.  The shapes for those characters
  123. Nare displayed the same as for any other character.  When writing more than one
  124. Mcharacter with 09h, you MUST move the cursor yourself with function 02h.  You
  125. /can use any video page by specifying it in BH.
  126. N   For graphics modes, the "attribute" in BL for function 09h is a "draw mode"
  127. Oinstead of an attribute.  The low-order N bits of BL, where N is the power that
  128. O2 is raised to to get the number of colors allowed in the current mode, acts as
  129. Ka "mask", with which the pixels are ANDed before plotting.  This causes the
  130. Ncharacters to be plotted in the color specified by those N bits, if high-order
  131. Obit of BL is reset (0).  If said high-order bit is indeed reset, the results of
  132. Pthe AND with the "mask" simply replaces what is on the screen, thus plotting the
  133. Mcharacter on a clear background.  If the high-order bit is set, however, then
  134. Lthe results of the AND is then XORed with the screen contents at the cursor.
  135. OThis allows text to be re-drawn on top of itself (also in XOR mode) to actually
  136. Merase itself and restore the former screen contents automatically!  This is a
  137. Lvery useful feature for displaying transient messages in a graphics program.
  138. N   We will demonstrate only the text-mode aspects of this function at present.
  139. NIn this demonstration, we will display all the screen codes and all the attri-
  140. Mbutes, one attribute per code.  In other words, ASCII code 41h (65, "A") will
  141. Mdisplay in attribute 41h, or deep blue on deep red.  Keep a lookout for those
  142. Mcharacters which aren't easy to display any other way short of direct access 
  143. Lto the display buffer memory (not very compatible) -- i. e. Bell, Backspace,
  144. Linefeed and Return.
  145. M   BIOS video function 0Ah ("Write Character Only at Cursor") is identical to
  146. Lexcept for the fact that, in text modes, register BL (attribute) is ignored.
  147. NInstead of specifying an attribute, the new character has the attribute of the
  148. Kcharacter which was previously at that location.  For the demo, we will use
  149. Pfunction 09h to display 256 "x"'s with random attributes, then overlay them with
  150. Mall the ASCII codes in sequence, but with function 0Ah, so that they keep the
  151. #attributes which were there before.
  152. L   BIOS function 0Bh ("Set Color Palette") sets the CGA Palette port (or the
  153. Lequivalent on the PCjr and EGA).  It has two subfunctions, controlled by the
  154. MBH register.  If BH is 0, the low four bits of the Palette port are set, thus
  155. Ksetting the border color in the CGA text or 16-color modes, the background/
  156. Kborder color in the 4-color graphics modes, and the foreground color in the
  157. M2-color hi-res modes.  The desired color is in BL.  If BH is 1, then function
  158. O0Bh instead sets the palette used in the 320x200 color graphics mode (BIOS mode
  159. N04h on the CGA) to one of two standard palettes, specified in BL.  If BL is 0,
  160. Lthe Green/Red/Brown palette is selected.  If BL is 1, the Cyan/Magenta/White
  161. Ppalette is selected.  We will demonstrate both subfunctions here.  For the demo,
  162. Pwe will first cycle through the text border colors.  Then we will switch to BIOS
  163. LMode 04h (320x200 color graphics) and then proceed to write some text in all
  164. Othree foreground colors, then use the second subfunction to toggle the palette.
  165. This is a color palette test.
  166. M   BIOS video function 0Ch ("Write graphics pixel") is the basic dot-plotting
  167. Jfunction on which most graphics which use the BIOS are based.  Register AL
  168. Mholds the desired color.  Like text plotting, if the high-bit of the color is
  169. Oset, the pixel is plotted in XOR mode.  Register CX holds the X coordinate, and
  170. Oregister DX holds the Y coordinate.  Our demo is a random kaleidoscope-type dot
  171. pattern.
  172. K   BIOS video function 0Dh ("Read Graphics Pixel") is used to determine the
  173. Ocolor of the pixel at a specified X/Y graphics coordinate.  Among other things,
  174. Kthis function can be used to sense the edges of an area for a fill or paint
  175. Lroutine, to determine collisions in an arcade game, etc.  It is quite simple
  176. Mto use:  simply place the X-coordinate in CX and the Y-coordinate in DX, call
  177. Lthe interrupt, and the color will be found in Register AL.  For our demo, we
  178. Mwill fill the medium-res graphics screen with a diagonally-striped pattern of
  179. Oall four colors.  We will then pick random pixels and display their coordinates
  180. Pand color at the bottom of the screen.  We will use XOR mode to flash the pixel.
  181. J   BIOS video function 0Eh ("Write Text in 'Teletype' Mode") is a somewhat
  182. L"smarter" function than 0Ah ("Write Character Only at Cursor").  Unlike that
  183. Ofunction and function 09h ("Write Character and Attribute at Cursor"), this one
  184. NDOES move the cursor afterwards!  For most characters, it moves the cursor one
  185. Ospace to the right.  If the cursor is already in the rightmost column, it moves
  186. Nthe first column of the next line, or of the same line if it was on the bottom
  187. Nline of the screen, in which case the screen scrolls one line.  It also recog-
  188. 7nizes and acts upon the following special ASCII codes:
  189. 3Dec  Hex  ASCII  Full Name        "Teletype" Action
  190. K  7   07   BEL   Bell             Speaker beeps at 800Hz for 
  191.  second on an
  192. G                                  IBM-PC.  Others may beep differently.
  193. O  8   08    BS   Back Space       Cursor moves one position to the left.  If it
  194. N                                  is already at the leftmost position, it does
  195. +                                  not move.
  196. O 10   0A    LF   Line Feed        Cursor moves one line down.  If it is already
  197. O                                  at the bottom line, the cursor does not move,
  198. I                                  but the screen scrolls up one one line.
  199. N 13   0D    CR   Carriage Return  Cursor moves to the leftmost position on the
  200. /                                  current line.
  201. N   One thing it does NOT do is to place attributes.  Like 0Ah (but unlike 09h)
  202. Mit uses the same attribute which was already at the cursor position.  This is
  203. Nthe function that MS-DOS uses for most screen output.  It actually calls func-
  204. Ptions 02h ("Set Cursor Position"), 06h ("Initialize Window or Scroll Window Con-
  205. Mtents Up") and 0Ah ("Write Character Only at Cursor") to do its "dirty work".
  206. PIt will NOT display the shapes for the four "special" characters, since it gives
  207. Pthem special functions instead.  Upon entry, register AL holds the desired ASCII
  208. Lcode, BH holds the desired display page, and BL holds the color code for the
  209. 2graphics modes only.  No information is returned.
  210. N   The demonstration will be a simple typewriter simulator.  As you type keys,
  211. Pfunction 0Eh will be called to "echo" them.  When done, press any non-ASCII key,
  212. >such as a Function key, an Arrow key, an Alt-combination, etc.
  213. J   BIOS video function 0Fh ("Get Current Display Mode") is the last of the
  214. Jstandard video functions.  No registers need to be set up to hold any data
  215. Nbefore the call, but the following registers hold data upon return:  AL is the
  216. Mcurrent BIOS mode number (as per function 00h), AL is the number of character
  217. Pcolumns per line in the current mode, and BH is the active display page number.
  218. C   For our demonstration, we will simply display that information:
  219. Current BIOS video mode:  
  220. # of character columns:   
  221. Active display page:      
  222. N   We hope you enjoyed and benefited from this little demonstration of the ROM
  223. LBIOS video functions available to intermediate programmers.  We know that we
  224. Menjoyed bringing it to you.  We suggest you try running it on various systems
  225. Owith various video capabilities, as this program senses the video hardware con-
  226.  figuration and acts accordingly.
  227. RETURN.CHN
  228. N  BIOS video functions 0Bh ("Set Color Palette"), 0Ch ("Write Graphics Pixel")
  229. Oand 0Dh ("Read Graphics Pixel") are useless on an MDA, so they will be skipped.
  230. JRe-run this demo with your color graphics card enabled to see these demos.
  231.