]> icculus.org git repositories - btb/d2x.git/blob - main/gamefont.c
use portable rand function (fixes #1118)
[btb/d2x.git] / main / gamefont.c
1 /* $Id: gamefont.c,v 1.4 2003-10-10 09:36:35 btb Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Fonts for the game.
18  *
19  * Old Log:
20  * Revision 1.2  1995/08/18  10:23:25  allender
21  * remove refernce to big font -- add PC small font for pixel
22  * doubling display
23  *
24  * Revision 1.1  1995/05/16  15:25:22  allender
25  * Initial revision
26  *
27  * Revision 2.0  1995/02/27  11:30:14  john
28  * New version 2.0, which has no anonymous unions, builds with
29  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
30  *
31  * Revision 1.8  1994/11/18  16:41:39  adam
32  * trimmed some meat
33  *
34  * Revision 1.7  1994/11/17  13:07:11  adam
35  * removed unused font
36  *
37  * Revision 1.6  1994/11/03  21:36:12  john
38  * Added code for credit fonts.
39  *
40  * Revision 1.5  1994/08/17  20:20:02  matt
41  * Took out alternate-color versions of font3, since this is a mono font
42  *
43  * Revision 1.4  1994/08/12  12:03:44  adam
44  * tweaked fonts.
45  *
46  * Revision 1.3  1994/08/11  12:43:40  adam
47  * changed font filenames
48  *
49  * Revision 1.2  1994/08/10  19:57:15  john
50  * Changed font stuff; Took out old menu; messed up lots of
51  * other stuff like game sequencing messages, etc.
52  *
53  * Revision 1.1  1994/08/10  17:20:09  john
54  * Initial revision
55  *
56  *
57  */
58
59 #ifdef HAVE_CONFIG_H
60 #include <conf.h>
61 #endif
62
63 #ifdef RCS
64 static char rcsid[] = "$Id: gamefont.c,v 1.4 2003-10-10 09:36:35 btb Exp $";
65 #endif
66
67 #include <stdlib.h>
68
69 #include "inferno.h"
70 #include "gr.h"
71 #include "gamefont.h"
72
73 // if 1, use high-res versions of fonts
74 int FontHires = 0;
75 int FontHiresAvailable = 0;
76
77 char * Gamefont_filenames[] = { "font1-1.fnt",      // Font 0
78                                 "font1-1h.fnt",     // Font 0 High-res
79                                 "font2-1.fnt",      // Font 1
80                                 "font2-1h.fnt",     // Font 1 High-res
81                                 "font2-2.fnt",      // Font 2
82                                 "font2-2h.fnt",     // Font 2 High-res
83                                 "font2-3.fnt",      // Font 3
84                                 "font2-3h.fnt",     // Font 3 High-res
85                                 "font3-1.fnt",      // Font 4
86                                 "font3-1h.fnt",     // Font 4 High-res
87                               };
88
89 grs_font *Gamefonts[MAX_FONTS];
90
91 int Gamefont_installed = 0;
92
93 void gamefont_init()
94 {
95         int i;
96
97         if (Gamefont_installed)
98                 return;
99         Gamefont_installed = 1;
100         FontHiresAvailable = 1;
101
102         for (i = 0; i < MAX_FONTS; i += 2)
103                 Gamefonts[i] = gr_init_font(Gamefont_filenames[i]);
104         for (i = 1; i < MAX_FONTS; i += 2)
105         {
106                 Gamefonts[i] = gr_init_font(Gamefont_filenames[i]);
107                 if (!Gamefonts[i])
108                         FontHiresAvailable = 0;
109         }
110
111         atexit(gamefont_close);
112 }
113
114
115 void gamefont_close()
116 {
117         int i;
118
119         if (!Gamefont_installed)
120                 return;
121         Gamefont_installed = 0;
122
123         for (i = 0; i < MAX_FONTS; i++)
124         {
125                 gr_close_font(Gamefonts[i]);
126                 Gamefonts[i] = NULL;
127         }
128 }