home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / tpatch.lbr / TPATCH.DZC / TPATCH.DOC
Encoding:
Text File  |  1993-06-07  |  12.3 KB  |  282 lines

  1.  
  2.         Patches for Turbo Pascal V3.00A and V3.01A
  3.         ------------------------------------------
  4.  
  5. Release:    January 9, 1993 (finally!)
  6. Author:        Herbert Oppmann
  7. Address:    Drausnickstrasse 29, W8520 Erlangen, Germany
  8. Phone:        +49 9131 55018
  9. eMail:        htoppman@cip.informatik.uni-erlangen.de
  10.  
  11.  
  12.         1. Introduction and overall design
  13.  
  14. While Turbo Pascal is a very fine product I really like to work with,
  15. it hasn't been upgraded for a while now (and will probably never be).
  16. Over time I noticed several bugs and limitations that annoyed me more
  17. and more. And, with ZCPR3, I really missed the support for user areas.
  18.  
  19. So I decided to do something against it, and talked with other Turbo
  20. Pascal users here in Germany and compiled a "wish list". Astonishingly
  21. for me, this list grew quite large, and I soon realized that it was
  22. unfeasable to achive the goal just by layering some new code over the
  23. old one with e.g. some include file. I needed to change some intrinsic
  24. things.
  25.  
  26. As I don't have the copyright on Turbo Pascal, it was impossible to
  27. distribute a modified version of it, so the only way left was writing
  28. a patch. This was not easy, because I needed a lot of information
  29. about the internal workings, and squeezing something into the very
  30. limited space sometimes was more work than to implement the feature.
  31. From the first ideas to this release version, it took me more than a
  32. year ...
  33.  
  34. While addressing my needs (and the needs of my friends), I took care
  35. to retain everything machine-independant and backward-compatible, and
  36. to make things installable even when I didn't needed the flexibility.
  37.  
  38. Now I have to explain something about COM and CHN files:
  39. The only difference between compiling to a COM file or to a CHN file
  40. is that the runtime library is omitted in the latter case. While you
  41. can run COM files directly from the CP/M command line, you need to
  42. run a (COM) program first that "chains" to your desired CHN file.
  43. Such a program (usually CHAIN.COM) is a Turbo Pascal program, that in
  44. fact does little more than getting the filename of the desired CHN file
  45. from the command line and then calling the library procedure "chain" that
  46. loads the CHN file directly after the memory image of the runtime libary,
  47. thus overloading the current Pascal program. That way, the runtime library
  48. is inherited from the CHAIN program.
  49.  
  50. So, if I patch the runtime library of CHAIN.COM, _all_ CHN files profit
  51. without the need to recompile them (if that is possible, i.e. if you
  52. have the source for them). To allow for even more old programs to profit
  53. of the new runtime library, I wrote a small program (COMTOCHN) that cuts
  54. away the runtime library of your old Turbo Pascal COM files, thus making
  55. them CHN files. This does not only save a lot of space, it has the big
  56. advantage that any changes in installation (terminal or my patch) will
  57. immediately apply to all your CHN files, or, you could have more than
  58. one CHAIN program with different installation.
  59.  
  60. The patches to the runtime library need to be self-sufficient. But the
  61. other patches I did to the editor and compiler rely on the patched run-
  62. time library. So I put all the patches together in one file that is to be
  63. applied to TURBO.COM. Now, when you compile a program to a COM file, the
  64. patched runtime library that is within TURBO.COM is inherited by your
  65. program.
  66.  
  67.  
  68.         2. Patches for the runtime library
  69.  
  70. ZCPR3 support:
  71.  
  72. The beginning of the runtime library, i.e. the beginning of all Turbo
  73. Pascal COM files (including the compiler itself) now has a ZCPR3 type
  74. 1 header. When running under ZCPR3 the address of the environment de-
  75. scriptor is stored in the header (zero means "not available"):
  76.     VAR z3ptr : ^z3env absolute $109;
  77. The include file Z3ENV.INC contains this line and the definition of the
  78. environment descriptor structure (incomplete). Include file NAMEDDIR.INC
  79. serves as a good example on how to use the environment descriptor from
  80. withing a Turbo Pascal program.
  81.  
  82.  
  83. line editor:
  84.  
  85. The built-in line editor of Turbo is somewhat better than the one CP/M
  86. 2.2 had, but at least users of a Memotech computer have a far better
  87. line editor in their system. I added an installable option to use the
  88. BDOS line editor function 10 instead of the built-in one.
  89. Warning: if you use the BDOS function and press a ^C at the beginning
  90. of the line, the program is aborted. This cannot be caught in your Turbo
  91. Pascal program via a user supplied error handler.
  92.  
  93.  
  94. command line:
  95.  
  96. To access the command line from within your Turbo Pascal program, there
  97. are two library functions "ParamCount" and "ParamStr". Because of Turbo's
  98. variables residing between $B0 and $FF, the length of the command line
  99. was limited to 30 characters. The rest was overwritten while initializing.
  100. Now the command line is copied into the heap space before the initializa-
  101. tion, thus allowing for the maximum of 126 characters.
  102. Warning: this will reduce the available data space by a maximum of 128
  103. byte. This reduction occurs at runtime, so when compiling, it doesn't
  104. show. Don't lower the end address too much.
  105.  
  106. terminal reset string: (upon special request)
  107.  
  108. If you have a program that modifies your terminal setting, it has been
  109. quite difficult to ensure its restauration under all circumstances.
  110. You had to supply your own error handler, or re-rout the warmboot entry.
  111. To facilitate this there is now an installable terminal reset string
  112. that is issued everytime the program ends, no matter why.
  113. Warning: if you selected the BDOS line editor and press ^C at the be-
  114. ginning of the line, the program is aborted without sending this reset
  115. string.
  116.  
  117. error in Int2Real:
  118.  
  119. The routine in the runtime library that converts integer numbers to
  120. real numbers has a bug: integer $8000 causes an endless loop!
  121. Astonishingly, Turbo Pascal version 2 was ok. Some ignorant at Borland
  122. deleted two opcodes that treated this special case ...
  123. Is now fixed.
  124.  
  125. DU form support:
  126.  
  127. Now Turbo Pascal supports DU form! Everywhere you were able to enter
  128. a filename with a drive designator you can now enter a user too!
  129. Ironically, I had problems with old programs that handle the user
  130. itself. After some thought, I was able to come up with a solution.
  131. There is an include file NAMEDDIR.INC that adds DIR form support
  132. for your own programs. Sorry, but the limited space didn't allow to
  133. include the DIR form into the patch.
  134. Warning: some old programs store filenames in strings that are only
  135. e.g. 14 chars long. Drive and user and long filename doesn't fit in
  136. there! If you have problems, use a shorter filename (rename the file)
  137. or recompile the program with bigger strings.
  138.  
  139. Overlays:
  140.  
  141. Overlay≤ are searched on the current user on the drive supplied
  142. via the procedure OvrDrive. Now you can install a DU where Turbo looks
  143. for the overlay after this search has failed.ì
  144.  
  145. Chain/Execute:
  146.  
  147. Space for patches was very scarce in the runtime library. Either I had
  148. to give up most of my wishes, or I had to remove something to gain some
  149. space. After some investigation I decided to remove the Chain and Execute
  150. procedures, because a) I hope they are used infrequently and b) I wanted
  151. to rewrite them anyway. Using the old entry points now results in a run-
  152. time error CE. If you need Chain or Execute, use the new, much more
  153. sophisticated version in the include file NEWCHAIN.INC.
  154.  
  155.  
  156.         3. Patches for the editor/compiler
  157.  
  158. ZCPR3 support:
  159.  
  160. When compiling to a COM file, the runtime library is first copied from
  161. the memory image of TURBO.COM. The address of the environment descriptor
  162. that is possibly stored in the header musn't be copied to the COM file!
  163. It must be filled with zero instead.
  164.  
  165. TURBO startup:
  166.  
  167. To get some badly needed space for the patches in the compiler
  168. the opening menu had to be removed. Whether the error message file
  169. should be read in is now installable.
  170. The command line is evaluated, you may now optionally provide a workfile
  171. name and a main file name (of course in DU form, an extension of PAS is
  172. assumed if none is given). e.g.
  173.     TURBO a4:workfile.inc b2:mainfileì
  174. ì
  175. path for TURBO.MSG, TURBO.OVR, *.COM (eXecute):
  176.  
  177. Without the patch, Turbo searched on the (supplied or) current drive,
  178. then on the drive that was current when Turbo was started, and then
  179. on drive A (all on the current user).
  180. Now Turbo searches on the (supplied or) current DU, then on the DU
  181. that was current when Turbo was started, and then on an installable DU.
  182.  
  183. DU form support:
  184.  
  185. Here too, you can support a user anywhere you like.
  186. The editor had an input line for the filenames that was only 15 char-
  187. acters long. I increased that string by one while decreasing the
  188. string for the options (e.g. when searching/replacing). The latter is
  189. now only 9 characters long instead of 10.
  190.  
  191. saving workfile:
  192.  
  193. When typing blindly, it sometimes happened to a friend of mine that
  194. he pressed "W" (new workfile) and Turbo asked him "modified. Save?".
  195. Not seeing this, he entered his new filename. Unluckily for him, his
  196. name contained an "N" and so his modifications were lost ...
  197. I have put an ASCII BELL character in that message now, so he knows
  198. when it's time to look what's going on.
  199.  
  200.  
  201.         4. New overlay
  202.  
  203. The old one was so hopelessly buggy ... When I tried the old one, nearly
  204. 2/3 of the programs didn't execute properly, a lot of times my machine
  205. crashed. So I wrote a new one. It needs a bit more space on disk and in
  206. memory, but it runs ok as far as I could test it.
  207. It mimics a BDOS and BIOS interface to protect its code, and it supports
  208. user areas. When failing to find TURBO.COM, it does not only ask the user
  209. about retrying, but it also offers the possiblity to abort.
  210. The old overlay was really bad in this respect, because it constantly
  211. asked me to "insert disk with TURBO.COM in drive A:", which is my Ramdisk,
  212. sigh! I always had to reboot when I accidently hit the "X" key.
  213. Warning: this new overlay is designed to work with the patched TURBO.COM
  214. only! While probably nothing fatal will happen, I don't recommend using it
  215. with the unpatched TURBO.COM. Using the old overlay with the patched TURBO
  216. works, but why would you want to do this?
  217.  
  218.  
  219.         5. Installation
  220.  
  221. First, compile the public domain general installation program TheInst.
  222.  
  223. Determine what version of Turbo Pascal you have. Versions 3.00A and
  224. 3.01A are supported. After extracting the library, you have to rename some
  225. files according to your version: the files ending with "0" are for version
  226. 3.00A, the ones ending with "1" are for version 3.01A, e.g. for v3.00A:
  227.  
  228.     ren newchain.inc=newchai0.inc
  229.     era newchai1.inc
  230.     ...
  231.  
  232. Now we need TURBO.COM: we need a "fresh" one, i.e. it has to be installed
  233. properly (with e.g. TINST), but no patches are allowed at this point!
  234. (see discussion about compatibility with other patches below).
  235. Apply patches by using mload:
  236.  
  237.     mload turbo.com,tpatch.hex
  238.  
  239. I'm not sure if using TINST after applying my patch is safe; better don't
  240. do it. If you must, don't change the terminal name! This string isn't used
  241. anymore and there is some code at this place instead.
  242. Install the patched TURBO.COM:
  243.  
  244.     theinst turbo
  245.  
  246. Use the supplied TURBO.OVR and TURBO.MSG instead of yours.
  247. Install the new TURBO.OVR:
  248.  
  249.     theinst turbovr
  250.  
  251. Now compile COMTOCHN and CHAIN with the new TURBO.COM.
  252. Install CHAIN.COM:
  253.  
  254.     theinst chain
  255.  
  256.  
  257.         6. Compatiblity with other patches
  258.  
  259. I badly needed every bit of space for my patches, thatswhy I asked every-
  260. body about his wishes and included them. I hope your favourite patches are
  261. included too. Most of the patches I know of use the space at the beginning
  262. of the runtime library. Unfortunately, nothing is free there anymore, so
  263. they are not compatible. I included the source for my patches (sorry, the
  264. comments are in german) so you can easily check if there is a conflict in
  265. affected locations.
  266.  
  267. Definitely incompatible:        affected address(es) (V3.00A)
  268. - break entry at 30h instead of 38h
  269.   for Schneider/Amstrad computers    0372h,0378h
  270. - no opening menue            2177h-2179h
  271. - don't ask for error message        222Ch-222Eh
  272.  
  273. Definitely compatible:
  274. - assign with wildcards            03F3h
  275. - UpCase for german umlaut characters    04AAh
  276. - sign of the MOD function        0745h-074Bh
  277. - no backup file            268Bh
  278. - other extension            2D2Bh-2D2Eh
  279.  
  280.  
  281. If you have problems, suggestions, comments, ... feel free to contact me.
  282.