rfancella

WinUAE Loader.ahk

Dec 8th, 2014
503
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. MEmu = WinUAE Loader
  2. MEmuV = v1.74
  3. MURL = http://headsoft.com.au/index.php?category=winuaeloader
  4. MAuthor = djvj
  5. MVersion = 2.0.2
  6. MCRC = 5CA46EB
  7. iCRC = 4E0EC826
  8. MID = 635038268935640326
  9. MSystem = "Commodore Amiga"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Requires WinUAE v2.4.0+
  13. ; You can configure WinUAE from the built-in GUI or use another loader that makes things a bit simpler
  14. ; To configure WinUAE settings using WinUAE Loader v1.72 or later
  15. ; Paths->WinUAE Exe->WinUAE Exe should point to your winuae.exe
  16. ; Paths->Rom Folders->WHDLoad should point to your roms dir
  17. ; Input->Exit Options->Global Exit Key should be 27 (if you use ESC). Check "Force WHDLoad Close" and set "Close Timeout" to 0 for the fastest exit
  18. ; Settings->Display Options set Full Screen and all the check boxes
  19. ;
  20. ; Don't forget to open WinUAE directly and goto Paths and set your System ROMs dir. WinAUE will scan all your roms and enables what it finds
  21. ;
  22. ; Set emupath to your WinUAELoader dir and the exe to WinUAELoader.exe
  23. ; autoResume additions courtesy of: http://www.hyperspin-fe.com/forum/showthread.php?24702-Amiga-Whdloader-module-with-auto-save-load-state
  24. ;----------------------------------------------------------------------------
  25. StartModule()
  26. BezelGUI()
  27. FadeInStart()
  28.  
  29. settingsFile := modulePath . "\" . moduleName . ".ini"
  30. fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  31. resolution := IniReadCheck(settingsFile, "Settings", "Resolution","1024x768",,1) ; Set resolution of WinUAE's window. Depending on Fullscreen value, there are different resolutions supported by WinUAE.
  32. autoResume := IniReadCheck(settingsFile, "Settings", "autoResume","true",,1) ; if true, will automatically save your game's state on exit and reload it on the next launch of the same game.
  33.  
  34. ;Bezel settings
  35. bezelTopOffset := IniReadCheck(settingsFile, "Settings", "Bezel_Top_Offset","0",,1)
  36. bezelBottomOffset := IniReadCheck(settingsFile, "Settings", "Bezel_Bottom_Offset","0",,1)
  37. bezelRightOffset := IniReadCheck(settingsFile, "Settings", "Bezel_Right_Offset", "0",,1)
  38. bezelLeftOffset := IniReadCheck(settingsFile, "Settings", "Bezel_Left_Offset", "0",,1)
  39.  
  40. loaderINI := CheckFile(emuPath . "\Data\WinUAELoader.ini")
  41. IniRead, currentFullScreen, %loaderINI%, Display, Windowed
  42.  
  43. fullscreenResAr := Object("640x480",0,"720x480",1,"720x576",2,"800x600",3,"1024x768",4,"1152x864",5,"1280x720",6,"1280x756",7,"1280x800",8,"1280x960",9,"1280x1024",10,"1360x768",11,"1366x768",12,"1600x900",13,"1600x1024",14,"1600x1200",15,"1680x1050",16,"1900x1080",17,"1920x1200",18)
  44. windowedResAr := Object("320x256",0,"640x512",1,"720x576",2)
  45.  
  46. BezelStart()
  47.  
  48. If fullscreen = true ; get value to set in WinUAELoader's ini
  49. resolution := fullscreenResAr[resolution]
  50. Else
  51. resolution := windowedResAr[resolution]
  52.  
  53. If (fullscreen != "true" && resolution >= 3) || !resolution ; if user switched from fullscreen to windowed and did not set a valid windowed resolution, or the array lookup failed, we will default to 720x576 because the default 1024x768 res is not valid in windowed mode
  54. resolution := 2
  55.  
  56. ; Setting Fullscreen setting in ini if it doesn't match what user wants above. Because the key is "Windowed" set values are opposite normal emus
  57. If ( Fullscreen != "true" And currentFullScreen = "false" ) { ; want windowed mode
  58. IniWrite, True, %loaderINI%, Display, Windowed
  59. IniWrite, %resolution%, %loaderINI%, Display, Screen
  60. } Else If ( Fullscreen = "true" And currentFullScreen = "true" ) { ; want fullscreen mode
  61. IniWrite, False, %loaderINI%, Display, Windowed
  62. IniWrite, %resolution%, %loaderINI%, Display, Screen
  63. }
  64.  
  65. winUAELoaderClass := If fullscreen = "true" ? "AmigaPowah" : "PCsuxRox"
  66.  
  67. hideEmuObj := Object("Restore a WinUAE snapshot file",0,"ahk_class " . winUAELoaderClass,1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  68. 7z(romPath, romName, romExtension, 7zExtractPath)
  69.  
  70. stateName := emuPath . "\states\" . romName . ".uss"
  71.  
  72. HideEmuStart() ; This fully ensures windows are completely hidden even faster than winwait
  73. Run(executable . " -mode whdload -game """ . romPath . "\" . romName . romExtension . """", emuPath)
  74.  
  75. If (FileExist(stateName) and autoResume="true") {
  76. clipboard = %stateName%
  77. WinWait("ahk_class AmigaPowah")
  78. Send {F7} ; open load state window
  79. WinWait("Restore a WinUAE snapshot file")
  80. Send ^v
  81. Send {Enter}
  82. }
  83.  
  84. WinWait("ahk_class " . winUAELoaderClass) ; window class name changes if in windowed or fullscreen
  85. WinWaitActive("ahk_class " . winUAELoaderClass)
  86.  
  87. BezelDraw()
  88. HideEmuEnd()
  89. FadeInExit()
  90. Process("WaitClose", executable)
  91. 7zCleanUp()
  92. FadeOutExit()
  93.  
  94. GroupAdd,DIE,DIEmWin
  95. GroupClose, DIE, A
  96.  
  97. ExitModule()
  98.  
  99.  
  100. CloseProcess:
  101. If (FileExist(stateName) and autoResume="true")
  102. Send {F5} ; open save state window
  103. FadeOutStart()
  104. If (FileExist(stateName) and autoResume="true") {
  105. clipboard = %stateName% ; just in case something happened to clipboard in between start of module to now
  106. WinWait("Save a WinUAE snapshot file")
  107. Send ^v
  108. Send {Enter}
  109. Sleep, 50 ; always give time for a file operation to occur before closing an app
  110. }
  111. WinClose("ahk_class " . winUAELoaderClass)
  112. Return
Advertisement
Add Comment
Please, Sign In to add comment