Advertisement
Guest User

runcommand-onstart.sh

a guest
Sep 26th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.37 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #title           :  runcommand-onstart.sh
  3. #description     :  This script perform the following
  4. #                   Determines if the game being run is a console or an arcade/fba
  5. #                   For arcades, it will programatically determine the resolution based on resolution.ini file
  6. #                   For consoles, hdmi_timings can be set based on emulator or system
  7. #                   Dynamically creates the game_name.zip.cfg file and sets the custom_viewport_height
  8. #                   Dynamically add these parameters (video_allow_rotate = "true" and video_rotation = 1) for vertical games
  9. #                       vertical.txt contains all the mame 0.184 vertical games
  10. #                   Ability to set custom_viewport_width for arcades/fba
  11. #                   Fix arcade custom_viewport_width for 320x224 and 320x240 resolutions
  12. #                   Added amiga and C64 support
  13. #                   Automatically set custom_viewport_y to center vertically (Removed on 0.7.1)
  14. #                   Added support for 480 height arcade games like tapper
  15. #                   All console and arcade will default to 1600x240 resolution
  16. #                   Disable resolution change for non libretto cores
  17. #                   Added support for 448 height arcade games like popeye
  18. #                   Added support for 254 height arcade games like mk3
  19. #                   Arcade/FBA - Set custom_viewport_width to be rom_resolution_width multiplied closest to 1600
  20. #                   Removed text output when running scripts
  21. #                   Reverted hdmi_timings to previous version
  22. #                   Removed all logging
  23. #                   Default non supported emulators to 320x240
  24. #author          :  Michael Vencio
  25. #date            :  2019-05-25
  26. #version         :  0.8.3
  27. #notes           :  For advance users only and would need to be tweaked
  28. #                   to cater to your needs and preference
  29. #                   resolution.ini (0.184) file needed http://www.progettosnaps.net/renameset/
  30. #===============================================================================================================
  31.  
  32.  
  33. # get the system name
  34. system=$1
  35.  
  36. # get the emulator name
  37. emul=$2
  38. emul_lr=${emul:0:2}
  39.  
  40. # get the full path filename of the ROM
  41. rom_fp=$3
  42. rom_bn=$3
  43.  
  44. # Game or Rom name
  45. rom_bn="${rom_bn%.*}"
  46. rom_bn="${rom_bn##*/}"
  47.  
  48. # Determine if arcade or fba then determine resolution, set hdmi_timings else goto console section
  49. if [[ "$system" == "arcade" ]] || [[ "$system" == "fba" ]] || [[ "$system" == "mame-libretro" ]] ; then
  50.     # get the line number matching the rom
  51.     rom_ln=$(tac /opt/retropie/configs/all/resolution.ini | grep -w -n $rom_bn | cut -f1 -d":")
  52.  
  53.     # get resolution of rom
  54.     rom_resolution=$(tac /opt/retropie/configs/all/resolution.ini | sed -n "$rom_ln,$ p" | grep -m 1 -F '[')
  55.     rom_resolution=${rom_resolution#"["}
  56.     rom_resolution=${rom_resolution//]}
  57.     rom_resolution=$(echo $rom_resolution | sed -e 's/\r//g')
  58.     rom_resolution_width=$(echo $rom_resolution | cut -f1 -d"x")
  59.     rom_resolution_height=$(echo $rom_resolution | cut -f2 -d"x")
  60.     # Set rom_resolution_height for 480p and 448p roms
  61.     if [ $rom_resolution_height == "480" ]; then
  62.         rom_resolution_height="240"
  63.     elif [ $rom_resolution_height == "448" ]; then
  64.         rom_resolution_height="224"    
  65.     fi 
  66.    
  67.     # Create rom_name.cfg
  68.     if ! [ -f "$rom_fp"".cfg" ]; then
  69.         touch "$rom_fp"".cfg"
  70.     fi
  71.    
  72.     # Set custom_viewport_height
  73.     if ! grep -q "custom_viewport_height" "$rom_fp"".cfg"; then
  74.         echo -e "custom_viewport_height = ""\"$rom_resolution_height\"" >> "$rom_fp"".cfg" 2>&1
  75.     fi
  76.    
  77.     # determine if vertical  
  78.     if grep -w "$rom_bn" /opt/retropie/configs/all/vertical.txt ; then
  79.         # Add vertical parameters (video_allow_rotate = "true")
  80.         if ! grep -q "video_allow_rotate" "$rom_fp"".cfg"; then
  81.             echo -e "video_allow_rotate = \"true\"" >> "$rom_fp"".cfg" 2>&1
  82.         fi
  83.         # Add vertical parameters (video_rotation = 1)
  84.         if ! grep -q "video_rotation" "$rom_fp"".cfg"; then
  85.             echo -e "video_rotation = \"1\"" >> "$rom_fp"".cfg" 2>&1
  86.         fi 
  87.     fi
  88.  
  89.     # set the custom_viewport_width
  90.     if ! grep -q "custom_viewport_width" "$rom_fp"".cfg"; then
  91.         echo -e "custom_viewport_width = ""\"1600\"" >> "$rom_fp"".cfg"  2>&1
  92.     fi
  93. fi
  94.  
  95. # Use 1600 resolution for libretto cores
  96. if [[ "$emul_lr" == "lr" ]]; then
  97.     vcgencmd hdmi_timings 1600 1 85 157 192 240 1 4 3 15 0 0 0 60 0 32000000 1 > /dev/null
  98.     tvservice -e "DMT 87" > /dev/null
  99.     fbset -depth 8 && fbset -depth 16 -xres 1600 -yres 240 > /dev/null
  100. else
  101.     vcgencmd hdmi_timings 320 1 16 30 34 240 1 2 3 22 0 0 0 60 0 6400000 1  > /dev/null
  102.     tvservice -e "DMT 87" > /dev/null
  103.     fbset -depth 8 && fbset -depth 16 -xres 320 -yres 240 > /dev/null
  104. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement