http://www.ousob.com --- Legacy Redefined #include <conio.h> #include <dos.h> #include <extend50.h> #define BELL cprintf("\a"); int far *vb = (int far *)0xB8000000; typedef struct{ unsigned int ch_attr : 8; unsigned int foreGround : 3; unsigned int intensity : 1; unsigned int backGround : 3; unsigned int blink : 1; } ATTR; typedef union{ struct{ unsigned char character; unsigned char attribute; } c; ATTR a; } CHR; CHR ch; void ss(int t, int l, int b, int r, int *aPtr); void rs(int t, int l, int b, int r, int *aPtr); unsigned char gac(int row, int col); int blen(char *string); int bcen(int num, char *string); void bbox(int t,int l,int b,int r,int fg,int bg, int bl,int in, int fi , int sh ); CLIPPER b_errmsg() { int row = _parni(1); char *msg = _parc(2); int fg = _parni(3); int bg = _parni(4); int *tmp, *ptr, ml, col, j; if( !ISNUM(1) && !ISCHAR(2) && !ISNUM(3) && !ISNUM(4) ){ _ret(); return; } if( (ptr = _xalloc(480)) == NULL ){ _ret(); return; } ss( (row-2), 0, (row+3), 79, ptr ); ml = blen(msg); bbox((row-1),(bcen(80,msg)-2),(row+1),+(bcen(80,msg)+ml+1) ,fg ,bg ,0 ,1 ,1 ,1 ); ch.a.foreGround = fg; ch.a.backGround = bg; ch.a.intensity = 1; for(j=0,col = bcen(80,msg); col<bcen(80,msg)+blen(msg); col++,j++){ *(vb + (row*80) + col) = (unsigned char)msg[j] | ch.c.attribute<<8; } BELL getch(); rs( (row-2), 0, (row+3), 79, ptr ); _xfree(ptr); _ret(); } int blen(char *string) { union REGS iRegs,oRegs; struct SREGS segregs; iRegs.x.ax = 0x1225; segregs.ds = FP_SEG( (void far *)string ); iRegs.x.si = FP_OFF( (void far *)string ); int86x(0x2F,&iRegs,&oRegs,&segregs); return(oRegs.x.cx - 1); } int bcen(int num, char *string) { return( (num - blen(string)) / 2 ); } void bbox(int t,int l,int b,int r,int fg,int bg, int bl,int in , int fi , int sh ) { int i,j; int row = t; int col = l; int ht = (b - t); int wd = (r - l); int fill = fi; int shadow = sh; ch.a.foreGround = fg; ch.a.backGround = bg; ch.a.blink = bl; ch.a.intensity = in; if( fill ){ for(i=t; i<=b; i++){ for(j=l; j<=r; j++){ *(vb + i*80 + j) = (unsigned char)' ' | ch.c.attribute<<8; } } } *(vb + (row*80) + col) = (unsigned char)'' | ch.c.attribute<<8; for(col=(l+1); col<(l+wd); col++){ *(vb + (t*80) + col) = (unsigned char)'' | ch.c.attribute<<8; } *(vb + (t*80) + (l+wd) ) = (unsigned char)'' | ch.c.attribute<<8; col = (l + wd ); for(row=(t+1); row<(t+1+ht); row++){ *(vb + (row*80) + col) = (unsigned char)'' | ch.c.attribute<<8; } col = l; for(row=(t+1); row<(t+ht); row++){ *(vb + (row*80) + col) = (unsigned char)'' | ch.c.attribute<<8; } *(vb + (b*80) + l) = (unsigned char)'' | ch.c.attribute<<8; for(col=(l+1); col<(l+wd); col++){ *(vb + (b*80) + col) = (unsigned char)'' | ch.c.attribute<<8; } *(vb + (b*80) + r ) = (unsigned char)'' | ch.c.attribute<<8; ch.a.blink = 0; if( shadow ){ ch.a.foreGround = 8; ch.a.intensity = 1; ch.a.backGround = 0; col = (l + wd + 1); for(row=(t+1); row <=(t+1+ht); row++){ *(vb + (row*80) + col) = gac(row,col) | ch.c.attribute<<8; } row = (b+1); for(col=(l+2); col<(l+2+wd); col++){ *(vb + (row*80) + col) = gac(row,col) | ch.c.attribute<<8; } } } unsigned char gac(int row, int col) { return *(vb + (row * 80) + col); } void ss(int t, int l, int b, int r, int *aPtr) { register int i,j; int *tmp; tmp = aPtr; for(i=t; i<=b; i++){ for(j=l; j<=r; j++){ *aPtr = *(vb + (i * 80) + j); aPtr++; } } aPtr = tmp; } void rs(int t, int l, int b, int r, int *aPtr) { register int i,j; int *tmp; tmp = aPtr; for(i=t; i<=b; i++){ for(j=l; j<=r; j++){ *(vb + (i * 80) + j) = *tmp; tmp++; } } }