//The client is connected and can send data: void clientConnected(struct remotePsp *aPsp) { int skip = 0; char mess[100] = "Hello distant World !!!"; while(!osl_quit){ if (!skip){ oslStartDrawing(); printInfo(); oslDrawStringf(10, 60, "Press O to send a message to %s", aPsp->name); oslDrawString(10, 70, "Press O to abort"); oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); oslReadKeys(); if (osl_keys->released.cross) { oslPlaySound(KeypressStandard, 1); oslQuit(); } else if (osl_keys->released.circle) { oslAdhocSendData(aPsp, mess, strlen( mess)); } } }
int scanMS(){ char strFound[10] = ""; char *scannedMsg; cpuBoost(); ML_checkFiles(checkFileCallback); int found = ML_scanMS(userSettings->mediaLibraryRoot, fileExt, fileExtCount-1, scanDirCallback, NULL); cpuRestore(); snprintf(strFound, sizeof(strFound), "%i", found); while(!osl_quit && !exitFlagMediaLibrary){ oslStartDrawing(); drawCommonGraphics(); drawButtonBar(MODE_MEDIA_LIBRARY); strcpy(buffer, langGetString("MEDIA_FOUND")); scannedMsg = replace(buffer, "XX", strFound); drawMessageBox(langGetString("SCAN_FINISHED"), scannedMsg); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); oslReadKeys(); if(getConfirmButton()) break; } return 0; }
void tmHelp(void) { oslClearScreen(RGBA(0, 0, 0, 255)); while (!osl_quit) { oslStartDrawing(); oslReadKeys(); tmDrawGrid(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125)); oslDrawString(1, 10, "ToneMatrix is a 16-step drum machine. The X axis represents one"); oslDrawString(1, 20, "4/4 measure in sixteenth notes, and the Y axis represents eight"); oslDrawString(1, 30, "different sounds. Select a node on the grid with the D-pad and the"); oslDrawString(1, 40, "sound will be played in time."); oslDrawString(1, 60, "Press O (circle) to stop or resume playing. Press [] (square) to"); oslDrawString(1, 70, "mute the row the cursor is on. Press /\\ (triangle) to mute every"); oslDrawString(1, 80, "row except the row the cursor is on. You can mute more than one row"); oslDrawString(1, 90, "at once."); oslDrawString(1, 110, "Press START to use the menu, and use the D-pad to select a menu"); oslDrawString(1, 120, "item or change a value (like the tempo), and X (cross) to confirm"); oslDrawString(1, 130, "to confirm your choice."); oslDrawString(1, 150, "You can play up to sixteen measures in a row by using the R and L"); oslDrawString(1, 160, "triggers, or by switching the \"grid\" value in the START menu."); oslDrawString(1, 170, "If \"loop all\" is on, then the measures will play one after"); oslDrawString(1, 180, "another. If it is off, it will only repeat one measure. It is"); oslDrawString(1, 190, "recommended that you stop playback before editing another grid."); oslDrawString(1, 210, "Press SELECT to hide this screen."); if (osl_keys->pressed.select) break; oslEndDrawing(); oslSyncFrame(); } return; }
int scanDirCallback(char *dirName){ oslStartDrawing(); drawCommonGraphics(); drawButtonBar(MODE_MEDIA_LIBRARY); int startX = (480 - scanBkg->sizeX) / 2; int startY = (272 - scanBkg->sizeY) / 2; oslDrawImageXY(scanBkg, startX, startY); skinGetColor("RGBA_POPUP_TITLE_TEXT", tempColor); skinGetColor("RGBA_POPUP_TITLE_TEXT_SHADOW", tempColorShadow); setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT); oslDrawString((480 - oslGetStringWidth(langGetString("SCANNING"))) / 2, startY + 3, langGetString("SCANNING")); skinGetColor("RGBA_POPUP_MESSAGE_TEXT", tempColor); skinGetColor("RGBA_POPUP_MESSAGE_TEXT_SHADOW", tempColorShadow); setFontStyle(fontNormal, defaultTextSize, RGBA(tempColor[0], tempColor[1], tempColor[2], tempColor[3]), RGBA(tempColorShadow[0], tempColorShadow[1], tempColorShadow[2], tempColorShadow[3]), INTRAFONT_ALIGN_LEFT); getFileName(dirName, buffer); if (strlen(buffer) > 70) buffer[70] = '\0'; oslDrawString((480 - oslGetStringWidth(buffer)) / 2, startY + 30, buffer); oslReadKeys(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); return 0; }
int initiateMessage() { char* nickname = (char*)malloc(100); int skip = 0; oslSetFont(Roboto); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, INTRAFONT_ALIGN_LEFT); while(!osl_quit) { if (!skip) { oslStartDrawing(); if (oslIsWlanPowerOn()) { oslDrawString(10, 10, "Please Enter nickname By Pressing X (Client)..."); oslDrawString(10, 25, "Please Press O To Act As Server..."); if (oslOskIsActive()){ oslDrawOsk(); if (oslGetOskStatus() == PSP_UTILITY_DIALOG_NONE) { if (oslOskGetResult() == OSL_OSK_CANCEL) { nickname = (char*)"Client"; } else { oslOskGetText(nickname); } oslEndOsk(); } } else { oslDrawString(10, 40, "Please turn on the wlan switch!"); } oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); oslReadKeys(); if (osl_keys->released.cross && oslIsWlanPowerOn()) { oslInitOsk((char*)"Please enter nickname!", (char*)"Client", 99, 1, -1); } } } sceKernelExitGame(); return 0; }
void USB_Toggle() { oslReadKeys(); if (osl_keys->pressed.select) { enableUsb(); } else if (osl_keys->pressed.select) { disableUsb(); } }
void langControls() { oslReadKeys(); if (pad.Buttons != oldpad.Buttons) { if (osl_keys->pressed.down) { langScrollDown(); if (strcmp(folderIcons[current].filePath, "doesn't matter") != 0) changeLanguage(); timer = 0; } else if (osl_keys->pressed.up) { langScrollUp(); if (strcmp(folderIcons[current].filePath, "doesn't matter") != 0) changeLanguage(); timer = 0; } } if ((osl_keys->pressed.cross) && (strcmp(folderIcons[current].filePath, "doesn't matter") != 0)) { oslPlaySound(KeypressStandard, 1); language = setFileDefaultsInt("system/settings/language.bin", 0, language); oslDeleteImage(langSelection); firstBootInitiation(); } captureScreenshot(); timer++; if ((timer > 30) && (pad.Buttons & PSP_CTRL_UP)) { dirDown(); timer = 25; } else if ((timer > 30) && (pad.Buttons & PSP_CTRL_DOWN)) { dirDown(); timer = 25; } if (current < 1) current = 1; if (current > MAX_FILES) current = MAX_FILES; }
static int ctrl_init(PyController *self, PyObject *args, PyObject *kwargs) { OSL_CONTROLLER *ctrl; if (!PyArg_ParseTuple(args, ":__init__")) return -1; ctrl = oslReadKeys(); self->pCtrl = (OSL_CONTROLLER*)malloc(sizeof(*ctrl)); memcpy(self->pCtrl, ctrl, sizeof(*ctrl)); return 0; }
//The server accepted the connection and it's ready to receive data: void serverConnected(struct remotePsp *aPsp) { int skip = 0; char buffer[100] = ""; int dataLength = 0; while(!osl_quit){ if (dataLength <= 0) dataLength = oslAdhocReceiveData(aPsp, buffer, 100); if (!skip){ oslStartDrawing(); printInfo(); if (dataLength <= 0) { oslDrawStringf(10, 40, "Waiting for data from %s", aPsp->name); } else { oslDrawStringf(10, 40, "Data received from %s:", aPsp->name); oslDrawStringf(10, 55, buffer); oslDrawString(10, 70, "Press O to receive more data"); } oslDrawString(150, 250, "Press X to quit"); oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); oslReadKeys(); if (osl_keys->released.cross) { oslQuit(); } else if (osl_keys->released.circle && dataLength > 0) { dataLength = 0; memset(buffer, sizeof(buffer), 0); } } }
bool tmDeleteWarning(int slot) { bool x = FALSE; char msg[50]; sprintf(msg, "Are you sure you want to delete song%d.tms ?", slot); while (!osl_quit) { oslStartDrawing(); oslReadKeys(); tmDrawGrid(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125)); oslDrawString(13, 70, msg); oslDrawString(100, 90, "X - Yes"); oslDrawString(100, 100, "O - No"); if (osl_keys->pressed.cross) { x = TRUE; break; } if (osl_keys->pressed.circle) break; oslEndDrawing(); oslSyncFrame(); } return x; }
bool tmClearAllWarning(void) { oslClearScreen(RGBA(0, 0, 0, 255)); bool x = FALSE; while (!osl_quit) { oslStartDrawing(); oslReadKeys(); tmDrawGrid(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125)); oslSetTextColor(RGBA(255,0,0,255)); oslDrawString(200, 50, "WARNING:"); oslSetTextColor(RGBA(255,255,255,255)); oslDrawString(3, 70, "Are you sure you want to clear all grids? This cannot be undone."); oslDrawString(13, 80, "Press X to clear all grids, or press O to cancel."); if (osl_keys->pressed.cross) { x = TRUE; break; } if (osl_keys->pressed.circle) break; oslEndDrawing(); oslSyncFrame(); } return x; }
void MP3Play(char * path) { struct ID3Tag ID3; nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888); mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888); mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888); if (!nowplaying) debugDisplay(); scePowerSetClockFrequency(333, 333, 166); pspAudioInit(); int i, mp3Min = 0; MP3ME_Init(1); ParseID3(path, &ID3); MP3ME_Load(path); MP3ME_Play(); isPlaying = 1; while (!osl_quit) { LowMemExit(); oslStartDrawing(); oslClearScreen(RGB(0,0,0)); oslReadKeys(); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0); if (MP3ME_playingTime > 59) { mp3Min += 1; MP3ME_playingTime = 0; } oslDrawImageXY(nowplaying, 0, 0); oslDrawStringf(240,76, "Playing: %.19s", folderIcons[current].name); oslDrawStringf(240,96, "Title: %.21s", ID3.ID3Title); oslDrawStringf(240,116, "Artist: %.20s", ID3.ID3Artist); oslDrawStringf(240,136, "Album: %.21s", ID3.ID3Album); oslDrawStringf(240,156, "Year: %.22s", ID3.ID3Year); oslDrawStringf(240,176, "Genre: %.21s", ID3.ID3GenreText); oslDrawStringf(435,206, "0%d:%.f", mp3Min, MP3ME_playingTime); if (MP3ME_isPlaying == 1) oslDrawImageXY(mp3Play, 230, 224); if (MP3ME_isPlaying == 0) oslDrawImageXY(mp3Pause, 230, 224); battery(370,2,1); digitaltime(420,4,0,hrTime); volumeController(); if(osl_keys->pressed.select) { oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return; } if(MP3ME_isPlaying == 1 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); MP3ME_Pause(); for(i=0; i<10; i++) { sceDisplayWaitVblankStart(); } } else if (MP3ME_isPlaying == 0 && osl_keys->pressed.cross) { MP3ME_Play(); } if (MP3ME_EndOfStream() == 1) { isPlaying = 0; endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3ME_Play(); } if(osl_keys->pressed.circle) { endAudioLib(); MP3ME_Stop(); releaseAudio(); oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); isPlaying = 0; setCpuBoot(); //Restore previous CPU state return; } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } }
int mp3player() { mp3bg = oslLoadImageFilePNG(apolloBgPath, OSL_IN_RAM, OSL_PF_8888); mp3_select = oslLoadImageFilePNG(apolloSelectorPath, OSL_IN_RAM, OSL_PF_8888); if (!mp3bg || !mp3_select) debugDisplay(); oslSetFont(Roboto); int MenuSelection = 1; // Pretty obvious int selector_x = 8; //The x position of the first selection int selector_y = 43; //The y position of the first selection int selector_image_x; //Determines the starting x position of the selection int selector_image_y = 55; //Determines the starting y position of the selection int numMenuItems = 3; //Amount of items in the menu int selection = 0; while (!osl_quit) { LowMemExit(); selector_image_x = selector_x+(mp3XSelection*MenuSelection); //Determines where the selection image is drawn for each selection selector_image_y = selector_y+(mp3YSelection*MenuSelection); //Determines where the selection image is drawn for each selection oslStartDrawing(); oslReadKeys(); oslClearScreen(RGB(0,0,0)); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0); oslDrawImageXY(mp3bg, 0, 0); oslDrawImageXY(mp3_select, selector_image_x, selector_image_y); oslDrawStringf(20,108,"MUSIC"); oslDrawStringf(20,163,"PSP/MUSIC"); oslDrawStringf(20,218,"PSP/GAME/CyanogenPSP/Downloads"); battery(370,2,1); digitaltime(420,4,0,hrTime); volumeController(); if (osl_keys->pressed.down) MenuSelection++; //Moves the selector down if (osl_keys->pressed.up) MenuSelection--; //Moves the selector up if (MenuSelection > numMenuItems) MenuSelection = 1; //Sets the selection to the first if (MenuSelection < 1) MenuSelection = numMenuItems; //Sets the selection back to last if (MenuSelection == 1 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3View("ms0:/MUSIC"); } else if (MenuSelection == 2 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3View("ms0:/PSP/MUSIC"); } else if (MenuSelection == 3 && osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3View("ms0:/PSP/GAME/CyanogenPSP/downloads"); } if (osl_keys->pressed.circle) { oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); appdrawer(); } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } return selection; }
void mp3Controls() //Controls { oslReadKeys(); if (pad.Buttons != oldpad.Buttons) { if (osl_keys->pressed.down) { mp3Down(); timer = 0; } else if (osl_keys->pressed.up) { mp3Up(); timer = 0; } if (osl_keys->pressed.right) { mp3Downx5(); timer = 0; } else if (osl_keys->pressed.left) { mp3Upx5(); timer = 0; } if (osl_keys->pressed.triangle) { curScroll = 1; current = 1; } if (osl_keys->pressed.cross) { oslPlaySound(KeypressStandard, 1); openDir(folderIcons[current].filePath, folderIcons[current].fileType); } } volumeController(); char * ext = strrchr(folderIcons[current].filePath, '.'); if (osl_keys->pressed.circle) { if((strcmp("ms0:/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/MUSIC", curDir)==0) || (strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)==0) || (strcmp("ms0:/", curDir)==0)) { oslDeleteImage(mp3bg); oslDeleteImage(mp3_select); mp3player(); } else if((strcmp("ms0:/MUSIC", curDir)!=0)) { dirBack(3); } else if((strcmp("ms0:/PSP/MUSIC", curDir)!=0)) { dirBack(4); } else if((strcmp("ms0:/PSP/GAME/CyanogenPSP/downloads", curDir)!=0)) { dirBack(5); } } if (((ext) != NULL) && ((strcmp(ext ,".mp3") == 0) || ((strcmp(ext ,".MP3") == 0))) && (osl_keys->pressed.cross)) { if (isPlaying == 1) { endAudioLib(); MP3ME_Stop(); releaseAudio(); MP3Play(folderIcons[current].filePath); } else { oslPlaySound(KeypressStandard, 1); MP3Play(folderIcons[current].filePath); } } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); timer++; if ((timer > 30) && (pad.Buttons & PSP_CTRL_UP)) { mp3Up(); timer = 25; } else if ((timer > 30) && (pad.Buttons & PSP_CTRL_DOWN)) { mp3Down(); timer = 25; } if (current < 1) current = 1; if (current > MAX_FILES) current = MAX_FILES; }
int soundPlay(char * path) { nowplaying = oslLoadImageFilePNG(nowplayingBgPath, OSL_IN_RAM, OSL_PF_8888); mp3Play = oslLoadImageFilePNG("system/app/apollo/play.png", OSL_IN_RAM, OSL_PF_8888); mp3Pause = oslLoadImageFilePNG("system/app/apollo/pause.png", OSL_IN_RAM, OSL_PF_8888); OSL_SOUND * sound = oslLoadSoundFile(path, OSL_FMT_NONE); if (!nowplaying) debugDisplay(); oslInitAudioME(3); oslPlaySound(sound,0); isPlaying = 1; int Play = 1; while (!osl_quit) { LowMemExit(); oslStartDrawing(); oslClearScreen(RGB(0,0,0)); oslReadKeys(); oslIntraFontSetStyle(Roboto, fontSize, BLACK, 0, 0); oslDrawImageXY(nowplaying, 0, 0); if (Play == 1) oslDrawImageXY(mp3Play, 230, 224); else if (Play == 0) oslDrawImageXY(mp3Pause, 230, 224); oslDrawStringf(240,76, "%.28s", folderIcons[current].name); battery(370,2,1); digitaltime(420,4,0,hrTime); volumeController(); if(osl_keys->pressed.select) { oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return 1; } if(osl_keys->pressed.cross && Play == 1) { Play = 0; oslPlaySound(KeypressStandard, 1); oslPauseSound(sound,-1); } else if(osl_keys->pressed.cross && Play == 0) { Play = 1; oslPlaySound(KeypressStandard, 1); oslPauseSound(sound,-1); } if(osl_keys->pressed.circle) { isPlaying = 0; oslStopSound(sound); oslDeleteSound(sound); oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return 1; } if (osl_keys->pressed.square) { powermenu(); } if (osl_keys->pressed.L) { oslPlaySound(Lock, 1); lockscreen(); } captureScreenshot(); oslEndDrawing(); oslEndFrame(); oslSyncFrame(); } oslStopSound(sound); oslDeleteSound(sound); oslDeleteImage(nowplaying); oslDeleteImage(mp3Play); oslDeleteImage(mp3Pause); return 0; }
/* Affiche le logo OSLib Ne cherchez pas à comprendre cette fonction si vous débutez :p */ int oslShowSplashScreen1() { OSL_IMAGE *texte, *etoile; OSL_IMAGE *fond; int skip=0; int x, y; int angle, nFrame, val; float dist; int pousNb; float pousX[100], pousY[100]; int i, imgAngle; float tblVitPous[8] = {0.2, 0.3, 0.15, 0.2, 0.35, 0.2, 0.15, 0.3}; int fade = 0; //Add these files to the list oslAddVirtualFileList((OSL_VIRTUALFILENAME*)__osl_logo_ram_files, oslNumberof(__osl_logo_ram_files)); texte = oslLoadImageFile("ram:/logo/texte.png", OSL_IN_VRAM | OSL_UNSWIZZLED, OSL_PF_8888); if (!texte) return 0; logoDecalePixels(texte); oslStartDrawing(); oslSetDithering(1); oslSetDrawBuffer(texte); oslDrawGradientRect(0,0, WIDTH,HEIGHT, RGB(0,0,0), RGB(0,0,128), RGB(0,0,128), RGB(0,0,0)); oslSetDrawBuffer(OSL_DEFAULT_BUFFER); oslEndDrawing(); oslMoveImageTo(texte, OSL_IN_RAM); oslSwizzleImage(texte); fond = logoCreeImageFond(); if (!fond) { oslDeleteImage(texte); return 0; } oslSetTransparentColor(RGB(255,0,254)); etoile = oslLoadImageFile("ram:/logo/etoile.png", OSL_IN_RAM, OSL_PF_5551); if (!etoile) { oslDeleteImage(texte); oslDeleteImage(fond); return 0; } oslDisableTransparentColor(); texte->centerX = texte->sizeX / 2; texte->centerY = texte->sizeY / 2; angle = 270; dist = 160.0f; nFrame = 0; pousNb=0; imgAngle = 78; while (!osl_quit) { if (!skip) { oslStartDrawing(); logoCreePaletteRotative(fond, 2000-nFrame*8); oslDrawImage(fond); x = WIDTH/2; y = HEIGHT/2; if (dist > 0) { x += oslCos(angle, dist); y -= oslSin(angle, dist); texte->stretchX = texte->sizeX * (1+dist*0.03f); texte->stretchY = texte->sizeY * (1+dist*0.03f); texte->angle = imgAngle; } else { texte->stretchX = texte->sizeX; texte->stretchY = texte->sizeY; texte->angle = 0; } oslSetBilinearFilter(1); //Effet spécial pour le texturage des nuages if (nFrame >= 50) { val = (nFrame - 50) * 6; if (val > 255) val = 255; oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(val,val,val,0xff)); } else oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(0,0,0,0xff)); oslDrawImageXY(texte, x, y); oslSetImageTileSize(etoile, 0,0, 16,16); oslCorrectImageHalfBorder(etoile); oslImageSetRotCenter(etoile); etoile->angle = 360 - ((nFrame * 3) % 360); etoile->stretchX = 16; etoile->stretchY = 16; oslSetAlpha(OSL_FX_ALPHA|OSL_FX_COLOR, RGBA(0xff,0,0,0xff)); oslDrawImageXY(etoile, 480-9, 272-9); //Dessine l'étoile if (nFrame >= 140 && nFrame < 240) { val = nFrame - 140; angle = (val * 5) % 360; i = nFrame - (240 - 256/12); if (val*16 < 255) oslSetAlpha(OSL_FX_ALPHA, val*16); else if (i > 0) oslSetAlpha(OSL_FX_ALPHA, 255-i*12); else oslSetAlpha(OSL_FX_RGBA, 0); etoile->angle = (val * 8) % 360; etoile->x = WIDTH/2 + oslCosi(angle, 120); etoile->y = HEIGHT/2 - oslSini(angle, 50); etoile->stretchX = 16 * 2; etoile->stretchY = 16 * 2; oslDrawImage(etoile); oslResetImageHalfBorder(etoile); } //Restaure l'environnement oslSetBilinearFilter(0); //Dessine les poussières oslSetAlpha(OSL_FX_ADD, 0xff); oslSetImageTileSize(etoile, 0,16, 8,8); oslImageSetRotCenter(etoile); for (i=0;i<pousNb;i++) oslDrawImageSimpleXY(etoile, pousX[i], pousY[i]); oslSetAlpha(OSL_FX_RGBA, 0); // oslSysBenchmarkDisplay(); //Fade if (nFrame < 32) oslDrawFillRect(0,0, WIDTH,HEIGHT, RGBA(0,0,0,255-(nFrame<<3))); if (fade > 0) { if (fade >= 31) fade = 31; oslDrawFillRect(0,0, WIDTH,HEIGHT, RGBA(0,0,0,(fade<<3))); } oslEndDrawing(); } nFrame++; //L'étoile tourne sur le logo if (nFrame >= 140 && nFrame < 240) { val = nFrame - 140; angle = (val * 5) % 360; if (angle >= 200 && angle <= 340) { pousX[pousNb] = WIDTH/2 + oslCos(angle, 120); pousY[pousNb] = HEIGHT/2 - oslSin(angle, 50); pousNb++; } } if (fade > 0) fade++; if (nFrame > 290 && fade == 0) fade = 1; for (i=0;i<pousNb;i++) { pousY[i] += tblVitPous[i%8]; } dist -= 2.0f; angle -= 4; imgAngle -= 1; if (angle < 0) angle += 360; skip = oslSyncFrameEx(1,4,0); //Lecture des touches oslReadKeys(); if ((osl_keys->pressed.value & (OSL_KEYMASK_START|OSL_KEYMASK_CIRCLE|OSL_KEYMASK_CROSS)) && fade == 0) fade = 1; if (fade >= 32) break; } oslSetAlpha(OSL_FX_RGBA, 0); oslDeleteImage(texte); oslDeleteImage(fond); oslDeleteImage(etoile); oslRemoveVirtualFileList((OSL_VIRTUALFILENAME*)__osl_logo_ram_files, oslNumberof(__osl_logo_ram_files)); return 1; }
//Waits for a connection from a psp: void doServer() { int skip = 0; int quit = 0; char message[100] = ""; int dialog = OSL_DIALOG_NONE; int connected = 0; int init = oslAdhocInit("ULUS99999"); if (init) { snprintf(message, sizeof(message), "adhocInit error: %i", init); oslMessageBox(message, "Debug", oslMake3Buttons(OSL_KEY_CROSS, OSL_MB_OK , 0, 0, 0, 0)); return; } while(!osl_quit && !quit){ struct remotePsp *reqPsp = oslAdhocGetConnectionRequest(); if (!skip){ oslStartDrawing(); printInfo(); oslDrawString(10, 40, "Press O to abort"); if (reqPsp == NULL) { oslDrawString(10, 100, "Waiting for a connection request..."); } else { snprintf(message, sizeof(message), "Accept request from psp : %s", reqPsp->name); oslDrawString(10, 100, message); if (oslGetDialogType() == OSL_DIALOG_NONE) oslInitMessageDialog(message, 1); } dialog = oslGetDialogType(); if (dialog){ oslDrawDialog(); if (oslGetDialogStatus() == PSP_UTILITY_DIALOG_NONE){ if (dialog == OSL_DIALOG_MESSAGE){ int button = oslGetDialogButtonPressed(); if (button == PSP_UTILITY_MSGDIALOG_RESULT_YES) { oslAdhocAcceptConnection(reqPsp); connected = 1; } else if (button == PSP_UTILITY_MSGDIALOG_RESULT_NO) { oslAdhocRejectConnection(reqPsp); } } oslEndDialog(); } } oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); if (connected) serverConnected(reqPsp); oslReadKeys(); if (dialog == OSL_DIALOG_NONE) { if (osl_keys->released.circle) { quit = 1; } } } oslAdhocTerm(); }
int oslShowSplashScreen2() { OSL_IMAGE *logo, *temp; int skip = 0; float y, vy; int frameNb, phase; float vyList[TABW]; float speeds[TABH][TABW]; int i, j, fade; float positions[TABH][TABW]; temp = oslLoadImageFile("logo/neoflash.png", OSL_IN_RAM, OSL_PF_5650); if (!temp) return 0; logo = oslCreateSwizzledImage(temp, OSL_IN_VRAM); oslDeleteImage(temp); if (!logo) return 0; y = -logo->sizeY; vy = 1.0f; frameNb = 0; phase = 1; fade = 0; for (i=0;i<LARG/TILE;i++) vyList[i] = (rand() % 7500) / 10000.f + 0.25f; for (j=0;j<HAUT/TILE;j++) for (i=0;i<LARG/TILE;i++) { speeds[j][i] = vyList[i] - (HAUT/TILE - j) * ((rand() % 1000) / 10000.0f + 0.04f); positions[j][i] = j * TILE; } while(!osl_quit && fade < 31 && frameNb < 220) { oslReadKeys(); if (phase < 9) { y += vy; if (y + logo->sizeY >= HAUT) { if (vy > 0) vy -= 0.8f; else vy -= 0.4f; if (phase % 2 == 1) phase++; } else if (phase == 1) vy += 0.4f; else { if (vy > 0) vy += 0.4f; else vy += 0.8f; if (phase % 2 == 0) phase++; } } else { y = 0; frameNb++; } if (frameNb > 120) { for (j=0;j<HAUT/TILE;j++) for (i=0;i<LARG/TILE;i++) { speeds[j][i] += 0.15f; if (speeds[j][i] > 0.0f) positions[j][i] += speeds[j][i]; } } if (fade > 0) fade++; if ((osl_keys->pressed.value & (OSL_KEYMASK_START|OSL_KEYMASK_CIRCLE|OSL_KEYMASK_CROSS)) && fade == 0) fade = 1; if (!skip) { oslStartDrawing(); oslClearScreen(0); if (frameNb <= 120) { logo->y = y; if (y < 0) { logo->stretchY = logo->sizeY; logo->stretchX = logo->sizeX; logo->x = 0; } else { logo->stretchY = logo->sizeY - y; logo->stretchX = logo->sizeX + y; logo->x = - y / 2; } oslDrawImage(logo); } else LogoDrawTiles(logo, positions); if (fade > 0) { oslSetAlpha(OSL_FX_RGBA, 0); oslDrawFillRect(0, 0, LARG, HAUT, RGBA(0, 0, 0, fade<<3)); /* oslSetAlpha(OSL_FX_SUB, 0xff); oslDrawFillRect(0, 0, LARG, HAUT, RGB(fade<<3, fade<<3, fade<<3)); oslSetAlpha(OSL_FX_DEFAULT, 0);*/ } oslEndDrawing(); } skip = oslSyncFrameEx(1,4,0); } oslDeleteImage(logo); return 1; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Main: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main(){ int skip = 0; int enabled = 1; int selectedConfig = 0; SetupCallbacks(); initOSLib(); oslIntraFontInit(INTRAFONT_CACHE_MED); oslNetInit(); //Loads image: bkg = oslLoadImageFilePNG("bkg.png", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888); //Load font: OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf"); oslSetFont(font); if (!oslIsWlanPowerOn()) sprintf(message, "Please turn on the WLAN."); //Get connections list: struct oslNetConfig configs[OSL_MAX_NET_CONFIGS]; int numconfigs = oslGetNetConfigs(configs); if (!numconfigs){ sprintf(message, "No configuration found!"); enabled = 0; } while(runningFlag && !osl_quit){ if (!skip){ oslStartDrawing(); oslDrawImageXY(bkg, 0, 0); if (enabled){ sprintf(buffer, "Press X to connect to %s.", configs[selectedConfig].name); oslDrawString(30, 50, buffer); oslDrawString(30, 80, "Press UP and DOWN to change settings."); } oslDrawString(30, 150, "Press /\\ to quit."); oslDrawString(30, 200, message); oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); oslReadKeys(); if (osl_keys->released.triangle) runningFlag = 0; if (osl_keys->released.cross){ connectToAP(selectedConfig + 1); }else if (osl_keys->released.up){ if (++selectedConfig >= numconfigs) selectedConfig = numconfigs - 1; }else if (osl_keys->released.down){ if (--selectedConfig < 0) selectedConfig = 0; } } //Quit OSL: oslNetTerm(); oslEndGfx(); sceKernelExitGame(); return 0; }
//Connects to a psp: void doClient() { int skip = 0; int quit = 0; int i = 0; int current = 0; int init = oslAdhocInit("ULUS99999"); if (init) { char message[100] = ""; sprintf(message, "adhocInit error: %i", init); oslMessageBox(message, "Debug", oslMake3Buttons(OSL_KEY_CROSS, OSL_MB_OK , 0, 0, 0, 0)); return; } while(!osl_quit && !quit){ if (!skip){ oslStartDrawing(); printInfo(); if (oslAdhocGetRemotePspCount()) oslDrawString(10, 60, "Press X to request a connection"); oslDrawString(10, 70, "Press O to abort"); for (i=0; i < oslAdhocGetRemotePspCount(); i++) { if (i == current) oslIntraFontSetStyle(Roboto, 1.0, RGBA(100,100,100,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT); else oslIntraFontSetStyle(Roboto, 1.0, RGBA(255,255,255,255), RGBA(0,0,0,0), INTRAFONT_ALIGN_LEFT); oslDrawString(10, 100 + 15 * i, oslAdhocGetPspByIndex(i)->name); } oslEndDrawing(); } oslEndFrame(); skip = oslSyncFrame(); oslReadKeys(); if (osl_keys->released.down) { if (++current >= oslAdhocGetRemotePspCount()) current = 0; } else if (osl_keys->released.up) { if (--current < 0) current = oslAdhocGetRemotePspCount() - 1; } else if (osl_keys->released.cross && oslAdhocGetRemotePspCount()) { //Request a connection: int ret = oslAdhocRequestConnection(oslAdhocGetPspByIndex(current), 30, NULL); if (ret == OSL_ADHOC_ACCEPTED || ret == OSL_ADHOC_ESTABLISHED) { clientConnected(oslAdhocGetPspByIndex(current)); } } else if (osl_keys->released.circle) { quit = 1; } } oslAdhocTerm(); }
void tmFileDialog(bool save) { int x; unsigned char option = 0; bool empty[MAX_SAVE_SLOTS]; char strings[MAX_SAVE_SLOTS][50]; char mdate[MAX_SAVE_SLOTS][50]; char tmp[30]; SceIoStat a; typedef struct { int year, month, day; int minute, hour; } metadata; metadata songMeta[MAX_SAVE_SLOTS]; current = 0; for (x = 0; x < MAX_SAVE_SLOTS; x++) { bzero(tmp, sizeof(tmp)); sprintf(tmp, "songs/song%d.tms", x); sceIoGetstat(tmp, &a); songMeta[x].year = a.st_mtime.year; songMeta[x].month = a.st_mtime.month; songMeta[x].day = a.st_mtime.day; songMeta[x].minute = a.st_mtime.minute; songMeta[x].hour = a.st_mtime.hour; } // I have to make a separate struct because accessing sm->tm_mday // from the while (!osl_quit) fries the memory stick // same reason why there's a bool empty[] for (x = 0; x < MAX_SAVE_SLOTS; x++) { bzero(tmp, sizeof(tmp)); sprintf(tmp, "songs/song%d.tms", x); empty[x] = tmDoesFileExist(tmp); } while (!osl_quit) { oslStartDrawing(); oslReadKeys(); tmDrawGrid(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125)); if (save) oslDrawString(10, 40, "Press X (cross) to save your song in the selected slot."); else oslDrawString(10, 40, "Press X (cross) to load a song from the selected slot."); oslDrawString(10, 50, "Press O (circle) to cancel."); for (x = 0; x < MAX_SAVE_SLOTS; x++) { bzero(strings[x], sizeof(strings[x])); bzero(tmp, sizeof(tmp)); sprintf(tmp, "song%d.tms", x); sprintf(strings[x], "%s %s", (option == x) ? "->" : " ", (empty[x]) ? "EMPTY" : tmp); sprintf(mdate[x], "%d/%d/%d %d:%d UTC", songMeta[x].month, songMeta[x].day, songMeta[x].year, songMeta[x].hour, songMeta[x].minute); oslDrawString(10, (70+(x*10)), strings[x]); if (!empty[x]) oslDrawString(200, (70+(x*10)), mdate[x]); } oslDrawString(10, 190, "Press /\\ (triangle) to delete the selected song slot."); if ((osl_keys->pressed.up) && (option > 0)) option--; if ((osl_keys->pressed.down) && (option < (MAX_SAVE_SLOTS-1))) option++; if (osl_keys->pressed.cross) { if (empty[option]) { if (save) { tmWrite(option); break; } } else { if (save) { if (tmOverwriteWarning(option)) { tmWrite(option); break; } } else { tmRead(option); break; } } } if (osl_keys->pressed.triangle) { if (!empty[option]) { if (tmDeleteWarning(option)) { bzero(tmp, sizeof(tmp)); sprintf(tmp, "songs/song%d.tms", option); remove(tmp); empty[option] = TRUE; } } } if (osl_keys->pressed.circle) break; if (osl_keys->pressed.start) break; oslEndDrawing(); oslSyncFrame(); } return; }
unsigned char tmMenu(void) { int x; char mstrings[MAX_MENU_ITEMS][40]; char ver[25]; while (!osl_quit) { oslStartDrawing(); oslReadKeys(); tmDrawGrid(); oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125)); tempo = tmTempo(bpm); bpm = tmBPM(tempo); for (x = 0; x < MAX_MENU_ITEMS; x++) { bzero(mstrings[x], sizeof(mstrings[x])); switch (x) { case SAVEM: sprintf(mstrings[x], "%s Save song", (menuoption == x) ? "->" : " "); break; case LOADM: sprintf(mstrings[x], "%s Load song", (menuoption == x) ? "->" : " "); break; case HELPM: sprintf(mstrings[x], "%s Help me", (menuoption == x) ? "->" : " "); break; case LOOPM: sprintf(mstrings[x], "%s Loop all: %s", (menuoption == x) ? "->" : " ", (loopall) ? "on" : "off"); break; case TEMPOM: sprintf(mstrings[x], "%s Tempo: %d BPM", (menuoption == x) ? "->" : " ", tmBPM(tempo)); break; case GRIDM: sprintf(mstrings[x], "%s Grid: %d", (menuoption == x) ? "->" : " ", (current+1)); break; case CUTM: sprintf(mstrings[x], "%s Cut grid", (menuoption == x) ? "->" : " "); break; case COPYM: sprintf(mstrings[x], "%s Copy grid", (menuoption == x) ? "->" : " "); break; case PASTEM: if (tmIsGridEmpty(clipboard)) oslSetTextColor(RGBA(255,0,0,255)); sprintf(mstrings[x], "%s Paste grid", (menuoption == x) ? "->" : " "); break; case CLEARM: sprintf(mstrings[x], "%s Clear grid", (menuoption == x) ? "->" : " "); break; case CLEARALLM: sprintf(mstrings[x], "%s Clear all grids", (menuoption == x) ? "->" : " "); break; } oslDrawString(10, (60+(x*10)), mstrings[x]); oslSetTextColor(RGBA(255,255,255,255)); } bzero(ver, sizeof(ver)); // sprintf(ver, "ToneMatrix %s by Babkock", VERSION); oslDrawString(10, 240, ver); if ((osl_keys->pressed.up) && (menuoption > 0)) { menuoption--; if (menuoption == BREAK) menuoption--; } if ((osl_keys->pressed.down) && (menuoption < (MAX_MENU_ITEMS-1))) { menuoption++; if (menuoption == BREAK) menuoption++; } if (osl_keys->pressed.left) { switch (menuoption) { case GRIDM: if (current > 0) current--; break; case LOOPM: loopall = (loopall) ? FALSE : TRUE; break; case TEMPOM: if (bpm > MIN_BPM) bpm -= 5; tempo = tmTempo(bpm); break; } } if (osl_keys->pressed.right) { switch (menuoption) { case GRIDM: if (current < (MAX_GRIDS-1)) current++; break; case LOOPM: loopall = (loopall) ? FALSE : TRUE; break; case TEMPOM: if (bpm < MAX_BPM) bpm += 5; tempo = tmTempo(bpm); break; } } if (osl_keys->pressed.cross) { if ((menuoption != LOOPM) && (menuoption != TEMPOM) && (menuoption != GRIDM) && (menuoption != CUTM) && (menuoption != COPYM) && (menuoption != PASTEM)) return menuoption; else { switch (menuoption) { case CUTM: clipboard = tmClear(); clipboard = data[current]; data[current] = tmClear(); break; case COPYM: clipboard = tmClear(); clipboard = data[current]; break; case PASTEM: if (!tmIsGridEmpty(clipboard)) { data[current] = tmClear(); data[current] = clipboard; } break; } } } if (osl_keys->pressed.start) break; oslEndDrawing(); oslSyncFrame(); } return 69; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Main: /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int main(){ SetupCallbacks(); oslSrand(1); //Init network (for net conf dialog): oslNetInit(); int skip = 0; LedAnimFreq.f=2; const int calx1=-20,calx2=20,caly1=-20,caly2=20; //float fx,fy; float_or_int_t _movW,_movX,_movY,_movZ; DroneSck = oslNetSocketCreate(); DroneUdp = make_udpsocket(AT_PORT); initOSLib(); oslIntraFontInit(INTRAFONT_CACHE_MED); //Loads image: //OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_8888); OSL_IMAGE *bkg = oslLoadImageFileJPG("back1.jpg", OSL_IN_RAM | OSL_SWIZZLED, OSL_PF_5650); OSL_IMAGE *img1 = oslCreateImage (130,130,OSL_IN_RAM,OSL_PF_8BIT); FirePalette (img1,255); oslClearImage (img1,0); //Load font: OSL_FONT *font = oslLoadFontFile("flash0:/font/ltn0.pgf"); oslSetFont(font); while(runningFlag && !osl_quit){ if (!skip){ oslStartDrawing(); oslDrawImageXY(bkg, 0, 0); oslReadKeys(); _movX.f = ((float)osl_pad.analogX/128)*mscale; _movY.f = ((float)osl_pad.analogY/128)*mscale; _movZ.f = 0; _movW.f = 0; if ((osl_pad.analogX > calx1) && (osl_pad.analogX < calx2)) _movX.f = 0; //Deadzone X if ((osl_pad.analogY > caly1) && (osl_pad.analogY < caly2)) _movY.f = 0; //Deadzone Y if (osl_pad.held.triangle) _movZ.f = delta; //Up if (osl_pad.held.cross) _movZ.f = -delta; //Down if (osl_pad.held.L) _movW.f = -delta; //CW if (osl_pad.held.R) _movW.f = delta; //CCW if (_movX.f==0 && _movY.f==0 && _movZ.f==0 && _movW.f==0) Hover=0; else Hover=1; oslDrawStringf(320, 10, "Tic#= %d",AT_SEQ); oslDrawStringf(10, 220, "x= %d y= %d z= %d w= %d !Hvr= %d",osl_pad.analogX,osl_pad.analogY,_movZ.i,_movW.i,Hover); oslDrawStringf(10, 240, "xf= %1.2f yf= %1.2f Scl= %1.2f",_movX.f,_movY.f,mscale); if (Connected==1) GameTic++; if (drawMenu==1) { Menu();} else { if (osl_pad.pressed.up) { //Drone.AddCmd "AT*ANIM=", CStr(Seq) & "," & Anim_Time(Seq) vb anim code snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_AHEAD,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_AHEAD],CR); sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} if (osl_pad.pressed.down) { snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_BEHIND,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_BEHIND],CR); sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} if (osl_pad.pressed.right) { snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_RIGHT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_RIGHT],CR); sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} if (osl_pad.pressed.left) { snprintf(netbuf,1024,"AT*ANIM=%d,%d,%d%c",AT_SEQ++,ARDRONE_ANIM_FLIP_LEFT,MAYDAY_TIMEOUT[ARDRONE_ANIM_FLIP_LEFT],CR); sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} if (osl_pad.pressed.start) { drawMenu=1;} if (osl_pad.pressed.circle){//Take off snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF|512,CR);//TAKE OFF sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} if (osl_pad.pressed.square){//Land snprintf(netbuf,1024,"AT*REF=%d,%d%c",AT_SEQ++,AT_REF,CR); sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} } if (showjoypad) JoyPadGfx(img1); if (showfire) FireFx(img1); if (showjoypad||showfire) oslDrawImageXY(img1, 345, 85); oslEndDrawing(); } if (GameTic >= TicRoof){ GameTic=0; //snprintf(netbuf,1024,"AT*COMWDG=%d%cAT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,CR,AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY snprintf(netbuf,1024,"AT*PCMD=%d,%d,%d,%d,%d,%d%c",AT_SEQ++,Hover,_movX.i,_movY.i,_movZ.i,_movW.i,CR);//XY sendto(DroneUdp, netbuf, strlen(netbuf), 0, (struct sockaddr*)&dest, sizeof(dest));} oslEndFrame(); skip = oslSyncFrame(); } //Quit OSL: oslNetTerm(); oslEndGfx(); oslQuit(); sceKernelExitGame(); return 0; }