예제 #1
0
파일: CODEGEN2.C 프로젝트: krattai/flosh
/* main menu */
void main(void)
{
	int key,
		buton = 1,
		h,
		v,
		dbon=0,
		dpon=0;

	startup();						/* standard startup sequence */

	mainbuttons();
	mainplates();
	defform("70,70,16,Name,70,90,4,Left,70,110,4,Top,70,130,6,Button,"
			"70,150,8,Action");


	initrat(&rat);
	raton(&rat);

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
			ratoff(&rat);
			if(!dbon)
			{
				showform(0,LLEFT);
				dbon=1;
			}
			else
			{
				eraseform(0,LLEFT);
				dbon=0;
			}
			raton(&rat);
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
			ratoff(&rat);
			if(!dpon)
			{
				showform(0,LLEFT);
				dpon=1;
			}
			else
			{
				eraseform(0,LLEFT);
				dpon=0;
			}
			raton(&rat);
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
		{
			ratoff(&rat);
			clearplates();
			raton(&rat);
			options();
			ratoff(&rat);
			mainplates();
			raton(&rat);
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
	} while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	ratoff(&rat);

	shutdown();						/* standard shutdown sequence */
}
예제 #2
0
파일: ENVIR8.C 프로젝트: krattai/flosh
void main(void)
{
	int key,
		formon = 0,
		buton = 1,
		f2 = 0,
		busy = 0,
		v,
		h,
		z;
	char test;
	int garb;

	startup();						/* standard startup sequence */

	/* Button */
	defbutton(100,450,"End");
	defbutton(400,450,"Help");
	defplate(0,25,"File");
	defplate(58,25,"Form");
    defplate(150,25,"DOS");
	defplate(350,25,"Display");
	defplate(450,25,"Clear");
	defplate(522,25,"Edit");
	defform("50,50,4,test,50,70,8,test2,50,90,6,test3"); 

	initrat(&rat);
	raton(&rat);

	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
			ratoff(&rat);
			if(formon)
			{
				if(f2) busy = 0;
				removeform();
				formon = 0;
			}
			else
			{
				if(f2) busy = 1;
				displayform();
				formon = 1;
			}
			raton(&rat);
		}
		if((rat.buttons == RBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
			garb = spawnle(P_WAIT,"c:\\command.com",NULL,NULL);
			if(garb == -1)
			{
				shutdown();
				perror("\nError");
				getch();
				exit(1);
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
		{
			if(f2 && !busy)
			{
				ratoff(&rat);
				showdata(0,0,testform.fld1);
				showdata(0,1,testform.fld2);
				showdata(0,2,testform.fld3);
				raton(&rat);
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(4,h,v)))
		{
			if(f2 && !busy)
			{
				ratoff(&rat);
				cleanform(0,0,testform.fld1);
				cleanform(0,1,testform.fld2);
				cleanform(0,2,testform.fld3);
				raton(&rat);
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(5,h,v)))
		{
			if(f2 && !busy)
			{
				ratoff(&rat);
				cleanform(0,0,testform.fld1);
				for(z=0;z<=10;z++) testform.fld1[z]=NULL;
				test=get_key();
				z=0;
				while(test != ENTER && z < 4)
				{
					testform.fld1[z]=test;
					showdata(0,0,testform.fld1);
					z++;
					test=get_key();
				}
				cleanform(0,1,testform.fld2);
				for(z=0;z<=10;z++) testform.fld2[z]=NULL;
				test=get_key();
				z=0;
				while(test != ENTER && z < 8)
				{
					testform.fld2[z]=test;
					showdata(0,1,testform.fld2);
					z++;
					test=get_key();
				}
				cleanform(0,2,testform.fld3);
				for(z=0;z<=10;z++) testform.fld3[z]=NULL;
				test=get_key();
				z=0;
				while(test != ENTER && z < 6)
				{
					testform.fld3[z]=test;
					showdata(0,2,testform.fld3);
					test=get_key();
					z++;
				}
				raton(&rat);
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
			ratoff(&rat);
			if(f2)
			{
				eraseform(0,WITHOUT);
				f2 = 0;
			}
			else
			{
				showform(0,WITHOUT);
				f2 = 1;
			}
			raton(&rat);
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
	} while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	ratoff(&rat);

	shutdown();
}
예제 #3
0
파일: CODEGEN2.C 프로젝트: krattai/flosh
void options(void)
{
	int key,
		buton = 1,
		h,
		v;
/*		on=0; */

	ratoff(&rat);
	optionplates();
	raton(&rat);

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			ratoff(&rat);
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
			raton(&rat);
		}
	} while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	ratoff(&rat);
	clearplates();
	raton(&rat);
}
예제 #4
0
파일: CODEGEN3.C 프로젝트: krattai/flosh
/* main menu */
void main(void)
{
	int key,
		buton = 1,
		help = 0,
		h,
		v;

	startup();						/* standard startup sequence */

	mainbuttons();
	mainplates();
	defform("70,70,16,Name,70,90,4,Left,70,110,4,Top,70,130,6,Button,"
			"70,150,8,Action");
	defform("70,70,15,Name,70,90,4,Left,70,110,4,Top,70,130,2,Length");

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
			clearplates();
			if(defbut()) key = ESC;
			mainplates();
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
			clearplates();
			if(defplt()) key = ESC;
			mainplates();
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
			clearplates();
			if(deffrm()) key = ESC;
			mainplates();
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
		{
			clearplates();
			if(options()) key = ESC;
			mainplates();
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		while((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			if(!help)
			{
				buttonoff(1);
			}
			help=1;
			key = checkinput();
			h = rat.horiz;
			v = rat.verti;
		}
		if(help)
		{
			buttonon(1);
			help=0;
		}
	} while(!(((rat.buttons == LBUTTON && key == PRESS) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	shutdown();						/* standard shutdown sequence */
}
예제 #5
0
파일: CODEGEN3.C 프로젝트: krattai/flosh
int deffrm(void)
{
	int key,
		buton = 1,
		h,
		v,
		end=0;
/*		on=0; */

	dbutplt();
	showform(1,LLEFT);

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
			key = ESC;
			end = 1;
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
	} while(!(((rat.buttons == LBUTTON && key == PRESS) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	eraseform(1,LLEFT);
	clearplates();

	if(end)
		return(0);
	else
		return(1);
}
예제 #6
0
파일: CODEGEN3.C 프로젝트: krattai/flosh
int options(void)
{
	int key,
		buton = 1,
		h,
		v,
		end=0;
	int poly[10]={100,100,300,100,300,300,100,300,100,100};
/*		on=0; */

	optionplates();
	defbutton(220,450,"Previous");

	/* while exit not requested */
	do {
		key = checkinput();
		h = rat.horiz;
		v = rat.verti;

		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
		{
		/* This option should toggle printing of file on and off.
			If on, file will be printed when the program that was created
			is saved.
		*/
			ratoff();
			setcolor(CCSLWHITE);
			setfillstyle(SOLID_FILL,CCSLLTBLUE);
			fillpoly(5,poly);
			raton();
			getch();
			ratoff();
			setcolor(CCSLDKBLUE);
			setfillstyle(SOLID_FILL,CCSLDKBLUE);
			fillpoly(5,poly);
			raton();
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
		{
		/* new */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
		{
		/* load */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
		{
		/* save */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(4,h,v)))
		{
		/* write */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(5,h,v)))
		{
		/* save */
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (platehit(6,h,v)))
		{
		/* change type from graphics (default) to text and vice versa */
			ratoff();
			setcolor(CCSLWHITE);
			setfillstyle(SOLID_FILL,CCSLLTBLUE);
			fillpoly(5,poly);
			raton();
			getch();
			ratoff();
			setcolor(CCSLDKBLUE);
			setfillstyle(SOLID_FILL,CCSLDKBLUE);
			fillpoly(5,poly);
			raton();
		}
		if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
		{
			if(buton)
			{
				buttonoff(1);
				buton = 0;
			}
			else
			{
				buttonon(1);
				buton = 1;
			}
		}
		if((rat.buttons == LBUTTON && key == PRESS) && (checkhit(2,h,v)))
		{
			key = ESC;
			end = 1;
		}
	} while(!(((rat.buttons == LBUTTON && key == PRESS) || (key == ENTER))
			&& checkhit(0,h,v) || key == ESC));

	clearplates();
	remove_button(2);

	if(end)
		return(0);
	else
		return(1);
}
예제 #7
0
파일: MACHINER.C 프로젝트: krattai/flosh
int machinery(void)
{
   int key,
       button = 1,
       status = 0,
       h, v;
   machineplates();
   do{
      key = checkinput();
      h = rat.horiz;
      v = rat.verti;
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(0,h,v)))
      {
         clearplates();
         status = farmpower();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(1,h,v)))
      {
         clearplates();
         status = cropping();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(2,h,v)))
      {
         clearplates();
         status = haying();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(3,h,v)))
      {
         clearplates();
         status = specialcrops();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(4,h,v)))
      {
         clearplates();
         status = dairy();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(5,h,v)))
      {
         clearplates();
         status = swine();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(6,h,v)))
      {
         clearplates();
         status = poultry();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(7,h,v)))
      {
         clearplates();
         status = genlvstock();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(8,h,v)))
      {
         clearplates();
         status = misc();
         machineplates();
      }
      if((rat.buttons == LBUTTON && key == PRESS) && (platehit(9,h,v)))
      {
         clearplates();
         status = landlords();
         machineplates();
      }
      if((rat.buttons == RBUTTON && key == HELD) && (checkhit(1,h,v)))
      {
	     if(buton)
		 {
		    buttonoff(1);
			buton = 0;
		 }
		 else
		 {
		    buttonon(1);
			buton = 1;
		 }
	  }
     if((rat.buttons == CBUTTON && key == RELEASE) && (checkhit(1,h,v)))
      {
	     if(buton)
		 {
		    buttonoff(1);
			buton = 0;
		 }
		 else
		 {
		    buttonon(1);
			buton = 1;
		 }
	  }
     if((rat.buttons == LBUTTON && key == PRESS) && (checkhit(2,h,v)))
     {
	    status = 1;
	 }
	 if((rat.buttons == LBUTTON && key == PRESS) && (checkhit(0,h,v)))
     {
		status = 2;
     }
     if (status == 2 || status == 1) key = ESC;
     }while(!(((rat.buttons == LBUTTON && key == RELEASE) || (key == ENTER)) && checkhit(3,h,v) || (key == ESC));
        clearplates();
        return(status);
     }
