void loadTheme() { int i, bytesRead; SceUID fp; fp = sceIoOpen("ms0:/lockdown.thm", PSP_O_RDONLY, 0777); if (fp < 0) { fp = sceIoOpen("flash0:/lockdown.thm", PSP_O_RDONLY, 0777); if (fp < 0) { printTextScreen(0, 0, "Error loading flash0:/lockdown.thm.", RGB(255, 0, 0)); printTextScreen(0, 8, "Place theme at ms0:/lockdown.thm to load from memory stick.", RGB(255, 0, 0)); sceDisplayWaitVblankStart(); flipScreen(); sceKernelSleepThread(); } } for (i = 0; i < NUMFILES; i++) { bytesRead = sceIoRead(fp, &images[i].hdr, sizeof(imagehdr)); if (bytesRead != sizeof(imagehdr)) { printTextScreen(0, 0, "Unexpected end of header.", RGB(255, 0, 0)); sceDisplayWaitVblankStart(); flipScreen(); sceKernelSleepThread(); } images[i].blockid = sceKernelAllocPartitionMemory(2, "block", 0, (sizeof(unsigned char) * images[i].hdr.size), NULL); if (images[i].blockid < 0) { printTextScreen(0, 0, "Memory allocation error.", RGB(255, 0, 0)); sceDisplayWaitVblankStart(); flipScreen(); sceKernelSleepThread(); } images[i].data = (unsigned char*) sceKernelGetBlockHeadAddr(images[i].blockid); bytesRead = sceIoRead(fp, images[i].data, images[i].hdr.size); if (bytesRead != images[i].hdr.size) { printTextScreen(0, 0, "Unexpected end of data.", RGB(255, 0, 0)); sceDisplayWaitVblankStart(); flipScreen(); sceKernelSleepThread(); } } sceIoClose(fp); }
int main(int argc, char *argv[]) { int done = 0; long prvTickCount = 0; int i; int btn; SDL_Event event; long nowTick; int frame; parseArgs(argc, argv); initDegutil(); initSDL(windowMode); if ( !noSound ) initSound(); initFirst(); initTitle(); while ( !done ) { SDL_PollEvent(&event); keys = SDL_GetKeyState(NULL); if ( keys[SDLK_ESCAPE] == SDL_PRESSED || event.type == SDL_QUIT ) done = 1; if ( keys[SDLK_p] == SDL_PRESSED ) { if ( !pPrsd ) { if ( status == IN_GAME ) { status = PAUSE; } else if ( status == PAUSE ) { status = IN_GAME; } } pPrsd = 1; } else { pPrsd = 0; } nowTick = SDL_GetTicks(); frame = (int)(nowTick-prvTickCount) / interval; if ( frame <= 0 ) { frame = 1; SDL_Delay(prvTickCount+interval-nowTick); if ( accframe ) { prvTickCount = SDL_GetTicks(); } else { prvTickCount += interval; } } else if ( frame > 5 ) { frame = 5; prvTickCount = nowTick; } else { prvTickCount += frame*interval; } for ( i=0 ; i<frame ; i++ ) { move(); tick++; } smokeScreen(); draw(); flipScreen(); } quitLast(); }
int netDialog() { int done = 0; pspUtilityNetconfData data; memset(&data, 0, sizeof(data)); data.base.size = sizeof(data); data.base.language = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH; data.base.buttonSwap = PSP_UTILITY_ACCEPT_CROSS; data.base.graphicsThread = 17; data.base.accessThread = 19; data.base.fontThread = 18; data.base.soundThread = 16; data.action = PSP_NETCONF_ACTION_CONNECTAP; struct pspUtilityNetconfAdhoc adhocparam; memset(&adhocparam, 0, sizeof(adhocparam)); data.adhocparam = &adhocparam; sceUtilityNetconfInitStart(&data); while(running) { guStart(); clearScreen(0xff554433); guEnd(); switch(sceUtilityNetconfGetStatus()) { case PSP_UTILITY_DIALOG_NONE: break; case PSP_UTILITY_DIALOG_VISIBLE: sceUtilityNetconfUpdate(1); break; case PSP_UTILITY_DIALOG_QUIT: sceUtilityNetconfShutdownStart(); break; case PSP_UTILITY_DIALOG_FINISHED: done = 1; break; default: break; } sceDisplayWaitVblankStart(); flipScreen(); if(done) break; } return 1; }
static void ShowMessageDialog(const char *message, int enableYesno) { clearScreen(0); flipScreen(); clearScreen(0); flipScreen(); ConfigureDialog(&dialog, sizeof(dialog)); dialog.mode = PSP_UTILITY_MSGDIALOG_MODE_TEXT; dialog.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT; if(enableYesno) dialog.options |= PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS|PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO; strcpy(dialog.message, message); sceUtilityMsgDialogInitStart(&dialog); for(;;) { switch(sceUtilityMsgDialogGetStatus()) { case 2: sceUtilityMsgDialogUpdate(1); break; case 3: sceUtilityMsgDialogShutdownStart(); break; case 0: return; } sceDisplayWaitVblankStart(); } }
//pauses the game // // // // void Pause(Image* theme0,Image* theme1) {SceCtrlData pad; int timer = 0; Color White = RGB(255, 255, 255); Color Black = RGB(0, 0, 0); while(1) { sceCtrlReadBufferPositive(&pad, 1); timer++; if (pad.Buttons & PSP_CTRL_START) { timer++; if (timer > 14) { break; } } if (pad.Buttons & PSP_CTRL_TRIANGLE) { timer++; if (timer > 14) { break; } } if (timer == 14) {timer = 0; } fillScreenRect(Black, 0, 0, 480, 272); blitAlphaImageToScreen(0, 0, 90, 272, theme0, 0, 0); blitAlphaImageToScreen(0, 0, 90, 272, theme1, 390, 0); if (timer < 7) { printTextScreen(210, 130, "PAUSE", White); } if (timer > 7) { printTextScreen(210, 130, "PAUSE", Black); } sceDisplayWaitVblankStart(); flipScreen(); }}
void CruiseEngine::pauseEngine(bool pause) { Engine::pauseEngine(pause); if (pause) { // Draw the 'Paused' message drawSolidBox(64, 100, 256, 117, 0); drawString(10, 100, langString(ID_PAUSED), gfxModuleData.pPage00, itemColor, 300); gfxModuleData_flipScreen(); _savedCursor = currentCursor; changeCursor(CURSOR_NOMOUSE); } else { processAnimation(); flipScreen(); changeCursor(_savedCursor); } gfxModuleData_addDirtyRect(Common::Rect(64, 100, 256, 117)); }
void SkinDialog::paint() { clearImage(drawImage, 0); //fillImageRect(drawImage, (alpha << 24) | bgColor, SKIN_DIALOG_X, SKIN_DIALOG_Y, SKIN_DIALOG_W, SKIN_DIALOG_H); fillImageEllipse(drawImage, (alpha << 24) | bgColor, SKIN_DIALOG_X, SKIN_DIALOG_Y, SKIN_DIALOG_W, SKIN_DIALOG_H, SKIN_DIALOG_R); int titleX = SKIN_DIALOG_X + (SKIN_DIALOG_W - strlen(title)*fontSize/2)/2; mainFont->printStringToImage(drawImage, titleX, SKIN_DIALOG_Y+2+fontSize-1, SKIN_DIALOG_W-titleX+SKIN_DIALOG_X, fontSize+2, labelColor, title); int helpX = SKIN_DIALOG_X + (SKIN_DIALOG_W - strlen(help)*fontSize/2)/2; mainFont->printStringToImage(drawImage, helpX, SKIN_DIALOG_Y+SKIN_DIALOG_H-4-fontSize+fontSize-1, SKIN_DIALOG_W-helpX+SKIN_DIALOG_X, fontSize+2, labelColor, help); if ( itemCurrent < itemTop ) { itemTop = itemCurrent; } else if (itemCurrent - itemTop >= itemBottom ){ itemTop = itemCurrent - itemBottom + 1; } int i; for(i=0;i<itemBottom;i++) { if( itemTop + i < itemCount) { if ( itemTop + i == itemCurrent) mainFont->printStringToImage(drawImage, SKIN_DIALOG_ITEM_X+1, SKIN_DIALOG_ITEM_Y + i*(fontSize+2)+fontSize-1, SKIN_DIALOG_ITEM_W-2, fontSize , PPA_SKINDLG_VALUE_HLCOLOR, skinItems[itemTop + i].longname); else mainFont->printStringToImage(drawImage, SKIN_DIALOG_ITEM_X+1, SKIN_DIALOG_ITEM_Y + i*(fontSize+2)+fontSize-1, SKIN_DIALOG_ITEM_W-2, fontSize , PPA_SKINDLG_VALUE_COLOR, skinItems[itemTop + i].longname); //items[i]->paint(SKIN_DIALOG_ITEM_X, SKIN_DIALOG_ITEM_Y + i*(fontSize+2), SKIN_DIALOG_ITEM_W, fontSize + 2 ); } } guStart(); clearScreen(); // blitImageToScreen(0, 0, screenSnapshot->imageWidth, screenSnapshot->imageHeight, screenSnapshot, 0, 0); blitImageToScreen(0, 0, mainWindow->imageWidth, mainWindow->imageHeight, mainWindow, 0, 0); blitAlphaImageToScreen(0, 0, mainDrawImage->imageWidth, mainDrawImage->imageHeight, mainDrawImage, 0, 0); blitAlphaImageToScreen(0, 0, drawImage->imageWidth, drawImage->imageHeight, drawImage, 0, 0); flipScreen(); };
//shows the current round the player is at void RoundDisplay(int Round) { char RoundAsChar[3]; int timer = 0; Color White = RGB(255, 255, 255); Color Black = RGB(0, 0, 0); while(1) {timer++; if (timer == 150) { break; } fillScreenRect(Black, 0, 0, 480, 272); printTextScreen(200, 135, "Round", White); sprintf(RoundAsChar, "%d", Round); printTextScreen(250, 135, RoundAsChar, White); sceDisplayWaitVblankStart(); flipScreen(); } }
int main() { //call psp stuff pspDebugScreenInit(); SetupCallbacks(); initGraphics(); char bafer[200]; //Image definido no graphics.h Image* nossaImage; //joga caminho no bafer sprintf(bafer, "media/prince_ascii.png"); nossaImage = loadImage(bafer); //checar se imagem existe!! if (!nossaImage) { //Image load failed printf("Ta lah nao! \n"); } else { int x = 0; int y = 0; sceDisplayWaitVblankStart(); blitAlphaImageToScreen(0 ,0 , 480, 272, nossaImage, x, y); flipScreen(); } sceKernelSleepThread(); return 0; }
//shows the game over screen // // // void GameOver(int Score) { char ScoreAsChar[5]; int timer = 0; Color White = RGB(255, 255, 255); Color Black = RGB(0, 0, 0); while(1) { timer++; if (timer == 300) { break; } fillScreenRect(Black, 0, 0, 480, 272); sprintf(ScoreAsChar, "%d", Score); printTextScreen(245, 145, ScoreAsChar, White); printTextScreen(200, 145, "Score:", White); printTextScreen(200, 135, "Game Over", White); sceDisplayWaitVblankStart(); flipScreen(); } }
int main_thread(SceSize args, void *argp) { #ifdef DEBUG pspDebugScreenInit(); printf("Free Memory: %u KB\n",sceKernelTotalFreeMemSize()/1024); #else initGraphics(); loadTheme(); background = loadImageFromMemory(images[BACKGROUND].data, images[BACKGROUND].hdr.size); sceKernelFreePartitionMemory(images[BACKGROUND].blockid); images[BACKGROUND].blockid = -1; mask = loadImageFromMemory(images[MASK].data, images[MASK].hdr.size); sceKernelFreePartitionMemory(images[MASK].blockid); images[MASK].blockid = -1; #endif int firstUse = 0; int recovery = 0; int bytesRead = 0; Config cfg; char input[11]; if ((args == 9) && (strcmp(argp, "recovery") == 0)) { recovery = 1; } SceUID fp; fp = sceIoOpen("flash0:/buttons.ini", PSP_O_RDONLY, 0777); if (fp < 0) { #ifdef DEBUG printf("\nflash0:/buttons.ini could not be opned. Assuming first usage."); #endif firstUse = 1; } else { bytesRead = sceIoRead(fp, &cfg, sizeof(cfg)); sceIoClose(fp); if(bytesRead != sizeof(cfg)) { firstUse = 1; } } if (firstUse) { setPassword(); } else if (((args == 0) || (recovery != 0)) || !(cfg.onlyBoot)) { int len; main_password: #ifndef DEBUG footer_pressselect = loadImageFromMemory(images[FOOTER_PRESSSELECT].data, images[FOOTER_PRESSSELECT].hdr.size); title_password = loadImageFromMemory(images[TITLE_PASSWORD].data, images[TITLE_PASSWORD].hdr.size); #endif while(1) { selectEnabled = 1; #ifdef DEBUG printf("\nPress START to accept.\nPress SELECT to change password.\nEnter password: "******"\nPassword OK."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y); msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y); freeImage(msg_passwordok); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(1000*1000); break; } else { #ifdef DEBUG printf("\nIncorrect password."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_PRESSSELECT].hdr.w, images[FOOTER_PRESSSELECT].hdr.h, footer_pressselect, images[FOOTER_PRESSSELECT].hdr.x, images[FOOTER_PRESSSELECT].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_PASSWORD].hdr.w, images[TITLE_PASSWORD].hdr.h, title_password, images[TITLE_PASSWORD].hdr.x, images[TITLE_PASSWORD].hdr.y); msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y); freeImage(msg_passwordincorrect); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); } } #ifndef DEBUG freeImage(footer_pressselect); freeImage(title_password); #endif if(len == -1) { #ifndef DEBUG footer_changemode = loadImageFromMemory(images[FOOTER_CHANGEMODE].data, images[FOOTER_CHANGEMODE].hdr.size); title_oldpassword = loadImageFromMemory(images[TITLE_OLDPASSWORD].data, images[TITLE_OLDPASSWORD].hdr.size); #endif while(1) { #ifdef DEBUG printf("\nChange password mode.\nEnter old password: "******"\nPassword OK."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y); msg_passwordok = loadImageFromMemory(images[MSG_PASSWORDOK].data, images[MSG_PASSWORDOK].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDOK].hdr.w, images[MSG_PASSWORDOK].hdr.h, msg_passwordok, images[MSG_PASSWORDOK].hdr.x, images[MSG_PASSWORDOK].hdr.y); freeImage(msg_passwordok); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); break; } else { #ifdef DEBUG printf("\nIncorrect password."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_OLDPASSWORD].hdr.w, images[TITLE_OLDPASSWORD].hdr.h, title_oldpassword, images[TITLE_OLDPASSWORD].hdr.x, images[TITLE_OLDPASSWORD].hdr.y); msg_passwordincorrect = loadImageFromMemory(images[MSG_PASSWORDINCORRECT].data, images[MSG_PASSWORDINCORRECT].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDINCORRECT].hdr.w, images[MSG_PASSWORDINCORRECT].hdr.h, msg_passwordincorrect, images[MSG_PASSWORDINCORRECT].hdr.x, images[MSG_PASSWORDINCORRECT].hdr.y); freeImage(msg_passwordincorrect); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); } } #ifndef DEBUG freeImage(footer_changemode); freeImage(title_oldpassword); #endif if(len == -1) { goto main_password; } selectEnabled = 0; setPassword(); } } #ifndef DEBUG freeImage(background); freeImage(mask); sceGuTerm(); int i; for (i = 0; i < NUMFILES; i++) { if (images[i].blockid != -1) { sceKernelFreePartitionMemory(images[i].blockid); } } #endif __psp_free_heap(); #ifdef DEBUG printf("\n__psp_free_heap(): %u KB\n",sceKernelTotalFreeMemSize()/1024); sceKernelDelayThread(3000*1000); #endif #ifdef DEBUG printf("\nLoading loader.prx"); #endif SceUID mod = sceKernelLoadModule("flash0:/loader.prx", 0, NULL); if (mod & 0x80000000) { #ifdef DEBUG printf("\nLoadModule failed 0x%x", mod); #endif } else { SceUID startmod; startmod = sceKernelStartModule(mod, args, argp, NULL, NULL); if (mod != startmod) { #ifdef DEBUG printf("\nStartModule failed 0x%x", startmod); #endif } } return sceKernelExitDeleteThread(0); }
void mainDraw(int mode) { #ifdef USE_GL if(mode == 2) g_driver->CopyBlockPhys((unsigned char *)screen, 0, 0, 320, 200); #endif if(mode == 0) { //restoreDirtyRects(); } else { genVar5 = 0; copyToScreen(aux2, screen); } #ifdef USE_GL g_driver->startFrame(); #endif setClipSize(0, 0, 319, 199); genVar6 = 0; #ifdef USE_GL g_driver->cleanScreenKeepZBuffer(); #endif #ifdef INTERNAL_DEBUGGER if(backgroundMode == backgroundModeEnum_3D) { for(int i = 0; i < getNumberOfRoom(); i++) { drawHardCol(i); drawSceZone(i); } drawConverZones(); } #endif #ifdef USE_GL g_driver->startModelRender(); #endif for(int i = 0; i < numActorInList; i++) { int currentDrawActor = sortedActorTable[i]; actorStruct *actorPtr; actorPtr = &actorTable[currentDrawActor]; //if(actorPtr->flags & 0x25) { actorPtr->flags &= 0xFFFB; if(actorPtr->flags & 0x20) { mainDrawSub2(currentDrawActor); } else { char *bodyPtr = listBody->get(actorPtr->bodyNum); if(listBody->getVar1()) { // initAnimInBody(actorPtr->FRAME, HQR_Get(listAnim, actorPtr->ANIM), bodyPtr); } renderModel(actorPtr->worldX + actorPtr->modX, actorPtr->worldY + actorPtr->modY, actorPtr->worldZ + actorPtr->modZ, actorPtr->alpha, actorPtr->beta, actorPtr->gamma, bodyPtr); if(actorPtr->animActionType && actorPtr->field_98 != -1) { getHotPoint(actorPtr->field_98, bodyPtr, &actorPtr->hotPoint); } ///////////////////////////////////// DEBUG #ifdef INTERNAL_DEBUGGER // if(debuggerVar_drawModelZv) { if(backgroundMode == backgroundModeEnum_3D) { drawZv(actorPtr); } } #endif ///////////////////////////////////// } if(BBox3D1 < 0) BBox3D1 = 0; if(BBox3D3 > 319) BBox3D3 = 319; if(BBox3D2 < 0) BBox3D2 = 0; if(BBox3D4 > 199) BBox3D4 = 199; if(BBox3D1 <= 319 && BBox3D2 <= 199 && BBox3D3 >= 0 && BBox3D4 >= 0) { // is the character on screen ? if(g_fitd->getGameType() == GType_AITD1) { if(actorPtr->field_0 == CVars[getCVarsIdx(LIGHT_OBJECT)]) { mainVar3 = (BBox3D3 + BBox3D1) / 2; mainVar2 = (BBox3D4 + BBox3D2) / 2; } } #ifdef INTERNAL_DEBUGGER if(backgroundMode == backgroundModeEnum_2D) #endif { if(g_fitd->getGameType() == GType_AITD1) drawBgOverlay(actorPtr); } //addToRedrawBox(); } else { actorPtr->field_1A = -1; actorPtr->field_18 = -1; actorPtr->field_16 = -1; actorPtr->field_14 = -1; } } } #ifdef USE_GL g_driver->stopModelRender(); #endif if(drawTextOverlay()) { //addToRedrawBox(); } if(!lightVar1) { if(mode) { if(mode != 2 || lightVar2) { //makeBlackPalette(); flipScreen(); make3dTatouUnk1(0x10, 0); lightVar2 = 0; } else { //flipScreen(); } } else { //mainDrawSub1(); } } else { } #ifdef INTERNAL_DEBUGGER debugger_draw(); #endif #ifdef USE_GL g_driver->stopFrame(); #endif flipScreen(); }
void setPassword() { Config cfg; char input[11]; int len; #ifndef DEBUG footer_changemode = loadImageFromMemory(images[FOOTER_CHANGEMODE].data, images[FOOTER_CHANGEMODE].hdr.size); #endif while(1) { #ifdef DEBUG printf("\nEnter new password: "******"\nConfirm password: "******"\nPassword changed."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_CONFIRMPASSWORD].hdr.w, images[TITLE_CONFIRMPASSWORD].hdr.h, title_confirmpassword, images[TITLE_CONFIRMPASSWORD].hdr.x, images[TITLE_CONFIRMPASSWORD].hdr.y); freeImage(title_confirmpassword); msg_passwordchanged = loadImageFromMemory(images[MSG_PASSWORDCHANGED].data, images[MSG_PASSWORDCHANGED].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_PASSWORDCHANGED].hdr.w, images[MSG_PASSWORDCHANGED].hdr.h, msg_passwordchanged, images[MSG_PASSWORDCHANGED].hdr.x, images[MSG_PASSWORDCHANGED].hdr.y); freeImage(msg_passwordchanged); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); #ifdef DEBUG printf("\n\nPress X to require password only at reboot.\n\nPress O to require password always at XMB."); #else blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); title_requirepassword = loadImageFromMemory(images[TITLE_REQUIREPASSWORD].data, images[TITLE_REQUIREPASSWORD].hdr.size); blitAlphaImageToScreen(0, 0, images[TITLE_REQUIREPASSWORD].hdr.w, images[TITLE_REQUIREPASSWORD].hdr.h, title_requirepassword, images[TITLE_REQUIREPASSWORD].hdr.x, images[TITLE_REQUIREPASSWORD].hdr.y); freeImage(title_requirepassword); buttons = loadImageFromMemory(images[BUTTONS].data, images[BUTTONS].hdr.size); blitAlphaImageToScreen(0, 0, images[BUTTONS].hdr.w, images[BUTTONS].hdr.h, buttons, images[BUTTONS].hdr.x, images[BUTTONS].hdr.y); freeImage(buttons); sceDisplayWaitVblankStart(); flipScreen(); #endif SceCtrlLatch latch; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); int skipped=0; while(1) { sceCtrlReadLatch(&latch); if(!skipped) { skipped=1; continue; } if (latch.uiMake & PSP_CTRL_CROSS) { cfg.onlyBoot = 1; break; } if (latch.uiMake & PSP_CTRL_CIRCLE) { cfg.onlyBoot = 0; break; } sceKernelDelayThread(10*1000); } sceKernelDelayThread(2000*1000); break; } else { #ifdef DEBUG printf("\nPasswords do not match."); #else int temp; blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[FOOTER_CHANGEMODE].hdr.w, images[FOOTER_CHANGEMODE].hdr.h, footer_changemode, images[FOOTER_CHANGEMODE].hdr.x, images[FOOTER_CHANGEMODE].hdr.y); blitAlphaImageToScreen(0, 0, images[TITLE_CONFIRMPASSWORD].hdr.w, images[TITLE_CONFIRMPASSWORD].hdr.h, title_confirmpassword, images[TITLE_CONFIRMPASSWORD].hdr.x, images[TITLE_CONFIRMPASSWORD].hdr.y); freeImage(title_confirmpassword); msg_notmatch = loadImageFromMemory(images[MSG_NOTMATCH].data, images[MSG_NOTMATCH].hdr.size); blitAlphaImageToScreen(0, 0, images[MSG_NOTMATCH].hdr.w, images[MSG_NOTMATCH].hdr.h, msg_notmatch, images[MSG_NOTMATCH].hdr.x, images[MSG_NOTMATCH].hdr.y); freeImage(msg_notmatch); for(temp = 0; temp < len; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(3000*1000); } } #ifndef DEBUG freeImage(footer_changemode); #endif int result; result = sceIoUnassign("flash0:"); if(result < 0) { #ifdef DEBUG printf("\nError in unassign flash0."); #endif } else { result = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0); if(result < 0) { #ifdef DEBUG printf("\nError in assigning flash0 for write."); #endif } else { SceUID fp; fp = sceIoOpen("flash0:/buttons.ini", PSP_O_WRONLY|PSP_O_TRUNC|PSP_O_CREAT, 0777); if(fp < 0) { #ifdef DEBUG printf("\nError writing flash0:/buttons.ini."); #endif } else { sceIoWrite(fp, &cfg, sizeof(cfg)); sceIoClose(fp); #ifdef DEBUG printf("\nPassword written successfully."); #endif } } } }
int getInput(char* input) { int pos=0; int temp; int skipped=0; SceCtrlLatch latch; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); while(1) { sceCtrlReadLatch(&latch); temp=pos; if(!skipped) { skipped=1; continue; } if ((latch.uiMake & PSP_CTRL_SELECT) && selectEnabled) { input[pos] = '\0'; return -1; } if (latch.uiMake & PSP_CTRL_START) { break; } if (pos >=10) { sceKernelDelayThread(10*1000); continue; } if (latch.uiMake & PSP_CTRL_TRIANGLE) { input[pos++] = 1; } if (latch.uiMake & PSP_CTRL_CROSS) { input[pos++] = 2; } if (latch.uiMake & PSP_CTRL_SQUARE) { input[pos++] = 3; } if (latch.uiMake & PSP_CTRL_CIRCLE) { input[pos++] = 4; } if (latch.uiMake & PSP_CTRL_UP) { input[pos++] = 5; } if (latch.uiMake & PSP_CTRL_DOWN) { input[pos++] = 6; } if (latch.uiMake & PSP_CTRL_LEFT) { input[pos++] = 7; } if (latch.uiMake & PSP_CTRL_RIGHT) { input[pos++] = 8; } if (latch.uiMake & PSP_CTRL_LTRIGGER) { input[pos++] = 9; } if (latch.uiMake & PSP_CTRL_RTRIGGER) { input[pos++] = 10; } if(pos>10) { pos=10; } #ifdef DEBUG if (pos > temp) { printf("*"); } #else blitImageToScreen(0, 0, images[BACKGROUND].hdr.w, images[BACKGROUND].hdr.h, background, images[BACKGROUND].hdr.x, images[BACKGROUND].hdr.y); blitAlphaImageToScreen(0, 0, images[footerindex].hdr.w, images[footerindex].hdr.h, *footer, images[footerindex].hdr.x, images[footerindex].hdr.y); blitAlphaImageToScreen(0, 0, images[titleindex].hdr.w, images[titleindex].hdr.h, *title, images[titleindex].hdr.x, images[titleindex].hdr.y); for (temp = 0; temp < pos; temp++) { blitAlphaImageToScreen(0, 0, images[MASK].hdr.w, images[MASK].hdr.h, mask, images[MASK].hdr.x+(temp*images[MASK].hdr.w), images[MASK].hdr.y); } sceDisplayWaitVblankStart(); flipScreen(); #endif sceKernelDelayThread(10*1000); } input[pos] = '\0'; return pos; }
int main() { initGraphics(); SceCtrlData pad, pad_old; sceCtrlReadBufferPositive(&pad_old, 1); starfield.nb_stars = 0; starfield.z_move = 1; starfield_add_stars(&starfield, 600); while(1) { fillScreenRect(RGB(0, 0, 0), 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); starfield_move_and_draw(&starfield); Print(0,0,RGB(255, 255, 255),"StarField - Ported to the TIFF exploit by BlackSith"); Print(2,1,RGB(255, 255, 255),"Originally ported to the PSP by Karmon"); Print(0,30,RGB(255, 255, 255),"..Press Start to Exit.."); //char str_buffer[40]; if(t_disp > 0) { t_disp--; //sprintf(str_buffer, sizeof(str_buffer), "Stars:%d \nSpeed:%d", starfield.nb_stars, starfield.z_move); //print(3, SCREEN_HEIGHT-10, RGB(255, 255, 255), str_buffer); } /*if(frame == 0) { gettimeofday(&tv, NULL); start_fps = tv.tv_sec; } if(show_fps > 0) { gettimeofday(&tv, NULL); //snprintf(str_buffer, sizeof(str_buffer), "FPS: %ld", frame/(tv.tv_sec-start_fps+1)); //printTextScreen(3, 3, str_buffer, RGB(255, 255, 255)); }*/ frame++; sceCtrlReadBufferPositive(&pad, 1); if(pad.Buttons != pad_old.Buttons){ pad_old = pad; if(pad.Buttons & PSP_CTRL_UP) { starfield.z_move++; t_disp = MSG_DISP_TIME; } else if(pad.Buttons & PSP_CTRL_DOWN) { starfield.z_move--; t_disp = MSG_DISP_TIME; } if(pad.Buttons & PSP_CTRL_RIGHT) { starfield_add_stars(&starfield, 100); t_disp=MSG_DISP_TIME; } else if(pad.Buttons & PSP_CTRL_LEFT) { starfield_del_stars(&starfield, 100); t_disp=MSG_DISP_TIME; } if(pad.Buttons & PSP_CTRL_CROSS) { if(show_fps > 0) show_fps--; else show_fps++; } } flipScreen(); sceDisplayWaitVblankStart(); if(pad.Buttons & PSP_CTRL_START) { vshKernelExitVSHVSH(0); } } //sceKernelSleepThread(); return(0); }
Common::Error loadSavegameData(int saveGameIdx) { int lowMemorySave; Common::String saveName; cellStruct *currentcellHead; Common::SaveFileManager *saveMan = g_system->getSavefileManager(); Common::InSaveFile *f = saveMan->openForLoading(_vm->getSavegameFile(saveGameIdx)); if (f == NULL) { printInfoBlackBox("Savegame not found..."); waitForPlayerInput(); return Common::kNoGameDataFoundError; } printInfoBlackBox("Loading in progress..."); initVars(); _vm->sound().stopMusic(); // Skip over the savegame header CruiseSavegameHeader header; readSavegameHeader(f, header); delete header.thumbnail; // Synchronise the remaining data of the savegame Common::Serializer s(f, NULL); DoSync(s); delete f; // Post processing for (int j = 0; j < 64; j++) preloadData[j].ptr = NULL; for (int j = 1; j < numOfLoadedOverlay; j++) { if (overlayTable[j].alreadyLoaded) { overlayTable[j].alreadyLoaded = 0; loadOverlay(overlayTable[j].overlayName); if (overlayTable[j].alreadyLoaded) { ovlDataStruct *ovlData = overlayTable[j].ovlData; // overlay BSS if (ovlRestoreData[j]._sBssSize) { if (ovlData->data4Ptr) { MemFree(ovlData->data4Ptr); } ovlData->data4Ptr = ovlRestoreData[j]._pBss; ovlData->sizeOfData4 = ovlRestoreData[j]._sBssSize; } // overlay object data if (ovlRestoreData[j]._sNumObj) { if (ovlData->arrayObjVar) { MemFree(ovlData->arrayObjVar); } ovlData->arrayObjVar = ovlRestoreData[j]._pObj; ovlData->size9 = ovlRestoreData[j]._sNumObj; } } } } updateAllScriptsImports(); lastAni[0] = 0; lowMemorySave = lowMemory; for (int i = 0; i < NUM_FILE_ENTRIES; i++) { if (filesDatabase[i].subData.ptr) { int j; int k; for (j = i + 1; j < NUM_FILE_ENTRIES && filesDatabase[j].subData.ptr && !strcmp(filesDatabase[i].subData.name, filesDatabase[j].subData.name) && (filesDatabase[j].subData.index == (j - i)); j++) ; for (k = i; k < j; k++) { if (filesDatabase[k].subData.ptrMask) lowMemory = 0; filesDatabase[k].subData.ptr = NULL; filesDatabase[k].subData.ptrMask = NULL; } /*if (j < 2) { error("Unsupported mono file load"); //loadFileMode1(filesDatabase[j].subData.name,filesDatabase[j].subData.var4); } else */ if (strlen(filesDatabase[i].subData.name) > 0) { loadFileRange(filesDatabase[i].subData.name, filesDatabase[i].subData.index, i, j - i); } else { filesDatabase[i].subData.ptr = NULL; filesDatabase[i].subData.ptrMask = NULL; } i = j - 1; lowMemory = lowMemorySave; } } lastAni[0] = 0; currentcellHead = cellHead.next; while (currentcellHead) { if (currentcellHead->type == 5) { uint8 *ptr = mainProc14(currentcellHead->overlay, currentcellHead->idx); ASSERT(0); if (ptr) { ASSERT(0); //*(int16 *)(currentcellHead->datas+0x2E) = getSprite(ptr,*(int16 *)(currentcellHead->datas+0xE)); } else { ASSERT(0); //*(int16 *)(currentcellHead->datas+0x2E) = 0; } } currentcellHead = currentcellHead->next; } if (strlen(currentCtpName)) { loadCtFromSave = 1; initCt(currentCtpName); loadCtFromSave = 0; } //prepareFadeOut(); //gfxModuleData.gfxFunction8(); for (int j = 0; j < 8; j++) { if (strlen((char *)backgroundTable[j].name)) { loadBackground(backgroundTable[j].name, j); } } regenerateBackgroundIncrust(&backgroundIncrustHead); // to finish changeCursor(CURSOR_NORMAL); mainDraw(1); flipScreen(); return Common::kNoError; }
void CruiseEngine::mainLoop() { //int32 t_start,t_left; //uint32 t_end; //int32 q=0; /* Dummy */ int16 mouseX, mouseY; int16 mouseButton; int enableUser = 0; strcpy(nextOverlay, ""); strcpy(lastOverlay, ""); strcpy(cmdLine, ""); currentActiveMenu = -1; autoMsg = -1; linkedRelation = 0; main21 = 0; main22 = 0; userWait = 0; autoTrack = false; initAllData(); playerDontAskQuit = 0; int quitValue2 = 1; int quitValue = 0; if (ConfMan.hasKey("save_slot")) loadGameState(ConfMan.getInt("save_slot")); do { // Handle frame delay uint32 currentTick = g_system->getMillis(); if (!bFastMode) { // Delay for the specified amount of time, but still respond to events bool skipEvents = false; do { g_system->delayMillis(10); currentTick = g_system->getMillis(); if (!skipEvents) skipEvents = manageEvents(); if (playerDontAskQuit) break; _vm->getDebugger()->onFrame(); } while (currentTick < lastTick + _gameSpeed); } else { manageEvents(); if (currentTick >= (lastTickDebug + 10)) { lastTickDebug = currentTick; _vm->getDebugger()->onFrame(); } } if (playerDontAskQuit) break; lastTick = g_system->getMillis(); // Handle switchover in game speed after intro if (!_speedFlag && canLoadGameStateCurrently()) { _speedFlag = true; _gameSpeed = GAME_FRAME_DELAY_2; } // Handle the next frame // frames++; // t_start=Osystem_GetTicks(); // readKeyboard(); bool isUserWait = userWait != 0; playerDontAskQuit = processInput(); if (playerDontAskQuit) break; if (enableUser) { userEnabled = 1; enableUser = 0; } if (userDelay && !userWait) { userDelay--; continue; } if (isUserWait & !userWait) { // User waiting has ended changeScriptParamInList(-1, -1, &procHead, 9999, 0); changeScriptParamInList(-1, -1, &relHead, 9999, 0); // Disable any mouse click used to end the user wait currentMouseButton = 0; } // FIXME: I suspect that the original game does multiple script executions between game frames; the bug with // Raoul appearing when looking at the book is being there are 3 script iterations separation between the // scene being changed to the book, and the Raoul actor being frozen/disabled. This loop is a hack to ensure // that when a background changes, a few extra script executions are done bool bgChanged; int numIterations = 1; while (numIterations-- > 0) { bgChanged = backgroundChanged[masterScreen]; manageScripts(&relHead); manageScripts(&procHead); removeFinishedScripts(&relHead); removeFinishedScripts(&procHead); if (!bgChanged && backgroundChanged[masterScreen]) { bgChanged = true; numIterations += 2; } } processAnimation(); if (remdo) { // ASSERT(0); /* main3 = 0; * var24 = 0; * var23 = 0; * * freeStuff2(); */ } if (cmdLine[0]) { ASSERT(0); /* redrawStrings(0,&cmdLine,8); waitForPlayerInput(); cmdLine = 0; */ } if (displayOn) { if (doFade) PCFadeFlag = 0; /*if (!PCFadeFlag)*/ mainDraw(userWait); flipScreen(); if (userEnabled && !userWait && !autoTrack) { if (currentActiveMenu == -1) { static int16 oldMouseX = -1; static int16 oldMouseY = -1; getMouseStatus(&main10, &mouseX, &mouseButton, &mouseY); if (mouseX != oldMouseX || mouseY != oldMouseY) { int objectType; int newCursor1; int newCursor2; oldMouseX = mouseX; oldMouseY = mouseY; objectType = findObject(mouseX, mouseY, &newCursor1, &newCursor2); if (objectType == 9) { changeCursor(CURSOR_EXIT); } else if (objectType != -1) { changeCursor(CURSOR_MAGNIFYING_GLASS); } else { changeCursor(CURSOR_WALK); } } } else { changeCursor(CURSOR_NORMAL); } } else { changeCursor(CURSOR_NORMAL); } if (userWait == 1) { // Waiting for press - original wait loop has been integrated into the // main event loop continue; } // wait for character to finish auto track if (autoTrack) { if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) { if (autoMsg != -1) { freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0); char* pText = getText(autoMsg, autoOvl); if (strlen(pText)) userWait = 1; } changeScriptParamInList(-1, -1, &relHead, 9998, 0); autoTrack = false; enableUser = 1; } else { userEnabled = false; } } else if (autoMsg != -1) { removeCell(&cellHead, autoOvl, autoMsg, 5, masterScreen); autoMsg = -1; } } else { // Keep ScummVM being responsive even when displayOn is false g_system->updateScreen(); } } while (!playerDontAskQuit && quitValue2 && quitValue != 7); // Free data removeAllScripts(&relHead); removeAllScripts(&procHead); resetActorPtr(&actorHead); freeOverlayTable(); closeCnf(); closeBase(); resetFileEntryRange(0, NUM_FILE_ENTRIES); freeObjectList(&cellHead); freeBackgroundIncrustList(&backgroundIncrustHead); }
void game(){ SceCtrlData pad; int playerStarting; char cursorPathLeft[200] = "./images/selector_left.png"; char cursorPathRight[200] = "./images/selector_right.png"; char *activeCursorPath; Image* lCursorSide1 = loadImage( cursorPathLeft ); Image* lCursorSide2 = loadImage( cursorPathLeft ); Image* lCursorSide3 = loadImage( cursorPathLeft ); Image* lCursorSide4 = loadImage( cursorPathLeft ); Image* lCursorSide5 = loadImage( cursorPathLeft ); //char *playerOneChosenCards[5][20] = { {p1.cardOne}, {p1.cardTwo}, {p1.cardThree}, {p1.cardFour}, {p1.cardFive} }; //char *playerTwoChosenCards[5][20] = { {p2.cardOne}, {p2.cardTwo}, {p2.cardThree}, {p2.cardFour}, {p2.cardFive} }; char *cardSelectedRight; int selMenuLeft = 0; int selMenuRight = 0; int sideDrawDoneLeft = 0; int sideDrawDoneRight = 0; int cursorDrawn = 0; char *cardSelectedPlayerOne; playerStarting = firstRandStart(); resetScreen(); // have to clear the screen to display background etc. setPlayerOneCards( "Geezard", "Funguar", "Bite Bug", "Red Bat", "Blobra"); setPlayerTwoCards( "Geezard", "Funguar", "Bite Bug", "Red Bat", "Blobra"); //set player's cards if(playerStarting == 0){ cardDrawSideMenuP1(); sideDrawDoneLeft = cardDrawSideMenuBackP2(); activeCursorPath = cursorPathLeft; } else { cardDrawSideMenuP2(); sideDrawDoneRight = cardDrawSideMenuBackP1(); activeCursorPath = cursorPathRight; } while(sideDrawDoneLeft == 1){ sceCtrlReadBufferPositive(&pad, 1); sprintf( activeCursorPath, cursorPathLeft ); lCursorSide1 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; if(pad.Buttons & PSP_CTRL_UP){ if(selMenuLeft > 0){ selMenuLeft--; switch(selMenuLeft){ case 0: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide1 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 1: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide2 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 2: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide3 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 3: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide4 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 4: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide5 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; default: break; } } flipScreen(); } else if(pad.Buttons & PSP_CTRL_DOWN){ if(selMenuLeft < 4){ selMenuLeft++; switch(selMenuLeft){ case 0: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide1 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 1: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide2 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 2: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide3 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 3: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide4 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; case 4: if(cursorDrawn == 1){ freeImage( lCursorSide1 ); freeImage( lCursorSide2 ); freeImage( lCursorSide3 ); freeImage( lCursorSide4 ); freeImage( lCursorSide5 ); } sprintf( activeCursorPath, cursorPathLeft ); lCursorSide5 = loadImage( activeCursorPath ); blitAlphaImageToScreen( 0, 0, 24, 15, lCursorSide1, 78, triadSideCardGridY[selMenuLeft]); cursorDrawn = 1; break; default: break; } if(pad.Buttons & PSP_CTRL_CROSS){ switch(selMenuLeft){ case 0: cardSelectedPlayerOne = playerOneCardOne; break; case 1: cardSelectedPlayerOne = playerOneCardTwo; break; case 2: cardSelectedPlayerOne = playerOneCardThree; break; case 3: cardSelectedPlayerOne = playerOneCardFour; break; case 4: cardSelectedPlayerOne = playerOneCardFive; break; default: break; } } } } flipScreen(); } }
int main() { pspDebugScreenInit(); SetupCallbacks(); // Colors enum colors { RED = 0xFF0000FF, GREEN = 0xFF00FF00, BLUE = 0xFFFF0000, WHITE = 0xFFFFFFFF, LITEGRAY = 0xFFBFBFBF, GRAY = 0xFF7F7F7F, DARKGRAY = 0xFF3F3F3F, BLACK = 0xFF000000, }; pspDebugScreenPrintf("intraFont 0.31 - 2009 by BenHur\n\nLoading fonts: 0%%"); // Init intraFont library intraFontInit(); // Load fonts intraFont* ltn[16]; //latin fonts (large/small, with/without serif, regular/italic/bold/italic&bold) char file[40]; int i; for (i = 0; i < 16; i++) { sprintf(file, "flash0:/font/ltn%d.pgf", i); ltn[i] = intraFontLoad(file,0); //<- this is where the actual loading happens intraFontSetStyle(ltn[i], 1.0f, WHITE, DARKGRAY, 0); pspDebugScreenSetXY(15,2); pspDebugScreenPrintf("%d%%",(i+1)*100/20); } intraFont* jpn0 = intraFontLoad("flash0:/font/jpn0.pgf",INTRAFONT_STRING_SJIS); //japanese font with SJIS text string encoding intraFontSetStyle(jpn0, 0.8f, WHITE, DARKGRAY, 0); //scale to 80% pspDebugScreenSetXY(15,2); pspDebugScreenPrintf("%d%%",17*100/20); intraFont* kr0 = intraFontLoad("flash0:/font/kr0.pgf", INTRAFONT_STRING_UTF8); //Korean font (not available on all systems) with UTF-8 encoding intraFontSetStyle(kr0, 0.8f, WHITE, DARKGRAY, 0); //scale to 80% pspDebugScreenSetXY(15,2); pspDebugScreenPrintf("%d%%",18*100/20); intraFont* arib = intraFontLoad("flash0:/font/arib.pgf",0); //Symbols (not available on all systems) intraFontSetStyle(arib, 0.8f, WHITE, DARKGRAY, 0); //scale to 80% pspDebugScreenSetXY(15,2); pspDebugScreenPrintf("%d%%",19*100/20); intraFont* chn = intraFontLoad("flash0:/font/gb3s1518.bwfon", 0); //chinese font intraFontSetStyle(chn, 0.8f, WHITE, DARKGRAY, 0); //scale to 80% pspDebugScreenSetXY(15,2); pspDebugScreenPrintf("done\n"); // Make sure the important fonts for this application are loaded if(!ltn[0] || !ltn[4] || !ltn[8]) sceKernelExitGame(); // Set alternative fonts that are used in case a certain char does not exist in the main font intraFontSetAltFont(ltn[8], jpn0); //japanese font is used for chars that don't exist in latin intraFontSetAltFont(jpn0, chn); //chinese font (bwfon) is used for chars that don't exist in japanese (and latin) intraFontSetAltFont(chn, kr0); //korean font is used for chars that don't exist in chinese (and jap and ltn) intraFontSetAltFont(kr0, arib); //symbol font is used for chars that don't exist in korean (and chn, jap & ltn) // NB: This is an extreme case - usually you need only one alternative font (e.g. japanese & chinese) // Also: if one of the fonts failed to load (e.g. chn) the chain breaks and all subequent fonts are not used (e.g. kr0 and arib) initGraphics(); float x_scroll1 = 80, x_scroll2 = 225, x_scroll3 = 370, x_scroll4 = 385; while(running) { clearScreen(GRAY); // Must be called before any of the intraFont functions guStart(); // Draw various text float x,y = 20; intraFontSetStyle(ltn[4], 1.0f,BLACK,WHITE,INTRAFONT_ALIGN_CENTER); intraFontPrint(ltn[4], 240, y, "intraFont 0.31 - 2009 by BenHur"); intraFontSetStyle(ltn[4], 1.0f,WHITE,DARKGRAY,0); y += 21; intraFontPrint(ltn[8], 10, y, "Latin Sans-Serif:"); intraFontPrint(ltn[0], 180, y, "regular,"); intraFontPrint(ltn[2], 270, y, "italic,"); intraFontPrint(ltn[4], 330, y, "bold,"); intraFontPrint(ltn[6], 390, y, "both"); y += 17; intraFontPrint(ltn[8], 10, y, "Latin Sans-Serif small:"); intraFontPrint(ltn[8], 180, y, "regular,"); intraFontPrint(ltn[10], 270, y, "italic,"); intraFontPrint(ltn[12], 330, y, "bold,"); intraFontPrint(ltn[14], 390, y, "both"); y += 17; intraFontPrint(ltn[8], 10, y, "Latin with Serif:"); intraFontPrint(ltn[1], 180, y, "regular,"); intraFontPrint(ltn[3], 270, y, "italic,"); intraFontPrint(ltn[5], 330, y, "bold,"); intraFontPrint(ltn[7], 390, y, "both"); y += 17; intraFontPrint(ltn[8], 10, y, "Latin with Serif small:"); intraFontPrint(ltn[9], 180, y, "regular,"); intraFontPrint(ltn[11], 270, y, "italic,"); intraFontPrint(ltn[13], 330, y, "bold,"); intraFontPrint(ltn[15], 390, y, "both"); y += 17; intraFontSetEncoding(ltn[8], INTRAFONT_STRING_UTF8); //set text string encoding to UTF-8 intraFontPrint(ltn[8], 10, y, "LTN (UTF8):"); //(has no effect on std ascii) intraFontPrint(ltn[8], 110, y, "\xC3\xA5 \xC3\xA8 \xC3\xAD \xC3\xB4 \xC3\xBC \xC3\xB1"); //UTF-8 encoded chars with accents on top of them intraFontPrint(ltn[8], 250, y, "Symbols: "); unsigned short ucs2_arib[] = { 57786, 57787, 57788, 57789, 57790, 0 }; x = intraFontPrintUCS2(arib, 350, y, ucs2_arib); if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]"); y += 17; intraFontPrint(ltn[8], 10, y, "JPN (UTF8):"); char utf8_jpn[] = {0xE3, 0x81, 0x93, 0xE3, 0x82, 0x93, 0xE3, 0x81, 0xAB, 0xE3, 0x81, 0xA1, 0xE3, 0x81, 0xAF, 0x20, 0xE4, 0xB8, 0x96, 0xE7, 0x95, 0x8C, 0}; intraFontSetEncoding(jpn0, INTRAFONT_STRING_UTF8); //temporarely switch to UTF-8 (INTRAFONT_STRING_SJIS was set in intraFontLoad call) x = intraFontPrint(jpn0, 110, y, utf8_jpn); //print UTF-8 encoded string if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]"); intraFontSetEncoding(jpn0, INTRAFONT_STRING_SJIS); //switch back to S-JIS intraFontPrint(ltn[8], 250, y, "JPN (S-JIS):"); x = intraFontPrint(jpn0, 350, y, "イントラフォント"); //S-JIS encoded text string (flag INTRAFONT_STRING_SJIS set in intraFontLoad call) if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]"); y += 17; intraFontPrint(ltn[8], 10, y, "CHN (GBK):"); char gbk_chn[] = { 0xbc,0xf2, 0xcc,0xe5, 0xd6,0xd0, 0xce,0xc4, 0}; intraFontSetEncoding(chn, INTRAFONT_STRING_GBK); x = intraFontPrint(chn, 110, y, gbk_chn); //print GBK-encoded string (simplified chinese) if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]"); intraFontPrint(ltn[8], 250, y, "CHN (BIG5):"); char big5_chn[] = { 0xc1,0x63, 0xc5,0xe9, 0xa4,0xa4, 0xa4,0xe5, 0}; intraFontSetEncoding(chn, INTRAFONT_STRING_BIG5); x = intraFontPrint(chn, 350, y, big5_chn); //print BIG5-encoded string (trad. chinese) if (x == 350) intraFontPrint(ltn[8], 350, y, "[n/a]"); y += 17; intraFontPrint(ltn[8], 10, y, "KOR (UTF8):"); char utf8_kr[] = {0xed, 0x99, 0x98, 0xec, 0x98, 0x81, 0x20, 0xeb, 0x8c, 0x80, 0xed, 0x95, 0x9c, 0xeb, 0xaf, 0xbc, 0xea, 0xb5, 0xad, 0}; x = intraFontPrint(kr0, 110, y, utf8_kr); //print UTF-8 string (flag INTRAFONT_STRING_UTF8 set in intraFontLoad call) if (x == 110) intraFontPrint(ltn[8], 110, y, "[n/a]"); intraFontPrint(ltn[8], 250, y, "MIX (UCS2):"); unsigned short ucs2_all[] = { 0x0041, 0x0192, 0x3401, 0x3402, 0x4E01, 0x4E02, 0xAC01, 0xAC02, 0xE1BE, 0}; x = intraFontPrintUCS2(ltn[8], 350, y, ucs2_all); //print chars from all fonts (using alternative fonts, which were set after font loading) y += 17; intraFontPrint(ltn[8], 10, y, "Colors: "); intraFontSetStyle(ltn[8], 1.0f,RED,BLUE,0); x = intraFontPrint(ltn[8], 80, y, "colorful, "); intraFontSetStyle(ltn[8], 1.0f,WHITE,0,0); x = intraFontPrint(ltn[8], x, y, "no shadow, "); intraFontSetStyle(ltn[8], 1.0f,0,DARKGRAY,0); x = intraFontPrint(ltn[8], x, y, "no text, "); intraFontSetStyle(ltn[8], 1.0f,0x7FFFFFFF,DARKGRAY,0); x = intraFontPrint(ltn[8], x, y, "transparent, "); intraFontSetStyle(ltn[8], 1.0f,GRAY,WHITE,0); x = intraFontPrint(ltn[8], x, y, "glowing, "); float t = ((float)(clock() % CLOCKS_PER_SEC)) / ((float)CLOCKS_PER_SEC); int val = (t < 0.5f) ? t*511 : (1.0f-t)*511; intraFontSetStyle(ltn[8], 1.0f,LITEGRAY,(0xFF<<24)+(val<<16)+(val<<8)+(val),0); x = intraFontPrint(ltn[8], x, y, "flashing"); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0); y += 17; intraFontPrint(ltn[8], 10, y, "Spacing: "); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX); x = intraFontPrint(ltn[8], 80, y, "fixed (default), "); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_WIDTH_FIX | 12); x = intraFontPrint(ltn[8], x, y, "fixed (12), "); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[8], x, y, "variable width"); y += 22; intraFontPrint(ltn[8], 10, y, "Scaling: "); intraFontSetStyle(ltn[0], 0.5f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[0], 80, y, "tiny, "); intraFontSetStyle(ltn[0], 0.75f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[0], x, y, "small, "); intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[0], x, y, "regular, "); intraFontSetStyle(ltn[0], 1.25f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[0], x, y, "large, "); intraFontSetStyle(ltn[0], 1.5f,WHITE,DARKGRAY,0); x = intraFontPrint(ltn[0], x, y, "huge"); intraFontSetStyle(ltn[0], 1.0f,WHITE,DARKGRAY,0); y += 17; intraFontPrint(ltn[8], 10, y, "Align: "); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_LEFT); t = ((float)(clock() % (CLOCKS_PER_SEC*10))) / ((float)CLOCKS_PER_SEC); int length = (t < 5.0f) ? t*5.8f : (10.0f-t)*5.8f; intraFontPrintColumnEx(ltn[8], 80, y, 90, "left aligned w. linebreaks ", length); //NB: intraFontPrintColumnEx() is used to print a sub-string of a given length (last parameter) // if you want to print the whole string, simply use intraFontPrintColumn() and omit the length parameter intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_CENTER); intraFontPrintColumnEx(ltn[8], 225, y, 110, "center aligned w. linebreaks", length); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_RIGHT); intraFontPrintColumnEx(ltn[8], 370, y, 90, "right aligned w. linebreaks ", length); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_ALIGN_FULL); intraFontPrintColumnEx(ltn[8], 380, y, 90, "full justified w. linebreaks", length); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0); y += 28; intraFontPrint(ltn[8], 10, y, "Scrolling: "); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_LEFT); x_scroll1 = intraFontPrintColumn(ltn[8], x_scroll1, y, 80, "This text is scrolled to the left."); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_SEESAW); x_scroll2 = intraFontPrintColumn(ltn[8], x_scroll2, y, 90, "Back & forth like a seesaw."); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_RIGHT); x_scroll3 = intraFontPrintColumn(ltn[8], x_scroll3, y, 80, "Scrolling to the right..."); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,INTRAFONT_SCROLL_THROUGH); x_scroll4 = intraFontPrintColumn(ltn[8], x_scroll4, y, 80, "This text is scrolled through."); intraFontSetStyle(ltn[8], 1.0f,WHITE,DARKGRAY,0); // End drawing sceGuFinish(); sceGuSync(0,0); // Swap buffers (waiting for vsync) sceDisplayWaitVblankStart(); flipScreen(); } //create screenshot (optional) //saveImage("scrshot.png", getVramDisplayBuffer(), SCREEN_WIDTH, SCREEN_HEIGHT, PSP_LINE_SIZE, 0); // Unload our fonts for (i = 0; i < 16; i++) { intraFontUnload(ltn[i]); } intraFontUnload(jpn0); intraFontUnload(kr0); intraFontUnload(arib); intraFontUnload(chn); // Shutdown font library intraFontShutdown(); sceKernelExitGame(); return 0; }
int video_thread(SceSize args, void *argp) { // Pixel coordinates: first = first luminant pixel to breach threshhold, last = ..., mid = ... Coord first, last, mid; int bufsize; int threshold = 200; // Luminance threshold. int showvideo = 0; // Show the actual video input? 0: No, 1: Yes // Camera buffers. PspUsbCamSetupVideoParam videoparam; static u8 buffer[MAX_STILL_IMAGE_SIZE] __attribute__((aligned(64))); static u8 work[68*1024] __attribute__((aligned(64))); static u32 framebuffer[480*272] __attribute__((aligned(64))); // Startup cursor position. cursor.x = 237, cursor.y = 50; old.x = 237, old.y = 50; // Setup the screenmap size and position. screenmap.x = 20; screenmap.y = 200; screenmap.w = 60; screenmap.h = 60; screenmap.gridcolor = 0xFFC09090; screenmap.fillcolor = 0xFFF0F0F0; screenmap.selcolor = 0xFFC0FFFF; // Create a start button. Button btnStart; btnStart.x = 420; btnStart.y = 250; btnStart.w = 50; btnStart.h = 12; btnStart.fillcolor = 0xFF00FFFF; btnStart.textcolor = 0xFF000000; btnStart.bordercolor = 0xFF000000; btnStart.shadowcolor = 0xFF888888; btnStart.bordersize = 1; btnStart.borderbevel = 0; btnStart.shadowsize = 0; btnStart.shadowdistance = 0; strcpy(btnStart.text, "Start"); strcpy(btnStart.name, "btnStart"); // Wait for camera to be connected. while (!connected) { clearScreen(0xFFF0F0F0); printTextScreenCenter(132, "Please connect the camera and press any button.", 0xFF009900); flipScreen(); sceDisplayWaitVblankStart(); sceKernelDelayThread(20000); } // Load the camera modules and start the decoder. if (LoadModules() < 0) sceKernelSleepThread(); if (StartUsb() < 0) sceKernelSleepThread(); if (sceUsbActivate(PSP_USBCAM_PID) < 0) sceKernelSleepThread(); if (InitJpegDecoder() < 0) sceKernelSleepThread(); while (1) { if ((sceUsbGetState() & 0xF) == PSP_USB_CONNECTION_ESTABLISHED) break; sceKernelDelayThread(50000); } //Setup video parameters and start video capture. memset(&videoparam, 0, sizeof(videoparam)); videoparam.size = sizeof(videoparam); videoparam.resolution = PSP_USBCAM_RESOLUTION_480_272; videoparam.framerate = PSP_USBCAM_FRAMERATE_30_FPS; videoparam.wb = PSP_USBCAM_WB_INCANDESCENT; videoparam.saturation = 125; videoparam.brightness = 100; videoparam.contrast = 64; videoparam.sharpness = 0; videoparam.effectmode = PSP_USBCAM_EFFECTMODE_NORMAL; videoparam.framesize = MAX_VIDEO_FRAME_SIZE; videoparam.evlevel = PSP_USBCAM_EVLEVEL_0_0; if (sceUsbCamSetupVideo(&videoparam, work, sizeof(work)) < 0) sceKernelExitDeleteThread(0); sceUsbCamAutoImageReverseSW(1); if (sceUsbCamStartVideo() < 0) sceKernelExitDeleteThread(0); while (running) { int i, j, lum = 0, tracking = 0; first.x = 0; first.y = 0; last.x = 0; last.y = 0; mid.x = old.x; mid.y = old.y; clearScreen(0xFFFFFFFF); // Capture the camera image into the framebuffer. bufsize = sceUsbCamReadVideoFrameBlocking(buffer, MAX_VIDEO_FRAME_SIZE); if (bufsize > 0) sceJpegDecodeMJpeg(buffer, bufsize, framebuffer, 0); // Analyze the camera image. for (i = 0; i < 272; i++) { for (j = 0; j < 480; j++) { if (showvideo) putPixelScreen(framebuffer[i * CAM_LINE_SIZE + j], j, i); // Show video input. // Calculate luminance (brightness as perceived by the eye) and compare versus threshhold. lum = (299 * R(framebuffer[i * CAM_LINE_SIZE + j]) + 587 * G(framebuffer[i * CAM_LINE_SIZE + j]) + 114 * B(framebuffer[i * CAM_LINE_SIZE + j])) / 1000; if (lum > threshold) { tracking = 1; if (aligned) putPixelScreen(0xFF0000FF, j, i); if ((first.x == 0) || (j < first.x)) first.x = j; if ((first.y == 0) || (i < first.y)) first.y = i; if ((last.x == 0) || (j > last.x)) last.x = j; if ((last.y == 0) || (i > last.y)) last.y = i; } } } if (tracking) { // Calculate directional movement and determine cursor position. mid.x = first.x + (abs((last.x - first.x)) / 2); mid.y = first.y + (abs((last.y - first.y)) / 2); checkDirection(mid, old); switch (direction) { case 0: cursor.x = old.x; cursor.y = old.y; break; case 1: cursor.x = first.x; cursor.y = first.y + (abs((last.y - first.y)) / 2); break; case 2: cursor.x = first.x; cursor.y = first.y; break; case 3: cursor.x = first.x + (abs((last.x - first.x)) / 2); cursor.y = first.y; break; case 4: cursor.x = last.x; cursor.y = first.y; break; case 5: cursor.x = last.x; cursor.y = first.y + (abs((last.y - first.y)) / 2); break; case 6: cursor.x = last.x; cursor.y = last.y; break; case 7: cursor.x = first.x + (abs((last.x - first.x)) / 2); cursor.y = last.y; break; case 8: cursor.x = first.x; cursor.y = last.y; break; }; //Uncomment the following lines to draw 'directional' markers on screen. /*if ((abs(last.x - first.x) > 15) || (abs(last.y - first.y) > 15)) { if ((direction > 0) && (direction <= 4)) { drawLineScreen(first.x, first.y, last.x, last.y, 0xFFC0C0C0); } else { drawLineScreen(last.x, last.y, first.x, first.y, 0xFFC0C0C0); } switch (direction) { case 0: break; case 1: drawLineScreen(last.x, last.y + ((last.y - first.y) / 2), first.x, first.y + ((last.y - first.y) / 2), 0xFFC0C0C0); break; // W case 2: drawLineScreen(last.x, last.y, first.x, first.y, 0xFFC0C0C0); break; // NW case 3: drawLineScreen(first.x + ((last.x - first.x) / 2), last.y, first.x + ((last.x - first.x) / 2), first.y, 0xFFC0C0C0); break; // N case 4: drawLineScreen(first.x, last.y, last.x, first.y, 0xFFC0C0C0); break; // NE case 5: drawLineScreen(first.x, first.y + ((last.y - first.y) / 2), last.x, first.y + ((last.y - first.y) / 2), 0xFFC0C0C0); break; // E case 6: drawLineScreen(first.x, first.y, last.x, last.y, 0xFFC0C0C0); break; // SE case 7: drawLineScreen(first.x + ((last.x - first.x) / 2), first.y, first.x + ((last.x - first.x) / 2), last.y, 0xFFC0C0C0); break; // S case 8: drawLineScreen(last.x, first.y, first.x, last.y, 0xFFC0C0C0); break; // SW }; drawLineScreen((first.x > last.x) ? last.x : first.x, (first.y > last.y) ? last.y : first.y, (first.x < last.x) ? last.x : first.x, (first.y < last.y) ? last.y : first.y, 0xFFC0C0C0); } else { drawRectScreen(0xFFC0C0C0, first.x, first.y, last.x - first.x, last.y - first.y); }*/ } else { printTextScreenCenter(10, "Please return to the playing area.", 0xFF0000FF); if (lastdirection == 0) { cursor.x = old.x; cursor.y = old.y; } //if ((aligned) && (!menu) && (_gameState = GAME_RUNNING)) HandlePauseGame(); } if (!aligned) { showvideo = 1; // Alignment Screen: wait for camera to be aligned to the playing area. printTextScreenCenter(126, "Please align the camera to the playing area.", 0xFFFFFFFF); printTextScreenCenter(136, "Drag the cursor to the \"Start\" button to continue.", 0xFFFFFFFF); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFF00FF00; aligned = 1; menu = 1; } drawButtonScreen(btnStart); if (aligned) { btnStart.fillcolor = 0xFF00FFFF; btnStart.x = 240 - (btnStart.w / 2); btnStart.y = 200; } } else if (menu) { showvideo = 0; // Menu Screen: show a splash, logo, menu, etc. printTextScreenCenter(126, "eyePSP Pong", 0xFF009900); printTextScreenCenter(136, "Please press the \"Start\" button to continue.", 0xFFFF0000); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; menu = 0; } drawButtonScreen(btnStart); } else { // Draw any game objects here. if (_gameState == GAME_PAUSED) { printTextScreenCenter(100, "Game Paused", COLOR_RED); if (tracking) _gameState = GAME_RUNNING; } else if (_gameState == GAME_RUNNING) { DrawMainText(); // Draw main graphics and supporting text to the screen. DrawPaddle(&_paddle); // Draws the paddle to the screen } else if (_gameState == GAME_CONTINUE) { char sbuffer[50]; sprintf(sbuffer, "%d Ball%s Remaining...", _resBalls, (_resBalls == 1) ? "" : "s"); printTextScreenCenter(100, sbuffer, 0xFF000088); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; _gameState = GAME_RUNNING; } drawButtonScreen(btnStart); } else if (_gameState == GAME_OVER) { // Draws game over graphics and waits for user to continue DrawGameOverMenu(); if (checkCoordButton(cursor, btnStart)) { btnStart.fillcolor = 0xFFC0FFC0; _gameState = GAME_RUNNING; } drawButtonScreen(btnStart); } } // Draw cursor (within boundaries) . if (tracking) { for (i = cursor.y - 5; i <= cursor.y + 5; i++) { if ((i > 0) && (i < 272)) putPixelScreen(!tracking ? 0xFF0000FF : 0xFF009900, cursor.x, i); } // y-axis for (j = cursor.x - 5; j <= cursor.x + 5; j++) { if ((j > 0) && (j < 480)) putPixelScreen(!tracking ? 0xFF0000FF : 0xFF009900, j, cursor.y); } // x-axis } old.x = cursor.x; old.y = cursor.y; lastdirection = direction; flipScreen(); sceDisplayWaitVblankStart(); sceKernelDelayThread(2000); } sceKernelExitDeleteThread(0); return 0; }