Advertisement
Guest User

Untitled

a guest
Nov 26th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. #!/Ausr/bin/env python
  2. import os, sys
  3. import recalboxFiles
  4. import settings
  5. from settings.unixSettings import UnixSettings
  6. import subprocess
  7. import json
  8.  
  9. mupenSettings = UnixSettings(recalboxFiles.mupenCustom, separator=' ')
  10.  
  11. GlideN64FBEmulation_whitelist = ["ocarina", "empire", "pokemon", "rayman", "donald", "diddy", "beetle", "tennis", "instinct", "gemini", "twins", "majora", "quake", "ridge"]
  12. GLideN64LegacyBlending_blacklist = ["empire", "beetle", "donkey", "zelda", "bomberman", "party"]
  13. GLideN64NativeResolution_blacklist = ["majora"]
  14.  
  15. def writeMupenConfig(system, controllers, rom):
  16. setPaths()
  17. writeHotKeyConfig(controllers)
  18. if system.config['videomode'] != 'default':
  19. group, mode, drive = system.config['videomode'].split()
  20. setRealResolution(group, mode, drive)
  21. #Draw or not FPS
  22. if system.config['showFPS'] == 'true':
  23. mupenSettings.save('ShowFPS', 'True')
  24. # show_fps is used for Video-Glide64mk2 & Video-GlideN64
  25. mupenSettings.save('show_fps', '4')
  26. else:
  27. mupenSettings.save('ShowFPS', 'False')
  28. mupenSettings.save('show_fps', '8')
  29.  
  30. #Write GlideN64 config
  31. romName = os.path.basename(rom)
  32.  
  33. #Crop resulted image.
  34. mupenSettings.save('CropMode', '1')
  35. #Bilinear filtering mode.
  36. mupenSettings.save('bilinearMode', '1')
  37. #Size of texture cache in megabytes.
  38. mupenSettings.save('CacheSize', '100')
  39. #Enable color buffer copy to RDRAM.
  40. mupenSettings.save('EnableCopyColorToRDRAM', '0')
  41. #Enable frame and|or depth buffer emulation.
  42. mupenSettings.save('EnableFBEmulation', 'False')
  43. #Do not use shaders to emulate N64 blending modes. Works faster on slow GPU. Can cause glitches.
  44. mupenSettings.save('EnableLegacyBlending', 'True')
  45. #Frame buffer size is the factor of N64 native resolution.
  46. mupenSettings.save('UseNativeResolutionFactor', '1')
  47.  
  48. for n in GlideN64FBEmulation_whitelist:
  49. if n in romName.lower():
  50. mupenSettings.save('EnableFBEmulation', 'True')
  51.  
  52. for n in GLideN64LegacyBlending_blacklist:
  53. if n in romName.lower():
  54. mupenSettings.save('EnableLegacyBlending', 'False')
  55.  
  56. for n in GLideN64NativeResolution_blacklist:
  57. if n in romName.lower():
  58. mupenSettings.save('UseNativeResolutionFactor', '0')
  59.  
  60. def writeHotKeyConfig(controllers):
  61. if '1' in controllers:
  62. if 'hotkey' in controllers['1'].inputs:
  63. if 'start' in controllers['1'].inputs:
  64. mupenSettings.save('Joy Mapping Stop', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['start'])))
  65. if 'y' in controllers['1'].inputs:
  66. mupenSettings.save('Joy Mapping Save State', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['y'])))
  67. if 'x' in controllers['1'].inputs:
  68. mupenSettings.save('Joy Mapping Load State', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['x'])))
  69. if 'pageup' in controllers['1'].inputs:
  70. mupenSettings.save('Joy Mapping Screenshot', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['pageup'])))
  71. if 'up' in controllers['1'].inputs:
  72. mupenSettings.save('Joy Mapping Increment Slot', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['up'])))
  73. if 'right' in controllers['1'].inputs:
  74. mupenSettings.save('Joy Mapping Fast Forward', "\"J{}{}/{}\"".format(controllers['1'].index, createButtonCode(controllers['1'].inputs['hotkey']), createButtonCode(controllers['1'].inputs['right'])))
  75.  
  76.  
  77. def createButtonCode(button):
  78. if(button.type == 'axis'):
  79. if button.value == '-1':
  80. return 'A'+button.id+'-'
  81. else:
  82. return 'A'+button.id+'+'
  83. if(button.type == 'button'):
  84. return 'B'+button.id
  85. if(button.type == 'hat'):
  86. return 'H'+button.id+'V'+button.value
  87.  
  88.  
  89. def setRealResolution(group, mode, drive):
  90. # Use tvservice to get the real resolution
  91. groups = ['CEA', 'DMT']
  92. if group not in groups:
  93. sys.exit("{} is an unknown group. Can't switch to {} {} {}".format(group, group, mode, drive))
  94.  
  95. drives = ['HDMI', 'DVI']
  96. if drive not in drives:
  97. sys.exit("{} is an unknown drive. Can't switch to {} {} {}".format(drive, group, mode, drive))
  98.  
  99. proc = subprocess.Popen(["tvservice -j -m {}".format(group)], stdout=subprocess.PIPE, shell=True)
  100. (out, err) = proc.communicate()
  101. print "program output:", out
  102. tvmodes = json.loads(out)
  103.  
  104. for tvmode in tvmodes:
  105. if tvmode["code"] == int(mode):
  106. #mupenSettings.save('ScreenWidth', "{}".format(tvmode["width"]))
  107. #mupenSettings.save('ScreenHeight', "{}".format(tvmode["height"]))
  108. mupenSettings.save('ScreenWidth', "1280")
  109. mupenSettings.save('ScreenHeight', "720")
  110. return
  111.  
  112. sys.exit("The resolution for '{} {} {}' is not supported by your monitor".format(group, mode, drive))
  113.  
  114.  
  115. def setPaths():
  116. mupenSettings.save('ScreenshotPath', recalboxFiles.SCREENSHOTS)
  117. mupenSettings.save('SaveStatePath', recalboxFiles.mupenSaves)
  118. mupenSettings.save('SaveSRAMPath', recalboxFiles.mupenSaves)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement