From: billyc AT ncdc DOT cirrus DOT com (billy chen) Newsgroups: comp.os.msdos.djgpp,comp.os.msdos.programmer Subject: Re: Dual monitor debugging? Date: Mon, 01 Dec 1997 22:31:02 GMT Organization: Cirrus Logic NC Lines: 374 Message-ID: <3483399d.17761605@news.cirrus.com> References: <65u9r7$5h9$1 AT news2 DOT xs4all DOT nl> NNTP-Posting-Host: dellp200.rsa.cirrus.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I have MCprint.c and MCprint.h. Your are welcom to have it. No support please. -------------------mcprint.h /* No longer needed it This are suppose to be private functions void save_mcscreen(); void restore_mcscreen(); void scroll_screen(); */ void open_mcprint(int mode); void close_mcprint(); void set_cursor(int x, int y); void mccls(int mode); void mcputs(char *s); void mcputc(char c); void mcprintf(char *format, ... ); -------------------mcprint.c #include #include #include #define MCHIGH 24 #define MCWIDTH 80 #define FIXEDHIGH 25 #define FIXEDWIDTH 80 #define MCHIGH1 (MCHIGH-1) #define MCWIDTH2 MCWIDTH*2 #define FIXEDHIGH1 (FIXEDHIGH-1) #define FIXEDWIDTH2 FIXEDWIDTH*2 unsigned long MC = 0xB0000L; unsigned short mcscreen[FIXEDHIGH][FIXEDWIDTH]; unsigned char oldcursorh, /* position */ oldcursorl; int cursorRow=0, cursorCol=0; int mcprintflag = 0; char buffer[1000]; /* ----------------------------------------------------------------------- Cursor control: 6845 CRT conntroller port location: CGA 3D4/3D5 * MDA 3B4/3B5 register on port 3B4 of MDA offset 0AH scan line for start 0BH scan line for end 200/25 = 8 PCjr 350/25 = 14 MDA offset 0EH 6 bits high order byte 0FH 8 bits low order byte ----------------------------------------------------------------------- */ void set_cursor(int x, int y); void save_mcscreen(); void restore_mcscreen(); void open_mcprint(int mode); void close_mcprint(); void scroll_screen(); void mccls(int mode); void mcputs(char *s); void mcputc(char c); void mcprintf(char *format, ... ); void set_cursor(int x, int y) { unsigned short cp = (unsigned short)(x+y*FIXEDWIDTH); unsigned char h, l; h = (unsigned char)(cp >> 8)&0xff; l = (unsigned char)(cp&0xff); /* set cursor position in the position for MDA */ outportb(0x3b4, 0xe); outportb(0x3b5, h); outportb(0x3b4, 0xf); outportb(0x3b5, l); /* set cursor shape for MDA */ outportb(0x3b4, 0xa); outportb(0x3b5, 1); outportb(0x3b4, 0xb); outportb(0x3b5, 14); } void open_mcprint(int mode) { if( mcprintflag == 1 ) return; save_mcscreen(); mccls(mode); atexit(restore_mcscreen); mcprintflag = 1; } void close_mcprint() { if( mcprintflag == 0 ) return; restore_mcscreen(); mcprintflag = 0; } unsigned char manutextv[82]= "fine fast [j|u +|-]-Scale [l/k o/i 0/9]-next 1/10/100 glyph [h]-Hinting on/off "; unsigned char manuattribv[82]= "pppppppppppppppppppppppp"; unsigned char manutextz[82]= "fine fast [x|c v|b]-Rotation [j|u +|-]-Scale [l/k o/i 0/9]-Next 1/10/100 glyph"; unsigned char manuattribz[82]= "ppppppppppppppppppppppppppppp"; void put_manu(int mode) { int i, j; switch( mode ) { case 1: for( i = 0; i < 80; i++ ){ buffer[j++] = manutextv[i]; buffer[j++] = manuattribv[i]; } break; case 2: for( i = 0; i < 80; i++ ){ buffer[j++] = manutextz[i]; buffer[j++] = manuattribz[i]; } break; default: for( i = 0; i < 80; i++ ){ buffer[j++] = ' '; buffer[j++] = 0x1f; } break; } dosmemput( buffer, MCWIDTH2, MC+FIXEDHIGH1*MCWIDTH2); } void save_mcscreen() { /* keep old cursor position */ outportb(0x3b4, 0xe); oldcursorh = inportb(0x3b5); outportb(0x3b4, 0xf); oldcursorl = inportb(0x3b5); /* keep old data in screen */ dosmemget( 0xB0000, FIXEDWIDTH2*FIXEDHIGH, mcscreen); } void restore_mcscreen() { /* restore old cursor position */ outportb(0x3b4, 0xe); outportb(0x3b5, oldcursorh); outportb(0x3b4, 0xf); outportb(0x3b5, oldcursorl); /* restore old cursor shape use default (a/b is read only regioster) */ outportb(0x3b4, 0xa); outportb(0x3b5, 11); outportb(0x3b4, 0xb); outportb(0x3b5, 13); /* restore old cursor position */ dosmemput( mcscreen, FIXEDWIDTH2*FIXEDHIGH, 0xB0000); } void mccls(int mode) { int i; for( i = 0; i < FIXEDWIDTH2; i++ ) buffer[i]=0; for( i = 0; i < FIXEDHIGH; i++ ) dosmemput( buffer, FIXEDWIDTH2, MC+i*FIXEDWIDTH2); /* set cursor in (0, 0)*/ outportb(0x3b4, 0xe); outportb(0x3b5, 0); outportb(0x3b4, 0xf); outportb(0x3b5, 0); put_manu(mode); } void scroll_screen() { int i; for( i = 0; i < MCHIGH1; i++ ) { dosmemget(MC+(i+1)*MCWIDTH2, MCWIDTH2, buffer); dosmemput( buffer, MCWIDTH2, MC+i*MCWIDTH2); } for( i = 0; i < MCWIDTH2; i++ ) buffer[i] = 0; dosmemput( buffer, MCWIDTH2, MC+MCHIGH1*MCWIDTH2); } void mcputs(char *s) { int i, j, k; k = strlen(s); if( cursorRow >= MCHIGH ) { cursorRow = MCHIGH1; scroll_screen(); } for( i = 1; i < MCWIDTH2; i+=2 ) buffer[i] = 7; /* attrib for mc */ for( i = 0; i < k; i++ ){ j = i<<1; buffer[j] = s[i]; } for( i = k; i < MCWIDTH; i++ ){ j = i<<1; buffer[j] = ' '; } dosmemput( buffer, MCWIDTH2, MC+cursorRow*MCWIDTH2); cursorCol = k; set_cursor(cursorCol, cursorRow); cursorRow++; } #include #include #include char pbuffer[512]; char text[5]; void mcputc(char c) { unsigned long p; switch( c ) { case 10 : cursorRow++; case 13 : cursorCol = 0; break; default: text[0] = c; text[1] = 7; /* attrib */ p = (unsigned long)(cursorCol+cursorRow*MCWIDTH)*2; dosmemput( text, 2, MC+p ); cursorCol++; break; } if( cursorCol >= MCWIDTH ){ cursorCol = 0; cursorRow++; } if( cursorRow >= MCHIGH ){ cursorRow--; scroll_screen( ); } set_cursor( cursorCol, cursorRow ); } void mcprintf(char *format, ... ) { va_list args; int i, k; va_start(args, format); vsprintf(pbuffer, format, args); k = strlen( pbuffer ); if( k > (512-1) ) k = 512-1; for( i = 0; i < k; i++ ) mcputc( pbuffer[i] ); } #ifdef DEBUG main() { mcprintf( " Test one \n\n\n"); getch(); mcprintf( " Test one 1\n\n\n"); getch(); mcprintf( " Test one 2\n\n\n"); getch(); mcprintf( " Test one 3\n\n\n"); getch(); mcprintf( " Test one 4\n\n\n"); mcputs("012332342343242344443223424234423"); mcputs("012332342343242344443223424234423"); mcputs("012332342343242344443223424234423"); mcputs("012332342343242344443223424234423"); mcputs("012332342343242344443223424234423\n"); getch(); mcprintf( " Test one"); getch(); mcprintf( " Test 1"); getch(); mcprintf( " Test 2"); getch(); mcprintf( " Test 3"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test one\n"); getch(); mcprintf( " Test 1\n"); getch(); mcprintf( " Test 2\n"); getch(); mcprintf( " Test 3\n"); getch(); mcprintf( " Test 4\n"); getch(); mcprintf( " Test 5\n"); getch(); mcputs("01233234234324234444322342423441"); getch(); mcputs("0"); getch(); mcputs("01111111111111"); getch(); mcputs("0"); getch(); } #endif On 1 Dec 1997 12:16:39 GMT, rkramer AT xs4all DOT nl () wrote: >Hi all, > >This might be slightly off-topic, but I'm trying to debug my graphics >application using an additional Hercules monitor. Redirecting to a file >doesn't work, because the last (and the only relevant) bit of debug info >is lost after crash/termination of my application.. > >I tried 'mode mono' and mshell by DJ Delorie, but both only move the >blinking cursor on my mono screen - I don't see any text. I'm working in a >Win95 DOS box. Can anyone tell me how to get this working, or point me to >a dual-monitor debugging FAQ or something? Shouldn't I see any text if I >output bytes to b000:0 in DEBUG? (I don't! :) > >Is there a simpler way to do this under Win95, for example redirect stdout >to some window? > >Thanks! > > Rob Kramer > rkramer AT xs4all DOT nl > >P.S. Could you please CC to my personal e-mail address? Ta! > > >