void Vid_Init(int mode) { OldScreenData.cb=ScreenData.cb=sizeof(ScreenData); VioGetMode(&OldScreenData,hvio); memcpy(&ScreenData,&OldScreenData,sizeof(ScreenData)); switch (mode) { case TEXT_25: ScreenData.row=25; ScreenData.vres=400; break; case TEXT_30: ScreenData.row=30; ScreenData.vres=480; break; } VioSetMode(&ScreenData,hvio); VioGetMode(&ScreenData,hvio); CELL_SIZE=ScreenData.buf_length / (ScreenData.row * ScreenData.col); VioGetCurType(&Save,hvio); mAcurs=&Ins[1]; Ins[0].yStart=0; Ins[0].cEnd=ScreenData.vres/ScreenData.row; Ins[0].cx=1; Ins[1].yStart=ScreenData.vres/ScreenData.row-2; Ins[1].cEnd=ScreenData.vres/ScreenData.row; Ins[1].cx=1; VioSetCurType(&Ins[1],hvio); }
bool intern initmonitor( void ) /*****************************/ { struct _VIOMODEINFO vioMode; struct _VIOCONFIGINFO config; if( UIData == NULL ) { UIData = &ui_data; } vioMode.cb = sizeof(vioMode); if( VioGetMode(&vioMode, HANDLE) != 0 ) return( FALSE ); UIData->width = vioMode.col; UIData->height = vioMode.row; config.cb = sizeof(config); if( VioGetConfig(0,&config,0) != 0 ) return( FALSE ); if( config.display == 3 ) { UIData->colour = M_BW; } else { switch( config.adapter ) { case 0: UIData->colour = M_MONO; break; case 1: UIData->colour = M_CGA; break; case 2: UIData->colour = M_EGA; break; case 3: UIData->colour = M_VGA; break; default: UIData->colour = M_VGA; break; } } return( TRUE ); }
int PDC_get_columns(void) /***********************************************************************/ { #ifdef EMXVIDEO int rows=0; #else VIOMODEINFO modeInfo={0}; #endif int cols=0; char *env_cols=NULL; #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_columns() - called\n"); #endif #ifdef EMXVIDEO v_dimen (&cols, &rows); #else modeInfo.cb = sizeof(modeInfo); VioGetMode(&modeInfo, 0); cols = modeInfo.col; #endif env_cols = (char *)getenv("COLS"); if (env_cols != (char *)NULL) { cols = min(atoi(env_cols),cols); } #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_columns() - returned: cols %d\n",cols); #endif return(cols); }
/* * ScreenInit - get screen info */ void ScreenInit( void ) { unsigned short solvb; struct _VIOCONFIGINFO config; struct _VIOMODEINFO vioMode; void * SEG16 ptr; vioMode.cb = sizeof( vioMode ); if( VioGetMode( &vioMode, 0 ) != 0 ) { FatalError( ERR_WIND_INVALID ); } EditVars.WindMaxWidth = vioMode.col; EditVars.WindMaxHeight = vioMode.row; config.cb = sizeof( config ); if( VioGetConfig( 0, &config, 0 ) != 0 ) { FatalError( ERR_WIND_INVALID ); } if( config.display == 3 ) { EditFlags.BlackAndWhite = TRUE; } else { if( config.adapter == 0 ) { EditFlags.Monocolor = TRUE; } else { EditFlags.Color = TRUE; } } VioGetBuf( (PULONG) &ptr, (PUSHORT) &solvb, 0); Scrn = ptr; ScreenPage( 0 ); } /* ScreenInit */
int tty_size_changed () { VIOMODEINFO vi; vi.cb = sizeof (vi); VioGetMode (&vi, 0); return (last_col != vi.col || last_row != vi.row); }
static void hb_gt_os2_mouse_Hide( PHB_GT pGT ) { /* NOTE: mouse cursor always visible if not in full screen */ HB_SYMBOL_UNUSED( pGT ); if( s_uMouHandle ) { NOPTRRECT rect; VIOMODEINFO vi; /* needed to get max Row/Col */ /* QUESTION: should I call the GT MaxRow/Col function ? pro: encapsulating of the GetScreen function con: calling function from another module, GT must be linked in con: VioGetMode is been called twice */ vi.cb = sizeof( vi ); VioGetMode( &vi, 0 ); rect.row = 0; /* x-coordinate upper left */ rect.col = 0; /* y-coordinate upper left */ rect.cRow = vi.row - 1; /* x-coordinate lower right */ rect.cCol = vi.col - 1; /* y-coordinate lower right */ MouRemovePtr( &rect, s_uMouHandle ); } }
/* return ElvTrue if VIO is available. */ static int vio_test (void) { VIOMODEINFO info; USHORT rc; #if 0 { static char digits[] = "0123456789abcdef"; char buffer[32]; int i, j; for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) { buffer[j * 2] = digits[j]; buffer[j * 2 + 1] = i * 16 + j; buffer[j * 2 + 1] = 0x07; buffer[j * 2 ] = i * 16 + j; } VioWrtCellStr (buffer, 32, i, 0, 0); } vio_read (buffer, 1, 0); } #endif info.cb = sizeof (info); rc = VioGetMode (&info, 0); return rc == NO_ERROR; }
/*--------------------------------------------------------------------------* * getvmode * * * *--------------------------------------------------------------------------*/ getvmode(int *rows, int *cols) { int rc; VIOMODEINFO vmi; void myerror(int, char *, char *); if (rows) *rows = 0; if (cols) *cols = 0; vmi.cb = sizeof(VIOMODEINFO); if (rc = VioGetMode(&vmi, 0)) { myerror(rc, "init", "VioGetMode"); return(BAILOUT); } else { if (rows) *rows = vmi.row; if (cols) *cols = vmi.col; } return(1); }
char vm_getscreenwidth(void) { VIOMODEINFO vi; vi.cb = sizeof(VIOMODEINFO); VioGetMode(&vi, 0); return vi.col; }
char vm_getscreenheight(void) { VIOMODEINFO vi; vi.cb = sizeof(VIOMODEINFO); VioGetMode(&vi, 0); return vi.row; }
int PDC_get_rows(void) /***********************************************************************/ { #ifdef EMXVIDEO int cols=0; #else VIOMODEINFO modeInfo={0}; #endif int rows=0; char *env_rows=NULL; #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_rows() - called\n"); #endif /* use the value from LINES environment variable, if set. MH 10-Jun-92 */ /* and use the minimum of LINES and *ROWS. MH 18-Jun-92 */ #ifdef EMXVIDEO v_dimen (&cols, &rows); #else modeInfo.cb = sizeof(modeInfo); VioGetMode(&modeInfo, 0); rows = modeInfo.row; #endif env_rows = (char *)getenv("LINES"); if (env_rows != (char *)NULL) rows = min(atoi(env_rows),rows); #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_rows() - returned: rows %d\n",rows); #endif return(rows); }
int GetScreenRows(void) { VIOMODEINFO vmi; VioGetMode(&vmi, 0); return vmi.row; }
int ConQuerySize(int *X, int *Y) { VIOMODEINFO vmi; vmi.cb = sizeof(VIOMODEINFO); VioGetMode(&vmi, 0); if (X) *X = vmi.col; if (Y) *Y = vmi.row; return 0; }
int tty_getsize (struct winsize *ws) { VIOMODEINFO vi; vi.cb = sizeof (vi); VioGetMode (&vi, 0); last_col = ws->ws_col = vi.col; last_row = ws->ws_row = vi.row; ws->ws_xpixel = vi.hres; ws->ws_ypixel = vi.vres; return 0; }
/* -------------------------------------------------------------------------- Get console screen size in columns (cx) and rows (cy). - Parameters ------------------------------------------------------------- PCONSIZE - Return value ----------------------------------------------------------- BOOL : TRUE/FALSE (success/error). -------------------------------------------------------------------------- */ BOOL screenSize(PSIZEL psize) { USHORT aus[4]; aus[0] = 8; g.rc = VioGetMode((PVIOMODEINFO)aus, 0); if (g.rc) return handleError(FALSE, TRUE, SZERR_GETSCREENSIZE, g.rc); psize->cx = ((PVIOMODEINFO)aus)->col; psize->cy = ((PVIOMODEINFO)aus)->row; return TRUE; }
int get_window_size(void) { #ifdef CAN_GET_WINSIZE int ocol = columns, oline = lines; int new_wrapsize; # ifdef TIOCGWINSZ struct winsize size; int first = 1; retry: if (ioctl(STDIN_FILENO, TIOCGWINSZ, &size) < 0) return 0; if (size.ws_col > 0) columns = size.ws_col; if (size.ws_row > 0) lines = size.ws_row; if (first && lines < 3) { /* Konsole sometimes sends an incorrect resize followed by a correct * resize. The incorrect one would make tf disable visual mode. So * if the resize looks fishy, wait briefly for a second resize, and * if we get it, ignore the first. */ struct timeval timeout = {0,10000}; first = 0; select(0, NULL, NULL, NULL, &timeout); goto retry; } # endif # ifdef EMXANSI static VIOMODEINFO info; /* must be static for thunking (16 bit func) */ info.cb = sizeof(info); VioGetMode(&info,(HVIO)0); if (info.col > 0) columns = info.col; if (info.row > 0) lines = info.row; # endif if (columns == ocol && lines == oline) return 1; new_wrapsize = columns - (ocol - wrapsize); if (new_wrapsize < 1) new_wrapsize = columns > 1 ? columns - 1 : 1; /* set_int_var_direct avoids ch_wrap() */ set_int_var_direct(&special_var[VAR_wrapsize], TYPE_INT, new_wrapsize); ch_visual(NULL); do_hook(H_RESIZE, NULL, "%d %d", columns, lines); return 1; #else return 0; #endif }
char vm_getscreenheight(void) { if (_osmode == DOS_MODE) { int width, height; vi_init(); v_dimen(&width, &height); return (char)height; } else { VIOMODEINFO vi; vi.cb = sizeof(VIOMODEINFO); VioGetMode(&vi, 0); return vi.row; } }
/* * This function determines the screen size. */ static void vio_getsize (void) { VIOMODEINFO info; USHORT rc; /* get the window size, one way or another. */ info.cb = sizeof (info); rc = VioGetMode (&info, 0); /* did we get a realistic value? */ if (rc == NO_ERROR && info.row >= 2 && info.col >= 30) { o_ttyrows = info.row; o_ttycolumns = info.col; } }
void TProgram::initScreen() { #ifdef __OS2__ short mode = TScreen::screenMode; if ( mode != TDisplay::smMono && mode != TDisplay::smBW80 && mode != TDisplay::smCO80 ) { VIOMODEINFO info; info.cb=sizeof(VIOMODEINFO); VioGetMode(&info,0); if ( info.color == COLORS_2 ) mode = TDisplay::smMono; else mode = TDisplay::smCO80; } #else #ifdef __NT__ short mode = TDisplay::smCO80; #else #ifdef __MSDOS__ short mode = TScreen::screenMode; #else #error Unknown platform! #endif // !__MSDOS__ #endif // __NT__ #endif // __OS2__ if( (mode & 0x00FF) != TDisplay::smMono ) { if( (mode & TDisplay::smFont8x8) != 0 ) shadowSize.x = 1; else shadowSize.x = 2; shadowSize.y = 1; showMarkers = False; if( (mode & 0x00FF) == TDisplay::smBW80 ) appPalette = apBlackWhite; else appPalette = apColor; } else { shadowSize.x = 0; shadowSize.y = 0; showMarkers = True; appPalette = apMonochrome; } }
int tty_setsize (struct winsize *ws) { USHORT cx, cy; VIOMODEINFO vi; vi.cb = sizeof (vi); VioGetMode(&vi, 0); VioGetCurPos (&cx, &cy, 0); vi.col = ws->ws_col; vi.row = ws->ws_row; vi.cb = sizeof (vi.cb) + sizeof (vi.fbType) + sizeof (vi.color) + sizeof (vi.col) + sizeof (vi.row); VioSetMode (&vi, 0); VioSetCurPos (cx, cy, 0); return 0; }
int ConSetSize(int X, int Y) { VIOMODEINFO vmi; int rc; assert(X <= ConMaxCols); assert(Y <= ConMaxRows); vmi.cb = sizeof(VIOMODEINFO); VioGetMode(&vmi, 0); vmi.col = (USHORT)X; vmi.row = (USHORT)Y; vmi.cb = 2 + 1 + 1 + 2 + 2; rc = VioSetMode(&vmi, 0); if (rc == 0) return 0; return -1; }
int PDC_get_scrn_mode( VIOMODEINFO *modeinfo ) #endif /***********************************************************************/ { #ifndef EMXVIDEO VIOMODEINFO amodeinfo; #endif #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_scrn_mode() - called\n"); #endif #ifdef EMXVIDEO return(ERR); #else VioGetMode ( &amodeinfo, 0 ); *modeinfo = amodeinfo; return(OK); #endif }
int PDC_get_font(void) /***********************************************************************/ { #ifdef EMXVIDEO int retval=0; #else VIOMODEINFO modeInfo={0}; #endif #ifdef PDCDEBUG if (trace_on) PDC_debug("PDC_get_font() - called\n"); #endif #ifdef EMXVIDEO retval = v_hardware(); return (retval == V_MONOCHROME) ? 14 : (retval == V_COLOR_8) ? 8 : 12; #else modeInfo.cb = sizeof(modeInfo); /* set most parameters of modeInfo */ VioGetMode(&modeInfo, 0); return ( modeInfo.vres / modeInfo.row); #endif }
/* * ScreenInit - get screen info */ void ScreenInit( void ) { unsigned short solvb; struct _VIOCONFIGINFO config; struct _VIOMODEINFO vioMode; void * SEG16 ptr; /* Set the cb member of VIOMODEINFO/VIOCONFIGINFO to smaller values * in order to be backward compatible with old OS/2 versions. */ vioMode.cb = offsetof( VIOMODEINFO, buf_addr ); if( VioGetMode( &vioMode, 0 ) != 0 ) { StartupError( ERR_WIND_INVALID ); } WindMaxWidth = vioMode.col; WindMaxHeight = vioMode.row; config.cb = offsetof( VIOCONFIGINFO, Configuration ); if( VioGetConfig( 0, &config, 0 ) != 0 ) { StartupError( ERR_WIND_INVALID ); } if( config.display == 3 ) { EditFlags.BlackAndWhite = TRUE; } else { if( config.adapter == 0 ) { EditFlags.Monocolor = TRUE; } else { EditFlags.Color = TRUE; } } VioGetBuf( (PULONG) &ptr, (PUSHORT) &solvb, 0); Scrn = ptr; ScreenPage( 0 ); } /* ScreenInit */
//bool Vid::init(void) bool vid_init(void) { VIOMODEINFO viomode; VIOCONFIGINFO vioconfig; //USHORT _far16 *disp_address; //USHORT _far16 **temp = &disp_address; // BCC optimize workaround USHORT mode = 0; USHORT w_mode; vioconfig.cb = sizeof(vioconfig); rc = VioGetConfig(0, &vioconfig, 0); if(rc != 0) err_exit("Unknown VIDEO adapter", rc); /* #define COLORS_2 0x0001 VIOMODEINFO.color constants #define COLORS_4 0x0002 #define COLORS_16 0x0004 */ viomode.cb = sizeof(viomode); rc = VioGetMode(&viomode, 0); if(rc != 0) err_exit("Unknown VIDEO mode", rc); // set disp_address ptr, vidbufsize // rc = VioGetBuf((PULONG16)temp , &usvidbufsize, 0); // if(rc != 0) // err_exit(" Error in winstart.c VIOGETBUF", rc); mode = vioconfig.adapter; // set globals // saved_cursor= Vid::get_cursor(); /* #define DISPLAY_MONOCHROME 0x0000 VIOCONFIGINFO.adapter constants #define DISPLAY_CGA 0x0001 #define DISPLAY_EGA 0x0002 #define DISPLAY_VGA 0x0003 #define DISPLAY_8514A 0x0007 #define DISPLAY_IMAGEADAPTER 0x0008 #define DISPLAY_XGA 0x0009 */ /* #define MONITOR_MONOCHROME 0x0000 VIOCONFIGINFO.display constants #define MONITOR_COLOR 0x0001 #define MONITOR_ENHANCED 0x0002 #define MONITOR_8503 0x0003 #define MONITOR_851X_COLOR 0x0004 #define MONITOR_8514 0x0009 #define MONITOR_FLATPANEL 0x000A #define MONITOR_8507_8604 0x000B #define MONITOR_8515 0x000C #define MONITOR_9515 0x000F #define MONITOR_9517 0x0011 #define MONITOR_9518 0x0012 */ switch (mode) { case 0: // MDA adapter if(vioconfig.display == 0x0000) // monochrome screen w_mode = 2; break; case 1: w_mode= 1; // if((vioconfig.display == 0x0000) || (vioconfig.display == 13)) if(vioconfig.display == 0x0000) w_mode = 2; /* color card with mono screen */ break; case 2: case 3: /* color card */ /* OS/2 2.0 returns 8 for vga */ case 8: w_mode= 1; if(vioconfig.display == 0x0000) w_mode = 2; /* color card with mono screen */ break; case 7: w_mode= 2; /* BW card */ break; /* add more cases here, if needed */ case 10: /* OS/2 2.1 returns 10 for SVGA */ default: w_mode= 1; /* assume color SVGA card */ break; // return FALSE; /* unknown card */ } // vid_buf_length = viomode.buf_length; //#ifdef TESTING DBG_WIN1(dout<<endl<<" viomode.rows = "<< viomode.row<<endl); DBG_WIN1(dout<< "viomode.cols = " <<viomode.col<<endl); DBG_WIN1(dout<< "vid_buf_length = "<< viomode.buf_length<<endl); // writelog( "vid_full_length = %d\n", viomode.full_length); // writelog( "video buf size = %d\n", usvidbufsize); // pause(); // err_exit(" TEST", 14); //#endif return TRUE; }
void VioInit( ) { APIRET rc; UCHAR **cpp; UINT vlen; UINT row; VIOMODEINFO md; memset(&md, 0, sizeof(md) ); md.cb = sizeof(md); if( VioGetMode(&md, 0) ) { printf( "Vio error" ); exit(0); } VideoRows = md.row; VideoCols = md.col; MaxPer = VideoRows - 2 ; /* max # of lines of Code */ MaxData = VideoRows * 2 / 3; /* max # of rows for data window */ MinPer = MaxPer - MaxData; /* min # of lines of Code */ ProRow = VideoRows - 3; /* screen row for prompt (0..N) */ MenuRow = VideoRows - 3; /* screen row for menu bar (0..N) */ FnameRow = VideoRows - 2; /* screen row for file name (0..N) */ HelpRow = VideoRows - 1; /* screen row for menu help (0..N) */ MsgRow = VideoRows - 1; /* screen row for messages (0..N) */ LinesPer = MaxPer - TopLine; /* current # of lines per screen */ /* for source */ VideoMap = vaColor; if( md.color == 1 ) VideoMap = vaMono; rc = VioGetBuf((PULONG)&VideoPtr, (PUSHORT)&vlen, 0); if( rc != 0 ){ printf( "VioGetBuf() returned %d\n", rc ); panic(OOquit); } if( ! HiddenCursor.attr ){ rc = VioGetCurType(&NormalCursor,0); if( rc != 0 ){ printf( "VioGetCurType() returned %d\n", rc ); panic(OOquit); } /*********************************************************************/ /* If the cursor is in insert mode when we enter here then convert */ /* the parms of cursorinfo into a normal mode cursor. */ /*********************************************************************/ if ((NormalCursor.cEnd - NormalCursor.yStart) > 2) NormalCursor.yStart = NormalCursor.cEnd - ((NormalCursor.cEnd - NormalCursor.yStart - 1) / 4); NormalCursor.yStart -= 1; /*112*/ memcpy( &InsertCursor, &NormalCursor, sizeof(InsertCursor) ); /*100*/ InsertCursor.yStart = 0; memcpy( &HiddenCursor, &NormalCursor, sizeof(HiddenCursor) ); /*100*/ HiddenCursor.attr = -1; } /*************************************************************************/ /* - Allocate memory for screen bounds 400*/ /* - set the bounds to the video cols 400*/ /*************************************************************************/ BoundPtr = Talloc(VideoRows); /*521 518*/ if (BoundPtr) /*518*/ memset(BoundPtr,VideoCols,VideoRows); /*518*/ else /*518*/ { /*518*/ printf( "malloc failed\n"); /*518*/ panic(OOquit); /*518*/ } /*518*/ VioStartOffSet = 1; TopLine = 1; MenuRow = 0; LinesPer = MaxPer - TopLine; InitDataWinCsr(); AccessMouse(); HideCursor(); ClrScr( 0, VideoRows-1, vaBptOk ); cpp = banner; for( row = BANNER_ROW; *cpp; cpp++,row++ ) { putrc( row, (VideoCols-strlen(*cpp)) / 2, *cpp ); } }
main() { printf("Cells - A Cellular Automata Demo for OS/2 2.0 \n"); printf(" By John E. Stone \n"); printf("For comments send E-Mail to: [email protected] \n"); printf("\n\n\n\n\n"); printf("The number of states is how many different colors\n"); printf("a pixel can take on. The larger the number of states\n"); printf("the longer it takes to complete, and it may even become\n"); printf("stagnant with more than 20 states.\n\n"); printf("\nProcess ID=%d\n",getpid()); printf("Would you like cells to continue processing when it\n"); printf("isn't visible on the screen? (1=no, 0=yes) \n"); scanf("%u",&VWAIT); if ((VWAIT<0) || (VWAIT>1)) VWAIT=0; printf("\n\nEnter the number of states in the system: (5-25) \n"); scanf("%d",&temp2); st=10; srand(getpid()); if ((temp2>4) || (temp2<26)) { st=temp2; } /* setup for graphics mode */ phys.pBuf=(unsigned char *) 0xA0000; phys.cb=65536; moda.cb=12; moda.fbType=3; moda.color=8; moda.row=25; moda.col=40; moda.hres=320; moda.vres=200; VioGetMode(&orig, HANDLE); VioSetMode(&moda, HANDLE); VioGetPhysBuf(&phys, 0); ptr0=MAKEP(phys.asel[0], 0); VioScrLock(1, &status, HANDLE); /* Wait for exclusive screenlock */ cls(ptr0,0); for (i=0; i<=xs; i++) { for (j=0; j<=ys; j++) { nz[i][j]=(char) rand() % st; oz[i][j]=nz[i][j]; } } numchange=1; while ((kbhit()==0) && (numchange>0)) { numchange=0; for (i=0; i<=xs; i++) { for (j=0; j<=ys; j++) { for (x=0; x<=3; x++) { k=(i+nx[x]+xc) % xc; l=(j+ny[x]+yc) % yc; if (oz[k][l]==((oz[i][j]+1) % st)) { nz[i][j]=(oz[k][l] % st); numchange++; } } } } memcpy(oz,nz,sizeof(nz)); VioScrLock(VWAIT,&status,HANDLE); if (!status) { for (i=0; i<VRES; i++) { for (j=0; j<HRES; j++) { temp=COLORSET+nz[j][i]; putpixel(ptr0,j,i,temp); } } } VioScrUnLock(HANDLE); } VioScrLock(WAIT,&status,HANDLE); cls(ptr0,0); VioScrUnLock(HANDLE); } /* end of cells.c */
USHORT __pascal VIOGETMODE(VIOMODEINFO * ModeInfo, const HVIO Handle) { return VioGetMode(ModeInfo, Handle); }
void xf86OpenConsole() { /* try to catch problems before they become obvious */ os2_checkinstallation(); if (serverGeneration == 1) { HKBD fd; ULONG drive; ULONG dummy; KBDHWID hwid; APIRET rc; int VioTid; ULONG actual_handles; LONG new_handles; /* hv 250197 workaround for xkb-Problem: switch to X11ROOT drive */ char *x11r = getenv("X11ROOT"); /* Make sure X11ROOT is set before we go further sm280297 */ if (x11r == NULL){ ErrorF("The environment variable X11ROOT is not set! The xserver is aborting.\n"); exit(1); } if (_chdir2(x11r) < 0) { ErrorF("xf86-OS/2: Cannot change to X11ROOT directory!\n"); } ErrorF("xf86-OS/2: Console opened\n"); OriginalVideoMode.cb=sizeof(VIOMODEINFO); rc=VioGetMode(&OriginalVideoMode,(HVIO)0); if(rc!=0) ErrorF("xf86-OS/2: Could not get original video mode. RC=%d\n",rc); xf86Info.consoleFd = -1; /* Set the number of handles to higher than the default 20. Set to 80 which should be plenty */ new_handles = 0; rc = DosSetRelMaxFH(&new_handles,&actual_handles); if (actual_handles < 80) { new_handles = 80 - actual_handles; rc = DosSetRelMaxFH(&new_handles,&actual_handles); ErrorF("xf86-OS/2: Increased number of available handles to %d\n",actual_handles); } /* grab the keyboard */ rc = KbdGetFocus(0,0); if (rc != 0) FatalError("xf86OpenConsole: cannot grab kbd focus, rc=%d\n",rc); /* open the keyboard */ rc = KbdOpen(&fd); if (rc != 0) FatalError("xf86OpenConsole: cannot open keyboard, rc=%d\n",rc); xf86Info.consoleFd = fd; ErrorF("xf86-OS/2: Keyboard opened\n"); /* assign logical keyboard */ KbdFreeFocus(0); rc = KbdGetFocus(0,fd); if (rc != 0) FatalError("xf86OpenConsole: cannot set local kbd focus, rc=%d\n",rc); /* Create kbd queue semaphore */ rc = DosCreateEventSem(NULL,&hKbdSem,DC_SEM_SHARED,TRUE); if (rc != 0) FatalError("xf86OpenConsole: cannot create keyboard queue semaphore, rc=%d\n",rc); /* Create popup semaphore */ rc=DosCreateEventSem("\\SEM32\\XF86PUP",&hevPopupPending,DC_SEM_SHARED,1); if(rc) ErrorF("xf86-OS/2: Could not create popup semaphore! RC=%d\n",rc); /* rc=VioRegister("xf86vio","XF86POPUP_SUBCLASS",0x20002004L,0L); if(rc) { FatalError("xf86-OS2: Could not register XF86VIO.DLL module. Please install in LIBPATH! RC=%d\n",rc); } */ /* Start up the VIO monitor thread */ VioTid=_beginthread(os2VideoNotify,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started Vio thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Start up the hard-error VIO monitor thread */ VioTid=_beginthread(os2HardErrorNotify,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started hard error Vio mode monitor thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Start up the kbd monitor thread */ VioTid=_beginthread(os2KbdMonitorThread,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started Kbd monitor thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Disable hard-errors through DosError */ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive)); rc = DosSuppressPopUps(0x0001L,drive+96); /* Disable popups */ rc = KbdSetCp(0,0,fd); if(rc != 0) FatalError("xf86-OS/2: xf86OpenConsole: cannot set keyboard codepage, rc=%d\n",rc); hwid.cb = sizeof(hwid); /* fix crash on P9000 */ rc = KbdGetHWID(&hwid, fd); if (rc == 0) { switch (hwid.idKbd) { default: case 0xab54: /* 88/89 key */ case 0: /*unknown*/ case 1: /*real AT 84 key*/ xf86Info.kbdType = KB_84; break; case 0xab85: /* 122 key */ FatalError("xf86-OS/2: OS/2 has detected an extended 122key keyboard: unsupported!\n"); case 0xab41: /* 101/102 key */ xf86Info.kbdType = KB_101; break; } } else xf86Info.kbdType = KB_84; /*defensive*/ /* Start up the Kbd bit-bucket thread. We don't want to leave the kbd events in the driver queue */ VioTid=_beginthread(os2KbdBitBucketThread,NULL,0x2000,(void *)NULL); ErrorF("xf86-OS/2: Started Kbd bit-bucket thread, Tid=%d\n",VioTid); xf86Config(FALSE); /* Read XF86Config */ } return; }
static int os2vio_init(__AA_CONST struct aa_hardware_params *p,__AA_CONST void *none, struct aa_hardware_params *dest, void *params) { static struct aa_hardware_params def= {NULL, AA_DIM_MASK | AA_REVERSE_MASK | AA_NORMAL_MASK | AA_BOLD_MASK | AA_EXTENDED, 0, 0, 0, 0, 80, 32, 0, 0}; BYTE bCell[2]; VIOCURSORINFO hidecur; #ifdef __EMX__ int idx; struct sigaction sa; #endif *dest=def; /* check size or prompt for it */ if(p->width) width = p->width; else { char c[255]; width = def.recwidth; if(p->recwidth) width = p->recwidth; printf("Width?[%i]", width); gets(c); sscanf(c, "%i", &width); } if (p->height) height = p->height; else { char c[256]; height = def.recheight; if (p->recheight) height = p->recheight; printf("Height?[%i]", height); gets(c); sscanf(c, "%i", &height); } if (p->maxwidth && width > p->maxwidth) width = p->maxwidth; if (p->minwidth && width < p->minwidth) width = p->minwidth; if (p->maxheight && height > p->maxheight) height = p->maxheight; if (p->minheight && height < p->minheight) height = p->minheight; /* set font for modes that we know the size for, default vga16 */ switch(height) { case 50: p->font = &aa_font8; break; case 43: p->font = &aa_font9; break; case 28: p->font = &aa_font14; break; } RowStr = (BYTE *)malloc(2 * width * sizeof(BYTE)); if(RowStr==NULL) return 0; oldMode.cb=sizeof(VIOMODEINFO); VioGetMode((PVIOMODEINFO) &oldMode,(HVIO) 0); VioGetCurType(&oldCurInfo, (HVIO)0); memcpy((void *) &vio_mode, (const void *) &oldMode, sizeof(VIOMODEINFO)); /* VIO, 80x50 */ vio_mode.fbType = 1; vio_mode.color = 4; vio_mode.col = width; vio_mode.row = height; if(width>=132) vio_mode.hres = 1056; else vio_mode.hres = 720; vio_mode.vres = 400; vio_mode.fmt_ID = 0; vio_mode.attrib = 1; if (VioSetMode(&vio_mode, (HVIO) 0)) return 0; #ifdef __EMX__ /* under EMX, catch the signals to clean up proberly */ sa.sa_handler = breakfunc; sa.sa_flags = 0; sigemptyset(&sa.sa_mask); for (idx=SIGHUP;idx<=SIGTERM;idx++) sigaction(idx,&sa,NULL); #endif hidecur.attr = -1; VioSetCurType(&hidecur, (HVIO)0); bCell[0] = 0x20; bCell[1] = ( WM_BLACK << 4 ) + WM_PALEGRAY; VioScrollDn(TOP_ROW,LEFT_COL,0xFFFF,0xFFFF,0xFFFF,bCell,(HVIO) 0); #ifdef 0 printf("minwidth=%d\nminheight=%d\n", p->minwidth, p->minheight); printf("maxwidth=%d\nmaxheight=%d\n", p->maxwidth, p->maxheight); printf("recwidth=%d\nrecheight=%d\n", p->recwidth, p->recheight); printf("mmwidth=%d\nmmheight=%d\n", p->mmwidth, p->mmheight); printf("width=%d\nheight=%d\n", p->width, p->height); if(p->font!=NULL) { printf("fontheight=%d\n", p->font->height); printf("fontname=%s\n", p->font->name); printf("fontname(short)=%s\n", p->font->shortname); } getchar(); #endif return 1; }