Advertisement
djvj

Untitled

Mar 4th, 2015
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.85 KB | None | 0 0
  1. MEmu = Demul
  2. MEmuV = v0.5.8.2
  3. MURL = http://demul.emulation64.com/
  4. MAuthor = djvj
  5. MVersion = 2.0.5 BETA
  6. MCRC = EFEE7501
  7. iCRC = F43FB746
  8. mId = 635211874656892855
  9. MSystem = "Gaelco","Sammy Atomiswave","Sega Dreamcast","Sega Hikaru","Sega Naomi","Sega Naomi 2"
  10. ;----------------------------------------------------------------------------
  11. ; Notes:
  12. ; Required - control and nvram files can be found in my user dir on the FTP at /Upload Here/djvj/Sega Naomi\Emulators. Additonal instructions from my orignal HL1.0 script at http://www.hyperspin-fe.com/forum/showpost.php?p=86093&postcount=104
  13. ; Required - moduleName ini example can be found on GIT in the Demul module folder
  14. ; moduleName ini must be placed in same folder as this module if you use the provided example, just be sure to rename it to just Demul.ini first so it matches the module's name
  15. ; GDI images must match mame zip names and be extracted and have a .dat extension
  16. ; Rom_Extension should include 7z|zip|gdi|cue|cdi|chd|mds|ccd|nrg
  17. ; Module will automatically set your rom path for you on first launch
  18. ;
  19. ; Make sure the awbios, dc, hikaru, naomi, naomi2, saturn.zip bios archives are in any of your rom paths as they are needed to play all the games.
  20. ; Set your Video Plugin to gpuDX11 and set your desired resolution there
  21. ; In case your control codes do not match mine, set your desired control type in demul, then open the demul.ini and find section PORTB and look for the device key. Use this number instead of the one I provided
  22. ; gpuDX10 and gpuDX11 are the only supported plugins. You can define what plugin you want to use for each game in the module settings in HLHQ
  23. ; Read the tooltip for the Fullscreen module setting in HLHQ on how to control windowed fullscreen, true fullscreen, or windowed mode
  24. ; Windowed fullscreen will take effect the 2nd time you run the emu. It has to calculate your resolution on first run.
  25. ;
  26. ; Controls:
  27. ; Start a game of each control type (look in the HLHQ's module settings for these types, they all have their own tabs) and configure your controls to play the game. After configuring your controls manually in Demul, open padDemul.ini and Copy/paste the JAMMA0_0 and JAMMA0_1 (for naomi) or the ATOMISWAVE0_0 and ATOMISWAVE0_1 (for atomiswave) into HLHQ's module settings for each controls tab (standard, sfstyle, etc).
  28. ; Each pair of control tabs designates another real arcade control schema for a grouping of games. Demul does not handle this like MAME, so the module does instead.
  29. ;
  30. ; Troubleshooting:
  31. ; For some reason demul's ini files can get corrupted and ahk can't read/write to them correctly.
  32. ; If your ini keys are not being read or not writing to their existing keys in the demul inis, create a new file and copy/paste everything from the old ini into the new one and save.
  33. ; If you use Fade_Out, the module will disable it. Demul crashes when Fade tries to draw on top of it in windowed and fullscreen modes.
  34. ;----------------------------------------------------------------------------
  35. StartModule()
  36. BezelGUI()
  37. ExtraFixedResBezelGUI()
  38. FadeInStart()
  39.  
  40. ; This object controls how the module reacts to different systems. Demul can play a few systems, but needs to know what system you want to run, so this module has to adapt.
  41. mType := Object("Gaelco","gaelco","Sammy Atomiswave","atomiswave","Sega Dreamcast","dc","Sega Hikaru","hikaru","Sega Naomi","naomi","Sega Naomi 2","naomi2")
  42. ident := mType[systemName] ; search object for the systemName identifier Demul uses
  43. If !ident
  44. ScriptError("Your systemName is: " . systemName . "`nIt is not one of the known supported systems for this Demul module: " . moduleName)
  45.  
  46. settingsFile := modulePath . "\" . moduleName . ".ini"
  47. demulFile := CheckFile(emuPath . "\Demul.ini", "Could not find Demul's ini. Please run Demul manually first and each of it's settings sections so the appropriate inis are created for you: " . emuPath . "\Demul.ini")
  48. padFile := CheckFile(emuPath . "\padDemul.ini", "Could not find Demul's control ini. Please run Demul manually first and set up your controls so this file is created for you: " . emuPath . "\padDemul.ini")
  49.  
  50. demulFileEncoding := COM_Invoke(HLObject, "getFileEncoding", demulFile)
  51. If demulFileEncoding {
  52. Log("Module - Recreating demul.ini as ANSI because UTF-8 format cannot be read")
  53. If COM_Invoke(HLObject, "removeBOM", demulFile)
  54. Log("Module - Successfully converted demul.ini to ANSI")
  55. Else
  56. Log("Module - Failed to convert demul.ini to ANSI",3)
  57. }
  58.  
  59. maxHideTaskbar := IniReadCheck(settingsFile, "Settings", "MaxHideTaskbar", "true",,1)
  60. controllerCode := IniReadCheck(settingsFile, "Settings", "ControllerCode", "16777216",,1)
  61. mouseCode := IniReadCheck(settingsFile, "Settings", "MouseCode", "131072",,1)
  62. keyboardCode := IniReadCheck(settingsFile, "Settings", "KeyboardCode", "1073741824",,1)
  63. lightgunCode := IniReadCheck(settingsFile, "Settings", "LightgunCode", "-2147483648",,1)
  64. lastControlUsed := IniReadCheck(settingsFile, "Settings", "LastControlUsed",,,1)
  65. hideDemulGUI := IniReadCheck(settingsFile, "Settings", "HideDemulGUI", "true",,1)
  66.  
  67. fullscreen := IniReadCheck(settingsFile, "Settings|" . romName, "Fullscreen", "windowedfullscreen",,1)
  68. plugin := IniReadCheck(settingsFile, "Settings|" . romName, "Plugin", "gpuDX11",,1)
  69. shaderUsePass1 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderUsePass1", "false",,1)
  70. shaderUsePass2 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderUsePass2", "false",,1)
  71. shaderNamePass1 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderNamePass1",,,1)
  72. shaderNamePass2 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderNamePass2",,,1)
  73. listSorting := IniReadCheck(settingsFile, "Settings|" . romName, "ListSorting", "true",,1)
  74. internalResolutionScale := IniReadCheck(settingsFile, "Settings|" . romName, "InternalResolutionScale", "1",,1)
  75. videomode := IniReadCheck(settingsFile, "Settings|" . romName, "VideoMode", "0",,1)
  76.  
  77. displayVMU := IniReadCheck(settingsFile, "Settings", "DisplayVMU", "true",,1)
  78. VMUPos := IniReadCheck(settingsFile, "Settings", "VMUPos", "topRight",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  79. VMUHideKey := IniReadCheck(settingsFile, "Settings", "VMUHideKey","F10",,1)
  80.  
  81. Bios := IniReadCheck(settingsFile, romName, "Bios",,,1)
  82. LoadDecrypted := IniReadCheck(settingsFile, romName, "LoadDecrypted",,,1) ; not currently supported
  83.  
  84. ; Read all the control values
  85. controls := IniReadCheck(settingsFile, romname, "Controls", "standard",,1) ; have to read this first so the below ini reads work
  86. push1_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push1",,,1)
  87. push2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push2",,,1)
  88. push3_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push3",,,1)
  89. push4_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push4",,,1)
  90. push5_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push5",,,1)
  91. push6_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push6",,,1)
  92. push7_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push7",,,1)
  93. push8_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push8",,,1)
  94. service_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "SERVICE",,,1)
  95. start_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "START",,,1)
  96. coin_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "COIN",,,1)
  97. digitalup_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALUP",,,1)
  98. digitaldown_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALDOWN",,,1)
  99. digitalleft_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALLEFT",,,1)
  100. digitalright_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALRIGHT",,,1)
  101. analogup_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGUP",,,1)
  102. analogdown_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGDOWN",,,1)
  103. analogleft_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGLEFT",,,1)
  104. analogright_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGRIGHT",,,1)
  105. analogup2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGUP2",,,1)
  106. analogdown2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGDOWN2",,,1)
  107. analogleft2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGLEFT2",,,1)
  108. analogright2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGRIGHT2",,,1)
  109. push1_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push1",,,1)
  110. push2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push2",,,1)
  111. push3_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push3",,,1)
  112. push4_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push4",,,1)
  113. push5_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push5",,,1)
  114. push6_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push6",,,1)
  115. push7_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push7",,,1)
  116. push8_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push8",,,1)
  117. service_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "SERVICE",,,1)
  118. start_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "START",,,1)
  119. coin_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "COIN",,,1)
  120. digitalup_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALUP",,,1)
  121. digitaldown_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALDOWN",,,1)
  122. digitalleft_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALLEFT",,,1)
  123. digitalright_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALRIGHT",,,1)
  124. analogup_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGUP",,,1)
  125. analogdown_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGDOWN",,,1)
  126. analogleft_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGLEFT",,,1)
  127. analogright_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGRIGHT",,,1)
  128. analogup2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGUP2",,,1)
  129. analogdown2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGDOWN2",,,1)
  130. analogleft2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGLEFT2",,,1)
  131. analogright2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGRIGHT2",,,1)
  132.  
  133. ; Verify user set desired gpu plugin name correctly
  134. If ( plugin != "gpuDX11" && plugin != "gpuDX10" && plugin != "")
  135. ScriptError(plugin . " is not a supported gpu plugin.`nLeave the plugin blank to use the default ""gpuDX11"".`nValid options are gpuDX11 or gpuDX10.")
  136.  
  137. ; Read and write videomode value for cable type
  138. IniWrite, %videomode%, %demulFile%, main, videomode
  139. Log("Module - Demul is updating the config with videomode = " . videomode)
  140. ExitApp
  141.  
  142. ; Handle Demul's rom paths so the user doesn't have to
  143. IniRead, romPathCount, %demulFile%, files, romsPathsCount
  144. Log("Module - Demul is configured with " . romPathCount . " rom path(s). Scanning these for a romPath to this rom.")
  145. Loop, %romPathCount%
  146. { demulRomPath := A_Index - 1 ; rompaths in demul start with 0
  147. IniRead, path%A_Index%, %demulFile%, files, roms%demulRomPath%
  148. Log("Module - Path" . demulRomPath . ": " . path%A_Index%)
  149. ; msgbox % path%A_Index%
  150. If (path%A_Index% = romPath . "\") ; demul tacks on the backslash at the end
  151. { romPathFound := 1 ; flag that demul has this romPath in its config and no need to add it
  152. Log("Module - Stopping search because Demul is already configured with the correct romPath to this rom: " . path%A_Index%)
  153. Break ; stop looking for a correct romPath
  154. }
  155. }
  156. If !romPathFound ; if demul doesn't have the romPath in its ini, add it
  157. { Log("Module - Demul does not have this romPath in Demul.ini, adding it for you.",2)
  158. nextPath := romPathCount + 1 ; add 1 to the romPathCount and write that to the ini
  159. IniWrite, %nextPath%, %demulFile%, files, romsPathsCount
  160. IniWrite, %romPath%\, %demulFile%, files, % "roms" . romPathCount ; write the rompath to the ini
  161. }
  162.  
  163. BezelStart("FixResMode")
  164.  
  165. ; Force Fade_Out to disabled as it causes demul to not close properly
  166. fadeOut = false
  167. Log("Module - Turning off Fade_Out because it doesn't let Demul exit properly.",2)
  168.  
  169. ; check for the specified gpu plugin
  170. gpuFile := CheckFile(emuPath . "\" . plugin . ".ini")
  171.  
  172. ; This updates the DX11gpu ini file to turn List Sorting on or off. Depending on the games, turning this on for some games may remedy missing graphics, having it off on other games may fix corrupted graphics. Untill they improve the DX11gpu, this is the best it's gonna get.
  173. If ListSorting = true
  174. IniWrite, 0, %gpuFile%, main, AutoSort
  175. Else
  176. IniWrite, 1, %gpuFile%, main, AutoSort
  177.  
  178. ; This updates the DX10gpu or DX11gpu ini file to the scale you want to use for this game
  179. IniWrite, %InternalResolutionScale%, %gpuFile%, main, scaling
  180.  
  181. ; This updates the demul.ini with your gpu plugin choice for the selected rom
  182. IniWrite, %plugin%.dll, %demulFile%, plugins, gpu
  183.  
  184. ; This updates the demul.ini with your VMU display choice
  185. VMUscreendisable := if (displayVMU="true") ? "false" : "true"
  186. IniWrite, %VMUscreendisable% , %demulFile%, main, VMUscreendisable
  187.  
  188. ; Shader Effects
  189. Loop, 2 {
  190. shaderUsePass%A_Index% := If (ShaderUsePass%A_Index% != "" and ShaderUsePass%A_Index% != "ERROR" ? (ShaderUsePass%A_Index%) : (GlobalShaderUsePass%A_Index%)) ; determine what shaderUsePass to use
  191. IniRead, currentusePass%A_Index%, %gpuFile%, shaders, usePass%A_Index%
  192. If (shaderUsePass%A_Index% = "true")
  193. {
  194. shaderNamePass%A_Index% := If (ShaderNamePass%A_Index% != "" and ShaderNamePass%A_Index% != "ERROR" ? (ShaderNamePass%A_Index%) : (GlobalShaderNamePass%A_Index%)) ; determine what shaderNamePass to use
  195. If shaderNamePass%A_Index% not in FXAA,HDR-TV,SCANLINES,CARTOON,RGB DOT(MICRO),RGB DOT(TINY),BLUR
  196. ScriptError(shaderNamePass%A_Index% . " is not a valid choice for a shader. Your options are FXAA, HDR-TV, SCANLINES, CARTOON, RGB DOT(MICRO), RGB DOT(TINY), or BLUR.")
  197. If (currentusePass%A_Index% = 0)
  198. IniWrite, 1, %gpuFile%, shaders, usePass%A_Index% ; turn shader on in gpuDX11 ini
  199. IniWrite, % shaderNamePass%A_Index%, %gpuFile%, shaders, shaderPass%A_Index% ; update gpuDX11 ini with the shader name to use
  200. }Else If (shaderUsePass%A_Index% != "true" and currentusePass%A_Index% = 1)
  201. IniWrite, 0, %gpuFile%, shaders, usePass%A_Index% ; turn shader off in gpuDX11 ini
  202. }
  203.  
  204. If ident = dc
  205. {
  206. 7z(romPath, romName, romExtension, 7zExtractPath)
  207. If ( romExtension = ".cdi" || romExtension = ".mds" || romExtension = ".ccd" || romExtension = ".nrg" || romExtension = ".gdi" || romExtension = ".cue" ) {
  208. gdrImageFile := CreateDefaultGDROMIni("image")
  209. FileDelete, %gdrImageFile%
  210. Sleep, 500
  211. IniWrite, gdrImage.dll, %demulFile%, plugins, gdr
  212. IniWrite, false, %gdrImageFile%, Main, openDialog
  213. IniWrite, %romPath%\%romName%%romExtension%, %gdrImageFile%, Main, imagefilename
  214. } Else If romExtension = .chd
  215. {
  216. gdrCHDFile := CreateDefaultGDROMIni("chd")
  217. FileDelete, %gdrCHDFile%
  218. Sleep, 500
  219. IniWrite, false, %gdrCHDFile%, Main, openDialog
  220. IniWrite, gdrCHD.dll, %demulFile%, plugins, gdr
  221. IniWrite, %romPath%\%romName%%romExtension%, %gdrCHDFile%, Main, imagefilename
  222. } Else
  223. ScriptError(romExtension . " is not a supported file type for this " . moduleName . " module.")
  224.  
  225. IniWrite, 1, %demulFile%, main, region ; Set BIOS to Auto Region
  226. } Else { ; all other systems, Naomi and Atomiswave
  227. ; This updates the demul.ini with your Bios choice for the selected rom
  228. If ( Bios != "" && Bios != "ERROR" ) {
  229. Bios := RegExReplace(Bios,"\s.*") ; Cleans off the added text from the key's value so only the number is left
  230. IniWrite, false, %demulFile%, main, naomiBiosAuto ; turning auto bios off so we can use a specific one instead
  231. IniWrite, %Bios%, %demulFile%, main, naomiBios ; setting specific bios user has set from the moduleName ini
  232. } Else
  233. IniWrite, true, %demulFile%, main, naomiBiosAuto ; turning auto bios on if user did not specify a specific one
  234. }
  235.  
  236. ; This section writes your custom keys to the padDemul.ini. Naomi games had many control panel layouts. The only way we can accomodate these differing controls, is to keep track of them all and write them to the ini at the launch of each game.
  237. ; First we check if the last controls used are the same as the game we want to play, so we don't waste time updating the ini if it is not necessary. For example playing 2 sfstyle type games in a row, we wouldn't need to write to the ini.
  238.  
  239. ; This section tells demul what arcade control type should be connected to the game. Options are standard (aka controller), mouse, lightgun, or keyboard
  240. If ( controls = "lightgun" || controls = "mouse" ) {
  241. Log("Module - This game uses a Mouse or Lightgun control type.")
  242. IniWrite, %MouseCode%, %demulFile%, PORTB, device
  243. } Else If ( controls = "keyboard" ) {
  244. Log("Module - This game uses a Keyboard control type.")
  245. IniWrite, %KeyboardCode%, %demulFile%, PORTB, device
  246. } Else { ; accounts for all other control types
  247. Log("Module - This game uses a standard (controller) control type.")
  248. IniWrite, %ControllerCode%, %demulFile%, PORTB, device
  249. }
  250.  
  251. Log("Module - Last control scheme used was """ . lastControlUsed . """ and this game requires """ . controls . """")
  252. If ( LastControlUsed != controls ) { ; find out last controls used for the system we are launching
  253. WriteControls(padFile, 0,push1_0,push2_0,push3_0,push4_0,push5_0,push6_0,push7_0,push8_0,SERVICE_0,START_0,COIN_0,DIGITALUP_0,DIGITALDOWN_0,DIGITALLEFT_0,DIGITALRIGHT_0,ANALOGUP_0,ANALOGDOWN_0,ANALOGLEFT_0,ANALOGRIGHT_0,ANALOGUP2_0,ANALOGDOWN2_0,ANALOGLEFT2_0,ANALOGRIGHT2_0)
  254. WriteControls(padFile, 1,push1_1,push2_1,push3_1,push4_1,push5_1,push6_1,push7_1,push8_1,SERVICE_1,START_1,COIN_1,DIGITALUP_1,DIGITALDOWN_1,DIGITALLEFT_1,DIGITALRIGHT_1,ANALOGUP_1,ANALOGDOWN_1,ANALOGLEFT_1,ANALOGRIGHT_1,ANALOGUP2_1,ANALOGDOWN2_1,ANALOGLEFT2_1,ANALOGRIGHT2_1)
  255. IniWrite, %controls%, %settingsFile%, Settings, LastControlUsed
  256. Log("Module - Wrote " . controls . " controls to padDemul.ini.")
  257. } Else
  258. Log("Module - Not changing controls because the currently configured controls are the same for this game.")
  259.  
  260. ; Setting demul to use true fullscreen if defined in settings.ini, otherwise sets demul to run windowed. This is for gpuDX11 plugin only
  261. If plugin = gpuDX11
  262. If fullscreen = truefullscreen
  263. IniWrite, 1, %gpuFile%, main, UseFullscreen
  264. Else
  265. IniWrite, 0, %gpuFile%, main, UseFullscreen
  266.  
  267. If fullscreen = windowedfullscreen
  268. {
  269. If maxHideTaskbar = true
  270. {
  271. Log("Module - Hiding Taskbar and Start Button.")
  272. WinHide, ahk_class Shell_TrayWnd
  273. WinHide, Start ahk_class Button
  274. }
  275. ; Create black background to give the emu the fullscreen look
  276. Log("Module - Creating black background to simulate a fullscreen look.")
  277. Gui demulGUI: -Caption +ToolWindow
  278. Gui demulGUI: Color, Black
  279. Gui demulGUI: Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%
  280. }
  281.  
  282. Sleep, 250
  283.  
  284. ; Construct the CLI for demul and send romName if naomi or atomiswave. Dreamcast needs a full path and romName.
  285. If LoadDecrypted = true ; decrypted naomi rom
  286. romCLI := "-customrom=" . """" . romPath . "\" . romName . ".bin"""
  287. Else If ident = dc ; dreamcast game
  288. romCLI := " -image=" . """" . romPath . "\" . romName . romExtension . """"
  289. Else ; standard naomi rom
  290. romCLI := "-rom=" . romName
  291.  
  292. If hideDemulGUI = true
  293. SetTimer, HideGUIWindow, 50 ; start watching for gui window so it can be completely hidden
  294.  
  295. ; Run(executable . " -run=" . ident . " " . romCLI, emuPath,, emuPID)
  296. Run(executable . " -run=" . ident . " " . romCLI, emuPath, (If hideDemulGUI = "true" ? "min" : ""), emuPID) ; launching minimized, then restoring later hides the launch completely
  297. Sleep, 1000 ; Need a second for demul to launch, increase if yours takes longer and the emu is NOT appearing and staying minimized. This is required otherwise bezel backgrounds do not appear
  298.  
  299. DetectHiddenWindows, On
  300. Log("Module - Waiting for Demul to finish loading game.")
  301. Loop { ; looping until demul is done loading rom and gpu starts showing frames
  302. Sleep, 200
  303. WinGetTitle, winTitle, ahk_class window
  304. StringSplit, winTextSplit, winTitle, %A_Space%
  305. If ( winTextSplit5 = "gpu:" And winTextSplit6 != "0" And winTextSplit6 != "1" )
  306. Break
  307. }
  308. Log("Module - Demul finished loading game.")
  309.  
  310. If (InStr(systemName, "Gaelco") && fullscreen = "truefullscreen")
  311. Send !{Enter} ; Automatic fullscreen seems to be broken in the Gaelco driver, must alt+Enter to get fullscreen
  312.  
  313. ; This is where we calculate and maximize demul's window using our pseudo fullscreen code
  314. If fullscreen = windowedfullscreen
  315. {
  316. WinSet, Style, -0x40000, ahk_class window ; Removes the border of the game window
  317. WinSet, Style, -0xC00000, ahk_class window ; Removes the TitleBar
  318. Send, {F3} ; Removes the MenuBar
  319. MaximizeWindow("ahk_class window") ; this will take effect after you run demul once because we cannot stretch demul's screen while it is running.
  320. }
  321.  
  322. If hideDemulGUI = true
  323. { SetTimer, HideGUIWindow, Off
  324. WinSet, Transparent, Off, ahk_class window
  325. }
  326.  
  327. BezelDraw()
  328. If (displayVMU="true"){
  329. WinGet VMUWindowID, ID, LCD 0 ahk_class LCD 0
  330. ExtraFixedResBezelDraw(VMUWindowID, "VMU", VMUPos, 144, 96, 8, 8, 28, 8)
  331. VMUHideKey := xHotKeyVarEdit(VMUHideKey,"VMUHideKey","~","Add")
  332. xHotKeywrapper(VMUHideKey,"VMUHide")
  333. }
  334. FadeInExit()
  335. Process("WaitClose", executable)
  336.  
  337. If fullscreen = windowedfullscreen
  338. { Gui demulGUI: Destroy
  339. Log("Module - Destroyed black gui background.")
  340. }
  341.  
  342. BezelExit()
  343. ExtraFixedResBezelExit()
  344. FadeOutExit()
  345.  
  346. If (fullscreen = "windowedfullscreen" && maxHideTaskbar = "true") {
  347. Log("Module - Showing Taskbar and Start Button.")
  348. WinShow,ahk_class Shell_TrayWnd
  349. WinShow,Start ahk_class Button
  350. }
  351.  
  352. ExitModule()
  353.  
  354.  
  355. ; Write new controls to padDemul.ini
  356. WriteControls(file, player,push1,push2,push3,push4,push5,push6,push7,push8,service,start,coin,digitalup,digitaldown,digitalleft,digitalright,analogup,analogdown,analogleft,analogright,analogup2,analogdown2,analogleft2,analogright2) {
  357. IniWrite, %push1%, %file%, JAMMA0_%player%, PUSH1
  358. IniWrite, %push2%, %file%, JAMMA0_%player%, PUSH2
  359. IniWrite, %push3%, %file%, JAMMA0_%player%, PUSH3
  360. IniWrite, %push4%, %file%, JAMMA0_%player%, PUSH4
  361. IniWrite, %push5%, %file%, JAMMA0_%player%, PUSH5
  362. IniWrite, %push6%, %file%, JAMMA0_%player%, PUSH6
  363. IniWrite, %push7%, %file%, JAMMA0_%player%, PUSH7
  364. IniWrite, %push8%, %file%, JAMMA0_%player%, PUSH8
  365. IniWrite, %service%, %file%, JAMMA0_%player%, SERVICE
  366. IniWrite, %start%, %file%, JAMMA0_%player%, START
  367. IniWrite, %coin%, %file%, JAMMA0_%player%, COIN
  368. IniWrite, %digitalup%, %file%, JAMMA0_%player%, DIGITALUP
  369. IniWrite, %digitaldown%, %file%, JAMMA0_%player%, DIGITALDOWN
  370. IniWrite, %digitalleft%, %file%, JAMMA0_%player%, DIGITALLEFT
  371. IniWrite, %digitalright%, %file%, JAMMA0_%player%, DIGITALRIGHT
  372. IniWrite, %analogup%, %file%, JAMMA0_%player%, ANALOGUP
  373. IniWrite, %analogdown%, %file%, JAMMA0_%player%, ANALOGDOWN
  374. IniWrite, %analogleft%, %file%, JAMMA0_%player%, ANALOGLEFT
  375. IniWrite, %analogright%, %file%, JAMMA0_%player%, ANALOGRIGHT
  376. IniWrite, %analogup2%, %file%, JAMMA0_%player%, ANALOGUP2
  377. IniWrite, %analogdown2%, %file%, JAMMA0_%player%, ANALOGDOWN2
  378. IniWrite, %analogleft2%, %file%, JAMMA0_%player%, ANALOGLEFT2
  379. IniWrite, %analogright2%, %file%, JAMMA0_%player%, ANALOGRIGHT2
  380. }
  381.  
  382. MaximizeWindow(class) {
  383. Global MEmu,plugin,gpuFile
  384. Log("MaximizeWindow - Started")
  385. WinGetPos, appX, appY, appWidth, appHeight, %class%
  386. Log("MaximizeWindow - " . MEmu . " is currently x: " . appX . " y: " . appY . " w: " . appWidth . " h: " . appHeight,4)
  387. widthMaxPercenty := ( A_ScreenWidth / appWidth )
  388. heightMaxPercenty := ( A_ScreenHeight / appHeight )
  389.  
  390. If ( widthMaxPercenty < heightMaxPercenty )
  391. percentToEnlarge := widthMaxPercenty
  392. Else
  393. percentToEnlarge := heightMaxPercenty
  394.  
  395. appWidthNew := appWidth * percentToEnlarge
  396. appHeightNew := appHeight * percentToEnlarge
  397. Transform, appX, Round, %appX%
  398. Transform, appY, Round, %appY%
  399. Transform, appWidthNew, Round, %appWidthNew%
  400. Transform, appHeightNew, Round, %appHeightNew%
  401. appXPos := ( A_ScreenWidth / 2 ) - ( appWidthNew / 2 )
  402. appYPos := ( A_ScreenHeight / 2 ) - ( appHeightNew / 2 )
  403. If ( plugin = "gpuDX11" ) {
  404. IniWrite, %appWidthNew%, %gpuFile%, resolution, Width
  405. IniWrite, %appHeightNew%, %gpuFile%, resolution, Height
  406. } Else {
  407. IniWrite, %appWidthNew%, %gpuFile%, resolution, wWidth
  408. IniWrite, %appHeightNew%, %gpuFile%, resolution, wHeight
  409. }
  410. WinMove, %class%,, appXPos, appYPos
  411. Log("MaximizeWindow - " . MEmu . " resized to x: " . appX . " y: " . appY . " w: " . appWidthNew . " h: " . appHeightNew,4)
  412. Log("MaximizeWindow - Ended")
  413. }
  414.  
  415. ; Creates a default gdrCHD.ini or gdrImage.ini in your emu folder if one does not exist already.
  416. CreateDefaultGDROMIni(type) {
  417. Global emuPath
  418. defaultIni := "[main]`r`nimageFileName = `r`nopenDialog = false"
  419. IniType := If type = "chd" ? "gdrCHD.ini" : "gdrImage.ini"
  420. FileAppend, %defaultIni%, % emuPath . "\" . IniType
  421. Return emuPath . "\" . IniType
  422. }
  423.  
  424. HaltEmu:
  425. If fullscreen = truefullscreen
  426. Send !{ENTER}
  427. Return
  428. RestoreEmu:
  429. If fullscreen = truefullscreen
  430. Send !{ENTER}
  431. Return
  432.  
  433. HideGUIWindow:
  434. WinSet, Transparent, On, ahk_class window
  435. WinActivate ahk_class window ; once activated, demul starts loading the rom
  436. Return
  437.  
  438. VMUHide:
  439. If (VMUHidden) {
  440. WinSet, Transparent, off, ahk_ID %VMUWindowID%
  441. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,255)
  442. ;WinSet, Transparent, off, ahk_ID %extraFixedRes_Bezel_hwnd%
  443. ;WinShow, extraFixedRes_Bezel_GUI
  444. ;WinShow, extraFixedRes_Bezel_GUI
  445. VMUHidden := false
  446. } Else {
  447. WinSet, Transparent, 0, ahk_ID %VMUWindowID%
  448. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,0)
  449. ;WinSet, Transparent, 0, ahk_ID %extraFixedRes_Bezel_hwnd%
  450. ;WinHide, extraFixedRes_Bezel_GUI
  451. VMUHidden := true
  452. }
  453. Return
  454.  
  455. CloseProcess:
  456. FadeOutStart()
  457. PostMessage, 0x111, 40085,,,ahk_class window ; Stop emulation first for a clean exit
  458. Sleep, 5 ; just like to give a little time before closing
  459. PostMessage, 0x111, 40080,,,ahk_class window ; Exit
  460. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement