Tips on developing programs in Turbo Pascal 3 on the Adam

Post your CP/M & TDOS questions here
Post Reply
User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Tips on developing programs in Turbo Pascal 3 on the Adam

Post by Wmaalouli » Fri Nov 06, 2020 5:48 pm

So I just finished a utility program to help with character definition on the Adam under CP/M using Turbo Pascal 3 with the bitmap graphic extensions, and I thought I'd share some tips on that process. I'll be making a separate post about that program in the next couple of days.

- The integrated editor that comes with TP3 does not work well on the Adam, particularly the vertical scrolling function, which makes it pretty useless, so I use an external 40-col editor (Adamed) instead. However, when the compiler encounters an error in your source code, it will give you a meaningful error message. If the message is longer than 32 columns, press CTRL-<right arrow> to scroll to the right. Press ESC and you will be taken to the exact place where the error occurred, so the integrated editor is still very useful in this regard. Once you know where the error is in your code, press CTRL-KD to exit the editor then Q to exit TP3. You can then load your external editor and edit your source accordingly.

- Unless your program is very small, you need to go into the TP3 Options menu and change the memory model to COM, which means that compilation will take place directly on disk and not in RAM, otherwise you will quickly run out of memory and you will get a compiler error. The Options menu is accessed by pressing O at the TP3 main menu, then pressing C to switch to the COM model, and finally pressing Q to go back to the main menu.

- I strongly recommend you have a separate disk for your program source and compiled code instead of working with the TP3 disk which has limited free space on it and in order to avoid potential disk corruption. This does mean that you need 2 disk drives available, although you could use a DDP drive and a disk drive or even 2 DDP drives for that purpose, assuming you have the requisite patience!

- You need to keep your source code at no more than 15K in size otherwise TP3 will choke on it. The way to go around this limitation is simply to break up your source into as many chunks as you need keeping each chunk within the 15K limit and using the INCLUDE compiler directive to bring all the parts together.

- The compiled program cannot exceed 128 records or about 16K, otherwise your program will start acting erratically (I have not seen this on other systems, so it might be a quirk specific to the Adam). The solution here is to have a master program which stays within that limit and has the essential routines that need to be in memory most of the time. Break up the rest of the program into procedures and functions and use the OVERLAY compiler directive for each. This means that only the master program will continuously remain in memory while the overlaid routines will switch in and out of memory when called and are loaded from disk on an as needed basis. This process requires planning because a routine cannot call another routine belonging to the same overlay file because the latter will simply overwrite the former and your program will crash. The benefit here is that your program can effectively be as large as you have disk space available for it, which is one of the main attractions of TP3.

- The bitmap graphic extensions use a lot of memory, so I suggest culling out the un-needed procedures from the different graphic modules and overlaying most of the remaining one, being mindful of the overlapping limitation mentioned in the previous paragraph. For example, if you don't need to draw circles, simply delete that procedure from the BMPDRAW.PAS module.

- Remember that once you invoke the bitmap graphic extensions from within your program, everything you put on screen is actually being drawn on the bitmap screen. Therefore, the standard WRITE and READ pascal functions for output and input will NOT work! While the extensions do give you the ability to put text on screen, there is no built in facility to get direct text input except with the GETKEY function which returns the ASCII code of the key pressed. However, you can relatively easily create your own input routine based around the GETKEY function which you can tailor to your program's specific needs without the need for assembly support. I do just that in my character definition program.

- Finally, many of the bitmap graphic procedures are relatively slow, particularly the 42 column text procedure because the each letter here is being drawn pixel by pixel. On the other hand, 42 column text is much more flexible in terms of placement and looks much better than the standard 32 column text. I used 42 col text almost exclusively in my program for esthetic reasons, but then speed is not a requirement in that case :)

One bit of advice: read the TP3 manual! Only about half of it is relevant to the CP/M environment, so it's not as bad as you think and it is very informative particularly regarding the overlay facility. It's available online and in print on Amazon for around $5. I am also always available to answer any questions you might have on this forum regarding this process.

User avatar
joltguy
Posts: 91
Joined: Wed Aug 21, 2019 5:17 am
Location: Toronto, Canada
Contact:

Re: Tips on developing programs in Turbo Pascal 3 on the Adam

Post by joltguy » Fri Nov 06, 2020 11:41 pm

This is really useful information. Thanks for sharing!

User avatar
Milli
Site Admin
Posts: 224
Joined: Fri Jul 19, 2019 3:13 pm
Location: Beaver Falls PA
Contact:

Re: Tips on developing programs in Turbo Pascal 3 on the Adam

Post by Milli » Sat Nov 07, 2020 7:23 am

Yes thank you for this! Have you done any speed tests? How fast is TP versus ASM versus compiled basic etc?
Milli

User avatar
Wmaalouli
Posts: 155
Joined: Sat Jul 20, 2019 2:09 pm

Re: Tips on developing programs in Turbo Pascal 3 on the Adam

Post by Wmaalouli » Sat Nov 07, 2020 12:33 pm

No I have not, but I suspect a TP3 compiled program, without the graphic extensions, will still be somewhat slower than pure assembly, but much faster than Basic.

Post Reply