
#include<graphics.h>
#include<dos.h>
#include<stdio.h>
void mainscreen1(int sx,int sy,int ex,int ey);
void mainscreen2(int sx,int sy,int ex,int ey);
void har();
void nex();
void main()
{
int gd=DETECT,gm;
int sx,sy,ex,ey;
initgraph(&gd,&gm,"e:\\tc\\bgi");
sx=15;
sy=10;
ex=630;
ey=470;
mainscreen1(sx,sy,ex,ey);
mainscreen2(sx,sy,ex,ey);
har();
nex();
getch();
}


void mainscreen1(int sx,int sy,int ex,int ey)
{
   setfillstyle(1,7);
   bar(sx,sy,ex,ey);
   setfillstyle(1,7);
   setcolor(15);
   line(sx,sy,sx,ey);
   line(sx,sy,ex,sy);
   line(sx,sy,sx,ey);
   line(sx,sy,ex,sy);
   setcolor(0);
   line(ex,sy,ex,ey);
   line(ex,sy,ex,ey);
   line(sx,ey,ex,ey);
   line(sx,ey,ex,ey);


   settextstyle(0,0,0);
   setfillstyle(1,1);
   bar(sx+2,sy+2,ex-2,sy+20);
   setcolor(13);
   settextstyle(8,0,1);
   outtextxy(sx+190,sy-5,"HARDWARE SECTION ");
   //for x
   setfillstyle(1,7);
   bar(ex-15,sy+4,ex-4,sy+15);
   setcolor(15);
   line(ex-15,sy+4,ex-4,sy+4);
   line(ex-15,sy+4,ex-15,sy+15);
   setcolor(0);
   line(ex-15,sy+15,ex-4,sy+15);
   line(ex-4,sy+4,ex-4,sy+15);
   setcolor(1);
   settextstyle(0,0,1);
   outtextxy(ex-13,sy+5,"x");
   setfillstyle(1,7);
}

void mainscreen2(int sx,int sy,int ex,int ey)
{
  sx=sx+15;
  sy=sy+24;
  ex=ex-17;
  ey=ey-9;
 setcolor(0);

   line(sx,sy,sx,ey);
   line(sx,sy,ex,sy);
   line(sx,sy,sx,ey);
   line(sx,sy,ex,sy);
   setcolor(15);
   line(ex,sy,ex,ey);
   line(ex,sy,ex,ey);
   line(sx,ey,ex,ey);
   line(sx,ey,ex,ey);


  }

