rfancella

ePSXe.ahk

Mar 9th, 2015
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.72 KB | None | 0 0
  1. MEmu = ePSXe
  2. MEmuV = v1.9.0
  3. MURL = http://www.epsxe.com/
  4. MAuthor = djvj & Shateredsoul & brolly
  5. MVersion = 2.0.8
  6. MCRC = 748F1FE3
  7. iCRC = 727A7789
  8. MID = 635038268888210842
  9. MSystem = "Sony PlayStation"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; epsxe can't deal with bin/cue dumps with more than one audio track if you load the cue file directly.
  13. ; For these to work you must mount the cue on daemon tools and let epsxe boot the game from there.
  14. ; You need to make sure you have a SCSI virtual drive on Daemon Tools, NOT a DT one.
  15. ; On first time use, 2 default memory card files will be created called _default_001.mcr and _default_002.mcr in emuPath\memcards
  16. ;
  17. ; Extract all your BIOS files to the bios subfolder. Then goto Config->Bios and select the bios you wish to use.
  18. ;
  19. ; Go to Config->Video then choose a plugin. Pete's OpenGL line is preffered
  20. ; Click Configure (under video plugin) and choose fullscreen and set your desired resolution. Video options/results will vary based on the plugin you choose.
  21. ;
  22. ; If you are using images with multiple tracks, set your extension to cue (make sure all your cues are correctly pointing to their tracks).
  23. ; Go to Config->Cdrom->Configure button and select the drive letter associated with your daemon tools virtual drive.
  24. ;
  25. ; ePSXe will ONLY close via Escape, it will bug out with all other forms of closing a normal program. Do not edit CloseProcess!
  26. ;
  27. ; TurboButton will only work with DX7 video plugin. Turbo key by Hypnoziz
  28. ;
  29. ; Requires at least Libs\Shared.ahk v1.1.3
  30. ;
  31. ; epsxe stores its settings in the registry @ HKEY_CURRENT_USER\Software\epsxe\config
  32. ; plugins store their settings in the registry @ HKEY_CURRENT_USER\Software\Vision Thing\PSEmu Pro
  33. ;----------------------------------------------------------------------------
  34. StartModule()
  35. BezelGUI()
  36. FadeInStart()
  37.  
  38. settingsFile := modulePath . "\" . moduleName . ".ini"
  39. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  40. turboButton := IniReadCheck(settingsFile, "Settings", "turboButton","F12",,1) ; Key mapping for turbo button assignment
  41. slowBoot := IniReadCheck(settingsFile, "Settings", "slowBoot","false",,1) ; If true, force emulator to show bios screen at boot
  42. enableAnalog := IniReadCheck(settingsFile, "Settings", "enableAnalog","true",,1) ; If true, enables analog controls at start of game for you, so you don't have to press F5
  43. hideEpsxeGUIs := IniReadCheck(settingsFile, "Settings", "HideePSXeGUIs","true",,1)
  44. perGameMemCards := IniReadCheck(settingsFile, "Settings", "PerGameMemoryCards","true",,1)
  45. disableMemoryCard1 := IniReadCheck(settingsFile, romName, "DisableMemoryCard1","false",,1) ; If true, disables memory card 1 for this game. Some games may not boot if both memory cards are inserted.
  46. disableMemoryCard2 := IniReadCheck(settingsFile, romName, "DisableMemoryCard2","false",,1) ; If true, disables memory card 2 for this game. Some games may not boot if both memory cards are inserted.
  47. memCardPath := IniReadCheck(settingsFile, "Settings", "memCardPath", EmuPath . "\memcards",,1)
  48. memCardPath := AbsoluteFromRelative(EmuPath, memCardPath)
  49.  
  50. dialogOpen := i18n("dialog.open") ; Looking up local translation
  51.  
  52. BezelStart()
  53.  
  54. If (Fullscreen = "true") {
  55. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteOpenGL2", "WindowMode", 0) ; changes fullscreen setting for all 3 gpu plugins
  56. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteTNT", "WindowMode", 0)
  57. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\DFXVideo", "WindowMode", 0)
  58. } Else {
  59. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteOpenGL2", "WindowMode", 1)
  60. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteTNT", "WindowMode", 1)
  61. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\DFXVideo", "WindowMode", 1)
  62. If (bezelEnabled = "true") {
  63. winSize := bezelScreenHeight * 65536 + bezelScreenWidth ; convert desired windowed resolution to Decimal
  64. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteOpenGL2", "WinSize", winSize)
  65. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\PeteTNT", "WinSize", winSize)
  66. WriteReg("DWORD", "Vision Thing\PSEmu Pro\GPU\DFXVideo", "WinSize", winSize)
  67. }
  68. }
  69.  
  70. ; Memory Cards
  71. defaultMemCard1 := memCardPath . "\_default_001.mcr" ; defining default blank memory card for slot 1
  72. defaultMemCard2 := memCardPath . "\_default_002.mcr" ; defining default blank memory card for slot 2
  73. memCardName := If romTable[1,5] ? romTable[1,4] : romName ; defining rom name for multi disc rom
  74. romMemCard1 := memCardPath . "\" . memCardName . "_001.mcr" ; defining name for rom's memory card for slot 1
  75. romMemCard2 := memCardPath . "\" . memCardName . "_002.mcr" ; defining name for rom's memory card for slot 2
  76. memcardType := If perGameMemCards = "true" ? "rom" : "default" ; define the type of memory card we will create in the below loop
  77. IfNotExist, %memCardPath%
  78. FileCreateDir, %memCardPath% ; create memcard folder if it doesn't exist
  79. Loop 2
  80. { IfNotExist, % %memcardType%MemCard%A_Index%
  81. { FileAppend,, % %memcardType%MemCard%A_Index% ; create a new blank memory card if one does not exist
  82. Log("Module - Created a new blank memory card in Slot " . A_Index . ":" . %memcardType%MemCard%A_Index%)
  83. }
  84. WriteReg("SZ", "epsxe\config", "Memcard" . A_Index, %memcardType%MemCard%A_Index%)
  85.  
  86. ; Now disable a memory card if required for the game to boot properly
  87. memcard%A_Index%Enable := ReadReg("epsxe\config", "Memcard" . A_Index . "Enable")
  88. If (disableMemoryCard%A_Index% = "true")
  89. WriteReg("SZ", "epsxe\config", "Memcard" . A_Index . "Enable", 0)
  90. Else
  91. WriteReg("SZ", "epsxe\config", "Memcard" . A_Index . "Enable", 1)
  92. }
  93.  
  94. hideEmuObj := Object(dialogOpen . " PSX ISO ahk_class #32770",0,"ahk_class EPSXGUI",0,"ePSXe ahk_class EPSX",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  95. 7z(romPath, romName, romExtension, 7zExtractPath)
  96.  
  97. epsxeExtension := InStr(".ccd|.cue|.mds|.img|.iso",romExtension) ; the psx extensions supported by the emu
  98.  
  99. SetKeyDelay(50)
  100. ; turboButton := xHotKeyVarEdit(turboButton,"turboButton","~","Add")
  101. xHotKeywrapper(turboButton,"TurboProcess")
  102. turboEnabled = 0 ; Initialize turbo state
  103.  
  104. RomTableCheck() ; make sure romTable is created already so the next line can calculate correctly
  105. noGUI := If romTable.MaxIndex() ? "" : " -nogui" ; multidisc games will not use nogui because we need to select an option in epsxe's gui to swap discs
  106. slowBoot := If slowBoot = "true" ? " -slowboot" : ""
  107.  
  108. If (noGUI = "" && hideEpsxeGUIs = "true") { ; for multi disc games only
  109. Log("Module - Starting the HideGUIWindow timer to prevent them from showing")
  110. SetTimer, HideGUIWindow, 10 ; start watching for gui window so it can be completely hidden
  111. }
  112.  
  113. ; Mount the CD using DaemonTools
  114. If (epsxeExtension && dtEnabled = "true" ) {
  115. Log("Module - Daemon Tools is enabled and " . romExtension . " is a supported DT extension")
  116.  
  117. DaemonTools("get") ; populates the dtDriveLetter variable with the drive letter to your scsi or dt virtual drive
  118. currentCDRomAscii := ReadReg("epsxe\config", "CdromLetter") ; read the current setting for ePSXe's cdrom it is using
  119. currentCDRomLetter := Chr(currentCDRomAscii) ; converts the ascii code to a letter
  120.  
  121. If (currentCDRomLetter = "")
  122. Log("Module - " . MEmu . " is not configured with a CDRom Drive")
  123. Else If (currentCDRomAscii = 48)
  124. Log("Module - " . MEmu . " is configured to read from the FirstCdrom Drive and will be updated to a proper letter instead")
  125. Else
  126. Log("Module - " . MEmu . " is configured to read from Drive " . currentCDRomLetter . ":")
  127.  
  128. If (currentCDRomLetter != dtDriveLetter) {
  129. newCDRomAscii := Asc(dtDriveLetter) ; converts the letter to an ascii code
  130. WriteReg("SZ", "epsxe\config", "CdromLetter", newCDRomAscii)
  131. Log("Module - Updated " . MEmu . " to use Drive " . dtDriveLetter . ": for all future launches.",2)
  132. } Else
  133. Log("Module - " . MEmu . " is configured to use the correct drive already")
  134.  
  135. DaemonTools("mount",romPath . "\" . romName . romExtension)
  136. HideEmuStart() ; This fully ensures windows are completely hidden even faster than winwait
  137. errorLvl := Run(executable . noGUI . slowBoot, emuPath)
  138. usedDT := 1
  139. } Else {
  140. Log("Module - Sending rom to emu directly as Daemon Tools is not enabled or " . romExtension . " is not a supported DT extension.")
  141. HideEmuStart() ; This fully ensures windows are completely hidden even faster than winwait
  142. errorLvl := Run(executable . noGUI . slowBoot . " -loadiso """ . romPath . "\" . romName . romExtension . """", emuPath)
  143. }
  144. If errorLvl
  145. ScriptError("Error launching " . executable . "`, closing module.")
  146.  
  147. epsxeLaunchType := If usedDT ? "CDROM" : "ISO" ; determines which command gets sent to epsxe
  148.  
  149. If (noGUI = "") { ; for multi disc games only
  150. Log("Module - " . romName . " is a multi-disc game, so launching " . MEmu . " with GUI enabled so swapping can occur.")
  151. WinWait("ePSXe ahk_class EPSXGUI")
  152. If (epsxeLaunchType = "CDROM") {
  153. Log("Module - Telling ePSXe to run a CDROM")
  154. PostMessage, 0x111, 40001,,,ahk_class EPSXGUI ; Run CDROM
  155. } Else {
  156. Log("Module - Telling ePSXe to run an ISO")
  157. PostMessage, 0x111, 40003,,,ahk_class EPSXGUI ; Run ISO
  158. }
  159. } Else
  160. Log("Module - " . romName . " is not a multi-disc game, so launching " . MEmu . " with GUI disabled.")
  161.  
  162. If (!usedDT && noGUI = "") { ; for some reason, epsxe still shows an open psx iso box even though it was provided on the run command when we don't also send -nogui. This handles loading the rom.
  163. Log("Module - " . MEmu . " GUI and DT support are both disabled. Loading rom via the Open PSX ISO window.")
  164. OpenROM(dialogOpen . " PSX ISO ahk_class #32770", romPath . "\" . romName . romExtension)
  165. }
  166.  
  167. WinWait("ePSXe ahk_class EPSX")
  168. WinWaitActive("ePSXe ahk_class EPSX")
  169.  
  170. If (noGUI = "" && hideEpsxeGUIs = "true") { ; for multi disc games only
  171. Log("Module - Stopping the HideGUIWindow timer")
  172. SetTimer, HideGUIWindow, Off
  173. }
  174.  
  175. BezelDraw()
  176. HideEmuEnd()
  177. FadeInExit()
  178.  
  179. If enableAnalog = true
  180. { Sleep, 1500 ; necessary otherwise epsxe doesn't register the key
  181. Send, {F5 down}{F5 up}
  182. }
  183.  
  184. Process("WaitClose", executable)
  185.  
  186. If usedDT
  187. DaemonTools("unmount")
  188.  
  189. 7zCleanUp()
  190. BezelExit()
  191. FadeOutExit()
  192. ExitModule()
  193.  
  194.  
  195. ReadReg(var1, var2) {
  196. RegRead, regValue, HKEY_CURRENT_USER, Software\%var1%, %var2%
  197. Return %regValue%
  198. }
  199.  
  200. WriteReg(type, var1, var2, var3) {
  201. RegWrite, REG_%type%, HKEY_CURRENT_USER, Software\%var1%, %var2%, %var3%
  202. }
  203.  
  204. TurboProcess:
  205. If (turboEnabled = 0) {
  206. Send, {Delete}{End}{End}{Delete}
  207. turboEnabled = 1
  208. } Else {
  209. Send, {Delete}{End}{Delete}
  210. turboEnabled = 0
  211. }
  212. Return
  213.  
  214. HaltEmu:
  215. If Fullscreen = true
  216. { PostMessage, 0x111, 40001,,,ahk_class EPSXGUI ; Go fullscreen, same as alt+enter
  217. Sleep, 200
  218. }
  219. Return
  220. MultiGame:
  221. ; msgbox % "selectedRom = " . selectedRom . "`nselected game = " . currentButton . "`nmgRomPath = " . mgRomPath . "`nmgRomExt = " . mgRomExt . "`nmgRomName = " . mgRomName
  222. SetKeyDelay(50)
  223. If usedDT
  224. { DaemonTools("unmount") ; Unmount the CD from DaemonTools
  225. Sleep, 500 ; Required to prevent DT from bugging
  226. DaemonTools("mount",selectedRom) ; Mount the CD using DaemonTools
  227. }
  228. ControlSend,, {ESC down}{ESC Up}, ahk_class EPSX ; this exits the game window and brings back ePSXe's gui menu window
  229. If hideEpsxeGUIs = true
  230. { Log("Module - Starting the HideGUIWindow timer to prevent them from showing")
  231. SetTimer, HideGUIWindow, 10
  232. }
  233.  
  234. If (epsxeLaunchType = "CDROM") {
  235. Log("Module - Telling ePSXe to swap to another CDROM")
  236. PostMessage, 0x111, 40005,,,ahk_class EPSXGUI ; Change Disc CDROM
  237. } Else {
  238. Log("Module - Telling ePSXe to swap to another ISO")
  239. PostMessage, 0x111, 40006,,,ahk_class EPSXGUI ; Change Disc ISO
  240. }
  241.  
  242. If usedDT
  243. { WinWait("Change Disc Option ahk_class #32770")
  244. ControlSend,Button1,{Enter},Change Disc Option ahk_class #32770
  245. } Else {
  246. OpenROM(dialogOpen . " PSX ISO ahk_class #32770", romPath . "\" . romName . romExtension)
  247. }
  248. If hideEpsxeGUIs = true
  249. { Log("Module - Stopping the HideGUIWindow timer")
  250. SetTimer, HideGUIWindow, off
  251. }
  252. ; If BezelEnabled
  253. ; BezelDraw()
  254. Return
  255. RestoreEmu:
  256. WinActivate, ahk_id %emulatorID%
  257. If Fullscreen = true
  258. PostMessage, 0x111, 40001,,,ahk_class EPSXGUI ; Go fullscreen, same as alt+enter
  259. Return
  260.  
  261. HideGUIWindow:
  262. WinSet, Transparent, On, ePSXe ahk_class EPSXGUI
  263. WinSet, Transparent, On, Open PSX ISO ahk_class #32770 ; when not using DT
  264. WinSet, Transparent, On, Change Disc Option ahk_class #32770 ; when using DT
  265. Return
  266.  
  267. CloseProcess:
  268. FadeOutStart()
  269. SetWinDelay, 50
  270. Log("Module - Sending Escape to close emulator")
  271. ; ControlSend,, {Esc down}{Esc up}, ePSXe ahk_class EPSX ; DO NOT CHANGE
  272. PostMessage, 0x111, 40007,,,ahk_class EPSX ; Exit ePSXe
  273. If (noGUI = "") { ; for multi disc games only
  274. WinWait("ePSXe ahk_class EPSXGUI")
  275. WinClose("ePSXe ahk_class EPSXGUI")
  276. }
  277. Return
Advertisement
Add Comment
Please, Sign In to add comment