14 int text_console_enabled = 1;
17 #define text_console_enabled (!isvga())
20 cvar_t *cvar_vars = NULL;
22 /* Console specific cvars */
23 /* How discriminating we are about which messages are displayed */
24 cvar_t con_threshold = {"con_threshold", "0",};
26 /* Private console stuff */
27 #define CON_NUM_LINES 40
28 #define CON_LINE_LEN 40
29 static char con_display[40][40];
30 static int con_line; /* Current display line */
33 * con_init - Initialise the console.
38 /* Make sure the output is unbuffered */
39 if (text_console_enabled) {
40 setbuf (stdout, NULL);
41 setbuf (stderr, NULL);
44 memset(con_display, ' ', sizeof(con_display));
47 /* Initialise the cvars */
48 cvar_registervariable (&con_threshold);
53 * con_printf - Print a message to the console.
56 void con_printf(int priority, char *fmt, ...)
61 if (priority <= ((int)con_threshold.value))
63 va_start (arglist, fmt);
64 vsprintf (buffer, fmt, arglist);
65 if (text_console_enabled) vprintf(fmt, arglist);
68 /* for (i=0; i<l; i+=CON_LINE_LEN,con_line++)
70 memcpy(con_display, &buffer[i], min(80, l-i));
76 * con_update - Check for new console input. If it's there, use it.
81 // char buffer[CMD_MAX_LENGTH], *t;
83 /* Check for new input */
84 /* t = fgets(buffer, sizeof(buffer), stdin);
85 if (t == NULL) return;
92 * cvar_registervariable - Register a CVar
95 void cvar_registervariable (cvar_t *cvar)
102 cvar->value = strtod(cvar->string, (char **) NULL);
104 if (cvar_vars == NULL)
109 for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ;
115 * cvar_set - Set a CVar's value
118 void cvar_set (char *cvar_name, char *value)
122 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
123 if (!strcmp(cvar_name, ptr->name)) break;
125 if (ptr == NULL) return; // If we didn't find the cvar, give up
127 ptr->value = strtod(value, (char **) NULL);
131 * cvar() - Get a CVar's value
134 float cvar (char *cvar_name)
138 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
139 if (!strcmp(cvar_name, ptr->name)) break;
141 if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up
147 /* ==========================================================================
149 * ==========================================================================
153 /* char buffer[CON_LINE_LEN+1];
155 /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++)
157 memcpy(buffer, con_display[i], CON_LINE_LEN);
158 buffer[CON_LINE_LEN] = 0;
159 gr_string(1,j*10,buffer);