/* Getmode.c gets info on current vio window's mode */ /* API info structure and program output are shown after main func */ #define INCL_VIO #include #include void bitprint(char num); /* routine to print out binary from hex */ int main(void) { HVIO VioHandle; /* Vio handle */ APIRET rc; struct _VIOMODEINFO CurMode; PVIOMODEINFO ModeData; /* ptr to modeinfo struct */ VioHandle = 0; /* non-PM, handle is zero */ ModeData = &CurMode; CurMode.cb = 34; /* max length of modeinfo struct */ rc = VioGetMode(ModeData, VioHandle); printf(" VioGetMode returned: %lu.\n\r", rc); printf(" Length of info structure: %u.\n\r", ModeData->cb); printf("\n\r"); printf(" Mode bitmask (binary): "); bitprint(ModeData->fbType); printf("\n\r"); printf(" Number of colors: %lu.\n\r", (1 << ModeData->color)); printf(" Number of columns, rows: %u, %u.\n\r", ModeData->col, ModeData->row); printf("Resolution (horiz x vert): %u x %u.\n\r", ModeData->hres, ModeData->vres); printf(" Attribute format ID: %u.\n\r", ModeData->fmt_ID); printf(" Attributes per cell: %u.\n\r", ModeData->attrib); printf("\n\r"); printf(" Buffer address: %lx.\n\r", ModeData->buf_addr); printf("Length of physical buffer: %lu.\n\r", ModeData->buf_length); printf(" Size of full buffer save: %lu.\n\r", ModeData->full_length); printf(" Partial (popup) buffer: %lu.\n\r", ModeData->partial_length); printf(" Extended data area addr: %lx.\n\r", ModeData->ext_data_addr); printf("\n\r"); return 0; } void bitprint(char num) { int bit, j; register int mask; mask = 0x80; /* 1000 0000 binary */ for (j=0; j<8; j++) { bit = (mask & num) ? 1 : 0; /* is bit set? 1 if so */ printf("%d",bit); if ( (j==3) ) printf(" "); /* space after 4 bits */ mask >>= 1; /* mask for next binary dgit (bit) */ } } /* struct _VIOMODEINFO { USHORT cb; Length of the entire data structure UCHAR fbType; Bit mask of mode being set UCHAR color; Number of colors (power of 2) USHORT col; Number of text columns USHORT row; Number of text rows USHORT hres; Horizontal resolution USHORT vres; Vertical resolution UCHAR fmt_ID; Attribute format UCHAR attrib; Number of attributes ULONG buf_addr; ULONG buf_length; ULONG full_length; ULONG partial_length; PCH ext_data_addr; } VIOMODEINFO; typedef VIOMODEINFO far *PVIOMODEINFO; ************************************************************************ Example of output: Full Screen OS/2 VIO VioGetMode returned: 0. Length of info structure: 34. Mode bitmask (binary): 0000 0001 Number of colors: 16. Number of columns, rows: 80, 25. Resolution (horiz x vert): 720 x 400. Attribute format ID: 0. Attributes per cell: 1. Buffer address: b8000. Length of physical buffer: 4000. Size of full buffer save: 1048576. Partial (popup) buffer: 8192. Extended data area addr: 0. **************************************************************************** Example of output: OS/2 VIO Window after issuing "Mode.com 80,43" VioGetMode returned: 0. Length of info structure: 34. Mode bitmask (binary): 0000 0001 Number of colors: 16. Number of columns, rows: 80, 43. Resolution (horiz x vert): 640 x 344. Attribute format ID: 0. Attributes per cell: 1. Buffer address: b8000. Length of physical buffer: 6880. Size of full buffer save: 6880. Partial (popup) buffer: 4000. Extended data area addr: 0. *******************************************/