Program for implementing all the display functions

Started by Kalyan, Apr 06, 2008, 06:25 PM

Previous topic - Next topic

Kalyan

Program for implementing all the display functions

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<process.h>
#include<iostream.h>
# include<ctype.h>
main()
{
int choice;
char cont='y';
int a1q1(),a1q2(),a1q3(),a1q4(),a1q5(),a1q6(),a1q7(),a1q8(),a1q9(),a1q10();
clrscr();
gotoxy(24,3);
while(cont=='y')
{
  clrscr();
  printf("\n---------------------------------------");
  printf("\n|1.Get current Display Mode.          | ");
  printf("\n|2.Character with chosen attribute.   | ");
  printf("\n|3. Scroll the window up.             | ");
  printf("\n|4.Scroll the window down.            | ");
  printf("\n|5.Read the character & it's attribute| ");
  printf("\n|6.Positioning the Cursor .           | ");
  printf("\n|7.Selecting the Video Mode.          | ");
  printf("\n|8.Selecting the type of the Cursor.  | ");
  printf("\n|9.Reading the Cursor position        | ");
  printf("\n|10.Select the page of the text.      | ");
  printf("\n|11. Exit.                            | ");
  printf("\n---------------------------------------");
  printf("\n\n\t\t Enter your choice [  ]");
  gotoxy(37,16);
  scanf("%d",&choice);
  switch(choice)
  {
   case 1:
     a1q1();
     break;
   case 2:
     a1q2();
     break;
   case 3:
     a1q3();
     break;
   case 4:
     a1q4();
     break;
   case 5:
     a1q5();
     break;
   case 6:
     a1q6();
     break;
   case 7:
     a1q7();
     break;
   case 8:
     a1q8();
     break;
   case 9:
     a1q9();
     break;
   case 10:
     a1q10();
     break;
   case 11:
     exit(0);
  }
gotoxy(3,21);
printf("\nDo you want to continue[y/n]: [ ]");
gotoxy(32,22);
cin>>cont;
}
getch();
}
/****************************************************************************/
a1q1()
{
clrscr();
union REGS regs;
regs.h.ah=0x0f;
int86(0x10,&regs,&regs);
int noofcol;
int displaymode;
int activetextpage;
noofcol = regs.h.ah;
displaymode = regs.h.al;
activetextpage = regs.h.bh;
printf("\n");
printf("\tNo. of Columns on Screen - %d\n",noofcol);
printf("\tDisplay Mode - %d\n",displaymode);
printf("\tThe Active Text Page - %d\n",activetextpage);
return(0);
}
/****************************************************************************/
a1q2()
{
clrscr();
union REGS regs;
regs.h.ah = 2;
regs.h.dh = 0;
regs.h.dl = 0;
regs.h.bh = 0;
int86(0x10,&regs,&regs);

getch();

regs.h.ah = 9;
regs.h.bh = 0;
regs.h.al = 65;
regs.h.dl = 8;
regs.h.cl = 2;
regs.h.ch = 0;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/
a1q3()
{
clrscr();
union REGS regs;
regs.h.ah = 6;
regs.h.al = 5;
regs.h.bh = 8;
regs.h.ch = 0;
regs.h.cl = 0;
regs.h.dh = 50;
regs.h.dl = 50;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/
a1q4()
{
clrscr();
union REGS regs;
regs.h.ah = 7;
regs.h.al = 5;
regs.h.bh = 8;
regs.h.ch = 0;
regs.h.cl = 0;
regs.h.dh = 50;
regs.h.dl = 50;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/
a1q5()
{
clrscr();
int x,y;
union REGS regs;
regs.h.ah = 2;
regs.h.dh = 0;
regs.h.dl = 0;
regs.h.bh = 0;
int86(0x10,&regs,&regs);

getch();

regs.h.ah = 8;
regs.h.bh = 0;
int86(0x10,&regs,&regs);
x = regs.h.al;
y = regs.h.ah;
clrscr();
printf("Ascii Character is - %d\n",x);
printf("The attribute of Character is - %d\n",y);
return(0);
}
/****************************************************************************/
a1q6()
{
clrscr();
int x,y;
union REGS regs;
printf("\n Enter the X-position - ");
scanf("%d",&x);
printf("\n Enter the Y-position - ");
scanf("%d",&y);
regs.h.ah = 2;
regs.h.bh = 0;
regs.h.dh = y;
regs.h.dl = x;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/
a1q7()
{
clrscr();
int choice;
union REGS regs;
printf("\n For CGA Mode(0-6).");
printf("\n For Mono MOde(1).");
printf("\n Select the Mode - ");
scanf("%d",&choice);
clrscr();
regs.h.ah = 0;   /*Set cursor position*/
regs.h.al = choice;
int86(0x10,&regs,&regs);
gotoxy(40,12);
printf("\t\HAVE A NICE DAY");
return(0);
}
/****************************************************************************/
a1q8()
{
clrscr();
int x,y;
union REGS regs;
printf("\n Enter the starting line of the cursor(0-4) - ");
scanf("%d",&x);
printf("\n Enter the ending line of the cursor - ");
scanf("%d",&y);
gotoxy(40,12);
regs.h.ah = 1;
regs.h.ch = x;
regs.h.cl = y;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/
a1q9()
{
clrscr();
union REGS regs;
regs.h.ah = 3;
regs.h.bh = 9;
regs.h.dh = 8;
regs.h.dl = 27;
int86(0x10,&regs,&regs);
printf("\nThe row position of cursor on selected page - %d",regs.h.ch);
printf("\nThe column position of cursor on selected page - %d",regs.h.cl);
return(0);
}
/****************************************************************************/
a1q10()
{
clrscr();
union REGS regs;
regs.h.ah = 5;
regs.h.bh = 6;
int86(0x10,&regs,&regs);
return(0);
}
/****************************************************************************/