void physicsThreadMain(u32 arg) { physicsThread_s* p=(physicsThread_s*)arg; while(!p->exit) { svcWaitSynchronization(p->requestMutex, U64_MAX); appendRequestQueue(&p->privateList, &p->requestList); svcReleaseMutex(p->requestMutex); // bool debug=false; // u64 val=svcGetSystemTick(); request_s* r=NULL; while((r=unqueueRequest(&p->privateList)) && !p->exit) { handleRequest(p, r); svcSleepThread(1000); } // if(debug)print("%d ticks\n",(int)(svcGetSystemTick()-val)); updateOBBs(); svcSleepThread(1000000); } svcExitThread(); }
void gameFrame(void) { int lala; switch(currentBuffer) { case false: #ifdef DEBUG_GAME iprintf("\x1b[0;0H"); iprintf("%d FPS \n", FPS); iprintf("%d (debug) \n", debugVal); iprintf("%d (free ram) \n", getMemFree()/1024); iprintf("%p (portal) \n", portal1.displayList); iprintf("%p (portal) \n", portal2.displayList); #endif cpuEndSlice(); postProcess1(); // iprintf("postproc : %d \n",cpuEndSlice()); render1(); // if(keysDown()&KEY_SELECT)testStepByStep^=1; //TEMP #ifdef DEBUG_GAME iprintf("full : %d (%d) \n",cpuEndTiming(),testStepByStep); #endif swiWaitForVBlank(); cpuStartTiming(0); prevTiming=0; if(previousPortal)dmaCopy(VRAM_C, previousPortal->viewPoint, 256*192*2); setRegCapture(true, 0, 15, 2, 0, 3, 1, 0); frmCNT++; break; case true: // cpuStartTiming(0); postProcess2(); // iprintf("frm 2 : %d \n",cpuGetTiming()); render2(); listenPI9(); updateOBBs(); // iprintf("frm 2 : %d \n",cpuEndTiming()); #ifdef DEBUG_GAME iprintf("fake frame : %d \n",cpuEndTiming()); #endif swiWaitForVBlank(); cpuStartTiming(0); prevTiming=0; dmaCopy(VRAM_C, mainScreen, 256*192*2); setRegCapture(true, 0, 15, 2, 0, 3, 1, 0); break; } // if(testStepByStep){int i=0;while(!(keysUp()&KEY_TOUCH)){scanKeys();listenPI9();swiWaitForVBlank();}NOGBA("WAITED");scanKeys();scanKeys();if(keysHeld()&KEY_SELECT)testStepByStep=false;} // else if(keysDown()&KEY_SELECT)testStepByStep=true; currentBuffer^=1; }