summaryrefslogtreecommitdiff
path: root/apps/plugins/clock/clock_menu.c
blob: ed0027305b1ac80f932b4f34dc68769ba7d81617 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2003 Zakk Roberts
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#include "clock.h"
#include "clock_bitmaps.h"
#include "clock_settings.h"
#include "lib/playback_control.h"

/* Option structs (possible selections per each option) */
static const struct opt_items noyes_text[] = {
    { "No", -1 },
    { "Yes", -1 }
};

static const struct opt_items backlight_settings_text[] = {
    { "Always Off", -1 },
    { "Use Rockbox Setting", -1 },
    { "Always On", -1 }
};

static const struct opt_items idle_poweroff_text[] = {
    { "Disabled", -1 },
    { "Enabled", -1 }
};

static const struct opt_items date_format_text[] = {
    { "No date", -1 },
    { "US (M-D-Y)", -1 },
    { "European (D-M-Y)", -1 },
    { "Japanese (Y-M-D)", -1 },
};

static const struct opt_items hour_format_text[] = {
    { "24-Hour", -1 },
    { "12-Hour", -1 }
};

/***************
 * Select a mode, returs true when the mode has been selected
 * (we go back to clock display then)
 **************/
bool menu_mode_selector(void){
    MENUITEM_STRINGLIST(menu,"Mode Selector",NULL, "Analog",
                        "Digital", "Binary");
    if(rb->do_menu(&menu, &clock_settings.mode, NULL, false) >=0)
        return(true);
    return(false);
}

/**********************
 * Analog settings menu
 *********************/
void menu_analog_settings(void)
{
    int selection=0, result=0;

    MENUITEM_STRINGLIST(menu,"Analog Mode Settings",NULL,"Show Date",
                        "Show Second Hand","Show Border");

    while(result>=0){
        result=rb->do_menu(&menu, &selection, NULL, false);
        switch(result){
            case 0:
                rb->set_option("Show Date", &clock_settings.analog.show_date,
                               BOOL, noyes_text, 2, NULL);
                break;
            case 1:
                rb->set_option("Show Second Hand",
                               &clock_settings.analog.show_seconds,
                               BOOL, noyes_text, 2, NULL);
                break;
            case 2:
                rb->set_option("Show Border",
                               &clock_settings.analog.show_border,
                               BOOL, noyes_text, 2, NULL);
                break;
        }
    }
}

/***********************
 * Digital settings menu
 **********************/
void menu_digital_settings(void){
    int selection=0, result=0;

    MENUITEM_STRINGLIST(menu,"Digital Mode Settings",NULL,"Show Seconds",
                        "Blinking Colon");

    while(result>=0){
        result=rb->do_menu(&menu, &selection, NULL, false);
        switch(result){
            case 0:
                rb->set_option("Show Seconds",
                               &clock_settings.digital.show_seconds,
                               BOOL, noyes_text, 2, NULL);
                break;
            case 1:
                rb->set_option("Blinking Colon",
                               &clock_settings.digital.blinkcolon,
                               BOOL, noyes_text, 2, NULL);
                break;
        }
    }
}

/***********************************************************
 * Confirm resetting of settings, used in general_settings()
 **********************************************************/
void confirm_reset(void){
    int result=0;

    rb->set_option("Reset all settings?", &result, INT, noyes_text, 2, NULL);

    if(result == 1){ /* reset! */
        clock_settings_reset(&clock_settings);
        rb->splash(HZ, "Settings reset!");
    }
    else
        rb->splash(HZ, "Settings NOT reset.");
}

/************************************
 * General settings. Reset, save, etc
 ***********************************/
void menu_general_settings(void){
    int selection=0, result=0;

    MENUITEM_STRINGLIST(menu,"General Settings",NULL,
                        "Hour Format","Date Format","Show Counter",
                        "Reset Settings","Save Settings Now",
                        "Save On Exit","Backlight Settings",
                        "Idle Poweroff (temporary)");

    while(result>=0){
        result=rb->do_menu(&menu, &selection, NULL, false);
        switch(result){
            case 0:
                rb->set_option("Hour format",
                               &clock_settings.general.hour_format,
                               INT, hour_format_text, 2, NULL);
                break;
            case 1:
                rb->set_option("Date format",
                               &clock_settings.general.date_format,
                               INT, date_format_text, 4, NULL);
                break;
            case 2:
                rb->set_option("Show Counter", &clock_settings.general.show_counter,
                               BOOL, noyes_text, 2, NULL);
                break;
            case 3:
                confirm_reset();
                break;

            case 4:
                save_settings_wo_gui();
                rb->splash(HZ, "Settings saved");
                break;

            case 5:
                rb->set_option("Save On Exit",
                               &clock_settings.general.save_settings,
                               BOOL, noyes_text, 2, NULL);

                /* if we no longer save on exit,
                   we better save now to remember that */
                if(!clock_settings.general.save_settings)
                    save_settings_wo_gui();
                break;
            case 6:
                rb->set_option("Backlight Settings",
                               &clock_settings.general.backlight,
                               INT, backlight_settings_text, 3, NULL);
                apply_backlight_setting(clock_settings.general.backlight);
                break;

            case 7:
                rb->set_option("Idle Poweroff (temporary)",
                               &clock_settings.general.idle_poweroff,
                               BOOL, idle_poweroff_text, 2, NULL);
                break;
        }
    }
}

/***********
 * Main menu
 **********/
bool main_menu(void){
    int selection=0;
    bool done = false;
    bool exit_clock=false;

    MENUITEM_STRINGLIST(menu,"Clock Menu",NULL,"View Clock","Mode Selector",
                        "Mode Settings","General Settings","Playback Control",
                        "Quit");

    while(!done){
        switch(rb->do_menu(&menu, &selection, NULL, false)){
            case 0:
                done = true;
                break;

            case 1:
                done=menu_mode_selector();
                break;

            case 2:
                switch(clock_settings.mode){
                    case ANALOG: menu_analog_settings();break;
                    case DIGITAL: menu_digital_settings();break;
                    case BINARY: /* no settings */;break;
                }
                break;

            case 3:
                menu_general_settings();
                break;

            case 4:
                playback_control(NULL);
                break;

            case 5:
                exit_clock = true;
                done = true;
                break;

            default:
                done=true;
                break;
        }
    }
    return(exit_clock);
}
15' href='#n1115'>1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602
/* Emacs style mode select   -*- C++ -*-
 *-----------------------------------------------------------------------------
 *
 *
 *  PrBoom a Doom port merged with LxDoom and LSDLDoom
 *  based on BOOM, a modified and improved DOOM engine
 *  Copyright (C) 1999 by
 *  id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
 *  Copyright (C) 1999-2000 by
 *  Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 *  02111-1307, USA.
 *
 * DESCRIPTION:  Heads-up displays
 *
 *-----------------------------------------------------------------------------
 */

// killough 5/3/98: remove unnecessary headers

#include "doomstat.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "st_stuff.h" /* jff 2/16/98 need loc of status bar */
#include "w_wad.h"
#include "s_sound.h"
#include "dstrings.h"
#include "sounds.h"
//#include "d_deh.h"   /* Ty 03/27/98 - externalization of mapnamesx arrays */
#include "g_game.h"
#include "m_swap.h"

// global heads up display controls

int hud_active;       //jff 2/17/98 controls heads-up display mode
int hud_displayed;    //jff 2/23/98 turns heads-up display on/off
int hud_nosecrets;    //jff 2/18/98 allows secrets line to be disabled in HUD
int hud_distributed;  //jff 3/4/98 display HUD in different places on screen
int hud_graph_keys=1; //jff 3/7/98 display HUD keys as graphics

//
// Locally used constants, shortcuts.
//
// Ty 03/28/98 -
// These four shortcuts modifed to reflect char ** of mapnamesx[]
#define HU_TITLE  (*mapnames[(gameepisode-1)*9+gamemap-1])
#define HU_TITLE2 (*mapnames2[gamemap-1])
#define HU_TITLEP (*mapnamesp[gamemap-1])
#define HU_TITLET (*mapnamest[gamemap-1])
#define HU_TITLEHEIGHT  1
#define HU_TITLEX 0
//jff 2/16/98 change 167 to ST_Y-1
// CPhipps - changed to ST_TY
// proff - changed to 200-ST_HEIGHT for stretching
#define HU_TITLEY ((200-ST_HEIGHT) - 1 - SHORT(hu_font[0].height))

