Compiling a FOSSIL aware 16bit DOS executable with FPC
Recently Captain Hood of Black Flag BBS asked if I could throw together a quick door that could run under Oblivion/2 for displaying ANSI scrollers in a semi slowed down fashion. You see, back in the day the speed you saw an ANSI render was essentially that of your modem – 9600bps for example.
So what the hell, why not do this in Pascal?! I downloaded Free Pascal, built the 8086-msdos cross compiler and punched in some code.
Here are the steps I took if anyone out there in the world needs to write a 8086 16bit DOS application in Pascal :)
Note that these instructions are from from a Elementary OS Freya x86_64 box. YMMV.
Prep work
Install dependencies
sudo apt-get install nasm subversion
FPC
To cross compile FPC, you will need FPC. I used the .dep from Lazarus on Sourceforge (You should only need fpc*2.6.4-**amd64.deb)
Build the 8086-msdos cross compiler
(This is covered more extensively in the FPC wiki)
Checkout the FPC source from TRUNK:
svn checkout http://svn.freepascal.org/svn/fpc/trunk fpc
Build:
make clean all OS_TARGET=msdos CPU_TARGET=i8086 OPT=”-CX -XXs” CROSSOPT=-WmSmall BINUTILSPREFIX= PP=/usr/bin/ppcx64
Install:
make crossinstall OS_SOURCE=linux CPU_SOURCE=i386 OS_TARGET=msdos CPU_TARGET=i8086 PP=compiler/ppcross8086 CROSSOPT=-WmSmall BINUTILSPREFIX= INSTALL_PREFIX=/home/
/ /fpc-i8086/snapshot/small OPT=”-CX -XXs”
Be sure to replace the value of INSTALL_PREFIX
with an appropriate path!
1.
Repeat steps #2 & #3 replacing -WmSmall
with the various models you wish: Medium, Large, etc. See the FPC wiki for details.
2.
Update your fpc.cfg
file. The default location is /etc/fpc.cfg. Make the following changes:
Add:
#ifdef cpui8086
-CX
-XX
-XP
#endif
Replace:
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
with:
#IFDEF CPUI8086
-Fu/home/<user>/<where>/fpc-i8086/snapshot/$fpcmemorymodel/lib/fpc/$fpcversion/units/$fpctarget
-Fu/home/<user>/<where>/fpc-i8086/snapshot/$fpcmemorymodel/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/home/<user>/<where>/fpc-i8086/snapshot/$fpcmemorymodel/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ELSE
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
FOSSIL support
There is a nice Pascal package for DOS FOSSIL support called Ele Communications Kit 1.2. You can find it on the BBS archive site. Search for ELECOM12.ZIP elsewhere.
I won’t get into the details of the library itself – there is an EXAMPLE.PAS that makes it fairly clear: Open a COM port that FOSSIL is bound to, do I/O, close it. Nothing fancy.
Compile!
After you have written yourself a nice little FOSSIL aware piece of source, compile as such:
fpc-i8086/ppcross8086 -WmHuge -Fu./ELEC/ SOURCE.PAS
Again, replace -WmHuge
with the model of your choice. The cross compiler (ppcross8086
) is found under the path you specified with INSTALL_PREFIX
of course.
SLOWMO!
As for myself, I created something super simple called SLOWMO! It’s now released under Acidic modding for giggles:
Enjoy!