예제 #8
0
static int
raymove(		/* check for hit as we move */
	FVECT  pos,			/* current position, modified herein */
	OBJECT  *cxs,			/* checked objects, modified by checkhit */
	int  dirf,			/* direction indicators to speed tests */
	RAY  *r,
	CUBE  *cu
)
{
	int  ax;
	double  dt, t;

	if (istree(cu->cutree)) {		/* recurse on subcubes */
		CUBE  cukid;
		int  br, sgn;

		cukid.cusize = cu->cusize * 0.5;	/* find subcube */
		VCOPY(cukid.cuorg, cu->cuorg);
		br = 0;
		if (pos[0] >= cukid.cuorg[0]+cukid.cusize) {
			cukid.cuorg[0] += cukid.cusize;
			br |= 1;
		}
		if (pos[1] >= cukid.cuorg[1]+cukid.cusize) {
			cukid.cuorg[1] += cukid.cusize;
			br |= 2;
		}
		if (pos[2] >= cukid.cuorg[2]+cukid.cusize) {
			cukid.cuorg[2] += cukid.cusize;
			br |= 4;
		}
		for ( ; ; ) {
			cukid.cutree = octkid(cu->cutree, br);
			if ((ax = raymove(pos,cxs,dirf,r,&cukid)) == RAYHIT)
				return(RAYHIT);
			sgn = 1 << ax;
			if (sgn & dirf)			/* positive axis? */
				if (sgn & br)
					return(ax);	/* overflow */
				else {
					cukid.cuorg[ax] += cukid.cusize;
					br |= sgn;
				}
			else
				if (sgn & br) {
					cukid.cuorg[ax] -= cukid.cusize;
					br &= ~sgn;
				} else
					return(ax);	/* underflow */
		}
		/*NOTREACHED*/
	}
	if (isfull(cu->cutree)) {
		if (checkhit(r, cu, cxs))
			return(RAYHIT);
	} else if (r->ro == &Aftplane && incube(cu, r->rop))
		return(RAYHIT);
					/* advance to next cube */
	if (dirf&0x11) {
		dt = dirf&1 ? cu->cuorg[0] + cu->cusize : cu->cuorg[0];
		t = (dt - pos[0])/r->rdir[0];
		ax = 0;
	} else
		t = FHUGE;
	if (dirf&0x22) {
		dt = dirf&2 ? cu->cuorg[1] + cu->cusize : cu->cuorg[1];
		dt = (dt - pos[1])/r->rdir[1];
		if (dt < t) {
			t = dt;
			ax = 1;
		}
	}
	if (dirf&0x44) {
		dt = dirf&4 ? cu->cuorg[2] + cu->cusize : cu->cuorg[2];
		dt = (dt - pos[2])/r->rdir[2];
		if (dt < t) {
			t = dt;
			ax = 2;
		}
	}
	VSUM(pos, pos, r->rdir, t);
	return(ax);
}