| Close | Back |
#include<stdio.h>
#include<dos.h>
#include<conio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<graphics.h>
#include<stdlib.h>
#include<tsr.h>
#define statx 13
#define staty 25
#define ESC 0x1b
main()
{
/*--------------------------------------------------------------*/
/* Declaration segment */
char *menu_items[3]={
"File",
"Edit",
"About"
};
int i,j,store, /*Store to save i when quitting to DOS Shell*/
delay_val=50; /*Delay value*/
struct
{
quit:1; /*Bitfield*//*quit status flag*/
redo:1; /*Ditto *//*redo do-while loop? flag*/
osshell:1; /*osshell flag*/
sts_msg:1; /*Status Message is being dispaled or not?*/
}
flags;
struct time t;
char buffer[8],
osshell[8],
ch;
/* Declaration ends here */
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
/* Initialization begins */
flags.quit=0;
flags.osshell=0;
flags.sts_msg=1;
/* Initialization ends */
/*--------------------------------------------------------------*/
/*--------------------------------------------------------------*/
/* code segment begins */
do
{
if(!flags.osshell)
{
printf("\nEnter the delay value b/w colors in milliseconds\n\
\nPress enter for default value\n\
\nDelay : ");
fflush(stdin);
while(!kbhit());
if((ch=getch())!='\r')
{
ungetc(ch,stdin);
putch(ch);
scanf("%s",buffer);
sscanf(buffer,"%d",&delay_val);
}
#if (defined(DEBUG) && DEBUG==1)
printf("\nDelay_val=%d",delay_val);
getch();
#endif
}
clrscr();
fillcolor();
navbar();
statusbar();
box(1,0,23,79,WHITE,BLUE);
menus(3,menu_items);
*((char far *)(0xB0008000+398)) = ' ';
*((char far *)(0xB0008000+400)) = 'T';
gotoxy(10-strlen("color = "),10);
printf("color = ");
for(i=0;i<=255 && !(flags.quit);i++)
{
if(flags.osshell)
{
if(i<store)
i=store;
flags.osshell=0; /*reset flag*/
}
gotoxy(10,10);
printf("%d",i);
if(flags.sts_msg)
{
gotoxy(statx,staty);
clreol();
printf("Displaying colors");
flags.sts_msg=0;
}
*((char far *)(0xB0008000+399))=i;
*((char far *)(0xB0008000+401))=i;
delay(delay_val);
if(kbhit())
{
if(getch()==ESC)
{
flags.quit=1;
flags.redo=0;
}
else
{
gotoxy(statx,staty);
printf(" Hit a key to continue ..");
flags.sts_msg=1;
getch();
gotoxy(statx,staty);
clreol();
}
}
}
gotoxy(statx,staty);
clreol();
if(!(flags.quit))
{
gettime(&t);
printf("Displaying colors completed at %2d:%02d:%02d.%02d",t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
flags.sts_msg=1;
gotoxy(2,22);
printf("Do once again ? [yn] ");
scanf("%s",buffer);
if(*buffer=='y'||*buffer=='Y')
flags.redo=1;
else
flags.redo=0;
}
else
{
gettime(&t);
printf("User abort at %2d:%02d:%02d.%02d",t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
flags.sts_msg=1;
printf("\n DOS shell [yn]\t");
scanf("%s",osshell);
if(*osshell=='y'||*osshell=='Y')
{
clrscr();
printf("\nEnter 'exit' to return");
flags.quit=0;
flags.redo=1;
store=i;
flags.osshell=1;
system("command");
}
}
}
while(flags.redo);
if(!(flags.quit))
{
gotoxy(statx,staty);
printf("Hit a key to quit ...");
getch();
}
printf("\n\nExiting");
/* code segment ends */
/*--------------------------------------------------------------*/
getch();
}
fillcolor()
{
int i;
textbackground(BLUE);
textcolor(BLUE);
gotoxy(1,2);
for(i=0;i<2000-80;i++)
cprintf("a");
}
navbar()
{
int i;
textbackground(7);
textcolor(7);
gotoxy(1,1);
for(i=0;i<80;i++)
cprintf("a");
}
statusbar()
{
int i;
textbackground(7);
textcolor(7);
gotoxy(1,25);
for(i=0;i<79;i++)
cprintf("a");
{
char far *p=((char far *)(0xB0008000+3999));
*p=122;
}
textbackground(7);
textcolor(BLACK);
gotoxy(1,25);
cprintf(" Status : ");
}
menus(int no_of_menus,char **menu_items)
{
char *blank=" ";
int i;
gotoxy(4,1);
textbackground(7);
for(i=0;i<no_of_menus;i++)
{
int x;
textcolor(BLACK);
cprintf("%s",blank);
cprintf("%s",menu_items[i]);
x=wherex();
gotoxy(x-strlen(menu_items[i]),wherey());
textcolor(RED);
cprintf("%c",menu_items[i][0]);
gotoxy(x,wherey());
}
}
box(int r1,int c1,int r2,int c2,int attrb,int bk)
{
int rr,cc;
/*
clrwin(r1,c1,r2,c2,attrb);
*/
textbackground(bk);
textcolor(attrb);
gotoxy(c1+1,r1+1);
putch(201);
gotoxy(c2+1,r1+1);
putch(187);
gotoxy(c1+1,r2+1);
putch(200);
gotoxy(c2+1,r2+1);
putch(188);
for(rr=r1+1;rr<r2;rr++)
{
gotoxy(c1+1,rr+1);
putch(186);
gotoxy(c2+1,rr+1);
putch(186);
}
for(cc=c1+1;cc<c2;cc++)
{
gotoxy(cc+1,r1+1);
putch(205);
gotoxy(cc+1,r2+1);
putch(205);
}
}