djvj

pcsx2 test

Apr 21st, 2022 (edited)
2,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MEmu := "PCSX2"
  2. MEmuV := "1.7.2864"
  3. MURL := ["http://pcsx2.net/"]
  4. MAuthor := ["djvj"]
  5. MVersion := "2.3.1"
  6. MCRC := ""
  7. iCRC := ""
  8. MID := ""
  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. ; If the incorrect drive is used, the emu will boot to the bios screen and emu will hang in your running processes on exit and require it to be force closed
  17. ; Module will set the CdvdSource to Plugin or Iso depending on if you have Virtual Drive enabled or not.
  18. ; If you have any problems closing the emulator, make sure noGUI module setting in RocketLauncherUI is set to default or false.
  19. ; Most stable bios is Japan v01.00(17/01/2000)
  20. ;
  21. ; Per-game memory cards
  22. ; This module supports per-game memory cards to prevent them from ever becoming full
  23. ; To use this feature, set the PerGameMemoryCards to true in RocketLauncherUI
  24. ; 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.
  25. ; 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.
  26. ; The module will only insert memory cards into Slot 1. So save your games there.
  27. ;
  28. ; Linuz cdvd plugin stores its settings in the registry @ HKEY_CURRENT_USER\Software\PS2Eplugin\CDVD\CDVDiso
  29. ;
  30. ; v1.4.0 setup guide: https://www.youtube.com/watch?v=ovagz8UXFTU
  31. ;
  32. ; Latest CLI options can be found here https://wiki.pcsx2.net/Command-line_support
  33. ; Run pcsx2 with the --help option to see current CLI parameters
  34. ; Known CLI options not currently supported by this module:
  35. ;  --console            forces the program log/console to be visible
  36. ;  --portable           enables portable mode operation (requires admin/root access)
  37. ;  --elf=<str>          executes an ELF image
  38. ;  --forcewiz           forces PCSX2 to start the First-time Wizard
  39. ;----------------------------------------------------------------------------
  40. StartModule()
  41. BezelGUI()
  42. FadeInStart()
  43.  
  44. If StringUtils.InStr(executable,"qt") {
  45.     emuGUI := "qt"  ; QT
  46.     RLLog.Info("Module - Using PCSX2 QT UI")
  47. } Else {
  48.     emuGUI := "wx"  ; wxWidgets
  49.     RLLog.Info("Module - Using PCSX2 wxWidgets UI")
  50. }  
  51.  
  52. primaryExe := new Emulator(emuPath . "\" . executable)              ; instantiate emulator executable object
  53.  
  54. If (emuGUI = "qt") {
  55.     emuPrimaryWindow := new Window(new WindowTitle(,"Qt630QWindowIcon"),,,"PCSX2")  ; instantiate primary emulator window object
  56.     emuGUIWindow := new Window(new WindowTitle("PCSX2","Qt630QWindowIcon"))
  57.     emuLoadingWindow := new Window(new WindowTitle("Speed","Qt630QWindowIcon"),,"PCSX2") ;  "Speed" stats never appear in the title like the wx version has
  58.     ; emuBootingWindow := new Window(new WindowTitle("Booting","Qt630QWindowIcon"))
  59. } Else {
  60.     emuPrimaryWindow := new Window(new WindowTitle(,"wxWindowNR"),,,"PCSX2")    ; instantiate primary emulator window object
  61.     emuGUIWindow := new Window(new WindowTitle("PCSX2","wxWindowNR"))
  62.     emuLoadingWindow := new Window(new WindowTitle("Speed","wxWindowNR"),,"PCSX2")
  63.     emuBootingWindow := new Window(new WindowTitle("Booting","wxWindowNR"))
  64. }
  65.  
  66.  
  67. Fullscreen := moduleIni.Read("Settings", "Fullscreen","true",,1)
  68. AspectRatio := moduleIni.Read(romName . "|Settings", "AspectRatio","4:3",,1)
  69. noGUI := moduleIni.Read("Settings", "noGUI","false",,1) ; disables display of the gui while running games
  70. perGameMemCards := moduleIni.Read("Settings", "PerGameMemoryCards","false",,1)
  71. hideConsole := moduleIni.Read("Settings", "HideConsole","true",,1)  ; Hides console window from view if it shows up
  72. cfgPath := moduleIni.Read("Settings", "cfgpath", emuPath . "\Game Configs",,1)  ; specifies the config folder; applies to pcsx2 + plugins
  73. autoCreateINIDir := moduleIni.Read("Settings", "AutoCreateINIDir","false",,1)  ; Enables the module to auto-create of per game ini files and directories
  74. defaultINISPath := moduleIni.Read("Settings", "DefaultINISPath",,,1)  ; Path to default INIS folder of PCSX2.
  75. fullboot := moduleIni.Read(romName . "|Settings", "fullboot","false",,1)    ; disables the quick boot feature, forcing you to sit through the PS2 startup splash screens
  76. gs := moduleIni.Read(romName . "|Settings", "gs",,,1)   ; override for the GS plugin
  77. pad := moduleIni.Read(romName . "|Settings", "pad",,,1) ; override for the PAD plugin
  78. spu2 := moduleIni.Read(romName . "|Settings", "spu2",,,1)   ; override for the SPU2 plugin
  79. cdvd := moduleIni.Read(romName, "cdvd",,,1) ; override for the CDVD plugin
  80. usb := moduleIni.Read(romName . "|Settings", "usb",,,1) ; override for the USB plugin
  81. fw := moduleIni.Read(romName . "|Settings", "fw",,,1)   ; override for the FW plugin
  82. dev9 := moduleIni.Read(romName . "|Settings", "dev9",,,1)   ; override for the DEV9 plugin
  83. vdOveride := moduleIni.Read(romName, "VDOveride",,,1)
  84. nohacks := moduleIni.Read(romName, "nohacks","false",,1)    ; disables all speedhacks
  85. gamefixes := moduleIni.Read(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
  86.  
  87. ; GS plugin settings, primarily to fix upscaling issues in games. Game specific settings can be found here: http://www.neogaf.com/forum/showpost.php?p=27110555&postcount=2
  88. ; userHacks_MSAA := If moduleIni.Read(romName, "MSAA",0,,1) ; Applies hardware anti-aliasing
  89. userHacks_SkipDraw := moduleIni.Read(romName, "Skipdraw",0,,1)  ; Can remove ghost images
  90. userHacks_HalfPixelOffset := If moduleIni.Read(romName, "Half-pixel_Offset",0,,1)   ; Fixes blur or halo effects
  91. userHacks_WildHack := If moduleIni.Read(romName, "Wild_Arms_Offset",0,,1)   ; Fixes fonts in many games
  92. ; userHacks_unsafe_fbmask := If moduleIni.Read(romName, "Fast_Accurate_Blending",0,,1)  ; Accelerates blending operations, speeds up Xenosaga
  93. ; userHacks_AlphaStencil := If moduleIni.Read(romName, "Alpha_Stencil",0,,1)    ; May improve drawing shadows
  94. userHacks_align_sprite_X := If moduleIni.Read(romName, "Align_Sprite",0,,1) ; Fixes issues with vertical lines in Ace Combat, Tekken, Soul Calibur
  95. ; userHacks_AlphaHack := If moduleIni.Read(romName, "Alpha",0,,1)   ; Improves drawing fog-like effects
  96. ; preload_frame_with_gs_data := If moduleIni.Read(romName, "Preload_Data_Frame",0,,1)   ; Fixes black screen issues in Armored Core: Last Raven
  97. userHacks_round_sprite_offset := moduleIni.Read(romName, "Round_Sprite",0,,1)   ; Fixes lines in sprites in Ar tonelico
  98. ; userHacks_SpriteHack := moduleIni.Read(romName, "Sprite",0,,1)    ; Fixes inner lines in sprites in Mana Khemia, Ar tonelico, Tales of Destiny
  99. userHacks_TCOffsetX := moduleIni.Read(romName, "TC_OffsetX",0,,1)   ; Fixes misaligned textures in Persona 3, Haunting Ground, Xenosaga
  100. userHacks_TCOffsetY := moduleIni.Read(romName, "TC_OffsetY",0,,1)   ; Fixes misaligned textures in Persona 3, Haunting Ground, Xenosaga
  101. ; Set the userHacks variable to 1 if any of the hacks are used.
  102. userHacks := If (userHacks_MSAA || userHacks_SkipDraw || userHacks_HalfPixelOffset || userHacks_WildHack || userHacks_unsafe_fbmask || userHacks_AlphaStencil || userHacks_align_sprite_X || userHacks_AlphaHack || preload_frame_with_gs_data || userHacks_round_sprite_offset || userHacks_SpriteHack || userHacks_TCOffset) ? 1 : ""
  103.  
  104. cfgPath := new Folder(GetFullName(cfgPath))
  105. If !cfgPath.Exist()
  106.     cfgPath.CreateDir() ; create the cfg folder if it does not exist
  107.  
  108. ; PCSX2_ui.ini = default ini that contains memory card info and general settings
  109. portableIni := new File(emuPath . "\portable.ini")
  110. If portableIni.Exist() {    ; portable install
  111.     RLLog.Info("Module - PCSX2 is operating in a portable mode")
  112.     pcsx2IniFolder := emuPath . "\inis"
  113.     pcsx2_GS_IniFile := CheckFile(pcsx2IniFolder . "\GS.ini", "Could not find the default GS.ini file. Please manually run and configure PCSX2 first so this file is created with all your default settings.")
  114. } Else {    ; default not portable install
  115.     RLLog.Info("Module - PCSX2 is operating in a standard installation mode")
  116.     pcsx2IniFolder := Registry.Read("HKCU", "Software\PCSX2", "SettingsFolder")
  117. }
  118. pcsx2Ini := new IniFile(pcsx2IniFolder . "\PCSX2_ui.ini")
  119. pcsx2Ini.CheckFile("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.")
  120. pcsx2GSIni := new IniFile(pcsx2IniFolder . "\GS.ini")
  121. pcsx2GSIni.CheckFile("Could not find the default GS.ini file. Please manually run and configure PCSX2 first so this file is created with all your default settings.")
  122. pcsx2IniFolder := new Folder(pcsx2IniFolder)
  123.  
  124. ; Create INIs subfolder for the game if it does not exist and if AutoCreateINIDir is true
  125. perGameINIPath := new Folder(cfgPath.FileFullPath . "\" . romName)
  126. If (autoCreateINIDir = "true") {
  127.     RLLog.Info("Module - PerGameIni - perGameINIPath = " . perGameINIPath.FileFullPath)
  128.     If !perGameINIPath.Exist() {
  129.         perGameINIPath.CreateDir()
  130.         If (defaultINISPath != "") {
  131.             defaultINISPath := new Folder(defaultINISPath)
  132.             RLLog.Info("Module - PerGameIni - perGameINIPath does not exist.  So we will create it at " . perGameINIPath.FileFullPath)
  133.             RLLog.Info("Module - PerGameIni - Now copying the ini files from " . defaultINISPath.FileFullPath . " to " . perGameINIPath.FileFullPath)
  134.             defaultINISPath.Copy(perGameINIPath.FileFullPath,0,"\*.ini")
  135.         } Else {
  136.             RLLog.Info("Module - PerGameIni - perGameINIPath does not exist.  So we will create it at " . perGameINIPath.FileFullPath)
  137.             RLLog.Info("Module - PerGameIni - Now copying the ini files from " . pcsx2IniFolder.FileFullPath . " to " . perGameINIPath.FileFullPath)
  138.             pcsx2IniFolder.Copy(perGameINIPath.FileFullPath,0,"\*.ini")
  139.         }
  140.     }
  141. }
  142.  
  143. BezelStart()
  144.  
  145. If (emuGUI = "qt") {
  146.     Fullscreen := If Fullscreen = "true" ? " -fullscreen" : ""
  147.     noGUI := ""
  148.     fullboot := ""
  149.     nohacks := ""
  150.     gamefixes := ""
  151. } Else {
  152.     Fullscreen := If Fullscreen = "true" ? " --fullscreen" : ""
  153.     noGUI := If noGUI = "true" ? " --nogui" : ""
  154.     If (noGUI != "")
  155.         RLLog.Warning("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.")
  156.     fullboot := If fullboot = "true" ? " --fullboot" : ""
  157.     nohacks := If nohacks = "true" ? " --nohacks" : ""
  158.     gamefixes := If gamefixes ? " --gamefixes=" . gamefixes : ""
  159. }
  160.  
  161. ; THESE WERE REMOVED IN V1.7.0
  162. ; gs := If gs ? " --gs=""" . GetFullName(gs) . """" : ""
  163. ; pad := If pad ? " --pad=""" . GetFullName(pad) . """" : ""
  164. ; spu2 := If spu2 ? " --spu2=""" . GetFullName(spu2) . """" : ""
  165. ; usb := If usb ? " --usb=""" . GetFullName(usb) . """" : ""
  166. ; fw := If fw ? " --fw=""" . GetFullName(fw) . """" : ""
  167. ; dev9 := If dev9 ? " --dev9=""" . GetFullName(dev9) . """" : ""
  168. gs := ""
  169. pad := ""
  170. spu2 := ""
  171. usb := ""
  172. fw := ""
  173. dev9 := ""
  174.  
  175.  
  176. ; cfgRomPath := new File(cfgPath . "\" . romName)
  177. cfgPathCLI := If perGameINIPath.Exist() ? " --cfgpath=""" . perGameINIPath.FileFullPath . """" : ""
  178.  
  179. ; Specify what main ini PCSX2 should use
  180. pcsx2GameIni := new File(perGameINIPath.FileFullPath . "\PCSX2_ui.ini")
  181. If (cfgPathCLI && pcsx2GameIni.Exist()) {
  182.     ;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
  183.     ;--cfg specifies a custom configuration file to use instead of PCSX2.ini (does not affect plugins)
  184.     filecount := 0
  185.     Loop % perGameINIPath.FileFullPath . "\*.ini"
  186.         filecount++
  187.     If (filecount = 1)
  188.     {
  189.         ;Only PCSX2_ui.ini found
  190.         pcsx2IniFile := pcsx2GameIni
  191.         RLLog.Info("Module - Found a game-specific PCSX2_ui.ini in the cfgPath. Telling PCSX2 to use this one instead: " . pcsx2IniFile.FileFullPath)
  192.         cfg := " --cfg=""" . pcsx2IniFile.FileFullPath . """"
  193.         cfgPathCLI := ""
  194.     }
  195. }
  196. RLLog.Info("Module - " . (If cfgPathCLI != "" ? "Setting PCSX2's config path to """ . perGameINIPath.FileFullPath . """" : "Using PCSX2's default configuration folder: """ . pcsx2IniFolder.FileFullPath . """"))
  197.  
  198. ; Update the aspect ratio if the user selected one.
  199. If AspectRatio {
  200.     pcsx2Ini.Write(AspectRatio, "GSWindow", "AspectRatio")  ; Write the aspect ratio value to the pcsx2Ini.
  201. }
  202.  
  203. ; Update the GS plugin settings if hacks were selected.
  204. If userHacks {
  205.     RLLog.Info("Module - UserHacks are being used. Updating GSdx.ini")
  206.     pcsx2GSIni.Write(userHacks, "Settings", "UserHacks")
  207.     ; pcsx2GSIni.Write(userHacks_MSAA, "Settings", "UserHacks_MSAA")
  208.     pcsx2GSIni.Write(userHacks_SkipDraw, "Settings", "UserHacks_SkipDraw")
  209.     pcsx2GSIni.Write(userHacks_HalfPixelOffset, "Settings", "UserHacks_HalfPixelOffset")
  210.     pcsx2GSIni.Write(userHacks_WildHack, "Settings", "UserHacks_WildHack")
  211.     ; pcsx2GSIni.Write(userHacks_unsafe_fbmask, "Settings", "UserHacks_unsafe_fbmask")
  212.     ; pcsx2GSIni.Write(userHacks_AlphaStencil, "Settings", "UserHacks_AlphaStencil")
  213.     pcsx2GSIni.Write(userHacks_align_sprite_X, "Settings", "UserHacks_align_sprite_X")
  214.     ; pcsx2GSIni.Write(userHacks_AlphaHack, "Settings", "UserHacks_AlphaHack")
  215.     ; pcsx2GSIni.Write(preload_frame_with_gs_data, "Settings", "preload_frame_with_gs_data")
  216.     pcsx2GSIni.Write(userHacks_round_sprite_offset, "Settings", "UserHacks_round_sprite_offset")
  217.     ; pcsx2GSIni.Write(userHacks_SpriteHack, "Settings", "UserHacks_SpriteHack")
  218.     pcsx2GSIni.Write(userHacks_TCOffsetX, "Settings", "UserHacks_TCOffsetX")
  219.     pcsx2GSIni.Write(userHacks_TCOffsetY, "Settings", "UserHacks_TCOffsetY")
  220. } Else {
  221.     ; Make sure hacks are disabled.
  222.     pcsx2GSIni.Write(UserHacks, "Settings", "UserHacks")
  223. }
  224.  
  225. ; Memory Cards
  226. If (perGameMemCards = "true")
  227. {   currentMemCard1 := pcsx2Ini.Read("MemoryCards", "Slot1_Filename")
  228.     memCardPath := pcsx2Ini.Read("Folders", "MemoryCards")  ; folder where memory cards are stored
  229.     memCardPathLeft := StringUtils.SubStr(memCardPath,1,3)  ; get left 3 characters
  230.     memCardPathIsAbsolute := If (StringUtils.RegExMatch(memCardPathLeft, "[a-zA-Z]:\\") && (StringUtils.StringLength(memCardPath) >= 3))    ; this is 1 only when path looks like this "C:\"
  231.     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
  232.     defaultMemCard := new File(memCardPath . "\default.ps2")    ; defining default blank memory card for slot 1
  233.     RLLog.Info("Module - Default memory card for Slot 1 should be: " . defaultMemCard.FileFullPath)
  234.     romMemCard1 := new File(memCardPath . "\" . romName . ".ps2")   ; defining name for rom's memory card for slot 1
  235.     RLLog.Info("Module - Rom memory card for Slot 1 should be: " . romMemCard1.FileFullPath)
  236.     RLLog.Info("Module - Current memory card inserted in PCSX2's ini in Slot 1 is: " . currentMemCard1.FileFullPath)
  237.  
  238.     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
  239.         If !romMemCard1.Exist() ; first check if romName.ps2 memory card exists
  240.             If !defaultMemCard.Exist()
  241.                 RLLog.Error("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.")
  242.             Else {
  243.                 defaultMemCard.Copy(romMemCard1.FileFullPath)   ; create a new blank memory card for this game
  244.                 RLLog.Info("Module - Creating a new blank memory card for this game in Slot 1: " . romMemCard1.FileFullPath)
  245.             }
  246.         pcsx2Ini.Write(romName . ".ps2", "MemoryCards", "Slot1_Filename")   ; update the ini to use this rom's card
  247.         RLLog.Info("Module - Switched memory card in Slot 1 to: " . romMemCard1.FileFullPath)
  248.     }
  249. }
  250.  
  251. hideEmuObj := Object(emuBootingWindow,0,emuGUIWindow,0,emuPrimaryWindow,1)
  252. 7z(romPath, romName, romExtension, SevenZExtractPath)
  253.  
  254. pcsx2Ini := LoadProperties(pcsx2IniFile.FileFullPath)   ; load the config into memory
  255. dvdSource := ReadProperty(pcsx2Ini,"CdvdSource")    ; read value
  256.  
  257. If (vdEnabled != "true" && romExtension = ".cue") {
  258.     RLLog.Warning("Module - Virtual Drive is disabled but you supplied a .cue as your rom which is not supported by PCSX2")
  259.     pcsx2GameBin := new File(romPath . "\" . romName . ".bin")
  260.     pcsx2GameIso := new File(romPath . "\" . romName . ".iso")
  261.     If pcsx2GameBin.Exist() {
  262.         romExtension := ".bin"
  263.         RLLog.Warning("Module - Found a .bin file with the same name as your cue, using it instead. Please change the order of your rom extensions if you want bins to be found first.")
  264.     } Else If pcsx2GameIso.Exist() {
  265.         romExtension := ".iso"
  266.         RLLog.Warning("Module - Found a .iso file with the same name as your cue, using it instead. Please change the order of your rom extensions if you want isos to be found first.")
  267.     }
  268. }
  269.  
  270. ; Mount the CD using a Virtual Drive
  271. If vdOveride    ; this allows per-game Virtual Drive support because some games boot to black when Virtual Drive is enabled
  272.     vdEnabled := vdOveride
  273. If (vdEnabled = "true" && StringUtils.Contains(romExtension,"\.mds|\.mdx|\.b5t|\.b6t|\.bwt|\.ccd|\.cue|\.isz|\.nrg|\.cdi|\.iso|\.ape|\.flac")) {    ; if Virtual Drive is enabled and using an image type Virtual Drive can load
  274.     If !cdvd {
  275.         vdCDVDPlugin := moduleIni.Read("Settings", "VD_CDVD_Plugin",,,1)
  276.         If vdCDVDPlugin
  277.             cdvd := vdCDVDPlugin
  278.     }
  279.     cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  280.     If (dvdSource != "Plugin")
  281.     {   RLLog.Info("Module - CdvdSource was not set to ""Plugin"", changing it so PCSX2 can read from Virtual Drive.")
  282.         WriteProperty(pcsx2Ini,"CdvdSource","Plugin")   ; write a new value to the pcsx2IniFile
  283.         SaveProperties(pcsx2IniFile.FileFullPath,pcsx2Ini)  ; save pcsx2IniFile to disk
  284.     }
  285.    
  286.     pcsx2cdvdIni := new IniFile(pcsx2IniFolder . "\cdvdGigaherz.ini")
  287.     dvdDrive := pcsx2cdvdIni.Read("Config", "Source")   ; cdvd drive
  288.     If StringUtils.InStr(dvdDrive,"@") {
  289.         If (vdDriveLetter != "")
  290.             pcsx2cdvdIni.Write(vdDriveLetter, "Config", "Source")
  291.         Else
  292.             ScriptError("You are using a Virtual Drive but have not selected the drive you want to use in PCSX2 CDVD Plugin settings. Select your drive first, either in RLUI Virtual Drive Third Party Settings or within the PCSX2's plugin settings, then try launching again.")
  293.     } Else If (dvdDrive != vdDriveLetter) {
  294.         RLLog.Warning("Module - PCSX2 is set to use drive """ . dvdDrive . """ but RocketLauncher is set to use """ . vdDriveLetter . """. Ignore this warning if this is expected.")
  295.     }
  296.     VirtualDrive("mount",romPath . "\" . romName . romExtension)
  297.     HideAppStart(hideEmuObj,hideEmu)
  298.     errLvl := primaryExe.Run(" --usecd" . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, "UseErrorLevel")
  299.     usedVD := 1 ; tell the rest of the script to use VD methods
  300. } Else If StringUtils.Contains(romExtension,"\.iso|\.mdf|\.nrg|\.bin|\.img|\.chd|\.gz|\.cso|\.dump")    ; the only formats PCSX2 supports loading directly
  301. {
  302.     If !cdvd {
  303.         imageCDVDPlugin := moduleIni.Read("Settings", "Image_CDVD_Plugin",,,1)
  304.         If imageCDVDPlugin
  305.             cdvd := imageCDVDPlugin
  306.     }
  307.     cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  308.     If (dvdSource != "Iso")
  309.     {   RLLog.Info("Module - CdvdSource was not set to ""Iso"", changing it so PCSX2 can launch this " . romExtension . " image directly")
  310.         WriteProperty(pcsx2Ini,"CdvdSource","Iso")  ; write a new value to the pcsx2IniFile
  311.         SaveProperties(pcsx2IniFile.FileFullPath,pcsx2Ini)  ; save pcsx2IniFile to disk
  312.     }
  313.     HideAppStart(hideEmuObj,hideEmu)
  314.     errLvl := primaryExe.Run(" """ . romPath . "\" . romName . romExtension . """ " . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, "UseErrorLevel")
  315. } Else If StringUtils.Contains(romExtension,"\.bz2")    ; special case format that requires plugin mode and pcsx2 loads it directly
  316. {
  317.     If !cdvd {
  318.         linuzCDVDPlugin := moduleIni.Read("Settings", "Linuz_CDVD_Plugin",,,1)
  319.         If linuzCDVDPlugin
  320.             cdvd := linuzCDVDPlugin
  321.     }
  322.     cdvd := If cdvd ? " --cdvd=""" . GetFullName(cdvd) . """" : ""
  323.     If (dvdSource != "plugin")
  324.     {   RLLog.Info("Module - CdvdSource was not set to ""Plugin"", changing it so PCSX2 can launch this " . romExtension . " image directly")
  325.         WriteProperty(pcsx2Ini,"CdvdSource","Plugin")   ; write a new value to the pcsx2IniFile
  326.         SaveProperties(pcsx2IniFile.FileFullPath,pcsx2Ini)  ; save pcsx2IniFile to disk
  327.     }
  328.     oldHex := Registry.Read("HKEY_CURRENT_USER", "Software\PS2Eplugin\CDVD\CDVDiso", "IsoFile") ; read last used bz2 image
  329.     newHex := StringUtils.StringToHex(romPath . "\" . romName . romExtension)   ; convert new bz2 image path to hex
  330.     i := 512 - StringUtils.StringLength(newHex) ; get total amount of 0's to add to end of hex to make it 512 bytes
  331.     Loop % i
  332.         newHex := newHex . "0"  ; add required bytes to end
  333.     If (oldHex != newHex) {
  334.         RLLog.Info("Module - Writing new bz2 path to registry")
  335.         Registry.Write("REG_BINARY", "HKEY_CURRENT_USER", "Software\PS2Eplugin\CDVD\CDVDiso", "IsoFile", newHex)    ; write new bz2 path to registry
  336.     }
  337.     HideAppStart(hideEmuObj,hideEmu)
  338.     errLvl := primaryExe.Run(" """ . romPath . "\" . romName . romExtension . """ " . noGUI . Fullscreen . fullboot . nohacks . gamefixes . cfg . cfgPathCLI . gs . pad . spu2 . cdvd . usb . fw . dev9, "UseErrorLevel")
  339. } Else
  340.     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.")
  341.  
  342. If errLvl
  343.     ScriptError("Error launching emulator, closing script.")
  344.  
  345. emuPrimaryWindow.Wait()
  346. emuPrimaryWindow.WaitActive()
  347.  
  348. BezelDraw()
  349.  
  350. ; If (hideConsole = "true") {   ; should not be needed anymore
  351.     ; TimerUtils.SetTimerF("HidePCSX2Console", 10)
  352.     ; SetTimerF("HidePCSX2Console", 10)
  353.     ; emuBootingWindow.Set("Transparent",0) ; ,"Booting ahk_class wxWindowNR",,"fps:","fps:")   ; hiding the console window
  354.     ; emuGUIWindow.Set("Transparent",0) ;,"PCSX2 ahk_class wxWindowNR",,"fps:","fps:")  ; hiding the GUI window with the menubar
  355. ; }
  356.  
  357. 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
  358. Loop { ; Looping until pcsx2 is done loading game
  359.     Sleep, 200
  360.     loopWinTitle := emuLoadingWindow.GetTitle(0) ; Excluding the title of the GUI window so we can read the title of the game window instead
  361.     StringUtils.RegExMatch(loopWinTitle,"(?<=\()(.*?)(?=\))",winText) ;,1,0)    ; Only get value between parenthesis
  362.     If (winText > 0) {  ; If FPS shows any value, break out
  363.         RLLog.Debug("Module - Game is now running, waiting for exit")
  364.         Break
  365.     }
  366.     If A_Index > 150    ; After 30 seconds, error out
  367.         ScriptError("There was an error detecting when PCSX2 finished loading your game. Please report this so the module can be fixed.")
  368.  
  369.     ; Old method here in case devs change something back
  370.     ; StringSplit, winTextSplit, winTitle, |, %A_Space%
  371.     ; If (winTextSplit10 != "") ; 10th position in the array is empty until game actually starts
  372.         ; Break
  373.     ; tipText:=
  374.     ; Loop % winTextSplit0
  375.         ; tipText .= "`nposition " . A_Index . ": " . winTextSplit%A_Index%
  376.     ; ToolTip, % "Loop: " . A_Index . "`ntitle: " . winTitle . "`ntext: " . winText . tipText,0,0
  377. }
  378.  
  379. HideAppEnd(hideEmuObj,hideEmu)
  380. FadeInExit()
  381. primaryExe.Process("WaitClose")
  382.  
  383. If usedVD
  384.     VirtualDrive("unmount")
  385.  
  386. 7zCleanUp()
  387. BezelExit()
  388. FadeOutExit()
  389. ExitModule()
  390.  
  391.  
  392. MultiGame:
  393.     ; msgbox % "selectedRom = " . selectedRom . "`nselected game = " . currentButton . "`nmgRomPath = " . mgRomPath . "`nmgRomExt = " . mgRomExt . "`nmgRomName = "  . mgRomName
  394.     ; Unmount the CD from Virtual Drive
  395.     If usedVD
  396.         VirtualDrive("unmount")
  397.     Sleep, 500  ; Required to prevent your Virtual Drive from bugging
  398.     ; Mount the CD using Virtual Drive
  399.     If usedVD
  400.         VirtualDrive("mount",selectedRom)
  401. Return
  402.  
  403. ; HidePCSX2Console:
  404.     ; hideConsoleTimer++
  405.     ; If emuBootingWindow.Exist()
  406.     ; { RLLog.Info("Module - HidePCSX2Console - Console window found, hiding it out of view.")
  407.         ; emuBootingWindow.Set("Transparent",0) ; ,"Booting ahk_class wxWindowNR",,"fps:","fps:")   ; hiding the console window
  408.         ; emuGUIWindow.Set("Transparent",0) ; ,"PCSX2 ahk_class wxWindowNR",,"fps:","fps:") ; hiding the GUI window with the menubar
  409.         ; SetTimer("HidePCSX2Console", "Off")
  410.     ; } Else If (hideConsoleTimer >= 200)
  411.         ; SetTimer("HidePCSX2Console", "Off")
  412. ; Return
  413. ; HidePCSX2Console() {
  414.     ; Static hideConsoleTimer
  415.     ; hideConsoleTimer++
  416.     ; If emuBootingWindow.Exist()
  417.     ; { RLLog.Info("Module - HidePCSX2Console - Console window found, hiding it out of view.")
  418.         ; emuBootingWindow.Set("Transparent",0) ; ,"Booting ahk_class wxWindowNR",,"fps:","fps:")   ; hiding the console window
  419.         ; emuGUIWindow.Set("Transparent",0) ; ,"PCSX2 ahk_class wxWindowNR",,"fps:","fps:") ; hiding the GUI window with the menubar
  420.         ; TimerUtils.SetTimerF("HidePCSX2Console", "Off")
  421.     ; } Else If (hideConsoleTimer >= 200)
  422.         ; TimerUtils.SetTimerF("HidePCSX2Console", "Off")
  423. ; }
  424.  
  425. CloseProcess:
  426.     FadeOutStart()
  427.     If (fullscreen = "true") {
  428.         ; emuPrimaryWindow.CreateControl("wxWindowNR1")     ; instantiate new control for wxWindowNR1
  429.         ; emuPrimaryWindow.GetControl("wxWindowNR1").Send("Esc")    ; Send ESC to the main window when fullscreen is true to close the emu
  430.         emuPrimaryWindow.Close()
  431.     } Else {
  432.         emuGUIWindow.MenuSelectItem("System","Pause")
  433.         emuGUIWindow.Close()
  434.     }
  435. Return
  436.  
Add Comment
Please, Sign In to add comment