コード例 #1
0
ファイル: filters.cpp プロジェクト: libretro/vbam-libretro
FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth)
{
    FilterFunc func;

    switch (colorDepth) {
    case 15:
    case 16:
        func = Filters[f].func16;
        break;
    case 24:
        func = Filters[f].func24;
        break;
    case 32:
        func = Filters[f].func32;
        break;
    default:
        func = 0;
        break;
    }

    if (func)
        switch (f) {
        case kStretch1x:
            sdlStretchInit(colorDepth, 0, srcWidth);
            break;
        case kStretch2x:
            sdlStretchInit(colorDepth, 1, srcWidth);
            break;
        case kStretch3x:
            sdlStretchInit(colorDepth, 2, srcWidth);
            break;
        case kStretch4x:
            sdlStretchInit(colorDepth, 3, srcWidth);
            break;
        case k2xSaI:
        case kSuper2xSaI:
        case kSuperEagle:
            if (colorDepth == 15)
                Init_2xSaI(555);
            else if (colorDepth == 16)
                Init_2xSaI(565);
            else
                Init_2xSaI(colorDepth);
            break;
        case khq2x:
        case klq2x:
            hq2x_init(colorDepth);
            break;
        default:
            break;
        }

    return func;
}
コード例 #2
0
ファイル: filters.cpp プロジェクト: EmperorArthur/VBA-M
FilterFunc initFilter(const Filter f, const int srcWidth)
{
  FilterFunc func = Filters[f].func32;

  if (func)
    switch (f) {
      case kStretch1x:
        sdlStretchInit(0, srcWidth);
        break;
      case kStretch2x:
        sdlStretchInit(1, srcWidth);
        break;
      case kStretch3x:
        sdlStretchInit(2, srcWidth);
        break;
      case kStretch4x:
        sdlStretchInit(3, srcWidth);
        break;
      case k2xSaI:
      case kSuper2xSaI:
      case kSuperEagle:
        Init_2xSaI(32);
        break;
      case khq2x:
      case klq2x:
        hq2x_init(32);
        break;
      default:
        break;
    }

  return func;
}
コード例 #3
0
static int config(struct vf_instance_s* vf,
        int width, int height, int d_width, int d_height,
	unsigned int flags, unsigned int outfmt){

    Init_2xSaI(outfmt&255);

    return vf_next_config(vf,2*width,2*height,2*d_width,2*d_height,flags,outfmt);
}
コード例 #4
0
ファイル: S9xPortPart.cpp プロジェクト: ModeenF/snes9x_haiku
void 
S9xInitDisplay()
{
	Init_2xSaI (565);
	
	memset(s9x->Screen()->Bits(), 0, s9x->Screen()->BitsLength());
	memset(s9x->SubScreen()->Bits(), 0, s9x->SubScreen()->BitsLength());
	
    GFX.Screen = (uint8 *)s9x->Screen()->Bits();
    GFX.Pitch = s9x->Screen()->BytesPerRow();
	Delta = new uint8 [(IMAGE_WIDTH + 2) * IMAGE_HEIGHT * 2];
	GFX.SubScreen = (uint8 *)s9x->SubScreen()->Bits();
	GFX.ZBuffer = new uint8[((int)(SCREEN_WIDTH) * IMAGE_HEIGHT)];
	GFX.SubZBuffer = new uint8[((int)(SCREEN_WIDTH) * IMAGE_HEIGHT)];
}
コード例 #5
0
ファイル: OpenGL.cpp プロジェクト: Brukwa/VisualBoyAdvance
bool OpenGLDisplay::initialize()
{
	switch( theApp.cartridgeType )
	{
	case IMAGE_GBA:
		theApp.sizeX = 240;
		theApp.sizeY = 160;
		break;
	case IMAGE_GB:
		if ( gbBorderOn )
		{
			theApp.sizeX = 256;
			theApp.sizeY = 224;
		}
		else
		{
			theApp.sizeX = 160;
			theApp.sizeY = 144;
		}
		break;
	}


	switch(theApp.videoOption)
	{
	case VIDEO_1X:
		theApp.surfaceSizeX = theApp.sizeX;
		theApp.surfaceSizeY = theApp.sizeY;
		break;
	case VIDEO_2X:
		theApp.surfaceSizeX = theApp.sizeX * 2;
		theApp.surfaceSizeY = theApp.sizeY * 2;
		break;
	case VIDEO_3X:
		theApp.surfaceSizeX = theApp.sizeX * 3;
		theApp.surfaceSizeY = theApp.sizeY * 3;
		break;
	case VIDEO_4X:
		theApp.surfaceSizeX = theApp.sizeX * 4;
		theApp.surfaceSizeY = theApp.sizeY * 4;
		break;
	case VIDEO_320x240:
	case VIDEO_640x480:
	case VIDEO_800x600:
	case VIDEO_OTHER:
		{
			if( theApp.fullScreenStretch ) {
				theApp.surfaceSizeX = theApp.fsWidth;
				theApp.surfaceSizeY = theApp.fsHeight;
			} else {
				float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
				float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
				float min = ( scaleX < scaleY ) ? scaleX : scaleY;
				if( theApp.fsMaxScale )
					min = ( min > (float)theApp.fsMaxScale ) ? (float)theApp.fsMaxScale : min;
				theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
				theApp.surfaceSizeY = (int)((float)theApp.sizeY * min);
			}
		}
		break;
	}

	theApp.rect.left = 0;
	theApp.rect.top = 0;
	theApp.rect.right = theApp.sizeX;
	theApp.rect.bottom = theApp.sizeY;

	theApp.dest.left = 0;
	theApp.dest.top = 0;
	theApp.dest.right = theApp.surfaceSizeX;
	theApp.dest.bottom = theApp.surfaceSizeY;

	DWORD style = WS_POPUP | WS_VISIBLE;
	DWORD styleEx = 0;

	if( theApp.videoOption <= VIDEO_4X )
		style |= WS_OVERLAPPEDWINDOW;
	else
		styleEx = 0;

	if( theApp.videoOption <= VIDEO_4X )
		AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
	else
		AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );    

	int winSizeX = theApp.dest.right - theApp.dest.left;
	int winSizeY = theApp.dest.bottom - theApp.dest.top;
	int x = 0, y = 0;

	if( theApp.videoOption <= VIDEO_4X ) {
		x = theApp.windowPositionX;
		y = theApp.windowPositionY;
	} else {
		winSizeX = theApp.fsWidth;
		winSizeY = theApp.fsHeight;
	}

	// Create a window
	MainWnd *pWnd = new MainWnd;
	theApp.m_pMainWnd = pWnd;

	pWnd->CreateEx(
		styleEx,
		theApp.wndClass,
		"VisualBoyAdvance",
		style,
		x,y,winSizeX,winSizeY,
		NULL,
		0 );
	
	if (!(HWND)*pWnd) {
		winlog("Error creating Window %08x\n", GetLastError());
		return FALSE;
	}
	
	theApp.updateMenuBar();
	
	theApp.adjustDestRect();
	
	theApp.mode320Available = FALSE;
	theApp.mode640Available = FALSE;
	theApp.mode800Available = FALSE;

	CDC *dc = pWnd->GetDC();
	HDC hDC = dc->GetSafeHdc();

	PIXELFORMATDESCRIPTOR pfd = { 
		sizeof(PIXELFORMATDESCRIPTOR),
		1,                     // version number 
		PFD_DRAW_TO_WINDOW |   // support window 
		PFD_SUPPORT_OPENGL |   // support OpenGL 
		PFD_DOUBLEBUFFER,      // double buffered 
		PFD_TYPE_RGBA,         // RGBA type 
		24,                    // 24-bit color depth 
		0, 0, 0, 0, 0, 0,      // color bits ignored 
		0,                     // no alpha buffer 
		0,                     // shift bit ignored 
		0,                     // no accumulation buffer 
		0, 0, 0, 0,            // accum bits ignored 
		32,                    // 32-bit z-buffer     
		0,                     // no stencil buffer 
		0,                     // no auxiliary buffer 
		PFD_MAIN_PLANE,        // main layer 
		0,                     // reserved 
		0, 0, 0                // layer masks ignored 
	};
	
	int  iPixelFormat; 
	if( !(iPixelFormat = ChoosePixelFormat( hDC, &pfd )) ) {
		winlog( "Failed ChoosePixelFormat\n" );
		return false;
	}
	
	// obtain detailed information about
	// the device context's first pixel format
	if( !( DescribePixelFormat(
		hDC,
		iPixelFormat,
		sizeof(PIXELFORMATDESCRIPTOR),
		&pfd ) ) )
	{
		winlog( "Failed DescribePixelFormat\n" );
		return false;
	}
	
	if( !SetPixelFormat( hDC, iPixelFormat, &pfd ) ) {
		winlog( "Failed SetPixelFormat\n" );
		return false;
	}
	
	if( !( hglrc = wglCreateContext( hDC ) ) ) {
		winlog( "Failed wglCreateContext\n" );
		return false;
	}
	
	if( !wglMakeCurrent(hDC, hglrc) ) {
		winlog( "Failed wglMakeCurrent\n" );
		return false;
	}
	
	pWnd->ReleaseDC( dc );
	
	// setup 2D gl environment
	glPushAttrib( GL_ENABLE_BIT );
	glDisable( GL_DEPTH_TEST );
	glDisable( GL_CULL_FACE );
	glEnable( GL_TEXTURE_2D );

	initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );

	setVSync( theApp.vsync );

#ifdef MMX
	if(!theApp.disableMMX)
		cpu_mmx = theApp.detectMMX();
	else
		cpu_mmx = 0;
#endif

	systemRedShift = 3;
	systemGreenShift = 11;
	systemBlueShift = 19;
	systemColorDepth = 32;
	theApp.fsColorDepth = 32;
	
	Init_2xSaI(32);
	
	utilUpdateSystemColorMaps();
	theApp.updateFilter();
	theApp.updateIFB();
	
	if(failed)
		return false;
	
	pWnd->DragAcceptFiles(TRUE);

	return TRUE;  
}