home *** CD-ROM | disk | FTP | other *** search
-
- Patches for Turbo Pascal V3.00A and V3.01A
- ------------------------------------------
-
- Release: January 9, 1993 (finally!)
- Author: Herbert Oppmann
- Address: Drausnickstrasse 29, W8520 Erlangen, Germany
- Phone: +49 9131 55018
- eMail: htoppman@cip.informatik.uni-erlangen.de
-
-
- 1. Introduction and overall design
-
- While Turbo Pascal is a very fine product I really like to work with,
- it hasn't been upgraded for a while now (and will probably never be).
- Over time I noticed several bugs and limitations that annoyed me more
- and more. And, with ZCPR3, I really missed the support for user areas.
-
- So I decided to do something against it, and talked with other Turbo
- Pascal users here in Germany and compiled a "wish list". Astonishingly
- for me, this list grew quite large, and I soon realized that it was
- unfeasable to achive the goal just by layering some new code over the
- old one with e.g. some include file. I needed to change some intrinsic
- things.
-
- As I don't have the copyright on Turbo Pascal, it was impossible to
- distribute a modified version of it, so the only way left was writing
- a patch. This was not easy, because I needed a lot of information
- about the internal workings, and squeezing something into the very
- limited space sometimes was more work than to implement the feature.
- From the first ideas to this release version, it took me more than a
- year ...
-
- While addressing my needs (and the needs of my friends), I took care
- to retain everything machine-independant and backward-compatible, and
- to make things installable even when I didn't needed the flexibility.
-
- Now I have to explain something about COM and CHN files:
- The only difference between compiling to a COM file or to a CHN file
- is that the runtime library is omitted in the latter case. While you
- can run COM files directly from the CP/M command line, you need to
- run a (COM) program first that "chains" to your desired CHN file.
- Such a program (usually CHAIN.COM) is a Turbo Pascal program, that in
- fact does little more than getting the filename of the desired CHN file
- from the command line and then calling the library procedure "chain" that
- loads the CHN file directly after the memory image of the runtime libary,
- thus overloading the current Pascal program. That way, the runtime library
- is inherited from the CHAIN program.
-
- So, if I patch the runtime library of CHAIN.COM, _all_ CHN files profit
- without the need to recompile them (if that is possible, i.e. if you
- have the source for them). To allow for even more old programs to profit
- of the new runtime library, I wrote a small program (COMTOCHN) that cuts
- away the runtime library of your old Turbo Pascal COM files, thus making
- them CHN files. This does not only save a lot of space, it has the big
- advantage that any changes in installation (terminal or my patch) will
- immediately apply to all your CHN files, or, you could have more than
- one CHAIN program with different installation.
-
- The patches to the runtime library need to be self-sufficient. But the
- other patches I did to the editor and compiler rely on the patched run-
- time library. So I put all the patches together in one file that is to be
- applied to TURBO.COM. Now, when you compile a program to a COM file, the
- patched runtime library that is within TURBO.COM is inherited by your
- program.
-
-
- 2. Patches for the runtime library
-
- ZCPR3 support:
-
- The beginning of the runtime library, i.e. the beginning of all Turbo
- Pascal COM files (including the compiler itself) now has a ZCPR3 type
- 1 header. When running under ZCPR3 the address of the environment de-
- scriptor is stored in the header (zero means "not available"):
- VAR z3ptr : ^z3env absolute $109;
- The include file Z3ENV.INC contains this line and the definition of the
- environment descriptor structure (incomplete). Include file NAMEDDIR.INC
- serves as a good example on how to use the environment descriptor from
- withing a Turbo Pascal program.
-
-
- line editor:
-
- The built-in line editor of Turbo is somewhat better than the one CP/M
- 2.2 had, but at least users of a Memotech computer have a far better
- line editor in their system. I added an installable option to use the
- BDOS line editor function 10 instead of the built-in one.
- Warning: if you use the BDOS function and press a ^C at the beginning
- of the line, the program is aborted. This cannot be caught in your Turbo
- Pascal program via a user supplied error handler.
-
-
- command line:
-
- To access the command line from within your Turbo Pascal program, there
- are two library functions "ParamCount" and "ParamStr". Because of Turbo's
- variables residing between $B0 and $FF, the length of the command line
- was limited to 30 characters. The rest was overwritten while initializing.
- Now the command line is copied into the heap space before the initializa-
- tion, thus allowing for the maximum of 126 characters.
- Warning: this will reduce the available data space by a maximum of 128
- byte. This reduction occurs at runtime, so when compiling, it doesn't
- show. Don't lower the end address too much.
-
- terminal reset string: (upon special request)
-
- If you have a program that modifies your terminal setting, it has been
- quite difficult to ensure its restauration under all circumstances.
- You had to supply your own error handler, or re-rout the warmboot entry.
- To facilitate this there is now an installable terminal reset string
- that is issued everytime the program ends, no matter why.
- Warning: if you selected the BDOS line editor and press ^C at the be-
- ginning of the line, the program is aborted without sending this reset
- string.
-
- error in Int2Real:
-
- The routine in the runtime library that converts integer numbers to
- real numbers has a bug: integer $8000 causes an endless loop!
- Astonishingly, Turbo Pascal version 2 was ok. Some ignorant at Borland
- deleted two opcodes that treated this special case ...
- Is now fixed.
-
- DU form support:
-
- Now Turbo Pascal supports DU form! Everywhere you were able to enter
- a filename with a drive designator you can now enter a user too!
- Ironically, I had problems with old programs that handle the user
- itself. After some thought, I was able to come up with a solution.
- There is an include file NAMEDDIR.INC that adds DIR form support
- for your own programs. Sorry, but the limited space didn't allow to
- include the DIR form into the patch.
- Warning: some old programs store filenames in strings that are only
- e.g. 14 chars long. Drive and user and long filename doesn't fit in
- there! If you have problems, use a shorter filename (rename the file)
- or recompile the program with bigger strings.
-
- Overlays:
-
- Overlay≤ are searched on the current user on the drive supplied
- via the procedure OvrDrive. Now you can install a DU where Turbo looks
- for the overlay after this search has failed.ì
-
- Chain/Execute:
-
- Space for patches was very scarce in the runtime library. Either I had
- to give up most of my wishes, or I had to remove something to gain some
- space. After some investigation I decided to remove the Chain and Execute
- procedures, because a) I hope they are used infrequently and b) I wanted
- to rewrite them anyway. Using the old entry points now results in a run-
- time error CE. If you need Chain or Execute, use the new, much more
- sophisticated version in the include file NEWCHAIN.INC.
-
-
- 3. Patches for the editor/compiler
-
- ZCPR3 support:
-
- When compiling to a COM file, the runtime library is first copied from
- the memory image of TURBO.COM. The address of the environment descriptor
- that is possibly stored in the header musn't be copied to the COM file!
- It must be filled with zero instead.
-
- TURBO startup:
-
- To get some badly needed space for the patches in the compiler
- the opening menu had to be removed. Whether the error message file
- should be read in is now installable.
- The command line is evaluated, you may now optionally provide a workfile
- name and a main file name (of course in DU form, an extension of PAS is
- assumed if none is given). e.g.
- TURBO a4:workfile.inc b2:mainfileì
- ì
- path for TURBO.MSG, TURBO.OVR, *.COM (eXecute):
-
- Without the patch, Turbo searched on the (supplied or) current drive,
- then on the drive that was current when Turbo was started, and then
- on drive A (all on the current user).
- Now Turbo searches on the (supplied or) current DU, then on the DU
- that was current when Turbo was started, and then on an installable DU.
-
- DU form support:
-
- Here too, you can support a user anywhere you like.
- The editor had an input line for the filenames that was only 15 char-
- acters long. I increased that string by one while decreasing the
- string for the options (e.g. when searching/replacing). The latter is
- now only 9 characters long instead of 10.
-
- saving workfile:
-
- When typing blindly, it sometimes happened to a friend of mine that
- he pressed "W" (new workfile) and Turbo asked him "modified. Save?".
- Not seeing this, he entered his new filename. Unluckily for him, his
- name contained an "N" and so his modifications were lost ...
- I have put an ASCII BELL character in that message now, so he knows
- when it's time to look what's going on.
-
-
- 4. New overlay
-
- The old one was so hopelessly buggy ... When I tried the old one, nearly
- 2/3 of the programs didn't execute properly, a lot of times my machine
- crashed. So I wrote a new one. It needs a bit more space on disk and in
- memory, but it runs ok as far as I could test it.
- It mimics a BDOS and BIOS interface to protect its code, and it supports
- user areas. When failing to find TURBO.COM, it does not only ask the user
- about retrying, but it also offers the possiblity to abort.
- The old overlay was really bad in this respect, because it constantly
- asked me to "insert disk with TURBO.COM in drive A:", which is my Ramdisk,
- sigh! I always had to reboot when I accidently hit the "X" key.
- Warning: this new overlay is designed to work with the patched TURBO.COM
- only! While probably nothing fatal will happen, I don't recommend using it
- with the unpatched TURBO.COM. Using the old overlay with the patched TURBO
- works, but why would you want to do this?
-
-
- 5. Installation
-
- First, compile the public domain general installation program TheInst.
-
- Determine what version of Turbo Pascal you have. Versions 3.00A and
- 3.01A are supported. After extracting the library, you have to rename some
- files according to your version: the files ending with "0" are for version
- 3.00A, the ones ending with "1" are for version 3.01A, e.g. for v3.00A:
-
- ren newchain.inc=newchai0.inc
- era newchai1.inc
- ...
-
- Now we need TURBO.COM: we need a "fresh" one, i.e. it has to be installed
- properly (with e.g. TINST), but no patches are allowed at this point!
- (see discussion about compatibility with other patches below).
- Apply patches by using mload:
-
- mload turbo.com,tpatch.hex
-
- I'm not sure if using TINST after applying my patch is safe; better don't
- do it. If you must, don't change the terminal name! This string isn't used
- anymore and there is some code at this place instead.
- Install the patched TURBO.COM:
-
- theinst turbo
-
- Use the supplied TURBO.OVR and TURBO.MSG instead of yours.
- Install the new TURBO.OVR:
-
- theinst turbovr
-
- Now compile COMTOCHN and CHAIN with the new TURBO.COM.
- Install CHAIN.COM:
-
- theinst chain
-
-
- 6. Compatiblity with other patches
-
- I badly needed every bit of space for my patches, thatswhy I asked every-
- body about his wishes and included them. I hope your favourite patches are
- included too. Most of the patches I know of use the space at the beginning
- of the runtime library. Unfortunately, nothing is free there anymore, so
- they are not compatible. I included the source for my patches (sorry, the
- comments are in german) so you can easily check if there is a conflict in
- affected locations.
-
- Definitely incompatible: affected address(es) (V3.00A)
- - break entry at 30h instead of 38h
- for Schneider/Amstrad computers 0372h,0378h
- - no opening menue 2177h-2179h
- - don't ask for error message 222Ch-222Eh
-
- Definitely compatible:
- - assign with wildcards 03F3h
- - UpCase for german umlaut characters 04AAh
- - sign of the MOD function 0745h-074Bh
- - no backup file 268Bh
- - other extension 2D2Bh-2D2Eh
-
-
- If you have problems, suggestions, comments, ... feel free to contact me.