void runTest() { int dfd = sceIoDopen("ms0:/tmp/"); if (dfd <= 0) { pspDebugScreenPrintf("sceIoDopen = 0x%08X\n", dfd); return; } SceIoDirent dir; u8 buffer[1044]; while (1) { memset(&dir, 0, sizeof(dir)); memset(buffer, 0, sizeof(buffer)); ((u32 *) buffer)[0] = sizeof(buffer); dir.d_private = buffer; int result = sceIoDread(dfd, &dir); pspDebugScreenPrintf("sceIoDread = 0x%08X\n", result); if (result <= 0) { break; } int i; for (i = 0; i < sizeof(buffer); i++) { if (buffer[i] != 0) { pspDebugScreenPrintf("[%2d] = 0x%02X('%c') ", i, buffer[i], buffer[i]); } } pspDebugScreenPrintf("\n"); } sceIoDclose(dfd); }
void checkVblankInterruptHandler() { int counter = 0, last_counter = 0; int results[3], n; //pspDebugScreenInit(); pspDebugScreenPrintf("Starting...\n"); printf("Starting...\n"); sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0, vblank_handler_counter, &counter); sceKernelDelayThread(80000); results[0] = counter; printf("NotEnabled: Counter:%s\n", (counter == 0) ? "zero" : "non-zero"); // 0. Not enabled yet. sceKernelEnableSubIntr(PSP_VBLANK_INT, 0); sceKernelDelayThread(160000); results[1] = counter; printf("Enabled (GreaterThan2): Counter:%s\n", (counter >= 2) ? "greater" : "no greater"); // n. Already enabled. sceKernelReleaseSubIntrHandler(PSP_VBLANK_INT, 0); last_counter = counter; sceKernelDelayThread(80000); results[2] = counter; printf("Disabled (NotChangedAfterDisabled): %s\n", (last_counter != counter) ? "changed" : "not changed"); // n. Disabled. for (n = 0; n < 3; n++) { //printf("Output %d:%d\n", n, results[n]); pspDebugScreenPrintf("%d\n", results[n]); } }
void pspDebugKbDrawKey(int row, int col, int highlight) { int i; int spacing = 0; int charsTo = 0; int charsTotal = 0; if (highlight) { pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_HIGHLIGHT); pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_HIGHLIGHT); } else { pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR); pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR); } if (row == PSP_DEBUG_KB_COMMAND_ROW) { for (i=0; i<PSP_DEBUG_KB_NUM_COMMANDS; i++) { charsTotal += strlen(commandRow[i]); if (i < col) { charsTo += strlen(commandRow[i]); } } spacing = (PSP_DEBUG_KB_BOX_WIDTH - charsTotal) / (PSP_DEBUG_KB_NUM_COMMANDS + 1); pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + (spacing * (col + 1)) + charsTo, PSP_DEBUG_KB_BOX_Y + (PSP_DEBUG_KB_SPACING_Y * (row + 2))); pspDebugScreenPrintf("%s", commandRow[col]); } else { pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_OFFSET_X + (PSP_DEBUG_KB_SPACING_X * col), PSP_DEBUG_KB_BOX_Y + (PSP_DEBUG_KB_SPACING_Y * (row + 2))); if (charTable[row][col] == '\0') { pspDebugScreenPrintf(" "); } else { pspDebugScreenPrintf("%c", charTable[row][col]); } } }
void write_files(const char *base) { char fn[256]; int newsize; newsize = gzip_decompress(file_buffer, installer, size_installer); if(newsize < 0) { pspDebugScreenPrintf("cannot decompress installer %d\n", newsize); return; } strcpy(fn, base); strcat(fn, "installer.prx"); write_file(fn, file_buffer, newsize); newsize = gzip_decompress(file_buffer, Rebootex_prx, size_Rebootex_prx); if(newsize < 0) { pspDebugScreenPrintf("cannot decompress rebootex %d\n", newsize); return; } strcpy(fn, base); strcat(fn, "Rebootex.prx"); write_file(fn, file_buffer, newsize); }
void printHeader() { pspDebugScreenInit(); pspDebugScreenPrintf("Press Cross to create the Mbx\n"); pspDebugScreenPrintf("Press Circle to send a message to the Mbx\n"); pspDebugScreenPrintf("Press Square to get the Mbx status\n"); pspDebugScreenPrintf("Press Left to receive a message from the Mbx\n"); pspDebugScreenPrintf("Press Triangle to Exit\n"); }
void pspDebugKbDrawString(char* str) { int i; pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR); pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR); pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + ((PSP_DEBUG_KB_BOX_WIDTH - PSP_DEBUG_KB_MAXLEN) / 2), PSP_DEBUG_KB_BOX_Y + 1); for (i=0; i<PSP_DEBUG_KB_MAXLEN; i++) { pspDebugScreenPrintf("_"); } pspDebugScreenSetXY(PSP_DEBUG_KB_BOX_X + ((PSP_DEBUG_KB_BOX_WIDTH - PSP_DEBUG_KB_MAXLEN) / 2), PSP_DEBUG_KB_BOX_Y + 1); pspDebugScreenPrintf("%s", str); }
int main(int argc, char *argv[]) { char buf[1024]; char currdir[1024]; setupCallbacks(); pspDebugScreenInit(); pspDebugScreenPrintf("Registry Shell (c) 2k6 TyRaNiD\n"); pspDebugScreenPrintf("You must access it through a stdin app such as psplink\n"); strcpy(currdir, ROOT_DIR); printf("\n"); printf("%s> ", currdir); while(fgets(buf, sizeof(buf), stdin)) { char *cmd; char *arg; cmd = strtok(buf, " \t\n\r"); arg = strtok(NULL, "\t\n\r"); if(cmd) { if(strcasecmp(cmd, "ls") == 0) { print_key(currdir); } else if(strcasecmp(cmd, "cd") == 0) { change_dir(currdir, arg); } else if(strcasecmp(cmd, "exit") == 0) { break; } else { printf("ERROR: Unknown command '%s'\n", cmd); } } printf("%s> ", currdir); } sceKernelExitGame(); return 0; }
int main(int argc, void *argv[]){ char *quote = "abcdef"; GearWorks::init(); pspDebugScreenInit(); gwRender *render = new gwRender(); render->setClearColor(0xFF888888); render->setPrimitiveRenderMode(GW_FILL); gwTimer *timer = new gwTimer(); while (GearWorks::isRunning()) { timer->update(); render->start(); { for(int i = 0; i < strlen(quote); i++){ renderLetter(render,10 + i * (letterSize.w+5), 50 , quote[i]); } } render->end(true); pspDebugScreenSetXY(0,0); pspDebugScreenPrintf("Quote: %s\tFPS: %f", quote,timer->fps()); } GearWorks::exitGame(); return 1; }
int main(int argc, char **argv) { char buffer[1024]; int decpt, sign; char *rve; pspDebugScreenInit(); pspDebugScreenPrintf("%d", 0); checkSetLessThan(); checkLeftShift(); checkRightShift(); /* dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve); */ emitString((char *)_itoa(12345678, buffer, 10)); emitLong(0x0123456789ABCDEFL); emitLong(testArguments(0x100, 0x1234567800000000L, 9.0f)); test(); checkFloat24(1.0f); emitFloat(2.0f / GlobalFloat); //emitString(dtoa(1234.567, 0, 10, &decpt, &sign, &rve)); return 0; }
/** * Write error message to stderr stream. */ int GdError(const char *format, ...) { va_list args; char buf[1024]; va_start(args, format); #if __ECOS /* diag_printf() has much less dependencies than write() */ diag_printf(format, args); #else #if PSP vsprintf(buf, format, args); pspDebugScreenPrintf("%s\n", buf); #else #if HAVE_FILEIO vsprintf(buf, format, args); write(2, buf, strlen(buf)); #else /* discard EPRINTF/DPRINTF output!*/ #endif #endif #endif va_end(args); return -1; }
/* Example custom exception handler */ void MyExceptionHandler(PspDebugRegBlock *regs) { /* Do normal initial dump, setup screen etc */ pspDebugScreenInit(); /* I always felt BSODs were more interesting that white on black */ pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0xFFFFFFFF); pspDebugScreenClear(); pspDebugScreenPrintf("I regret to inform you your psp has just crashed\n"); pspDebugScreenPrintf("Please contact Sony technical support for further information\n\n"); pspDebugScreenPrintf("Exception Details:\n"); pspDebugDumpException(regs); pspDebugScreenPrintf("\nBlame the 3rd party software, it cannot possibly be our fault!\n"); }
void runTest() { performanceSum = 0; performanceCount = 0; runTest1(); runTest2(); runTest3(); runTest4(); runTest5(); runTest6(); runTest7(); runTest8(); runTest9(); runTest10(); runTest11(); runTest12(); runTest13(); runTest14(); runTest15(); runTest16(); runTest17(); runTest18(); runTest19(); runTest20(); runTest21(); runTest22(); runTest23(); runTest24(); runTest25(); pspDebugScreenPrintf("Overall performance index: %3.0f%%\n", performanceSum * 100 / performanceCount); }
void ExceptionHandler(PspDebugRegBlock * regs) { int i; SceCtrlData pad; pspDebugScreenInit(); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0xFFFFFFFF); pspDebugScreenClear(); pspDebugScreenPrintf("Your PSP has just crashed!\n"); pspDebugScreenPrintf("Exception details:\n\n"); pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); pspDebugScreenPrintf("EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); pspDebugScreenPrintf("Cause - %08X\n", (int)regs->cause); pspDebugScreenPrintf("Status - %08X\n", (int)regs->status); pspDebugScreenPrintf("BadVAddr - %08X\n", (int)regs->badvaddr); for(i=0; i<32; i+=4) pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); sceKernelDelayThread(1000000); pspDebugScreenPrintf("\n\nPress X to dump information on file exception.log and quit"); pspDebugScreenPrintf("\nPress O to quit"); for (;;){ sceCtrlReadBufferPositive(&pad, 1); if (pad.Buttons & PSP_CTRL_CROSS){ char filename[MAX_FILE]; sprintf(filename, "%s/exception.log", main_path); FILE *log = fopen(filename, "w"); if (log != NULL){ char testo[512]; sprintf(testo, "Exception details:\n\n"); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "EPC - %08X / %s.text + %08X\n", (int)regs->epc, module_info.modname, (unsigned int)(regs->epc-(int)&_ftext)); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "Cause - %08X\n", (int)regs->cause); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "Status - %08X\n", (int)regs->status); fwrite(testo, 1, strlen(testo), log); sprintf(testo, "BadVAddr - %08X\n", (int)regs->badvaddr); fwrite(testo, 1, strlen(testo), log); for(i=0; i<32; i+=4){ sprintf(testo, "%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], (int)regs->r[i], regName[i+1], (int)regs->r[i+1], regName[i+2], (int)regs->r[i+2], regName[i+3], (int)regs->r[i+3]); fwrite(testo, 1, strlen(testo), log); } fclose(log); } break; }else if (pad.Buttons & PSP_CTRL_CIRCLE){
/* Dump an exception to screen */ void pspDebugDumpException(PspDebugRegBlock *regs) { int i; pspDebugScreenPrintf("Exception - %s\n", codeTxt[(regs->cause >> 2) & 31]); pspDebugScreenPrintf("EPC - %08X\n", regs->epc); pspDebugScreenPrintf("Cause - %08X\n", regs->cause); pspDebugScreenPrintf("Status - %08X\n", regs->status); pspDebugScreenPrintf("BadVAddr - %08X\n", regs->badvaddr); for(i = 0; i < 32; i+=4) { pspDebugScreenPrintf("%s:%08X %s:%08X %s:%08X %s:%08X\n", regName[i], regs->r[i], regName[i+1], regs->r[i+1], regName[i+2], regs->r[i+2], regName[i+3], regs->r[i+3]); } sceDisplayWaitVblankStart(); }
int psp_power_callback(int arg1, int arg2, void *arg3) { pspDebugScreenPrintf("power call back call !\n"); psp_exit(0); return 0; }
void dispException() { // BSOD ! HAHAHA pspDebugScreenInit(); pspDebugScreenSetBackColor(BLUE); pspDebugScreenSetTextColor(WHITE); pspDebugScreenClear(); pspDebugScreenPrintf(exit_err); }
int _main(SceSize args, void *argp) { char path[1024]; char *slash; do { pspDebugScreenInit(); pspDebugScreenPrintf("PSPLink Bootstrap TyRaNiD (c) 2k7 Version %s\n", PSPLINK_VERSION); strcpy(path, argp); slash = strrchr(path, '/'); if(slash == NULL) { pspDebugScreenPrintf("Could not find last slash\n"); break; } slash++; *slash = 0; strcat(path, MODULE); SceUID mod = sceKernelLoadModule(path, 0, NULL); if (mod < 0) { pspDebugScreenPrintf("Error 0x%08X loading module %s.\n", mod, path); break; } mod = sceKernelStartModule(mod, args, argp, NULL, NULL); if (mod < 0) { pspDebugScreenPrintf("Error 0x%08X starting module %s.\n", mod, path); break; } sceKernelSelfStopUnloadModule(1, 0, NULL); } while(0); sceKernelDelayThread(2000000); sceKernelExitGame(); return 0; }
int main(void) { SceCtrlData pad; pspDebugScreenInit(); SetupCallbacks(); /* Install our custom exception handler. If this was NULL then the default would be used */ pspDebugInstallErrorHandler(MyExceptionHandler); sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); pspDebugScreenPrintf("Exception Sample\n\n"); pspDebugScreenPrintf("You have two choices, press O for a bus error or X for a breakpoint\n\n"); while(1) { sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons & PSP_CTRL_CIRCLE) { /* Cause a bus error */ _sw(0, 0); } if(pad.Buttons & PSP_CTRL_CROSS) { /* Cause a break exception */ asm( "break\r\n" ); } sceDisplayWaitVblankStart(); } /* We will never end up here, hopefully */ printf("End\n"); sceKernelExitDeleteThread(0); return 0; }
int main(void) { unsigned char buffer[0x1e]; /* Buffer */ pspDebugScreenInit(); SetupCallbacks(); pspDebugScreenPrintf("Idstorage sample by harleyg\nThanks to Dark_AleX and Mathieulh\n\n"); /* Read idstorage key 0x050 (serial) */ sceIdStorageLookup(0x050, 0x0, buffer, 0x1e); /* key, offset, buffer, length */ /* Print the serial */ pspDebugScreenPrintf("Serial: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], buffer[7], buffer[8], buffer[9], buffer[10], buffer[11], buffer[12], buffer[13], buffer[14], buffer[15], buffer[16], buffer[17], buffer[18], buffer[19], buffer[20], buffer[21], buffer[22], buffer[23], buffer[24], buffer[25], buffer[26], buffer[27], buffer[28], buffer[29]); sceKernelSleepThread(); return 0; }
void DebugScreen( void ) { fps++; sceRtcGetCurrentTick( &fpsTickNow ); if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f ) { fpsTickLast = fpsTickNow; sprintf( fpsDisplay, "FPS: %i", fps ); fps = 0; } pspDebugScreenSetOffset( (int)fbp0 ); pspDebugScreenSetXY( 0, 0 ); pspDebugScreenPrintf( fpsDisplay ); pspDebugScreenSetXY( 0, 1 ); pspDebugScreenPrintf( "%f", timerTest.getSeconds() ); pspDebugScreenSetXY( 0, 2 ); pspDebugScreenPrintf( "%f %f %f %d", myScene.cam->position.x, myScene.cam->position.y, myScene.cam->position.z, myScene.cam->type); }
void pspDebugKbClearBox() { int i, j; pspDebugScreenSetTextColor(PSP_DEBUG_KB_CHAR_COLOUR); pspDebugScreenSetBackColor(PSP_DEBUG_KB_BACK_COLOUR); for (i = PSP_DEBUG_KB_BOX_X; i <= PSP_DEBUG_KB_BOX_X + PSP_DEBUG_KB_BOX_WIDTH; i++) { for (j = PSP_DEBUG_KB_BOX_Y; j <= PSP_DEBUG_KB_BOX_Y + PSP_DEBUG_KB_BOX_HEIGHT; j++) { pspDebugScreenSetXY(i, j); pspDebugScreenPrintf(" "); } } }
void MyExceptionHandler(PspDebugRegBlock *regs) { /* Do normal initial dump, setup screen etc */ pspDebugScreenInit(); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0xFFFFFFFF); pspDebugScreenClear(); pspDebugScreenPrintf("Exception Details:\n"); pspDebugDumpException(regs); while (1) ; }
int main(int argc, char *argv[]) { SceCtrlData ctl; pspDebugScreenInit(); sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); /* Copy our small program into the ME reset vector */ memcpy((void *)0xbfc00040, me_run, (int)(me_end - me_run)); sceKernelDcacheWritebackInvalidateAll(); sceSysregMeResetEnable(); sceSysregMeBusClockEnable(); sceSysregMeResetDisable(); sceSysregVmeResetDisable(); while(1) { volatile u32 *count = (u32*) 0xBFC00060; pspDebugScreenSetXY(0, 0); pspDebugScreenPrintf("ME Basic Example, press Home to exit\n"); sceKernelDcacheWritebackInvalidateAll(); pspDebugScreenPrintf("ME Counter: %08x\n", *count); sceCtrlReadBufferPositive(&ctl, 1); if(ctl.Buttons & PSP_CTRL_HOME) { sceKernelExitGame(); } sceDisplayWaitVblankStart(); } return 0; }
void FPS( void ) { fps++; sceRtcGetCurrentTick( &fpsTickNow ); if( ((fpsTickNow - fpsTickLast)/((float)tickResolution)) >= 1.0f ) { fpsTickLast = fpsTickNow; sprintf( fpsDisplay, "FPS: %i", fps ); fps = 0; } pspDebugScreenSetOffset( (int)fbp0 ); pspDebugScreenSetXY( 0, 0 ); pspDebugScreenPrintf( fpsDisplay ); }
void endTest(int testNumber) { char s[1000]; int endSystemTime = sceKernelGetSystemTimeLow(); int durationMicros = endSystemTime - startSystemTime; int durationMillis = (durationMicros + 500) / 1000; float pspReference = pspDurationMillis[testNumber] / durationMillis; performanceSum += pspReference; performanceCount++; sprintf(s, "%-25s: %4d ms (%4.0f%%) @ %d MHz\n", testNames[testNumber], durationMillis, pspReference * 100, scePowerGetCpuClockFrequencyInt()); pspDebugScreenPrintf("%s", s); sceIoWrite(logFd, s, strlen(s)); }
void pspDebugPrintf(const char *Format, ...) { va_list Args; va_start( Args, Format ); if (pspDebugFd == (FILE *)0) { pspDebugFd = fopen("ms0:/psp/game/debug.log", "w"); if (! pspDebugFd) { pspDebugScreenPrintf("can\'t open debug file !\n"); sceKernelExitGame(); } } vfprintf(pspDebugFd, Format, Args); va_end( Args ); }
void throwError(int milisecs, char *fmt, ...) { va_list list; char msg[256]; va_start(list, fmt); vsprintf(msg, fmt, list); va_end(list); pspDebugScreenInit(); pspDebugScreenClear(); pspDebugScreenPrintf(msg); sceKernelDelayThread(milisecs * 1000); sceKernelExitGame(); }
int psp_exit(int status) { if (status) { pspDebugScreenPrintf("exit with status %d!\n Press Start to contine\n", status); kbd_wait_start(); } else { } # ifdef DEBUG if (pspDebugFd) { fclose(pspDebugFd); pspDebugFd = (FILE *)0; } # endif sceKernelExitGame(); return 0; }
int main_thread(SceSize args, void *argp) { FILE *fp; int argc = 1; char *argv[] = {save_argv0}; #ifdef WITH_PSP2D sceGuInit(); #endif Py_Initialize(); PySys_SetPath("ms0:/python"); PySys_SetArgv(argc, argv); fp = fopen("script.py", "r"); if (fp) { PyRun_SimpleFile(fp, "script.py"); fclose(fp); } else { #ifndef DEBUG pspDebugScreenInit(); #endif pspDebugScreenPrintf("Error - could not open script.py\n"); } #ifdef DEBUG sceKernelDelayThreadCB(1e7); #endif Py_Finalize(); #ifdef WITH_PSP2D sceGuTerm(); #endif sceKernelExitGame(); return 0; }
void printMbxStatus(SceUID mbxId) { SceKernelMbxInfo mbxInfo; int result; memset(&mbxInfo, 0, sizeof(mbxInfo)); mbxInfo.size = sizeof(mbxInfo); result = sceKernelReferMbxStatus(mbxId, &mbxInfo); if (result != 0) { pspDebugScreenPrintf("sceKernelReferMbxStatus returning 0x%08X\n", result); return; } pspDebugScreenPrintf("sceKernelReferMbxStatus mbxId=0x%08X:\n", mbxId); pspDebugScreenPrintf(" name = '%s'\n", mbxInfo.name); pspDebugScreenPrintf(" attr = 0x%X\n", mbxInfo.attr); pspDebugScreenPrintf(" numWaitThreads = %d\n", (int) mbxInfo.numWaitThreads); pspDebugScreenPrintf(" numMessages = %d\n", (int) mbxInfo.numMessages); pspDebugScreenPrintf(" firstMessage = 0x%08X\n", (int) mbxInfo.firstMessage); }