Beispiel #1
0
static void menu_left_transition(menu_st *menulist)
{
	menu_st *m;
	int i, jump;

	m = menulist->parent;
	GrCopyArea(m->transition, menulist->menu_gc, m->w, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);

	if (m->scheme_no != appearance_get_color_scheme()) {
		m->menu_wid = m->transition;
		m->x = 0;
		m->y = 0;

		menu_draw(m);

		m->menu_wid = menulist->menu_wid;
		m->x = menulist->x;
		m->y = menulist->y;
	}
	
	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		m->w / TRANSITION_STEPS : 0;
	for (i = TRANSITION_STEPS; i; i--) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, m->transition,
				i * jump, 0, 0);
	}
}
Beispiel #2
0
static menu_st *menu_right_transition(menu_st *menulist, item_st *item)
{
	menu_st *m;
	int i, jump;

	GrCopyArea(menulist->transition, menulist->menu_gc, 0, 0,
			menulist->w, menulist->h, menulist->menu_wid,
			menulist->x, menulist->y, 0);
	m = menu_init(menulist->transition, item->text,
			menulist->w, 0, menulist->w, menulist->h,
			menulist, (item_st *)item->action, menulist->op);
	menu_draw(m);

	m->menu_wid = menulist->menu_wid;
	m->x = menulist->x;
	m->y = menulist->y;

	jump = (ipod_get_setting(SLIDE_TRANSIT)) ?
		menulist->w / TRANSITION_STEPS : 0;
	for (i = 0; i < TRANSITION_STEPS; i++) {
		GrCopyArea(menulist->menu_wid, menulist->menu_gc,
				menulist->x, menulist->y, menulist->w,
				menulist->h, menulist->transition,
				(i + 1) * jump, 0, 0);
	}
	return m;
}
static void afterzure(void){
	int kari;
	wafter.mozi=wyomidata.mapd[wafter.x-1][wafter.y-1];
	kari=pictx(wafter.mozi);
	GrCopyArea(allmap_pixmap,keyman_gc,((wafter.x-1)*16),((wafter.y-1)*16),16,16,yomipict_pixmap,kari,0,0);
	wafter.mozi=wyomidata.mapd[wafter.x-1][wafter.y-1-1];
	kari=pictx(wafter.mozi);
	GrCopyArea(allmap_pixmap,keyman_gc,((wafter.x-1)*16),((wafter.y-1-1)*16),16,16,yomipict_pixmap,kari,0,0);
}
static void tuikapaint(int x,int y,char mozi){
	int kari=0;
	wyomidata.mapd[x-1][y-1]=mozi;
	kari=pictx(mozi);
	GrCopyArea(allmap_pixmap,keyman_gc,((x-1)*16),((y-1)*16),16,16,yomipict_pixmap,kari,0,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL,0);
	kmbitmap();
	//GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)),160,128,shu_pixmap,0,0,0);
	
	MINIPHOTO(0,0,160,128);
}
Beispiel #5
0
void CContextWeather::ThreadProc()
{
	static int i, x;

	switch(m_nThreadStep)
	{
	case 0:
		x = MENT_AREA_WIDTH;
		i = 0;
		m_nThreadStep++;
		break;
	case 1:		//멘트가 우측에서 진입해서 좌측끝까지 이동
		GrCopyArea(m_wid_ment, g_gc, MENT_AREA_WIDTH-i, 0, i, MENT_AREA_HEIGHT, m_pixmap_ment, 0, 0, MWROP_SRCCOPY);
		x-=MENT_SCROLL_SPEED;
		i+=MENT_SCROLL_SPEED;
		if(i > MENT_AREA_WIDTH) 
		{
			m_nThreadStep++;
			i = 0;
		}
		break;
	case 2:		//2초간 정지. 메인루프가 10ms delay를 갖고 있으므로 최소 200회
		i++;
		if(i >= 2000)
		{
			m_nThreadStep++;
			i = 0;
		}
		break;
	case 3:		//멘트가 사라질때까지 이동
		GrCopyArea(m_wid_ment, g_gc, 0, 0, m_width_ment-i, MENT_AREA_HEIGHT, m_pixmap_ment, i, 0, MWROP_SRCCOPY);

		x-=MENT_SCROLL_SPEED;
		i+=MENT_SCROLL_SPEED;

		if(i >= m_width_ment)
		{
			m_nThreadStep++;
			i = 0;
		}
		break;
	case 4:		//2초간 정지. 메인루프가 10ms delay를 갖고 있으므로 최소 200회
		i++;
		if(i >= 2000)
		{
			m_nThreadStep = 0;
		}
		break;
	}
}
// as its name suggests
static void zoom_out() {

	double dx,dy;

	current_depth--;
	if (current_depth<0) {
		current_depth=0;
		mandel_quit();
		return;
	}
	if (!(current_depth%2)) iterations=iterations/2;

	cursor_x = level[current_depth].cursor_pos%selection_size;
	cursor_y = level[current_depth].cursor_pos/selection_size;

	if (xMax>xMin) dx = xMax-xMin;
	else dx = xMin -xMax;
	xMin-=cursor_x*dx;
	xMax+=(selection_size-1-cursor_x)*dx;

	if (yMax>yMin) dy = yMax -yMin;
	else dy = yMin -yMax;
	yMin-=cursor_y*dy;
	yMax+=(selection_size-1-cursor_y)*dy;

	GrCopyArea(mandel_wid, mandel_gc, 0, 0,
			   screen_width, screen_height,
			   level[current_depth].mandel_buffer, 0, 0, MWROP_SRCCOPY);

	draw_cursor();
}
// draw the current mandelbro set
static void draw_mandel() {
		GrCopyArea(mandel_wid, mandel_gc, 0, 0,
			   screen_width, screen_height,
			   level[current_depth].mandel_buffer, 0, 0, MWROP_SRCCOPY);
			   
		if (show_cursor) draw_cursor();
}
Beispiel #8
0
static void chopDrawScene()
{
	char           s[30];
  
	GrClearWindow (chopBuffer, GR_FALSE);
	
	sprintf (s, "Chopper - %d", chopCounter);
		
	pz_draw_header (s);
	
	GrSetGCForeground(chopGC, GR_RGB(WHITE));
	GrFillRect(chopBuffer, chopGC, 0,0,screen_info.cols,screen_info.rows	); 
	
	chopDrawPlayer(iPlayerPosX - iCameraPosX,iPlayerPosY);
	
	/*
	
	If I was less lazy I could make a nifty shadow effect with this stuff...
	
	int h = chopTerrainHeightAtPoint(&mGround, iPlayerPosX);
	GrSetGCForeground(gc, GR_RGB(BLACK));
	GrFillRect(chopBuffer,gc,iPlayerPosX - iCameraPosX,h - 1,2,2);
	
	*/
	
	chopDrawTheWorld();
	
	
	//Flip the buffer
	GrCopyArea(chopWindow, chopGC, 0, 0,
	screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)),
	chopBuffer, 0, 0, MWROP_SRCCOPY);
}
Beispiel #9
0
/*
 * Copy a rectangular block of pixels
 */
int
XCopyArea(Display *dpy, Window src, Window dst, GR_GC_ID gc,
          int x1, int y1, int w, int h, int x2, int y2)
{
    /*	printf("XCopyArea: src=%d, dst=%d, w=%d, h=%d\n",src, dst, w, h); */
    GrCopyArea(dst, gc, x2, y2, w, h, src, x1, y1, MWROP_SRCCOPY);
    return(0);
}
Beispiel #10
0
static void
GrCopyAreaWrapper(void *r)
{
	nxCopyAreaReq *req = r;

	GrCopyArea(req->drawid, req->gcid, req->x, req->y, req->width, req->height,
		req->srcid, req->srcx, req->srcy, req->op);
}
Beispiel #11
0
int XCopyPlane(Display* display, Drawable src, Drawable dest, GC gc,
              int src_x, int src_y, unsigned int width, unsigned int height,
              int dest_x, int dest_y, unsigned long plane)
{
    GrCopyArea(dest, gc, dest_x, dest_y,
			width, height, src,
			src_x, src_y, 0);
    return Success;
}
Beispiel #12
0
void show_buffer(void)
{
  GR_GC_ID gc = GrNewGC();

  GrCopyArea(swindow, gc, 0, 0, WWIDTH, WHEIGHT, 
			offscreen, 0, 0, MWROP_SRCCOPY);

  GrDestroyGC(gc);
}
Beispiel #13
0
static void poppaint(int x,int y,char mozi){
	int kari=0;int Bkari=16;
	wyomidata.mapd[x-1][y-1]=mozi;
	if (mozi=='B'){kari=pictx('F');}
	else{kari=pictx(mozi);}
	
	GrCopyArea(allmap_pixmap,keyman_gc,((x-1)*16),((y-1)*16),16,16,yomipict_pixmap,Bkari,0,0);
	GrCopyArea(allmap_pixmap,keyman_gc,((x-1)*16),((y-1)*16)-4,16,16,yomipict_pixmap,kari,0,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL,0);
	kmbitmap();
	//GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)),160,128,shu_pixmap,0,0,0);
	
	MINIPHOTO(0,0,160,128);
	wafter.mozi=wyomidata.mapd[x-1][y-1];
	wafter.x=x;
	wafter.y=y;
	
	
}
Beispiel #14
0
static void makemenu(void){
	char itiziteki[10];
	GrSetGCForeground(keyman_gc, WHITE);
	GrFillRect(mainmenu_pixmap,keyman_gc,0,0,160,128);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,40,16,80,16,yomipict_pixmap,48,64,0);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,26,46,32,48,yomipict_pixmap,0,32,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,58,46,32,48,yomipict_pixmap,8,32,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,90,46,40,48,yomipict_pixmap,8,32,0);
	
	GrCopyArea(mainmenu_pixmap,keyman_gc,26,78,32,32,yomipict_pixmap,0,48,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,58,78,32,32,yomipict_pixmap,8,48,0);
	GrCopyArea(mainmenu_pixmap,keyman_gc,90,78,40,32,yomipict_pixmap,8,48,0);
	
	//GrCopyArea(mainmenu_pixmap,keyman_gc,120,80,32,32,yomipict_pixmap,0,80,MWROP_BLACKNESS);
	
	GrSetGCForeground(keyman_gc, BLACK);
	GrText(mainmenu_pixmap,keyman_gc,81,32,"for iPod",-1,GR_TFASCII|GR_TFTOP);
	GrSetGCForeground(keyman_gc, BLACK);
	GrText(mainmenu_pixmap,keyman_gc,31,50,"Key ",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,60,"Stage",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,70,"Start",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,80,"Training",-1,GR_TFASCII|GR_TFTOP);
	GrText(mainmenu_pixmap,keyman_gc,31,90,"Quit",-1,GR_TFASCII|GR_TFTOP);
	
	GrSetGCForeground(keyman_gc, BLACK);
	if (wmenukey.KEY==1){strcpy(itiziteki,"for G3 type");}
	else {strcpy(itiziteki,"for G4 type");}
	GrText(mainmenu_pixmap,keyman_gc,71,50,itiziteki,-1,GR_TFASCII|GR_TFTOP);
	sprintf(itiziteki,"%d",wmenukey.STAGE);
	GrText(mainmenu_pixmap,keyman_gc,101,60,itiziteki,-1,GR_TFASCII|GR_TFTOP);
			
			//GrText(mainmenu_pixmap,keyman_gc,-150,0,pathmap,-1,GR_TFASCII|GR_TFTOP);
			
	if (wmenukey.ANI<3){wmenukey.ANI++;}
	else {wmenukey.ANI=0;}
	GrCopyArea(mainmenu_pixmap,keyman_gc,85,73,32,32,yomipict_pixmap,(wmenukey.ANI*32),80,0);
			
	GrCopyArea(mainmenu_pixmap,keyman_gc,12,(48+(wmenukey.BA*10)),14,16,yomipict_pixmap,112,48,0);
	
	
}
// draw the selector rectangle
static void draw_cursor() {
	show_cursor=1;
	cursor_x = level[current_depth].cursor_pos%selection_size;
	cursor_y = level[current_depth].cursor_pos/selection_size;

	// update the screen with last picture
	GrCopyArea(mandel_wid, mandel_gc, 0, 0,
			   screen_width, screen_height,
			   level[current_depth].mandel_buffer, 0, 0, MWROP_SRCCOPY);	
	GrSetGCForeground(mandel_gc, GR_RGB(BLACK));
	GrRect(mandel_wid, mandel_gc, cursor_x*selection_width-1, cursor_y*selection_height-1, selection_width+2, selection_height+2);
	GrSetGCForeground(mandel_gc, GR_RGB(WHITE));
	GrRect(mandel_wid, mandel_gc, cursor_x*selection_width-2, cursor_y*selection_height-2, selection_width+4, selection_height+4);
}
Beispiel #16
0
/* redraw everything */
static void lights_do_draw( void )
{
	int w;
	int x, y;
	char buf[32];

	/* start clear */
	GrSetGCForeground( lights_gc, GR_RGB(0,0,0) );
	GrFillRect( lights_bufwid, lights_gc, 0, 0,
		    lights_screen_info.cols, lights_height );

	/* draw the buttons */
	w=0;
	for( y=0 ; y<lights_count ; y++ )
	{
		for( x=0 ; x<lights_count ; x++ )
		{
			lights_draw_button( lights_x+(lights_size*x),
				     1+(lights_size*y), w );
			w++;
		}
	}

	/* draw the stats */
	GrSetGCForeground( lights_gc, GR_RGB(255,255,255) );
	GrText( lights_bufwid, lights_gc, 3, 20, "Mov", 3, GR_TFASCII );
	snprintf( buf, 16, "%2d", lights_nmoves );
	GrText( lights_bufwid, lights_gc, 5, 35, buf, 3, GR_TFASCII );

	GrText( lights_bufwid, lights_gc, 3, 70, "Lit", 3, GR_TFASCII );
	snprintf( buf, 16, "%2d", lights_litcount );
	GrText( lights_bufwid, lights_gc, 5, 85, buf, 3, GR_TFASCII );

	/* copy the buffer into place */
	GrCopyArea( lights_wid, lights_gc, 0, 0,
		    lights_screen_info.cols, 
		    (screen_info.rows - (HEADER_TOPLINE + 1)),
		    lights_bufwid, 0, 0, MWROP_SRCCOPY);

	if( !lights_won && lights_litcount==0 )
	{
		lights_won = 1;
		snprintf( buf, 32, "You won in %d moves!", lights_nmoves );
		new_message_window( buf );
	}
}
Beispiel #17
0
void
draw_clock(int x, int y, int w, int h, GR_WINDOW_ID pmap, GR_GC_ID gc,
	   GR_WINDOW_ID window)
{
    int i;

    GrSetGCForeground(gc, GrGetSysColor(GR_COLOR_WINDOW));
    GrFillRect(pmap, gc, 0, 0, w, h);

    tick();
    push_matrix();
    translate(x + w / 2.0 - .5, y + h / 2.0 - .5);
    scale_xy((w - 1) / 28.0, (h - 1) / 28.0);
    if (type() == ROUND_CLOCK) {
	GrSetGCForeground(gc, BLACK);
	begin_polygon();
	circle(0, 0, 14, pmap, gc, w, h);
	end_polygon(pmap, gc);
	GrSetGCForeground(gc, BLACK);
	begin_loop();
	circle(0, 0, 14, pmap, gc, w, h);
	end_loop(pmap, gc);
    }
    //draw the shadows
    push_matrix();
    translate(0.60, 0.60);
    draw_clock_hands(LTGRAY, LTGRAY, pmap, gc);
    pop_matrix();
    //draw the tick marks
    push_matrix();
    GrSetGCForeground(gc, BLACK);
    for (i = 0; i < 12; i++) {
	if (6 == i)
	    rect(-0.5, 9, 1, 2, pmap, gc);
	else if (3 == i || 0 == i || 9 == i)
	    rect(-0.5, 9.5, 1, 1, pmap, gc);
	else
	    rect(-0.25, 9.5, .5, 1, pmap, gc);
	rotate(-30);
    }
    pop_matrix();
    //draw the hands
    draw_clock_hands(GRAY, BLACK, pmap, gc);
    pop_matrix();
    GrCopyArea(window, gc, 0, 0, w, h, pmap, 0, 0, MWROP_SRCCOPY);
}
Beispiel #18
0
GR_WINDOW_ID capture_screen(nstate *state)
{
	GR_WINDOW_ID pid;

#if CAPTURESCREEN_DELAY
	/* This is a hack to give the system enough time to redraw the screen
	 * before capturing it when we switch from one screensaver to another.
	 * without it, we often capture an only partially redrawn screen. */
	msleep(CAPTURESCREEN_DELAY);
#endif
	
	pid = GrNewPixmap(state->si.cols, state->si.rows, NULL);
	GrCopyArea(pid, state->main_gc, 0, 0, state->si.cols,
			state->si.rows, GR_ROOT_WINDOW_ID, 0, 0, 0);

	return pid;
}
Beispiel #19
0
/*
 * Here when a button is released.
 */