//jff 2/16/98 add coord text widget coordinates
// proff - changed to SCREENWIDTH to 320 for stretching
#define HU_COORDX (320 - 13*SHORT(hu_font2['A'-HU_FONTSTART].width))
//jff 3/3/98 split coord widget into three lines in upper right of screen
#define HU_COORDX_Y (1 + 0*SHORT(hu_font['A'-HU_FONTSTART].height))
#define HU_COORDY_Y (2 + 1*SHORT(hu_font['A'-HU_FONTSTART].height))
#define HU_COORDZ_Y (3 + 2*SHORT(hu_font['A'-HU_FONTSTART].height))

//jff 2/16/98 add ammo, health, armor widgets, 2/22/98 less gap
#define HU_GAPY 8
#define HU_HUDHEIGHT (6*HU_GAPY)
#define HU_HUDX 2
#define HU_HUDY (200-HU_HUDHEIGHT-1)
#define HU_MONSECX (HU_HUDX)
#define HU_MONSECY (HU_HUDY+0*HU_GAPY)
#define HU_KEYSX   (HU_HUDX)
//jff 3/7/98 add offset for graphic key widget
#define HU_KEYSGX  (HU_HUDX+4*SHORT(hu_font2['A'-HU_FONTSTART].width))
#define HU_KEYSY   (HU_HUDY+1*HU_GAPY)
#define HU_WEAPX   (HU_HUDX)
#define HU_WEAPY   (HU_HUDY+2*HU_GAPY)
#define HU_AMMOX   (HU_HUDX)
#define HU_AMMOY   (HU_HUDY+3*HU_GAPY)
#define HU_HEALTHX (HU_HUDX)
#define HU_HEALTHY (HU_HUDY+4*HU_GAPY)
#define HU_ARMORX  (HU_HUDX)
#define HU_ARMORY  (HU_HUDY+5*HU_GAPY)

//jff 3/4/98 distributed HUD positions
#define HU_HUDX_LL 2
#define HU_HUDY_LL (200-2*HU_GAPY-1)
// proff/nicolas 09/20/98: Changed for high-res
#define HU_HUDX_LR (320-120)
#define HU_HUDY_LR (200-2*HU_GAPY-1)
// proff/nicolas 09/20/98: Changed for high-res
#define HU_HUDX_UR (320-96)
#define HU_HUDY_UR 2
#define HU_MONSECX_D (HU_HUDX_LL)
#define HU_MONSECY_D (HU_HUDY_LL+0*HU_GAPY)
#define HU_KEYSX_D   (HU_HUDX_LL)
#define HU_KEYSGX_D  (HU_HUDX_LL+4*SHORT(hu_font2['A'-HU_FONTSTART].width))
#define HU_KEYSY_D   (HU_HUDY_LL+1*HU_GAPY)
#define HU_WEAPX_D   (HU_HUDX_LR)
#define HU_WEAPY_D   (HU_HUDY_LR+0*HU_GAPY)
#define HU_AMMOX_D   (HU_HUDX_LR)
#define HU_AMMOY_D   (HU_HUDY_LR+1*HU_GAPY)
#define HU_HEALTHX_D (HU_HUDX_UR)
#define HU_HEALTHY_D (HU_HUDY_UR+0*HU_GAPY)
#define HU_ARMORX_D  (HU_HUDX_UR)
#define HU_ARMORY_D  (HU_HUDY_UR+1*HU_GAPY)

//#define HU_INPUTTOGGLE  't' // not used                           // phares
#define HU_INPUTX HU_MSGX
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(hu_font[0].height) +1))
#define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT  1

#define key_alt KEY_RALT
#define key_shift KEY_RSHIFT

const char* chat_macros[] =
   // Ty 03/27/98 - *not* externalized
   // CPhipps - const char*
   {
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1,
      HUSTR_CHATMACRO1
   };

const char* player_names[] =
   // Ty 03/27/98 - *not* externalized
   // CPhipps - const char*
   {
      HUSTR_PLRGREEN,
      HUSTR_PLRINDIGO,
      HUSTR_PLRBROWN,
      HUSTR_PLRRED
   };

//jff 3/17/98 translate player colmap to text color ranges
int plyrcoltran[MAXPLAYERS]={CR_GREEN,CR_GRAY,CR_BROWN,CR_RED};

char chat_char;                 // remove later.
static player_t*  plr;

// font sets
patchnum_t hu_font[HU_FONTSIZE];
patchnum_t *hu_font2;
patchnum_t *hu_fontk;//jff 3/7/98 added for graphic key indicators
patchnum_t hu_msgbg[9];          //jff 2/26/98 add patches for message background

// widgets
static hu_textline_t  w_title;
static hu_stext_t     w_message;
static hu_itext_t     w_chat;
static hu_itext_t     w_inputbuffer[MAXPLAYERS];
static hu_textline_t  w_coordx; //jff 2/16/98 new coord widget for automap
static hu_textline_t  w_coordy; //jff 3/3/98 split coord widgets automap
static hu_textline_t  w_coordz; //jff 3/3/98 split coord widgets automap
static hu_textline_t  w_ammo;   //jff 2/16/98 new ammo widget for hud
static hu_textline_t  w_health; //jff 2/16/98 new health widget for hud
static hu_textline_t  w_armor;  //jff 2/16/98 new armor widget for hud
static hu_textline_t  w_weapon; //jff 2/16/98 new weapon widget for hud
static hu_textline_t  w_keys;   //jff 2/16/98 new keys widget for hud
static hu_textline_t  w_gkeys;  //jff 3/7/98 graphic keys widget for hud
static hu_textline_t  w_monsec; //jff 2/16/98 new kill/secret widget for hud
static hu_mtext_t     w_rtext;  //jff 2/26/98 text message refresh widget

static boolean    always_off = false;
static char       chat_dest[MAXPLAYERS];
boolean           chat_on;
static boolean    message_on;
static boolean    message_list; //2/26/98 enable showing list of messages
boolean           message_dontfuckwithme;
static boolean    message_nottobefuckedwith;
static int        message_counter;
extern int        showMessages;
extern boolean    automapactive;
static boolean    headsupactive = false;

//jff 2/16/98 hud supported automap colors added
int hudcolor_titl;  // color range of automap level title
int hudcolor_xyco;  // color range of new coords on automap
//jff 2/16/98 hud text colors, controls added
int hudcolor_mesg;  // color range of scrolling messages
int hudcolor_chat;  // color range of chat lines
int hud_msg_lines;  // number of message lines in window
//jff 2/26/98 hud text colors, controls added
int hudcolor_list;  // list of messages color
int hud_list_bgon;  // enable for solid window background for message list

//jff 2/16/98 initialization strings for ammo, health, armor widgets
static char *hud_coordstrx;
static char *hud_coordstry;
static char *hud_coordstrz;
static char *hud_ammostr;
static char *hud_healthstr;
static char *hud_armorstr;
static char *hud_weapstr;
static char *hud_keysstr;
static char *hud_gkeysstr; //jff 3/7/98 add support for graphic key display
static char *hud_monsecstr;

//jff 2/16/98 declaration of color switch points
extern int ammo_red;
extern int ammo_yellow;
extern int health_red;
extern int health_yellow;
extern int health_green;
extern int armor_red;
extern int armor_yellow;
extern int armor_green;

//
// Builtin map names.
// The actual names can be found in DStrings.h.
//
// Ty 03/27/98 - externalized map name arrays - now in d_deh.c
// and converted to arrays of pointers to char *
// See modified HUTITLEx macros
extern char **mapnames[];
extern char **mapnames2[];
extern char **mapnamesp[];
extern char **mapnamest[];

// key tables
// jff 5/10/98 french support removed,
// as it was not being used and couldn't be easily tested
//
const char* shiftxform;

const char english_shiftxform[] =
   {
      0,
      1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
      11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
      21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
      31,
      ' ', '!', '"', '#', '$', '%', '&',
      '"', // shift-'
      '(', ')', '*', '+',
      '<', // shift-,
      '_', // shift--
      '>', // shift-.
      '?', // shift-/
      ')', // shift-0
      '!', // shift-1
      '@', // shift-2
      '#', // shift-3
      '$', // shift-4
      '%', // shift-5
      '^', // shift-6
      '&', // shift-7
      '*', // shift-8
      '(', // shift-9
      ':',
      ':', // shift-;
      '<',
      '+', // shift-=
      '>', '?', '@',
      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
      'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
      '[', // shift-[
      '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
      ']', // shift-]
      '"', '_',
      '\'', // shift-`
      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
      'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
      '{', '|', '}', '~', 127
   };

