
Warehouse is finished, but it lives inside Turbo Pascal: to play it you start TURBO, answer its question, load WARE and press R. S6 showed the way out - compiling to a .COM file, a program the Einstein runs straight from the 0: prompt, as it runs TURBO itself. This section does that for the game, and looks at what changes.
Turbo compiles to memory unless it is told otherwise. O, at the main menu, shows the compiler options; C there chooses Com-file, and Q goes back to the menu. From then on C writes the compiled program to the disc, as a .COM with the work file's name:
Compiling --> A:WARE.COM
588 lines
Code: 6763 bytes (1FC9-3A34)
Free: 43849 bytes (3A35-E57E)
Data: 955 bytes (E57F-E93A)
The option lasts until Turbo is left; the next TURBO starts in Memory mode again.
R still works in Com-file mode: it runs the new .COM, and when the program ends, Turbo loads itself back in - Loading A:TURBO.MSG, Loading A:WARE.PAS - because the program has used the memory Turbo was in.
Quit Turbo with Q, and at the 0: prompt type
WARE
and the title appears. No Turbo, no work file, no R: the game is a program of the Einstein's, like any other. It reads and writes LEVELS.DAT exactly as before - it must be on the same disc - and if the file is not there, the game makes it, as it did the very first time.
Borland's manual explains that a .COM carries the parts of Turbo that every program needs; S6's HELLO.COM was 8,064 bytes for 57 bytes of code. WARE.COM takes 16k of the disc.
Look at Free in the two ways of compiling the same program:
| Code | Free | |
|---|---|---|
| To memory | 6,763 bytes | 8,961 bytes |
To WARE.COM | 6,763 bytes | 43,849 bytes |
The code is the same. What differs is what else is in memory. Compiled to memory, the program shares it with Turbo's editor, the compiler and the whole of your source text - the code starts at AB57, just after the text. As a .COM it starts at 1FC9, with the machine to itself, and the free memory grows nearly five times over.
There is no new code. With WARE as the work file:
O, then C - the arrow moves to Com-file - then Q.C. Turbo compiles to WARE.COM.Q to leave Turbo.0:, WARE and ENTER.Starting from
WARE from S36, saved. Turbo started, Y, W WARE.
What you should see
The compiler's report ending --> A:WARE.COM and the larger Free figure; then, at 0:, the title screen of the game, and the game itself, just as it played inside Turbo. Q at the end of the game brings back 0:.
Com-file chosen, press R instead of C. Play, then quit the game. What does Turbo do next?WARE1, from S27, to a .COM and run it at 0:. What does a program with no key loop do when it is run on its own?0:, ERA LEVELS.DAT (and Y), then WARE. Are the levels still there - and the best scores?37.1 Compile LEVLIST from exercise 31.2 to a .COM, and run it at 0:.
37.2 How much of the disc does WARE.COM take? Use D before and after compiling it.
37.3 Compile Warehouse to memory and to a .COM, and write down Code and Free for each. Which grows, and why does the other stay the same?
Worked solutions are in Appendix II.
| Symptom | Cause |
|---|---|
C compiles, but there is no .COM on the disc | Turbo is still in Memory mode. O, C, Q first. |
WARE at 0: says No File | WARE.COM was not made, or it is on another disc. |
| The best scores have gone | LEVELS.DAT was erased, or the game was run on a disc without it and made a new one. |
| The disc is full | .COM files are big. ERA the ones you do not need - every stage's source is still there to compile again. |
O, C switches Turbo to Com-file mode; C then writes WARE.COM. At 0:, WARE runs the game without Turbo, reading and writing LEVELS.DAT as before. The code is the same size either way, but a .COM has the machine to itself, and Warehouse's free memory goes from about 9,000 bytes to about 44,000.
S38, Reading A Real Program - MicroCalc, the spreadsheet Borland shipped with Turbo Pascal, compiled from its source on your disc.