Ejemplo n.º 1
50
void Xine::reconfigure(){
  release_device();
  if(!playing)
    return;
  while (playing)
    mmsUsleep(100000);
  setpos(cur_time);
};
Ejemplo n.º 2
0
ss_inst *parse_until(stream_t *stream, char until) {
    char start;
    switch (until) {
        case ')': start = '('; break;
        case ']': start = '['; break;
        case '}': start = '{'; break;
    }
    int count = 1;
    long IP, new_IP;
    new_IP = IP = getpos(stream);
    while (count) {
        char ch = getch(stream);
        if (ch == start) count++;
        else if (ch == until) count--;
    }
    new_IP = getpos(stream);
    int len = new_IP - IP - 1;
    char *buf = calloc(len + 1, sizeof(char));
    setpos(stream, IP);
    getstr(stream, len, buf);
    setpos(stream, new_IP);
    stream_t *sub_stream = init_stream('s', buf);
    ss_inst *expr = init_insts(sub_stream);  /* {expr} */
    close_stream(sub_stream);
    free(buf);
    return expr;
}
Ejemplo n.º 3
0
int get_parsable_length(stream_t *stream) {
    long IP, new_IP;
    new_IP = IP = getpos(stream);
    int diff;
    LOG(DEBUG, "next:: %u", listench(stream));
    while (listench(stream)) {
        diff = bi_parsable(stream);
        if (diff) {
            LOG(DEBUG, "inloop:: %d", diff);
        } else break;
    }
    new_IP = getpos(stream);
    int len = new_IP - IP - 1;
    char *buf = calloc(len + 1, sizeof(char));

    setpos(stream, IP);
    getstr(stream, len, buf);
    setpos(stream, new_IP);
    int pars_len;
    regmatch_t *match = malloc(sizeof(regmatch_t));
    regex_t *pattern = malloc(sizeof(regex_t));
    regcomp(pattern, ".[~#].", 0);

    if (!regexec(pattern, buf, 1, match, 0))
        pars_len = match->rm_so + 2;
    else
        pars_len = len;
    regfree(pattern);
    free(pattern);
    free(match);
    return pars_len;
}
Ejemplo n.º 4
0
void user_serve()
{
	setpos(&user.pos, mix+3, maxy/2);
	setpos(&ball.pos, mix+4, maxy/2);

	redraw();

	user1_serving_now = 1;
}
Ejemplo n.º 5
0
void init_game()
{
	setpos(&user.pos, mix+3, maxy/2);
	setpos(&ball.pos, mix+4, maxy/2);

	setpos(&user2.pos, max-3, maxy/2);

	user.score = 0;
	user2.score = 0;
}
Ejemplo n.º 6
0
help()
{
	char *menu[]={"How To Play","Selecting Option","Credits","About Me","Back"};
	int w=0,k,g=130,h=200;
	setbkcolor(0);
	settextstyle(3,0,3);
	setpos(0,0);
	viewport();
	settextstyle(7,0,5);
	setcolor(14);
	outtextxy(245,100,"HELP");
	settextstyle(1,0,2);
	setcolor(8);
	for(k=0;k<5;k++)
	{
		outtextxy(g,h,menu[k]);
		h+=textheight(menu[k])+10;
	}
	setpos(0,0);
	status("Select Any one using mouse pointer");

	while(1)
	{
		pos(&button,&n,&m);
		w=opt2(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<5;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;
			}
		}
		if(kbhit())
			goto pr;
	}
      //	getch();
	pr:
	return 0;
}
Ejemplo n.º 7
0
credit()
{
	setpos(0,0);
	viewport();
	status("                        Return : [Any key]");
	settextstyle(1,0,3);
	setcolor(14);
	outtextxy(240,50,"Credits");
	settextstyle(1,0,1);
	setcolor(2);
		outtextxy(100,100,"SPEED LEVEL [ 00 - 09 ] : 1 Point");
		outtextxy(100,125,"SPEED LEVEL [ 10 - 19 ] : 2 Points");
		outtextxy(100,150,"SPEED LEVEL [ 20 - 29 ] : 3 Points");
		outtextxy(100,175,"SPEED LEVEL [ 30 - 39 ] : 4 Points");
		outtextxy(100,200,"SPEED LEVEL [ 40 - 49 ] : 5 Points");
		outtextxy(100,225,"SPEED LEVEL [ 50 - 59 ] : 6 Points");
		outtextxy(100,250,"SPEED LEVEL [ 60 - 69 ] : 7 Points");
		outtextxy(100,275,"SPEED LEVEL [ 70 - 79 ] : 8 Points");
		outtextxy(100,300,"SPEED LEVEL [ 80 - 89 ] : 9 Points");
		outtextxy(100,325,"SPEED LEVEL [ 90 - 99 ] : 10 Points");
		outtextxy(100,350,"SPEED LEVEL [ - 100 - ] : 11 Points");
     setcolor(4);
     rectangle(0,400,getmaxx(),getmaxy()-27);
     setcolor(15);
     outtextxy(200,403,"BONUS POINT [ 100 POINTS ]");
     outtextxy(200,430,"\( Valid for 10 Seconds \)");
     getch();
     return 0;
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------------
void istream::getStr(char *str) {
  FatPos_t pos;
  uint16_t i = 0;
  uint16_t m = width() ? width() - 1 : 0XFFFE;
  if (m != 0) {
    getpos(&pos);
    int c = readSkip();

    while (i < m) {
      if (c < 0) {
        break;
      }
      if (isspace(c)) {
        setpos(&pos);
        break;
      }
      str[i++] = c;
      c = getch(&pos);
    }
  }
  str[i] = '\0';
  if (i == 0) {
    setstate(failbit);
  }
  width(0);
}
Ejemplo n.º 9
0
select()
{
	setpos(0,0);
	viewport();
	status("                         Return : [Any key]");
	settextstyle(1,0,3);
	setcolor(14);
	outtextxy(180,50,"Selecting Option");
	settextstyle(1,0,2);
	setcolor(4);
	outtextxy(100,100,"SPEED LEVEL:");
	settextstyle(1,0,1);
	setcolor(2);
	outtextxy(130,130,"To Increase the speed press [->] ");
	outtextxy(130,160,"To Decrease the speed press [<-] ");
	settextstyle(1,0,2);
	setcolor(4);
	outtextxy(100,200,"MAZE LEVEL:");
	settextstyle(1,0,1);
	setcolor(2);
	outtextxy(130,240,"To select the difficulty level \( Maze \)");
	outtextxy(130,280," Use Mouse pointer");
	getch();
	return 0;
}
Ejemplo n.º 10
0
Archivo: editcor.c Proyecto: 8l/FUZIX
PROC
scroll(bool down)
{
    int i;

    if (count <= 0)
	count = dofscroll;
    strput(CURoff);
    if (down) {
	curr = min(bufmax-1, nextline(TRUE, curr, count));
	i = min(bufmax-1, nextline(TRUE, pend, count));
	if (i > pend)
	    scrollforward(i);
    }
    else {
	curr = bseekeol(max(0,nextline(FALSE, curr, count)));
	i = bseekeol(max(0,nextline(FALSE, ptop, count)));
	if (i < ptop)
	    if (canUPSCROLL)
		scrollback(i);
	    else {
		ptop = i;
		setend();
		redisplay(TRUE);
	    }
    }
    strput(CURon);
    setpos(skipws(curr));	/* initialize new position - first nonwhite */
    yp = setY(curr);
    mvcur(yp, xp);		/* go there */
}
Ejemplo n.º 11
0
object::object()
{
    mesh =new Model_3ds();
    setpos(0,0,0);
    setrot(0,0,0);

}
Ejemplo n.º 12
0
void FormantFilter::setfreq_and_q(float frequency, float q_)
{
/*     //Convert form real freq[Hz]
    const float freq = (logf(frequency) / logf(2.0)) - 9.96578428f; //log2(1000)=9.95748f.*/
   Qfactor = q_;
    setpos(frequency); // setpos(freq) // zyn code doesn't seem to do anything ???
}
Ejemplo n.º 13
0
istream& istream::getline(char *str, streamsize n, char delim) {
  FatPos_t pos;
  int c;
  m_gcount = 0;
  if (n > 0) str[0] = '\0';
  while (1) {
    c = getch(&pos);
    if (c < 0) {
      break;
    }
    if (c == delim) {
      m_gcount++;
      break;
    }
    if ((m_gcount + 1)  >=  n) {
      setpos(&pos);
      setstate(failbit);
      break;
    }
    str[m_gcount++] = c;
    str[m_gcount] = '\0';
  }
  if (m_gcount == 0) setstate(failbit);
  return *this;
}
Ejemplo n.º 14
0
/** used to implement ws() */
void istream::skipWhite() {
  int c;
  FatPos_t pos;
  do {
    c = getch(&pos);
  } while (isspace(c));
  setpos(&pos);
}
Ejemplo n.º 15
0
void FormantFilter::setfreq_and_q(float frequency, float q_)
{
    //Convert form real freq[Hz]
    const float freq = log_2(frequency) - 9.96578428f; //log2(1000)=9.95748f.

    Qfactor = q_;
    setpos(freq);
}
Ejemplo n.º 16
0
Reader::LineInfo Reader::getlineinfo (long p) {
    if (p == -1)
        p = pos;
    setpos(0,'^');
    pos = 0;
    char buff[line_size];
    int last_pos, lineno = 1;
    read_line(buff,line_size);
    while (pos < p) {
        lineno++;
        last_pos = pos;
        read_line(buff,line_size);
    }
    int col = p - last_pos;
    setpos(p,'^');
    return {lineno, col};
}
Ejemplo n.º 17
0
topscore()
{
	int k,sco;
	char nam[20],sc[10];
	FILE *file;
	setpos(0,0);
	viewport();
	file=fopen("snake.dat","r");
	//if(file==-1)
	  //	printf("error");
	k=0;

	status("                         Exit : [Any key]   ");
	settextstyle(3,0,4);
	setcolor(14);
	outtextxy(250,50,"Top Score");
	settextstyle(1,0,1);
	setcolor(2);
	outtextxy(100,200,"NO MAZE");
	outtextxy(100,240,"MAZE  1");
	outtextxy(100,280,"MAZE  2");
	outtextxy(100,320,"MAZE  3");
	outtextxy(100,360,"MAZE  4");
	setcolor(13);
	while(fscanf(file,"%s %d\n",nam,&sco)!=EOF)
	{       itoa(sco,sc,10);
	if(k==0)
	{
	outtextxy(300,200,sc);
	outtextxy(400,200,nam);
	}
	else if(k==1)
	{
	outtextxy(300,240,sc);
	outtextxy(400,240,nam);
	}
	else if(k==2)
	{
	outtextxy(300,280,sc);
	outtextxy(400,280,nam);
	}
	else if(k==3)
	{
	outtextxy(300,320,sc);
	outtextxy(400,320,nam);
	}
	else if(k==4)
	{
	outtextxy(300,360,sc);
	outtextxy(400,360,nam);
	}
	k++;
	}

	fclose(file);
	getch();
	return 0;
}
Ejemplo n.º 18
0
/* Random walking even when we've moved
 * To simulate zombie stumbling and ineffective movement
 * Note that this is sub-optimal; stumbling may INCREASE a zombie's speed.
 * Most of the time (out in the open) this effect is insignificant compared to
 * the negative effects, but in a hallway it's perfectly even
 */
void monster::stumble(bool moved)
{
// don't stumble every turn. every 3rd turn, or 8th when walking.
    if((moved && !one_in(8)) || !one_in(3))
    {
        return;
    }

    std::vector <point> valid_stumbles;
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            const int nx = posx() + i;
            const int ny = posy() + j;
            if ((i || j) && can_move_to(nx, ny) &&
                    /* Don't ever stumble into impassable terrain, even if we normally could
                     * smash it, as this is uncoordinated movement (and is forced). */
                    g->m.move_cost(nx, ny) != 0 &&
                    //Stop zombies and other non-breathing monsters wandering INTO water
                    //(Unless they can swim/are aquatic)
                    //But let them wander OUT of water if they are there.
                    !(has_flag(MF_NO_BREATHE) && !has_flag(MF_SWIMS) && !has_flag(MF_AQUATIC)
                      && g->m.has_flag("SWIMMABLE", nx, ny)
                      && !g->m.has_flag("SWIMMABLE", posx(), posy())) &&
                    (g->u.posx != nx || g->u.posy != ny) &&
                    (g->mon_at(nx, ny) == -1)) {
                point tmp(nx, ny);
                valid_stumbles.push_back(tmp);
            }
        }
    }
    if (valid_stumbles.size() == 0) //nowhere to stumble?
    {
        return;
    }

    int choice = rng(0, valid_stumbles.size() - 1);
    int cx = valid_stumbles[choice].x;
    int cy = valid_stumbles[choice].y;

    moves -= calc_movecost(posx(), posy(), cx, cy);
    setpos(cx, cy);

// Here we have to fix our plans[] list,
// acquiring a new path to the previous target.
// target == either end of current plan, or the player.
    int tc;
    if (plans.size() > 0) {
        if (g->m.sees(posx(), posy(), plans.back().x, plans.back().y, -1, tc))
            set_dest(plans.back().x, plans.back().y, tc);
        else if (sees_player( tc ))
            set_dest(g->u.posx, g->u.posy, tc);
        else //durr, i'm suddenly calm. what was i doing?
            plans.clear();
    }
}
Ejemplo n.º 19
0
void		menu_block_palette(t_fox_window *win, t_tekpain *paint)
{
  t_color	color;

  (void) win;
  (void) paint;
  if (win->mouse.state == GO_DOWN)
    {
      paint->current_color = fox_getpixelxy(paint->menu, win->mouse.pos->x,
					    win->mouse.pos->y - 581);
      color.full = paint->current_color;
      fox_draw_rectangle_fill(paint->menu, setpos(87, 123), setpos(30, 30),
			      color);
      color.full = paint->tmp_color[1];
      fox_draw_rectangle_fill(paint->menu, setpos(127, 139), setpos(30, 30),
			      color);
      paint->status = 1;
      paint->is_drug = 0;
    }
}
Ejemplo n.º 20
0
void PololuOutputDevice::outputValue(double value, int output, int speed)
{
    Q_UNUSED(speed);
    if(!enabled)
        return;

    double pos = value;
    pos = qMax(pos, minValue);
    pos = qMin(pos, maxValue);

    setpos(output, pos);
}
Ejemplo n.º 21
0
//------------------------------------------------------------------------------
int istream::peek() {
  int16_t c;
  FatPos_t pos;
  m_gcount = 0;
  getpos(&pos);
  c = getch();
  if (c < 0) {
    if (!bad()) setstate(eofbit);
  } else {
    setpos(&pos);
  }
  return c;
}
Ejemplo n.º 22
0
void PololuOutputDevice::setEnabled(bool e)
{
    OutputDevice::setEnabled(e);
    if(enabled) {
        //open the device(com port) to be non-blocking (read will return immediately)
        devFile.open(QIODevice::WriteOnly);

        if(!devFile.isWritable()) {
            DEBUG << "Device file not writable";
            status = "Device file not writable";
            return;
        }

        int fd = devFile.handle();

        // Set new port settings for canonical input processing
        // TODO: What about windows? This should be ported to QSerialPort
        #ifdef TERMIOS_AVAILABLE
            struct termios newtio;
            newtio.c_cflag = B9600 | CRTSCTS | CS8 | 1 | 0 | 0 | CLOCAL/* | CREAD*/;
            newtio.c_iflag = IGNPAR;
            newtio.c_oflag = 0;
            newtio.c_lflag = 0;       //ICANON;
            newtio.c_cc[VMIN]=1;
            newtio.c_cc[VTIME]=0;
            tcflush(fd, TCIFLUSH);
            tcsetattr(fd,TCSANOW, &newtio);
        #endif

        setpos(0, 127);
        setpos(1, 127);

    } else {
        // Reset all to 127
        foreach(int servo, servopos.keys())
            setpos(servo,127);
        devFile.close();
    }
}
Ejemplo n.º 23
0
names()
{
char na[30];

	setpos(0,0);
	viewport();
	settextstyle(7,0,2);
	setcolor(15);
	outtextxy(80,200,"Enter UR Name : ");
	gotoxy(40,14);
	gets(na);
	strcpy(name,na);
	return 0;
}
Ejemplo n.º 24
0
int vehicle::turret_fire( vehicle_part &pt )
{
    int shots = 0;

    item &gun = pt.base;
    if( !gun.is_gun() ) {
        return false;
    }

    turret_reload( pt );

    switch( turret_query( pt ) ) {
        case turret_status::no_ammo:
            add_msg( m_bad, string_format( _( "The %s is out of ammo." ), pt.name().c_str() ).c_str() );
            break;

        case turret_status::no_power:
            add_msg( m_bad, string_format( _( "The %s is not powered." ), pt.name().c_str() ).c_str() );
            break;

        case turret_status::ready: {
            // Clone the shooter and place them at turret on roof
            auto shooter = g->u;
            shooter.setpos( global_part_pos3( pt ) );
            shooter.add_effect( effect_on_roof, 1 );
            shooter.recoil = abs( velocity ) / 100 / 4;

            tripoint pos = shooter.pos();
            auto trajectory = g->pl_target_ui( pos, gun.gun_range(), &gun, TARGET_MODE_TURRET_MANUAL );
            g->draw_ter();

            if( !trajectory.empty() ) {
                auto mode = gun.gun_current_mode();
                shots = shooter.fire_gun( trajectory.back(), mode.qty, *mode );
            }
            break;
        }

        default:
            debugmsg( "unknown turret status" );
            break;
    }

    turret_unload( pt );
    drain( fuel_type_battery, gun.get_gun_ups_drain() * shots );

    return shots;
}
Ejemplo n.º 25
0
void imgbase::rtt_draw_func()
{
	if(lpt)
	{
		setpos(*nowx, *nowy);
		setsize(*width, *height);
		setrota(*rota, *rota_x, *rota_y);
		g_pd3dD->SetTransform(D3DTS_WORLD,&(scale*rot*trans));
		g_pd3dD->SetTexture( 0, lpt->tex );
		g_pd3dD->SetTextureStageState(0, D3DTSS_ALPHAOP , D3DTOP_SELECTARG1);
		g_pd3dD->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
		g_pd3dD->SetStreamSource( 0, lpVB, 0, sizeof( Vertex ) );
		g_pd3dD->SetFVF( VertexFVF );
		g_pd3dD->DrawPrimitive( D3DPT_TRIANGLESTRIP ,0, 2 );
	}
}
Ejemplo n.º 26
0
  bool LineManager::SetLine(const int line, const int band) {
    if(line < 1) {
      QString message = "LineManager is unable to set the line to [" 
                       + toString(line) + "]. Minimum line value is 1.";
      throw IException(IException::Programmer, message, _FILEINFO_);
    }

    if(band < 1) {
      string message = "LineManager is unable to set the line for band [" 
                       + IString(band) + "]. Minimum band value is 1.";
      throw IException(IException::Programmer, message, _FILEINFO_);
    }

    int map = (band - 1) * MaxLines() + line - 1;
    return setpos(map);
  }
