/**[txh]******************************************************************** Copyright 2001-2003 by Salvador E. Tropea This file is covered by the GPL license. Module: Display Include: TDisplay Comments: This is the base class for low level screen output. Most members are pointers to functions defined by each platform dependent driver. Default members are provided. This is a complete new file created from concepts that José Angel Sanchez Caso provide me and coded from scratch. The names of some members are the same used in original Turbo Vision for compatibility purposes. ***************************************************************************/ //#define DEBUG_CURSOR #define Uses_stdio #define Uses_stdlib #define Uses_TScreen #define Uses_TVCodePage #include // Remove me please! int TDisplay::dual_display=0; void (*TDisplay::clearScreen)(uchar, uchar)=TDisplay::defaultClearScreen; ushort (*TDisplay::getRows)() =TDisplay::defaultGetRows; ushort (*TDisplay::getCols)() =TDisplay::defaultGetCols; void (*TDisplay::setCrtMode)(ushort mode) =TDisplay::defaultSetCrtMode; ushort (*TDisplay::getCrtMode)() =TDisplay::defaultGetCrtMode; void (*TDisplay::getCursorPos)(unsigned &x, unsigned &y) =TDisplay::defaultGetCursorShape; void (*TDisplay::setCursorPos)(unsigned x, unsigned y) =TDisplay::defaultSetCursorShape; void (*TDisplay::setCursorShape)(unsigned start, unsigned end) =TDisplay::defaultSetCursorShape; void (*TDisplay::getCursorShape)(unsigned &start, unsigned &end) =TDisplay::defaultGetCursorShape; void (*TDisplay::setCrtModeExt)(char *mode)=TDisplay::defaultSetCrtModeExt; int (*TDisplay::checkForWindowSize)(void) =TDisplay::defaultCheckForWindowSize; const char *(*TDisplay::getWindowTitle)(void) =TDisplay::defaultGetWindowTitle; int (*TDisplay::setWindowTitle)(const char *name) =TDisplay::defaultSetWindowTitle; int (*TDisplay::getBlinkState)() =TDisplay::defaultGetBlinkState; void (*TDisplay::getDisPaletteColors)(int from, int number, TScreenColor *colors) =TDisplay::defaultGetDisPaletteColors; int (*TDisplay::setDisPaletteColors)(int from, int number, TScreenColor *colors) =TDisplay::defaultSetDisPaletteColors; int (*TDisplay::setCrtModeRes_p)(unsigned w, unsigned h, int fW, int fH) =TDisplay::defaultSetCrtModeRes; Boolean (*TDisplay::showBusyState)(Boolean state) =TDisplay::defaultShowBusyState; void (*TDisplay::beep)() =TDisplay::defaultBeep; int TDisplay::argc =0; char **TDisplay::argv =NULL; char **TDisplay::environment =NULL; TScreenColor TDisplay::OriginalPalette[16]; TScreenColor TDisplay::ActualPalette[16]; char TDisplay::paletteModified =0; char TDisplay::avoidMoire =0; uint32 TDisplay::opts1 =0; TVCodePage *TDisplay::codePage =NULL; Boolean TDisplay::busyState =False; int TDisplay::drawingMode =TDisplay::codepage; TVScreenDriverDetectCallBack TDisplay::dCB =NULL; TScreenResolution TDisplay::dosModesRes[TDisplayDOSModesNum]= { { 80,25 }, { 80,28 }, { 80,30 }, { 80,34 }, { 80,35 }, { 80,40 }, { 80,43 }, { 80,50 }, { 80,60 }, { 82,25 }, { 90,30 }, { 90,34 }, { 94,30 }, { 94,34 }, { 132,25 }, { 132,43 }, { 132,50 }, { 132,60 } }; TScreenResolution TDisplay::dosModesCell[TDisplayDOSModesNum]= { { 9,16 }, { 9,14 }, { 9,16 }, { 9,14 }, { 9,10 }, { 9,10 }, { 9, 8 }, { 9, 8 }, { 9, 8 }, { 8,16 }, { 9,16 }, { 9,14 }, { 9,16 }, { 9,14 }, { 9,14 }, { 9,11 }, { 9,10 }, { 9, 8 } }; int TDisplay::dosModes[TDisplayDOSModesNum]= { smCO80x25, smCO80x28, smCO80x30, smCO80x34, smCO80x35, smCO80x40, smCO80x43, smCO80x50, smCO80x60, smCO82x25, smCO90x30, smCO90x34, smCO94x30, smCO94x34, smCO132x25, smCO132x43, smCO132x50, smCO132x60 }; /***************************************************************************** Default actions for TDisplay. *****************************************************************************/ /**[txh]******************************************************************** Description: Number of columns of the physical screen. ***************************************************************************/ ushort TDisplay::defaultGetCols() { return 80; } /**[txh]******************************************************************** Description: Number of rows of the physical screen. ***************************************************************************/ ushort TDisplay::defaultGetRows() { return 25; } /**[txh]******************************************************************** Description: Erase the screen using this width and height. ***************************************************************************/ void TDisplay::defaultClearScreen( uchar, uchar ) { } /**[txh]******************************************************************** Description: Sets the cursor shape, values in percent. ***************************************************************************/ void TDisplay::defaultSetCursorShape(unsigned /*start*/, unsigned /*end*/) { } /**[txh]******************************************************************** Description: Gets the cursor shape, values in percent. ***************************************************************************/ void TDisplay::defaultGetCursorShape(unsigned &start, unsigned &end) { start=end=0; } /**[txh]******************************************************************** Description: Returns information about a legacy DOS mode. Return: True if the mode is known. ***************************************************************************/ Boolean TDisplay::searchDOSModeInfo(ushort mode, unsigned &w, unsigned &h, int &fW, int &fH) { int i; for (i=0; i>8); #ifdef DEBUG_CURSOR fprintf(stderr,"Seteando 0x%0X => %X %X\n",val,val & 0xFF,val>>8); #endif } ushort TDisplay::getCursorType() { unsigned start,end; getCursorShape(start,end); #ifdef DEBUG_CURSOR fprintf(stderr,"Obteniendo: start %X end %X => 0x%0X\n",start,end,(start | (end<<8))); #endif return (ushort)(start | (end<<8)); } void TDisplay::setArgv(int aArgc, char **aArgv, char **aEnvir) { argc=aArgc; argv=aArgv; environment=aEnvir; } Boolean TDisplay::searchClosestRes(TScreenResolution *res, unsigned x, unsigned y, unsigned cant, unsigned &pos) { unsigned i, minDif, indexMin, dif; int firstXMatch=-1; // Look for an exact match of width for (i=0; i