//
// HU_Init()
//
// Initialize the heads-up display, text that overwrites the primary display
//
// Passed nothing, returns nothing
//
void HU_Init(void)
{
   int  i;
   int  j;
   char  buffer[9];

   shiftxform = english_shiftxform;

   // malloc all the strings, trying to get size down
   hud_ammostr=malloc(80*sizeof(char));
   hud_healthstr=malloc(80*sizeof(char));
   hud_armorstr=malloc(80*sizeof(char));
   hud_weapstr=malloc(80*sizeof(char));
   hud_keysstr=malloc(80*sizeof(char));
   hud_gkeysstr=malloc(80*sizeof(char));
   hud_monsecstr=malloc(80*sizeof(char));
   hud_coordstrx=malloc(32*sizeof(char));
   hud_coordstry=malloc(32*sizeof(char));
   hud_coordstrz=malloc(32*sizeof(char));
   hu_fontk=malloc(HU_FONTSIZE*sizeof(patchnum_t));
   hu_font2=malloc(HU_FONTSIZE*sizeof(patchnum_t));

   // load the heads-up font
   j = HU_FONTSTART;
   for (i=0;i<HU_FONTSIZE;i++,j++)
   {
      if ('0'<=j && j<='9')
      {
         snprintf(buffer, sizeof(buffer), "DIG%d",j-48);
         R_SetPatchNum(hu_font2 +i, buffer);
         snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
         R_SetPatchNum(&hu_font[i], buffer);
      }
      else if ('A'<=j && j<='Z')
      {
         snprintf(buffer, sizeof(buffer), "DIG%c",j);
         R_SetPatchNum(hu_font2 +i, buffer);
         snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
         R_SetPatchNum(&hu_font[i], buffer);
      }
      else if (j=='-')
      {
         R_SetPatchNum(hu_font2 +i, "DIG45");
         R_SetPatchNum(&hu_font[i], "STCFN045");
      }
      else if (j=='/')
      {
         R_SetPatchNum(hu_font2 +i, "DIG47");
         R_SetPatchNum(&hu_font[i], "STCFN047");
      }
      else if (j==':')
      {
         R_SetPatchNum(hu_font2 +i, "DIG58");
         R_SetPatchNum(&hu_font[i], "STCFN058");
      }
      else if (j=='[')
      {
         R_SetPatchNum(hu_font2 +i, "DIG91");
         R_SetPatchNum(&hu_font[i], "STCFN091");
      }
      else if (j==']')
      {
         R_SetPatchNum(hu_font2 +i, "DIG93");
         R_SetPatchNum(&hu_font[i], "STCFN093");
      }
      else if (j<97)
      {
         snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d"
         R_SetPatchNum(hu_font2 +i, buffer);
         R_SetPatchNum(&hu_font[i], buffer);
         //jff 2/23/98 make all font chars defined, useful or not
      }
      else if (j>122)
      {
         snprintf(buffer, sizeof(buffer), "STBR%d", j); //NOTE: "STBR%.3d"
         R_SetPatchNum(hu_font2 +i, buffer);
         R_SetPatchNum(&hu_font[i], buffer);
      }
      else
         hu_font[i] = hu_font[0]; //jff 2/16/98 account for gap
   }

   // CPhipps - load patches for message background
   for (i=0; i<9; i++) {
      snprintf(buffer, sizeof(buffer), "BOX%c%c", "UCL"[i/3], "LCR"[i%3]);
      R_SetPatchNum(&hu_msgbg[i], buffer);
   }

   // CPhipps - load patches for keys and double keys
   for (i=0; i<6; i++) {
      snprintf(buffer, sizeof(buffer), "STKEYS%d", i);
      R_SetPatchNum(hu_fontk+i, buffer);
   }
}

