Exemple #1
0
/*:::::*/
static int driver_init(char *title, int w, int h, int depth_arg, int refresh_rate, int flags)
{
	int depth = MAX(8, depth_arg);

	if (depth == 8) {
		depth = 24;
		blitter = fb_hGetBlitter(32, FALSE);
	} else {
		blitter = NULL;
	}

	if (flags & DRIVER_OPENGL)
		return -1;

	if (!XVideoSetMode(w, h, depth == 32 ? 24 : depth, refresh_rate))
		return -1;

	framebuffer = XVideoGetFB();

	quitting = FALSE;

	//XInput_Init();

	/* !!!FIXME!!! use rtlib thread creation function */
	XCreateThread(driver_update, NULL, NULL);

	return 0;
}
Exemple #2
0
static void XBOX_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
	// note that this whole function assumes that the physical screen 
	// is in 640x400 mode.  The logical screen is centered in the physical 
	// screen... one of these days I will change this to use the video cards 
	// graphic modes properly! 
	int i, j, k; 
	int xinc, yinc, destinc; 
	
	unsigned char *src = NULL, *dest = NULL;
	
	int SCREEN_WIDTH = 640;       
	int SCREEN_HEIGHT = 480;   
	int SCREEN_PIXELWIDTH = 4;
	           
	// center the screen 
	unsigned char* VIDEO_BUFFER_ADDR = (unsigned char*)XVideoGetFB() + (((SCREEN_HEIGHT - this->screen->h)/2) * (SCREEN_WIDTH * SCREEN_PIXELWIDTH)) + (((SCREEN_WIDTH - this->screen->w)/2) * SCREEN_PIXELWIDTH);        
	
	// These are the values for the incoming image
	xinc = this->screen->format->BytesPerPixel ; 
	yinc = this->screen->pitch ; 
	          
	for (i = 0; i < numrects; ++ i) 
	{ 
		int x = rects[i].x; 
		int y = rects[i].y; 
		int w = rects[i].w; 
		int h = rects[i].h; 
		src = this->screen->pixels + y*yinc + x*xinc; 
		dest = (unsigned char*)VIDEO_BUFFER_ADDR; 
		destinc = SCREEN_WIDTH * SCREEN_PIXELWIDTH; 
		      
		unsigned char *ptrsrc, *ptrdst; 
		for (j = h; j > 0; --j, src += yinc, dest += destinc) 
		{ 
			ptrsrc = src; 
			ptrdst = dest; 
			for (k = w; k > 0; --k) 
			{ 
				unsigned char r, g, b;
				if (this->screen->format->BytesPerPixel == 1)
					SDL_GetRGB(*ptrsrc, this->screen->format, &r, &g, &b); 
				else if (this->screen->format->BytesPerPixel == 2)
					SDL_GetRGB(*(unsigned short *)ptrsrc, this->screen->format, &r, &g, &b); 
				else 
					SDL_GetRGB(*(unsigned int *)ptrsrc, this->screen->format, &r, &g, &b); 
				*ptrdst++ = b; 
				*ptrdst++ = g;
				*ptrdst++ = r;
				*ptrdst++ = 0; ptrsrc += xinc;
			} 
		} 
	}
}