home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / seebios.lbr / SEEBIOS1.DZC / SEEBIOS1.DOC
Encoding:
Text File  |  1993-10-25  |  13.5 KB  |  260 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                                 SEEBIOS.COM
  7.                                 -----------
  8.  
  9.                       by Raymond Rosenkranz, (C) 1986
  10.  
  11.                           3-1325 Franklin Terrace,
  12.                       Victoria, B.C. V8S 1C8, Canada
  13.                           Telephone: 604-382-7590
  14.  
  15.  
  16.  
  17.  
  18.  
  19. In the present file I explain (1.) the background, (2.) the purpose, and (3.) 
  20. the functioning of the program I wrote and called SEEBIOS. A final section 
  21. (4.) contains further remarks.
  22.  
  23.  
  24.  
  25.                                1. BACKGROUND
  26.                                -------------
  27.  
  28. You have probably noticed how slow are the screen-writing routines in Kaypro's 
  29. CBIOS (CBIOS = customized [by Kaypro Corp.] BIOS). It is these routines that 
  30. do the work for CP/M's functions no. 2 and no. 9. The non-programmer sees 
  31. their slowness when he types past the right margin in WordStar and has to wait 
  32. up to 3 (!) seconds for the screen to be rewritten.
  33.  
  34. Exasperated by my CBIOS's sluggishness, I decided in my CP/M programming to 
  35. bypass functions no. 2 (in Turbo Pascal: Write[ln]) and function no. 9  
  36. altogether when writing to the screen, and to address the Kaypro's video chip 
  37. directly, instead.
  38.  
  39. This decision was no sooner made than I ran into the first of many unexpected 
  40. difficulties: where was one to get information regarding software control of 
  41. the Kaypro's video chip? Luckily, I happened to find out about Micro 
  42. Cornucopia's "Kaypro Schematic". Its descriptions and programming examples 
  43. were sufficient to get me going. I soon discovered the amazing gain in speed 
  44. achieved by taking control of the video chip.
  45.  
  46. Micro C's instructions, however, turned out to be incomplete as well as 
  47. partially outdated and incorrect (at least for post-1984 Kaypros). To make a 
  48. long story short, I opened my Kaypro, noted the manufacturing data on my video 
  49. chip, went to an electronics store, and copied the pages from the Rockwell 
  50. microchip catalogue pertaining to the chip (R6545-1AP) in my machine. Next, I 
  51. purchased the "CRT Controller Handbook", by Gerry Kane (Berkely, California: 
  52. Osborne/McGraw-Hill, 1980).
  53.  
  54. Both the Rockwell catalogue and Gerry Kane's book refer to programming 
  55. possibilities not mentioned in the Micro C schematic. These possibilities are 
  56. essential to genuine high-speed screen-writing, yet they are not easy to 
  57. understand. Gerry Kane's book proved particularly helpful here: it put the 
  58. flesh of explanation on the bare bones of Rockwell's technical specs.
  59.  
  60. With these three helpers (the Micro C schematic, the Rockwell specs, and the 
  61. "CRT Controller Handbook") I succeeded, at last, in formulating high-speed 
  62. screen-writing loops that made my Kaypro's CBIOS routines look like a Model-T 
  63. next to a Porsche.
  64.  
  65. The very success of these loops, however, disclosed a technical defect in 
  66. Kaypros that had, until then, been concealed behind their slowness: at random 
  67. intervals all characters (or attributes) written to the screen from a certain 
  68. point on were shifted either one character to the left or one to the right. 
  69. After countless experiments in reformulating the screen-writing loops - none 
  70. of them able to prevent these write errors - I concluded that the write errors 
  71. were due to a timing problem in the Kaypro's circuits. Since I wanted to 
  72. continue to use high-speed screen-writing in my programming but had no desire 
  73. to meddle with the hardware I decided to correct these random errors through 
  74. software, i.e., through test-and-correct loops in the screen-writing routine 
  75. itself. (If while using SEEBIOS you notice a screen line flicker then what you 
  76. saw was a write error followed by its correction.)
  77.  
  78. The next difficulty to emerge was due to the way the Kaypro's CBIOS screen 
  79. routines scroll the screen up one line when a Carriage Return (or Linefeed) is 
  80. entered in row 24, or when a character is typed in column 80 of row 24. To 
  81. make another long story short, it became necessary to locate the bytes in RAM 
  82. where Kaypro's CBIOS stores the current offset of the chip's screen memory 
  83. addresses. (If you don't know what "the current offset of the chip's screen 
  84. memory addresses" is, don't despair: I'll explain.) This necessity was the 
  85. mother of SEEBIOS's invention.
  86.  
  87.  
  88.  
  89.                                 2. PURPOSE
  90.                                 ----------
  91.  
  92. The primary purpose of SEEBIOS is reflected in its name: to observe the BIOS 
  93. in action as it updates its scratch tables in RAM (i.e., the bytes that 
  94. contain information it collects and utilizes during its operation) - 
  95. particularly those associated with its screen routines. Prior to writing 
  96. SEEBIOS I had located some of these bytes through trial and error. The 
  97. correlations I observed between the variations in their values and CP/M's 
  98. screen operations provided the hypotheses underlying the search algorithms 
  99. employed in SEEBIOS.
  100.  
  101. DDT, unfortunately, does not allow an inspection of RAM contents during CBIOS 
  102. (or BDOS) operations: it only provides snapshots after the completion of an 
  103. operation. This static display makes it extremely difficult to see the dynamic 
  104. correlations between such operations and the contents of certain bytes in RAM. 
  105. SEEBIOS, on the other hand, by virtue of its high-speed screen-writing 
  106. procedures, allows one to observe these correlations.
  107.  
  108. CBIOS values that can be observed 'in action' include:
  109.      -cursor row
  110.      -cursor column
  111.      -cursor screen memory address
  112.      -screen memory address offset
  113.      -input buffer
  114.      -input buffer pointers
  115.      -CONFIG's definitions of the vector key pad and of the numeric key pad
  116.  
  117. SEEBIOS is not limited to serving the primary purpose outlined above. Unlike 
  118. DDT, SEEBIOS does not alter the contents of any area in RAM except the portion 
  119. of TPA (Transient Program Area) occupied by SEEBIOS itself. In particular, it 
  120. leaves the vectors in CP/M's zero page (addresses 0 - FF hex) and the CCP 
  121. intact. This means that you can inspect not only CP/M's proper values in these 
  122. areas but also auxiliary programs - such as key definition programs, desktop 
  123. accessories, and the like - residing in high memory just below the CCP (an 
  124. area that might otherwise be overwritten by DDT).
  125.  
  126.  
  127.  
  128.                               3. FUNCTIONING
  129.                               --------------
  130.  
  131. I wrote SEEBIOS in 8080 assembly code. Why not Z80 code? Because I don't have 
  132. a Z80 debugger but do have DDT. And because writing assembly code without a 
  133. debugger is something I leave to geniuses and fools.
  134.  
  135. Even so, SEEBIOS is fairly bulky (8k) considering how little it actually does. 
  136. The reasons for this bulk are: (a) SEEBIOS contains all help and prompt 
  137. information so that it is always quickly available; (b) the screen-writing 
  138. procedure is fairly intricate, partly because of its test-and-correct loop; 
  139. (c) the algorithms seeking CBIOS's scratch tables are also quite involved.
  140.  
  141. These algorithms, as remarked above, make certain hypotheses concerning CP/M's 
  142. methods of counting, storing, offsetting, etc. For example, the algorithm to 
  143. locate the bytes storing the row and column values assumes (a) that CP/M 
  144. counts rows and columns from 0 to 24 (decimal) and from 0 to 79 instead of 
  145. from 1 to 25 and from 1 to 80, and (b) that the row value is stored at an 
  146. address immediately adjacent to and lower than the address of the column value 
  147. (i.e., to the 'left' of the column value in a RAM display such as DDT's or 
  148. SEEBIOS's).
  149.  
  150. Given these and some other hypotheses, SEEBIOS searches for the bytes holding 
  151. the row and column values, the cursor address, and the screen address offset 
  152. in three stages: first, it locates the row and column values by running the 
  153. cursor diagonally from the 0/0 (home) position and by checking which RAM 
  154. values in the CBIOS area vary accordingly. Second, it prints spaces in row 24, 
  155. column 80 and checks which RAM values receive an increment of 80 at each step. 
  156. (80 is the offset added to the screen memory addresses at a 1-line scroll.) 
  157. Third, it uses this knowledge of the current offset value to determine the 
  158. cursor address by running the cursor diagonally again and checking which RAM 
  159. values in the CBIOS area vary accordingly.
  160.  
  161. To locate the cursor address one must know - as can be learned both from the 
  162. Rockwell catalogue and from Gerry Kane's book together with the information 
  163. about Kaypro's video chip initialization values provided by "Micro C"'s Kaypro 
  164. schematic - that the Kaypro uses binary (or consecutive) screen memory 
  165. addressing. This means that it assigns screen locations not to row and column 
  166. coordinates but to a continuing count of 2000 screen locations from 0 to 1999. 
  167. Thus, the uppermost and leftmost screen location has number 0, the one 
  168. immediately below it (80 bytes 'away' from it, so to say) has number 80, etc.:
  169.  
  170.  
  171. ------------------------------- . . . . . .  ----------
  172. l         l         l         l              l         l
  173. l    0    l     1   l    2    l              l    79   l
  174. l         l         l         l              l         l
  175. l-------- l---------l---------l              l---------l
  176. l         l         l         l              l         l
  177. l    80   l    81   l    82   l              l    159  l
  178. l         l         l         l              l         l
  179. l---------l---------l---------l              l---------l
  180.  . . .  and so on.
  181.  
  182. Since there are 2000 screen locations (in ASCII text mode, but more in 
  183. graphics mode) the last screen location bears number 1999. (The count began 
  184. with 0 and not with 1).
  185.  
  186. However, screen memory locations actually range from 0 to 2047 (decimal) 
  187. because 10 bits are used to address the chip. (Attribute addresses are another 
  188. story altogether!) When Kaypo's CBIOS scrolls the screen up (as when entering 
  189. a carriage return in row 24) it does not shift any memory contents - e.g., put 
  190. the contents of location 80 into location 0 - but, rather, changes the initial 
  191. display address: it begins the screen display not with (the contents of) 
  192. location 0 but with (the contents of) location 80! The optical illusion 
  193. created by this method is - a scroll.
  194.  
  195. In this way, each 1-line scroll adds an offset of 80 to screen memory. This 
  196. means that screen display begins with (the contents of) a location 80 bytes 
  197. further 'down' from where it last began.
  198.  
  199. At the same time, with only 10 bits available to address screen locations, the 
  200. count gets reset to 0 at the transition from 2047 to 2048. This means that the 
  201. maximum screen address - 2047 decimal or 7FF hex - may be located anywhere on 
  202. the screen, rather than at the lower edge of the screen, as a result of 
  203. repeated scrolls having been performed.
  204.  
  205. Using SEEBIOS you can observe these peculiarities of the screen location 
  206. addresses as they reflect both cursor position and scrolls.
  207.  
  208.  
  209.  
  210.                             4. FURTHER REMARKS
  211.                             ------------------
  212.  
  213. SEEBIOS directly addresses various ports on the Kaypro. It is conceivable that 
  214. the ports on your machine are not the same as those on mine (I have a 1985 
  215. Kaypro 1). In that case SEEBIOS will not perform properly for you.
  216.  
  217. SEEBIOS is capable of printing a hard copy of the currently displayed RAM 
  218. contents - both the hex values and the corresponding graphic (ASCII and non-
  219. ASCII) characters displayed to the right of the hex values. The printing of 
  220. Control and non-ASCII characters is accomplished by translation into printable 
  221. ASCII characters: Control characters have their bit 6 set (i.e., 64 decimal is 
  222. added to their binary value) and are printed in italics, non-ASCII characters 
  223. (128 decimal to 255 decimal) have their bit 7 reset (i.e., set to zero) and 
  224. are printed underlined. The non-printable ASCII character 127 (decimal) is 
  225. replaced by a reverse slash ("\"). Since the value 255 (decimal), after having 
  226. had its bit 7 reset, equals 127 it is shown as "\" underlined. This 
  227. translation also allows you to recognize Control and non-ASCII characters at 
  228. once.
  229.  
  230. As supplied, the program supports an Epson-compatible printer. You may change 
  231. the printer commands (italics, underlining, substitution) or enter escape 
  232. sequences appropriate to your printer by patching (e.g. in DDT) different 
  233. values in the following locations of SEEBIOS:
  234.  
  235. (Note: in each sequence of bytes the first byte must specify the number of 
  236. following bytes to be sent to the printer!)
  237.  
  238. 01C2 through 01CB:  2nd byte specifies character to substitute for 7F hex; the 
  239.      remaining 8 bytes were left so that one could preface the substitution 
  240.      character with a printer command to switch to a different international 
  241.      character set, for instance, and follow the substitution character with a 
  242.      printer command to switch back to USA characters. I omitted these 
  243.      commands because they slow down the printing considerably on my 
  244.      "Panasonic" printer.
  245. 01D5 through 01DD:  9 bytes available to set underlining.
  246. 01DE through 01E6:  9 bytes available to set italic mode.
  247. 01E7 through 01EF:  9 bytes available to release both underlining and italic.
  248.  
  249. SEEBIOS contains a complete, self-explanatory Help screen: call up SEEBIOS and 
  250. press LINEFEED (CTRL-J) when prompted for input.
  251.  
  252.  
  253.                              -- Good luck! --
  254.  
  255.  
  256. P.S.: I would be interested in any comments or suggestions you might have.
  257. P.P.S.: I plan in a further 'letter' to describe the programming necessary to 
  258. achieve high-speed screen-writing by direct chip address rather than through 
  259. Kaypro's sluggish CBIOS routines.
  260.