Date: Thu, 3 Jun 93 21:13:43 +0200 From: javier AT orion DOT auto DOT isa DOT cie DOT uva DOT es (Javier Achirica) To: djgpp AT sun DOT soe DOT clarkson DOT edu Hello you all, I've just got the latest version of djgpp and I have made some corrections to the pc library, to better match Borland's conio: - BLINK attribute for colors (textcolor) doesn't work. The bit isn't correctly masked. - clrscr() should move the cursor to the upper left corner after clearing the screen. - putch() doesn't print correctly chars above 127. It should be modified to use unsigned chars. - I've written a cgets() function which should be included in /libsrc/pc/src/gppconio.h - I've written a delay() function that uses a BIOS service that produces delays using system timers. It's a delay.s file. It's also necessary to include a prototype in stdio.h: void delay (unsigned int milliseconds); The file included (libsrc/c/dos/delay.s) replaces libsrc/c/dos/delay.c. The advantage is that multitaskers can detect this call and use the CPU time for other processes. I hope you find it useful. Regards, # * # __ _ __ _ # # __\ | | | <__> \/ \ `==' <__|_ \/ _|_ \__ _|_ ----------------------------- cut here /libsrc/pc/src/gppconio.h ------- *** old\gppconio.c Fri Aug 14 22:22:50 1992 --- gppconio.c Wed Jun 2 21:58:14 1993 *************** *** 89,94 **** void textcolor(int color) { ! ScreenAttrib &= 0xf0; ! txinfo.attribute=(ScreenAttrib |= (color & 0x0f)); } --- 89,94 ---- void textcolor(int color) { ! ScreenAttrib &= 0x70; ! txinfo.attribute=(ScreenAttrib |= (color & 0x8f)); } *************** *** 95,100 **** void textbackground(int color) { ! ScreenAttrib &= 0x0f; ! txinfo.attribute=(ScreenAttrib |= ((color & 0x0f) << 4)); } --- 95,100 ---- void textbackground(int color) { ! ScreenAttrib &= 0x8f; ! txinfo.attribute=(ScreenAttrib |= ((color & 0x07) << 4)); } *************** *** 155,158 **** --- 155,160 ---- for (col=txinfo.winleft-1; col < txinfo.winright; col++) *VIDADDR(row,col) = c; + + ScreenSetCursor(txinfo.wintop - 1, txinfo.winleft - 1); } *************** *** 173,177 **** } else { ! short val = c | (ScreenAttrib << 8); /* puttext(col + 1, row + 1, col + 1, row + 1, &val); */ *VIDADDR(row,col) = val; --- 175,179 ---- } else { ! short val = (unsigned char)c | (ScreenAttrib << 8); /* puttext(col + 1, row + 1, col + 1, row + 1, &val); */ *VIDADDR(row,col) = val; -------------- cut here and include in /libsrc/pc/src/gppconio.c ------- char * cgets (char *str) { int row, col, c, len = 2; short blank = ' ' | (ScreenAttrib << 8); str[2] = 0; if (*str) { do { c = getxkey (); switch (c) { case 8: case 587: ScreenGetCursor (&row, &col); if (len > 2) { if (col == txinfo.winleft - 1) { if (row == txinfo.wintop - 1) break; col = txinfo.winright - 1; row--; } else col--; *VIDADDR (row, col) = blank; len--; } ScreenSetCursor (row, col); str[len] = 0; case 10: case 13: break; default: if (c < 255 && len <= *(unsigned char *) str) { putch (c); str[len++] = c; str[len] = 0; } } } while (c != 13); cputs ("\r\n"); } str[1] = len - 2; return &str[2]; } ----------------------------- cut here /libsrc/c/dos/delay.s ----------- /* A new delay() function for DJGPP Include void delay(unsigned int milliseconds); in stdio.h */ .globl _delay _delay: pushl %edi pushl %esi pushl %ebx movl 16(%esp),%ebx jmp L2 L4: movb $0x86,%ah movw $65535,%cx movw $65240,%dx int $0x15 addl $-4294967,%ebx L2: cmpl $4294967,%ebx ja L4 L3: movl %ebx,%eax sall $5,%eax subl %ebx,%eax leal (%ebx,%eax,4),%eax leal 0(,%eax,8),%ebx movl %ebx,%ecx shrl $16,%ecx movw %bx,%dx movb $0x86,%ah int $0x15 popl %ebx popl %esi popl %edi ret ----------------------------- cut here ---------------------------------