예제 #1
0
파일: util.c 프로젝트: xtforever/xtcw
void tseg_set_text(tseg_text_t *ts, char *string )
{
    m_clear( ts->text );
    m_write( ts->text, 0, string, strlen(string)+1 );
    int ms = ts->m_seg;
    int ma = ts->m_attr;
    text_segment_t seg;
    char *s = string;
    int a,b,x,attr = 0;
    while( isspace(*s) ) s++;
    m_clear( ms );
    while(1) {
	memset(&seg,0,sizeof seg);
	if( strlist_cut_word(s,&a,&b)) break;
	if( b-a <= 0 ) break; 
	if( s[b] == '\n' ) seg.format = T_HARD_BREAK;
	
	if( s[a] == '@' ) /* attribute prefix found */
	    {
		a++;
		if( s[a] != '@' ) {
		    if( (x = tseg_get_format(ma,s,&a,&b))) 
			seg.format |= x;
		
		    if( (x=tseg_get_attr(ma, s, &a, &b )) >= 0 ) 
			attr = x;
		}
	    }
	seg.start = (s-string)+a;
	seg.end   = (s-string)+b-1;
	seg.attribute = attr; 
	s+=b;
	m_put( ms, &seg );
    }
}
예제 #2
0
파일: contact.cpp 프로젝트: WilliamRen/qwx
Contact::~Contact() 
{
#if QWX_DEBUG
    qDebug() << "DEBUG:" << __PRETTY_FUNCTION__;
#endif
    m_clear();
}
예제 #3
0
void
cleanup()
{
	m_pop();
	m_clear();
	exit(0);
}
예제 #4
0
void my_clear_bitmap(MBITMAP *b)
{
	ALLEGRO_BITMAP *target = al_get_target_bitmap();
	m_set_target_bitmap(b);
	m_clear(al_map_rgba(0, 0, 0, 0));
	al_set_target_bitmap(target);
}
예제 #5
0
main()
   {

	int clean();

	/* setup MGR */

	m_setup(M_DEBUG);
   m_push(P_FLAGS|P_FONT);
   signal(SIGTERM,clean);
   signal(SIGINT,clean);
   m_setmode(M_OVERSTRIKE);
	m_func(14);
   /* m_font(4); */
	m_clear();

	/* display output */

   conv(stdin);

	/* wait for ack. */

	getpass("\007");
   clean(0);
   }
