24: How can I link
graphics drivers directly into my executable?
A: This is a
complicated, yet a very useful task, because then you
won't need any separate graphics drivers (or fonts) to go
separately
along with your program. Unfortunately, Turbo Pascal
documentation
on this task is a bit confusing.
1) The very first step is to get the necessary files from the
Turbo Pascal disks to your working directory. To start with, you'll
need binobj.exe and all the .bgi files.
2) Run the following commands (best to place them in a batch,
call it e.g. makeobj.bat):
binobj cga.bgi cga CGADriverProc
binobj egavga.bgi egavga EGAVGADriverProc
binobj herc.bgi herc HercDriverProc
binobj pc3270.bgi pc3270 PC3270DriverProc
binobj att.bgi att ATTDriverProc
rem binobj ibm8514.bgi 8514 IBM8514DriverProc
3) Get drivers.pas from the Turbo Pascal disk and compile it with
Turbo Pascal. Now you have a drivers.tpu unit which contains all
the
graphics drivers.
4) Now you won't need the .bgi and the .obj files any more. You
may delete them from your working directory.
5) Write your graphics program in the usual manner. But before
putting your program in the graphics mode use the following
procedure if you want to link e.g. the EGAVGA graphics driver
directly into your executable. (Link just the driver(s) you'll need,
since the drivers take up a lot of space.)
uses Graph, Drivers;
:
procedure EGAVGA2EXE;
begin
if RegisterBGIdriver(@EGAVGADriverProc) < 0 then
begin
writeln ('EGA/VGA: ', GraphErrorMsg(GraphResult));
halt(1);
end;
end; (* egavga2exe *)
:
Linking the .bgi and .chr drivers is also covered in Swan (1989),
Mastering Turbo Pascal 5.5 pp. 355-359 and Mitchell (1993),
Borland
Pascal Developer's Guide , pp. 221-229.
Incidentally, although this is a slightly different matter, you
can link any data material into your executable. See Stephen
O'Brien, (1988), Turbo Pascal, Advanced Programmer's Guide,
pp. 31 -
35 for more details.