|
|
1.1.1.2 ! root 1: /* Created by Microsoft Corp. 1987 ! 2: */ 1.1 root 3: /*** SETEGA.C OS/2 demo program to switch EGA between 25- and 43- line modes 4: * 5: * SETEGA accepts one parameter, which must be either "25" or "43". 6: * Too few or too many parameters, or a parameter other than the two 7: * specified above, will result in an error message and termination 8: * with no action taken. 9: * 10: * This program will work only on machines equipped with a standard EGA. 11: * 12: * SETEGA functions as follows: 13: * 14: * 1) Check parameters 15: * 1.1.1.2 ! root 16: * 2) Clear the screen, using the VioScrollUp function as described 1.1 root 17: * in the CLRSCR example elsewhere in these bulletin boards 18: * 1.1.1.2 ! root 19: * 3) Get current mode information using VioGetMode 1.1 root 20: * 1.1.1.2 ! root 21: * USHORT APIENTRY VioGetMode ( ! 22: * PVIOMODEINFO, ! 23: * HVIO ); 1.1 root 24: * 25: * This call fills a data structure of type 26: * 1.1.1.2 ! root 27: * struct VIOMODEINFO { ! 28: * USHORT cb; ! 29: * UCHAR fbType; ! 30: * UCHAR color; ! 31: * USHORT col; ! 32: * USHORT row; ! 33: * USHORT hres; ! 34: * USHORT vres; ! 35: UCHAR fmt_ID; ! 36: UCHAR attrib; 1.1 root 37: * }; 38: * 39: * whose address we pass in the first parameter. The second 40: * parameter is the VIO handle, a reserved word of zeros. 41: * 42: * 4) We leave all these fields as they are except "row", the number 43: * of alphanumeric rows for this mode. This is changed to the 44: * value specified in our parameter. 45: * 1.1.1.2 ! root 46: * 5) VioSetMode is now used to set the mode. 1.1 root 47: * 1.1.1.2 ! root 48: * USHORT APIENTRY VioSetMode ( ! 49: * PVIOMODEINFO, ! 50: * HVIO ); 1.1 root 51: * 1.1.1.2 ! root 52: * This call has the same parameters as VioGetMode. 1.1 root 53: * We are now set to the desired mode. 54: * 55: * 6) We then set the cursor to an appropriate size and shape. This is 56: * done by filling in a structure of the type 57: * 1.1.1.2 ! root 58: * struct VIOSURSORINFO { ! 59: * USHORT yStart; ! 60: * USHORT cEnd; ! 61: * USHORT cx; ! 62: * USHORT attr; 1.1 root 63: * }; 64: * 1.1.1.2 ! root 65: * with appropriate values, then calling VioSetCurType 1.1 root 66: * 1.1.1.2 ! root 67: * USHORT APIENTRY VioSetCurType ( ! 68: * PVIOCURSORINFO, ! 69: * HVIO ); 1.1 root 70: * 71: * where the second parameter is again the VIO handle, 0. 72: * 73: * 7) Last, we set the cursor to the upper left hand corner of the 1.1.1.2 ! root 74: * screen using VioSetCurPos. 1.1 root 75: * 76: * 77: * Compile using the -Lp option; this program may be bound for use under 78: * real mode. 79: */ 80: 1.1.1.2 ! root 81: #define INCL_SUB ! 82: ! 83: #include <os2def.h> ! 84: #include <bsesub.h> 1.1 root 85: #include <stdio.h> 86: 87: void usage(); 88: 89: void main( argc, argv ) 90: int argc; 91: char *argv[]; 92: { 93: 1.1.1.2 ! root 94: VIOMODEINFO modedata; 1.1 root 95: 1.1.1.2 ! root 96: VIOCURSORINFO cursordata; 1.1 root 97: 98: static char buffer[2] = { 0x20, 0x07 }; /* scrolling fill character */ 99: /* for clearing the screen */ 100: if( argc != 2 ) 101: usage(argv[0]); 102: 103: switch(atoi(argv[1])) { 104: case 43: 1.1.1.2 ! root 105: VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 ); ! 106: modedata.cb = sizeof( modedata ); ! 107: VioGetMode( &modedata, 0 ); 1.1 root 108: modedata.row = 43; 1.1.1.2 ! root 109: VioSetMode( &modedata, 0 ); ! 110: cursordata.yStart = 7; ! 111: cursordata.cEnd = 7; ! 112: cursordata.cx = 1; ! 113: cursordata.attr = 0; ! 114: VioSetCurType( &cursordata, 0 ); ! 115: VioSetCurPos( 0, 0, 0 ); 1.1 root 116: break; 117: 118: case 25: 1.1.1.2 ! root 119: VioScrollUp( 0, 0, -1, -1, -1, (char far *)buffer, 0 ); ! 120: modedata.cb = sizeof( modedata ); ! 121: VioGetMode( &modedata, 0 ); 1.1 root 122: modedata.row = 25; 1.1.1.2 ! root 123: VioSetMode( &modedata, 0 ); ! 124: cursordata.yStart = 12; ! 125: cursordata.cEnd = 13; ! 126: cursordata.cx = 1; ! 127: cursordata.attr = 0; ! 128: VioSetCurType( &cursordata, 0 ); ! 129: VioSetCurPos( 0, 0, 0 ); 1.1 root 130: break; 131: 132: default: 133: usage(argv[0]); 134: } 135: exit(0); 136: } 137: 138: void 139: usage(p) 140: char *p; 141: { 142: printf( "usage: %s 25|43\n", p); 143: exit(1); 144: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.