예제 #6
0
/*{{{  redraw*/
void redraw(int my_width, int my_height)
{
  m_clear();
  m_func(BIT_SRC);
  m_bitcopyto(0,0,my_width/2,my_height,0,0,0,EYE_BITMAP);
  m_bitcopyto(my_width/2,0,my_width/2,my_height,0,0,0,EYE_BITMAP);
}
예제 #7
0
void sendSPI(uint16_t data)
{
  m_clear(SS);
  SPDR = HIGH(data);
  while(!check(SPSR,SPIF));
  SPDR = LOW(data);
  while(!check(SPSR,SPIF));
  m_set(SS);
}
예제 #8
0
파일: ex16.c 프로젝트: xtforever/xtcw
int file_read(int buf, char *fn)
{
    if(buf<=0) buf=m_create(10,1); else m_clear(buf);
    FILE *fp = fopen(fn,"r");
    if(fp) {
        m_fscan(buf,'\n',fp);
        fclose(fp);
    }
    return buf;
}
예제 #9
0
int main(int argc, char *argv[])
{
	int slp = 0;

	ckmgrterm( *argv );

	if (argc>1 && strcmp(argv[1],"-s")==0)
		slp++;

	m_setup(0);
	m_push(P_EVENT|P_FLAGS);
	get_size(&x, &y, &hsize, &vsize);
	rad = (vsize+hsize)>>6;/* size is the avg. of dims. / 32 */

	vx = 5; /* constant horizontal velocity */
	vy = 0;  /* initial vertical velocity of zero */
	x = rad + 1;
	y = rad + 1;

	bcolor = random()%24;
	m_bcolor(bcolor);
	while((lcolor = random()%24) == bcolor);
	m_linecolor(BIT_SRC,lcolor);
	m_fcolor(lcolor);
	m_clear();
	m_circle(x,y,rad);
	for(;;)
	{
		x1 = x +vx; /* add velocity to x */
		if (x1 > MAXX-rad || x1 < rad) {
		/* fix coords if over border */
			vx *= -1;
			x1 += vx;
		}
		vy += ACC; /* accelerate vertical velocity */
		y1 = y + vy; /* add velocity to y */
		if (y1 > MAXY-rad || y1 < rad) {
	                m_circle(x1,MAXY-rad,rad);
			vy = -vy * 95 /100;
                        if (abs(vy) < ACC) {
                           usleep(900000);
                           }
			y1 += vy;
		}
		m_circle(x1,y1,rad); /* draw new position */
		x = x1; /* reset x and y */
		y = y1;
		m_flush();
		if (slp)
		   usleep(90000);
	}
        return 0;
}
예제 #10
0
파일: pipeshell.c 프로젝트: xtforever/xtcw
static void child_input_cb( XtPointer p, int *n, XtInputId *id )
{
    int hc = (int) p;
    struct child_stat *child = mls(CLIST, hc);
    TRACE(trace_child,"");
    if( child_read2(hc) )  {
        child_close(hc);
        return;
    }

    while( mrb_get_line(child->qin,child->line)==1) {
        if( child->cb ) child->cb(hc);
        m_clear(child->line);
    };
}
예제 #11
0
파일: util.c 프로젝트: xtforever/xtcw
/** kopiert ein wort von line nach buf
    führende leerzeichen werden übersprungen 
    trenn-zeichen sind: ",", "=", ":"
    returns: das trenn-zeichen oder -1 falls kein wort gelesen wurde
*/
int cut_id(int line, int *p, int buf )
{
  int ch = -1;
  m_clear(buf);
  if( skip_ws(line,p) < 0 ) return -1;
  while( *p < m_len(line) )
    {
	ch = CHAR(line,*p); (*p)++;
	if(! isspace(ch) && ch != ',' && ch!='=' 
	   && ch != ':' ) m_putc( buf,ch); else break;
    }
  m_putc(buf,0);
  if( m_len(buf) < 2 ) return -1;
  return ch;
}
예제 #12
0
MBITMAP *create_trapezoid(int dir, int topw, int bottomw, int length, MCOLOR color)
{
	MBITMAP *b;

	color.a = 1.0f;
	
	m_push_target_bitmap();

	int flgs = al_get_new_bitmap_flags();
	al_set_new_bitmap_flags(flgs & ~ALLEGRO_NO_PRESERVE_TEXTURE);
	
	if (dir == DIRECTION_NORTH) {
		b = m_create_bitmap(bottomw, length); // check
	}
	else if (dir == DIRECTION_EAST) {
		b = m_create_bitmap(length, bottomw); // check
	}
	else if (dir == DIRECTION_SOUTH) {
		b = m_create_bitmap(bottomw, length); // check
	}
	else {
		b = m_create_bitmap(length, bottomw); // check
	}

	al_set_new_bitmap_flags(flgs);

	m_set_target_bitmap(b);
	m_clear(m_map_rgba(0, 0, 0, 0));

	float y = get_trap_peak(topw, bottomw, length);

	if (dir == DIRECTION_NORTH) {
		m_draw_triangle(bottomw/2, length+y-1, 0, 0, bottomw-1, 0, color);
	}
	else if (dir == DIRECTION_EAST) {
		m_draw_triangle(-y, bottomw/2, length-1, 0, length-1, bottomw-1, color);
	}
	else if (dir == DIRECTION_SOUTH) {
		m_draw_triangle(bottomw/2, -y, bottomw-1, length-1, 0, length-1, color);
	}
	else if (dir == DIRECTION_WEST) {
		m_draw_triangle(length+y-1, bottomw/2, 0, 0, 0, bottomw-1, color);
	}

	m_pop_target_bitmap();

	return b;
}
예제 #13
0
static MBITMAP *clone_sub_bitmap(MBITMAP *b)
{
	ALLEGRO_STATE st;
	al_store_state(&st, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER | ALLEGRO_STATE_NEW_BITMAP_PARAMETERS);

	MBITMAP *clone = m_create_alpha_bitmap(
		m_get_bitmap_width(b),
		m_get_bitmap_height(b)
	);

	m_set_target_bitmap(clone);
	m_clear(al_map_rgba_f(0, 0, 0, 0));

	m_draw_bitmap(b, 0, 0, 0);

	al_restore_state(&st);

	return clone;
}
예제 #14
0
static void mcu_input_cb( XtPointer p, int *n, XtInputId *id )
{
    uint mcuid = (uintptr_t) p;
    struct mcu_comm *mcu = mcu_ptr(mcuid);

    TRACE(1,"input");

    if( mrb_sock_read(mcu->qin, mcu->fd  ) ) {
        mcu_close(mcuid);
        return;
    }

    
    
    while( mrb_get_line(mcu->qin, mcu->line) ) {
    
	if( mcu->callback )
	    mcu->callback(mcu->w, mcu->user, (void*) (intptr_t) mcu->line );
	else
	    dummy_cb(mcu->w, mcu->user, (void*) (intptr_t)mcu->line );
	m_clear(mcu->line);
    }
}
예제 #15
0
void m_flip_display(void)
{
	bool skip_flip = false;

	if (prompt_for_close_on_next_flip) {
		prompt_for_close_on_next_flip = false;
		prepareForScreenGrab2();
		bool hidden = is_cursor_hidden();
		show_mouse_cursor();
		int r = triple_prompt("", "Really quit game or return to menu?", "", "Menu", "Quit", "Cancel", 2, true);
		if (hidden) {
			hide_mouse_cursor();
		}
		if (r == 0) {
			break_main_loop = true;
		}
		else if (r == 1) {
			do_close_exit_game();
		}
		skip_flip = true;
	}
	else if (show_item_info_on_flip >= 0) {
		int tmp = show_item_info_on_flip;
		show_item_info_on_flip = -1;
		prepareForScreenGrab2();
		showItemInfo(tmp, true);
		skip_flip = true;
	}
	else if (show_player_info_on_flip) {
		show_player_info_on_flip = false;
		prepareForScreenGrab2();
		if (player_to_show_on_flip) {
			showPlayerInfo_ptr(player_to_show_on_flip);
			player_to_show_on_flip = NULL;
		}
		else {
			showPlayerInfo_number(player_number_to_show_on_flip);
		}
		skip_flip = true;
	}
	else if (close_pressed_for_configure) {
		close_pressed_for_configure = false;
		int _dx, _dy, _dw, _dh;
		get_screen_offset_size(&_dx, &_dy, &_dw, &_dh);
		ALLEGRO_STATE state;
		al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_NEW_BITMAP_PARAMETERS);
		al_set_new_bitmap_format(al_get_bitmap_format(tmpbuffer->bitmap));
		al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
		ALLEGRO_BITMAP *tmp = al_create_bitmap(
			al_get_bitmap_width(tmpbuffer->bitmap),
			al_get_bitmap_height(tmpbuffer->bitmap)
		);
		al_set_target_bitmap(tmp);
		al_clear_to_color(black);
		al_draw_bitmap(tmpbuffer->bitmap, 0, 0, 0);
		al_restore_state(&state);
		config_menu();
		int __dx, __dy, __dw, __dh;
		get_screen_offset_size(&__dx, &__dy, &__dw, &__dh);
		al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP);
		al_set_target_bitmap(tmpbuffer->bitmap);
		al_clear_to_color(black);
		al_draw_scaled_bitmap(
			tmp,
			_dx, _dy, _dw, _dh,
			__dx, __dy, __dw, __dh,
			0
		);
		al_restore_state(&state);
		al_destroy_bitmap(tmp);
	}

	if (!skip_flip) {
		al_flip_display();
	}

	int xxx, yyy, www, hhh;
	al_get_clipping_rectangle(&xxx, &yyy, &www, &hhh);
	al_set_clipping_rectangle(
		0, 0,
		al_get_display_width(display),
		al_get_display_height(display)
	);
	m_clear(black);
	al_set_clipping_rectangle(xxx, yyy, www, hhh);

	fps_frames++;
	double elapsed = al_get_time() - fps_counter;
	if (fps_on && elapsed > 2) {
		fps = (int)(round((float)fps_frames/elapsed));
		fps_counter = al_get_time();
		fps_frames = 0;
	}
}
예제 #16
0
void
clearit()
{
	get_size(&x, &y, &hsize, &vsize);
	m_clear();
}
예제 #17
0
/*{{{  erase*/
void vd_erase(void)
{
  m_clear();
}
예제 #18
0
파일: edm.c 프로젝트: nionjo/dm
int * breakout(double * ts, int n, int min_size, double beta, int degree, int *ol){

    if (!ts || min_size < 5 || n < 2 * min_size || !ol){
        return NULL;
    }

    double (*G)(double);
    switch(degree){
        case 1 :  G = Linear;
                break;
        case 2 :  G = Quadratic;
                break;
        default : G = Const;
                break;
    }

    int * prev = (int*)malloc(sizeof(int) * (n + 1));
    memset(prev, 0, sizeof(int) * (n + 1));

    int * num  = (int*)malloc(sizeof(int) * (n + 1));
    memset(num, 0, sizeof(int) * (n + 1));

    double * F = (double*)malloc(sizeof(double) * (n + 1));
    memset(F, 0, sizeof(double) * (n + 1));

    MTrace * m1 = m_create((CMP_FN)cmp_fn, NULL);
    MTrace * m2 = m_create((CMP_FN)cmp_fn, NULL);

    for (int s = 2 * min_size; s < n + 1; ++s){
        m_clear(m1); m_clear(m2);
        for (int i = 0; i < min_size - 1; ++i){
            m_add(m1, ts + i);
        }
        for (int i = min_size - 1; i < s; ++i){
            m_add(m2, ts + i);
        }
        for (int t = min_size; t < s - min_size + 1; ++t){
            m_add(m1, ts + t - 1);
            m_remove(m2, ts + t - 1);
            if (prev[t] > prev[t - 1]){
                for (int i = prev[t - 1]; i < prev[t]; ++i){
                    m_remove(m1, ts + i);
                }
            }
            if (prev[t] < prev[t - 1]){
                for (int i = prev[t]; i < prev[t - 1]; ++i){
                    m_add(m1, ts + i);
                }
            }
            double lm = *(double*)get_median(m1);
            double rm = *(double*)get_median(m2);
            double normalize = ((t - prev[t]) * (s - t))       \
                             / ((double)(s - prev[t]) * (s - prev[t]));
            double tmp_s = F[t] + normalize * (lm - rm) * (lm - rm) - beta * G(num[t]);
            if (tmp_s > F[s]){
                num[s] = num[t] + 1;
                F[s] = tmp_s;
                prev[s] = t;
            }
        }
    }
    int k = num[n];
    *ol = k;
    int * re = (int*)malloc(sizeof(int) * k);
    memset(re, 0, sizeof(int) * k);
    int i = n;
    while(i > 0){
        if (prev[i])
            re[--k] = prev[i];
        i = prev[i];
    }

    free(prev); prev = NULL;
    free(num);  num  = NULL;
    free(F);    F    = NULL;
    m_free(m1); m1   = NULL;
    m_free(m2); m2   = NULL;

    return re;
}