Advertisement
inukaze

ePSXe - Bash Launcher 2

Jun 3rd, 2011
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.73 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Inukaze - ePSXe Launcher
  4. # Blog : http://inukaze.wordpress.com
  5. # License GPL
  6. # If you use this source code or part of this , you must specify the Autor and the part
  7. # of this source code are you using.
  8. # Special Thanks to :   Facebook user "Beakos GNU Linux" for giveme the command "sed 's/[.].*//'"
  9. # Special Thanks to :   ArchLinux user "alfPlayer" for commands Like "Path=${0%/*}"
  10. #           & Testing and Corrections Ideas for this Script
  11.  
  12. clear && reset
  13.  
  14. # Change to game directory
  15. ePSXe_Path=${0%/*}
  16. cd "$ePSXe_Path"
  17.  
  18. # Checking if there are relevant files and directories
  19. # For the correct execution of the emulator ePSXe.
  20. if [ ! -f keycodes.lst ] || [ ! -f bios/scph1001.bin ] || [ ! -e cfg ] || [ ! -e plugins ] || [ ! -e memcards ]
  21. then
  22.     echo "Missing needs files / and / directories in `$ePSXe_Path`"
  23.     echo "Your ePSXe is incomplete!"
  24. exit 1
  25. fi
  26.  
  27. # Determining CPU Speed
  28. CPUMHz=`dmesg | grep "MHz processor" | cut -d " " -f07 | sed 's/[.].*//'`
  29.     if [ "$CPUMHz" -ge "800" ]
  30.     then
  31.         let CPUGHz=$CPUMHz/1000
  32.         echo "You have $CPUGHz GHz Processor"
  33.     else
  34.         echo "You need a 800 MHz Processor to run ePSXe"
  35. fi
  36.  
  37. # Determining If the user has enough RAM to run the emulator
  38. RAM_Kb=`grep MemTotal /proc/meminfo | awk '{print $2}'`
  39.     if [ "$RAM_Kb" -ge "128000" ]
  40.     then
  41.         let RAM_MB=$RAM_Kb/1000
  42.         echo "You have $RAM_MB MB RAM"
  43.     else
  44.     echo "You need 128 MB RAM , please install more RAM Memory"
  45. fi
  46.  
  47. # Determining Video Card & Video Card Size & 3D Support
  48. vcard=`lspci -v | grep "VGA" | cut -d " " -f05`
  49. if [ "$vcard" = nVidia ]
  50.     then
  51.     echo "You have a nVidia Video Card"
  52.     nv_card_size=`nvidia-settings -q VideoRam | grep "Attribute 'VideoRam'" | cut -d " " -f06 | sed 's/[.].*//'`
  53.         if [ "$nv_card_size" -ge "64000" ]
  54.             then
  55.             let nvcard_mbmem=$nv_card_size/1000
  56.             echo "You have $nvcard_mbmem Mb Video Memory"
  57.             nvsupport3d=`nvidia-settings -g | grep "direct rendering: Yes" | cut -d " " -f05`
  58.                 if [ $nvsupport3d = "Yes" ]
  59.             then
  60.                 echo "You have 3D Support & Direct Rendering"
  61.             else
  62.                 echo "You dont have 3D Support"
  63.                 echo "You need 3D Support to use ePSXe to run PlayStation 1 Games"
  64.             fi
  65.         else
  66.         echo ""
  67.         echo "You need 64 MB Video Card with 3D Support"
  68.         echo ""    
  69.         fi
  70. else
  71.         echo "You have $vcard Video Card"
  72. vidsize=lspci -v -s `lspci | awk '/VGA/{print $1}'` | sed -n '/Memory.*, prefetchable/s/.*\[size=\([^]]\+\)M\]/\1/p'
  73.     if [ "$vidsize" -ge 64 ]
  74.         then
  75.             echo "You have $vidsize MB Video"
  76.                 support3d=glxinfo | grep "direct rendering: Yes" | cut -d " " -f03
  77.                 if [ $support3d = Yes ]
  78.                     then
  79.                         echo "You have 3D Support & Direct Rendering"
  80.                     else
  81.                         echo "You dont have 3D Support"
  82.                         echo "You need 3D Support to use ePSXe to run PlayStation 1 Games"
  83.                 fi
  84.         else
  85.             echo "You need 64 MB Video Card to Gaming with ePSXe"
  86.     fi
  87. fi
  88.  
  89. # Determining Operating System Architecture & Linux Distro Name For Use 32 Bits Libs
  90. MACHINE=`uname -m`
  91.     if [ "$MACHINE" = "x86_64" ]
  92.     then
  93.         echo "You have a 64 Bits Operating System"
  94.     else
  95.         echo "You have a 32 Bits Operating System"
  96.     fi
  97.  
  98. # Determining Linux Distro Name
  99. # For Use 32 Bits Libraries Directory
  100. DISTRONAME=`awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | tr '[:upper:]' '[:lower:]'`
  101. LIBS="$ePSXe_Path/32bits_libs"
  102. DISTROLIBS="$LIBS/$DISTRONAME"
  103. if [ "$DISTRONAME" = "$DISTRONAME" ]
  104.     then
  105.         chmod 666 $ePSXe_Path/cfg/*.cfg $ePSXe_Path/sstates/* \
  106.         $ePSXe_Path/memcards/*.mcr $ePSXe_Path/snap/* 2>/dev/null
  107.         export LD_LIBRARY_PATH="$DISTROLIBS"
  108.         #Uncoment the follow line if you must need use OSS :
  109.         #export LD_PRELOAD="$DISTROLIBS/libaoss.so" exec "$@"
  110.         BIN=$ePSXe_Path/.epsxe
  111.         echo "Using 32 Bits Libraries for $DISTRONAME"
  112.     else
  113.         chmod 666 $ePSXe_Path/cfg/*.cfg $ePSXe_Path/sstates/* \
  114.         $ePSXe_Path/memcards/*.mcr $ePSXe_Path/snap/* 2>/dev/null
  115.         export LD_LIBRARY_PATH="$LIBS/testing"
  116.         BIN=$ePSXe_Path/.epsxe
  117.         echo "Using 32 Bits Testing Libraries"
  118.         echo "Because ePSXe 1.6.0 dont have libs for this distro"
  119. fi
  120.  
  121. # Run the ePSXe - Sony PlayStation Emulator:
  122. $BIN "$@"
  123.  
  124. # Check for errors
  125. e=$?
  126. if [ $e -ne 0 ]
  127. then
  128.     echo ""
  129.     echo "It looks like ePSXe crashed! If you need support, please include the"
  130.     echo "contents of the log file in your problem report."
  131.  
  132.     LOGPATH="$HOME/.epsxe/epsxe.log"
  133.     if [ ! -f "$LOGPATH" ]
  134.     then
  135.         touch "$LOGPATH"
  136.         echo "The log file is stored at: $LOGPATH"
  137.  
  138.         echo "" >> $LOGPATH
  139.         echo "Libraries used:" >> $LOGPATH
  140.         ldd $BIN >> $LOGPATH 2>&1
  141.  
  142.         echo "" >> $LOGPATH
  143.         GLXINFO=`which glxinfo`
  144.         if [ -z "$GLXINFO" ]
  145.         then
  146.             echo "glxinfo not found!" >> $LOGPATH
  147.         else
  148.             echo "Output of glxinfo:" >>$LOGPATH
  149.             glxinfo >>$LOGPATH 2>&1
  150.         fi
  151.        
  152.     else
  153.         echo "Unfortunately, no log file has been created!"
  154.     fi
  155. fi
  156.  
  157. exit $e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement