Advertisement
djvj

Untitled

Oct 22nd, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.63 KB | None | 0 0
  1. MEmu = PCSX2
  2. MEmuV = Git-20150807
  3. MURL = http://pcsx2.net/
  4. MAuthor = djvj
  5. MVersion = 2.1.5
  6. MCRC = 3747C6AD
  7. iCRC = 776E3DD9
  8. MID = 635038268913291718
  9. MSystem = "Sony PlayStation 2"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; This module has many settings that can be controlled via RocketLauncherUI
  13. ; If you want to customize settings per game, add the game to the module's ini using RocketLauncherUI
  14. ; If you use Daemon Tools, make sure you have a SCSI virtual drive setup. Not a DT one.
  15. ; Tested Virtual Drive support with the cdvdGigaherz CDVD plugin. Make sure you set it to use your SCSI Virtual Drive letter.
  16. ; Module will set the CdvdSource to Plugin or Iso depending on if you have Virtual Drive enabled or not.
  17. ; If you have any problems closing the emulator, make sure noGUI module setting in RocketLauncherUI is set to default or false.
  18. ;
  19. ; Per-game memory cards
  20. ; This module supports per-game memory cards to prevent them from ever becoming full
  21. ; To use this feature, set the PerGameMemoryCards to true in RocketLauncherUI
  22. ; You need to create a default blank memory card in the path you have defined in pcsx's ini found in section [Folders], key MemoryCards.
  23. ; Make sure one of the current memory cards are blank, then copy it in that folder and rename it to "default.ps2". The module will copy this file to a romName.ps2 for each game launched.
  24. ; The module will only insert memory cards into Slot 1. So save your games there.
  25. ;
  26. ; Linuz cdvd plugin stores its settings in the registry @ HKEY_CURRENT_USER\Software\PS2Eplugin\CDVD\CDVDiso
  27. ;
  28. ; Run pcsx2 with the --help option to see current CLI parameters
  29. ;
  30. ; Known CLI options not currently supported by this module:
  31. ; --console forces the program log/console to be visible
  32. ; --portable enables portable mode operation (requires admin/root access)
  33. ; --elf=<str> executes an ELF image
  34. ; --forcewiz forces PCSX2 to start the First-time Wizard
  35. ;----------------------------------------------------------------------------
  36. StartModule()
  37. BezelGUI()
  38. FadeInStart()
  39.  
  40. ; PCSX2_ui.ini = default ini that contains memory card info and general settings
  41. If FileExist(emuPath . "\portable.ini") { ; portable install
  42. Log("Module - PCSX2 is operating in a portable mode")
  43. pcsx2IniFile := CheckFile(emuPath . "\inis\PCSX2_ui.ini", "Could not find the default PCSX2_ui.ini file. Please manually run and configure PCSX2 first so this file is created with all your default settings.")
  44. } Else { ; default not portable install
  45. Log("Module - PCSX2 is operating in a standard installation mode")
  46. RegRead, pcsx2IniFolder, HKCU, Software\PCSX2, SettingsFolder
  47. pcsx2IniFile := CheckFile(pcsx2IniFolder . "\PCSX2_ui.ini", "Could not find the default PCSX2_ui.ini file. Please manually run and configure PCSX2 first so this file is created with all your default settings.")
  48. }
  49. settingsFile := modulePath . "\" . moduleName . ".ini"
  50.  
  51. ; global settings
  52. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  53. noGUI := IniReadCheck(settingsFile, "Settings", "noGUI","false",,1) ; disables display of the gui while running games
  54. fullboot := IniReadCheck(settingsFile, "Settings", "fullboot","false",,1) ; disables the quick boot feature, forcing you to sit through the PS2 startup splash screens
  55. perGameMemCards := IniReadCheck(settingsFile, "Settings", "PerGameMemoryCards","true",,1)
  56. hideConsole := IniReadCheck(settingsFile, "Settings", "HideConsole","true",,1) ; Hides console window from view if it shows up
  57. cfgPath := IniReadCheck(settingsFile, "Settings", "cfgpath", emuPath . "\Game Configs",,1) ; specifies the config folder; applies to pcsx2 + plugins
  58. autoCreateINIDir := IniReadCheck(settingsFile, "Settings", "AutoCreateINIDir","false",,1) ; Enables the module to auto-create of per game ini files and directories
  59. defaultINISPath := IniReadCheck(settingsFile, "Settings", "DefaultINISPath",,,1) ; Path to default INIS folder of PCSX2.
  60. gs := IniReadCheck(settingsFile, "Settings|" . romName, "gs",,,1) ; override for the GS plugin
  61. pad := IniReadCheck(settingsFile, "Settings|" . romName, "pad",,,1) ; override for the PAD plugin
  62. spu2 := IniReadCheck(settingsFile, "Settings|" . romName, "spu2",,,1) ; override for the SPU2 plugin
  63. cdvd := IniReadCheck(settingsFile, romName, "cdvd",,,1) ; override for the CDVD plugin
  64. usb := IniReadCheck(settingsFile, "Settings|" . romName, "usb",,,1) ; override for the USB plugin
  65. fw := IniReadCheck(settingsFile, "Settings|" . romName, "fw",,,1) ; override for the FW plugin
  66. dev9 := IniReadCheck(settingsFile, "Settings|" . romName, "dev9",,,1) ; override for the DEV9 plugin
  67. vdOveride := IniReadCheck(settingsFile, romName, "VDOveride",,,1)
  68. nohacks := IniReadCheck(settingsFile, romName, "nohacks","false",,1) ; disables all speedhacks
  69. gamefixes := IniReadCheck(settingsFile, romName, "gamefixes",,,1) ; Enable specific gamefixes for this session. Use the specified comma or pipe-delimited list of gamefixes: VuAddSub,VuClipFlag,FpuCompare,FpuMul,FpuNeg,EETiming,SkipMpeg,OPHFlag,DMABusy,VIFFIFO,VI,FMVinSoftware
  70.  
  71. cfgPath := GetFullName(cfgPath)
  72. IfNotExist % cfgPath
  73. FileCreateDir, %cfgPath% ; create the cfg folder if it does not exist
  74.  
  75. ; Create INIs subfolder for the game if it does not exist and if AutoCreateINIDir is true
  76. If (autoCreateINIDir = "true") {
  77. perINIPath := cfgPath . "\" . romName
  78. Log("Module - PerGameIni - perINIPath = " . perINIPath,4)
  79. If !FileExist(perINIPath) {
  80. If (defaultINISPath != "") {
  81. Log("Module - PerGameIni - perINIPath does not exist. So we will create it at " . PerINIPath,4)
  82. FileCreateDir, %perINIPath%
  83. Log("Module - PerGameIni - Now to copy the ini files from " . defaultINISPath . " to " . perINIPath . ".",4)
  84. FileCopy, %defaultINISPath%\*.ini, %perINIPath%
  85. } Else {
  86. Log("Module - PerGameIni - perINIPath does not exist. So we will create it at " . PerINIPath,4)
  87. FileCreateDir, %perINIPath%
  88. Log("Module - PerGameIni - Now to copy the ini files from " . emuPath . "\inis" . " to " . perINIPath . ".",4)
  89. FileCopy, %emuPath%\inis\*.ini, %perINIPath%
  90. }
  91. }
  92. }
  93.  
  94. BezelStart()
  95.  
  96. Fullscreen := If Fullscreen = "true" ? " --fullscreen" : ""
  97. noGUI := If noGUI = "true" ? " --nogui" : ""
  98. If (noGUI != "")
  99. Log("Module - noGUI is set to true, THIS MAY PREVENT PCSX2 FROM CLOSING PROPERLY. If you have any issues, set it to false or default in RocketLauncherUI.",2)
  100. fullboot := If fullboot = "true" ? " --fullboot" : ""
  101. nohacks := If nohacks = "true" ? " --nohacks" : ""
  102. gamefixes := If gamefixes ? " --gamefixes=" . gamefixes : ""
  103. gs := If gs ? " --gs=""" . GetFullName(gs) . """" : ""
  104. pad := If pad ? " --pad=""" . GetFullName(pad) . """" : ""
  105. spu2 := If spu2 ? " --spu2=""" . GetFullName(spu2) . """" : ""
  106. usb := If usb ? " --usb=""" . GetFullName(usb) . """" : ""
  107. fw := If fw ? " --fw=""" . GetFullName(fw) . """" : ""
  108. dev9 := If dev9 ? " --dev9=""" . GetFullName(dev9) . """" : ""
  109.  
  110. cfgRomPath := cfgPath . "\" . romName
  111. cfgPathCLI := If FileExist(cfgRomPath) ? " --cfgpath=""" . GetFullName(cfgRomPath) . """" : ""
  112.  
  113. ; Specify what main ini PCSX2 should use
  114. If (cfgPathCLI && FileExist(cfgRomPath . "\PCSX2_ui.ini")) {
  115. ;We can't set both cfgpath and cfg CLI switches, so if only PCSX2_ui.ini file exists we use cfg otherwise we use cfgpath
  116. ;--cfg specifies a custom configuration file to use instead of PCSX2.ini (does not affect plugins)
  117. filecount := 0
  118. Loop, %cfgRomPath%\*.ini
  119. filecount++
  120. If (filecount == 1)
  121. {
  122. ;Only PCSX2_ui.ini found
  123. pcsx2IniFile := cfgRomPath . "\PCSX2_ui.ini"
  124. Log("Module - Found a game-specific PCSX2_ui.ini in the cfgPath. Telling PCSX2 to use this one instead: " . pcsx2IniFile)
  125. cfg := " --cfg=""" . pcsx2IniFile . """"
  126. cfgPathCLI := ""
  127. }
  128. }
  129. Log("Module - " . (If cfgPathCLI != "" ? "Setting PCSX2's config path to """ . cfgRomPath . """" : "Using PCSX2's default configuration folder: """ . emuPath . "\inis"""))
  130.  
  131. ; Memory Cards
  132. If perGameMemCards = true
  133. { IniRead, currentMemCard1, %pcsx2IniFile%, MemoryCards, Slot1_Filename
  134. IniRead, memCardPath, %pcsx2IniFile%, Folders, MemoryCards ; folder where memory cards are stored
  135. StringLeft, memCardPathLeft, memCardPath, 3
  136. memCardPathIsAbsolute := If (RegExMatch(memCardPathLeft, "[a-zA-Z]:\\") && (StrLen(memCardPath) >= 3)) ; this is 1 only when path looks like this "C:\"
  137. memCardPath := If memCardPathIsAbsolute ? memCardPath : emuPath . "\" . memCardPath ; if only a folder name is defined for the memory card path, tack on the emuPath to find the memory cards, otherwise leave the full path as is
  138. defaultMemCard := memCardPath . "\default.ps2" ; defining default blank memory card for slot 1
  139. Log("Module - Default memory card for Slot 1 should be: " . defaultMemCard,4)
  140. romMemCard1 := memCardPath . "\" . romName . ".ps2" ; defining name for rom's memory card for slot 1
  141. Log("Module - Rom memory card for Slot 1 should be: " . romMemCard1,4)
  142. Log("Module - Current memory card inserted in PCSX2's ini in Slot 1 is: " . currentMemCard1)
  143.  
  144. If (currentMemCard1 != romName . ".ps2") { ; if current memory card in slot 1 does not match this romName, switch to one that does if exist or load a default one
  145. IfNotExist, %romMemCard1% ; first check if romName.ps2 memory card exists
  146. IfNotExist, %defaultMemCard%
  147. Log("Module - A default memory card for Slot 1 was not found in """ . memCardPath . """. Please create an empty memory card called ""default.ps2"" in this folder for per-game memory card support.",3)
  148. Else {
  149. FileCopy, %defaultMemCard%, %romMemCard1% ; create a new blank memory card for this game
  150. Log("Module - Creating a new blank memory card for this game in Slot 1: " . romMemCard1)
  151. }
  152. IniWrite, %romName%.ps2, %pcsx2IniFile%, MemoryCards, Slot1_Filename ; update the ini to use this rom's card
  153. Log("Module - Switched memory card in Slot 1 to: " . romMemCard1)
  154. }
  155. }
  156.  
  157. hideEmuObj := Object("ahk_class wxWindowNR",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  158. 7z(romPath, romName, romExtension, 7zExtractPath)
  159.  
  160. pcsx2Ini := LoadProperties(pcsx2IniFile) ; load the config into memory
  161. dvdSource := ReadProperty(pcsx2Ini,"CdvdSource") ; read value
  162.  
  163. ; Mount the CD using a Virtual Drive
  164. If vdOveride ; this allows per-game Virtual Drive support because some games boot to black when Virtual Drive is enabled
  165. vdEnabled := vdOveride
  166. If (vdEnabled = "true" && InStr(".mds|.mdx|.b5t|.b6t|.bwt|.ccd|.cue|.isz|.nrg|.cdi|.iso|.ape|.flac", romExtension)) { ; if Virtual Drive is enabled and using an image type Virtual Drive can load
  167. If !cdvd {
  168. vdCDVDPlugin := IniReadCheck(settingsFile, "Settings", "VD_CDVD_Plugin",,,1)
  169. If vdCDVDPlugin
  170. cdvd := vdCDVDPlugin
  171. }
  172. cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  173. If dvdSource != Plugin
  174. { Log("Module - CdvdSource was not set to ""Plugin"", changing it so PCSX2 can read from Virtual Drive.")
  175. WriteProperty(pcsx2Ini,"CdvdSource","Plugin") ; write a new value to the pcsx2IniFile
  176. SaveProperties(pcsx2IniFile,pcsx2Ini) ; save pcsx2IniFile to disk
  177. }
  178. VirtualDrive("mount",romPath . "\" . romName . romExtension)
  179. HideEmuStart()
  180. errLvl := Run(executable . " --usecd" . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, emuPath, "UseErrorLevel")
  181. usedVD = 1 ; tell the rest of the script to use VD methods
  182. } Else If romExtension in .iso,.mdf,.nrg,.bin,.img,.gz ; the only formats PCSX2 supports loading directly
  183. {
  184. If !cdvd {
  185. imageCDVDPlugin := IniReadCheck(settingsFile, "Settings", "Image_CDVD_Plugin",,,1)
  186. If imageCDVDPlugin
  187. cdvd := imageCDVDPlugin
  188. }
  189. cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  190. If dvdSource != Iso
  191. { Log("Module - CdvdSource was not set to ""Iso"", changing it so PCSX2 can launch this " . romExtension . " image directly")
  192. WriteProperty(pcsx2Ini,"CdvdSource","Iso") ; write a new value to the pcsx2IniFile
  193. SaveProperties(pcsx2IniFile,pcsx2Ini) ; save pcsx2IniFile to disk
  194. }
  195. HideEmuStart()
  196. errLvl := Run(executable . " """ . romPath . "\" . romName . romExtension . """ " . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, emuPath, "UseErrorLevel")
  197. } Else If romExtension in .bz2 ; special case format that requires plugin mode and pcsx2 loads it directly
  198. {
  199. If !cdvd {
  200. linuzCDVDPlugin := IniReadCheck(settingsFile, "Settings", "Linuz_CDVD_Plugin",,,1)
  201. If linuzCDVDPlugin
  202. cdvd := linuzCDVDPlugin
  203. }
  204. cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  205. If dvdSource != plugin
  206. { Log("Module - CdvdSource was not set to ""Plugin"", changing it so PCSX2 can launch this " . romExtension . " image directly")
  207. WriteProperty(pcsx2Ini,"CdvdSource","Plugin") ; write a new value to the pcsx2IniFile
  208. SaveProperties(pcsx2IniFile,pcsx2Ini) ; save pcsx2IniFile to disk
  209. }
  210. oldHex := ReadReg("IsoFile") ; read last used bz2 image
  211. newHex := StrToHex(romPath . "\" . romName . romExtension) ; convert new bz2 image path to hex
  212. i := 512 - StrLen(newHex) ; get total amount of 0's to add to end of hex to make it 512 bytes
  213. Loop, %i%
  214. newHex := newHex . "0" ; add required bytes to end
  215. If (oldHex != newHex) {
  216. Log("Module - Writing new bz2 path to registry",4)
  217. WriteReg("IsoFile", newHex) ; write new bz2 path to registry
  218. }
  219. HideEmuStart()
  220. errLvl := Run(executable . " """ . romPath . "\" . romName . romExtension . """ " . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, emuPath, "UseErrorLevel")
  221. } Else
  222. ScriptError("You are trying to run a rom type of """ . romExtension . """ but PCSX2 only supports loading iso|mdf|nrg|bin|img|gz directly. Please turn on Virtual Drive and/or 7z support or put ""cue"" last in your rom extensions for " . MEmu . " instead.")
  223.  
  224. If errLvl
  225. ScriptError("Error launching emulator, closing script.")
  226.  
  227. WinWait("ahk_class wxWindowNR",,, "PCSX2")
  228. WinWaitActive("ahk_class wxWindowNR",,, "PCSX2")
  229.  
  230. BezelDraw()
  231.  
  232. If hideConsole = true
  233. SetTimer, HideConsole, 10
  234.  
  235. SetTitleMatchMode 2 ;Wrong window might be detected in the next loop if we only use the class name for WinGetTitle so we will add fps to it
  236. Loop { ; looping until pcsx2 is done loading game
  237. Sleep, 200
  238. WinGetTitle, winTitle, Speed ahk_class wxWindowNR,, PCSX2 ; excluding the title of the GUI window so we can read the title of the game window instead
  239. Log("Detected Window Title is " . winTitle,4)
  240. RegExMatch(winTitle,"(?<=\().*(?=\))",winText) ; only get value between parenthesis
  241. If (winText > 0) ; if FPS shows any value, break out
  242. Break
  243. If A_Index > 150 ; after 30 seconds, error out
  244. ScriptError("There was an error detecting when PCSX2 finished loading your game. Please report this so the module can be fixed.")
  245.  
  246. ; StringSplit, winTextSplit, winTitle, |, %A_Space%
  247. ; If (winTextSplit10 != "") ; 10th position in the array is empty until game actually starts
  248. ; Break
  249. ; tipText:=
  250. ; Loop % winTextSplit0
  251. ; tipText .= "`nposition " . A_Index . ": " . winTextSplit%A_Index%
  252. ; ToolTip, % "Loop: " . A_Index . "`ntitle: " . winTitle . "`ntext: " . winText . tipText,0,0
  253. }
  254.  
  255. HideEmuEnd()
  256. FadeInExit()
  257. Process("WaitClose", executable)
  258.  
  259. If usedVD
  260. VirtualDrive("unmount")
  261.  
  262. 7zCleanUp()
  263. BezelExit()
  264. FadeOutExit()
  265. ExitModule()
  266.  
  267.  
  268. ReadReg(var1) {
  269. regValue := RegRead("HKEY_CURRENT_USER", "Software\PS2Eplugin\CDVD\CDVDiso", var1)
  270. Return %regValue%
  271. }
  272.  
  273. WriteReg(var1, var2, ValueType="REG_BINARY") {
  274. RegWrite(ValueType, "HKEY_CURRENT_USER", "Software\PS2Eplugin\CDVD\CDVDiso", var1, var2)
  275. }
  276.  
  277. StrToHex(S) {
  278. Return S="" ? "":Chr((*&S>>4)+48) Chr((x:=*&S&15)+48+(x>9)*7) StrToHex(SubStr(S,2))
  279. }
  280.  
  281. MultiGame:
  282. ; msgbox % "selectedRom = " . selectedRom . "`nselected game = " . currentButton . "`nmgRomPath = " . mgRomPath . "`nmgRomExt = " . mgRomExt . "`nmgRomName = " . mgRomName
  283. ; Unmount the CD from Virtual Drive
  284. If usedVD
  285. VirtualDrive("unmount")
  286. Sleep, 500 ; Required to prevent your Virtual Drive from bugging
  287. ; Mount the CD using Virtual Drive
  288. If usedVD
  289. VirtualDrive("mount",selectedRom)
  290. Return
  291.  
  292. HideConsole:
  293. hideConsoleTimer++
  294. IfWinExist, Booting ahk_class wxWindowNR
  295. { Log("Module - HideConsole - Console window found, hiding it out of view.")
  296. WinSet, Transparent, 0, Booting ahk_class wxWindowNR,,fps:,fps: ; hiding the console window
  297. WinSet, Transparent, 0, PCSX2 ahk_class wxWindowNR,,fps:,fps: ; hiding the GUI window with the menubar
  298. SetTimer, HideConsole, Off
  299. } Else If hideConsoleTimer >= 200
  300. SetTimer, HideConsole, Off
  301. Return
  302.  
  303. CloseProcess:
  304. FadeOutStart()
  305. WinMenuSelectItem, PCSX2 ahk_class wxWindowNR,, System, Pause
  306. WinClose("PCSX2 ahk_class wxWindowNR") ; sending command to the GUI window to properly close the entire emu
  307. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement