Advertisement
djvj

djvj zx spectrum

Oct 9th, 2011
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.74 KB | None | 0 0
  1. ;----------------------------------------------------------------------------
  2. ; Sinclair ZX Spectrum
  3. ; Spectaculator v7.51
  4. ; by djvj & brolly
  5. ; 1.2
  6. ;
  7. ; Notes:
  8. ; Install Spectaculator, on first run put in your registration info and uncheck the box on the Welcome to Spectaculator window.
  9. ; On your first exit, uncheck the box to show warning next time and click Yes.
  10. ;
  11. ; Games are run on 48k model by default, if you want to use a different model for a specific game you can set it on the Settings.ini file that
  12. ; is on the same dir as this script, Configuration example (the key names MUST match your rom name):
  13. ;
  14. ; [Fish! (Europe)]
  15. ; model=plus3
  16. ; [3D Space Wars (Europe)]
  17. ; model=16k
  18. ; [Xybots (Europe)]
  19. ; model=128k
  20. ;
  21. ; To set your res and ratio, goto Tools->Options->Advanced->Display
  22. ; To enable fullscreen, set the Fullscreen variable below to true
  23.  
  24. ; Spectaculator stores its settings in the registry @ HKEY_CURRENT_USER\Software\spectaculator.com\Spectaculator\Settings
  25. ;----------------------------------------------------------------------------
  26.  
  27. LoadingScreen = true
  28. ExitScreen = true
  29. Fullscreen = true
  30. loadingPic = Splash.jpg
  31. loadingPicW = 800
  32. loadingPicH = 600
  33. loadingColor = Black
  34.  
  35. settingsFile := CheckFile(A_Scriptdir . "\Modules\" . systemName . "\Settings.ini")
  36.  
  37. ; This gets rid of the emu window that pops up on launch
  38. If ( LoadingScreen = "true" ) {
  39. Gui +LastFound
  40. WinGet GUI_ID, ID
  41. Gui +AlwaysOnTop -Caption +ToolWindow
  42. Gui, Color, %loadingColor%
  43. loadXPos := ( A_ScreenWidth / 2 ) - ( loadingPicW / 2 )
  44. loadYPos := ( A_ScreenHeight / 2 ) - ( loadingPicH / 2 )
  45. Gui, Add, Picture,x%loadXPos% y%loadYPos%, %A_ScriptDir%\Modules\%systemName%\%loadingPic%
  46. Gui Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth% Hide
  47. DllCall("AnimateWindow","UInt",GUI_ID,"Int",300,"UInt","0xa0000") ; animate in loading GUI
  48. }
  49.  
  50. ; Read current ini & registry values so we know if they need to be updated for the chosen game
  51. currentFullScreen := ReadReg("Full Screen")
  52. currentModel := ReadReg("Model v6+")
  53. IniRead, iniModel, %settingsFile%, %romName%, model, 1 ; 1 is the default value, which is the 48k ZX Spectrum model
  54.  
  55. ; Updating registry with desired model number if it is different
  56. If ( currentModel != iniModel ) {
  57. If ( iniModel = "128k" )
  58. WriteReg("Model v6+", 2)
  59. Else If (iniModel = "16k")
  60. WriteReg("Model v6+", 0)
  61. Else If (iniModel = "plus3")
  62. WriteReg("Model v6+", 5)
  63. Else
  64. WriteReg("Model v6+", 1) ; model 48k
  65. }
  66.  
  67. ; Setting Fullscreen setting in registry if it doesn't match what user wants above
  68. If ( Fullscreen != "true" And currentFullScreen = 1 )
  69. WriteReg("Full Screen", 0)
  70. Else If ( Fullscreen = "true" And currentFullScreen = 0 )
  71. WriteReg("Full Screen", 1)
  72.  
  73. Run, %executable% "%romPath%%romName%%romExtension%", %emuPath%
  74.  
  75. WinWait, ahk_class SpectaculatorClass
  76. WinWaitActive, ahk_class SpectaculatorClass
  77.  
  78. ; Detect when our emulator is fullscreen and then continue
  79. If ( Fullscreen = "true" ) {
  80. While ( FS_Active != 1 && WinActive(ahk_class SpectaculatorClass) ) {
  81. CheckFullscreen()
  82. Sleep, 50
  83. }
  84. }
  85.  
  86. DllCall("SetMenu", uint, WinActive( "A" ), uint, 0) ; Removes the MenuBar
  87. DllCall("AnimateWindow",UInt,GUI_ID,UInt,500,UInt,0x90000) ; animate out loading GUI
  88. Gui Destroy
  89.  
  90. Process, WaitClose, %executable%
  91.  
  92. DllCall("AnimateWindow",UInt,GUI_ID2,UInt,250,UInt,0x90000) ; animate out exit GUI
  93.  
  94. WinActivate, Hyperspin
  95.  
  96. ExitApp
  97.  
  98.  
  99. ReadReg(var1) {
  100. RegRead, regValue, HKEY_CURRENT_USER, Software\spectaculator.com\Spectaculator\Settings, %var1%
  101. Return %regValue%
  102. }
  103.  
  104. WriteReg(var1, var2) {
  105. RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\spectaculator.com\Spectaculator\Settings, %var1%, %var2%
  106. }
  107.  
  108. ScriptError(error) {
  109. MsgBox,48,Error,%error%,5
  110. ExitApp
  111. }
  112.  
  113. CheckFile(file) {
  114. IfNotExist, %file%
  115. {
  116. ScriptError("Cannot find " . file)
  117. ExitApp
  118. }
  119. return %file%
  120. }
  121.  
  122. CheckFullscreen() {
  123. FS_ABM := DllCall( "RegisterWindowMessage", Str,"AppBarMsg" ), VarSetCapacity( FS_AppBarData,36,0 )
  124. FS_Off := NumPut(36,FS_AppBarData), FS_Off := NumPut( WinExist(A_ScriptFullPath " - AutoHotkey"), FS_Off+0 )
  125. FS_Off := NumPut(FS_ABM, FS_Off+0), FS_Off := NumPut( 1,FS_Off+0 ) , FS_Off := NumPut( 1, FS_Off+0 )
  126. DllCall( "Shell32.dll\SHAppBarMessage", UInt, 0x0, UInt,&FS_APPBARDATA )
  127. OnMessage( FS_ABM, "FS_Notify" )
  128. }
  129.  
  130. FS_Notify( wParam, LParam, Msg, HWnd ) {
  131. Global FS_Active
  132. FS_Active := LParam
  133. }
  134.  
  135. CloseProcess:
  136. If ( exitScreen = "true" ) {
  137. Gui +LastFound
  138. WinGet GUI_ID2, ID
  139. Gui +AlwaysOnTop -Caption +ToolWindow
  140. Gui Color, Black
  141. Gui Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth% Hide
  142. DllCall("AnimateWindow","UInt",GUI_ID2,"Int",500,"UInt","0xa0000") ; animate in exit GUI
  143. }
  144. WinClose, ahk_class SpectaculatorClass
  145. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement