rfancella

ActiveGS.ahk

Sep 24th, 2014
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 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.1
  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 original.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" ; use a custom systemName ini If it exists
  26. configFile := A_MyDocuments . "\ActiveGSLocalData\activegs.conf"
  27.  
  28. Fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  29. KeepAspectRatio := IniReadCheck(settingsFile, "Settings", "KeepAspectRatio","true",,1)
  30. externalOS := IniReadCheck(settingsFile, romName, "External_OS","false",,1)
  31. SingleDrive := IniReadCheck(settingsFile, romName, "SingleDrive","false",,1)
  32. DiskSwapDrive := IniReadCheck(settingsFile, romName, "DiskSwapDrive","1",,1)
  33. HardDiskImage := IniReadCheck(settingsFile, romName, "HardDiskImage","false",,1)
  34. Command := IniReadCheck(settingsFile, romName, "Command", "",,1)
  35. SendCommandDelay := IniReadCheck(settingsFile, "Settings" . "|" . romName, "SendCommandDelay", "2000",,1)
  36. WaitBetweenSends := IniReadCheck(settingsFile, "Settings" . "|" . romName, "WaitBetweenSends", "false",,1)
  37. DefaultVideoType := IniReadCheck(settingsFile, "Settings", "VideoType", "lcd",,1)
  38. VideoType := IniReadCheck(settingsFile, romName, "VideoType", DefaultVideoType,,1)
  39. ColorMode := IniReadCheck(settingsFile, romName, "ColorMode", "auto",,1)
  40. BootableHardDiskImage := IniReadCheck(settingsFile, "Settings", "BootableHardDiskImage","System 6 and Free Games.hdv",,1)
  41.  
  42. If FileExist(configFile) {
  43. configIni := LoadProperties(configFile) ; load the config into memory
  44. ;Set the properties in the preferences.cfg file
  45. WriteProperty(configIni,"videoFX",VideoType,,,":")
  46. WriteProperty(configIni,"colorMode",ColorMode,,,":")
  47. SaveProperties(configFile,configIni) ; save changes to Preferences.cfg
  48. } Else
  49. Log("activegs.conf was not found at " . configFile . ". Emulator was probably never run before")
  50.  
  51. If (SystemName = "Apple II") {
  52. if (romExtension = ".dsk") {
  53. bootslot := "6"
  54. SlotNumber := "6"
  55. } Else {
  56. bootslot := "5"
  57. SlotNumber := "5"
  58. }
  59. } Else {
  60. bootslot := "5"
  61. SlotNumber := "5"
  62. }
  63.  
  64. disk1 := " "
  65. disk2 := " "
  66. slot7disk1 := " "
  67.  
  68. If (%HardDiskImage%) {
  69. slot7disk1 := romPath . romName . romExtension
  70. bootslot := 7
  71. } Else {
  72. Sleep, 100 ;Without this romtable comes empty (thread related?)
  73. RomTableCheck() ; make sure romTable is created already so the next line can calculate correctly
  74. If (romTable.MaxIndex() > 1) {
  75. If (%SingleDrive%) { ;some games require all disks to be mounted in only one drive
  76. disk1 := romTable[1,1]
  77. } Else {
  78. disk1 := romTable[1,1]
  79. disk2 := romTable[2,1]
  80. }
  81. } Else
  82. disk1 := romPath . "\" . romName . romExtension
  83. }
  84.  
  85. If (%externalOS%) {
  86. checkImageExists := CheckFile(emuPath . "\" . BootableHardDiskImage) ;For games without OS included, make sure it exists and error If not found
  87. slot7disk1 := emuPath . "\" . BootableHardDiskImage
  88. bootslot := 7
  89. }
  90.  
  91. ;Limited CLI, so setup XML with proper disks and correct boot sequence
  92. ActiveGSXML := emuPath . "\default.activegsxml"
  93. FileDelete %ActiveGSXML% ; Build a new file on every execution
  94.  
  95. FileAppend,
  96. (
  97. <?xml version="1.0" encoding="iso-8859-1"?>
  98. <config version="2">
  99. <format>2GS</format>
  100. <image slot="%SlotNumber%" disk="1" icon="">%disk1%</image>
  101. <image slot="%SlotNumber%" disk="2" icon="">%disk2%</image>
  102. <image slot="7" disk="1" icon="">%slot7disk1%</image>
  103. <speed>2</speed>
  104. <bootslot>%bootslot%</bootslot>
  105. </config>
  106. ), %ActiveGSXML%
  107.  
  108. BezelStart()
  109.  
  110. hideEmuObj := Object("ActiveGS ahk_class AfxFrameOrView90s",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  111. 7z(romPath, romName, romExtension, 7zExtractPath)
  112.  
  113. HideEmuStart()
  114. Run(executable, emuPath)
  115.  
  116. WinWait("ActiveGS ahk_class AfxFrameOrView90s")
  117. WinWaitActive("ActiveGS ahk_class AfxFrameOrView90s")
  118.  
  119. Send, {F8} ;Enable Mouse Lock
  120.  
  121. If (Fullscreen = "true") {
  122. ;No true fullscreen is available for ActiveGS, so we fake it by maximizing the window
  123. ;WinGetPos, WinX, WinY, WinWidth, WinHeight, A
  124. WinSet, Style, -0xC00000, ActiveGS ahk_class AfxFrameOrView90s ; Removes the TitleBar
  125. DllCall("SetMenu", uint, WinActive( "A" ), uint, 0) ; Removes the MenuBar
  126. WinSet, Style, -0x40000, ActiveGS ahk_class AfxFrameOrView90s ; Removes the border of the game window
  127. ;Sleep, 600 ; Need this otherwise the game window snaps back to size, increase If this occurs
  128.  
  129. If (KeepAspectRatio = "true")
  130. MaximizeWindow("ActiveGS ahk_class AfxFrameOrView90s")
  131. Else
  132. WinMove, A, , 0, 0, A_ScreenWidth, A_ScreenHeight
  133. } Else {
  134. ;Resize window per user settings and center
  135. WindowWidth := IniReadCheck(settingsFile, "Settings", "WindowWidth","800",,1)
  136. WindowHeight := IniReadCheck(settingsFile, "Settings", "WindowHeight","600",,1)
  137. WinMove, A, , (A_ScreenWidth-WindowWidth)/2, (A_ScreenHeight-WindowHeight)/2, WindowWidth, WindowHeight
  138. }
  139.  
  140. WaitBetweenSends := (If WaitBetweenSends = "true" ? "1" : "0")
  141.  
  142. WinWaitActive("ActiveGS ahk_class AfxFrameOrView90s")
  143. SendCommand(Command, SendCommandDelay, "500", WaitBetweenSends)
  144.  
  145. BezelDraw()
  146. HideEmuEnd()
  147. FadeInExit()
  148. Process("WaitClose", executable)
  149. 7zCleanUp()
  150. BezelExit()
  151. FadeOutExit()
  152. ExitModule()
  153.  
  154.  
  155. MaximizeWindow(class) {
  156. WinGetPos, appX, appY, appWidth, appHeight, %class%
  157. widthMaxPercenty := ( A_ScreenWidth / appWidth )
  158. heightMaxPercenty := ( A_ScreenHeight / appHeight )
  159.  
  160. If ( widthMaxPercenty < heightMaxPercenty )
  161. percentToEnlarge := widthMaxPercenty
  162. Else
  163. percentToEnlarge := heightMaxPercenty
  164.  
  165. appWidthNew := appWidth * percentToEnlarge
  166. appHeightNew := appHeight * percentToEnlarge
  167. Transform, appX, Round, %appX%
  168. Transform, appY, Round, %appY%
  169. Transform, appWidthNew, Round, %appWidthNew%, 2
  170. Transform, appHeightNew, Round, %appHeightNew%, 2
  171. appXPos := ( A_ScreenWidth / 2 ) - ( appWidthNew / 2 )
  172. appYPos := ( A_ScreenHeight / 2 ) - ( appHeightNew / 2 )
  173. WinMove, %class%,, appXPos, appYPos, appWidthNew, appHeightNew
  174. }
  175.  
  176. HaltEmu:
  177. disableSuspendEmu := true
  178. PostMessage, 0x111, 40025,,,ActiveGS ahk_class AfxFrameOrView90s ; Pause
  179. Return
  180.  
  181. RestoreEmu:
  182. PostMessage, 0x111, 40025,,,ActiveGS ahk_class AfxFrameOrView90s ; Pause
  183. Return
  184.  
  185. MultiGame:
  186. If (SystemName = "Apple II")
  187. DriveToChoose := If DiskSwapDrive = "1" ? "S6D1" : "S6D2"
  188. Else
  189. DriveToChoose := If DiskSwapDrive = "1" ? "S5D1" : "S5D2"
  190.  
  191. 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)
  192.  
  193. WinWait("ActiveGS ahk_class #32770")
  194. WinWaitActive("ActiveGS ahk_class #32770")
  195.  
  196. Control, ChooseString, %DriveToChoose%, ComboBox1, ActiveGS ahk_class #32770 ;Select the correct drive in the ComboBox
  197. ControlClick,Button7,ActiveGS ahk_class #32770,,,,NA
  198. OpenROM("Open ahk_class #32770", selectedRom)
  199.  
  200. WinClose("ActiveGS ahk_class #32770")
  201. Return
  202.  
  203. CloseProcess:
  204. FadeOutStart()
  205. IfExist, %emuPath%\original.activegsxml
  206. {
  207. FileCopy,%emuPath%\original.activegsxml, %emuPath%\default.activegsxml, 1
  208. }
  209. WinClose("ActiveGS ahk_class AfxFrameOrView90s")
  210. Return
Advertisement
Add Comment
Please, Sign In to add comment