void
do_buttonup(GR_EVENT_BUTTON	*bp)
{
	if (bp->wid == w4) {
		if (lineok) {
			GrLine(w4, gc4, xorxpos, xorypos, linexpos, lineypos);
			GrLine(w4, gc3, bp->x, bp->y, linexpos, lineypos);
		}
		lineok = GR_FALSE;
	        GrCopyArea(w1, gc4, 200,200, 200,200, p1,0,0,MWROP_COPY);
		return;
	}

	if (bp->wid == w2) {
		GrClose();
		exit(0);
	}
}
Beispiel #20
0
static void mappaint(){
int x=0;
int i=0;
int p=0;
	GrSetGCForeground(keyman_gc, BLACK);
	kmimage_id=GrLoadImageFromFile(pathimage,0);
	yomipict_pixmap=GrNewPixmap(384,128,NULL);
	allmap_pixmap=GrNewPixmap(160,(TATEHABA*16),NULL);
	GrDrawImageToFit(yomipict_pixmap,keyman_gc,0,0,384,128,kmimage_id);
	
	for (i=0;i<=(TATEHABA-1);i++){
	
		for (p=0;p<=9;p++){
			x=pictx(wyomidata.mapd[p][i]);
			GrCopyArea(allmap_pixmap,keyman_gc,(p*16),(i*16),16,16,yomipict_pixmap,x,0,0);
			

		}
	}
}
Beispiel #21
0
static void update_score()
{
	char s[24];

	GrSetGCForeground(invaders_gc, GR_RGB(255,255,255));
	GrFillRect(invaders_score_pix, invaders_gc, 0, 0,
			screen_info.cols, 13);
	GrSetGCForeground(invaders_gc, GR_RGB(0,0,0));
	sprintf(s, "Score %.5d", score);
	vector_render_string(invaders_score_pix, invaders_gc, s, 1, 1, 2, 2);
	if(score > high_score)
		high_score = score;
	if(screen_info.cols < 150)
		sprintf(s, "Top: %.5d", high_score);
	else
		sprintf(s, "HiScore: %.5d", high_score);
	vector_render_string_right(invaders_score_pix, invaders_gc, s, 1, 1,
			screen_info.cols - 2, 2);
	GrCopyArea(invaders_wid, invaders_gc, 0, 0, screen_info.cols, 12,
			invaders_score_pix, 0, 0, 0);
}
Beispiel #22
0
/* this would be much cleaner if raster ops worked properly; perhaps I just
 * misunderstand how they are supposed to be used */
