📄 console.c
字号:
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: console.c,v 1.15 2001/03/03 19:41:22 ydario Exp $//// Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.////// $Log: console.c,v $// Revision 1.15 2001/03/03 19:41:22 ydario// I_OutputMsg not implemented in OS/2//// Revision 1.14 2001/03/03 06:17:33 bpereira// no message//// Revision 1.13 2001/02/24 13:35:19 bpereira// no message//// Revision 1.12 2001/01/25 22:15:41 bpereira// added heretic support//// Revision 1.11 2000/11/12 09:48:15 bpereira// no message//// Revision 1.10 2000/11/02 17:50:06 stroggonmeth// Big 3Dfloors & FraggleScript commit!!//// Revision 1.9 2000/09/28 20:57:14 bpereira// no message//// Revision 1.8 2000/08/31 14:30:55 bpereira// no message//// Revision 1.7 2000/08/10 15:01:06 ydario// OS/2 port//// Revision 1.6 2000/08/03 17:57:41 bpereira// no message//// Revision 1.5 2000/04/24 15:10:56 hurdler// Support colormap for text//// Revision 1.4 2000/04/16 18:38:06 bpereira// no message//// Revision 1.3 2000/04/07 23:09:12 metzgermeister// fixed array boundary error//// Revision 1.2 2000/02/27 00:42:10 hurdler// fix CR+LF problem//// Revision 1.1.1.1 2000/02/22 20:32:33 hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION:// console for Doom LEGACY////-----------------------------------------------------------------------------#include "doomdef.h"#include "console.h"#include "g_game.h"#include "g_input.h"#include "hu_stuff.h"#include "keys.h"#include "r_defs.h"#include "sounds.h"#include "st_stuff.h"#include "s_sound.h"#include "v_video.h"#include "i_video.h"#include "z_zone.h"#include "i_system.h"#ifdef __WIN32__#include "win32/win_main.h"void I_LoadingScreen ( LPCSTR msg );#endif#ifdef HWRENDER#include "hardware/hw_main.h"#endifboolean con_started=false; // console has been initialisedboolean con_startup=false; // true at game startup, screen need refreshingboolean con_forcepic=true; // at startup toggle console transulcency when // first offboolean con_recalc; // set true when screen size has changedint con_tick; // console ticker for anim or blinking prompt cursor // con_scrollup should use time (currenttime - lasttime)..boolean consoletoggle; // true when console key pushed, ticker will handleboolean consoleready; // console prompt is readyint con_destlines; // vid lines used by console at final positionint con_curlines; // vid lines currently used by consoleint con_clipviewtop;// clip value for planes & sprites, so that the // part of the view covered by the console is not // drawn when not needed, this must be -1 when // console is off// TODO: choose max hud msg lines#define CON_MAXHUDLINES 5static int con_hudlines; // number of console heads up message linesint con_hudtime[5]; // remaining time of display for hud msg linesint con_clearlines; // top screen lines to refresh when view reducedboolean con_hudupdate; // when messages scroll, we need a backgrnd refresh// console text outputchar* con_line; // console text output current lineint con_cx; // cursor position in current lineint con_cy; // cursor line number in con_buffer, is always // increasing, and wrapped around in the text // buffer using modulo.int con_totallines; // lines of console text into the console bufferint con_width; // columns of chars, depend on vid mode widthint con_scrollup; // how many rows of text to scroll up (pgup/pgdn)// hold 32 last lines of input for history#define CON_MAXPROMPTCHARS 256#define CON_PROMPTCHAR '>'char inputlines[32][CON_MAXPROMPTCHARS]; // hold last 32 prompt linesint inputline; // current input line numberint inputhist; // line number of history input line to restoreint input_cx; // position in current input linepic_t* con_backpic; // console background picture, loaded staticpic_t* con_bordleft;pic_t* con_bordright; // console borders in translucent mode// protos.static void CON_InputInit (void);static void CON_RecalcSize (void);static void CONS_speed_Change (void);static void CON_DrawBackpic (pic_t *pic, int startx, int destwidth);//======================================================================// CONSOLE VARS AND COMMANDS//======================================================================#ifdef __MACOS__#define CON_BUFFERSIZE 4096 //my compiler cant handle local vars >32k#else#define CON_BUFFERSIZE 16384#endifchar con_buffer[CON_BUFFERSIZE];// how many seconds the hud messages lasts on the screenconsvar_t cons_msgtimeout = {"con_hudtime","5",CV_SAVE,CV_Unsigned};// number of lines console move per frameconsvar_t cons_speed = {"con_speed","8",CV_CALL|CV_SAVE,CV_Unsigned,&CONS_speed_Change};// percentage of screen height to use for consoleconsvar_t cons_height = {"con_height","50",CV_SAVE,CV_Unsigned};CV_PossibleValue_t backpic_cons_t[]={{0,"translucent"},{1,"picture"},{0,NULL}};// whether to use console background picture, or translucent modeconsvar_t cons_backpic = {"con_backpic","0",CV_SAVE,backpic_cons_t};void CON_Print (char *msg);// Check CONS_speed value (must be positive and >0)//static void CONS_speed_Change (void){ if (cons_speed.value<1) CV_SetValue (&cons_speed,1);}// Clear console text buffer//static void CONS_Clear_f (void){ if (con_buffer) memset(con_buffer,0,CON_BUFFERSIZE); con_cx = 0; con_cy = con_totallines-1; con_line = &con_buffer[con_cy*con_width]; con_scrollup = 0;}int con_keymap; //0 english, 1 french// Choose english keymap//static void CONS_English_f (void){ shiftxform = english_shiftxform; con_keymap = english; CONS_Printf("English keymap.\n");}// Choose french keymap//static void CONS_French_f (void){ shiftxform = french_shiftxform; con_keymap = french; CONS_Printf("French keymap.\n");}char *bindtable[NUMINPUTS];void CONS_Bind_f(void){ int na,key; na=COM_Argc(); if ( na!= 2 && na!=3) { CONS_Printf ("bind <keyname> [<command>]\n"); CONS_Printf("\2bind table :\n"); na=0; for(key=0;key<NUMINPUTS;key++) if(bindtable[key]) { CONS_Printf("%s : \"%s\"\n",G_KeynumToString (key),bindtable[key]); na=1; } if(!na) CONS_Printf("Empty\n"); return; } key=G_KeyStringtoNum(COM_Argv(1)); if(!key) { CONS_Printf("Invalid key name\n"); return; } if(bindtable[key]!=NULL) { Z_Free(bindtable[key]); bindtable[key]=NULL; } if( na==3 ) bindtable[key]=Z_StrDup(COM_Argv(2));}//======================================================================// CONSOLE SETUP//======================================================================// Prepare a colormap for GREEN ONLY translucency over background//byte* whitemap;byte* greenmap;byte* graymap;static void CON_SetupBackColormap (void){ int i,j,k; byte* pal;//// setup the green translucent background colormap// greenmap = (byte *) Z_Malloc(256,PU_STATIC,NULL); whitemap = (byte *) Z_Malloc(256,PU_STATIC,NULL); graymap = (byte *) Z_Malloc(256,PU_STATIC,NULL); pal = W_CacheLumpName ("PLAYPAL",PU_CACHE); for(i=0,k=0; i<768; i+=3,k++) { j = pal[i] + pal[i+1] + pal[i+2]; if( gamemode == heretic ) { greenmap[k] = 209 + (float)j*15/(3*255); //remaps to greens(209-224) graymap[k] = (float)j*35/(3*255); //remaps to grays(0-35) whitemap[k] = 145 + (float)j*15/(3*255); //remaps to reds(145-168) } else greenmap[k] = 127 - (j>>6); }//// setup the white and gray text colormap// // this one doesn't need to be aligned, unless you convert the // V_DrawMappedPatch() into optimised asm. if( gamemode != heretic ) { for(i=0; i<256; i++) { whitemap[i] = i; //remap each color to itself... graymap[i] = i; } for(i=168;i<192;i++) { whitemap[i]=i-88; //remaps reds(168-192) to whites(80-104) graymap[i]=i-80; //remaps reds(168-192) to gray(88-...) } whitemap[45]=190-88; // the color[45]=color[190] ! graymap [45]=190-80; whitemap[47]=191-88; // the color[47]=color[191] ! graymap [47]=191-80; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -