ELF(4hR4 ( pN444444OOOOOp OOO  PPPDDQtd/lib/ld-linux-armhf.so.3GNUGNUr!'ifes=+%:-!"1* ,4%$9 )(+#3 /&. 0'58 726% D PB!0ĚLA"@(Ab 4A&  "$%')+./02458]AE6ZU}s4܍}0`+k[˧x| O[1/N=||Fu)2u. ʡ2>XyC+>~|@QlAI얩ڑu z?Y~AZ+ʖ%ʠHqX|! &vU _ޓK?ժ?BE췓4q{|WvT<  :to7#reX0XCQ=(to{ JibwQtoQ^6rEQNto4 Q"libSDL-1.2.so.0__gmon_start___Jv_RegisterClasses_init_finilibSDL_image-1.2.so.0libSGE.so.0SDL_FreeSurfaceSDL_QuitSDL_PollEventSDL_GetMouseStateIMG_LoadSDL_DisplayFormatSDL_MapRGBSDL_SetColorKeySDL_GetErrorSDL_UpperBlitSDL_SetPalettesge_GetPixelsge_PutPixelSDL_FillRectSDL_CreateRGBSurfacesge_transformSDL_FlipSDL_DelaySDL_SetVideoModeSDL_InitSDL_GetVideoInfoSDL_WM_SetCaptionlibstdc++.so.6_Znwjlibm.so.6libgcc_s.so.1__aeabi_unwind_cpp_pr0__aeabi_unwind_cpp_pr1libc.so.6strcpysprintf_IO_putcsrandfopenputstimeputcharabortstrtolfseekstdoutmemcpyfclosefreadstrcmp__libc_start_mainbasename__cxa_atexit_edata__bss_start__bss_start____bss_end____end___endGCC_3.5GLIBC_2.4GLIBCXX_3.4 U&y  ii t)PQ@PDPHP/LP0PP.TPXP'\P`P dP5hPlP pPtP3xP|P PPP"P%P#PPPP&P+PPPPP$P9P P!P*P,P4P-PPP1PPP @-&-|Ə ʌ|Ə ʌtƏ ʌlƏ ʌdƏ ʌ\Ə ʌTƏ ʌLƏ ʌDƏ ʌ<Ə ʌ4Ə ʌ,Ə ʌ$Ə ʌƏ ʌƏ ʌ Ə ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌƏ ʌ|Ə ʌtƏ ʌlƏ ʌdƏ ʌ\Ə ʌTƏ ʌLƏ ʌDƏ ʌ<Ə ʌ4Ə ʌ,Ə ʌ$PO-p MP[@P PV |P0N zxvtrpnljh|cxdtbp`l^h\dZ`X\VXTTRPP WF<P ,P P P . @f(00T  {P uP6 kP fPt6 d]P TXP0I0 8P4P J P6 C P6 <PJ 6P5 /PL )P@T 5Pd   dP|5xP@T  P5P P 05P0CƷP@T  XP@T  PP@T  t4 PL@T lK@CB tnpllj: 4f0d,bH` ^XU _ TRPNLJHFDB:P Px0+p,'Y0 @FB000B0d420S 0SM @( p2`0S d4So4S Pؖ||||Ė\40\4 Pb  L $H10S) ~7 ,`Ht @t Hl Q0<HTXdpx(Ph|TQ 0Ly`@h$ , 0\,T<`|<Px8@- \0\@P@ C΂ P  S4.R0 ==0=8L#0lm>  --- 0]t̏0 00S/U0 R  /Q @-0S0S3/OA-H1H0SH0SE0ApDPDnP pTA`P a^U@PP 00 P 0 - P 0 - P |0 -`00ST00S<00S000S4A,$QP#lm0>ؾľd@- \\0    S 00 < 0 jPQ! Q@-M@ 0(00,0VP 00C SL <<<<<<<D 0pS 0 :  Ѝ0 0 @ JpS D0@Q H 0 S0 S0Q8@-rPP E@P@ 1 0 C8404 R@T @8Qp@-@P P 0=B`P @P@ 0   Mp@ l@l00S0S= H0=400S $p@0Sp0Qp@-PhA P 0=`P. PPP 0  ]Q  4Sp `P ` -0PPpp@qP00S0S= ypd0=\00S oHZ4Sp0S4Sp0Q>>`o,@-MMqr s0@@ @ @ 0\̠ 0XЍۍ@-Pa0E@PY 0CSܢĢXK0 p  Mq/UE P` 020 P 40[@ 00 p q 0 0 0 #D0T R  2P R PÖQ//G-p0lpq  \`\ 0S@yPt0  0@S SS0Qp@-q0@p` Pvu 0 p@0O--dUdEM  \4 SD5D5Pp0 5 - 50Sp 5%0Sk =z 0j*:j zz ,hD@ 0j抴f^z('zhzz*~P. h몯੟` T0 % 0  ]~| 0H  HD mT S3  00S=S  0/?ਏ0Ȁcx3 pbp0e`#<3 R P#z0:0zS'=Ƞ 0*:, 0zz$ z'zgzzZY  P 몯੟ʠɐzy` 0  0   0H  ~ H m 10S!p0 0 P q` p-1`⾀P@p1p0<Q`A  ` `p@@-8-(1`tP FbЍ R  R *0SNJa z+S>\ 0K661C.80ਏ= 0/?,5\ \B0Qpxho>>`o>,p0-@I@dAU^ P@\P@2^P@_P@0 @ 0 @$0 @ 1 A  @  @J K  S 0 d <0 P0 4  8  &@  E F  H 0\0L$T$ 0X$ 0\$ 0`$ 0d$ 0 0/Qp!h@-T0T R H Q8 Q$ 0Sd0Q@- \@\002H0 J 0S80 0S0 0 @cQp0Կ@- \@\002|H0 J 0S80 0S0 0 @CQx0A- YPTdA0SpPPqQ@Q 0 0 410S0SA#! GdV0 p0260J`0S 0S 00 P 2T0dp 0J S 0S H08Qpt4Tx0`Կp@-@  P `P ` -0PP |`P ` `-\0PP p@(0>>`o,@-0@0S00S p 0Sp0=S d@}\@zT00dSH00S <00S0SQ00= W0@-0= 0@K0@-@M0@0 p00Sd00S X0H P 0~ @W@Ѝ40 0 0s0QT@-tA\$d4RW dQ P 00= P *81 -\$aFZpP% -`P` 0  + m& \0 `R  B d00S0S= \ <0R - \$<5F Q0 0$ r 3H /Q8@-A4S84S7 1 Q02p1 J 0S 0S @1H0 81 !0S (dQ! R! R$ p+ 0S8=S* 8@l0 P020 J 0S 0S 00 QX  dRS D00Ss0S888@AQx0pԿ@-M;0D |0(00,0(P 00C SĶص 0pS#0 :  3#0S #0 0V 0Ѝx30SlPP`#L3Q-P# R7D# R38PB  PH \4S"0C\4 0 :pR"4S0H0H0S SLP$R HH $0RT"0P"0 ,"H0,"00 "Q QH R $RHPb!1QS!1Q ! R!1 @P B 8` Rd \1F D!0Q ! R !1 P  `2Rd 0F $p0R8L$RPP0 ` p    p 3K Qp@-M8A81P`   R0(00,0P$ 00C S#0S# S0 S Ѝp 0pS0 :  0S 0 0 :pR4S0H0H0 0Q Q@- @4S8 `4EF0= 0`FP00S00S p 0S T0=SXXL00dS@00S 400SQ08@-@TUL4S P4SP4< 8aQ@@P804 S 4 0@0888EQ(L0\d$Q /8  R /( R\` /Qhl'Xt0@- MpP5@P ` XP 0GP[ Ѝ0 |PQE-`HPHP epJ@0 @3/ Tؐܐ/0 0 R ꬑ@-info: Cleaning Up...info: Free Imagesinfo: ...Done Cleaning Up Thank You for using sdlSlideimage: %s background: %s BlitSurface error: %s defaultFont.pngCouldn't load game font! (%s) Exitting. CreateRGBSurface failed: %s info: scaling image %f:1 info: image is centeredinfo: set %dx%dx16 video mode info: set %dx%d window mode Couldn't initialize SDL: %s info: probing video for W x HsdlSlideerror: Couldn't set video mode: %s info: video output disabledinfo: image is scaledinfo: image is not scaled%dx%d%s: %dx%d %s (%dx%d)%s - %d%%%s - %d:1info: failed loading: %s sdlSlide.timeTaken=%d sdlSlide.totalTime=%d sdlSlide (one-file) v%s 1.2.3rberror: cant open '%s' --version-v--helpCopyright 2016 MiNTed Games View graphics files, using SDL v1.2. usage: sdlSlide-1f [_option_] []_option_: --1f one-file (1f) source information --background instead of black screen --slideshow Slideshow images list (with options) then exit --delay Delay between slides seconds (number keys, default 4) --repeat Show images list times --center Show image centered (C key) --zoom Set zoom to %% (same as below) (default 100, +/- keys) --pixels Pixels size or skip (-) pixels, (default 1, +/- keys) --fullscreen Set window to fullscreen (F11 key) --fit Scale and Center image to fit page --format Display file information (no shows all formats) --novideo Dont display images (use with verbose) --size Only output size (no image) --help This help information -v|--version Version information -V|--verbose Verbose output --debug Extra verbose output special thanks to: www.parallelrealities.co.uk-1f--1fCopyright 2016 MiNTed Gamesone-file (1f) source information. usage: sdlSlide-1f _option_ --src|--source output attached one-file (1f) source file --src-size size of appended source (in bytes) (%d) --src-type type of source appended (TXT/ZIP) (%s) To save one-file (1f) source to file use one of the following: sdlSlide-1f --src > sdlSlide-1f.cpp sdlSlide-1f --src > sdlSlide-1f`sdlSlide-1f --src-type`To verify one-file (1f) source file size: sdlSlide-1f --src-size (match this to the size in a directory listing)or use:NAME=sdlSlide; if [ `ls -l $NAME-1f.cpp|cut -d \ -f 5` = `./$NAME-1f --src-size` ]; then echo Verified; else echo Failed; fione-file (1f) options exit with status: 31 successful (0x1f) 32 an error occured (0x20)--source--src--src-type--src-size%d--format--formats--verbose-V--novideo---no-video--debug--size--center--fullscreen--fit--slideshow--zoomerror: --zoom needs a number--pixelserror: --pixels needs a number--fpserror: --fps needs a number--delayerror: --delay needs a number--repeaterror: --repeat needs a number--backgrounderror: --repeat needs a filename[15] image formats: .ICO Microsoft Icon format .CUR Microsoft Cursor format .BMP Microsoft Bit Map image .GIF Graphics Interchange Format .JPG JPEG encoded graphic image (lossy) .JPEG JPEG encoded graphic image (lossy) .ILBM InterLeaved BitMap image (IFF containers) .LBM InterLeaved BitMap image (IFF containers) .PCX PC Paintbrush eXtended graphic .PNG Portable Network Graphic .PNM Portable Network M .TIF 32bit Image File Format .TIFF 32bit Image File Format .XCF GIMP image .XBM X Windows mono Bit Map image (ASCII) .XPM X Windows color Pixel Map image (ASCII) .XV X Windows .WEBP Cell/Mobile phone Web graphic ICO CUR BMP GIF JPG JPEG ILBM LBM PCX PNG PNM TIF TIFF XCF XBM XPM XV WEBPerror: --size needs at least one filelxD<L l(d@V O OopЄ  4P`<,őooVOPGCC: (Debian 4.6.3-14+rpi1) 4.6.3A.aeabi$6  ,.symtab.strtab.shstrtab.interp.note.ABI-tag.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.text.fini.rodata.ARM.extab.ARM.exidx.eh_frame.init_array.fini_array.jcr.dynamic.got.data.bss.comment.ARM.attributes44#PP 1pp$HDoN ЄVpp^oVV tkő `z ,,  B<< `   $̏.>>DM$pNOOO O OOOOO 4P4PPPQQt0Q"p"Q/QQhW` gA4PpЄpV̋ , <   ̏O OOO4PPQJPMJ J4JJPPM@@J\M MM MMJJ M(JJMJM JMJLMXJPMdJܠMJMJM JMJ,M0JMJMJ M JMJ M JMԮJMԯJMJMİJMJMJ<MXJpMtJ MXJMصJMJTMJ4MDJ@MhJMJdMpJ|MJM̏JMJԗJMJJOJJQ%OJPMd2dJ|HQJ OW OM~JJOOJQMJlMtMxJJJOOPO OO4PM J M )<IXajxvԮQP XX ̏ #to+(; Kİ0Zjwx(to$2DtoOXj { #hLdX!ԯ5`E Kd^ rthQD$PtoD$9GYQe0x`Q %Q.@Pprlt X  D1p/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o$d$a/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.ocall_gmon_start/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crtn.osdlSlide-1f.cpp_GLOBAL__sub_I_sdlSlidecrtstuff.c__JCR_LIST____do_global_dtors_auxcompleted.5637__do_global_dtors_aux_fini_array_entryframe_dummy__frame_dummy_init_array_entryelf-init.oSatexit.oS__FRAME_END____JCR_END____dso_handle_DYNAMIC__init_array_end__init_array_start_GLOBAL_OFFSET_TABLE__Znwj@@GLIBCXX_3.4SDL_FillRect_Z9loadImagePcSDL_QuitSDL_Flip_Z7cleanUpv_Z12redrawNormalv_edatastrtol@@GLIBC_2.4fseek@@GLIBC_2.4data_start_IO_stdin_used_Z10slidePausev_Z14loadBackgroundPcSDL_MapRGBmainexit@@GLIBC_2.4printf@@GLIBC_2.4__end___Z10flushInputv_Z10initSystemv_Z9imageInfoPcputs@@GLIBC_2.4_Z8initVarsvSDL_PollEvent_Z12getUserInputv_Z14setVideoWindowv_IO_putc@@GLIBC_2.4putchar@@GLIBC_2.4atexitSDL_Delay_finiSDL_GetError__bss_end__fopen@@GLIBC_2.4abort@@GLIBC_2.4SDL_UpperBlit_Z11updateTitlePc_bss_end__SDL_Initstrcpy@@GLIBC_2.4_Z11setVideoMaxvSDL_FreeSurfaceSDL_SetVideoModeSDL_SetPalettegraphicsSDL_WM_SetCaption_startsge_GetPixelSDL_DisplayFormat_Z12scalePixelUpiifread@@GLIBC_2.4_Z11togglePausev_Z14sdlUpdateVideov_Z10showRepeatv_init_Z12loadCurImagePc_Jv_RegisterClasses__cxa_atexit@@GLIBC_2.4SDL_GetVideoInfo_Z16toggleFullScreenvSDL_SetColorKeybasename@@GLIBC_2.4_Z10slideDelayv__bss_start___Z9slideShowv__data_start_end_Z9copyPixeliiiiSDL_CreateRGBSurfacesge_transformmemcpy@@GLIBC_2.4__bss_start_Z13redrawComplexv__libc_csu_init_Z12getImageFilevfclose@@GLIBC_2.4sprintf@@GLIBC_2.4_Z9output_1fPc__aeabi_unwind_cpp_pr1@@GCC_3.5SDL_GetMouseStatestdout@@GLIBC_2.4_Z13sdlSlide_InitvsdlSlidestrcmp@@GLIBC_2.4time@@GLIBC_2.4_Z12setFontColorP11SDL_Surfaceiii_Z8loadFontvIMG_Load__libc_csu_fini__aeabi_unwind_cpp_pr0@@GCC_3.5_Z9imageSizev_Z9checkKeysvsge_PutPixel__libc_start_main@@GLIBC_2.4__gmon_start__srand@@GLIBC_2.4_Z10isOnScreeniiii_Z10version_1fv/* sdlSlide-1f one-file (1f) image viewer (SDL 1.2 image & SGE) Copyright (C) 2016 MiNTed Games All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* one-file (-1f) compile g++ `sdl-config --cflags` -Wall -O3 -DVERSION=\"1.2.3\" `sdl-config --libs` -lSDL_image -lSGE -o sdlSlide-1f sdlSlide-1f.cpp ; \ g++ `sdl-config --cflags` -Wall -O3 -DVERSION=\"1.2.3\" -DPRG_SIZE=`ls -l sdlSlide-1f|cut -d \ -f 5` -DSRC_SIZE=`ls -l sdlSlide-1f.cpp|cut -d \ -f 5` `sdl-config --libs` -lSDL_image -lSGE -o sdlSlide-1f sdlSlide-1f.cpp ; \ cat sdlSlide-1f.cpp >> sdlSlide-1f */ /* one-file (-1f) requires libsdl1.2-dev libsdl-image-dev libsdl-sge-dev */ /* one-file (1f) headers */ #include #include #include #include #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "SDL/sge.h" /* one-file source appendage */ #define NO_SIZE 45678 //#define SRC_TYPE ".zip" // if its a ZIP appendage #define SRC_TYPE ".cpp" // if its a TEXT appendage, name the extention #ifndef PRG_SIZE //#define PRG_SIZE 27142 // last checked binary size was ... #define PRG_SIZE NO_SIZE // .. this should be close to actual #endif #ifndef SRC_SIZE // size of 1 text file or 1 zip file //#define SRC_SIZE 44921 // last checked source size was ... #define SRC_SIZE NO_SIZE // .. affects binary size if too small #endif const long offset_1f = PRG_SIZE; // this has never been accurate (EXT4) const long sizeOf_1f = SRC_SIZE; // we use this (-sizeOf_1f) as offset /* one-file (1f) start */ /* one-file (1f) defines */ #define SCREEN_WIDTH 1360 // these are actually dynamic #define SCREEN_HEIGHT 768 #define WINDOW_WIDTH 800 // size when not --fullscreen (ie. windowed) #define WINDOW_HEIGHT 600 #define LINUX 1 #define MAX_TEXTSHAPES 70 #define MAX_FONTSHAPES 6 #define MAX_SHAPES 100 /* one-file (1f) enums */ // Font Colors enum { FONT_WHITE, FONT_RED, FONT_YELLOW, FONT_GREEN, FONT_CYAN, FONT_OUTLINE // a dark blue color }; /* one-file (1f) structs */ typedef struct sdlSlideEngineVariables { signed char debug; SDL_Event event; signed char done; SDL_RWops *sdlrw; float ssx; float ssy; int cursor_x, cursor_y; int eventTimer; int totalTime; int startTime; int stopTime; int timeTaken; // In seconds signed char timePlayed; signed char seconds; signed char minutes; signed char hours; signed char paused; signed char useVideo; signed char fullscreen; signed char useBackground; char background[1024]; signed char slideshow; int delay; int delayCount; int fps; int next; int current; int playlist; char playList[50][1024]; int repeat; int repeatCount; int display_w; int display_h; int window_w; int window_h; int ox; int oy; int ow; int oh; signed char oneIn; signed char center; signed char useZoom; int zoom; signed char useScale; int scale; signed char doFit; signed char fitPage; signed char info; signed char showFormat; signed char showSize; // This really only applies to Linux users. char userHomeDirectory[1024]; char keyState[350]; signed char section; }; sdlSlideEngineVariables sdlSlide; typedef struct bRect { int x, y, w, h; bRect *next; } bRect; typedef struct textObject { SDL_Surface *image; unsigned char life; float x, y; signed char fontColor; char text[255]; }; /* one-file (1f) classes */ class sdlSlideGraphics { public: Uint32 red; Uint32 darkRed; Uint32 yellow; Uint32 darkYellow; Uint32 green; Uint32 darkGreen; Uint32 blue; Uint32 darkBlue; Uint32 darkerBlue; Uint32 black; Uint32 white; Uint32 lightGrey; Uint32 darkGrey; SDL_Surface *screen, *background; SDL_Surface *cur_image, *scale_image; SDL_Surface *shape[MAX_SHAPES]; SDL_Surface *fontShape[MAX_FONTSHAPES]; bRect *bufferHead; bRect *bufferTail; textObject textShape[MAX_TEXTSHAPES]; SDL_Rect blitRect; SDL_Rect scale_rect; SDL_Surface *messageBox; sdlSlideGraphics() { bufferHead = new bRect; bufferHead->next = NULL; bufferTail = bufferHead; for (int i = 0 ; i < MAX_SHAPES ; i++) shape[i] = NULL; for (int i = 0 ; i < MAX_TEXTSHAPES ; i++) textShape[i].image = NULL; messageBox = NULL; background = NULL; cur_image = NULL; scale_image = NULL; } SDL_Surface *setTransparent(SDL_Surface *sprite) { SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(sprite->format, 0, 0, 0)); return sprite; } void addBuffer(int x, int y, int w, int h) { bRect *rect = new bRect; rect->next = NULL; rect->x = x; rect->y = y; rect->w = w; rect->h = h; bufferTail->next = rect; bufferTail = rect; } void blit(SDL_Surface *image, int x, int y, SDL_Surface *dest) { // Set up a rectangle to draw to blitRect.x = x; blitRect.y = y; blitRect.w = image->w; blitRect.h = image->h; /* Blit onto the screen surface */ if(SDL_BlitSurface(image, NULL, dest, &blitRect) < 0) { printf("BlitSurface error: %s\n", SDL_GetError()); } // addBuffer(blitRect.x, blitRect.y, blitRect.w, blitRect.h); } void blit(SDL_Surface *image, int x, int y) { blit(image, x, y, screen); } void blitText(int i) { blit(textShape[i].image, (int)textShape[i].x, (int)textShape[i].y, screen); } void flushBuffer() { bRect *prevRect = bufferHead; bRect *rect = bufferHead; bufferTail = bufferHead; while (rect->next != NULL) { rect = rect->next; prevRect->next = rect->next; delete rect; rect = prevRect; } bufferHead->next = NULL; } void unBuffer() { bRect *prevRect = bufferHead; bRect *rect = bufferHead; bufferTail = bufferHead; while (rect->next != NULL) { rect = rect->next; blitRect.x = rect->x; blitRect.y = rect->y; blitRect.w = rect->w; blitRect.h = rect->h; if (SDL_BlitSurface(background, &blitRect, screen, &blitRect) < 0) { printf("BlitSurface error: %s\n", SDL_GetError()); } prevRect->next = rect->next; delete rect; rect = prevRect; } bufferHead->next = NULL; } /* In 16 bit mode this is slow. VERY slow. Don't write directly to a surface that constantly needs updating (eg - the main game screen) */ int renderString(char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest) { SDL_Rect area; area.x = x; area.y = y; area.w = 8; area.h = 14; SDL_Rect letter; letter.y = 0; letter.w = 8; letter.h = 14; while (*in != '\0') { if (*in != 32) { letter.x = (*in - 33); letter.x *= 8; letter.x--; // Temp fix /* Blit onto the screen surface */ if(SDL_BlitSurface(fontShape[fontColor], &letter, dest, &area) < 0) { printf("BlitSurface error: %s\n", SDL_GetError()); } } area.x += 9; if (wrap) { if ((area.x > (dest->w - 70)) && (*in == 32)) { area.y += 16; area.x = x; } } *in++; } return area.y; } int drawString(char *in, int x, int y, int fontColor, signed char wrap, SDL_Surface *dest) { renderString(in, x, y - 1, FONT_OUTLINE, wrap, dest); renderString(in, x, y + 1, FONT_OUTLINE, wrap, dest); renderString(in, x, y + 2, FONT_OUTLINE, wrap, dest); renderString(in, x - 1, y, FONT_OUTLINE, wrap, dest); renderString(in, x - 2, y, FONT_OUTLINE, wrap, dest); renderString(in, x + 1, y, FONT_OUTLINE, wrap, dest); return renderString(in, x, y, fontColor, wrap, dest); } int drawString(char *in, int x, int y, int fontColor, SDL_Surface *dest) { if (x == -1) x = (dest->w - (strlen(in) * 9)) / 2; return drawString(in, x, y, fontColor, 0, dest); } int drawString(char *in, int x, int y, int fontColor) { if (x == -1) x = (800 - (strlen(in) * 9)) / 2; return drawString(in, x, y, fontColor, 0, screen); } /* Finds the location of the requested color within the palette and returns it's number. This colors are used for drawing rectangles, circle, etc in the correct colors. */ void setColorIndexes() { red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00); darkRed = SDL_MapRGB(screen->format, 0x66, 0x00, 0x00); yellow = SDL_MapRGB(screen->format, 0xff, 0xff, 0x00); darkYellow = SDL_MapRGB(screen->format, 0x66, 0x66, 0x00); green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00); darkGreen = SDL_MapRGB(screen->format, 0x00, 0x66, 0x00); blue = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff); darkBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x99); darkerBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x44); black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); white = SDL_MapRGB(screen->format, 0xff, 0xff, 0xff); lightGrey = SDL_MapRGB(screen->format, 0xcc, 0xcc, 0xcc); darkGrey = SDL_MapRGB(screen->format, 0x99, 0x99, 0x99); } /* Draws the background surface that has been loaded */ void drawBackGround() { blit(background, 0, 0, screen); } void drawCurImage() { blit(cur_image, 0, 0, screen); } void clearScreen(Uint32 color) { SDL_FillRect(screen, NULL, color); } void updateScreen() { SDL_Flip(screen); // Give the audio (and possibly the X server) time to work SDL_Delay(1); } /* * get the pixel at (x, y) to the given value */ /* Uint32 getpixel(SDL_Surface *surface, int x, int y) { // Uint32 pixel; unsigned char pixel[4]; int bpp = surface->format->BytesPerPixel; // Here p is the address to the pixel we want to set Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { switch(bpp) { case 1: pixel[0] = p; break; case 2: pixel[0] = (p[0] >> 8) & 0xff; pixel[1] = p[1] & 0xff; break; case 3: pixel[0] = (p[0] >> 16) & 0xff; pixel[1] = (p[1] >> 8) & 0xff; pixel[2] = p[2] & 0xff; break; case 4: pixel = p; break; } }else{ switch(bpp) { case 1: pixel[0] = p; break; case 2: pixel[0] = p[0] & 0xff; pixel[1] = (p[1] >> 8) & 0xff; break; case 3: pixel[0] = p[0] & 0xff; pixel[1] = (p[1] >> 8) & 0xff; pixel[2] = (p[2] >> 16) & 0xff; break; case 4: pixel = p; break; } } return(pixel); } */ /* * Set the pixel at (x, y) to the given value * NOTE: The surface must be locked before calling this! */ void putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel) { int bpp = surface->format->BytesPerPixel; /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; switch(bpp) { case 1: *p = pixel; break; case 2: *(Uint16 *)p = pixel; break; case 3: if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { p[0] = (pixel >> 16) & 0xff; p[1] = (pixel >> 8) & 0xff; p[2] = pixel & 0xff; } else { p[0] = pixel & 0xff; p[1] = (pixel >> 8) & 0xff; p[2] = (pixel >> 16) & 0xff; } break; case 4: *(Uint32 *)p = pixel; break; } } void drawLine(SDL_Surface *dest, int x1, int y1, int x2, int y2, int col) { int counter = 0; if ( SDL_MUSTLOCK(dest) ) { if ( SDL_LockSurface(dest) < 0 ) { printf("Can't lock screen: %s\n", SDL_GetError()); } } while(1) { putpixel(dest, x1, y1, col); if (x1 > x2) x1--; if (x1 < x2) x1++; if (y1 > y2) y1--; if (y1 < y2) y1++; if ((x1 == x2) && (y1 == y2)) {break;} if (counter == 1000) {printf("Loop Error!\n"); break;} counter++; } if ( SDL_MUSTLOCK(dest) ) { SDL_UnlockSurface(dest); } } void drawLine(int x1, int y1, int x2, int y2, int col) { drawLine(screen, x1, y1, x2, y2, col); } /* A quick(?) circle draw function. This code was posted to the SDL mailing list... I didn't write it myself. */ void circle(int xc, int yc, int R, SDL_Surface *PIX, int col) { int x = 0, xx = 0; int y = R, yy = R+R; int p = 1-R; putpixel(PIX, xc, yc - y, col); putpixel(PIX, xc, yc + y, col); putpixel(PIX, xc - y, yc, col); putpixel(PIX, xc + y, yc, col); while(x < y) { xx += 2; ++x; if (p >= 0) { yy -= 2; --y; p -= yy; } p += xx + 1; putpixel(PIX, xc - x, yc - y, col); putpixel(PIX, xc + x, yc - y, col); putpixel(PIX, xc - x, yc + y, col); putpixel(PIX, xc + x, yc + y, col); putpixel(PIX, xc - y, yc - x, col); putpixel(PIX, xc + y, yc - x, col); putpixel(PIX, xc - y, yc + x, col); putpixel(PIX, xc + y, yc + x, col); } if ((x = y)) { putpixel(PIX, xc - x, yc - y, col); putpixel(PIX, xc + x, yc - y, col); putpixel(PIX, xc - x, yc + y, col); putpixel(PIX, xc + x, yc + y, col); } } void blevelRect(SDL_Surface *dest, int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue) { SDL_Rect r = {x, y, w, h}; SDL_FillRect(dest, &r, SDL_MapRGB(screen->format, red, green, blue)); drawLine(dest, x, y, x + w, y, SDL_MapRGB(screen->format, 255, 255, 255)); drawLine(dest, x, y, x, y + h, SDL_MapRGB(screen->format, 255, 255, 255)); drawLine(dest, x, y + h, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128)); drawLine(dest, x + w, y + 1, x + w, y + h, SDL_MapRGB(screen->format, 128, 128, 128)); } void blevelRect(int x, int y, int w, int h, Uint8 red, Uint8 green, Uint8 blue) { blevelRect(screen, x, y, w, h, red, green, blue); } SDL_Surface *createSurface(int width, int height) { SDL_Surface *surface, *newImage; Uint32 rmask, gmask, bmask, amask; /* SDL interprets each pixel as a 32-bit number, so our masks must depend on the endianness (byte order) of the machine */ #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; #else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; #endif surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, rmask, gmask, bmask, amask); if (surface == NULL) { printf("CreateRGBSurface failed: %s\n", SDL_GetError()); } newImage = SDL_DisplayFormat(surface); SDL_FreeSurface(surface); return newImage; } SDL_Surface *textSurface(char *inString, int color) { SDL_Surface *surface = createSurface(strlen(inString) * 9, 16); drawString(inString, 1, 1, color, surface); return setTransparent(surface); } void textSurface(int index, char *inString, int x, int y, int fontColor) { strcpy(textShape[index].text, inString); textShape[index].x = x; textShape[index].y = y; textShape[index].fontColor = fontColor; if (textShape[index].image != NULL) { SDL_FreeSurface(textShape[index].image); } textShape[index].image = textSurface(inString, fontColor); if (x == -1) textShape[index].x = (800 - textShape[index].image->w) / 2; } SDL_Surface *alphaRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue) { SDL_Surface *surface = createSurface(width, height); SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue)); SDL_SetAlpha(surface, SDL_SRCALPHA|SDL_RLEACCEL, 128); return surface; } SDL_Surface *transparentRect(int width, int height, Uint8 red, Uint8 green, Uint8 blue) { SDL_Surface *surface = createSurface(width, height); SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, red, green, blue)); SDL_SetColorKey(surface, (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(surface->format, red, green, blue)); // SDL_SetColorKey(surface, (SDL_SRCCOLORKEY|SDL_RLEACCEL), sge_GetPixel(bitmap,0,0)); return surface; } void createMessageBox(SDL_Surface *face, char *message, signed char transparent) { if (messageBox != NULL) { SDL_FreeSurface(messageBox); messageBox = NULL; } if (transparent) messageBox = alphaRect(550, 60, 0x00, 0x00, 0x00); else messageBox = createSurface(550, 60); signed char x = 60; if (face != NULL) { blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0xaa); blit(face, 5, 5, messageBox); } else { blevelRect(messageBox, 0, 0, messageBox->w - 1, messageBox->h - 1, 0x00, 0x00, 0x00); x = 10; } drawString(message, x, 5, FONT_WHITE, 1, messageBox); } void freeGraphics() { for (int i = 0 ; i < MAX_SHAPES ; i++) { if (shape[i] != NULL) { SDL_FreeSurface(shape[i]); shape[i] = NULL; } } for (int i = 0 ; i < MAX_TEXTSHAPES ; i++) { if (textShape[i].image != NULL) { SDL_FreeSurface(textShape[i].image); textShape[i].image = NULL; } } if (messageBox != NULL) { SDL_FreeSurface(messageBox); messageBox = NULL; } if (background != NULL) { SDL_FreeSurface(background); background = NULL; } if (cur_image != NULL) { SDL_FreeSurface(cur_image); cur_image = NULL; } if (scale_image != NULL) { SDL_FreeSurface(scale_image); scale_image = NULL; } } }; sdlSlideGraphics graphics; /* one-file (1f) functions */ /* key handling */ void flushInput() { for (int i = 0 ; i < 350 ; i++) sdlSlide.keyState[i] = 0; while (SDL_PollEvent(&sdlSlide.event)){} } void getUserInput() { // Get the current mouse position int x, y; SDL_GetMouseState(&x, &y); sdlSlide.cursor_x = x; sdlSlide.cursor_y = y; if (SDL_PollEvent(&sdlSlide.event)) { switch (sdlSlide.event.type) { case SDL_QUIT: exit(0); break; case SDL_MOUSEBUTTONDOWN: if (sdlSlide.event.button.button == SDL_BUTTON_LEFT) sdlSlide.keyState[SDLK_SPACE] = 1; if (sdlSlide.event.button.button == SDL_BUTTON_RIGHT) sdlSlide.keyState[SDLK_ESCAPE] = 1; break; case SDL_KEYDOWN: sdlSlide.keyState[sdlSlide.event.key.keysym.sym] = 1; if (sdlSlide.event.key.keysym.sym == SDLK_p) { if (sdlSlide.paused) sdlSlide.paused = 0; else sdlSlide.paused = 1; } break; case SDL_KEYUP: if (sdlSlide.event.key.keysym.sym != SDLK_p) sdlSlide.keyState[sdlSlide.event.key.keysym.sym] = 0; break; default: break; } } } /* This bit is just for Linux users. It attempts to get the user's home directory, then creates the .parallelrealities and .parallelrealities/starfighter directories so that saves and temporary data files can be written there. Good, eh? :) */ /* #if LINUX void setupUserHomeDirectory() { char *userHome; char *name = getlogin(); passwd *pass; if (name != NULL) pass = getpwnam(name); else pass = getpwuid(geteuid()); if (pass == NULL) { printf("Couldn't determine the user home directory. Exitting.\n"); exit(1); } userHome = pass->pw_dir; char dir[PATH_MAX]; strcpy(dir, ""); sprintf(dir, "%s/.parallelrealities", userHome); if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST)) showErrorAndExit(2, dir); sprintf(dir, "%s/.1f/sdlSlide", userHome); if ((mkdir(dir, S_IRWXU|S_IRWXG|S_IROTH|S_IXOTH) != 0) && (errno != EEXIST)) showErrorAndExit(2, dir); sprintf(sdlSlide.userHomeDirectory, "%s/.1f/sdlSlide/", userHome); } #endif */ /* image handling */ SDL_Surface *loadImage(char *filename) { SDL_Surface *image, *newImage; image = IMG_Load(filename); if (image == NULL) { if (sdlSlide.info || sdlSlide.debug) printf("image: %s\n", SDL_GetError()); return NULL; } newImage = SDL_DisplayFormat(image); if ( newImage ) { SDL_FreeSurface(image); } else { // This happens when we are loading the window icon image newImage = image; } return graphics.setTransparent(newImage); } void loadBackground(char *filename) { if (graphics.background != NULL) { SDL_FreeSurface(graphics.background); graphics.background = NULL; } graphics.background = loadImage(filename); if (graphics.background == NULL) { if (sdlSlide.info || sdlSlide.debug) printf("background: %s\n", SDL_GetError()); }else SDL_SetColorKey(graphics.background, 0, 0); // if (sdlSlide.useVideo) // graphics.drawBackGround(); } void loadCurImage(char *filename) { if (graphics.cur_image != NULL) { SDL_FreeSurface(graphics.cur_image); graphics.cur_image = NULL; } graphics.cur_image = loadImage(filename); if (graphics.cur_image == NULL) { if (sdlSlide.info || sdlSlide.debug) printf("image: %s\n", SDL_GetError()); }else SDL_SetColorKey(graphics.background, 0, 0); if (sdlSlide.useVideo) graphics.drawCurImage(); } void setFontColor(SDL_Surface *image, int red, int green, int blue) { SDL_Color colors[256]; colors[0].r = 0; colors[0].g = 0; colors[0].b = 0; for (int i = 1 ; i < 256 ; i++) { colors[i].r = red; colors[i].g = green; colors[i].b = blue; } SDL_SetPalette(image, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256); } /* Custom loading to alter the font color before doing all other things */ void loadFont() { SDL_Surface *image, *newImage; for (int i = 0 ; i < MAX_FONTSHAPES ; i++) { image = IMG_Load("defaultFont.png"); if (image == NULL) { printf("Couldn't load game font! (%s) Exitting.\n", SDL_GetError()); exit(1); } switch(i) { case 1: setFontColor(image, 255, 0, 0); break; case 2: setFontColor(image, 255, 255, 0); break; case 3: setFontColor(image, 0, 255, 0); break; case 4: setFontColor(image, 0, 255, 255); break; case 5: setFontColor(image, 0, 0, 10); break; } newImage = SDL_DisplayFormat(image); graphics.fontShape[i] = graphics.setTransparent(newImage); SDL_FreeSurface(image); } } int isOnScreen(int x, int y, int w, int h) { if ((x + w > 0) && (x < 800) && (y + h > 0) && (y < 600)) return 1; return 0; } void cleanUp() { if (sdlSlide.info || sdlSlide.debug) printf("info: Cleaning Up...\n"); graphics.freeGraphics(); if (sdlSlide.info || sdlSlide.debug) printf("info: Free Images\n"); SDL_Quit(); if (sdlSlide.info || sdlSlide.debug) printf("info: ...Done Cleaning Up\nThank You for using sdlSlide\n"); } /* Pixel Stuff */ void scalePixelUp(int x, int y) { int pc; pc = sge_GetPixel(graphics.cur_image, x, y); for (int yy = 0; yy < sdlSlide.scale; yy++) for (int xx = 0; xx < sdlSlide.scale; xx++) sge_PutPixel(graphics.scale_image, xx, yy, pc); } void copyPixel(int x, int y, int xx, int yy) { int pc; pc = sge_GetPixel(graphics.cur_image, x, y); sge_PutPixel(graphics.scale_image, xx, yy, pc); } int redrawComplex() { signed char scaleDone; int cw, ch, iw, ih, m; float scale, tw, th; graphics.clearScreen(0); if (sdlSlide.fullscreen) { cw = sdlSlide.display_w; ch = sdlSlide.display_h; }else{ cw = sdlSlide.window_w; ch = sdlSlide.window_h; } if (graphics.scale_image != NULL) { SDL_FreeSurface(graphics.scale_image); graphics.scale_image = NULL; } // scaleDone = 0; if (sdlSlide.fitPage && sdlSlide.doFit) { tw = (float) cw / graphics.cur_image->w; th = (float) ch / graphics.cur_image->h; if(tw < th) scale = tw; else scale = th; iw = scale * graphics.cur_image->w; ih = scale * graphics.cur_image->h; graphics.scale_image = graphics.transparentRect(iw, ih, 255, 0, 255); graphics.scale_rect = sge_transform(graphics.cur_image, graphics.scale_image, 0, scale, scale, 0, 0, iw/2, ih/2, SGE_TTMAP); sdlSlide.center = 1; sdlSlide.doFit = 0; }else if ( sdlSlide.useZoom || (sdlSlide.useScale && sdlSlide.scale >= 1) ) { if (sdlSlide.useZoom) scale = (float) sdlSlide.zoom / 100; else scale = (float) sdlSlide.scale; if (sdlSlide.debug) printf("info: scaling image %f:1\n", scale); iw = scale * graphics.cur_image->w; ih = scale * graphics.cur_image->h; if (iw > cw) iw = cw; if (ih > ch) ih = ch; graphics.scale_image = graphics.transparentRect(iw, ih, 255, 0, 255); graphics.scale_rect = sge_transform(graphics.cur_image, graphics.scale_image, 0, scale, scale, 0, 0, iw/2, ih/2, SGE_TTMAP); // scaleDone = 1; } /* else{ scaleDone = 1; } if (sdlSlide.useZoom && !scaleDone) { sdlSlide.useScale = 1; sdlSlide.oneIn = 0; while(true){ if (sdlSlide.zoom==90){ sdlSlide.oneIn = 1; sdlSlide.scale = -5; break; } if (sdlSlide.zoom==80){ sdlSlide.oneIn = 1; sdlSlide.scale = -4; break; } if (sdlSlide.zoom==70){ sdlSlide.oneIn = 1; sdlSlide.scale = -3; break; } if (sdlSlide.zoom==60){ sdlSlide.oneIn = 1; sdlSlide.scale = -2; break; } if (sdlSlide.zoom==50){ sdlSlide.oneIn = 0; sdlSlide.scale = -1; break; } if (sdlSlide.zoom==33){ sdlSlide.oneIn = 0; sdlSlide.scale = -2; break; } if (sdlSlide.zoom==25){ sdlSlide.oneIn = 0; sdlSlide.scale = -3; break; } if (sdlSlide.zoom==13){ sdlSlide.oneIn = 0; sdlSlide.scale = -4; break; } if (sdlSlide.zoom==12){ sdlSlide.oneIn = 0; sdlSlide.scale = -4; break; } if (sdlSlide.zoom==6) { sdlSlide.oneIn = 0; sdlSlide.scale = -5; break; } if (sdlSlide.zoom==5) { sdlSlide.oneIn = 0; sdlSlide.scale = -5; break; } sdlSlide.scale = 1; break; } } if (sdlSlide.useScale && !scaleDone) { if (sdlSlide.oneIn) // { / * scale down (50%, 33%, 25%, 12.5%, 6.25%) * / iw = (int)(graphics.cur_image->w / (-1 * sdlSlide.scale)); ih = (int)(graphics.cur_image->h / (-1 * sdlSlide.scale)); if (iw > cw) iw = cw; if (ih > ch) ih = ch; graphics.scale_image = graphics.transparentRect(iw, ih, 255, 0, 255); if (graphics.scale_image == NULL) return -1; sdlSlide.ox = 0; sdlSlide.oy = 0; for (int j=0; j= ih) j = ih - 1; for (int i=0; i= iw) i = iw - 1; copyPixel(i, j, sdlSlide.ox, sdlSlide.oy); sdlSlide.ox++; } sdlSlide.oy++; } // }else{ / * scale down (90%, 80%, 75%, 70%, 66%) * / iw = (int)(graphics.cur_image->w - (graphics.cur_image->w / (-1 * sdlSlide.scale))); ih = (int)(graphics.cur_image->h - (graphics.cur_image->h / (-1 * sdlSlide.scale))); if (iw > cw) iw = cw; if (ih > ch) ih = ch; graphics.scale_image = graphics.transparentRect(iw, ih, 255, 0, 255); if (graphics.scale_image == NULL) return -1; for (int j=0; j= ih) { j = ih; continue; } for (int i=0; iw/2); sdlSlide.oy = (ch/2)-(graphics.scale_image->h/2); }else{ sdlSlide.ox = (cw/2)-(graphics.cur_image->w/2); sdlSlide.oy = (ch/2)-(graphics.cur_image->h/2); } }else{ sdlSlide.ox = 0; sdlSlide.oy = 0; } if(graphics.background != NULL) graphics.drawBackGround(); if (graphics.scale_image != NULL) graphics.blit(graphics.scale_image, sdlSlide.ox, sdlSlide.oy, graphics.screen); else graphics.blit(graphics.cur_image, sdlSlide.ox, sdlSlide.oy, graphics.screen); graphics.updateScreen(); return 0; } /* initialization */ void sdlSlide_Init() { sdlSlide.debug = 0; if (sdlSlide.debug) printf("info: initializing engine\n"); sdlSlide.useVideo = 1; sdlSlide.fullscreen = 0; sdlSlide.useBackground = 0; sdlSlide.display_w = SCREEN_WIDTH; // default display size sdlSlide.display_h = SCREEN_HEIGHT; sdlSlide.window_w = WINDOW_WIDTH; // default window size sdlSlide.window_h = WINDOW_HEIGHT; sdlSlide.ox = 0; sdlSlide.oy = 0; sdlSlide.ow = 0; sdlSlide.oh = 0; sdlSlide.ssx = 0; sdlSlide.ssy = 0; for (int i = 0 ; i < 350 ; i++) sdlSlide.keyState[i] = 0; sdlSlide.eventTimer = 0; sdlSlide.totalTime = 0; sdlSlide.startTime = 0; sdlSlide.stopTime = 1; sdlSlide.timeTaken = 0; sdlSlide.seconds = 0; sdlSlide.minutes = 0; sdlSlide.paused = 0; sdlSlide.slideshow = 0; sdlSlide.delay = 4; sdlSlide.delayCount = 0; sdlSlide.fps = 0; sdlSlide.next = 0; sdlSlide.current = 0; sdlSlide.playlist = 0; sdlSlide.repeat = 0; sdlSlide.repeatCount = 0; sdlSlide.useZoom = 0; sdlSlide.zoom = 100; sdlSlide.useScale = 0; sdlSlide.scale = 1; sdlSlide.doFit = 0; sdlSlide.fitPage = 0; sdlSlide.info = 0; sdlSlide.showFormat = 0; sdlSlide.showSize = 0; sdlSlide.section = 0; } void initVars() { srand(time(NULL)); // for randomise playlist if (sdlSlide.useScale && sdlSlide.useZoom) sdlSlide.useZoom = 0; if (sdlSlide.scale == 0) sdlSlide.scale = 1; if (sdlSlide.zoom == 0) sdlSlide.zoom = 100; } void setVideoMax() { graphics.screen = SDL_SetVideoMode(sdlSlide.display_w, sdlSlide.display_h, 16, SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN); sdlSlide.fullscreen = 1; if (sdlSlide.info || sdlSlide.debug) printf("info: set %dx%dx16 video mode\n", sdlSlide.display_w, sdlSlide.display_h); } void setVideoWindow() { graphics.screen = SDL_SetVideoMode(sdlSlide.window_w, sdlSlide.window_h, 0, SDL_HWSURFACE|SDL_HWPALETTE); sdlSlide.fullscreen = 0; if (sdlSlide.info || sdlSlide.debug) printf("info: set %dx%d window mode\n", sdlSlide.window_w, sdlSlide.window_h); } void initSystem() { const SDL_VideoInfo* videoInfo; /* Initialize the SDL library */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { printf("Couldn't initialize SDL: %s\n", SDL_GetError()); exit(1); } if (sdlSlide.debug) printf("info: probing video for W x H\n"); videoInfo = SDL_GetVideoInfo(); sdlSlide.display_w = videoInfo->current_w; sdlSlide.display_h = videoInfo->current_h; if (sdlSlide.useVideo) { SDL_WM_SetCaption("sdlSlide", "sdlSlide"); // SDL_WM_SetIcon(loadImage("gfx/alienDevice.png"), NULL); if (sdlSlide.fullscreen) setVideoMax(); else setVideoWindow(); if (graphics.screen == NULL) { printf("error: Couldn't set video mode: %s\n", SDL_GetError()); exit(1); } }else{ if (sdlSlide.info || sdlSlide.debug) printf("info: video output disabled\n"); } } void redrawNormal() { graphics.clearScreen(0); if(graphics.background != NULL) graphics.drawBackGround(); graphics.drawCurImage(); graphics.updateScreen(); } void sdlUpdateVideo() { if (sdlSlide.center || (sdlSlide.scale != 1) || (sdlSlide.zoom != 100) || (sdlSlide.fitPage && sdlSlide.doFit) ) { if (redrawComplex() == -1) redrawNormal(); }else{ redrawNormal(); } if (sdlSlide.debug) { if (graphics.scale_image != NULL) printf("info: image is scaled\n"); else printf("info: image is not scaled\n"); } } /* slideshow states */ void imageSize() { printf("%dx%d", graphics.cur_image->w, graphics.cur_image->h); } void imageInfo(char *file) { char *filename; filename = basename(file); printf("%s: %dx%d\n", filename, graphics.cur_image->w, graphics.cur_image->h); } void updateTitle(char *file) { char title[50]; sprintf(title,"%s (%dx%d)", basename(file), graphics.cur_image->w, graphics.cur_image->h); if (sdlSlide.useZoom) sprintf(title,"%s - %d%%", title, sdlSlide.zoom); if (sdlSlide.useScale) sprintf(title,"%s - %d:1", title, sdlSlide.scale); SDL_WM_SetCaption(title, "sdlSlide"); } int getImageFile() //#0 { if (sdlSlide.next == sdlSlide.playlist) return 8; if (graphics.cur_image != NULL) { SDL_FreeSurface(graphics.cur_image); graphics.cur_image = NULL; } if (graphics.scale_image != NULL) { SDL_FreeSurface(graphics.scale_image); graphics.scale_image = NULL; } graphics.cur_image = loadImage(sdlSlide.playList[sdlSlide.next]); if (graphics.cur_image == NULL) { if (sdlSlide.debug) printf("info: failed loading: %s\n",sdlSlide.playList[sdlSlide.next]); return 9; } SDL_SetColorKey(graphics.cur_image, 0, 0); sdlSlide.current = sdlSlide.next; if (sdlSlide.fitPage) { sdlSlide.doFit = 1; sdlSlide.useZoom = 0; sdlSlide.zoom = 100; } return 2; } void togglePause() { if(sdlSlide.paused) sdlSlide.paused = 0; else sdlSlide.paused = 1; } void toggleFullScreen() { if (!sdlSlide.useVideo) return; if(sdlSlide.fullscreen) { setVideoWindow(); }else{ setVideoMax(); } if (sdlSlide.fitPage && sdlSlide.zoom != 100) sdlSlide.doFit = 1; sdlUpdateVideo(); } int checkKeys() //#1 { SDL_Delay(1); getUserInput(); if (sdlSlide.keyState[SDLK_ESCAPE] || sdlSlide.keyState[SDLK_q]) { sdlSlide.keyState[SDLK_ESCAPE] = 0; sdlSlide.keyState[SDLK_q] = 0; return 10; } if (sdlSlide.keyState[SDLK_F11]) { sdlSlide.keyState[SDLK_F11] = 0; toggleFullScreen(); } if (sdlSlide.keyState[SDLK_SPACE]) { sdlSlide.keyState[SDLK_SPACE] = 0; if(!sdlSlide.slideshow) return 8; togglePause(); return 3; } if (sdlSlide.keyState[SDLK_RETURN] || sdlSlide.keyState[SDLK_KP_ENTER]) { sdlSlide.keyState[SDLK_RETURN] = 0; sdlSlide.keyState[SDLK_KP_ENTER] = 0; if (sdlSlide.paused) togglePause(); return 8; } if (sdlSlide.keyState[SDLK_BACKSPACE]) { sdlSlide.keyState[SDLK_BACKSPACE] = 0; if (sdlSlide.paused) togglePause(); if (sdlSlide.next == 0) return 1; --sdlSlide.next; return 0; } if (sdlSlide.keyState[SDLK_LEFT]) { sdlSlide.keyState[SDLK_LEFT] = 0; if (sdlSlide.paused) togglePause(); if (sdlSlide.next == 0) return 1; --sdlSlide.next; return 0; } if (sdlSlide.keyState[SDLK_RIGHT]) { sdlSlide.keyState[SDLK_RIGHT] = 0; if (sdlSlide.paused) togglePause(); return 8; } if (sdlSlide.keyState[SDLK_b]) { sdlSlide.keyState[SDLK_b] = 0; sdlSlide.useBackground = !sdlSlide.useBackground; sdlUpdateVideo(); } if (sdlSlide.keyState[SDLK_c]) { sdlSlide.keyState[SDLK_c] = 0; sdlSlide.center = !sdlSlide.center; sdlUpdateVideo(); } if (sdlSlide.keyState[SDLK_KP_MINUS]) { sdlSlide.keyState[SDLK_KP_MINUS] = 0; if(sdlSlide.fitPage) sdlSlide.useZoom = 1; sdlSlide.scale--; sdlSlide.zoom -= 10; if(sdlSlide.scale < 1) sdlSlide.scale = 1; if(sdlSlide.zoom < 10) sdlSlide.zoom = 100; updateTitle(sdlSlide.playList[sdlSlide.current]); sdlUpdateVideo(); } if (sdlSlide.keyState[SDLK_KP_PLUS]) { sdlSlide.keyState[SDLK_KP_PLUS] = 0; if(sdlSlide.fitPage) sdlSlide.useZoom = 1; sdlSlide.scale++; sdlSlide.zoom += 10; if(sdlSlide.scale > 8) sdlSlide.scale = 8; if(sdlSlide.zoom > 800) sdlSlide.zoom = 100; updateTitle(sdlSlide.playList[sdlSlide.current]); sdlUpdateVideo(); } if(!sdlSlide.paused || sdlSlide.slideshow || sdlSlide.delay > 0) return 3; return 1; } int slidePause() { sdlSlide.keyState[SDLK_SPACE] = 0; while (!sdlSlide.keyState[SDLK_SPACE]) { SDL_Delay(1); getUserInput(); } return 8; } int slideShow() //#2 { sdlSlide.startTime = time(NULL); if (sdlSlide.useVideo) { updateTitle(sdlSlide.playList[sdlSlide.current]); sdlUpdateVideo(); }else{ imageInfo(sdlSlide.playList[sdlSlide.current]); } return 3; } int slideDelay() //#3 { int timeNow; if(sdlSlide.paused || !sdlSlide.slideshow || sdlSlide.delay < 1) return 1; if (sdlSlide.delay > 0) { timeNow = time(NULL); sdlSlide.timeTaken = timeNow - sdlSlide.startTime; if (sdlSlide.timeTaken >= (sdlSlide.delay * sdlSlide.stopTime)) { sdlSlide.totalTime += sdlSlide.timeTaken; if (sdlSlide.debug) printf("sdlSlide.timeTaken=%d\nsdlSlide.totalTime=%d\n", sdlSlide.timeTaken, sdlSlide.totalTime); sdlSlide.timeTaken = 0; }else{ sdlSlide.timeTaken = 0; return 1; } } return 8; } int showRepeat() //#8 { if (sdlSlide.next != sdlSlide.playlist) return 9; if (sdlSlide.repeat > 0) if (sdlSlide.repeatCount < sdlSlide.repeat) { sdlSlide.repeatCount++; sdlSlide.next = 0; sdlSlide.current = 0; return 0; } return 10; } /* one-file (1f) specific */ void version_1f() { printf("sdlSlide (one-file) v%s\n", VERSION); } void output_1f(char *file_1f) { FILE *source_1f; char out_1f[1]; if (offset_1f == NO_SIZE || sizeOf_1f == NO_SIZE) { version_1f(); printf("error: no source file or zip\n"); exit(32); }else{ source_1f = fopen(file_1f, "rb"); if (source_1f == NULL) { version_1f(); printf("error: cant open '%s'\n", file_1f); exit(32); } // fseek(source_1f, offset_1f + 223, SEEK_SET); // off by ? fseek(source_1f, -sizeOf_1f, SEEK_END); while(true) { if (!fread(out_1f, 1, 1, source_1f)) { fclose(source_1f); break; }else putchar((int) out_1f[0]); } } } /* one-file (1f) main */ int main(int argc, char *argv[]) { /* place used variables here */ int j, argDone, section; /* this is the begining of commandline argument processing */ if ( (argc > 1) && ( (strcmp("--version", argv[1]) == 0) || (strcmp("-v", argv[1]) == 0) ) ) { version_1f(); exit(0); } if ( (argc == 1) || ( (argc > 1) && (strcmp("--help", argv[1]) == 0) ) ) { version_1f(); printf("Copyright 2016 MiNTed Games\n\n"); printf("View graphics files, using SDL v1.2.\n\n"); printf("usage: sdlSlide-1f [_option_] []\n"); if (argc > 1) { printf("_option_:\n"); printf("\t--1f one-file (1f) source information\n"); printf("\t--background instead of black screen\n"); printf("\t--slideshow Slideshow images list (with options) then exit\n"); printf("\t--delay Delay between slides seconds (number keys, default 4)\n"); printf("\t--repeat Show images list times\n"); printf("\t--center Show image centered (C key)\n"); printf("\t--zoom Set zoom to %% (same as below) (default 100, +/- keys)\n"); printf("\t--pixels Pixels size or skip (-) pixels, (default 1, +/- keys)\n"); printf("\t--fullscreen Set window to fullscreen (F11 key)\n"); printf("\t--fit Scale and Center image to fit page\n"); printf("\t--format Display file information (no shows all formats)\n"); printf("\t--novideo Dont display images (use with verbose)\n"); printf("\t--size Only output size (no image)\n"); printf("\t--help This help information\n"); printf("\t-v|--version Version information\n"); printf("\t-V|--verbose Verbose output\n"); printf("\t--debug Extra verbose output\n"); printf("\nspecial thanks to: www.parallelrealities.co.uk\n"); } printf("\n"); exit(0); } if ( (argc > 1 ) && ( (strcmp("-1f", argv[1]) == 0) || (strcmp("--1f", argv[1]) == 0) ) ) { version_1f(); printf("Copyright 2016 MiNTed Games\n"); printf("one-file (1f) source information.\n\n"); if (offset_1f == NO_SIZE || sizeOf_1f == NO_SIZE) { printf("no source file or zip\n"); exit(32); }else{ printf("usage: sdlSlide-1f _option_\n"); printf("_option_:\n"); printf("\t--src|--source output attached one-file (1f) source file\n"); printf("\t--src-size size of appended source (in bytes) (%d)\n", SRC_SIZE); printf("\t--src-type type of source appended (TXT/ZIP) (%s)\n", SRC_TYPE); printf("\n"); printf("To save one-file (1f) source to file use one of the following:\n"); printf("\tsdlSlide-1f --src > sdlSlide-1f.cpp\n"); // printf("\tsdlSlide-1f --src > sdlSlide-1f.zip\n"); printf("\tsdlSlide-1f --src > sdlSlide-1f`sdlSlide-1f --src-type`\n"); printf("To verify one-file (1f) source file size:\n"); printf("\tsdlSlide-1f --src-size (match this to the size in a directory listing)\n"); printf("or use:\n"); printf("NAME=sdlSlide; if [ `ls -l $NAME-1f.cpp|cut -d \\ -f 5` = `./$NAME-1f --src-size` ]; then echo Verified; else echo Failed; fi\n"); printf("one-file (1f) options exit with status:\n"); printf("\t31 successful (0x1f)\n"); printf("\t32 an error occured (0x20)\n"); exit(31); } } if ( (argc > 1) && ( (strcmp("--source", argv[1]) == 0) || (strcmp("--src", argv[1]) == 0) ) ) { output_1f(argv[0]); exit(31); } if ( (argc > 1) && (strcmp("--src-type", argv[1]) == 0) ) { printf(SRC_TYPE); exit(31); } if ( (argc > 1) && (strcmp("--src-size", argv[1]) == 0) ) { printf("%d", SRC_SIZE); exit(31); } sdlSlide_Init(); // Must do this first j = 0; for (int i = 1; i < argc; i++) { argDone = 0; if ( (strcmp(argv[i], "--format") == 0) || (strcmp(argv[i], "--formats") == 0) ) { sdlSlide.showFormat = 1; argDone = 1; } if ( (strcmp(argv[i], "--verbose") == 0) || (strcmp(argv[i], "-V") == 0) ) { sdlSlide.info = 1; argDone = 1; } if ( (strcmp(argv[i], "--novideo") == 0) || (strcmp(argv[i], "---no-video") == 0) ) { sdlSlide.useVideo = 0; argDone = 1; } if (strcmp(argv[i], "--debug") == 0) { sdlSlide.debug = 1; argDone = 1; } if (strcmp(argv[i], "--size") == 0) { sdlSlide.showSize = 1; argDone = 1; } if (strcmp(argv[i], "--center") == 0) { sdlSlide.center = 1; argDone = 1; } if (strcmp(argv[i], "--fullscreen") == 0) { sdlSlide.fullscreen = 1; argDone = 1; } if (strcmp(argv[i], "--fit") == 0) { sdlSlide.fitPage = 1; argDone = 1; } if (strcmp(argv[i], "--slideshow") == 0) { sdlSlide.slideshow = 1; argDone = 1; } if (strcmp(argv[i], "--zoom") == 0) { i++; if (i == argc) { printf("error: --zoom needs a number\n"); exit(1); } sdlSlide.zoom = atoi(argv[i]); if (sdlSlide.zoom == 0) sdlSlide.zoom = 100; if (sdlSlide.zoom != 100) sdlSlide.useZoom = 1; argDone = 1; } if (strcmp(argv[i], "--pixels") == 0) { i++; if (i == argc) { printf("error: --pixels needs a number\n"); exit(1); } sdlSlide.scale = atoi(argv[i]); if (sdlSlide.scale == 0) sdlSlide.scale = 1; if (sdlSlide.scale != 1) sdlSlide.useScale = 1; if (sdlSlide.scale < 0) sdlSlide.oneIn = 1; argDone = 1; } if (strcmp(argv[i], "--fps") == 0) { i++; if (i == argc) { printf("error: --fps needs a number\n"); exit(1); } sdlSlide.fps = atoi(argv[i]); argDone = 1; } if (strcmp(argv[i], "--delay") == 0) { i++; if (i == argc) { printf("error: --delay needs a number\n"); exit(1); } sdlSlide.delay = atoi(argv[i]); argDone = 1; } if (strcmp(argv[i], "--repeat") == 0) { i++; if (i == argc) { printf("error: --repeat needs a number\n"); exit(1); } sdlSlide.repeat = atoi(argv[i]); argDone = 1; } if (strcmp(argv[i], "--background") == 0) { i++; if (i == argc) { printf("error: --repeat needs a filename\n"); exit(1); } strcpy(sdlSlide.background, argv[i]); sdlSlide.useBackground = 1; argDone = 1; } if (argDone == 0) { strcpy(sdlSlide.playList[j], argv[i]); j++; } } sdlSlide.playlist = j; if (sdlSlide.showFormat && sdlSlide.playlist == 0) { version_1f(); printf("[15] image formats:"); if(sdlSlide.info) { printf("\n"); printf("\t.ICO Microsoft Icon format\n"); printf("\t.CUR Microsoft Cursor format\n"); printf("\t.BMP Microsoft Bit Map image\n"); printf("\t.GIF Graphics Interchange Format\n"); printf("\t.JPG JPEG encoded graphic image (lossy)\n"); printf("\t.JPEG JPEG encoded graphic image (lossy)\n"); printf("\t.ILBM InterLeaved BitMap image (IFF containers)\n"); printf("\t.LBM InterLeaved BitMap image (IFF containers)\n"); printf("\t.PCX PC Paintbrush eXtended graphic\n"); printf("\t.PNG Portable Network Graphic\n"); printf("\t.PNM Portable Network M\n"); printf("\t.TIF 32bit Image File Format\n"); printf("\t.TIFF 32bit Image File Format\n"); printf("\t.XCF GIMP image\n"); printf("\t.XBM X Windows mono Bit Map image (ASCII)\n"); printf("\t.XPM X Windows color Pixel Map image (ASCII)\n"); printf("\t.XV X Windows\n"); printf("\t.WEBP Cell/Mobile phone Web graphic\n"); }else{ printf(" ICO CUR BMP GIF JPG JPEG ILBM LBM PCX PNG PNM TIF TIFF XCF XBM XPM XV WEBP\n"); } exit(0); } atexit(cleanUp); initSystem(); // Opens video mode and sound initVars(); if (sdlSlide.showSize) { if (!sdlSlide.playlist) { printf("error: --size needs at least one file\n"); exit(1); } getImageFile(); imageSize(); exit(0); } if (sdlSlide.useBackground) { loadBackground(sdlSlide.background); } section = 0; while (true) { // non-blocking (shows high CPU usage) // should be event driven, but this is faster //printf("%d ",section); switch(section) { case 0: section = getImageFile(); break; case 1: section = checkKeys(); break; case 2: section = slideShow(); break; case 3: section = slideDelay(); break; case 8: section = showRepeat(); break; case 9: sdlSlide.next++; section = 0; break; } if (section == 10) exit(0); } return(0); }