int main() { getSrvHandle(&srvHandle); aptInit(); gspGpuInit(); Handle hidHandle; Handle hidMemHandle; srv_getServiceHandle(srvHandle, &hidHandle, "hid:USER"); HIDUSER_GetInfo(hidHandle, &hidMemHandle); svc_mapMemoryBlock(hidMemHandle, 0x10000000, 0x1, 0x10000000); HIDUSER_Init(hidHandle); while(1) { u32 PAD=((u32*)0x10000000)[7]; renderEffect(); swapBuffers(); copyBuffer(); u32 regData=PAD|0x01000000; GSPGPU_WriteHWRegs(gspGpuHandle, 0x202A04, (u8*)®Data, 4); svc_sleepThread(1000000000); } svc_exitProcess(); return 0; }
void gspGpuInit() { gspInit(); GSPGPU_AcquireRight(NULL, 0x0); // //set subscreen to red // u32 regData=0x010000FF; // GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 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); }
void gspGpuInit() { gspInit(); GSPGPU_AcquireRight(NULL, 0x0); GSPGPU_SetLcdForceBlack(NULL, 0x0); //set subscreen to blue u32 regData=0x01FF0000; GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 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; }
void hidInit(u32* sharedMem) { if(!sharedMem)sharedMem=(u32*)HID_SHAREDMEM_DEFAULT; srv_getServiceHandle(NULL, &hidHandle, "hid:USER"); HIDUSER_GetInfo(NULL, &hidMemHandle); hidSharedMem=sharedMem; svc_mapMemoryBlock(hidMemHandle, (u32)hidSharedMem, 0x1, 0x10000000); HIDUSER_Init(NULL); }
void gspGpuInit() { gspInit(); GSPGPU_AcquireRight(NULL, 0x0); //set subscreen to red //u32 regData=0x010000FF; //GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 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); }