Miscellaneous code

Turbo Pascal Bug

There is a bug in the standard Turbo Pascal CRT unit. This bug causes a "Divide by zero" error on Pentium II and above. Any program that uses the CRT unit crashes. If, like many people, you only use CRT for "ClrScr", "GotoXY", "Delay", "Readkey" and "KeyPressed", then you can use my Small CRT replacement unit instead. It doesn't have the bug... until computers become 30,000 times faster than their current speed.

To download the Pascal source code (3k), click here.

Delay routine

I was told that Microsoft C doesn't have a "delay" routine. Since I don't use MS-C, I can't check this. Here, however, is a delay routine.

Add #include "delay.h" to the example programs and replace all references to delay with MilliDelay. This file contains MilliDelay (long n) and MicroDelay (long m) which wait for n milliseconds or m microseconds respectively.

To download the C source code (0k), click here.

For Pascal programmers, the MicroDelay routines is also available, as TurboPascal's delay only has a millisecond resolution

To download the Pascal source code (0k), click here.

Extended Memory Routines

A Turbo Pascal unit that enables the direct use of XMS (extended) memory in DOS programs.

To download the Pascal source code (3k), click here.
To download the C(++) source code (3k), click here.

Keyboard handler extension

Source code to trap cursor key presses and releases. This is allows for continuous movement of the player character instead of the repeat generated by the BIOS keyboard handler.

To download the Pascal source code (2k), click here.
To download the DJGPP/C(++) source code (2k), click here.

Many people have requested a list of scan codes for all the keys on the keyboard to be used with the replacement keyboard handler, so here it is.

To download the text file (4k), click here.

Mouse routines

Source code showing how to read information from the mouse.

To download the Pascal source code (1k), click here.
To download the DJGPP/C(++) source code (1k), click here.

Serial communication routines

Source code demonstrating how to send and receive data through a serial (COM) port.

To download the Pascal source code (3k), click here.
To download the C/C++ source code (3k), click here.

Timer routines

Source code demonstrating how to intercept and speed up the system timer.

To download the Pascal source code (1k), click here.
To download the C/C++ source code (1k), click here.