1 /* $Id: console.c,v 1.8 2002-08-01 23:28:57 btb Exp $ */
4 * FIXME: put description here
25 int text_console_enabled = 1;
28 #define text_console_enabled (!isvga())
31 cvar_t *cvar_vars = NULL;
33 /* Console specific cvars */
34 /* How discriminating we are about which messages are displayed */
35 cvar_t con_threshold = {"con_threshold", "0",};
37 /* Private console stuff */
38 #define CON_NUM_LINES 40
39 #define CON_LINE_LEN 40
40 static char con_display[40][40];
41 static int con_line; /* Current display line */
44 * con_init - Initialise the console.
49 /* Make sure the output is unbuffered */
50 if (text_console_enabled) {
51 setbuf (stdout, NULL);
52 setbuf (stderr, NULL);
55 memset(con_display, ' ', sizeof(con_display));
58 /* Initialise the cvars */
59 cvar_registervariable (&con_threshold);
64 * con_printf - Print a message to the console.
67 void con_printf(int priority, char *fmt, ...)
72 if (priority <= ((int)con_threshold.value))
74 va_start (arglist, fmt);
75 vsprintf (buffer, fmt, arglist);
77 if (text_console_enabled) {
78 va_start (arglist, fmt);
79 vprintf(fmt, arglist);
83 /* for (i=0; i<l; i+=CON_LINE_LEN,con_line++)
85 memcpy(con_display, &buffer[i], min(80, l-i));
91 * con_update - Check for new console input. If it's there, use it.
96 // char buffer[CMD_MAX_LENGTH], *t;
98 /* Check for new input */
99 /* t = fgets(buffer, sizeof(buffer), stdin);
100 if (t == NULL) return;
107 * cvar_registervariable - Register a CVar
110 void cvar_registervariable (cvar_t *cvar)
114 Assert(cvar != NULL);
117 cvar->value = strtod(cvar->string, (char **) NULL);
119 if (cvar_vars == NULL)
124 for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ;
130 * cvar_set - Set a CVar's value
133 void cvar_set (char *cvar_name, char *value)
137 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
138 if (!strcmp(cvar_name, ptr->name)) break;
140 if (ptr == NULL) return; // If we didn't find the cvar, give up
142 ptr->value = strtod(value, (char **) NULL);
146 * cvar() - Get a CVar's value
149 float cvar (char *cvar_name)
153 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
154 if (!strcmp(cvar_name, ptr->name)) break;
156 if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up
162 /* ==========================================================================
164 * ==========================================================================
168 /* char buffer[CON_LINE_LEN+1];
170 /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++)
172 memcpy(buffer, con_display[i], CON_LINE_LEN);
173 buffer[CON_LINE_LEN] = 0;
174 gr_string(1,j*10,buffer);