From fa18d4750b720b6804f73fe6b2247b9873d93b1d Mon Sep 17 00:00:00 2001 From: fincs Date: Mon, 25 Aug 2014 12:07:00 +0200 Subject: [PATCH] gfxInit(): initialize GSP event handler, use __gsp_heap_size --- libctru/source/gfx.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libctru/source/gfx.c b/libctru/source/gfx.c index d1049c3..0b5422d 100644 --- a/libctru/source/gfx.c +++ b/libctru/source/gfx.c @@ -51,6 +51,8 @@ void gfxSetFramebufferInfo(gfxScreen_t screen, u8 id) } } +extern u32 __gsp_heap_size; + void gfxInit() { gspInit(); @@ -65,7 +67,7 @@ void gfxInit() svcMapMemoryBlock(gspSharedMemHandle, 0x10002000, 0x3, 0x10000000); //map GSP heap - svcControlMemory((u32*)&gspHeap, 0x0, 0x0, 0x02000000, 0x10003, 0x3); + svcControlMemory((u32*)&gspHeap, 0x0, 0x0, __gsp_heap_size, 0x10003, 0x3); // default gspHeap configuration : // topleft1 0x00000000-0x00046500 @@ -88,19 +90,23 @@ void gfxInit() gfxSetFramebufferInfo(GFX_TOP, 0); gfxSetFramebufferInfo(GFX_BOTTOM, 0); - //wait until we can write stuff to it - svcWaitSynchronization(gspEvent, 0x55bcb0); - //GSP shared mem : 0x2779F000 gxCmdBuf=(u32*)(0x10002000+0x800+threadID*0x200); currentBuffer=0; + + // Initialize event handler and wait for VBlank + gspInitEventHandler(gspEvent, (vu8*)0x10002000, threadID); + gspWaitForVBlank(); } void gfxExit() { + // Exit event handler + gspExitEventHandler(); + //free GSP heap - svcControlMemory((u32*)&gspHeap, (u32)gspHeap, 0x0, 0x02000000, MEMOP_FREE, 0x0); + svcControlMemory((u32*)&gspHeap, (u32)gspHeap, 0x0, __gsp_heap_size, MEMOP_FREE, 0x0); //unmap GSP shared mem svcUnmapMemoryBlock(gspSharedMemHandle, 0x10002000);