/* 
########################
System functions
########################
 */
void gp_Reset(void)
{
	unsigned int i=0;
	
	gp_setCpuspeed(533);

	if( gp2x_sound_thread) 
	{ 
		gp2x_sound_thread_exit=1; 
		usleep(500); 
	}
 
	MLCADDRESS0 = bkregs32[0]; MLCADDRESS1 = bkregs32[1]; MLCCONTROL0 = bkregs32[2]; MLCCONTROL1 = bkregs32[3]; MLCLEFTRIGHT0 = bkregs32[4];
	MLCTOPBOTTOM0 = bkregs32[5]; MLCLEFTRIGHT1 = bkregs32[6]; MLCTOPBOTTOM1 = bkregs32[7]; MLCBGCOLOR = bkregs32[8]; MLCHSTRIDE0 = bkregs32[9];
	MLCVSTRIDE0 = bkregs32[10]; MLCHSTRIDE1 = bkregs32[11]; MLCVSTRIDE1 = bkregs32[12]; DPCCTRL1 = bkregs32[13]; MLCSCREENSIZE = bkregs32[14];

	lc_dirtylayer(0);
	lc_dirtylayer(1);
	lc_dirtymlc();

   	munmap((void *)memregs32, 0x20000);
	
	munmap(framebuffer_mmap[0], fb_size * BUFFERS);

	if (wiz_dev[0]) close(wiz_dev[0]);
	if (wiz_dev[1]) close(wiz_dev[1]);
	if (wiz_dev[2]) close(wiz_dev[2]);
	
	fcloseall();

	chdir("/usr/gp2x");
	execl("gp2xmenu",NULL);
}
/* Sets layer properties */
static void lc_setlayer(int layer, unsigned int onoff, unsigned int alpha, unsigned int invert, unsigned int trans, unsigned int mode)
{
	/* set layer properties register */
	unsigned int temp;
	temp = 0;
	if(onoff)	temp |= BIT(5);
	if(alpha)	temp |= BIT(2);
	if(invert)	temp |= BIT(1);
	if(trans)	temp |= BIT(0);
	temp |= BIT(12);
	temp |= BIT(14);
	temp |= BIT(15);
	temp |= (mode<<16);

	if(layer == 0) {
		MLCCONTROL0 = temp;
	} else {
		MLCCONTROL1= temp;
	}
	lc_dirtylayer(layer);

	int pixel_width = 0;
	/* set stride based on pixel width*/
	switch(mode) {
		case RGB565:
		case BGR565:
		case XRGB1555:
		case XBGR1555:
		case XRGB4444:
		case XBGR4444:
		case XRGB8332:
		case XBGR8332:
		case ARGB1555:
		case ABGR1555:
		case ARGB4444:
		case ABGR4444:
		case ARGB8332:
		case ABGR8332:
			pixel_width = 2;
			break;
		case RGB888:
		case BGR888:
			pixel_width = 3;
			break;
		case ARGB8888:
		case ABGR8888:
			pixel_width = 4;
			break;
		case PTRGB565:
			pixel_width = 1;
			break;
		default:
			break;
	}
	lc_setstride(layer, pixel_width, pixel_width*layer_width[layer]);
}
Exemple #3
0
void gp_setFramebuffer(int flip, int sync)
{
	CurrentFrameBuffer=flip;
	unsigned int address=(unsigned int)wiz_physvram[flip];
	unsigned short x=0;

	/* set absolute address for framebuffers */
	MLCADDRESS1 = address;
	lc_dirtylayer(1);
}
/* Sets stride registers */
static void lc_setstride(int layer, int hs, int vs)
{
	/* set how many bytes the MLC is supposed to read */
	if(layer == 0) {
		MLCHSTRIDE0 = hs;
		MLCVSTRIDE0 = vs;
	} else {
		MLCHSTRIDE1 = hs;
		MLCVSTRIDE1 = vs;
	}
	lc_dirtylayer(layer);
}
void gp_setFramebuffer(int flip, int sync)
{
	CurrentFrameBuffer=flip;
	unsigned int address=(unsigned int)wiz_physvram[flip];
	unsigned short x=0;

	// Wait for VSync if required
	if (sync) {
		while((DPCCTRL0 & 0x400) == 0); 
		DPCCTRL0 |= 0x400;
		}

	/* set absolute address for framebuffers */
	MLCADDRESS1 = address;
	lc_dirtylayer(1);
}
/* Sets layer position */
static void lc_layerpos(int layer, int x1, int y1, int x2, int y2)
{
	unsigned int temp_lr, temp_tb;
	temp_lr = (x1 << 16) | x2;
	temp_tb = (y1 << 16) | y2;

	if(layer == 0) {
		MLCLEFTRIGHT0 = temp_lr;
		MLCTOPBOTTOM0 = temp_tb;
	} else {
		MLCLEFTRIGHT1 = temp_lr;
		MLCTOPBOTTOM1 = temp_tb;
	}
	lc_dirtylayer(layer);

	layer_width[layer] = (x2-x1)+1;
}