void har()
{
int x1, i,x2,y1,y3,y2;
setcolor(6);
setfillstyle(1,GREEN);

setcolor(GREEN);




setfillstyle(1,CYAN);
bar(430,160,500,308);// for ic 74126(for second one)
setcolor(15);
line(430,160,430,308);
line(430,160,500,160);
setcolor(0);
line(500,308,500,160);
line(430,308,500,308);
setcolor(BLUE);
line(470,162,470,177);//for first buffer
line(470,162,457,170);
line(470,177,457,170);
//make two distance separation

x1=470;
x2=457;
y1=162;
y2=177;
y3=y2-7;



for(i=1;i<8;i++)
{
setfillstyle(1,BLUE);
floodfill(x1-2,y1+3,BLUE);
y1=y1+18;
y2=y2+18;
y3=y3+18;
line(x1,y1,x1,y2);
line(x1,y1,x2,y3);
line(x1,y2,x2,y3);
setfillstyle(1,BLUE);
floodfill(x1-2,y1+3,BLUE);
}
setfillstyle(1,CYAN);
setcolor(YELLOW);
bar(155,160,225,308);// for ic 74126(first one)
setcolor(15);
line(155,160,155,308);
line(155,160,225,160);
setcolor(0);
line(225,308,225,160);
line(155,308,225,308);
setcolor(BLUE);

x2=200;
x1=185;
y1=162;
y2=177;
y3=y2-7;
for(i=0;i<8;i++)
{

line(x1,y1,x1,y2);
line(x1,y1,x2,y3);
line(x1,y2,x2,y3);
setfillstyle(1,BLUE);
floodfill(x1+2,y1+3,BLUE);
y1=y1+18;
y2=y2+18;
y3=y3+18;
}
setfillstyle(1,MAGENTA);
setcolor(MAGENTA);
bar(290,160,355,308);//for unknown ic
 setcolor(15);
line(290,160,290,308);
line(290,160,355,160);
setcolor(0);
line(355,308,355,160);
line(290,308,355,308);
y3=170-18;
for(i=0;i<8;i++)//for making circles
{
y3+=18;
setcolor(15);
setfillstyle(1,6);
circle(300,y3,4);
circle(345,y3,4);
floodfill(345,y3,15);
floodfill(300,y3,15);
}
y3=170;
setcolor(0);
outtextxy(280,y3-4,"1");
outtextxy(360,y3-4,"9");
y3+=18;
outtextxy(280,y3-4,"2");
outtextxy(360,y3-4,"10");

y3+=18;
outtextxy(280,y3-4,"3");
outtextxy(360,y3-4,"11");
y3+=18;
outtextxy(280,y3-4,"4");
outtextxy(360,y3-4,"12");
y3+=18;
outtextxy(280,y3-4,"5");
outtextxy(360,y3-4,"13");
y3+=18;
outtextxy(280,y3-4,"6");
outtextxy(360,y3-4,"14");

y3+=18;
outtextxy(280,y3-4,"7");
outtextxy(360,y3-4,"15");
y3+=18;
outtextxy(280,y3-4,"8");
outtextxy(360,y3-4,"16");

//numbering session end

y3=170;
setlinestyle(0,0,2);
for(i=0;i<8;i++)
{
setcolor(RED);
line(200,y3,300,y3);
line(457,y3,345,y3);
y3+=18;

}
setcolor(12);
setfillstyle(1,12);
bar(340,330,470,400);//for 74244(second one)
setcolor(15);
line(340,330,340,400);
line(340,330,470,330);
setcolor(0);
line(340,400,470,400);
line(470,330,470,400);
setcolor(RED);
y3=170;
x1=360;
for(i=0;i<8;i++)
{
setcolor(RED);
line(x1,y3,x1,330);
setcolor(0);
setfillstyle(1,0);
circle(x1,y3,2);
floodfill(x1,y3,0);
setcolor(BLUE);
line(x1,400,x1,404+i*5);
line(x1,404+i*5,200+i*13,404+i*5);//for shortcircuiting of two 74244 o/p's
setcolor(0);
setfillstyle(1,0);
circle(200+i*13,404+i*5,2);//shortcuit using circles
floodfill(200+i*13,404+i*5,BLACK);//coloring circles
x1+=13;
y3+=18;
}
setcolor(12);

setfillstyle(1,12);
bar(180,330,310,400);//for 74244(first one)
setcolor(15);
line(180,330,180,400);
line(180,330,310,330);
setcolor(0);
line(180,400,310,400);
line(310,330,310,400);
setcolor(RED);
y3=170;
x1=200;
for(i=0;i<8;i++)
{
setcolor(RED);
line(x1,y3,x1,330);
setcolor(0);
setfillstyle(1,0);
circle(x1,y3,2);
floodfill(x1,y3,0);
setcolor(BLUE);
line(x1,400,x1,445);
x1+=13;
y3+=18;

}
setcolor(4);
outtextxy(200,450,"TO DATA PORT");
outtextxy(200,360,"IC 74244(1)");
outtextxy(360,360,"IC 74244(2)");

//end of 74244 session
setcolor(6);
setfillstyle(1,6);
bar(60,160,120,308);  //for data register(first one)
setcolor(15);
line(60,160,60,308);
line(60,160,120,160);
setcolor(0);
line(120,308,120,160);
line(60,308,120,308);
bar(530,160,590,308); //for data register
setcolor(15);
line(530,160,530,308);
line(530,160,590,160);
setcolor(0);
line(590,308,590,160);
line(530,308,590,308);
y3=170;
for(i=0;i<8;i++)
{
setcolor(5);
line(120,y3,184,y3);
line(60,y3,50,y3);
line(530,y3,471,y3);
line(590,y3,600,y3);
y3+=18;

}
settextstyle(0,1,0);
outtextxy(610,170,"FROM DATA PORT");

outtextxy(45,170,"FROM DATA PORT");
outtextxy(560,170,"DATA REGISTER(2)");
outtextxy(90,170,"DATA REGISTER(1)");

//end of data register section


bar(120,70,250,140); //for control register
setcolor(15);
line(120,70,120,140);
line(120,70,250,70);
setcolor(0);
line(120,140,250,140);
line(250,70,250,140);
setcolor(RED);
bar(410,70,530,140);//for control register 2
setcolor(15);
line(410,70,410,140);
line(410,70,530,70);
setcolor(0);
line(410,140,530,140);
line(530,70,530,140);
setcolor(RED);
settextstyle(0,0,0);
outtextxy(430,100,"CONTROL (2)");
outtextxy(150,100,"CONTROL (1)");
//for control of register1
//for connecting 126(1) to control register
setcolor(14);
setlinestyle(0,1,2);
	y3=175;
	x1=245;
	x2=520;
	for(i=0;i<4;i++)   //for first four lines
	{
	line(190,y3,190,y3+3);
	line(190,y3+3,x1-13*i,y3+3);
	line(x1-13*i,y3+3,x1-13*i,140);//end of first 126
	line(465,y3,465,y3+3);
	line(465,y3+3,x2-13*i,y3+3);
	line(x2-13*i,y3+3,x2-13*i,140);
	line(x2-13*i,70,x2-13*i,50);//for leads
	line(x1-13*i,70,x1-13*i,50);
	y3+=18;
	}
	x1=170;
	x2=455;
	for(i=0;i<4;i++)   //for second four lines
	{
	line(190,y3,190,y3+3);
	line(190,y3+3,x1-13*i,y3+3);
	line(x1-13*i,y3+3,x1-13*i,140);
	line(465,y3,465,y3+3);
	line(465,y3+3,x2-13*i,y3+3);
	line(x2-13*i,y3+3,x2-13*i,140);
	line(x2-13*i,70,x2-13*i,50);
	line(x1-13*i,70,x1-13*i,50);           //for leads
	y3+=18;
	}

	setcolor(MAGENTA);
	outtextxy(x1-40,40,"FROM DATA PORT");
	outtextxy(x2-40,40,"FROM DATA PORT");

setfillstyle(1,RED);
setcolor(RED);
bar(270,70,390,140); //for decoder74138
setcolor(15);
line(270,70,270,140);
line(270,70,390,70);
setcolor(0);
line(270,140,390,140);
line(390,70,390,140);
setcolor(GREEN);
setlinestyle(0,1,3);
setcolor(WHITE);
outtextxy(275,130,"0");
setcolor(13);
line(275,140,275,145);
line(275,145,260,145);
line(260,145,260,120);
line(260,120,250,120);//for control register1
setcolor(WHITE);
outtextxy(290,130,"1");
setcolor(13);
line(293,140,293,145);
line(293,145,400,145);
line(400,145,400,120);
line(400,120,410,120);//for control register2
setcolor(WHITE);
outtextxy(309,130,"2");
setcolor(13);
line(311,140,311,149);
line(311,149,100,149);
line(100,149,100,160);//for data register1
setcolor(WHITE);
outtextxy(325,130,"3");
setcolor(13);
line(329,140,329,149);
line(329,149,550,149);
line(550,149,550,160);//for data register2
setcolor(WHITE);
outtextxy(345,130,"4");
setcolor(13);
line(347,140,347,155);
line(347,155,250,155);
line(250,155,250,316);
line(250,316,170,316);
line(170,316,170,350);
line(170,350,180,350);//for 144(1)
setcolor(WHITE);
outtextxy(362,130,"5");
setcolor(13);
line(365,140,365,160);
line(365,160,390,160);
line(390,160,390,316);
line(390,316,480,316);
line(480,316,480,350);
line(480,350,470,350);//for 144(2)
setcolor(WHITE);
outtextxy(300,100,"DECODER");
setlinestyle(0,1,2);
line(300,70,300,50);
line(320,70,320,50);
line(340,70,340,50);
outtextxy(260,40,"FROM CONTROL PORT");

}

void nex()
{
setcolor(0);
settextstyle(1,0,2);


setcolor(7);
setfillstyle(1,7);
bar(520,340,590,380);//for next
setcolor(0);
outtextxy(530,350,"NEXT");

setcolor(15);
line(520,340,520,380);
line(520,340,590,340);
setcolor(0);
line(520,380,590,380);
line(590,380,590,340);
setcolor(0);
settextstyle(1,0,2);
setfillstyle(1,7);

bar(50,340,120,380);


outtextxy(60,350,"BACK");
setcolor(15);
line(50,340,120,340);
line(50,340,50,380);
setcolor(0);
line(50,380,120,380);
line(120,380,120,340);

}
