int main() { initSrv(); aptInit(APPID_APPLICATION); gspGpuInit(); hidInit(NULL); aptSetupEventHandler(); APP_STATUS status; while((status=aptGetStatus())!=APP_EXITING) { if(status==APP_RUNNING) { u32 PAD=hidSharedMem[7]; u32 regData=PAD|0x01000000; GSPGPU_WriteHWRegs(NULL, 0x202A04, (u32*)®Data, 4); renderEffect(); swapBuffers(); copyBuffer(); } svc_sleepThread(16666666); } hidExit(); gspGpuExit(); aptExit(); svc_exitProcess(); return 0; }
int main() { //Grab the status of the app (running, suspending, sleeping, exiting) APP_STATUS status; //Initialize 3ds services srvInit(); fsInit(); aptInit(); gfxInit(); hidInit(NULL); //Setup event handler to listen for changes in status aptSetupEventHandler(); while ((status = aptGetStatus()) != APP_EXITING) { if (status == APP_RUNNING) { //If the app is currently in the forground running, execute the program. program(); } else if (status == APP_SUSPENDING) { //If the app is currently suspended in the background, return to the home menu. aptReturnToMenu(); } else if (status == APP_SLEEPMODE) { //If the app is currently suspended in sleep mode, wait. aptWaitStatusEvent(); } //Wait for GPU gspWaitForVBlank(); } //Close all opened services. hidExit(); gfxExit(); aptExit(); srvExit(); //Kill the process. svcExitProcess(); return 0; }
int main() { initSrv(); aptInit(APPID_APPLICATION); gspGpuInit(); hidInit(NULL); Handle fsuHandle; srv_getServiceHandle(NULL, &fsuHandle, "fs:USER"); FSUSER_Initialize(fsuHandle); Handle fileHandle; u32 bytesRead; FS_archive sdmcArchive=(FS_archive){0x9, (FS_path){PATH_EMPTY, 1, (u8*)""}}; FS_path filePath=(FS_path){PATH_CHAR, 10, (u8*)"/test.bin"}; FSUSER_OpenFileDirectly(fsuHandle, &fileHandle, sdmcArchive, filePath, FS_OPEN_READ, FS_ATTRIBUTE_NONE); FSFILE_Read(fileHandle, &bytesRead, 0x0, (u32*)gspHeap, 0x46500); FSFILE_Close(fileHandle); aptSetupEventHandler(); while(!aptGetStatus()) { u32 PAD=hidSharedMem[7]; renderEffect(); swapBuffers(); copyBuffer(); u32 regData=PAD|0x01000000; GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 4); svc_sleepThread(1000000000); } svc_closeHandle(fsuHandle); hidExit(); gspGpuInit(); aptExit(); svc_exitProcess(); return 0; }
int main() { initSrv(); aptInit(APPID_APPLICATION); gspGpuInit(); hidInit(NULL); Handle fsuHandle; srv_getServiceHandle(NULL, &fsuHandle, "fs:USER"); FSUSER_Initialize(fsuHandle); aptSetupEventHandler(); init_map(); int i; int j; int p=4; int d=0; int q; int frogx = 0; int frogy = 0; int carx[6][9]; int logx[5][6]; // Cant use rand. //for(d=1;d<6;d++){ // while(p>4){ // p = rand(); // } // carx[d]=26+p; for(d=0;d<8;d++){ carx[0][d]=26; if(d<5){ logx[0][d]=26; } d++; } for(d=1;d<8;d++){ if(d<5){ logx[0][d]=0; } carx[0][d]=0; d++; } for(q=0;q<8;q++){ for(d=1; d<6; d++){ if(q<5){ if(d<5){ logx[d][q]=26+p+6; } } carx[d][q]=26+p +6; p=p+6; } p=0; q++; } p= 0; for(q=1;q<8;q++){ for(d=1;d<5;d++){ if(q<5){ if(d<5){ logx[d][q] = p-6; } } carx[d][q]=p-6; p=p-6; } p=0; q++; } while(!aptGetStatus()){ u32 PAD=hidSharedMem[7]; if (PAD == BUTTON_UP){ frogy+= 1; } else if (PAD == BUTTON_DOWN){ frogy+= -1; } else if (PAD == BUTTON_LEFT){ frogx+= -1; } else if (PAD == BUTTON_RIGHT){ frogx+=1; } u32 regData=PAD|0x01000000; init_map(); for(i=0;i<6;i++){ for(j=0;j<8;j++){ draw_car(carx[i][j],15+j*15); if(i<5){ if(j<5){ draw_logs(logx[i][j],150+j*15); } } } } draw_frog(frogx,frogy); //Checks Colition for(i=0;i<6;i++){ for(j=0;j<8;j++){ if(frogy==j+1){ if(frogx==carx[i][j]){ frogy =0; frogx =0; } } } } //Checks if frog in poodle if(frogy >9){ for(i=0;i<5;i++){ for(j=0;j<5;j++){ if(frogy==j+10){ if(frogx==logx[i][j] || frogx==logx[i][j]+1 || frogx==logx[i][j]+2){ frogx= frogx -1; } else{ frogx =0; frogy =0; } } } } } //reinitialize the cars :D // Cant use f*****g rand //for(p=0;p<6;p++){ // if(carx[p]==0){ // d=5; // while(d>4){ // d = rand(); // } // carx[p]= 26+d; // } // else { // carx[p]=carx[p]-1; // } //} for(i=0;i<6;i++){ for(j=0;j<9;j=j+2){ if(i<5){ if(j<5){ if(logx[i][j]==0){ logx[i][j]=26; } else{ logx[i][j]=logx[i][j]-1; } } } if(carx[i][j]==0){ carx[i][j] =26; } else{ carx[i][j]=carx[i][j]-1; } } } for(i=0;i<6;i++){ for(j=1;j<9;j=j+2){ if(i<5){ if(j<5){ if(logx[i][j]==26){ logx[i][j]=0; } else{ logx[i][j]=logx[i][j]+1; } } } if(carx[i][j]==26){ carx[i][j]=0; } else{ carx[i][j]= carx[i][j]+1; } } } copyBuffer(); swapBuffers(); GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 4); svc_sleepThread(220000000); } svc_closeHandle(fsuHandle); hidExit(); gspGpuInit(); aptExit(); svc_exitProcess(); return 0; }
int main() { int i, x, y; touchPosition lastTouch; u32 repeatkeys = 0; int repeatstate = 0; int repeatcount = 0; running = 0; pause = 0; exitemu = 0; PPU_Init(); srvInit(); aptInit(); aptOpenSession(); APT_SetAppCpuTimeLimit(NULL, 30); // enables syscore usage aptCloseSession(); gfxInit(); hidInit(NULL); fsInit(); GPU_Init(NULL); gpuCmdSize = 0x40000; gpuCmd = (u32*)linearAlloc(gpuCmdSize*4); GPU_Reset(gxCmdBuf, gpuCmd, gpuCmdSize); shader = SHDR_ParseSHBIN((u32*)blarg_shbin, blarg_shbin_size); GX_SetMemoryFill(gxCmdBuf, (u32*)gpuOut, 0x404040FF, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201); gfxSwapBuffersGpu(); UI_SetFramebuffer(gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL)); BorderTex = (u32*)linearAlloc(512*256*4); MainScreenTex = (u32*)linearAlloc(512*256*4); SubScreenTex = (u32*)linearAlloc(512*256*4); BrightnessTex = (u8*)linearAlloc(8*256); borderVertices = (float*)linearAlloc(5*3 * 2 * sizeof(float)); screenVertices = (float*)linearAlloc(7*3 * 2 * sizeof(float)); float* fptr = &vertexList[0]; for (i = 0; i < 5*3*2; i++) borderVertices[i] = *fptr++; for (i = 0; i < 7*3*2; i++) screenVertices[i] = *fptr++; sdmcArchive = (FS_archive){0x9, (FS_path){PATH_EMPTY, 1, (u8*)""}}; FSUSER_OpenArchive(NULL, &sdmcArchive); if (!LoadBorder("/blargSnesBorder.bmp")) CopyBitmapToTexture(defaultborder, BorderTex, 400, 240, 0xFF, 0, 64, true); CopyBitmapToTexture(screenfill, PPU_MainBuffer, 256, 224, 0, 16, 64, false); memset(PPU_SubBuffer, 0, 256*256*4); memset(PPU_Brightness, 0xFF, 224); UI_Switch(&UI_ROMMenu); svcCreateEvent(&SPCSync, 0); aptSetupEventHandler(); APP_STATUS status; while((status = aptGetStatus()) != APP_EXITING) { if(status == APP_RUNNING) { svcSignalEvent(SPCSync); hidScanInput(); u32 press = hidKeysDown(); u32 held = hidKeysHeld(); u32 release = hidKeysUp(); GPUCMD_SetBuffer(gpuCmd, gpuCmdSize, 0); RenderTopScreen(); GPUCMD_Finalize(); GPUCMD_Run(gxCmdBuf); if (running) { // emulate CPU_Run(); // runs the SNES for one frame. Handles PPU rendering. // SRAM autosave check // TODO: also save SRAM under certain circumstances (pausing, returning to home menu, etc) framecount++; if (!(framecount & 7)) SNES_SaveSRAM(); } else { // update UI if (held & KEY_TOUCH) { hidTouchRead(&lastTouch); UI_Touch(true, lastTouch.px, lastTouch.py); held &= ~KEY_TOUCH; } else if (release & KEY_TOUCH) { UI_Touch(false, lastTouch.px, lastTouch.py); release &= ~KEY_TOUCH; } if (press) { UI_ButtonPress(press); // key repeat repeatkeys = press & (KEY_UP|KEY_DOWN|KEY_LEFT|KEY_RIGHT); repeatstate = 1; repeatcount = 15; } else if (held == repeatkeys) { repeatcount--; if (!repeatcount) { repeatcount = 7; if (repeatstate == 2) UI_ButtonPress(repeatkeys); else repeatstate = 2; } } } UI_SetFramebuffer(gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL)); UI_Render(); /*GPUCMD_SetBuffer(gpuCmd, gpuCmdSize, 0); RenderTopScreen(); GPUCMD_Finalize(); GPUCMD_Run(gxCmdBuf);*/ // flush the bottomscreen cache while the PICA200 is busy rendering GSPGPU_FlushDataCache(NULL, gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), 0x38400); // wait for the PICA200 to finish drawing gspWaitForP3D(); // copy new screen textures // SetDisplayTransfer with flags=2 converts linear graphics to the tiled format used for textures GX_SetDisplayTransfer(gxCmdBuf, PPU_MainBuffer, 0x01000200, MainScreenTex, 0x01000200, 0x2); gspWaitForPPF(); GX_SetDisplayTransfer(gxCmdBuf, PPU_SubBuffer, 0x01000200, SubScreenTex, 0x01000200, 0x2); gspWaitForPPF(); // copy brightness. // TODO do better u8* bptr = BrightnessTex; for (i = 0; i < 224;) { u32 pixels = *(u32*)&PPU_Brightness[i]; i += 4; *bptr = (u8)pixels; pixels >>= 8; bptr += 2; *bptr = (u8)pixels; pixels >>= 8; bptr += 6; *bptr = (u8)pixels; pixels >>= 8; bptr += 2; *bptr = (u8)pixels; pixels >>= 8; bptr += 22; } // transfer the final color buffer to the LCD and clear it // we can mostly overlap those two operations GX_SetDisplayTransfer(gxCmdBuf, gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000); svcSleepThread(20000); GX_SetMemoryFill(gxCmdBuf, gpuOut, 0x404040FF, &gpuOut[0x2EE00], 0x201, gpuDOut, 0x00000000, &gpuDOut[0x2EE00], 0x201); gspWaitForPPF(); gspWaitForPSC0(); gspWaitForEvent(GSPEVENT_VBlank0, false); gfxSwapBuffersGpu(); } else if(status == APP_SUSPENDING)