void menu_draw_item(menu_st *menulist, int item)
{
	if(item < 0 || item > menulist->screen_items - 1) {
		Dprintf("menu_draw_item::No Such Pixmap\n");
		return;
	}
	/* xor the pixmap */
	if(item == (menulist->sel - menulist->top_item)) {
		GrSetGCMode(menulist->menu_gc, GR_MODE_XOR);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* make sure that the xor works properly for devices with
			 * fbrev turned off (host, photo) */
			GrSetGCForeground(menulist->menu_gc, WHITE );
		}

			/* just xor the menu option for now */
			/* eventually, draw the correct colors... */
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, 0, 0, menulist->w,
				menulist->height);
	}
	GrCopyArea(menulist->menu_wid, menulist->menu_gc, menulist->x,
			(item * menulist->height) + menulist->y,
			menulist->w - (menulist->scrollbar ? 8 : 0),
			menulist->height,
			menulist->pixmaps[menulist->pixmap_pos[item]],
			0, 0, 0);
	/* un umm xor the pixmap */
	if(item == (menulist->sel - menulist->top_item)) {
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, 0, 0, menulist->w,
				menulist->height);
		GrSetGCMode(menulist->menu_gc, GR_MODE_SET);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* reset fix for xor on certain devices (host, photo) */
			GrSetGCForeground(menulist->menu_gc, BLACK);
		}
	}
}
Beispiel #23
0
static void
DrawTile(int xpos, int ypos)
{
	char text[]="00";

	/* blank out old tile */
	GrSetGCForeground(gc1, RED);
	GrFillRect(tiles, gc1, (xpos* tile_width), (ypos*tile_height), tile_width, tile_height);

	if (value[xpos][ypos] != MAX_TILES ) {
		/* re-draw tile and number */
		GrSetGCForeground(gc1, WHITE);
		GrSetGCBackground(gc1, RED);
		GrRect(tiles, gc1, (xpos*tile_width), (ypos*tile_height), tile_width, tile_height);
		
#if USE_IMAGE
		if (using_image) {
			/* copy from image window */
			GrCopyArea(tiles, gc1, 1 + (xpos*tile_width), 1 + (ypos*tile_height), 
				tile_width - 2, tile_height - 2, image,
				1 + (((value[xpos][ypos] - 1) % WIDTH_IN_TILES) * tile_width), 
				1 + (((int)(value[xpos][ypos] - 1) / WIDTH_IN_TILES) * tile_height), 0);
		} else {
#endif
			/* label the tile with a number */
			if (value[xpos][ypos] > 9)
				text[0] = 48 + (int)(value[xpos][ypos]/10);
			else
				text[0] = 32;
	
			text[1] = 48 + value[xpos][ypos] % 10;
			
			GrText(tiles, gc1, (xpos*tile_width) + (tile_width /2) - 5, (ypos*tile_height) + (tile_height/2) + 5, &text, -1, 0);
#if USE_IMAGE
		}
#endif
	}
}
Beispiel #24
0
void periodic_draw(void)
{
	int cellsize = (screen_info.cols-1)/18;
	int bx = (screen_info.cols-(cellsize*18 + 1))/2;
	int by = 4;
	
	char buf[40];
	
	int tw, th, tb;
	int ty = by + cellsize*11 + 4;
	GrGetGCTextSize(periodic_gc, " ", 1, GR_TFASCII, &tw, &th, &tb);
	ty += (th-tb);
	
	/* copy the table */
	GrCopyArea(periodic_wid, periodic_gc, 0, 0, screen_info.cols, screen_info.rows - HEADER_TOPLINE, periodic_bufwid, 0, 0, MWROP_SRCCOPY);
	
	/* draw the element */
	periodic_draw_element(periodic_wid, periodic_gc, periodic_sel, bx, by, cellsize);
	
	/* draw element text */
	snprintf(buf, 40, _("#%d - %s - %s"), (periodic_sel+1), periodic_elements[periodic_sel].symbol, periodic_elements[periodic_sel].name);
	GrSetGCForeground(periodic_gc, GR_RGB(0,0,0));
	GrText(periodic_wid, periodic_gc, bx, ty, buf, -1, GR_TFASCII);
}
Beispiel #25
0
static int keyman_handle_event(GR_EVENT * event)
{
	int ret = 0;
    switch( event->type )
    {
    case( GR_EVENT_TYPE_TIMER ):
	
	switch(GAMEN){
		
		
		case MENU:
			makemenu();
			
			MINIPHOTO(0,0,160,128);
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case INGAME:
			
		
		
		
			if (wlastkey.AL==1){wnow.LR=-1;wnow.MUKI=-1;}
			else if(wlastkey.AR==1){wnow.LR=1;wnow.MUKI=1;}
			else {wnow.LR=0;}
			
			
			if(wlastkey.REE==1){
					if(wnow.JIMEN==ZIM){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					}
					else if (wnow.HASIGO==1){
					wnow.YKANSEI=-9;
					wnow.JIMEN=SORA;
					wnow.HASIGO=0;
					
					}
			}
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')==FALSE){wnow.HASIGO=0;}
			
			
			
			if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AU !=0){
				wnow.HASIGO=1;
				wnow.shupict=2;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC-3;
				}
			else if (INIT(wnow.XLOC+8,wnow.YLOC+8,'G')== TRUE && wlastkey.AD !=0){
				wnow.HASIGO=0;
				//GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,32,112,0);
				wnow.XKANSEI=0;
				//wnow.YLOC=wnow.YLOC+3;	
				}
				
			
			if (wnow.JIMEN==ZIM){wnow.XKANSEI=(0.9*wnow.XKANSEI)+(1*wnow.LR);}
			else {
				if (wnow.LR != 0){
				wnow.XKANSEI=(0.99*wnow.XKANSEI)+(0.3*wnow.LR);
				}
			}
			if (wnow.HASIGO==0 ){
				if (wnow.YKANSEI <= 6){
					wnow.YKANSEI++;
				}
			}
			else {wnow.YKANSEI=0;}
			
			
			

			
			wnow.XLOC=wnow.XLOC+wnow.XKANSEI;
			wnow.YLOC=wnow.YLOC+wnow.YKANSEI;
			
			
			if (wnow.NUPDW==-1 && ((wnow.MAPSCROLL) % 16)==0){wnow.YLOC=wnow.YLOC+16;}
			else if (wnow.NUPDW==1 && (wnow.MAPSCROLL % 16)==15){wnow.YLOC=wnow.YLOC-16;}
			
			
			
			if (wnow.MAPSCROLL>0 && wnow.MAPSCROLL<TATEHABA*16){
				wnow.MAPSCROLL=wnow.MAPSCROLL+wnow.NUPDW;
			}
			scr= (wnow.MAPSCROLL/16);
			ATARI2();
						
			
			if (wlastkey.AU != 1 && wlastkey.AD != 1){
			 if (wnow.MUKI==1){
			 wnow.shupict=0;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,0,112,0);
			 }
			 else {
			 wnow.shupict=1;
			 //GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,16,112,0);
			 }
			}			
			
						
			if (wnow.NUPDW==-1 && wnow.YLOC>136){
				wdeady.sp=-20;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
				
			else if(wnow.NUPDW==1 && wnow.YLOC<0){
				wdeady.sp=12;
				wdeady.g=0;
				wdeady.nowt=-16;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
			else if (wnow.NUPDW==0 && (wnow.YLOC>136)) {
			
				wdeady.sp=-10;
				wdeady.g=1.6;
				wdeady.nowt=128;
				GAMEN=END;
				wdeady.kaiten=0;
				ketumatu=0;
				wdeady.deadcount=1;}
					
				
			
			GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL,0);
			kmbitmap();
			//GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,(wnow.YLOC-(wnow.MAPSCROLL % 16)),160,128,shu_pixmap,0,0,0);
			hensu();		
			
			MINIPHOTO(0,0,160,128);
			if (wlastkey.PAU==1){GAMEN=PAUSE;}
			
			wlastkey.AR=0;wlastkey.AL=0;wlastkey.AU=0;wlastkey.AD=0;wlastkey.REE=0;wlastkey.PAU=0;
			break;
		case PAUSE:
			GrCopyArea(dialogall_pixmap,keyman_gc,0,0,96,80,dialog_pixmap,0,0,0);
			GrCopyArea(dialogall_pixmap,keyman_gc,3,24+(dialogkey*24),13,16,yomipict_pixmap,115,48,0);
			GrCopyArea(keyman_wid,keyman_gc,32+((screen_info.cols-160)/2),24+((screen_info.rows-128)/2),96,80,dialogall_pixmap,0,0,0);
			
			break;
		case END:
				if (ketumatu==0){
					wdeady.sp=wdeady.sp+wdeady.g;
					wdeady.nowt=wdeady.nowt+wdeady.sp;
					//sprintf(hensuu,"%d",wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW));
					
					if (wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)>0 && wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW)<TATEHABA*16){
						GrCopyArea(mainmenu_pixmap,keyman_gc,0,0,160,128,allmap_pixmap,0,wnow.MAPSCROLL+(wdeady.deadcount*wnow.NUPDW),0);
					}
					
					GrCopyArea(shu_pixmap,keyman_gc,0,0,16,16,yomipict_pixmap,wdeady.kaiten*16,16,0);
					GrCopyArea(mainmenu_pixmap,keyman_gc,wnow.XLOC,wdeady.nowt,160,128,shu_pixmap,0,0,0);
					hensu();
					
					MINIPHOTO(0,0,160,128);
					if (wdeady.kaiten<7){wdeady.kaiten++;}else{wdeady.kaiten=0;}
					if (training==0){
						if (wdeady.deadcount>31){GAMEN=MENU;
					
						}   
					}
					else if (training==1){
						if (wdeady.deadcount>15){opencard();GAMEN=INGAME;
						}
						
					}
					wdeady.deadcount++;
				}
				else if (ketumatu==1){
					if (training==0){
					GAMEN=MENU;
					}
					if (training==1){
						if (tranum>=MAXTRA){
							GAMEN=MENU;
						}
						else{
							startgame();
							GAMEN=INGAME;
						}
					
					}
				}
			break;
		case NODATA:
			GrSetGCForeground(keyman_gc, WHITE);
			GrFillRect(keyman_wid,keyman_gc,0,0,160,128);
			
			GrSetGCForeground(keyman_gc, GRAY);
			GrLine(keyman_wid,keyman_gc,80,20,34,100);
			GrLine(keyman_wid,keyman_gc,80,20,126,100);
			GrLine(keyman_wid,keyman_gc,34,100,126,100);
			GrEllipse(keyman_wid,keyman_gc,80,55,5,20);
			GrEllipse(keyman_wid,keyman_gc,80,85,5,5);
			
			GrSetGCForeground(keyman_gc, BLACK);
			GrText(keyman_wid,keyman_gc,50,48,"Please Copy",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,30,68,"KMData folder to /etc",-1,GR_TFASCII|GR_TFTOP);
			GrText(keyman_wid,keyman_gc,50,100,"Click to Quit",-1,GR_TFASCII|GR_TFTOP);
			break;
		}
		
			
	break;
	

    case( GR_EVENT_TYPE_KEY_DOWN ):
	
	switch(GAMEN){
		case INGAME:
			if (event->keystroke.ch==wsetkey.KLEFT){wlastkey.AL=1;}else{wlastkey.AL=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT){wlastkey.AR=1;}else{wlastkey.AR=0;}
			if (event->keystroke.ch==wsetkey.KUP){wlastkey.AU=1;}else{wlastkey.AU=0;}
			if (event->keystroke.ch==wsetkey.KDOWN){wlastkey.AD=1;}else{wlastkey.AD=0;}
			if (event->keystroke.ch==wsetkey.KJUMP){wlastkey.REE=1;}else{wlastkey.REE=0;}
			if (event->keystroke.ch==wsetkey.KPAUSE){wlastkey.PAU=1;}else{wlastkey.PAU=0;}
			break;
		case MENU:
			switch( event->keystroke.ch )
			{
	    
			case '\r': /* action */
				switch (wmenukey.BA){
				case 0:if (wmenukey.KEY<2){wmenukey.KEY++;}else{wmenukey.KEY=1;}break;	
				case 1:if (wmenukey.STAGE<MAXSTAGE){wmenukey.STAGE++;}
						else {wmenukey.STAGE=1;}
						break;
				
				case 2: GAMEN=INGAME; 
					training=0;
					startgame();
					break;
				case 3:GAMEN=INGAME;
					tranum=0;
					training=1;
					startgame();
					break;
				case 4: pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;
					break;
				}
			break;
			case 'r': /* CCW spin */
			if (wmenukey.BA<4){ipod_beep();wmenukey.BA++;}		
			break;

			case 'l': /* CW spin */
			if (wmenukey.BA>0){ipod_beep();wmenukey.BA--;}
			break;
			
			case 'm': /* menu */
					pz_close_window(keyman_wid);
					GrDestroyTimer(keyman_timer);
					GrUnmapWindow(keyman_wid);
					GrDestroyWindow(keyman_wid);
					GrFreeImage(kmimage_id);
					GrDestroyGC(keyman_gc);
					ret = 1;		
			break;
			}
			break;
			
					
		case PAUSE:
			if (event->keystroke.ch==wsetkey.KLEFT && dialogkey == 1){ipod_beep();dialogkey=0;}
			if (event->keystroke.ch==wsetkey.KRIGHT && dialogkey == 0){ipod_beep();dialogkey=1;}
			if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 0){GAMEN=INGAME;}
			else if (event->keystroke.ch==wsetkey.KJUMP && dialogkey == 1){GAMEN=MENU;}
			
			break;
		case END:break;
		case NODATA:
			if (event->keystroke.ch=='\r'){
			GrDestroyTimer(keyman_timer);
			GrUnmapWindow(keyman_wid);
			GrDestroyWindow(keyman_wid);
			GrFreeImage(kmimage_id);
			GrDestroyGC(keyman_gc);
			ret = 1;
			}
			break;
		}
	
	
	
	break;
    }

    return ret;
}
Beispiel #26
0
static void cube_draw(void)
{
	int i;
	GR_COLOR colour; // limey alert!
	GR_POINT faces[6][5] = {
		{
			{point2D[0].x, point2D[0].y},
			{point2D[1].x, point2D[1].y},
			{point2D[2].x, point2D[2].y},
			{point2D[3].x, point2D[3].y},
			{point2D[0].x, point2D[0].y},
		},
		{
			{point2D[4].x, point2D[4].y},
			{point2D[5].x, point2D[5].y},
			{point2D[6].x, point2D[6].y},
			{point2D[7].x, point2D[7].y},
			{point2D[4].x, point2D[4].y},
		},
		{
			{point2D[0].x, point2D[0].y},
			{point2D[5].x, point2D[5].y},
			{point2D[6].x, point2D[6].y},
			{point2D[3].x, point2D[3].y},
			{point2D[0].x, point2D[0].y},
		},
		{
			{point2D[1].x, point2D[1].y},
			{point2D[4].x, point2D[4].y},
			{point2D[7].x, point2D[7].y},
			{point2D[2].x, point2D[2].y},
			{point2D[1].x, point2D[1].y},
		},
		{
			{point2D[2].x, point2D[2].y},
			{point2D[3].x, point2D[3].y},
			{point2D[6].x, point2D[6].y},
			{point2D[7].x, point2D[7].y},
			{point2D[2].x, point2D[2].y},
		},
		{
			{point2D[0].x, point2D[0].y},
			{point2D[1].x, point2D[1].y},
			{point2D[4].x, point2D[4].y},
			{point2D[5].x, point2D[5].y},
			{point2D[0].x, point2D[0].y}
		}
	};
	zsort z_avgs_f[6];
	line_2D lines[12] = {
		{0,1}, {1,2}, {2,3}, {3,0},
		{4,5}, {5,6}, {6,7}, {7,4},
		{0,5}, {1,4}, {2,7}, {3,6}
	};
	
	if (solid) {
		for (i = 0; i < 6; i++) {
			z_avgs_f[i].place = i;
		}
		z_avgs_f[0].avg =
			(point3D[0].z + point3D[1].z + point3D[2].z + point3D[3].z)/4;
		z_avgs_f[1].avg =
			(point3D[4].z + point3D[5].z + point3D[6].z + point3D[7].z)/4;
		z_avgs_f[2].avg =
			(point3D[0].z + point3D[5].z + point3D[6].z + point3D[3].z)/4;
		z_avgs_f[3].avg =
			(point3D[1].z + point3D[4].z + point3D[7].z + point3D[2].z)/4;
		z_avgs_f[4].avg =
			(point3D[2].z + point3D[3].z + point3D[6].z + point3D[7].z)/4;
		z_avgs_f[5].avg =
			(point3D[0].z + point3D[1].z + point3D[4].z + point3D[5].z)/4;
		qsort(z_avgs_f, 6, sizeof(zsort), compfunc);
		for (i = 3; i < 6; i++) { /* we can only see the front 3 faces... */
			switch(z_avgs_f[i].place) {
				case 0:
					colour = (photo==0) ? LTGRAY : RED;
					break;
				case 1:
					colour = (photo==0) ? LTGRAY : GREEN;
					break;
				case 2:
					colour = (photo==0) ? GRAY : BLUE;
					break;
				case 3:
					colour = (photo==0) ? GRAY : YELLOW;
					break;
				case 4:
					colour = (photo==0) ? BLACK : MAGENTA;
					break;
				case 5:
					colour = (photo==0) ? BLACK : CYAN;
					break;
			}
			GrSetGCForeground(cube_gc, colour);
			GrFillPoly(temp_pixmap, cube_gc, 5, faces[z_avgs_f[i].place]);
		}
	} else {
		/* polygons not used so hidden lines can be gray in future
		 *  - once i work out how to do it, possibly with GrRegion stuff */
		GrSetGCForeground(cube_gc, BLACK);
		for (i = 0; i < 12; i++) {
			cube_draw_line(lines[i].v1, lines[i].v2);
		}
	}
	
	if (t_disp) {
		GrSetGCForeground(cube_gc, WHITE);
		GrFillRect(temp_pixmap, cube_gc,
			0, screen_info.rows-(HEADER_TOPLINE + 1)-14, screen_info.cols, 14);
		GrSetGCForeground(cube_gc, BLACK);
		GrLine(temp_pixmap, cube_gc,
			0, screen_info.rows-(HEADER_TOPLINE + 1)-14,
			screen_info.cols, screen_info.rows-(HEADER_TOPLINE + 1)-14);
		snprintf(t_buffer, 48, "%s:%d %s:%d %s:%d  |  d:%d ",
			t_ax[0], xs, t_ax[1], ys, t_ax[2], zs, z_off/10);
		GrText(temp_pixmap, cube_gc, 2,
			screen_info.rows-(HEADER_TOPLINE + 1)-2, t_buffer, -1, GR_TFASCII);
	}
	GrCopyArea(cube_wid, cube_gc, 0, 0,
		screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)),
		temp_pixmap, 0, 0, MWROP_SRCCOPY);
}
Beispiel #27
0
int main()
{
#ifdef TEST_FOR_X
	Display		*display;
	Window		window;
	GC		gc;
	XGCValues	gcValues;
	Colormap	colormap;
	Pixmap		src_pixmap;
	unsigned long	fgColor, bgColor;
	int		screenNum;
	XPoint		points[NUM_POINTS];
#else
	GR_WINDOW_ID 	window;
	GR_WINDOW_ID	src_pixmap;
	unsigned char*	src_pixmap_buf[320*240*2];
	GR_GC_ID        gc;
	GR_POINT	points[NUM_POINTS];
#endif
	
	int		c, c1,  count=4500;
	int		x, y, x1, y1, x2, y2;

#ifdef TEST_FOR_X
	if(!(display=XOpenDisplay(""))) {
		printf("Cannot connect to X.\n");
	}
	screenNum = DefaultScreen(display);
	colormap = DefaultColormap(display, screenNum);

	bgColor = BlackPixel(display, screenNum);
	fgColor = WhitePixel(display, screenNum);
	window = XCreateSimpleWindow(display, RootWindow(display, screenNum),
		0, 0 , 639, 479, 0,
		fgColor, bgColor);
	src_pixmap = XCreatePixmap(display, window, 320, 240, 16);
	XMapRaised(display, window);
	gcValues.background = bgColor;
	gcValues.foreground = fgColor;
	gcValues.line_width = 1;
	gcValues.line_style = LineSolid;
	gcValues.fill_style = FillSolid;
	gcValues.fill_rule = WindingRule;
	gcValues.arc_mode = ArcPieSlice;
	gc = XCreateGC(display, window,
		GCForeground  | GCBackground | GCLineWidth | GCLineStyle |
		GCFillStyle,
		&gcValues);

#else	
	GrOpen();
	window = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, 639, 479, 0, BLACK, BLUE);
	src_pixmap = GrNewPixmap(640, 480, src_pixmap_buf);
	GrMapWindow(window);
	gc = GrNewGC();
        GrSetGCForeground(gc, WHITE);
	GrSetGCBackground(gc, BLACK);
	GrSetGCMode(gc, GR_MODE_COPY);
