rfancella

NullDC.ahk

Feb 26th, 2015
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. MEmu = NullDC
  2. MEmuV = r141
  3. MURL = https://code.google.com/p/nulldc/
  4. MAuthor = djvj & bleasby
  5. MVersion = 2.0.4
  6. MCRC = E1BED80E
  7. iCRC = 2454AF41
  8. MID = 635038268910409317
  9. MSystem = "Sega Dreamcast"
  10. ;----------------------------------------------------------------------------
  11. ; NullDC works with these disc images:
  12. ; - CDI: Padus DiscJuggler image
  13. ; - MDS: Alcohol 120% Media Descriptor image (must be accompanied by a MDF file)
  14. ; - NRG: Nero Burning ROM image
  15. ; - GDI: Raw GDI dump
  16. ; - CHD: MAME's Compressed Hunk of Data
  17.  
  18. ; Helpful guide for getting the basics setup for NullDC: http://www.dgemu.com/forums/index.php/topic/474318-guide-configuring-nulldc-104-r136/
  19. ; If you want to use specific configs per game, create a folder called Cfg inside nullDC folder and copy your nullDC.cfg
  20. ; config files into it naming them to match the database names. Make sure you keep a copy of nullDC.cfg on the Cfg folder as well.
  21. ;
  22. ; If you want to convert your roms from gdi to chd, see here: http://www.emutalk.net/showthread.php?t=51502
  23. ; FileDelete(s) are in the script because sometimes demul will corrupt the ini and make it crash. The script recreates a clean ini for you.
  24. ;
  25. ; Setup the user settings in the moduleName ini to your liking
  26. ; Games can have a custom Cable Type (per game). Not all games work on VGA, so use the below option in the ini
  27. ; Cable can be 0 (VGA(0)(RGB)), 1 (VGA(1)(RGB)), 2 (TV(RGB)) or 3 (TV(VBS/Y+S/C)), default is 0.
  28. ;
  29. ; For additional setup steps prior to running, see this link: http://www.hyperspin-fe.com/forum/showpost.php?p=99852&postcount=138
  30. ; Not all builds work with swapping discs, it's mostly broken and is a nulldc problem, not HyperLaunch's. See here: http://code.google.com/p/nulldc/issues/detail?id=264
  31. ;----------------------------------------------------------------------------
  32. StartModule()
  33. BezelGUI()
  34. ExtraFixedResBezelGUI()
  35.  
  36. If systemName not contains dreamcast,dc
  37. ScriptError(systemName . " is not a supported system for this module. Only " . MSystem . " is supported.")
  38.  
  39. FadeInStart()
  40.  
  41. settingsFile := modulePath . "\" . moduleName . ".ini"
  42. nullDCcfg := checkFile(emuPath . "\nullDC.cfg")
  43.  
  44. fullscreen := IniReadCheck(settingsFile, "Settings", "Fullscreen","true",,1)
  45. dualMonitors := IniReadCheck(settingsFile, "NullDC", "DualMonitors","false",,1)
  46. autoStart := IniReadCheck(settingsFile, "NullDC", "autoStart","1",,1)
  47. noConsole := IniReadCheck(settingsFile, "NullDC", "noConsole","1",,1)
  48. autoHideMenu := IniReadCheck(settingsFile, "NullDC", "autoHideMenu","0",,1)
  49. alwaysOnTop := IniReadCheck(settingsFile, "NullDC", "alwaysOnTop","1",,1)
  50. showVMU := IniReadCheck(settingsFile, "NullDC", "showVMU","0",,1)
  51. VMU1Pos := IniReadCheck(settingsFile, "NullDC", "VMU1Pos","topLeft",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  52. VMU2Pos := IniReadCheck(settingsFile, "NullDC", "VMU2Pos","topRight",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  53. VMU3Pos := IniReadCheck(settingsFile, "NullDC", "VMU3Pos","bottomLeft",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  54. VMU4Pos := IniReadCheck(settingsFile, "NullDC", "VMU4Pos","bottomRight",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  55. VMUHideKey := IniReadCheck(settingsFile, "Settings", "VMUHideKey","F10",,1)
  56. loadDefaultImage := IniReadCheck(settingsFile, "NullDC", "loadDefaultImage","1",,1)
  57. patchRegion := IniReadCheck(settingsFile, "NullDC", "patchRegion","1",,1)
  58. cable := IniReadCheck(settingsFile, romName, "Cable","0",,1)
  59.  
  60. hideEmuObj := Object("ahk_class ConsoleWindowClass",0,"nullDC ahk_class ndc_main_window",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  61. 7z(romPath, romName, romExtension, 7zExtractPath)
  62.  
  63. specialCfg = %emuPath%\cfg\%romName%.cfg
  64. defaultCfg = %emuPath%\cfg\nullDC.cfg
  65. If ( FileExist(specialCfg) && FileExist(defaultCfg))
  66. FileCopy, %specialCfg%, %emuPath%\nullDC.cfg, 1
  67. Else If (FileExist(defaultCfg))
  68. FileCopy, %defaultCfg%, %emuPath%\nullDC.cfg, 1
  69.  
  70. ;Detect game region based on rom name
  71. IfInString, romName, (Europe)
  72. region = 2
  73. Else IfInString, romName, (Japan)
  74. region = 0
  75. Else IfInString, romName, (World)
  76. region = 2
  77. Else
  78. region = 1
  79.  
  80. BezelStart()
  81.  
  82. ;Write Settings
  83. IniWrite, % (If (Fullscreen = "true" )?("1"):("0")), %nullDCcfg%, nullDC_GUI, Fullscreen
  84. IniWrite, %autoStart%, %nullDCcfg%, nullDC, Emulator.AutoStart
  85. IniWrite, %noConsole%, %nullDCcfg%, nullDC, Emulator.NoConsole
  86. IniWrite, %autoHideMenu%, %nullDCcfg%, nullDC_GUI, AutoHideMenu
  87. IniWrite, %alwaysOnTop%, %nullDCcfg%, nullDC_GUI, AlwaysOnTop
  88. IniWrite, %showVMU%, %nullDCcfg%, drkMaple, VMU.Show
  89. IniWrite, %loadDefaultImage%, %nullDCcfg%, ImageReader, LoadDefaultImage
  90. IniWrite, %patchRegion%, %nullDCcfg%, ImageReader, PatchRegion
  91. IniWrite, %region%, %nullDCcfg%, nullDC, Dreamcast.Region
  92. IniWrite, %cable%, %nullDCcfg%, nullDC, Dreamcast.Cable
  93. IniWrite, %romPath%\%romname%%RomExtension%, %nullDCcfg%, ImageReader, DefaultImage
  94.  
  95. ;Fixes hanging previous nullDC on bad exits or loads
  96. Process("Exist", executable)
  97. If !ErrorLevel = 0
  98. Process("Close", executable)
  99.  
  100. ; This hides nullDC's menu when running dual screens
  101. If dualMonitors = true
  102. { MouseGetPos X, Y
  103. SetDefaultMouseSpeed, 0
  104. MouseMove %A_ScreenWidth%,%A_ScreenHeight%
  105. }
  106.  
  107. HideEmuStart() ; This fully ensures windows are completely hidden even faster than winwait
  108.  
  109. Run(executable, emuPath)
  110.  
  111. ; TESTING TO HIDE THE CONSOLE WINDOW POPUP, NOTHING WORKS
  112. ; WinWait("nullDC ahk_class ndc_main_window")
  113. ; WinSet, Transparent, On, nullDC ahk_class ndc_main_window
  114. ; WinSet, Transparent, On, ahk_class ConsoleWindowClass ; makes the console window transparent so you don't see it on exit
  115. ; Sleep, 2000 ; Enough to hide the startup logo
  116. ; WinHide, ahk_class ConsoleWindowClass
  117.  
  118. WinWait("nullDC ahk_class ndc_main_window")
  119. WinWaitActive("nullDC ahk_class ndc_main_window")
  120.  
  121. ndcID:=WinExist("A") ; storing the window's PID so we can toggle it later
  122. ToggleMenu(ndcID) ; Removes the MenuBar
  123. ; DllCall("SetMenu", uint, WinActive( "A" ), uint, 0) ; Removes the MenuBar
  124.  
  125. ;Let's completely hide the menu by slighly moving the window off screen
  126. ;nullDC will self adjust once the menu autohides
  127. If fullScreen = true
  128. { yOffset = -20
  129. winHeight := A_ScreenHeight - yOffset
  130. WinMove, nullDC,, 0, %yOffset%, %A_ScreenWidth%, %winHeight%
  131. }
  132.  
  133. ; WinShow, nullDC ahk_class ndc_main_window ; without these, nullDC may stay hidden behind HS
  134. ; WinActivate, nullDC ahk_class ndc_main_window
  135. HideEmuEnd()
  136. BezelDraw()
  137. If !(showVMU="0")
  138. SetTimer, CheckforVMU, 10000
  139. FadeInExit()
  140. WinSet, Transparent, Off, nullDC ahk_class ndc_main_window
  141. Process("WaitClose", executable)
  142. 7zCleanUp()
  143. BezelExit()
  144. ExtraFixedResBezelExit()
  145. FadeOutExit()
  146. ExitModule()
  147.  
  148.  
  149. ; Toggle the MenuBar
  150. !a::
  151. ToggleMenu(ndcID)
  152. Return
  153.  
  154. MultiGame:
  155. ; msgbox % "selectedRom = " . selectedRom . "`nselected game = " . currentButton . "`nmgRomPath = " . mgRomPath . "`nmgRomExt = " . mgRomExt . "`nmgRomName = " . mgRomName
  156. ToggleMenu(ndcID) ; Restore the MenuBar
  157. Loop {
  158. WinMenuSelectItem,nullDC ahk_class ndc_main_window,,Options,GDRom,Select Default Image
  159. WinWait("Select Image File ahk_class #32770")
  160. WinWaitActive("Select Image File ahk_class #32770")
  161. If WinActive("Select Image File ahk_class #32770")
  162. Break
  163. }
  164. OpenROM("Select Image File ahk_class #32770", mgRomPath . "\" . mgRomName . "." . mgRomExt) ; unsure if Select Image File needs to be translated via i18n
  165. WinWaitActive("nullDC ahk_class ndc_main_window")
  166. Sleep, 300 ; giving time for emu to mount the new image
  167. WinMenuSelectItem,nullDC ahk_class ndc_main_window,,Options,GDRom,Swap Disc ; DC does not support swapping discs on-the-fly like psx because the console reset when the drive was opened. This basically tells the emu to reset.
  168. ToggleMenu(ndcID) ; Removes the MenuBar
  169. Return
  170.  
  171. BezelLabel:
  172. disableHideToggleMenu := true
  173. Return
  174.  
  175. HaltEmu:
  176. If VMUHideKey
  177. XHotKeywrapper(VMUHideKey,"VMUHide","OFF")
  178. Return
  179.  
  180. RestoreEmu:
  181. If VMULoaded
  182. { Loop, 4
  183. { WinSet, Transparent, 0, % "ahk_ID " . VMUScreenID%A_Index%
  184. WinSet, AlwaysOnTop, On, % "ahk_ID " . VMUScreenID%A_Index%
  185. WinShow, % "ahk_ID " . VMUScreenID%A_Index%
  186. }
  187. WinSet, AlwaysOnTop, On, ahk_ID %extraFixedRes_Bezel_hwnd%
  188. WinShow, ahk_ID %extraFixedRes_Bezel_hwnd%
  189. If !(VMUHidden)
  190. Loop, 4
  191. WinSet, Transparent, off, % "ahk_ID " . VMUScreenID%A_Index%
  192. }
  193. If VMUHideKey
  194. XHotKeywrapper(VMUHideKey,"VMUHide","ON")
  195. Return
  196.  
  197. CheckforVMU:
  198. Loop, 4
  199. { Transform, letter, Chr, % A_Index + asc("A") - 1 ; transform number to letter
  200. If ((!(VMU%A_Index%Draw)) and (VMUScreenID%A_Index%:=WinExist("nullDC VMU " . letter . "0 ahk_class #32770")))
  201. { WinSet, Transparent, 0, % "ahk_ID " . VMUScreenID%A_Index%
  202. WinSet, AlwaysOnTop, On, % "ahk_ID " . VMUScreenID%A_Index%
  203. ExtraFixedResBezelDraw(VMUScreenID%A_Index%, "VMU",VMU%A_Index%Pos, 144, 96, 8, 8, 28, 8)
  204. WinShow, % "ahk_ID " . VMUScreenID%A_Index%
  205. WinSet, AlwaysOnTop, On, ahk_ID %extraFixedRes_Bezel_hwnd%
  206. WinShow, ahk_ID %extraFixedRes_Bezel_hwnd%
  207. WinSet, Transparent, off, % "ahk_ID " . VMUScreenID%A_Index%
  208. VMU%A_Index%Draw := true
  209. If !(VMULoaded){
  210. VMUHideKey := xHotKeyVarEdit(VMUHideKey,"VMUHideKey","~","Add")
  211. xHotKeywrapper(VMUHideKey,"VMUHide")
  212. VMULoaded := true
  213. }
  214. }
  215. }
  216. If ((VMU1Draw) and (VMU2Draw) and (VMU3Draw) and (VMU4Draw))
  217. SetTimer, CheckforVMU, off
  218. Return
  219.  
  220. VMUHide:
  221. If (VMUHidden)
  222. { Loop, 4
  223. WinSet, Transparent, off, % "ahk_ID " . VMUScreenID%A_Index%
  224. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,255)
  225. VMUHidden := false
  226. } Else {
  227. Loop, 4
  228. WinSet, Transparent, 0, % "ahk_ID " . VMUScreenID%A_Index%
  229. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,0)
  230. VMUHidden := true
  231. }
  232. Return
  233.  
  234. CloseProcess:
  235. If VMULoaded
  236. SetTimer, checkforVMU, off
  237. FadeOutStart()
  238. ; WinClose("ahk_class ConsoleWindowClass")
  239. WinClose("nullDC ahk_class ndc_main_window")
  240. Return
Advertisement
Add Comment
Please, Sign In to add comment