Subj : Re: read foregrnd / backgrnd colors To : borland.public.cpp.borlandcpp From : "Ed Mulroy [TeamB]" Date : Tue Aug 26 2003 08:01 pm I've watched this thread for some time and I do not understand why would be trying to delve under the language to work with the underlying firmware and hardware when he has not yet gotten a full handle on the language. I also do not understand why he would go to so much trouble to be be able to work with an obsolete operating system. If you must use the video interrupts yourself instead of the functions prototyped in CONIO.H which easily do all that for you then it probably would look something like this C program: ------------------------------------------ #include #include #include int screen_width; int screen_height; int current_page; unsigned char far *rows_minus_one_ptr = MK_FP(0x40, 0x84); #define BLINKING 0x80 void GetScreenSize(void) { union REGS r; r.h.ah = 0xF; int86(0x10, &r, &r); screen_width = r.h.ah; current_page = r.h.bh; screen_height = *rows_minus_one_ptr + 1; } #pragma startup GetScreenSize void WhereXY(int *x, int *y) { union REGS r; r.h.ah = 3; r.h.bh = current_page; int86(0x10, &r, &r); *y = r.h.dh + 1; *x = r.h.dl + 1; } void GoToXY(int x, int y) { if ((x > 0) && (x <= screen_width) && (y > 0) && (y <= screen_height)) { union REGS r; r.h.ah = 2; r.h.bh = 0; r.h.dh = y - 1; r.h.dl = x - 1; int86(0x10, &r, &r); } } int main() { char *msg = NULL; int orig_x; int orig_y; int result = EXIT_SUCCESS; FILE *fout = fopen("ScnData.TXT", "wt"); /* save original cursor position */ WhereXY(&orig_x, &orig_y); if (!fout) /* if fopen failed */ { msg = "Error: unable to open output file\n"; result = EXIT_FAILURE; } else /* fopen succeeded */ { int x; int y; fputs("Screen characters and attributes\n" "[x, y] char foreground color background color\n", fout); for (y = 1; y <= screen_height; ++y) { for (x = 1; x <= screen_width; ++x) { union REGS r; int fg; int bg; char *other; GoToXY(x, y); r.h.ah = 8; /* read char & attrib at cursor */ r.h.bh = current_page; int86(0x10, &r, &r); fg = r.h.ah & 0xF; /* fg color is lower 4 bits */ bg = (r.h.ah >> 4) & 7; /* bg is next 3 bits */ if (r.h.ah & BLINKING) other = "Blinking"; else other = " "; fprintf(fout, "[%3d, %3d] \'%c\' %02X %02X %s\n", x, y, r.h.al, fg, bg, other); } } fclose(fout); } GoToXY(orig_x, orig_y); if (msg) printf(msg); return result; } ------------------------------------------ .. Ed > Rob C. wrote in message > news:3f4bd67b$1@newsgroups.borland.com... .