//
// HU_Stop()
//
// Make the heads-up displays inactive
//
// Passed nothing, returns nothing
//
void HU_Stop(void)
{
   headsupactive = false;
}

//
// HU_Start(void)
//
// Create and initialize the heads-up widgets, software machines to
// maintain, update, and display information over the primary display
//
// This routine must be called after any change to the heads up configuration
// in order for the changes to take effect in the actual displays
//
// Passed nothing, returns nothing
//
void HU_Start(void)
{

   int   i;
   const char* s; /* cph - const */

   if (headsupactive)                    // stop before starting
      HU_Stop();

   plr = &players[displayplayer];        // killough 3/7/98
   message_on = false;
   message_dontfuckwithme = false;
   message_nottobefuckedwith = false;
   chat_on = false;

   // create the message widget
   // messages to player in upper-left of screen
   HUlib_initSText
   (
      &w_message,
      HU_MSGX,
      HU_MSGY,
      HU_MSGHEIGHT,
      hu_font,
      HU_FONTSTART,
      hudcolor_mesg,
      &message_on
   );

   //jff 2/16/98 added some HUD widgets
   // create the map title widget - map title display in lower left of automap
   HUlib_initTextLine
   (
      &w_title,
      HU_TITLEX,
      HU_TITLEY,
      hu_font,
      HU_FONTSTART,
      hudcolor_titl
   );

   // create the hud health widget
   // bargraph and number for amount of health,
   // lower left or upper right of screen
   HUlib_initTextLine
   (
      &w_health,
      hud_distributed? HU_HEALTHX_D : HU_HEALTHX,  //3/4/98 distribute
      hud_distributed? HU_HEALTHY_D : HU_HEALTHY,
      hu_font2,
      HU_FONTSTART,
      CR_GREEN
   );

   // create the hud armor widget
   // bargraph and number for amount of armor,
   // lower left or upper right of screen
   HUlib_initTextLine
   (
      &w_armor,
      hud_distributed? HU_ARMORX_D : HU_ARMORX,    //3/4/98 distribute
      hud_distributed? HU_ARMORY_D : HU_ARMORY,
      hu_font2,
      HU_FONTSTART,
      CR_GREEN
   );

   // create the hud ammo widget
   // bargraph and number for amount of ammo for current weapon,
   // lower left or lower right of screen
   HUlib_initTextLine
   (
      &w_ammo,
      hud_distributed? HU_AMMOX_D : HU_AMMOX,      //3/4/98 distribute
      hud_distributed? HU_AMMOY_D : HU_AMMOY,
      hu_font2,
      HU_FONTSTART,
      CR_GOLD
   );

   // create the hud weapons widget
   // list of numbers of weapons possessed
   // lower left or lower right of screen
   HUlib_initTextLine
   (
      &w_weapon,
      hud_distributed? HU_WEAPX_D : HU_WEAPX,      //3/4/98 distribute
      hud_distributed? HU_WEAPY_D : HU_WEAPY,
      hu_font2,
      HU_FONTSTART,
      CR_GRAY
   );

   // create the hud keys widget
   // display of key letters possessed
   // lower left of screen
   HUlib_initTextLine
   (
      &w_keys,
      hud_distributed? HU_KEYSX_D : HU_KEYSX,      //3/4/98 distribute
      hud_distributed? HU_KEYSY_D : HU_KEYSY,
      hu_font2,
      HU_FONTSTART,
      CR_GRAY
   );

   // create the hud graphic keys widget
   // display of key graphics possessed
   // lower left of screen
   HUlib_initTextLine
   (
      &w_gkeys,
      hud_distributed? HU_KEYSGX_D : HU_KEYSGX,    //3/4/98 distribute
      hud_distributed? HU_KEYSY_D : HU_KEYSY,
      hu_fontk,
      HU_FONTSTART,
      CR_RED
   );

   // create the hud monster/secret widget
   // totals and current values for kills, items, secrets
   // lower left of screen
   HUlib_initTextLine
   (
      &w_monsec,
      hud_distributed? HU_MONSECX_D : HU_MONSECX,  //3/4/98 distribute
      hud_distributed? HU_MONSECY_D : HU_MONSECY,
      hu_font2,
      HU_FONTSTART,
      CR_GRAY
   );

   // create the hud text refresh widget