static void
flip_page(void) {

   /* do we have to put *our* (messages, progbar) osd to aa's txtbuf ? */
    if (showosdmessage)
      {
	if (time(NULL)>=stoposd ) {
	  showosdmessage=0;
	  if(*osdmessagetext) {
	    memset(c->textbuffer + osdy * aa_scrwidth(c) + osdx,' ',strlen(osdmessagetext));
	    memset(c->attrbuffer + osdy * aa_scrwidth(c) + osdx ,0,strlen(osdmessagetext));
	    osdmessagetext[0] = '\0';
	  }
	  if(*posbar) {
	    memset(c->textbuffer + (osdy+1) * aa_scrwidth(c),' ',strlen(posbar));
	    memset(c->attrbuffer + (osdy+1) * aa_scrwidth(c),0,strlen(posbar));
	  }
	} else {
	  /* update osd */
	  aa_puts(c, osdx, osdy, AA_SPECIAL, osdmessagetext);
	  /* posbar? */
	  if (posbar[0]!='\0')
	    aa_puts(c, 0, osdy + 1, AA_SPECIAL, posbar);
	}
      }
    /* OSD time & playmode , subtitles */
    printosdtext();


    /* print out */
    aa_flush(c);
}
Exemplo n.º 2
0
static void displaytext(int p)
{
    int i;
    int x, x1, a = AA_NORMAL;
    char s[2] =
    {0, 0};
    textclrscr();
    displogo(1);
    for (i = 0; i < aa_scrwidth(context); i++) {
	context->textbuffer[aa_scrwidth(context) * (YSTART - 2) + i] = '_';
    }
    for (i = p; i < p + aa_scrheight(context) - YSTART; i++) {
	if (i < textsize) {
	    x = 0;
	    x1 = 0;
	    for (x1 = x = 0; x < strlen(line[i]); x++, x1++) {
		while (((unsigned char) line[i][x]) < 20)
		    a = line[i][x] - 1, x++;
		if (x < strlen(line[i])) {
		    s[0] = line[i][x];
		    aa_puts(context, x1, i - p + YSTART, a, s);
		}
	    }
	}
	else {
	    x = 0;
	    aa_puts(context, x, i - p + YSTART, AA_NORMAL, "~");
	}
    }
    if (dual) {
	int sh = aa_scrheight(context) - YSTART;
	for (i = p; i < p + (aa_scrheight(context) - YSTART); i++) {
	    if (i + sh < textsize) {
		x = 0;
		x1 = 0;
		for (x1 = x = 0; x < strlen(line[i + sh]); x++, x1++) {
		    while (((unsigned char) line[i + sh][x]) < 20)
			a = line[i + sh][x] - 1, x++;
		    if (x < strlen(line[i + sh])) {
			s[0] = line[i + sh][x];
			aa_puts(context, x1 + aa_scrwidth(context) / 2, i - p + YSTART, a, s);
		    }
		}
	    }
	    else {
		x = 0;
		aa_puts(context, x + aa_scrwidth(context) / 2, i - p + YSTART, AA_NORMAL, "~");
	    }
	}
    }


}
Exemplo n.º 3
0
static void display8()
{
    int i;
    for (i = 0; i < LOGOHEIGHT; i++) {
	aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i, AA_NORMAL, "8  8");
    }
}
Exemplo n.º 4
0
int aa_printf(aa_context *c, int x, int y, enum aa_attribute attr, __AA_CONST char *fmt, ...)
{
  va_list args;
  char buf[1025];
  int i;
  va_start(args,fmt);
  i=vsprintf(buf,fmt,args);
  va_end(args);
  aa_puts(c,x,y,attr,buf);
  return i;
}
Exemplo n.º 5
0
static void displogo(int y)
{
    int x = aa_scrwidth(context) / 2 - 9;
    aa_puts(context, x, y + 0, AA_NORMAL, "     dT8  8Tb");
    aa_puts(context, x, y + 1, AA_NORMAL, "    dT 8  8 Tb");
    aa_puts(context, x, y + 2, AA_NORMAL, "   dT  8  8  Tb");
    aa_puts(context, x, y + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    aa_puts(context, x, y + 4, AA_NORMAL, " dT    8  8    Tb");
    aa_puts(context, x, y + 5, AA_NORMAL, "dT     8  8     Tb");
}
Exemplo n.º 6
0
int main()
{
  context = aa_autoinit(&aa_defparams);
  if(context == NULL) {
    fprintf(stderr,"Cannot initialize AA-lib. Sorry\n");
    return 1;
  }
  
while(true) {
 aa_puts(context, 0, 10, AA_BOLDFONT, "Azerty is cooler dan qwerty");
aa_putpixel(context,50,50, );
aa_render(context, 50, 50, 100, 100);
aa_flush(context);
}


  aa_close(context);
return 0;
}
Exemplo n.º 7
0
static void aa_editdisplay(struct aa_edit *e)
{
    char s[1000];
    int i;
    if (e->cursor > strlen(e->data))
	e->cursor = strlen(e->data);
    if (e->cursor < e->printpos)
	e->printpos = e->cursor;
    if (e->cursor >= e->printpos + e->size)
	e->printpos = e->cursor - e->size;
    if (e->printpos < 0)
	e->printpos = 0;
    strncpy(s, e->data + e->printpos, e->size);
    s[e->size] = 0;
    for (i = strlen(e->data) - e->printpos; i < e->size; i++)
	s[i] = ' ';
    aa_puts(e->c, e->x, e->y, e->clearafterpress ? AA_REVERSE : AA_SPECIAL, s);
    aa_gotoxy(e->c, e->x + e->cursor - e->printpos, e->y);
}
Exemplo n.º 8
0
static void displaya(int p)
{
    int xpos = aa_scrwidth(context) / 2;
    int i;
    for (i = 0; i < LOGOHEIGHT; i++) {
	if (xpos - p - 5 - i >= 0)
	    aa_puts(context, xpos - p - 5 - i, i + LOGOY, AA_NORMAL, " ");
	if (xpos - p - 4 - i >= 0)
	    aa_puts(context, xpos - p - 4 - i, i + LOGOY, AA_NORMAL, "d");
	if (xpos - p - 3 - i >= 0)
	    aa_puts(context, xpos - p - 3 - i, i + LOGOY, AA_NORMAL, "T");
	if (xpos + p + 4 + i < aa_scrwidth(context))
	    aa_puts(context, xpos + p + 4 + i, i + LOGOY, AA_NORMAL, " ");
	if (xpos + p + 3 + i < aa_scrwidth(context))
	    aa_puts(context, xpos + p + 3 + i, i + LOGOY, AA_NORMAL, "b");
	if (xpos + p + 2 + i < aa_scrwidth(context))
	    aa_puts(context, xpos + p + 2 + i, i + LOGOY, AA_NORMAL, "T");
    }
}
Exemplo n.º 9
0
int main(int argc, char **argv)
{
	aa_context *c;
	int i, y;
	char s[256];
	aa_renderparams *p;
	strcpy(s, "line editor.");
	if (!aa_parseoptions(NULL, NULL, &argc, argv) || argc != 1) {
		printf("%s\n", aa_help);
		exit(1);
	}
	c = aa_autoinit(&aa_defparams);
	if (c == NULL) {
		printf("Can not intialize aalib\n");
		exit(2);
	}
	if (!aa_autoinitkbd(c, 0)) {
		printf("Can not intialize keyboard\n");
		aa_close(c);
		exit(3);
	}
	for (i = 0; i < aa_imgwidth(c); i++)
		for (y = 0; y < aa_imgheight(c); y++)
			aa_putpixel(c, i, y, i + y < 80 ? i : ((i + y) < 100 ? (i + y == 89 ? 150 : 0) : y * 8));
	aa_hidecursor(c);
	aa_fastrender(c, 0, 0, aa_scrwidth(c), aa_scrheight(c));
	aa_printf(c, 0, 0, AA_SPECIAL, "Fast rendering routine %i",1);
	aa_flush(c);
	aa_getkey(c, 1);
	aa_edit(c, 0, 1, 20, s, 256);
	aa_puts(c, 0, 0, AA_SPECIAL, "Key lookup test        ");
	aa_flush(c);
	int ch;
	while ((ch = aa_getevent(c, 1)) != ' ') {
		char s[80];
		sprintf(s, "Key event test-space to exit. c:%i", ch);
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
	}
	if (aa_autoinitmouse(c, AA_MOUSEALLMASK)) {
		int co = 0;
		sprintf(s, "Mouse test-space to exit");
		aa_puts(c, 0, 0, AA_SPECIAL, s);
		aa_flush(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_hidemouse(c);
		while (aa_getevent(c, 1) != ' ') {
			int x, y, b;
			char s[80];
			co++;
			aa_getmouse(c, &x, &y, &b);
			sprintf(s, "Hidden mouse test-space to exit. x:%i y:%i b:%i event #%i  ", x, y, b, co);
			aa_puts(c, 0, 0, AA_SPECIAL, s);
			aa_flush(c);
		}
		aa_uninitmouse(c);
	}
	p = aa_getrenderparams();
	for (i = 0; i < AA_DITHERTYPES; i++) {
		p->dither = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, aa_dithernames[i]);
		aa_flush(c);
		aa_getkey(c, 1);
	}
	for (i = 0; i < 255; i += 32) {
		p->bright = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - bright changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->bright = 0;
	for (i = 0; i < 128; i += 16) {
		p->contrast = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - contrast changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->contrast = 0;
	for (i = 0; i < 255; i += 32) {
		p->gamma = 1 + i / 32.0;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - gamma changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	p->gamma = 1.0;
	for (i = 0; i < 255; i += 32) {
		p->randomval = i;
		aa_render(c, p, 0, 0, aa_scrwidth(c), aa_scrheight(c));
		aa_puts(c, 0, 0, AA_SPECIAL, "Normal rendering - randomval changes");
		aa_flush(c);
		aa_getkey(c, 1);
	}
	aa_close(c);
	return 0;
}
Exemplo n.º 10
0
void draw_juggler(int show_loadavg, aa_context *c, JMLib *j) {
	int color;
	int i;
	struct aajm_loadavg load;

	arm* ap = &(j->ap);
	ball* rhand = &(j->rhand);
	ball* lhand = &(j->lhand);
	hand* handp = &(j->handpoly);

	color = 64;
	// draw head
	aa_drawcircle(c,ap->hx, ap->hy,
			ap->hr, color, -1);

	// draw juggler
	for (i=0;i<5;i++) {
		aa_drawline(c, ap->rx[i], ap->ry[i],
			ap->rx[i+1], ap->ry[i+1], color);
		aa_drawline(c, ap->lx[i], ap->ly[i],
			ap->lx[i+1], ap->ly[i+1], color);
	}

	// hands
	for (i=0; i <= 8; i++) {
		aa_drawline(c, rhand->gx + handp->rx[i],
			rhand->gy + handp->ry[i],
			rhand->gx + handp->rx[i+1],
			rhand->gy + handp->ry[i+1], color);
		aa_drawline(c, lhand->gx + handp->lx[i],
			lhand->gy + handp->ly[i],
			lhand->gx + handp->lx[i+1],
			lhand->gy + handp->ly[i+1], color);
	}
	aa_drawline(c, rhand->gx + handp->rx[9],
		rhand->gy + handp->ry[9],
		rhand->gx + handp->rx[0],
		rhand->gy + handp->ry[0], color);
	aa_drawline(c, lhand->gx + handp->lx[9],
		lhand->gy + handp->ly[9],
		lhand->gx + handp->lx[0],
		lhand->gy + handp->ly[0], color);

	color = 255;
	// draw balls
	int diam = (11*j->dpm/DW);
	for(i=j->numBalls()-1;i>=0;i--) {
		aa_drawcircle(c, j->b[i].gx + diam,
				j->b[i].gy + diam,
				diam, color, color);
	}


	aa_render(c, params, 0, 0,
		aa_imgwidth(c), aa_imgheight(c));

	aa_printf(c, 0, 0, AA_SPECIAL,
		gettext("Site: %s    Style: %s    Balls: %i"),
		j->getSite(), j->getStyle(), j->numBalls());

	if(show_loadavg) {
		loadaverage(&load);
		aa_printf(c, 0, 1, AA_SPECIAL,
			"LoadAvg: %2.2f %2.2f %2.2f",
			load.one, load.five, load.fifteen);
	}
	if(j->getStatus() == ST_PAUSE) {
		aa_puts(c, 1, 3, AA_SPECIAL, gettext("Paused"));
	}
	aa_flush(c);

	memset(c->imagebuffer,0,aa_imgwidth(c)*aa_imgheight(c));
}
Exemplo n.º 11
0
void main_loop(int max_iterations, int delay,
		int loadavg_flag, int normal_load, int socket_fd,
		float randomizestyletime, float randomizesitetime) {
	struct timeval starttime, endtime, selecttime;
	struct timeval lastrandomizestyletime={0,0};
	struct timeval lastrandomizesitetime ={0,0};
	struct aajm_loadavg load;
	long speed = DEFSPEED; /* microseconds between frames */
	long load_speed = 0; /* Speed adjustment, based on load */
	int loop_forever = 0;
	char c;
	int i;
	int tmp;
	char newsite[JML_MAX_SITELEN];
	char newstyle[2];

	int accepted_sock = 0; /* FD for accept()ed socket */
	int amount_read = 0; /* Amount read into buffer so far */
	int r; /* Num bytes read in last read() */
	char socket_buffer[MAX_SOCKET_BUFFER]; /* Buffer */
	char command[MAX_SOCKET_BUFFER];
	char data[MAX_SOCKET_BUFFER];
	fd_set socket_set; /* Used for select() */
	socklen_t sin_size; /* Used by accept() */
	struct sockaddr their_addr; /* Used by accept() */
	JML_CHAR **possible_styles;

	int newstyle_index;

	possible_styles = jmlib->getStyles();

	load.one = -1;
	load.five = -1;
	load.fifteen = -1;

	if(delay > 0) {
		speed = delay * 1000;
	}

	if(max_iterations <= 0) {
		loop_forever = 1;
	}

	memset((void *)socket_buffer,0,MAX_SOCKET_BUFFER);
	memset((void *)command,0,MAX_SOCKET_BUFFER);
	memset((void *)data,0,MAX_SOCKET_BUFFER);

	while (1) {
		gettimeofday(&starttime,NULL);
                if (randomizesitetime > 0 &&
                           (starttime.tv_sec -lastrandomizesitetime.tv_sec ) +
                    (float)(starttime.tv_usec-lastrandomizesitetime.tv_usec)/1000000
                     >= randomizesitetime) {
                        randompattern();
                        lastrandomizesitetime.tv_sec  = starttime.tv_sec;
                        lastrandomizesitetime.tv_usec = starttime.tv_usec;
                }
                if (randomizestyletime > 0 &&
                           (starttime.tv_sec -lastrandomizestyletime.tv_sec ) +
                    (float)(starttime.tv_usec-lastrandomizestyletime.tv_usec)/1000000
                      >= randomizestyletime) {
                        jmlib->setStyle("Random");
                        lastrandomizestyletime.tv_sec  = starttime.tv_sec;
                        lastrandomizestyletime.tv_usec = starttime.tv_usec;
                }

		jmlib->doJuggle();
		draw_juggler(loadavg_flag, context, jmlib);

		if(loadavg_flag) {
			loadaverage(&load);
			if(load.one != -1) {
				tmp = (int)(load.one*100 - normal_load);
				load_speed = 5000 * tmp;
			}
		}

		c=aa_getkey(context,0);
		if(c=='s' || c=='S') {
			/* Change SiteSwap */
			memset(newsite,0,JML_MAX_SITELEN);
			strncpy(newsite, jmlib->getSite(), JML_MAX_SITELEN);
			aa_puts(context, 1, 4, AA_SPECIAL,
				gettext("Enter New SiteSwap..."));
			aa_edit(context, 1, 5, 20,
				newsite, JML_MAX_SITELEN);
			if(newsite[0]!=0) {
				jmlib->setPattern(newsite,newsite,
					HR_DEF, DR_DEF);
				jmlib->setStyleDefault();
				jmlib->startJuggle();
			}
		} else if(c=='r' || c=='R') {
                        randompattern();
		} else if(c=='q' || c=='Q' || c==27) {
			/* Quit */
			/* 27 == Escape
			Don't complain. This was a hack before it started */
			return;
		} else if(c==' ' || c=='p' || c=='P') {
			/* Toggle Pause */
			jmlib->togglePause();
		} else if(c=='t' || c=='T') {
			/* Change Style */
			aa_puts(context, 3, 4, AA_SPECIAL,
				gettext("Choose New Style..."));
			for (i=0;i<jmlib->numStyles();i++) {
				aa_printf(context, 3, 5+i, AA_SPECIAL,
					"%i: %s",i+1,possible_styles[i]);
			}
			aa_flush(context);
			memset(newstyle,0,JML_MAX_SITELEN);
			aa_edit(context, 3, 5+i, 2, newstyle, 2);
			if(newstyle[0]!=0) {
				newstyle_index=atoi(newstyle)-1;
				if(newstyle_index>=0
				  && newstyle_index<jmlib->numStyles()) {
					jmlib->setStyle(possible_styles[newstyle_index]);
				}
			}
		} else if(c=='h' || c=='H') {
			/* Help */
			int curr_height = 4;
			aa_puts(context, 3, curr_height, AA_SPECIAL,
				gettext("Key Help"));
			++curr_height;
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("h - This screen"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("s - Change Siteswap"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("r - Random Pattern"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("t - Change Style"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("l - Toggle Load Monitoring"));
#ifdef HAVE_AVCODEC_H
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("m - Dump MPEG"));
#endif
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("q - Quit"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("space - Pause"));
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("+, -, enter - Speed up, down, reset"));
			++curr_height;
			aa_puts(context, 3, ++curr_height, AA_SPECIAL,
				gettext("Press any key to remove this menu"));
			aa_flush(context);
			aa_getkey(context, 1);
		} else if(c=='+' || c=='=' || c=='k') {
			/* Speed Up */
			speed -= 1500;
			if(speed < 0) { speed = 0; }
		} else if(c=='-' || c=='j') {
			/* Speed Down */
			speed += 1500;
#ifdef HAVE_AVCODEC_H
		} else if(c=='m') {
			/* Dump MPEG */
			char mpegname[20];
			memset(mpegname,0,20);
			aa_puts(context, 1, 4, AA_SPECIAL,
				gettext("Enter MPEG Name..."));
			aa_edit(context, 1, 5, 20,
				mpegname, JML_MAX_SITELEN);
			if(mpegname[0]!=0) {
				creatempeg(jmlib, mpegname);
			}
#endif
		} else if(c=='l') {
			/* Toggle Load Monitoring */
			if(loadavg_flag == 1) {
				loadavg_flag = 0;
				load_speed = 0;
			} else {
				loadavg_flag = 1;
			}
		} else if(c==13) {
			/* Speed Reset */
			/* 13 == Enter */
			speed = DEFSPEED;
		}
		gettimeofday(&endtime,NULL);

		selecttime.tv_sec = endtime.tv_sec - starttime.tv_sec;
		if (selecttime.tv_sec != 0) {
			endtime.tv_usec += 1000000*selecttime.tv_sec;
			selecttime.tv_sec = 0;
		}
		selecttime.tv_usec = (speed + load_speed) - 
					(endtime.tv_usec - starttime.tv_usec);
		if(selecttime.tv_usec < 0) {
			selecttime.tv_usec = 1;
		}

		/* IPC Code begins here */
		if(socket_fd <= 0) {
			select(0,NULL,NULL,NULL,&selecttime);
		} else {

		FD_ZERO(&socket_set);
		FD_SET(socket_fd,&socket_set);
		/* accepted_sock is the fd we get
			from accept()ing the socket */
		if(accepted_sock > 0) {
			/* read just one byte */
			r = read(accepted_sock,
				(void *)&socket_buffer[amount_read],1);
			if(r == -1 && errno != EAGAIN) {
			/* EAGAIN means we need to try reading again,
			there wasn't an error, the descriptor just had
			nothing waiting in it
			Else, close the handle reset the other data stuff */
				memset((void *)socket_buffer,0,MAX_SOCKET_BUFFER-amount_read-1);
				close(accepted_sock);
				amount_read = 0;
				accepted_sock = 0;
				memset((void *)data,0,MAX_SOCKET_BUFFER);
				memset((void *)command,0,MAX_SOCKET_BUFFER);
			} else if(r > 0) {
			/* transfer stuff: command=data; If we see an
			'=', everything before it was a command. If we
			see a ';', the stuff before it was data */
				amount_read+=r;
				if(socket_buffer[amount_read-1] == '=') {
					memset((void *)command,0,MAX_SOCKET_BUFFER);
					memcpy((void *)command,(void *)socket_buffer, amount_read-1);
					memset((void *)socket_buffer,0,MAX_SOCKET_BUFFER);
					amount_read = 0;
				} else if(socket_buffer[amount_read-1] == ';') {
					memset((void *)data,0,MAX_SOCKET_BUFFER);
					memcpy((void *)data,(void *)socket_buffer, amount_read-1);
					memset((void *)socket_buffer,0,MAX_SOCKET_BUFFER);
					close(accepted_sock);
					amount_read = 0;
					accepted_sock = 0;
				}
			}
			if(amount_read >= MAX_SOCKET_BUFFER-1) {
			/* Too late, F**k 'em, they're trying
			to overflow us anyway */
				write(accepted_sock,OVERFLOW_ERROR,strlen(OVERFLOW_ERROR));
				memset((void *)socket_buffer,0,MAX_SOCKET_BUFFER);
				close(accepted_sock);
				amount_read = 0;
				accepted_sock = 0;
			}
		}

		if(command[0] != '\0' && data[0] != '\0') {
			if(!strcmp(command,"Style")) {
				jmlib->setStyle(data);
			} else if(!strcmp(command,"Site")) {
				jmlib->setPattern("Something",data,
					HR_DEF, DR_DEF);
				jmlib->setStyleDefault();
				jmlib->startJuggle();
			} else if(!strcmp(command,"Speed")) {
				if(!strcmp(data,"Up")) {
					speed -= 1500;
					if(speed < 0) speed = 0;
				} else if(!strcmp(data,"Down")) {
					speed += 1500;
				} else if(!strcmp(data,"Reset")) {
					speed = DEFSPEED;
				}
			}

			memset((void *)data,0,MAX_SOCKET_BUFFER);
			memset((void *)command,0,MAX_SOCKET_BUFFER);
		}
		if(!strcmp(command,"Quit")) {
			return;
		}
				
		if(select(socket_fd+1, &socket_set,
			NULL, NULL, &selecttime) > 0) {
			if(FD_ISSET(socket_fd,&socket_set) && accepted_sock) {
			/* Just close any subsequent conenctions until
				this one's done */
				close(accept(socket_fd,&their_addr,&sin_size));
			} else if(FD_ISSET(socket_fd,&socket_set) && !accepted_sock) {
			/* Else accept() the socket, and set it to not block */
				sin_size = sizeof(sockaddr);
				accepted_sock = accept(socket_fd,&their_addr, &sin_size);
				fcntl(accepted_sock, F_SETFL, O_NONBLOCK);
			}
		}
		}

		if(!loop_forever && max_iterations-- <= 0) {
			break;
		}
	}
}
Exemplo n.º 12
0
void credits2(void)
{
    int i, ch;
    int p;
    int plast = -1;
    clrscr();

    centerprint(aa_imgwidth(context) / 2, aa_imgheight(context) / 3, 3, 128, "The", 0);
    centerprint(aa_imgwidth(context) / 2, 2 * aa_imgheight(context) / 3, 3, 128, "END", 0);
    drawptr = decrand;
    params->randomval = 50;
    timestuff(0, NULL, draw, 5000000);
    drawptr = NULL;
    params->randomval = 0;
    drawptr = pryc;
    timestuff(0, NULL, draw, MAXTIME);
    drawptr = NULL;
    clrscr();
    draw();
    load_song("bb3.s3m");
    bbupdate();
    starttime = endtime = TIME;
    play();
    bbwait(1);
    for (i = 0; i < LOGOHEIGHT; i++) {
	aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i, AA_BOLD, "8  8");
	if (i)
	    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");
	bbflushwait(100000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");

#define LWIDTH

    for (i = aa_scrwidth(context) / 2; i; i--) {
	display8();
	displaya(i);
	bbflushwait(10000);
    }
    for (; i < 100; i++) {
	textclrscr();
	displaya(10 * sin(i * M_PI / 100));
	display8();
	bbflushwait(10000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_DIM, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_BOLD, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    bbwait(1000000);
    for (i = LOGOY; i > 1; i--) {
	textclrscr();
	displogo(i);
	bbflushwait(30000);
    }

    source = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    target = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    params->dither = AA_NONE;
    format(dual ? aa_scrwidth(context) / 2 : aa_scrwidth(context));
    p = 0;
    while (1) {
	if (p != plast) {
	    getsource();
	    displaytext(p);
	    gettarget();
	    morph();
	    displaytext(p);
	    aa_flush(context);
        emscripten_sleep(1);
	    plast = p;
	}
      again:
    emscripten_sleep(100);
#ifndef __DJGPP__
	//ch = aa_getkey(context, 100);
    ch = AA_NONE;
#else
	while ((ch = bbupdate()) == AA_NONE) ;
#endif

	switch (ch) {
	case '1':
	    load_song("bb.s3m");
	    bbupdate();
	    play();
	    break;
	case '2':
	    load_song("bb2.s3m");
	    bbupdate();
	    play();
	    break;
	case '3':
	    load_song("bb3.s3m");
	    bbupdate();
	    play();
	    break;

	case 'b':
	case 'k':
	case 'B':
	case 'K':
	case AA_BACKSPACE:
	case AA_UP:
	    p -= (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p < 0)
		p = 0;
	    break;
	case AA_DOWN:
	case AA_LEFT:
	case 'f':
	case 'F':
	case ' ':
	case 'j':
	case 'J':
	    p += (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p > textsize)
		p = textsize;
	    break;
	case 'q':
	case 'Q':
	case AA_ESC:
	    finish_stuff = 0;
	    backconvert(0, 0, aa_scrwidth(context), aa_scrheight(context));
	    bbupdate();
	    starttime = endtime = TIME;
	    drawptr = decbright;
	    timestuff(0, NULL, draw, 1000000);
	    textclrscr();
	    drawptr = NULL;
	    aa_flush(context);
        emscripten_sleep(1);
	    free(source);
	    free(target);
	    return;
	default:
	    goto again;
	}
	bbupdate();
	starttime = endtime = TIME;
    }
}