4 #include <fastgraf.h>
\r
8 #include "fx.h" /* FOR FADING */
\r
9 #include "version.h" /* FOR HEADER */
\r
11 extern int far *topography; /* BACKGROUND TILE LIST (ARRAY) */
\r
12 extern int far *terrain; /* FOREGROUND TILE LIST (ARRAY) */
\r
13 extern int viewpage; /* CURRENTLY VIEWED PAGE */
\r
15 int startup_vmode=-1; /* STARTUP VIDEO MODE TO RETURN TO AT PROGRAM END */
\r
19 * Initializes/Sets-up the video mode and paging.
\r
22 void init_video (void)
\r
24 /* INITIALIZE VIDEO MODE */
\r
25 if (fg_testmode (VMODE, VPAGES)==0)
\r
27 printf ("Sorry, your video card does not support mode %d.\n", VMODE);
\r
31 startup_vmode=fg_getmode();
\r
36 /* SETUP SPRITE IMAGES */
\r
37 fg_setpage (TILEPAGE);
\r
39 fg_showgif (IMAGES, 0);
\r
40 fg_setpage (viewpage);
\r
42 fg_tcdefine (0,1); /* TREAT COLOR 0 AS TRANSPARENT */
\r
47 * "Officially" shuts down the program. Restores video, frees
\r
48 * allocated data including fonts, unhooks Sound Blaster,
\r
49 * and (optionally) exits with a message and errorcode
\r
52 void program_shutdown (char *msg, int errcode)
\r
54 fg_kbinit(0); /* UNLATCH LOW-LEVEL KEYBOARD HANDLER */
\r
57 if (topography!=NULL) farfree (topography);
\r
58 if (terrain!=NULL) farfree (terrain);
\r
60 /* RESTORE ORIGINAL VIDEO MODE TO USER */
\r
61 if (startup_vmode!=-1)
\r
64 fg_setmode (startup_vmode);
\r
68 /* FREE FONTS AND SOUND BLASTER SOMEWHERE IN HERE */
\r
70 printf (HEADER); /* PRINT HEADER */
\r
72 /* REPORT MESSAGE */
\r
74 printf ("ROADS: %s\n", msg);
\r
76 /* QUIT WITH ERROR CODE, IF SUPPLIED ONE */
\r
80 /* OTHERWISE, RETURN TO CALLER WHO WILL HANDLE EXITING */
\r
86 * Initialize dynamic data, which is freed with program_shutdown()
\r
89 void init_data (void)
\r
91 topography=farcalloc (WORLD_TILES_TOTAL,sizeof (int));
\r
92 terrain=farcalloc (WORLD_TILES_TOTAL,sizeof (int));
\r
94 if (topography==NULL || terrain==NULL)
\r
95 program_shutdown ("Not enough memory -- It's not my fault, I swear!", 1);
\r