void disfringe(){ int y=0; int x=0; int yy; int xx; int xtile; int ytile; for(yy=0;yy<17;yy++){ for(xx=0;xx<30;xx++){ x=xx+starttx; y=yy+startty; if( mappe[0][0][y][x][3] > 1){ ytile=floor(mappe[0][0][y][x][3] / tilesetw); xtile=mappe[0][0][y][x][3]-((ytile)*tilesetw); blitAlphaImageToScreen(xtile*16 ,ytile*16,unita , unita, tile, xx*unita, yy*unita); } if( mappe[0][0][y][x][4] > 1){ ytile=floor(mappe[0][0][y][x][4] / tilesetw); xtile=mappe[0][0][y][x][4]-((ytile)*tilesetw); blitAlphaImageToScreen(xtile*16 ,ytile*16,unita , unita, tile, xx*unita, yy*unita); } if( mappe[0][0][y][x][5] > 1){ if(mappe[0][0][y][x][5] == 2){ printTextScreen(xx*unita+5,yy*unita+5,"B", RGB(255,0,0)); }else{ printTextScreen(xx*unita+5,yy*unita+5,"?", RGB(0,0,0)); } } } } }
int cardDrawSideMenuBackP2(){ char cardBuffer[200]; Image* cardBack; sprintf(cardBuffer, "./images/cards/back.png"); cardBack = loadImage( cardBuffer ); blitAlphaImageToScreen(0,0,74,74,cardBack,406,triadSideCardGridY[0]); blitAlphaImageToScreen(0,0,74,74,cardBack,406,triadSideCardGridY[1]); blitAlphaImageToScreen(0,0,74,74,cardBack,406,triadSideCardGridY[2]); blitAlphaImageToScreen(0,0,74,74,cardBack,406,triadSideCardGridY[3]); blitAlphaImageToScreen(0,0,74,74,cardBack,406,triadSideCardGridY[4]); return 1; }
void resetScreen(){ clearScreen(RGB(0,0,0)); char buffer[200]; Image* bg; sprintf(buffer,"./images/backgrounddeck.png"); bg = loadImage(buffer); blitAlphaImageToScreen(0,0,480,272,bg,0,0); // printed background }
//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(); }}
int DrawBall(Ball *b) { int inPlay = 1; // Change ball's coordinates b->xPos = b->xPos + (b->xDir * b->xSpeed); b->yPos = b->yPos + (b->yDir * b->ySpeed); // Set balls direction as needed if (b->xPos + b->w >= SCREEN_WIDTH) { b->xPos = SCREEN_WIDTH - b->w; b->xDir = b->xDir * -1; } else if (b->xPos <= SCREEN_START + 1) { b->xPos = SCREEN_START + 1; //b->xDir = b->xDir * -1; } if (b->yPos <= SCREEN_START) { b->yPos = SCREEN_START; b->yDir = b->yDir * -1; } else if (b->yPos + b->h >= SCREEN_HEIGHT) { b->yPos = SCREEN_HEIGHT - b->h; b->yDir = b->yDir * -1; } // Check to see if ball is in contact with the paddle if ((b->yPos + b->h) >= _paddle.yPos && ((b->yPos + (b->h / 2)) <= (_paddle.yPos + _paddle.h)) && ((b->xPos + b->w) >= _paddle.xPos) && (b->xPos <= (_paddle.xPos + _paddle.w))) { b->xDir = b->xDir * -1; _score++; if (_score % 5 == 0 && (_resBalls + _ballCount) < MAX_BALLS) _resBalls++; // Add new reserve ball every 5 points } else if (b->xPos <= SCREEN_START + 1) { // Check to see if ball has missed the paddle _ballCount--; // Decrement ball count (number of balls currently in play) if (_ballCount == 0) { // Change state depending on number of balls in reserve if (_resBalls == 0) { if (_highScore < _score) _highScore = _score; // Update high score if necessary. _score = 0; _resBalls = START_RES_BALLS + 1; // Reset score and start reserve balls. _gameState = GAME_OVER; } else { _gameState = GAME_CONTINUE; } _resBalls--; } inPlay = 0; } if (inPlay) { // Update ball image if it is in play b->xPosOld = b->xPos; b->yPosOld = b->yPos; blitAlphaImageToScreen(0, 0, b->w, b->h, (void *)b->image, b->xPos, b->yPos); } return(inPlay); }
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(); };
void cardDrawImageP2Board( char *cardNameFunction, int grid ){ char * path = "Default"; char cardPathBuffer[40]; Image* cardBuffer; int i = 0; for( i = 0; i<5; i++ ){ if(strcmp(cardNameFunction, cardName[i])==0){ path = cardPathP2[i]; sprintf( cardPathBuffer, path ); } } int x=0; int y=0; x = triadGridX[grid]; y = triadGridY[grid]; cardBuffer = loadImage( cardPathBuffer ); blitAlphaImageToScreen(0,0,74,74,cardBuffer,x,y); }
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; }
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; }
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 cardDrawSideMenuP2(){ //String Compare and Draw for Card One Start. char * Path = "Default"; int i = 0; char cardOnePathP2[40]; Image* playerTwoCardOneDraw; for( i = 0; i<5; i++ ){ if(strcmp(playerTwoCardOne, cardName[i])==0){ Path = cardPathP2[i]; sprintf( cardOnePathP2, Path ); } } playerTwoCardOneDraw = loadImage( cardOnePathP2 ); blitAlphaImageToScreen(0,0,74,74,playerTwoCardOneDraw,0,triadSideCardGridY[0]); // End String Compare and Draw for Card One. // String Compare and Draw for Card Two Start. i = 0; Path = "Default"; char cardTwoPathP2[40]; Image* playerTwoCardTwoDraw; for( i=0; i<5; i++ ){ if(strcmp(playerTwoCardTwo, cardName[i])==0){ Path = cardPathP2[i]; sprintf( cardTwoPathP2, Path ); } } playerTwoCardTwoDraw = loadImage( cardTwoPathP2 ); blitAlphaImageToScreen(0,0,74,74,playerTwoCardTwoDraw,0,triadSideCardGridY[1]); // End String Compare and Draw for Card Two. // String Compare and Draw for Card Three Start. i = 0; Path = "Default"; //Reminder: Set Default to Geezard Path char cardThreePathP2[40]; Image* playerTwoCardThreeDraw; for( i=0; i<5; i++){ if(strcmp(playerTwoCardThree,cardName[i])==0){ Path = cardPathP2[i]; sprintf( cardThreePathP2, Path ); } } playerTwoCardThreeDraw = loadImage( cardThreePathP2 ); blitAlphaImageToScreen(0,0,74,74,playerTwoCardThreeDraw,0,triadSideCardGridY[2]); // End String Compare and Draw for Card Three. // String Compare and Draw for Card Four Start. i = 0; Path = "Default"; //Reminder: Set Default to Geezard Path char cardFourPathP2[40]; Image* playerTwoCardFourDraw; for( i=0; i<5; i++){ if(strcmp(playerTwoCardFour,cardName[i])==0){ Path = cardPathP2[i]; sprintf( cardFourPathP2, Path ); } } playerTwoCardFourDraw = loadImage( cardFourPathP2 ); blitAlphaImageToScreen(0,0,74,74,playerTwoCardFourDraw,0,triadSideCardGridY[3]); // End String Compare and Draw for Card Four. // String Compare and Draw for Card Five Start. i = 0; Path = "Default"; //Reminder: Set Default to Geezard Path char cardFivePathP2[40]; Image* playerTwoCardFiveDraw; for( i=0; i<5; i++){ if(strcmp(playerTwoCardFive,cardName[i])==0){ Path = cardPathP2[i]; sprintf( cardFivePathP2, Path ); } } playerTwoCardFiveDraw = loadImage( cardFivePathP2 ); blitAlphaImageToScreen(0,0,74,74,playerTwoCardFiveDraw,0,triadSideCardGridY[4]); // End String Compare and Draw for Card Five. return 1; }
//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 }