#include #include #include #include #include #include #include "pstypes.h" #include "u_mem.h" #include "error.h" #include "console.h" #include "cmd.h" #ifdef __ENV_LINUX__ int text_console_enabled = 1; #else int isvga(); #define text_console_enabled (!isvga()) #endif cvar_t *cvar_vars = NULL; /* Console specific cvars */ /* How discriminating we are about which messages are displayed */ cvar_t con_threshold = {"con_threshold", "0",}; /* Private console stuff */ #define CON_NUM_LINES 40 #define CON_LINE_LEN 40 static char con_display[40][40]; static int con_line; /* Current display line */ /* ====== * con_init - Initialise the console. * ====== */ int con_init(void) { /* Make sure the output is unbuffered */ if (text_console_enabled) { setbuf (stdout, NULL); setbuf (stderr, NULL); } memset(con_display, ' ', sizeof(con_display)); con_line = 0; /* Initialise the cvars */ cvar_registervariable (&con_threshold); return 0; } /* ====== * con_printf - Print a message to the console. * ====== */ void con_printf(int priority, char *fmt, ...) { va_list arglist; char buffer[2048]; if (priority <= ((int)con_threshold.value)) { va_start (arglist, fmt); vsprintf (buffer, fmt, arglist); if (text_console_enabled) vprintf(fmt, arglist); va_end (arglist); /* for (i=0; inext = NULL; cvar->value = strtod(cvar->string, (char **) NULL); if (cvar_vars == NULL) { cvar_vars = cvar; } else { for (ptr = cvar_vars; ptr->next != NULL; ptr = ptr->next) ; ptr->next = cvar; } } /* ====== * cvar_set - Set a CVar's value * ====== */ void cvar_set (char *cvar_name, char *value) { cvar_t *ptr; for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next) if (!strcmp(cvar_name, ptr->name)) break; if (ptr == NULL) return; // If we didn't find the cvar, give up ptr->value = strtod(value, (char **) NULL); } /* ====== * cvar() - Get a CVar's value * ====== */ float cvar (char *cvar_name) { cvar_t *ptr; for (ptr = cvar_vars; ptr != NULL; ptr = ptr->next) if (!strcmp(cvar_name, ptr->name)) break; if (ptr == NULL) return 0.0; // If we didn't find the cvar, give up return ptr->value; } /* ========================================================================== * DRAWING * ========================================================================== */ void con_draw(void) { /* char buffer[CON_LINE_LEN+1]; int i,j; */ /* for (i = con_line, j=0; j < 20; i = (i+1) % CON_NUM_LINES, j++) { memcpy(buffer, con_display[i], CON_LINE_LEN); buffer[CON_LINE_LEN] = 0; gr_string(1,j*10,buffer); }*/ }