Ejemplo n.º 27
0
int menu()
{
	char *menu[]={"New Game","Option","Instruction","Exit"};
	int w=0,k,g=130,h=200;
	setbkcolor(0);
	initmouse();
	show();
	setcolor(8);
	settextstyle(1,0,2);
	for(k=0;k<4;k++)
	{
		outtextxy(g,h,menu[k]);
		h+=textheight(menu[k])+10;
	}
	settextstyle(4,0,5);
	setcolor(14);
	setpos(0,0);
	outtextxy(190,90,"SNAKE GAME");
	status("Select Any one using mouse pointer");
	while(1)
	{
		pos(&button,&n,&m);
		w=opt(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<4;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;
			}
		}
	}
}
Ejemplo n.º 28
0
int sivakumar()
{
	char men[][20]={"Mazes","Speed Level","Top Scorer List","Back"};
	int w=0,k,g=130,h=200;
	setpos(0,0);
	viewport();
	setcolor(8);
	settextstyle(1,0,2);
	for(k=0;k<4;k++)
	{
		outtextxy(g,h,men[k]);
		h+=textheight(men[k])+10;
	}
	settextstyle(7,0,5);
	setcolor(14);
	outtextxy(210,90,"OPTIONS");
	while(1)
	{
		pos(&button,&n,&m);
		w=opt1(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<4;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,men[k]);
				h+=textheight(men[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,men[k]);
				h+=textheight(men[k])+10;
			}
		}
	}
     //	getch();
}
Ejemplo n.º 29
0
//------------------------------------------------------------------------------
istream& istream::get(char *str, streamsize n, char delim) {
  int c;
  FatPos_t pos;
  m_gcount = 0;
  while ((m_gcount + 1)  < n) {
    c = getch(&pos);
    if (c < 0) {
      break;
    }
    if (c == delim) {
      setpos(&pos);
      break;
    }
    str[m_gcount++] = c;
  }
  if (n > 0) str[m_gcount] = '\0';
  if (m_gcount == 0) setstate(failbit);
  return *this;
}
Ejemplo n.º 30
0
void term_uswitchtable( int gate, char state ) {
    if( gate >= 153 && gate <= 156 ) {
        gate -= (153-18);
    } else {
        gate --;
    }
    if( gate < 0 || gate > 21 ) {
        printf( "INVALID GATE!\n" );
        return;
    }

    int row = gate / 6;
    int col = gate % 6;

    savecur();
    setpos( TABLE_DOWN+1+row, TABLE_LEFT-4+(1+col)*9 );
    putc( state );
    loadcur();
}