2 * $Source: /cvs/cvsroot/d2x/main/console.c,v $
5 * $Date: 2002-07-22 02:17:10 $
7 * FIXME: put description here
9 * $Log: not supported by cvs2svn $
10 * Revision 1.5 2001/10/19 09:47:34 bradleyb
32 int text_console_enabled = 1;
35 #define text_console_enabled (!isvga())
38 cvar_t *cvar_vars = NULL;
40 /* Console specific cvars */
41 /* How discriminating we are about which messages are displayed */
42 cvar_t con_threshold = {"con_threshold", "0",};
44 /* Private console stuff */
45 #define CON_NUM_LINES 40
46 #define CON_LINE_LEN 40
47 static char con_display[40][40];
48 static int con_line; /* Current display line */
51 * con_init - Initialise the console.
56 /* Make sure the output is unbuffered */
57 if (text_console_enabled) {
58 setbuf (stdout, NULL);
59 setbuf (stderr, NULL);
62 memset(con_display, ' ', sizeof(con_display));
65 /* Initialise the cvars */
66 cvar_registervariable (&con_threshold);
71 * con_printf - Print a message to the console.
74 void con_printf(int priority, char *fmt, ...)
79 if (priority <= ((int)con_threshold.value))
81 va_start (arglist, fmt);
82 vsprintf (buffer, fmt, arglist);
83 if (text_console_enabled) vprintf(fmt, arglist);
86 /* for (i=0; i<l; i+=CON_LINE_LEN,con_line++)
88 memcpy(con_display, &buffer[i], min(80, l-i));
94 * con_update - Check for new console input. If it's there, use it.
99 // char buffer[CMD_MAX_LENGTH], *t;
101 /* Check for new input */
102 /* t = fgets(buffer, sizeof(buffer), stdin);
103 if (t == NULL) return;
110 * cvar_registervariable - Register a CVar
113 void cvar_registervariable (cvar_t *cvar)
117 Assert(cvar != NULL);
120 cvar->value = strtod(cvar->string, (char **) NULL);
122 if (cvar_vars == NULL)
127 for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ;
133 * cvar_set - Set a CVar's value
136 void cvar_set (char *cvar_name, char *value)
140 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
141 if (!strcmp(cvar_name, ptr->name)) break;
143 if (ptr == NULL) return; // If we didn't find the cvar, give up
145 ptr->value = strtod(value, (char **) NULL);
149 * cvar() - Get a CVar's value
152 float cvar (char *cvar_name)
156 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
157 if (!strcmp(cvar_name, ptr->name)) break;
159 if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up
165 /* ==========================================================================
167 * ==========================================================================
171 /* char buffer[CON_LINE_LEN+1];
173 /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++)
175 memcpy(buffer, con_display[i], CON_LINE_LEN);
176 buffer[CON_LINE_LEN] = 0;
177 gr_string(1,j*10,buffer);