rfancella

ActiveGS Old.ahk

Dec 16th, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.10 KB | None | 0 0
  1. MEmu = ActiveGS
  2. MEmuV = v3.7.1019
  3. MURL = http://activegs.freetoolsassociation.com/
  4. MAuthor = wahoobrian, brolly
  5. MVersion = 2.0
  6. MCRC = E845A645
  7. iCRC = 1459B10D
  8. mId = 635412285478387119
  9. MSystem = "Apple II","Apple IIGS"
  10. ;------------------------------------------------------------------------------------------------------------------
  11. ; Notes:
  12. ; CLI is very limited for this Emulator.
  13. ; To get around this, the module deletes and recreates the startup configuration xml file - default.activegsxml
  14. ;
  15. ; You will need to supply a default hard drive image that contains the ProDOS operating system.
  16. ; This is a good one ---> http://www.whatisthe2gs.apple2.org.za/files/harddrive_image.zip
  17. ;
  18. ; If you want to keep your default default.activegsxml file after exiting then make a copy of it in the
  19. ; emulator folder and name it default-default.activegsxml. This file will then be copied over on exit.
  20. ;------------------------------------------------------------------------------------------------------------------
  21. StartModule()
  22. BezelGUI()
  23. FadeInStart()
  24.  
  25. settingsFile := modulePath . "\" . (If FileExist(modulePath . "\" . systemName . ".ini") ? systemName : moduleName) . ".ini"
  26. ; use a custom systemName ini If it exists
  27.  
  28. configFile := A_MyDocuments . "\ActiveGSLocalData\activegs.conf"
  29.  
  30. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  31. KeepAspectRatio := IniReadCheck(settingsFile, "Settings", "KeepAspectRatio","true",,1)
  32. externalOS := IniReadCheck(settingsFile, romName, "External_OS","false",,1)
  33. SingleDrive := IniReadCheck(settingsFile, romName, "SingleDrive","false",,1)
  34. DiskSwapDrive := IniReadCheck(settingsFile, romName, "DiskSwapDrive","1",,1)
  35. HardDiskImage := IniReadCheck(settingsFile, romName, "HardDiskImage","false",,1)
  36. Command := IniReadCheck(settingsFile, romName, "Command", "",,1)
  37. SendCommandDelay := IniReadCheck(settingsFile, "Settings" . "|" . romName, "SendCommandDelay", "2000",,1)
  38. WaitBetweenSends := IniReadCheck(settingsFile, "Settings" . "|" . romName, "WaitBetweenSends", "false",,1)
  39. DefaultVideoType := IniReadCheck(settingsFile, "Settings", "VideoType", "lcd",,1)
  40. VideoType := IniReadCheck(settingsFile, romName, "VideoType", DefaultVideoType,,1)
  41. ColorMode := IniReadCheck(settingsFile, romName, "ColorMode", "auto",,1)
  42. BootableHardDiskImage := IniReadCheck(settingsFile, "Settings", "BootableHardDiskImage","System6.2mg",,1)
  43. HideMouse := IniReadCheck(settingsFile, "Settings", "HideMouse","false",,1) ; hides mouse cursor in the emu options
  44.  
  45. If FileExist(configFile) {
  46. configIni := LoadProperties(configFile) ; load the config into memory
  47. ;Set the properties in the preferences.cfg file
  48. WriteProperty(configIni,"videoFX",VideoType,,,":")
  49. WriteProperty(configIni,"colorMode",ColorMode,,,":")
  50. SaveProperties(configFile,configIni) ; save changes to Preferences.cfg
  51. } Else
  52. Log("activegs.conf was not found at " . configFile . ". Emulator was probably never run before")
  53.  
  54. If (SystemName = "Apple II") {
  55. if (romExtension = ".dsk") {
  56. bootslot := "6"
  57. SlotNumber := "6"
  58. } Else {
  59. bootslot := "5"
  60. SlotNumber := "5"
  61. }
  62. } Else {
  63. bootslot := "5"
  64. SlotNumber := "5"
  65. }
  66.  
  67. disk1 := " "
  68. disk2 := " "
  69. slot7disk1 := " "
  70.  
  71. If (%HardDiskImage%) {
  72. slot7disk1 := romPath . romName . romExtension
  73. bootslot := 7
  74. } Else {
  75. Sleep, 100 ;Without this romtable comes empty (thread related?)
  76. RomTableCheck() ; make sure romTable is created already so the next line can calculate correctly
  77. If (romTable.MaxIndex() > 1) {
  78. If (%SingleDrive%) { ;some games require all disks to be mounted in only one drive
  79. disk1 := romTable[1,1]
  80. } Else {
  81. disk1 := romTable[1,1]
  82. disk2 := romTable[2,1]
  83. }
  84. } Else
  85. disk1 := romPath . "\" . romName . romExtension
  86. }
  87.  
  88. If (%externalOS%) {
  89. checkImageExists := CheckFile(romPath . "\" . BootableHardDiskImage) ;For games without OS included, make sure it exists and error If not found
  90. slot7disk1 := romPath . "\" . BootableHardDiskImage
  91. bootslot := 7
  92. }
  93.  
  94. ;Limited CLI, so setup XML with proper disks and correct boot sequence
  95. ActiveGSXML := emuPath . "\default.activegsxml"
  96. FileDelete %ActiveGSXML% ; Build a new file on every execution
  97.  
  98. FileAppend,
  99. (
  100. <?xml version="1.0" encoding="iso-8859-1"?>
  101. <config version="2">
  102. <format>2GS</format>
  103. <image slot="%SlotNumber%" disk="1" icon="">%disk1%</image>
  104. <image slot="%SlotNumber%" disk="2" icon="">%disk2%</image>
  105. <image slot="7" disk="1" icon="">%slot7disk1%</image>
  106. <speed>2</speed>
  107. <bootslot>%bootslot%</bootslot>
  108. </config>
  109. ), %ActiveGSXML%
  110.  
  111. BezelStart()
  112.  
  113. hideEmuObj := Object("ActiveGS ahk_class AfxFrameOrView90s",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  114. 7z(romPath, romName, romExtension, 7zExtractPath)
  115.  
  116. HideEmuStart()
  117. Run(executable, emuPath)
  118.  
  119. WinWait("ActiveGS ahk_class AfxFrameOrView90s")
  120. WinWaitActive("ActiveGS ahk_class AfxFrameOrView90s")
  121.  
  122. Send, {F8} ;Enable Mouse Lock
  123.  
  124. If (Fullscreen = "true") {
  125. ;No true fullscreen is available for ActiveGS, so we fake it by maximizing the window
  126. ;WinGetPos, WinX, WinY, WinWidth, WinHeight, A
  127. WinSet, Style, -0xC00000, ActiveGS ahk_class AfxFrameOrView90s ; Removes the TitleBar
  128. DllCall("SetMenu", uint, WinActive( "A" ), uint, 0) ; Removes the MenuBar
  129. WinSet, Style, -0x40000, ActiveGS ahk_class AfxFrameOrView90s ; Removes the border of the game window
  130. ;Sleep, 600 ; Need this otherwise the game window snaps back to size, increase If this occurs
  131.  
  132. If (KeepAspectRatio = "true")
  133. MaximizeWindow("ActiveGS ahk_class AfxFrameOrView90s")
  134. Else
  135. WinMove, A, , 0, 0, A_ScreenWidth, A_ScreenHeight
  136. } Else {
  137. ;Resize window per user settings and center
  138. WindowWidth := IniReadCheck(settingsFile, "Settings", "WindowWidth","800",,1)
  139. WindowHeight := IniReadCheck(settingsFile, "Settings", "WindowHeight","600",,1)
  140. WinMove, A, , (A_ScreenWidth-WindowWidth)/2, (A_ScreenHeight-WindowHeight)/2, WindowWidth, WindowHeight
  141. }
  142.  
  143. WaitBetweenSends := (If WaitBetweenSends = "true" ? "1" : "0")
  144.  
  145. WinWaitActive("ActiveGS ahk_class AfxFrameOrView90s")
  146.  
  147. ;SendCommand(Command, SendCommandDelay, "500", WaitBetweenSends)
  148. ExecuteCommand(Command, SendCommandDelay)
  149.  
  150. If (HideMouse == true) {
  151. Send, {F8 down}{F8 up}
  152. }
  153.  
  154. BezelDraw()
  155. HideEmuEnd()
  156. FadeInExit()
  157. Process("WaitClose", executable)
  158. 7zCleanUp()
  159. BezelExit()
  160. FadeOutExit()
  161. ExitModule()
  162.  
  163.  
  164. ExecuteCommand(Command, SendCommandDelay) {
  165. If %Command% {
  166. WinWaitActive("ActiveGS ahk_class AfxFrameOrView90s")
  167. Sleep, %SendCommandDelay% ; increase If command is not appearing in the emu window or some just some letters
  168. SetKeyDelay, 100
  169.  
  170. StringSplit, cmd_array, Command, %A_Space%
  171. Loop, %cmd_array0% {
  172. cmdWord := cmd_array%a_index%
  173. If cmdWord = {CTRLDOWN}
  174. Send, {CTRL down}
  175. Else If cmdWord = {CTRLUP}
  176. Send, {CTRL up}
  177. Else If cmdWord = {ENTER}
  178. Send, {ENTER down}{ENTER up}
  179. Else If cmdWord = {SPACE}
  180. Send, {SPACE down}{SPACE up}
  181. Else If cmdWord = {RIGHT}
  182. Send, {RIGHT down}{RIGHT up}
  183. Else If cmdWord = {LEFT}
  184. Send, {LEFT down}{LEFT up}
  185. Else If cmdWord = {UP}
  186. Send, {UP down}{UP up}
  187. Else If cmdWord = {DOWN}
  188. Send, {DOWN down}{DOWN up}
  189. Else If cmdWord = {PAUSE}
  190. Sleep, 500
  191. Else
  192. Loop, Parse, cmdWord
  193. Send, {%A_LoopField% down}{%A_LoopField% up}
  194. }
  195. }
  196. Return
  197. }
  198.  
  199. MaximizeWindow(class) {
  200. WinGetPos, appX, appY, appWidth, appHeight, %class%
  201. widthMaxPercenty := ( A_ScreenWidth / appWidth )
  202. heightMaxPercenty := ( A_ScreenHeight / appHeight )
  203.  
  204. If ( widthMaxPercenty < heightMaxPercenty )
  205. percentToEnlarge := widthMaxPercenty
  206. Else
  207. percentToEnlarge := heightMaxPercenty
  208.  
  209. appWidthNew := appWidth * percentToEnlarge
  210. appHeightNew := appHeight * percentToEnlarge
  211. Transform, appX, Round, %appX%
  212. Transform, appY, Round, %appY%
  213. Transform, appWidthNew, Round, %appWidthNew%, 2
  214. Transform, appHeightNew, Round, %appHeightNew%, 2
  215. appXPos := ( A_ScreenWidth / 2 ) - ( appWidthNew / 2 )
  216. appYPos := ( A_ScreenHeight / 2 ) - ( appHeightNew / 2 )
  217. WinMove, %class%,, appXPos, appYPos, appWidthNew, appHeightNew
  218. }
  219.  
  220. HaltEmu:
  221. disableSuspendEmu := true
  222. PostMessage, 0x111, 40025,,,ActiveGS ahk_class AfxFrameOrView90s ; Pause
  223. Return
  224.  
  225. RestoreEmu:
  226. PostMessage, 0x111, 40025,,,ActiveGS ahk_class AfxFrameOrView90s ; Pause
  227. Return
  228.  
  229. MultiGame:
  230. If (SystemName = "Apple II")
  231. DriveToChoose := If DiskSwapDrive = "1" ? "S6D1" : "S6D2"
  232. Else
  233. DriveToChoose := If DiskSwapDrive = "1" ? "S5D1" : "S5D2"
  234.  
  235. ControlClick,x100 y100,ActiveGS ahk_class AfxFrameOrView90s,,RIGHT,,NAPos ;Click on the window (this way it will work even If it's not on focus)
  236.  
  237. WinWait("ActiveGS ahk_class #32770")
  238. WinWaitActive("ActiveGS ahk_class #32770")
  239.  
  240. Control, ChooseString, %DriveToChoose%, ComboBox1, ActiveGS ahk_class #32770 ;Select the correct drive in the ComboBox
  241. ControlClick,Button7,ActiveGS ahk_class #32770,,,,NA
  242. OpenROM("Open ahk_class #32770", selectedRom)
  243.  
  244. WinClose("ActiveGS ahk_class #32770")
  245. Return
  246.  
  247. CloseProcess:
  248. FadeOutStart()
  249. IfExist, %emuPath%\default.activegsxml
  250. {
  251. FileCopy,%emuPath%\default-default.activegsxml, %emuPath%\default.activegsxml, 1
  252. }
  253. WinClose("ActiveGS ahk_class AfxFrameOrView90s")
  254. Return
Advertisement
Add Comment
Please, Sign In to add comment