void screenshot(s_screen *vscreen, unsigned char *pal, int ingame) { #ifndef DC int shotnum = 0; char shotname[1024] = {""}; char modname[MAX_FILENAME_LEN] = {""}; getPakName(modname, 99); #ifdef PSP if(dirExists("ms0:/PICTURE/", 1) && dirExists("ms0:/PICTURE/Beats Of Rage/", 1)) { #endif do { #if PSP sprintf(shotname, "ms0:/PICTURE/Beats Of Rage/%s - ScreenShot - %02u.png", modname, shotnum); #elif SDL || WII sprintf(shotname, "%s/%s - %04u.png", screenShotsDir, modname, shotnum); #else sprintf(shotname, "./ScreenShots/%s - %04u.png", modname, shotnum); #endif ++shotnum; } while(fileExists(shotname) && shotnum < 10000); #ifdef PSP if(shotnum < 10000) { saveImage(shotname); } #else if(shotnum < 10000) { savepng(shotname, vscreen, pal); } #endif if(ingame) { debug_printf("Saved %s", shotname); } #ifdef PSP } #endif #endif }
int main(int argc, char *argv[]) { #ifndef SKIP_CODE char pakname[256]; #endif #ifdef CUSTOM_SIGNAL_HANDLER struct sigaction sigact; #endif #ifdef DARWIN char resourcePath[PATH_MAX]; CFBundleRef mainBundle; CFURLRef resourcesDirectoryURL; mainBundle = CFBundleGetMainBundle(); resourcesDirectoryURL = CFBundleCopyResourcesDirectoryURL(mainBundle); if(!CFURLGetFileSystemRepresentation(resourcesDirectoryURL, true, (UInt8 *) resourcePath, PATH_MAX)) { borExit(0); } CFRelease(resourcesDirectoryURL); chdir(resourcePath); #elif WII fatInitDefault(); #endif #ifdef CUSTOM_SIGNAL_HANDLER sigact.sa_sigaction = handleFatalSignal; sigact.sa_flags = SA_RESTART | SA_SIGINFO; if(sigaction(SIGSEGV, &sigact, NULL) != 0) { printf("Error setting signal handler for %d (%s)\n", SIGSEGV, strsignal(SIGSEGV)); exit(EXIT_FAILURE); } #endif setSystemRam(); initSDL(); packfile_mode(0); #ifdef ANDROID dirExists(rootDir, 1); chdir(rootDir); #endif dirExists(paksDir, 1); dirExists(savesDir, 1); dirExists(logsDir, 1); dirExists(screenShotsDir, 1); #ifdef ANDROID if(dirExists("/mnt/usbdrive/OpenBOR/Paks", 0)) strcpy(paksDir, "/mnt/usbdrive/OpenBOR/Paks"); else if(dirExists("/usbdrive/OpenBOR/Paks", 0)) strcpy(paksDir, "/usbdrive/OpenBOR/Paks"); else if(dirExists("/mnt/extsdcard/OpenBOR/Paks", 0)) strcpy(paksDir, "/mnt/extsdcard/OpenBOR/Paks"); #endif Menu(); #ifndef SKIP_CODE getPakName(pakname, -1); video_set_window_title(pakname); #endif openborMain(argc, argv); borExit(0); return 0; }
static int setup_touch_txt() { int pos, i, sdid, t; static char filename[256]; static char pakname[256]; char *buf, *command, *value; size_t size; ArgList arglist; char argbuf[MAX_ARG_LEN + 1] = ""; float w = nativeWidth; float h = nativeHeight; float hh = w * 480 / 800; SDL_Surface *ts; char *pngb; size_t pngs; getPakName(pakname, -1); sprintf(filename, "/mnt/sdcard/OpenBOR/Saves/%s", pakname); dirExists(filename, 1); sprintf(filename, "/mnt/sdcard/OpenBOR/Saves/%s/touch.txt", pakname); // Read file if( buffer_pakfile(filename, &buf, &size) != 1 && buffer_pakfile("data/touch.txt", &buf, &size) != 1 && buffer_pakfile("/mnt/sdcard/OpenBOR/Saves/touch.txt", &buf, &size) != 1) { return 0; } // Now interpret the contents of buf line by line pos = 0; while(pos < size) { if(ParseArgs(&arglist, buf + pos, argbuf)) { command = GET_ARG(0); if(command && command[0]) { if(stricmp(command, "button") == 0) { sdid = translate_SDID(GET_ARG(1)); if(sdid >= 0) { bx[sdid] = GET_FLOAT_ARG(2) * hh; by[sdid] = GET_FLOAT_ARG(3) * hh; br[sdid] = GET_FLOAT_ARG(4) * hh; t = GET_INT_ARG(5); /* corners: 0 1 3 2 */ if(t == 1 || t == 2) { bx[sdid] = w - bx[sdid]; } if(t == 2 || t == 3) { by[sdid] = h - by[sdid]; } } } else if(stricmp(command, "texture") == 0) { if(buffer_pakfile(GET_ARG(1), &pngb, &pngs)) { ts = pngToSurface(pngb); if(!ts || !(buttons = SDL_CreateTextureFromSurface(renderer, ts))) { printf("error: %s\n", SDL_GetError()); } if(ts) { SDL_FreeSurface(ts); } if(pngb) { free(pngb); } } } else if(stricmp(command, "screendocking") == 0) // change screen position to avoid buttons { screendocking = 0; for(i = 1; ; i++) { value = GET_ARG(i); if(!value || !value[0]) { break; } if(stricmp(value, "left") == 0) { screendocking |= DOCKLEFT; } else if(stricmp(value, "right") == 0) { screendocking |= DOCKRIGHT; } else if(stricmp(value, "top") == 0) { screendocking |= DOCKTOP; } else if(stricmp(value, "bottom") == 0) { screendocking |= DOCKBOTTOM; } else { screendocking = GET_INT_ARG(i); } } } } } // Go to next line pos += getNewLineStart(buf + pos); } if(buf != NULL) { free(buf); buf = NULL; } return 1; }