コード例 #1
0
ファイル: main.c プロジェクト: Tybus/3Dfrogr
void gspGpuInit()
{
	gspInit();

	GSPGPU_AcquireRight(NULL, 0x0);
	GSPGPU_SetLcdForceBlack(NULL, 0x0);

	//set subscreen to blue
	u32 regData=0x01FF0000;
	GSPGPU_WriteHWRegs(NULL, 0x202A04, &regData, 4);

	//grab main left screen framebuffer addresses
	GSPGPU_ReadHWRegs(NULL, 0x400468, (u32*)&topLeftFramebuffers, 8);

	//convert PA to VA (assuming FB in VRAM)
	topLeftFramebuffers[0]+=0x7000000;
	topLeftFramebuffers[1]+=0x7000000;

	//setup our gsp shared mem section
	u8 threadID;
	svc_createEvent(&gspEvent, 0x0);
	GSPGPU_RegisterInterruptRelayQueue(NULL, gspEvent, 0x1, &gspSharedMemHandle, &threadID);
	svc_mapMemoryBlock(gspSharedMemHandle, 0x10002000, 0x3, 0x10000000);

	//map GSP heap
	svc_controlMemory((u32*)&gspHeap, 0x0, 0x0, 0x2000000, 0x10003, 0x3);

	//wait until we can write stuff to it
	svc_waitSynchronization1(gspEvent, 0x55bcb0);

	//GSP shared mem : 0x2779F000
	gxCmdBuf=(u32*)(0x10002000+0x800+threadID*0x200);

	currentBuffer=0;
}
コード例 #2
0
ファイル: main.c プロジェクト: LITTOMA/HANS
void gspGpuInit()
{
	gspInit();

	GSPGPU_AcquireRight(NULL, 0x0);

	// //set subscreen to red
	// u32 regData=0x010000FF;
	// GSPGPU_WriteHWRegs(NULL, 0x202A04, &regData, 4);

	//setup our gsp shared mem section
	u8 threadID;
	svc_createEvent(&gspEvent, 0x0);
	GSPGPU_RegisterInterruptRelayQueue(NULL, gspEvent, 0x1, &gspSharedMemHandle, &threadID);
	svc_mapMemoryBlock(gspSharedMemHandle, 0x10002000, 0x3, 0x10000000);

	//wait until we can write stuff to it
	svc_waitSynchronization1(gspEvent, 0x55bcb0);

	gxCmdBuf=(u32*)(0x10002000+0x800+threadID*0x200);

	top_framebuffer = &gspHeap[0];
	low_framebuffer = &gspHeap[0x46500];

	GSP_FramebufferInfo topfb = (GSP_FramebufferInfo){0, (u32*)top_framebuffer, (u32*)top_framebuffer, 240 * 3, (1<<8)|(1<<6)|1, 0, 0};
	GSP_FramebufferInfo lowfb = (GSP_FramebufferInfo){0, (u32*)low_framebuffer, (u32*)low_framebuffer, 240 * 3, 1, 0, 0};
	
	GSPGPU_SetBufferSwap(NULL, 0, &topfb);
	GSPGPU_SetBufferSwap(NULL, 1, &lowfb);
}
コード例 #3
0
ファイル: gfx.c プロジェクト: Slashmolder/ctrulib
void gfxInit()
{
	gspInit();

	gfxSharedMemory=(u8*)0x10002000;

	GSPGPU_AcquireRight(NULL, 0x0);

	//setup our gsp shared mem section
	svcCreateEvent(&gspEvent, 0x0);
	GSPGPU_RegisterInterruptRelayQueue(NULL, gspEvent, 0x1, &gspSharedMemHandle, &gfxThreadID);
	svcMapMemoryBlock(gspSharedMemHandle, (u32)gfxSharedMemory, 0x3, 0x10000000);

	// default gspHeap configuration :
	//		topleft1  0x00000000-0x00046500
	//		topleft2  0x00046500-0x0008CA00
	//		bottom1   0x0008CA00-0x000C4E00
	//		bottom2   0x000C4E00-0x000FD200
	//	 if 3d enabled :
	//		topright1 0x000FD200-0x00143700
	//		topright2 0x00143700-0x00189C00

	gfxTopLeftFramebuffers[0]=linearAlloc(0x46500);
	gfxTopLeftFramebuffers[1]=linearAlloc(0x46500);
	gfxBottomFramebuffers[0]=linearAlloc(0x38400);
	gfxBottomFramebuffers[1]=linearAlloc(0x38400);
	gfxTopRightFramebuffers[0]=linearAlloc(0x46500);
	gfxTopRightFramebuffers[1]=linearAlloc(0x46500);
	enable3d=false;

	//initialize framebuffer info structures
	gfxSetFramebufferInfo(GFX_TOP, 0);
	gfxSetFramebufferInfo(GFX_BOTTOM, 0);

	//GSP shared mem : 0x2779F000
	gxCmdBuf=(u32*)(gfxSharedMemory+0x800+gfxThreadID*0x200);

	currentBuffer[0]=0;
	currentBuffer[1]=0;

	// Initialize event handler and wait for VBlank
	gspInitEventHandler(gspEvent, (vu8*)gfxSharedMemory, gfxThreadID);
	gspWaitForVBlank();

	GSPGPU_SetLcdForceBlack(NULL, 0x0);
}
コード例 #4
0
ファイル: main.c プロジェクト: Sniffynose/ninjhax2.x
void gspGpuInit()
{
	gspInit();

	GSPGPU_AcquireRight(NULL, 0x0);

	//set subscreen to red
	//u32 regData=0x010000FF;
	//GSPGPU_WriteHWRegs(NULL, 0x202A04, &regData, 4);

	//setup our gsp shared mem section
	u8 threadID;
	svc_createEvent(&gspEvent, 0x0);
	GSPGPU_RegisterInterruptRelayQueue(NULL, gspEvent, 0x1, &gspSharedMemHandle, &threadID);
	svc_mapMemoryBlock(gspSharedMemHandle, 0x10002000, 0x3, 0x10000000);

	//wait until we can write stuff to it
	svc_waitSynchronization1(gspEvent, 0x55bcb0);

	//GSP shared mem : 0x2779F000
	gxCmdBuf=(u32*)(0x10002000+0x800+threadID*0x200);
}
コード例 #5
0
ファイル: gfx.c プロジェクト: Voka/lpp-3ds
void gfxInit(GSPGPU_FramebufferFormats topFormat, GSPGPU_FramebufferFormats bottomFormat, bool vrambuffers)
{
	void *(*screenAlloc)(size_t);

	if (vrambuffers)
	{
		screenAlloc=vramAlloc;
		screenFree=vramFree;

	} else {

		screenAlloc=linearAlloc;
		screenFree=linearFree;
	}

	gspInit();

	gfxSharedMemory=(u8*)mappableAlloc(0x1000);

	GSPGPU_AcquireRight(0x0);

	//setup our gsp shared mem section
	svcCreateEvent(&gspEvent, 0x0);
	GSPGPU_RegisterInterruptRelayQueue(gspEvent, 0x1, &gspSharedMemHandle, &gfxThreadID);
	svcMapMemoryBlock(gspSharedMemHandle, (u32)gfxSharedMemory, 0x3, 0x10000000);

	// default gspHeap configuration :
	//		topleft1  0x00000000-0x00046500
	//		topleft2  0x00046500-0x0008CA00
	//		bottom1   0x0008CA00-0x000C4E00
	//		bottom2   0x000C4E00-0x000FD200
	//	 if 3d enabled :
	//		topright1 0x000FD200-0x00143700
	//		topright2 0x00143700-0x00189C00
	u32 topSize = 400 * 240 * __get_bytes_per_pixel(topFormat);
	u32 bottomSize = 320 * 240 * __get_bytes_per_pixel(bottomFormat);

	gfxTopLeftFramebuffers[0]=screenAlloc(topSize);
	gfxTopLeftFramebuffers[1]=screenAlloc(topSize);
	gfxBottomFramebuffers[0]=screenAlloc(bottomSize);
	gfxBottomFramebuffers[1]=screenAlloc(bottomSize);
	gfxTopRightFramebuffers[0]=screenAlloc(topSize);
	gfxTopRightFramebuffers[1]=screenAlloc(topSize);

	enable3d=false;

	//set requested modes
	gfxSetScreenFormat(GFX_TOP,topFormat);
	gfxSetScreenFormat(GFX_BOTTOM,bottomFormat);

	//initialize framebuffer info structures
	gfxSetFramebufferInfo(GFX_TOP, 0);
	gfxSetFramebufferInfo(GFX_BOTTOM, 0);

	//GSP shared mem : 0x2779F000
	gxCmdBuf=(u32*)(gfxSharedMemory+0x800+gfxThreadID*0x200);

	currentBuffer[0]=0;
	currentBuffer[1]=0;

	// Initialize event handler and wait for VBlank
	gspInitEventHandler(gspEvent, (vu8*) gfxSharedMemory, gfxThreadID);
	gspWaitForVBlank();

	GSPGPU_SetLcdForceBlack(0x0);
}
コード例 #6
0
ファイル: device.cpp プロジェクト: Findus79/testbed
D3DSDevice
D3DSDevice::CreateDevice( 
	GSPGPU_FramebufferFormats FBFormatTop,
	GSPGPU_FramebufferFormats FBFormatBottom,
	bool					  bVRamBuffers,
	bool                      bEnable3D ) 
{

    D3DSDevice device;

    device.m_b3DEnabled     = bEnable3D;
    device.m_FBFormatTop    = FBFormatTop;
    device.m_FBFormatBottom = FBFormatBottom;

    // select allocator
    void* (*allocator)(size_t);

    if (bVRamBuffers)
    {
        allocator = vramAlloc;
        device.dealloc   = vramFree;
    }
    else
    {
        allocator = linearAlloc;
        device.dealloc   = linearFree;
    }

    gspInit();

    device.m_pSharedMemory = (u8*) mappableAlloc( 0x1000 );

    GSPGPU_AcquireRight( 0x0 );

    // create shared memory
    svcCreateEvent( &device.m_hGSPEvent, 0x0 );
    GSPGPU_RegisterInterruptRelayQueue( device.m_hGSPEvent, 0x1, &device.m_hGSPSharedMemory, &device.m_ThreadId );
    svcMapMemoryBlock( device.m_hGSPSharedMemory, 
        (u32)device.m_pSharedMemory, 
        (MemPerm)(MEMPERM_READ|MEMPERM_WRITE), 
        MEMPERM_DONTCARE );

    // allocate framebuffers...
    u32 bytes_top    = 400 * 240 * D3DSDevice::GetBytesPerPixel( FBFormatTop );
    u32 bytes_bottom = 320 * 240 * D3DSDevice::GetBytesPerPixel( FBFormatBottom );

    device.m_FBBottom[0] = (u8*) allocator( bytes_bottom );
    device.m_FBBottom[1] = (u8*) allocator( bytes_bottom );
    device.m_FBTop[ 0 ]  = (u8*) allocator( bytes_top );
    device.m_FBTop[ 1 ]  = (u8*) allocator( bytes_top );
    if (device.m_b3DEnabled)
    {
        device.m_FBTop[ 2 ]  = (u8*) allocator( bytes_top );
        device.m_FBTop[ 3 ]  = (u8*) allocator( bytes_top );
    }

    device.SetFramebufferInfo( D3DS_SCREEN_TOP, 0 );
    device.SetFramebufferInfo( D3DS_SCREEN_BOTTOM, 0 );

    gxCmdBuf = (u32*) (device.m_pSharedMemory + 0x800 + device.m_ThreadId*0x200 );

    gspInitEventHandler( device.m_hGSPEvent, (vu8*)device.m_pSharedMemory, device.m_ThreadId );
    gspWaitForVBlank();


    GSPGPU_SetLcdForceBlack( 0x0 );

	return device;
}