#endif




	
	// Horizontal Line
	////////////////////////////////////////////////
	printf("Horizontal Line(XDrawLine)\n");
	start_timer();
	for(c=0; c<count*20; c++)
	{
		y1=random()%480;
#ifdef TEST_FOR_X
		XDrawLine(display, window, gc, 0, y1, 639, y1);
		XFlush(display);
#else
		GrLine(window, gc, 0, y1, 639, y1);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif
	
	// Vertical Line
	/////////////////////////////////////////////////
	printf("Vertical Line(XDrawLine)\n");
	start_timer();
	for(c=0; c<count*19; c++)
	{
		x1=random()%640;
#ifdef TEST_FOR_X
		XDrawLine(display, window, gc, x1, 0, x1, 479);
		XFlush(display);
#else
		GrLine(window, gc, x1, 0, x1, 479);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif

	// General Line
	/////////////////////////////////////////////////
	printf("General Line(XDrawLine)\n");
	start_timer();
	for(c=0; c<count*22; c++)
	{
		x1 = random()%640;
		x2 = random()%640;
		y1 = random()%480;
		y2 = random()%480;
#ifdef TEST_FOR_X
		XDrawLine(display, window, gc, x1, y1, x2, y2);
		XFlush(display);
#else
		GrLine(window, gc, x1, y1, x2, y2);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif

	// Point
	//////////////////////////////////////////////////
	printf("XPoint\n");
	start_timer();
	for(c=0; c<count*25; c++)
	{
		x1 = random()%640;
		y1 = random()%480;
#ifdef TEST_FOR_X
		XDrawPoint(display, window, gc, x1, y1);
		XFlush(display);
#else
		GrPoint(window, gc, x1, y1);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif

	// Rectangle
	//////////////////////////////////////////////////
	printf("XRectangle\n");
	start_timer();
	for(c=0; c<count*20; c++)
	{
		x1=random()%639;
		y1=random()%479;
		x2=random()%(639-x1)+1;
		y2=random()%(479-y1)+1;
#ifdef TEST_FOR_X
		XDrawRectangle(display, window, gc, x1, y1, x2, y2);
		XFlush(display);
#else
		GrRect(window, gc, x1, y1, x2, y2);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif

	// FillRectangle
	//////////////////////////////////////////////////
	printf("XFillRectangle\n");
	start_timer();
	for(c=0; c<count*18; c++)
	{
		x1=random()%639;
		y1=random()%479;
		x2=random()%(639-x1)+1;
		y2=random()%(479-y1)+1;	
#ifdef TEST_FOR_X
		XFillRectangle(display, window, gc, x1, y1, x2, y2);
		XFlush(display);
#else
		GrFillRect(window, gc, x1, y1, x2, y2);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X

	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif

	// FillPolygon
	//////////////////////////////////////////////////
	printf("XFillPolygon\n");
	start_timer();
	for(c=0; c<count; c++)
	{
		for(c1=0; c1<NUM_POINTS; c1++)
		{
			points[c1].x = random()%640;
			points[c1].y = random()%480;
		}	
#ifdef TEST_FOR_X
		XFillPolygon(display, window, gc, points, NUM_POINTS,
			0, 0);
		XFlush(display);
#else
		GrFillPoly(window, gc, NUM_POINTS, points);
		GrFlush();
#endif
	}
	end_timer();
#ifdef TEST_FOR_X
	XClearWindow(display, window);
#else
	GrClearWindow(window, GR_TRUE);
#endif


	// CopyArea
	/////////////////////////////////////////////////
	printf("XCopyArea\n");
	start_timer();
	for(c=0; c<count*5; c++)
	{
		x1=random()%320;
		y1=random()%240;
		x2=random()%319+1;
		y2=random()%239+1;
		
#ifdef TEST_FOR_X
		XCopyArea(display, src_pixmap, window, gc,
			0, 0, x2, y2, x1, y1);
		XFlush(display);
#else
		GrCopyArea(window, gc, x1, y1, x2 ,y2, src_pixmap,
			0, 0, 0);
		GrFlush();
#endif
	}
	end_timer();	

#ifdef TEST_FOR_X
	XDestroyWindow(display, window);
#else
	GrClose();
#endif
}
Beispiel #28
0
// Advances the game, draws the frame, then checks to see if the ball hit a chasm wall.
static void advance_and_check()
{
	
	// Increment game
	time_t t1;
	int i;
	int y;
	QUEUENODE *node;
	GR_COLOR gr = GRAY;
	GR_COLOR wh = WHITE;
	
	GrSetGCForeground(tunnel_gc, WHITE);
	GrFillRect(temp_pixmap, tunnel_gc,
			   0, 0, screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)));
	
	(void) time(&t1);
	srandom((long)t1);
	i = random() % 3;
	if (i == 0 && tail->offset > 0)
		cycle_chasm_queue(tail->offset - 1, &head, &middle, &tail);
	else if (i == 1 && tail->offset + chasmWidth < wi.width)
		cycle_chasm_queue(tail->offset + 1, &head, &middle, &tail);
	else
		cycle_chasm_queue(tail->offset, &head, &middle, &tail);
	
	// Draw chasm
	if( screen_info.bpp >= 16 ) {
		gr = GR_RGB( 255, 128, 0 );
		wh = GR_RGB( 128,  50, 0 );
	}

	node = head;
	y = 0;
	while (node != NULL)
	{
		GrSetGCForeground(tunnel_gc, wh);
		GrFillRect(temp_pixmap, tunnel_gc, 0, y, screen_info.cols, 2);

		GrSetGCForeground(tunnel_gc, WHITE);
		GrFillRect(temp_pixmap, tunnel_gc, 
				node->offset, y, chasmWidth, 2);

		GrSetGCForeground(tunnel_gc, BLACK);
		GrFillRect(temp_pixmap, tunnel_gc, 
				node->offset-5, y, 5, 2);
		GrFillRect(temp_pixmap, tunnel_gc,
				node->offset + chasmWidth, y,
				5, 2);

		GrSetGCForeground(tunnel_gc, gr);
		GrFillRect(temp_pixmap, tunnel_gc, 
				node->offset-8, y, 3, 2);
		GrFillRect(temp_pixmap, tunnel_gc,
				node->offset + chasmWidth+5, y,
				3, 2);

		node = node->next;
		y+=2;
	}
	
	// Draw ball
    GrSetGCForeground(tunnel_gc, BLACK);
	GrFillEllipse(temp_pixmap ,tunnel_gc, ball.x, wi.height / 2, ball.radius, ball.radius);
	
	// Map window 
	GrCopyArea(tunnel_wid, tunnel_gc, 0, 0,
			   screen_info.cols, (screen_info.rows - (HEADER_TOPLINE + 1)),
			   temp_pixmap, 0, 0, MWROP_SRCCOPY);
	
	// Check for collisions. Stop game if one is found.
	if (middle->offset >= ball.x - ball.radius || middle->offset + chasmWidth < ball.x + ball.radius)
	{
		running = 0;
		GrDestroyTimer( timer_id );
		running = 1;
		draw_result();
	}
	
	// increment score
	score++;
}
Beispiel #29
0
void menu_draw_timer(menu_st *menulist)
{
	char *c = strdup(">");
	int colors[] = {CS_ARROW0, CS_ARROW1, CS_ARROW2, CS_ARROW3,
			CS_ARROW3, CS_ARROW2, CS_ARROW1, CS_ARROW0};

	if(menulist->items[menulist->sel].op & CFLASH) {
		menulist->items[menulist->sel].op ^= CFLASH;
		menu_clear_pixmap(menulist, menulist->sel - menulist->top_item);
		menu_retext_pixmap(menulist, menulist->sel - menulist->top_item,
				&menulist->items[menulist->sel]);
		menu_handle_timer(menulist, 0);
		free(c);
		return;
	}

	if(menulist->items[menulist->sel].text_width >
			menulist->w - (8 + (menulist->scrollbar ? 8 : 0))) {
		int item, diff, move;
		item = menulist->sel - menulist->top_item;
		diff = (menulist->items[menulist->sel].text_width + 8) -
			(menulist->w - (8 + (menulist->scrollbar ? 8 : 0)));
		menulist->timer_step++;
		move = (!((menulist->timer_step / diff) % 2) ?
			(menulist->timer_step % diff) :
			(diff - (menulist->timer_step % diff)));
		if (menulist->timer == INT_MAX - 1)
			menulist->timer = 0;
		/* xor the pixmap */
		GrSetGCMode(menulist->menu_gc, GR_MODE_XOR);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* make sure that the xor works properly for devices with
			 * fbrev turned off (host, photo) */
			GrSetGCForeground(menulist->menu_gc, WHITE);
		}
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, move, 0,
				menulist->w, menulist->height);
		GrCopyArea(menulist->menu_wid, menulist->menu_gc, menulist->x,
				(item * menulist->height) + menulist->y,
				menulist->w - (menulist->scrollbar ? 8 : 0),
				menulist->height,
				menulist->pixmaps[menulist->pixmap_pos[item]],
				move, 0, 0);
		/* un umm xor the pixmap */
		GrFillRect(menulist->pixmaps[menulist->pixmap_pos[item]],
				menulist->menu_gc, move, 0,
				menulist->w, menulist->height);
		GrSetGCMode(menulist->menu_gc, GR_MODE_SET);
		if (hw_version == 0 || hw_version == 0x6 || hw_version == 0xc || hw_version == 0xb) {
			/* reset fix for xor on certain devices (host, photo) */
			GrSetGCForeground(menulist->menu_gc, BLACK);
		}
		free(c);
		return;
	}
	GrSetGCUseBackground(menulist->menu_gc, GR_FALSE);

	/* cycle through colors */
	if (menulist->timer_step < 0 || menulist->timer_step >= 12)
		menulist->timer_step = 0;
	GrSetGCForeground(menulist->menu_gc,
		appearance_get_color(colors[menulist->timer_step < 8 ?
			menulist->timer_step : 7]));
	menulist->timer_step++;

	/* executable instead */
	if(EXECUTE_MENU & menulist->items[menulist->sel].op)
		*c = 'x';
	/* double; with a 1px offset for bold */
	GrText(menulist->menu_wid, menulist->menu_gc, menulist->x +
			(menulist->w - 8) - 6, menulist->height *
			(menulist->sel - menulist->top_item) + menulist->y + 2,
			c, -1, GR_TFASCII | GR_TFTOP);
	GrText(menulist->menu_wid, menulist->menu_gc, menulist->x +
			(menulist->w - 8) - 7, menulist->height *
			(menulist->sel - menulist->top_item) + menulist->y + 2,
			c, -1, GR_TFASCII | GR_TFTOP);
	GrSetGCForeground(menulist->menu_gc, BLACK);
	GrSetGCUseBackground(menulist->menu_gc, GR_TRUE);

	free(c);
}
// update the status window contents
static void draw_busy_status() {
	GrCopyArea(status_wid, mandel_gc, 0, 0,  12, 12,status_image[status_counter%16], 0, 0, MWROP_SRCCOPY);
	status_counter++;
}