16 #if defined(__ENV_LINUX__) || defined(__MINGW32__)
17 int text_console_enabled = 1;
20 #define text_console_enabled (!isvga())
23 cvar_t *cvar_vars = NULL;
25 /* Console specific cvars */
26 /* How discriminating we are about which messages are displayed */
27 cvar_t con_threshold = {"con_threshold", "0",};
29 /* Private console stuff */
30 #define CON_NUM_LINES 40
31 #define CON_LINE_LEN 40
32 static char con_display[40][40];
33 static int con_line; /* Current display line */
36 * con_init - Initialise the console.
41 /* Make sure the output is unbuffered */
42 if (text_console_enabled) {
43 setbuf (stdout, NULL);
44 setbuf (stderr, NULL);
47 memset(con_display, ' ', sizeof(con_display));
50 /* Initialise the cvars */
51 cvar_registervariable (&con_threshold);
56 * con_printf - Print a message to the console.
59 void con_printf(int priority, char *fmt, ...)
64 if (priority <= ((int)con_threshold.value))
66 va_start (arglist, fmt);
67 vsprintf (buffer, fmt, arglist);
68 if (text_console_enabled) vprintf(fmt, arglist);
71 /* for (i=0; i<l; i+=CON_LINE_LEN,con_line++)
73 memcpy(con_display, &buffer[i], min(80, l-i));
79 * con_update - Check for new console input. If it's there, use it.
84 // char buffer[CMD_MAX_LENGTH], *t;
86 /* Check for new input */
87 /* t = fgets(buffer, sizeof(buffer), stdin);
88 if (t == NULL) return;
95 * cvar_registervariable - Register a CVar
98 void cvar_registervariable (cvar_t *cvar)
102 Assert(cvar != NULL);
105 cvar->value = strtod(cvar->string, (char **) NULL);
107 if (cvar_vars == NULL)
112 for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ;
118 * cvar_set - Set a CVar's value
121 void cvar_set (char *cvar_name, char *value)
125 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
126 if (!strcmp(cvar_name, ptr->name)) break;
128 if (ptr == NULL) return; // If we didn't find the cvar, give up
130 ptr->value = strtod(value, (char **) NULL);
134 * cvar() - Get a CVar's value
137 float cvar (char *cvar_name)
141 for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next)
142 if (!strcmp(cvar_name, ptr->name)) break;
144 if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up
150 /* ==========================================================================
152 * ==========================================================================
156 /* char buffer[CON_LINE_LEN+1];
158 /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++)
160 memcpy(buffer, con_display[i], CON_LINE_LEN);
161 buffer[CON_LINE_LEN] = 0;
162 gr_string(1,j*10,buffer);