/* SCREENSZ.C */ /* Queery system for screen size */ /* Coding for TC 2.0 */ /* After fruitlessly trying to find out how to find a modified screen's row and column, I finally found the memory location needed in COMPUTE!'s Mapping the IBM PC and PCjr. (1985, Page 182) I looked at the TC reference guide and The MSDOS Encyclopedia to no avail. (It might be in the Encyclopedia, but I couldn't find it!) This code fragment is very useful when a screen is changed to 40/43/50 lines (using Norton's NCC for example). Coding by Albert Stein, Chemical Bank, 212-310-3927 Software Ideology PO Box 305, Brooklyn, NY 11204 Any comments are welcome. Enjoy! */ #include #include #include #include #define STATE 15 void read_screensize (int *rows, int *cols,int type); int rows,cols; void main() { read_screensize (&rows,&cols,1); printf ("reported by bios: rows=%d cols=%d\n",rows,cols); read_screensize (&rows,&cols,0); printf ("reported by location: rows=%d cols=%d\n",rows,cols); } void read_screensize (int *rows, int *cols,int type) { union REGS regs; unsigned int value; unsigned int far *pvalue = &value; if (type == 1) { regs.h.ah = 0x0F; int86(0x10,®s,®s); *cols = regs.h.ah; switch (regs.h.al) { case 0x00: case 0x01: case 0x02: case 0x03: case 0x07: *rows = 25; break; default: printf ("Unexpected mode=0x%02x\n",regs.h.al); getch(); } } else { movedata (0x000,0x044A,FP_SEG(pvalue),FP_OFF(pvalue),2); *cols = *pvalue; /* this will return the total memory space in use */ movedata (0x000,0x044C,FP_SEG(pvalue),FP_OFF(pvalue),2); *rows = *pvalue / (*cols * 2); } }