Advertisement
djvj

Untitled

Jul 29th, 2015
1,029
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.89 KB | None | 0 0
  1. MEmu = Demul
  2. MEmuV = v0.7a
  3. MURL = http://demul.emulation64.com/
  4. MAuthor = djvj
  5. MVersion = 2.0.5
  6. MCRC = F2417FC2
  7. iCRC = 6192134B
  8. mId = 635211874656892855
  9. MSystem = "Cave 3rd","Gaelco","Sammy Atomiswave","Sega System SP","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 RocketLauncherUI
  23. ; Read the tooltip for the Fullscreen module setting in RocketLauncherUI 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 RocketLauncherUI'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 RocketLauncherUI'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. ; Gaelco:
  31. ; There is no known way to launch the desired Gaelco rom from CLI. You will always be presented with the rom selection window on launch.
  32. ; GPUDX11 does not yet support Gaelco in true fullscreen mode. Either use DX10 which does support fullscreen for Gaelco
  33. ; or if using DX11, choose fullscreen in the video options and then match the windows resolution to your desktop. This will give a pseudo fullscreen mode.
  34. ;
  35. ; Sega Hikaru:
  36. ; Windowed Fullscreen doesn't seem to work as demul does not allow stretching of its window
  37. ;
  38. ; Troubleshooting:
  39. ; For some reason demul's ini files can get corrupted and ahk can't read/write to them correctly.
  40. ; 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.
  41. ; 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.
  42. ;----------------------------------------------------------------------------
  43. StartModule()
  44. BezelGUI()
  45. ExtraFixedResBezelGUI()
  46. FadeInStart()
  47.  
  48. ; 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.
  49. mType := Object("Cave 3rd","cave3rd","Gaelco","gaelco","Sammy Atomiswave","awave","Sammy System SP","naomi","Sega Dreamcast","dc","Sega Hikaru","hikaru","Sega Naomi","naomi","Sega Naomi 2","naomi2")
  50. ident := mType[systemName] ; search object for the systemName identifier Demul uses
  51. If !ident
  52. ScriptError("Your systemName is: " . systemName . "`nIt is not one of the known supported systems for this Demul module: " . moduleName)
  53.  
  54. settingsFile := modulePath . "\" . moduleName . ".ini"
  55. 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")
  56. 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")
  57.  
  58. demulFileEncoding := COM_Invoke(RLObject, "getFileEncoding", demulFile)
  59. If demulFileEncoding {
  60. Log("Module - Recreating " . demulFile . " as ANSI because UTF-8 format cannot be read")
  61. If COM_Invoke(RLObject, "removeBOM", demulFile)
  62. Log("Module - Successfully converted " . demulFile . " to ANSI")
  63. Else
  64. Log("Module - Failed to convert " . demulFile . " to ANSI",3)
  65. }
  66.  
  67. maxHideTaskbar := IniReadCheck(settingsFile, "Settings", "MaxHideTaskbar", "true",,1)
  68. controllerCode := IniReadCheck(settingsFile, "Settings", "ControllerCode", "16777216",,1)
  69. mouseCode := IniReadCheck(settingsFile, "Settings", "MouseCode", "131072",,1)
  70. keyboardCode := IniReadCheck(settingsFile, "Settings", "KeyboardCode", "1073741824",,1)
  71. lightgunCode := IniReadCheck(settingsFile, "Settings", "LightgunCode", "-2147483648",,1)
  72. lastControlUsed := IniReadCheck(settingsFile, "Settings", "LastControlUsed",,,1)
  73. hideDemulGUI := IniReadCheck(settingsFile, "Settings", "HideDemulGUI", "true",,1)
  74. PerGameMemoryCards := IniReadCheck(settingsFile, "Settings", "PerGameMemoryCards", "true",,1)
  75. memCardPath := IniReadCheck(settingsFile, "Settings", "MemCardPath", emuPath . "\memsaves",,1)
  76. memCardPath := AbsoluteFromRelative(emuPath, memCardPath)
  77.  
  78. fullscreen := IniReadCheck(settingsFile, "Settings|" . romName, "Fullscreen", "windowedfullscreen",,1)
  79. plugin := IniReadCheck(settingsFile, "Settings|" . romName, "Plugin", "gpuDX11",,1)
  80. shaderUsePass1 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderUsePass1", "false",,1)
  81. shaderUsePass2 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderUsePass2", "false",,1)
  82. shaderNamePass1 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderNamePass1",,,1)
  83. shaderNamePass2 := IniReadCheck(settingsFile, "Settings|" . romName, "ShaderNamePass2",,,1)
  84. listSorting := IniReadCheck(settingsFile, "Settings|" . romName, "ListSorting", "true",,1)
  85. OpaqueMod := IniReadCheck(settingsFile, "Settings|" . romName, "OModifier", "true",,1)
  86. TransMod := IniReadCheck(settingsFile, "Settings|" . romName, "TModifier", "true",,1)
  87. internalResolutionScale := IniReadCheck(settingsFile, "Settings|" . romName, "InternalResolutionScale", "1",,1)
  88. videomode := IniReadCheck(settingsFile, "Settings|" . romName, "VideoMode", "0",,1)
  89.  
  90. displayVMU := IniReadCheck(settingsFile, "Settings", "DisplayVMU", "true",,1)
  91. VMUPos := IniReadCheck(settingsFile, "Settings", "VMUPos", "topRight",,1) ; topRight, topCenter, topLeft, leftCenter, bottomLeft, bottomCenter, bottomRight, rightCenter
  92. VMUHideKey := IniReadCheck(settingsFile, "Settings", "VMUHideKey","F10",,1)
  93.  
  94. Bios := IniReadCheck(settingsFile, romName, "Bios",,,1)
  95. LoadDecrypted := IniReadCheck(settingsFile, romName, "LoadDecrypted",,,1) ; not currently supported
  96.  
  97. ; Read all the control values
  98. controls := IniReadCheck(settingsFile, romname, "Controls", "standard",,1) ; have to read this first so the below ini reads work
  99. push1_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push1",,,1)
  100. push2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push2",,,1)
  101. push3_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push3",,,1)
  102. push4_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push4",,,1)
  103. push5_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push5",,,1)
  104. push6_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push6",,,1)
  105. push7_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push7",,,1)
  106. push8_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "push8",,,1)
  107. service_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "SERVICE",,,1)
  108. start_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "START",,,1)
  109. coin_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "COIN",,,1)
  110. digitalup_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALUP",,,1)
  111. digitaldown_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALDOWN",,,1)
  112. digitalleft_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALLEFT",,,1)
  113. digitalright_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "DIGITALRIGHT",,,1)
  114. analogup_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGUP",,,1)
  115. analogdown_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGDOWN",,,1)
  116. analogleft_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGLEFT",,,1)
  117. analogright_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGRIGHT",,,1)
  118. analogup2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGUP2",,,1)
  119. analogdown2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGDOWN2",,,1)
  120. analogleft2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGLEFT2",,,1)
  121. analogright2_0 := IniReadCheck(settingsFile, controls . "_JAMMA0_0", "ANALOGRIGHT2",,,1)
  122. push1_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push1",,,1)
  123. push2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push2",,,1)
  124. push3_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push3",,,1)
  125. push4_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push4",,,1)
  126. push5_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push5",,,1)
  127. push6_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push6",,,1)
  128. push7_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push7",,,1)
  129. push8_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "push8",,,1)
  130. service_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "SERVICE",,,1)
  131. start_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "START",,,1)
  132. coin_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "COIN",,,1)
  133. digitalup_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALUP",,,1)
  134. digitaldown_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALDOWN",,,1)
  135. digitalleft_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALLEFT",,,1)
  136. digitalright_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "DIGITALRIGHT",,,1)
  137. analogup_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGUP",,,1)
  138. analogdown_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGDOWN",,,1)
  139. analogleft_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGLEFT",,,1)
  140. analogright_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGRIGHT",,,1)
  141. analogup2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGUP2",,,1)
  142. analogdown2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGDOWN2",,,1)
  143. analogleft2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGLEFT2",,,1)
  144. analogright2_1 := IniReadCheck(settingsFile, controls . "_JAMMA0_1", "ANALOGRIGHT2",,,1)
  145.  
  146. If (InStr(systemName, "Hikaru") && plugin != "gpuDX11")
  147. plugin := "gpuDX11" ; Hikaru does not work with gpuDX10 gpu plugin, setting it dumps an error
  148.  
  149. ; Verify user set desired gpu plugin name correctly
  150. If (plugin != "gpuDX11ng" && plugin != "gpuDX11" && plugin != "gpuDX10" && plugin != "")
  151. ScriptError(plugin . " is not a supported gpu plugin.`nLeave the plugin blank to use the default ""gpuDX11"".`nValid options are gpuDX11ng, gpuDX11 or gpuDX10.")
  152.  
  153. ; Read and write videomode value for cable type
  154. IniRead, rvideomode, %demulFile%, main, videomode
  155. Log("Module - Demul is reading the config with videomode = " . rvideomode)
  156. IniWrite, %videomode%, %demulFile%, main, videomode
  157. Log("Module - Demul is updating the config with videomode = " . videomode)
  158. ;ExitApp
  159.  
  160. ; Handle Demul's rom paths so the user doesn't have to
  161. IniRead, romPathCount, %demulFile%, files, romsPathsCount
  162. Log("Module - Demul is configured with " . romPathCount . " rom path(s). Scanning these for a romPath to this rom.")
  163. Loop, %romPathCount%
  164. { demulRomPath := A_Index - 1 ; rompaths in demul start with 0
  165. IniRead, path%A_Index%, %demulFile%, files, roms%demulRomPath%
  166. Log("Module - Path" . demulRomPath . ": " . path%A_Index%)
  167. ; msgbox % path%A_Index%
  168. If (path%A_Index% = romPath . "\") ; demul tacks on the backslash at the end
  169. { romPathFound := 1 ; flag that demul has this romPath in its config and no need to add it
  170. Log("Module - Stopping search because Demul is already configured with the correct romPath to this rom: " . path%A_Index%)
  171. Break ; stop looking for a correct romPath
  172. }
  173. }
  174. If !romPathFound ; if demul doesn't have the romPath in its ini, add it
  175. { Log("Module - Demul does not have this romPath in Demul.ini, adding it for you.",2)
  176. nextPath := romPathCount + 1 ; add 1 to the romPathCount and write that to the ini
  177. IniWrite, %nextPath%, %demulFile%, files, romsPathsCount
  178. IniWrite, %romPath%\, %demulFile%, files, % "roms" . romPathCount ; write the rompath to the ini
  179. }
  180.  
  181. BezelStart("FixResMode")
  182.  
  183. ; Force Fade_Out to disabled as it causes demul to not close properly
  184. ; fadeOut = false
  185. ; Log("Module - Turning off Fade_Out because it doesn't let Demul exit properly.",2)
  186.  
  187. ; check for the specified gpu plugin
  188. gpuFile := CheckFile(emuPath . "\" . plugin . ".ini", "Please run Demul manually first and select the " . plugin . " gpu plugin so it creates this file for you: " . emuPath . "\" . plugin . ".ini")
  189.  
  190. demulFileEncoding := COM_Invoke(RLObject, "getFileEncoding", gpuFile)
  191. If demulFileEncoding {
  192. Log("Module - Recreating " . gpuFile . " as ANSI because UTF-8 format cannot be read")
  193. If COM_Invoke(RLObject, "removeBOM", gpuFile)
  194. Log("Module - Successfully converted " . gpuFile . " to ANSI")
  195. Else
  196. Log("Module - Failed to convert " . gpuFile . " to ANSI",3)
  197. }
  198.  
  199. ; 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.
  200. If ListSorting = true
  201. IniWrite, 0, %gpuFile%, main, AutoSort
  202. Else
  203. IniWrite, 1, %gpuFile%, main, AutoSort
  204.  
  205. ; This will set the Opaque or Trans modifier for each game
  206. If OpaqueMod = true
  207. IniWrite, 0, %gpuFile%, main, OModifier
  208. Else
  209. IniWrite, 1, %gpuFile%, main, OModifier
  210.  
  211. If TransMod = true
  212. IniWrite, 0, %gpuFile%, main, TModifier
  213. Else
  214. IniWrite, 1, %gpuFile%, main, TModifier
  215.  
  216. ; This updates the DX10gpu or DX11gpu ini file to the scale you want to use for this game
  217. IniWrite, %InternalResolutionScale%, %gpuFile%, main, scaling
  218.  
  219. ; This updates the demul.ini with your gpu plugin choice for the selected rom
  220. IniWrite, %plugin%.dll, %demulFile%, plugins, gpu
  221.  
  222. ; This updates the demul.ini with your VMU display choice
  223. VMUscreendisable := If (displayVMU="true") ? "false" : "true"
  224. IniWrite, %VMUscreendisable% , %demulFile%, main, VMUscreendisable
  225.  
  226. ; Shader Effects
  227. Loop, 2 {
  228. shaderUsePass%A_Index% := If (ShaderUsePass%A_Index% != "" and ShaderUsePass%A_Index% != "ERROR" ? (ShaderUsePass%A_Index%) : (GlobalShaderUsePass%A_Index%)) ; determine what shaderUsePass to use
  229. IniRead, currentusePass%A_Index%, %gpuFile%, shaders, usePass%A_Index%
  230. If (shaderUsePass%A_Index% = "true")
  231. {
  232. shaderNamePass%A_Index% := If (ShaderNamePass%A_Index% != "" and ShaderNamePass%A_Index% != "ERROR" ? (ShaderNamePass%A_Index%) : (GlobalShaderNamePass%A_Index%)) ; determine what shaderNamePass to use
  233. If shaderNamePass%A_Index% not in FXAA,HDR-TV,SCANLINES,CARTOON,RGB DOT(MICRO),RGB DOT(TINY),BLUR
  234. 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.")
  235. If (currentusePass%A_Index% = 0)
  236. IniWrite, 1, %gpuFile%, shaders, usePass%A_Index% ; turn shader on in gpuDX11 ini
  237. IniWrite, % shaderNamePass%A_Index%, %gpuFile%, shaders, shaderPass%A_Index% ; update gpuDX11 ini with the shader name to use
  238. }Else If (shaderUsePass%A_Index% != "true" and currentusePass%A_Index% = 1)
  239. IniWrite, 0, %gpuFile%, shaders, usePass%A_Index% ; turn shader off in gpuDX11 ini
  240. }
  241.  
  242. If ident = dc
  243. {
  244. 7z(romPath, romName, romExtension, 7zExtractPath)
  245. If ( romExtension = ".cdi" || romExtension = ".mds" || romExtension = ".ccd" || romExtension = ".nrg" || romExtension = ".gdi" || romExtension = ".cue" ) {
  246. gdrImageFile := CreateDefaultGDROMIni("image")
  247. FileDelete, %gdrImageFile%
  248. Sleep, 500
  249. IniWrite, gdrImage.dll, %demulFile%, plugins, gdr
  250. IniWrite, false, %gdrImageFile%, Main, openDialog
  251. IniWrite, %romPath%\%romName%%romExtension%, %gdrImageFile%, Main, imagefilename
  252. } Else If romExtension = .chd
  253. {
  254. gdrCHDFile := CreateDefaultGDROMIni("chd")
  255. FileDelete, %gdrCHDFile%
  256. Sleep, 500
  257. IniWrite, false, %gdrCHDFile%, Main, openDialog
  258. IniWrite, gdrCHD.dll, %demulFile%, plugins, gdr
  259. IniWrite, %romPath%\%romName%%romExtension%, %gdrCHDFile%, Main, imagefilename
  260. } Else
  261. ScriptError(romExtension . " is not a supported file type for this " . moduleName . " module.")
  262.  
  263. IniWrite, 1, %demulFile%, main, region ; Set BIOS to Auto Region
  264. } Else { ; all other systems, Naomi and Atomiswave
  265. ; This updates the demul.ini with your Bios choice for the selected rom
  266. If ( Bios != "" && Bios != "ERROR" ) {
  267. Bios := RegExReplace(Bios,"\s.*") ; Cleans off the added text from the key's value so only the number is left
  268. IniWrite, false, %demulFile%, main, naomiBiosAuto ; turning auto bios off so we can use a specific one instead
  269. IniWrite, %Bios%, %demulFile%, main, naomiBios ; setting specific bios user has set from the moduleName ini
  270. } Else
  271. IniWrite, true, %demulFile%, main, naomiBiosAuto ; turning auto bios on if user did not specify a specific one
  272. }
  273.  
  274. ; 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.
  275. ; 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.
  276.  
  277. ; This section tells demul what arcade control type should be connected to the game. Options are standard (aka controller), mouse, lightgun, or keyboard
  278. If (controls = "lightgun" || controls = "mouse") {
  279. Log("Module - This game uses a Mouse or Lightgun control type.")
  280. IniWrite, %MouseCode%, %demulFile%, PORTB, device
  281. } Else If (controls = "keyboard") {
  282. Log("Module - This game uses a Keyboard control type.")
  283. IniWrite, %KeyboardCode%, %demulFile%, PORTB, device
  284. } Else { ; accounts for all other control types
  285. Log("Module - This game uses a standard (controller) control type.")
  286. IniWrite, %ControllerCode%, %demulFile%, PORTB, device
  287. }
  288.  
  289. Log("Module - Last control scheme used was """ . lastControlUsed . """ and this game requires """ . controls . """")
  290. If (LastControlUsed != controls) { ; find out last controls used for the system we are launching
  291. 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)
  292. 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)
  293. IniWrite, %controls%, %settingsFile%, Settings, LastControlUsed
  294. Log("Module - Wrote " . controls . " controls to padDemul.ini.")
  295. } Else
  296. Log("Module - Not changing controls because the currently configured controls are the same for this game.")
  297.  
  298. ; This will check the save game files and create per game ones if enabled.
  299. If PerGameMemoryCards = true
  300. {
  301. IfNotExist, %memCardPath%
  302. FileCreateDir, %memCardPath% ; create memcard folder if it doesn't exist
  303. defaultMemCard := memCardPath . "\default_vms.bin" ; defining default blank VMU file
  304. If (FileExist(defaultMemCard))
  305. {
  306. Log("VMU - Default VMU file location - " . defaultMemCard,4)
  307. Loop, 4
  308. {
  309. outerLoop := A_Index
  310. If A_Index = 1
  311. {
  312. contrPort := "A"
  313. }
  314. Else If A_Index = 2
  315. {
  316. contrPort := "B"
  317. }
  318. Else If A_Index = 3
  319. {
  320. contrPort := "C"
  321. }
  322. Else If A_Index = 4
  323. {
  324. contrPort := "D"
  325. }
  326. IniRead, controllerPort%contrPort%, %demulFile%, PORT%contrPort%, device
  327. Log("VMU - Config for controller PORT" . contrPort . " = " . controllerPort%contrPort%,4)
  328. If controllerPort%contrPort% = -1
  329. continue
  330. Loop, 2
  331. {
  332. SubCount := % A_Index - 1
  333. IniRead, VMUPort%SubCount%, %demulFile%, PORT%contrPort%, port%SubCount%
  334. Log("VMU - Config Plugin VMUPort" . contrPort . SubCount . " for controller PORT" . contrPort . " = " . VMUPort%SubCount%,4)
  335. If (VMUPort%SubCount% <> -1)
  336. {
  337. IniRead, VMUPortFile%SubCount%, %demulFile%, VMS, VMS%contrPort%%SubCount%
  338. Log("VMU - VMUPortFile" . contrPort . SubCount . " controllerVMU" . contrPort . SubCount . " " . "VMS" . contrPort . SubCount . " = " . VMUPortFile%SubCount%,4)
  339. memCardName := If romTable[1,5] ? romTable[1,4] : romName ; defining rom name for multi disc rom
  340. PerGameVMUIn := memCardPath . "\" . memCardName . "_vms_" . contrPort . SubCount . ".bin"
  341. Log("VMU - PerGameVMUIn = " . PerGameVMUIn,4)
  342. If (FileExist(PerGameVMUIn))
  343. {
  344. Log("VMU - PerGameVMU file exists at " . PerGameVMUIn,4)
  345. IniWrite, %PerGameVMUIn%, %demulFile%, VMS, VMS%contrPort%%SubCount%
  346. Log("VMU - PerGameVMU file written to " . demulFile . " at section VMS to variable VMS" . contrPort . SubCount . " as " . PerGameVMUIn,4)
  347. } ELSE {
  348. Log("VMU - PerGameVMU file does not exist. So we will create one at " . PerGameVMUIn)
  349. FileCopy, %defaultMemCard%, %PerGameVMUIn%
  350. Log("VMU - PerGameVMU file written to " . demulFile . " at section VMS to variable VMS" . contrPort . SubCount . " as " . PerGameVMUIn)
  351. IniWrite, %PerGameVMUIn%, %demulFile%, VMS, VMS%contrPort%%SubCount%
  352. }
  353. } ELSE {
  354. Log("VMU - No VMU Plugged In.",4)
  355. }
  356. }
  357. }
  358. } Else {
  359. Log("VMU - No default VMU file at " . defaultMemCard,4)
  360. }
  361. }
  362.  
  363. ; Setting demul to use true fullscreen if defined in settings.ini, otherwise sets demul to run windowed. This is for gpuDX11 plugin only
  364. If (plugin = "gpuDX11" || plugin = "gpuDX11ng")
  365. If fullscreen = truefullscreen
  366. IniWrite, 1, %gpuFile%, main, UseFullscreen
  367. Else
  368. IniWrite, 0, %gpuFile%, main, UseFullscreen
  369.  
  370. If fullscreen = windowedfullscreen
  371. {
  372. If maxHideTaskbar = true
  373. {
  374. Log("Module - Hiding Taskbar and Start Button.")
  375. WinHide, ahk_class Shell_TrayWnd
  376. WinHide, Start ahk_class Button
  377. }
  378. ; Create black background to give the emu the fullscreen look
  379. Log("Module - Creating black background to simulate a fullscreen look.")
  380. Gui demulGUI: -Caption +ToolWindow
  381. Gui demulGUI: Color, Black
  382. Gui demulGUI: Show, x0 y0 h%A_ScreenHeight% w%A_ScreenWidth%
  383. }
  384.  
  385. Sleep, 250
  386.  
  387. ; Construct the CLI for demul and send romName if naomi or atomiswave. Dreamcast needs a full path and romName.
  388. If LoadDecrypted = true ; decrypted naomi rom
  389. romCLI := "-customrom=" . """" . romPath . "\" . romName . ".bin"""
  390. Else If ident = dc ; dreamcast game
  391. romCLI := " -image=" . """" . romPath . "\" . romName . romExtension . """"
  392. Else ; standard naomi rom
  393. romCLI := "-rom=" . romName
  394.  
  395. hideEmuObj := Object("LCD 0 ahk_class LCD 0",1,"ahk_class window",1) ; Hide_Emu will hide these windows. 0 = will never unhide, 1 = will unhide later
  396. HideEmuStart()
  397.  
  398. ; Run(executable . " -run=" . ident . " " . romCLI, emuPath,, emuPID)
  399. Run(executable . " -run=" . ident . " " . romCLI, emuPath, (If hideDemulGUI = "true" ? "min" : ""), emuPID) ; launching minimized, then restoring later hides the launch completely
  400. 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
  401.  
  402. DetectHiddenWindows, On
  403. If (hideDemulGUI = "true")
  404. { WinRestore, ahk_class window
  405. WinActivate, ahk_class window
  406. }
  407.  
  408. Log("Module - Waiting for Demul to finish loading game.")
  409. Loop { ; looping until demul is done loading rom and gpu starts showing frames
  410. Sleep, 200
  411. WinGetTitle, winTitle, ahk_class window
  412. StringSplit, winTextSplit, winTitle, %A_Space%
  413. If (winTextSplit5 = "gpu:" And winTextSplit6 != "0" And winTextSplit6 != "1")
  414. Break
  415. }
  416. Log("Module - Demul finished loading game.")
  417.  
  418. If (InStr(systemName, "Gaelco") && fullscreen = "truefullscreen")
  419. Send !{Enter} ; Automatic fullscreen seems to be broken in the Gaelco driver, must alt+Enter to get fullscreen
  420.  
  421. ; This is where we calculate and maximize demul's window using our pseudo fullscreen code
  422. If fullscreen = windowedfullscreen
  423. {
  424. WinSet, Style, -0x40000, ahk_class window ; Removes the border of the game window
  425. WinSet, Style, -0xC00000, ahk_class window ; Removes the TitleBar
  426. Send, {F3} ; Removes the MenuBar
  427. MaximizeWindow("ahk_class window") ; this will take effect after you run demul once because we cannot stretch demul's screen while it is running.
  428. }
  429.  
  430. BezelDraw()
  431.  
  432. If (displayVMU="true"){
  433. WinGet VMUWindowID, ID, LCD 0 ahk_class LCD 0
  434. ExtraFixedResBezelDraw(VMUWindowID, "VMU", VMUPos, 144, 96, 8, 8, 28, 8)
  435. VMUHideKey := xHotKeyVarEdit(VMUHideKey,"VMUHideKey","~","Add")
  436. xHotKeywrapper(VMUHideKey,"VMUHide")
  437. }
  438.  
  439. HideEmuEnd()
  440. FadeInExit()
  441. Process("WaitClose", executable)
  442.  
  443. If fullscreen = windowedfullscreen
  444. { Gui demulGUI: Destroy
  445. Log("Module - Destroyed black gui background.")
  446. }
  447.  
  448. 7zCleanUp()
  449. BezelExit()
  450. ExtraFixedResBezelExit()
  451. FadeOutExit()
  452.  
  453. If (fullscreen = "windowedfullscreen" && maxHideTaskbar = "true") {
  454. Log("Module - Showing Taskbar and Start Button.")
  455. WinShow,ahk_class Shell_TrayWnd
  456. WinShow,Start ahk_class Button
  457. }
  458.  
  459. ExitModule()
  460.  
  461.  
  462. ; Write new controls to padDemul.ini
  463. 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) {
  464. IniWrite, %push1%, %file%, JAMMA0_%player%, PUSH1
  465. IniWrite, %push2%, %file%, JAMMA0_%player%, PUSH2
  466. IniWrite, %push3%, %file%, JAMMA0_%player%, PUSH3
  467. IniWrite, %push4%, %file%, JAMMA0_%player%, PUSH4
  468. IniWrite, %push5%, %file%, JAMMA0_%player%, PUSH5
  469. IniWrite, %push6%, %file%, JAMMA0_%player%, PUSH6
  470. IniWrite, %push7%, %file%, JAMMA0_%player%, PUSH7
  471. IniWrite, %push8%, %file%, JAMMA0_%player%, PUSH8
  472. IniWrite, %service%, %file%, JAMMA0_%player%, SERVICE
  473. IniWrite, %start%, %file%, JAMMA0_%player%, START
  474. IniWrite, %coin%, %file%, JAMMA0_%player%, COIN
  475. IniWrite, %digitalup%, %file%, JAMMA0_%player%, DIGITALUP
  476. IniWrite, %digitaldown%, %file%, JAMMA0_%player%, DIGITALDOWN
  477. IniWrite, %digitalleft%, %file%, JAMMA0_%player%, DIGITALLEFT
  478. IniWrite, %digitalright%, %file%, JAMMA0_%player%, DIGITALRIGHT
  479. IniWrite, %analogup%, %file%, JAMMA0_%player%, ANALOGUP
  480. IniWrite, %analogdown%, %file%, JAMMA0_%player%, ANALOGDOWN
  481. IniWrite, %analogleft%, %file%, JAMMA0_%player%, ANALOGLEFT
  482. IniWrite, %analogright%, %file%, JAMMA0_%player%, ANALOGRIGHT
  483. IniWrite, %analogup2%, %file%, JAMMA0_%player%, ANALOGUP2
  484. IniWrite, %analogdown2%, %file%, JAMMA0_%player%, ANALOGDOWN2
  485. IniWrite, %analogleft2%, %file%, JAMMA0_%player%, ANALOGLEFT2
  486. IniWrite, %analogright2%, %file%, JAMMA0_%player%, ANALOGRIGHT2
  487. }
  488.  
  489. MaximizeWindow(class) {
  490. Global MEmu,plugin,gpuFile
  491. Log("MaximizeWindow - Started")
  492. WinGetPos, appX, appY, appWidth, appHeight, %class%
  493. Log("MaximizeWindow - " . MEmu . " is currently x: " . appX . " y: " . appY . " w: " . appWidth . " h: " . appHeight,4)
  494. widthMaxPercenty := ( A_ScreenWidth / appWidth )
  495. heightMaxPercenty := ( A_ScreenHeight / appHeight )
  496. If ( widthMaxPercenty < heightMaxPercenty )
  497. percentToEnlarge := widthMaxPercenty
  498. Else
  499. percentToEnlarge := heightMaxPercenty
  500. appWidthNew := appWidth * percentToEnlarge
  501. appHeightNew := appHeight * percentToEnlarge
  502. Transform, appX, Round, %appX%
  503. Transform, appY, Round, %appY%
  504. Transform, appWidthNew, Round, %appWidthNew%
  505. Transform, appHeightNew, Round, %appHeightNew%
  506. appXPos := (A_ScreenWidth / 2) - (appWidthNew / 2)
  507. appYPos := (A_ScreenHeight / 2) - (appHeightNew / 2)
  508. If (plugin = "gpuDX11" || plugin = "gpuDX11ng") {
  509. IniWrite, %appWidthNew%, %gpuFile%, resolution, Width
  510. IniWrite, %appHeightNew%, %gpuFile%, resolution, Height
  511. } Else {
  512. IniWrite, %appWidthNew%, %gpuFile%, resolution, wWidth
  513. IniWrite, %appHeightNew%, %gpuFile%, resolution, wHeight
  514. }
  515. WinMove, %class%,, appXPos, appYPos
  516. Log("MaximizeWindow - " . MEmu . " resized to x: " . appX . " y: " . appY . " w: " . appWidthNew . " h: " . appHeightNew,4)
  517. Log("MaximizeWindow - Ended")
  518. }
  519.  
  520. ; Creates a default gdrCHD.ini or gdrImage.ini in your emu folder if one does not exist already.
  521. CreateDefaultGDROMIni(type) {
  522. Global emuPath
  523. defaultIni := "[main]`r`nimageFileName = `r`nopenDialog = false"
  524. IniType := If type = "chd" ? "gdrCHD.ini" : "gdrImage.ini"
  525. FileAppend, %defaultIni%, % emuPath . "\" . IniType
  526. Return emuPath . "\" . IniType
  527. }
  528.  
  529. HaltEmu:
  530. If fullscreen = truefullscreen
  531. Send !{Enter}
  532. If VMUHideKey
  533. XHotKeywrapper(VMUHideKey,"VMUHide","OFF")
  534. Return
  535. RestoreEmu:
  536. If fullscreen = truefullscreen
  537. Send !{Enter}
  538. If (displayVMU="true")
  539. { WinSet, Transparent, 0, ahk_ID %VMUWindowID%
  540. WinSet, AlwaysOnTop, On, ahk_ID %VMUWindowID%
  541. WinShow, ahk_ID %VMUWindowID%
  542. WinSet, AlwaysOnTop, On, ahk_ID %VMUWindowID%
  543. WinSet, AlwaysOnTop, On, ahk_ID %extraFixedRes_Bezel_hwnd%
  544. WinShow, ahk_ID %extraFixedRes_Bezel_hwnd%
  545. If !(VMUHidden)
  546. WinSet, Transparent, off, ahk_ID %VMUWindowID%
  547. }
  548. If VMUHideKey
  549. XHotKeywrapper(VMUHideKey,"VMUHide","ON")
  550. Return
  551.  
  552. HideGUIWindow:
  553. WinSet, Transparent, On, ahk_class window
  554. WinActivate ahk_class window ; once activated, demul starts loading the rom
  555. Return
  556.  
  557. VMUHide:
  558. If (VMUHidden) {
  559. Loop, 4
  560. WinSet, Transparent, off, ahk_ID %VMUWindowID%
  561. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,255)
  562. VMUHidden := false
  563. } Else {
  564. Loop, 4
  565. WinSet, Transparent, 0, ahk_ID %VMUWindowID%
  566. UpdateLayeredWindow(extraFixedRes_Bezel_hwnd, extraFixedRes_Bezel_hdc,0,0, A_ScreenWidth, A_ScreenHeight,0)
  567. VMUHidden := true
  568. }
  569. Return
  570.  
  571. CloseProcess:
  572. FadeOutStart()
  573. PostMessage, 0x111, 40085,,,ahk_class window ; Stop emulation first for a clean exit
  574. Sleep, 5 ; just like to give a little time before closing
  575. PostMessage, 0x111, 40080,,,ahk_class window ; Exit
  576. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement