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(); };
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 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; }
//disegna void disegnamappa(){ blitImageToScreen(starttx*unita,startty*unita ,skernw , skernh, terra, 0, 0); blitAlphaImageToScreen(0,0,unita,unita, eroe, playerx ,playery);// stampa il pezzo sotto del pg disfringe(); }
void disegnatileset(){ clearScreen(RGB(255,255,255)); blitImageToScreen(0,0,480,256,tileset,0,0); blitAlphaImageToScreen(selecttilex*unita,selecttiley*unita,unita,unita,tile,0,256); blitAlphaImageToScreen(0,0,unita,unita, cursore,tilecurposx*unita,tilecurposy*unita);// stampa il pezzo sotto del pg }