Example #1
0
static int Init()
{
	bRotateGame = (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL);
	bFlipGame = BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED;

	if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
		BurnDrvGetVisibleSize(&clipy, &clipx);
		BurnDrvGetFullSize(&sizex, &sizey);
	} else {
		BurnDrvGetVisibleSize(&clipx, &clipy);
		BurnDrvGetFullSize(&sizex, &sizey);
	}
   	VidBpp		= nBurnBpp = 2;
	VidMemPitch	= sizex * VidBpp;
	VidMemLen	= sizey * VidMemPitch;
	VidMem = (unsigned char*)malloc(VidMemLen);
	SetBurnHighCol(16);
	bVidScanlines = 0;								// !!!
	nVidFullscreen=0;
	vidgu_init();
	return 0;
}
Example #2
0
int VideoInit()
{
	BurnDrvGetFullSize(&VideoBufferWidth, &VideoBufferHeight);
	printf("w=%d h=%d\n",VideoBufferWidth, VideoBufferHeight);

	nBurnBpp = 2;
	BurnHighCol = myHighCol16;

	BurnRecalcPal();
	nBurnPitch = VideoBufferWidth * 2;
	PhysicalBufferWidth = screen->w;
	BurnVideoBuffer = (unsigned short *)malloc(VideoBufferWidth * VideoBufferHeight * 2);
	BurnerVideoTrans = Blit_320x240_to_320x240; // default blit

	// if source buffer < screen buffer then set general blitting routine with centering if needed
	if(VideoBufferWidth <= screen->w && VideoBufferHeight <= screen->h) {
		p_offset = (screen->w - VideoBufferWidth)/2 + (screen->h - VideoBufferHeight)/2*screen->w;
		q_offset = VideoBufferWidth*VideoBufferHeight-1;
		if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
			BurnerVideoTrans = Blitf;
		else
			BurnerVideoTrans = Blit;
	} else {
		// if source buffer is bigger than screen buffer then find an appropriate downscaler
		for(int i = 0; blit_table[i].dst_w != 0; i++) {
			if(blit_table[i].dst_w == screen->w && blit_table[i].dst_h == screen->h &&
			   blit_table[i].src_w == VideoBufferWidth && blit_table[i].src_h == VideoBufferHeight) {
				if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
					BurnerVideoTrans = blit_table[i].blitf;
				else
					BurnerVideoTrans = blit_table[i].blit;
				break;
			}
		}
	}

	return 0;
}
Example #3
0
int VideoInit()
{
	// Initialize SDL
	int flags = (options.vsync ? (SDL_HWSURFACE |
#ifdef SDL_TRIPLEBUF
		SDL_TRIPLEBUF
#else
		SDL_DOUBLEBUF
#endif
		) : SDL_SWSURFACE);

	if(!(SDL_WasInit(SDL_INIT_VIDEO) & SDL_INIT_VIDEO)) {
		SDL_InitSubSystem(SDL_INIT_VIDEO);
	}

	screen = SDL_SetVideoMode(320, 240, 16, flags);
	/*{
		int i = 0; // 0 - 320x240, 1 - 400x240, 2 - 480x272
		int surfacewidth, surfaceheight;
		#define NUMOFVIDEOMODES 3
		struct {
			int x;
			int y;
		} vm[NUMOFVIDEOMODES] = {
			{320, 240},
			{400, 240},
			{480, 272}
		};

		// check 3 videomodes: 480x272, 400x240, 320x240
		for(i = NUMOFVIDEOMODES-1; i >= 0; i--) {
			if(SDL_VideoModeOK(vm[i].x, vm[i].y, 16, SDL_SWSURFACE) != 0) {
				surfacewidth = vm[i].x;
				surfaceheight = vm[i].y;
				break;
			}
		}
		screen = SDL_SetVideoMode(surfacewidth, surfaceheight, 16, SDL_SWSURFACE);
	}*/

	if(!screen) {
		printf("SDL_SetVideoMode screen not initialised.\n");
	} else {
		printf("SDL_SetVideoMode successful.\n");
	}

	VideoBuffer = (unsigned short*)screen->pixels;

	SDL_ShowCursor(SDL_DISABLE);
	SDL_WM_SetCaption("Final Burn SDL", 0);

	BurnDrvGetFullSize(&VideoBufferWidth, &VideoBufferHeight);
	printf("w=%d h=%d\n",VideoBufferWidth, VideoBufferHeight);

	nBurnBpp = 2;
	BurnHighCol = myHighCol16;

	BurnRecalcPal();
	nBurnPitch = VideoBufferWidth * 2;
	PhysicalBufferWidth = screen->w;
	BurnVideoBuffer = (unsigned short *)malloc(VideoBufferWidth * VideoBufferHeight * 2);
	memset(BurnVideoBuffer, 0, VideoBufferWidth * VideoBufferHeight * 2);
	BurnerVideoTrans = Blit_320x240_to_320x240; // default blit

	bool bVertical = options.rotate && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL);

	// if source buffer < screen buffer then set general blitting routine with centering if needed
	if(!bVertical && VideoBufferWidth <= screen->w && VideoBufferHeight <= screen->h) {
		if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
			BurnerVideoTrans = Blitf;
		else
			BurnerVideoTrans = Blit;
	} else if(bVertical && VideoBufferWidth <= screen->h && VideoBufferHeight <= screen->w) {
		if(BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
			BurnerVideoTrans = Blitrf;
		else
			BurnerVideoTrans = Blitr;
	} else {
		// if source buffer is bigger than screen buffer then find an appropriate downscaler
		for(int i = 0; blit_table[i].dst_w != 0; i++) {
			if(blit_table[i].dst_w == screen->w && blit_table[i].dst_h == screen->h &&
			   blit_table[i].src_w == VideoBufferWidth && blit_table[i].src_h == VideoBufferHeight) {
				if (bVertical && (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED))
					BurnerVideoTrans = blit_table[i].blitrf;
				else if (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED)
					BurnerVideoTrans = blit_table[i].blitf;
				else if (bVertical)
					BurnerVideoTrans = blit_table[i].blitr;
				else
					BurnerVideoTrans = blit_table[i].blit;
				break;
			}
		}
	}

	if (BurnerVideoTrans == Blit || BurnerVideoTrans == Blitf || BurnerVideoTrans == Blitr || BurnerVideoTrans == Blitrf) {
		if (bVertical) {
			p_offset = ((screen->h - VideoBufferWidth)/2)*screen->w;
			r_offset = screen->w - VideoBufferHeight;
		}
		else {
			p_offset = (screen->w - VideoBufferWidth)/2 + (screen->h - VideoBufferHeight)/2*screen->w;
			q_offset = VideoBufferWidth*VideoBufferHeight-1;
		}
	}

	return 0;
}
Example #4
0
void gp2x_initialize()
{
    int scaleheight=480;
    int scalewidth=800;
    BurnDrvGetFullSize(&WINDOW_WIDTH, &WINDOW_HEIGHT);
    if (((config_options.option_rotate==0) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) || (config_options.option_rotate==2))
    {
        int t;
        t=WINDOW_HEIGHT;
        WINDOW_HEIGHT=WINDOW_WIDTH;
        WINDOW_WIDTH=t;
    }
    printf("dw:%d dh:%d\n",WINDOW_WIDTH,WINDOW_HEIGHT);
    if (config_options.option_rescale==0)
    {
        scaleheight=WINDOW_HEIGHT;
        scalewidth=WINDOW_WIDTH;
        if (scaleheight>480) scaleheight=480;
        if (scalewidth>800) scalewidth=800;
    }
    if (config_options.option_rescale==1)
    {
        scaleheight=WINDOW_HEIGHT*2;
        scalewidth=WINDOW_WIDTH*2;
        if (scaleheight>480) scaleheight=480;
        if (scalewidth>800) scalewidth=800;
    }
    if (config_options.option_rescale==2)
    {
        float xw,xh;
        xh=(float)480/(float)WINDOW_HEIGHT;
        xw=(float)800/(float)WINDOW_WIDTH;
        if (xh>xw)
        {
            scalewidth=(int)((float)WINDOW_WIDTH*xw);
            scaleheight=(int)((float)WINDOW_HEIGHT*xw);
        }
        else
        {
            scalewidth=(int)((float)WINDOW_WIDTH*xh);
            scaleheight=(int)((float)WINDOW_HEIGHT*xh);

        }
        if (scaleheight>480) scaleheight=480;
        if (scalewidth>800) scalewidth=800;
    }
    if (config_options.option_rescale==3)
    {
        scaleheight=480;
        scalewidth=800;
    }

    char scaling[64];
    sprintf(scaling,"SDL_OMAP_LAYER_SIZE=%dx%d",scalewidth,scaleheight);
    printf("scaling x:%d y:%d   %s\n",scalewidth,scaleheight,scaling);

    for (int i=0;environ[i];i++)
    {
        if (strstr(environ[i],"SDL_OMAP_LAYER_SIZE="))
        {
            strcpy(environ[i],scaling);
        }

    }


    printf("Setting screen to %d x %d\n",WINDOW_WIDTH,WINDOW_HEIGHT);
    if ((SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO | SDL_INIT_TIMER))<0)
    {
        printf("sdl failed to init\n");
    }			// Initialize SDL
    myscreen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 16, SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF);
    if(!myscreen)
	{
		printf("SDL_SetVideoMode screen not initialised.\n");								// debug output example for serial cable
	}
	else printf("SDL_SetVideoMode successful.\n");
	SDL_ShowCursor(SDL_DISABLE);															// Disable mouse cursor on gp2x
	SDL_WM_SetCaption( WINDOW_TITLE, 0 );													// Sets the window title (not needed for gp2x)

    fbdev=open("/dev/fb0", O_RDONLY);

    joyCount=SDL_NumJoysticks();
	if (joyCount>5) joyCount=5;
	printf("%d Joystick(s) Found\n",joyCount);
	//if ((joyCount==1) && (strcmp(SDL_JoystickName(0),"gpio-keys")==0)) joyCount=0;
	if (joyCount>0)
	{

	    for (int i=0;i<joyCount;i++)
        {
            printf("%s\t",SDL_JoystickName(i));
            joys[i] = SDL_JoystickOpen(i);
            printf("Hats %d\t",SDL_JoystickNumHats(joys[i]));
            printf("Buttons %d\t",SDL_JoystickNumButtons(joys[i]));
            printf("Axis %d\n",SDL_JoystickNumAxes(joys[i]));
            if (strcmp(SDL_JoystickName(i),"nub0")==0) joys[0]=SDL_JoystickOpen(i);
            if (strcmp(SDL_JoystickName(i),"nub1")==0) joys[1]=SDL_JoystickOpen(i);
        }
        //if (joyCount>1) joys[0]=SDL_JoystickOpen(1);
        //if (joyCount>2) joys[1]=SDL_JoystickOpen(2);
	}
	VideoBuffer=(unsigned short*)malloc((WINDOW_WIDTH*2) * WINDOW_HEIGHT);
	SDL_VideoBuffer=SDL_CreateRGBSurfaceFrom(VideoBuffer,WINDOW_WIDTH*2,WINDOW_HEIGHT,16,WINDOW_WIDTH*2,0xF800,0x7E0,0x1F,0x0);
	SDL_LockSurface(SDL_VideoBuffer);
    gp2x_video_flip(true);
}