Category : C Source Code
Archive   : ASPRINTF.ZIP
Filename : ASPRINTF.C

 
Output of file : ASPRINTF.C contained in archive : ASPRINTF.ZIP
ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ Released to the public domain. Documentation is contained in header file ³
³ asprintf.h. ³
³ ³
³ Author: Victor Cummings ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
#include
#include
#include
#include
#include

union REGS regs;

void cdecl far gothere(int x, int y, int page){
regs.h.ah=0x02;
regs.h.bh=page;
regs.h.dh=y-1;
regs.h.dl=x-1;
int86(0x10,®s,®s);
}
unsigned short int cdecl far monochk(void)
{
regs.h.ah=0x0f;
int86(0x10,®s,®s);
if(regs.h.al==0x07)return(0);
else return(1);
}
void cdecl far write_char(char wrchar, int fg, int count, int page)
{
regs.h.ah=0x09; /* use BIOS to write character */
regs.h.al=wrchar; /* pass it the character */
regs.h.bh=page; /* pass it the page */
regs.x.cx=count; /* pass it the count */
regs.h.bl=(fg); /* pass it the color */
int86(0x10,®s,®s); /* call BIOS */
}
void cdecl far graph_write(char *str, int x, int y, int fg, int page, int just)
{
int i=0;
int len=0;
while(str[len]!=0)len++;
switch(just){
case 0: break;
case 1: x-=len-1;
break;
case 2: x-=len/2-1;
};
gothere(x,y,page);
while(str[i]!=0x00){write_char(str[i-1],fg,1,page);gothere(x+i,y,page);i++;}
write_char(str[i-1],fg,1,page);
}
void cdecl far displaypage(int page){
regs.h.ah=0x05;
regs.h.al=page;
int86(0x10,®s,®s);
}
void cdecl far cursoroff(void){
regs.h.ah=0x01;
regs.h.ch=0x20;
regs.h.cl=0x00;
int86(0x10,®s,®s);
}
void cdecl far cursoron(void){
regs.h.ah=0x01;
regs.h.ch=0x06;
regs.h.cl=0x07;
int86(0x10,®s,®s);
}
void cdecl far aswrite(char *str, int x, int y,
int attr, int chgattr, int page, int just){
int i=0;
int len=0;
unsigned char far *colorseg=(char far *)0xb8000000l;
unsigned char far *monoseg =(char far *)0xb0000000l;
while(str[len]!=0)len++;
switch(just){
case 0: break;
case 1: x-=len-1;
break;
case 2: x-=len/2-1;
};

if(monochk()==1){
while(i if((chgattr==0)|(chgattr==2)){colorseg[((y-1)*160)+(i*2)+(2*(x-1))+4096*page]=str[i];}
if((chgattr==1)|(chgattr==2)){colorseg[((y-1)*160)+(i*2)+(2*(x-1))+4096*page+1]=attr;}
i++;
}
}
if(monochk()==0){
while(i if((chgattr==0)|(chgattr==2)){monoseg[((y-1)*160)+(i*2)+(2*(x-1))+4096*page]=str[i];}
if((chgattr==1)|(chgattr==2)){monoseg[((y-1)*160)+(i*2)+(2*(x-1))+4096*page+1]=attr;}
i++;
}
}
}
int cdecl far asprintf (int x, int y, int attr, int chgattr, int page,
int just, int writemode, char *fmt, ... )
{
va_list argptr;
char str[140];
int cnt;
va_start( argptr, format );
cnt=vsprintf( str, fmt, argptr );
if(writemode==0) aswrite(str,x,y,attr,chgattr,page,just);
if(writemode==1) graph_write(str,x,y,attr,page,just);
/*if(writemode==2) outtextxy(x,y,str);*/
va_end( argptr );
return( cnt );
}
void cdecl far altclrscr(char ClearChar){
int i=0;
unsigned char far *colorseg=(char far *)0xb8000000l;
unsigned char far *monoseg=(char far *)0xb0000000l;
if(monochk()==1){
while(i<4001){colorseg[i]=ClearChar;i++;i++;}}
if(monochk()==0){
while(i<4001){monoseg[i]=ClearChar;i++;i++;}}
}

void cdecl far attrclr(char color){
int i=1;
unsigned char far *colorseg=(char far *)0xb8000000l;
unsigned char far *monoseg=(char far *)0xb0000000l;
if(monochk()==1){
while(i<4001){colorseg[i]=color;i++;i++;}}
if(monochk()==0){
while(i<4001){monoseg[i]=color;i++;i++;}}
}



  3 Responses to “Category : C Source Code
Archive   : ASPRINTF.ZIP
Filename : ASPRINTF.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/