Demul

Get answers to questions about using mGalaxy.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

After a lot of tests, I found that the 058 and upper versions are laggy so I would like to downgrade back to the 057 version which work perfectly (I managed to go through Shenmue from start to finish without major lag or glitches) but the 057 version don't want to run with mGalaxy (I know NullDC works fine but some games, like Shenmue, works better with Demul so I added both emulators in mGalaxy).

Here's the 057 version : http://demul.emulation64.com/files/demul057.rar

First, the required command-line to run the emulator is that :

Demul.exe -run=dc image=directory\file.ext (for example, this command-line works fine in a .bat file : demul.exe -run=dc -image="D:\Isos_Emulation\DreamCast\Shenmue v1.001 (2000)(Sega)(PAL)(M4)(Disc 1 of 4)[!].gdi")

Whatever I try, demul seems to be loaded in background when loaded through mGalaxy (it don't appear on my screen, but is in th taskmanager). I suppose I might need an auto-it script but the actual one is only compatible with 058+ versions (at least, even if it don't load the iso file because of a command-line problem, it should at least open the emulator, right?).

Aeliss said here (http://www.mgalaxy.com/forum/index.php? ... 42#msg1842) that another script were required for >5.0.8 versions but didn't find it anywhere.

Here's the actual command line in the xml file :

Code: Select all

<Cmd id="0" name="Demul (AutoIt)" value="-run=dc -image="%path\%file%ext"" />
(So the command line seems okay)

So all is missing would be an auto-it script ?

I know the old video plugins of this version don't allow to force fullscreen at startup, but that's not a big problem. I rather prefer that than playing games with lag, and I think it can probably be fixed (would just need to put an "ALT+ENTER" combo key in a auto-it script after the emulator startup).

I'm ready to buy a third supporter version if my problem is fixed ;) (and if it's someone else who fix my problem, I'm ready to buy and offer you a supporter version if you don't have one yet :D).

Thanks a lot in advance if someone can help me.
Last edited by davhuit on Fri May 02, 2014 7:08 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

Here you can find my last masochist tries > http://www.mgalaxy.com/forum/index.php? ... 83#msg1183

This script correct fullscreen and background problem, you can remove the specail config part.
I think I still have my config file for this version, hard to configure fullscreen to avoid flickering effect. It s really a crappy emulator, still at beta step after so many years.

Shenmue is working on NullDC too, perhaps it need some manipulation or patch, but I have already see on their forum that this game is totally playable (with special saves if I remember).

Edit:
I have tried this code 5 mn ago, and it work (for naomi and mgalaxy 5.2, you need to make some change for DC)

Code: Select all

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>

__myTaskHS(True)

Opt("WinTitleMatchMode", 1)

;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
   
HotKeySet("{ESC}", "Terminate")

$count = StringInStr($command, "-rom=", 0 , 1, 1)
local $file = StringTrimLeft( $command, $count + 4 )

local $fullscreenmode = 0 ; 0 = normal fullscreen 1 = special Fullscreen

; here you can use different configuration by game
local $option2 = "false"
local $option1 = IniRead("gpuDXv3.ini","main","transformZ", "")

;for naomi rom
if stringInStr($command,"naomi") then
   $type = ' -run=naomi -rom="'
   local $bios2 = 0
   Local $bios1 = IniRead("demul.ini", "main", "naomiBios", "")
   ;Special config for house of dead 2
   if $file = "hotd2" then
	  $bios2 = 17
	  $option2 = "true"
   elseIf $file = "kurucham" then
	   $bios2 = 27
   elseIf $file = "alpildx" then
	   $bios2 = 21
   elseIf $file = "lupinsho" then
	   $bios2 = 21
   elseIf $file = "takoron" then
	   $bios2 = 4
   else
	  $bios2 = 10
   Endif
   If $bios1 <> $bios2 then Iniwrite("demul.ini", "main", "naomiBios", $bios2)
;for atomiswave rom	  
elseif stringInStr($command,"Atomiswave") then
   $type = ' -run=atomiswave -rom="'
   $fullscreenmode = 1
;bug
Else
   Exit 0
Endif

;Set differents options by game
If $option1 <> $option2 then
   Iniwrite("gpuDXv3.ini","main","transformZ", $option2)
Endif

$PID = Run("demul.exe" & $type & $file & '"')
Local $hWnd = WinWaitActive ( "gpu" )

if $fullscreenmode = 1 then
   Local $winX = 0
   Local $winY = 0
   Local $winWidth = @DesktopWidth
   Local $winHeight = @DesktopHeight+20
   
   WinSetStyle($hWnd,$WS_POPUP)
   WinMove("gpu", "", $winX, $winY, $winWidth, $winHeight)
   Send("!{F3}")
   
   _MouseTrap(@DesktopWidth, @DesktopHeight, @DesktopWidth, @DesktopHeight)

   __myTaskHS(True)
else
   Send("!{ENTER}")
endif


ProcessWaitClose("demul.exe")

if $fullscreenmode = 1 then __myTaskHS(False)
   
Exit 0


;functions
Func Terminate()
  While ProcessExists ( $PID )
      ProcessClose ( $PID )
  WEnd
  if $fullscreenmode = 1 then __myTaskHS(False)
  Exit 0
EndFunc


Func WinSetStyle($hWnd, $Style = -1, $ExStyle = 0)
    Local Const $GWL_STYLE = -16
    Local Const $GWL_EXSTYLE = -20
    Local Const $SWP_NOMOVE = 0x2
    Local Const $SWP_NOSIZE = 0x1
    Local Const $SWP_SHOWWINDOW = 0x40
    Local Const $SWP_NOZORDER = 0x4
    Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
            "int", 0, "int", 0, "int", $iFlags)
EndFunc
		 

Func __myTaskHS($f_hide = False)
    Local $h_task = WinGetHandle("[CLASS:Shell_TrayWnd]")
    If Not $h_task Then Return SetError(1, 0, 0)

    Local $h_start = 0
    Local $a_wlist = WinList("[CLASS:Button]")
    If Not IsArray($a_wlist) Then Return SetError(2, 0, 0)

    For $iwin = 1 To $a_wlist[0][0]
        If _WinAPI_GetParent($a_wlist[$iwin][1]) = $h_task Then
            $h_start = $a_wlist[$iwin][1]
            ExitLoop
        EndIf
    Next

    If Not $h_start Then Return SetError(3, 0, 0)

    If $f_hide Then
        _WinAPI_ShowWindow($h_start, @SW_HIDE)
        _WinAPI_ShowWindow($h_task, @SW_HIDE)
    Else
        _WinAPI_ShowWindow($h_start, @SW_SHOW)
        _WinAPI_ShowWindow($h_task, @SW_SHOW)
    EndIf
EndFunc	




Last edited by Aeliss on Fri May 02, 2014 9:07 pm, edited 1 time in total.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

I might have precised it but it seemed logic as my command-line as the "dc" value in it, I'm trying to make it to work for the dreamcast (atomiswave and naomi are already ok on my computer with the v58.2).

The emulator works pretty fine here for dreamcast, but only the 057 version (the 058 have some flickering yeah, and the framerate seems choppy). As I said upper, I managed to finish Shenmue with major glitches where NullDC have some problems with it (sound problems during some parts in the game, for example).

I also mainly use NullDC but I prefer to have both, depending of the game (and I was planning to replay Shenmue as a undub version has been released). I can run the emulator manually but I'm really curious why mGalaxy can't load the v057 of the emulator.

I will try your scripts tomorrow with the 057 version, hoping it'll work :)
Last edited by davhuit on Fri May 02, 2014 11:20 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

Try in adding this

Code: Select all

;for atomiswave rom      
elseif stringInStr($command,"Atomiswave") then
   $type = ' -run=atomiswave -rom="'
   $fullscreenmode = 1
;for Dreamcast rom      
elseif stringInStr($command,"DC") then
   $type = ' -run=dc -image="'
   $fullscreenmode = 1
;bug
This script can use 2 fullscreen mode because of flickering try the 2 value for $fullscreenmode.
And I m using this code for 0.57 only.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

The emulator load with this script, but then it seems to crash/freeze without loading the game.

Do you have a lite version of that script? Just the part to load the emulator?

Or maybe it's because we don't have the same command-line in the xml? (I didn't updated my mGalaxy so I'm still at the 5.0 version).

My command-line is this one :

Code: Select all

<Cmd id="0" name="Demul (AutoIt)" value="-run=dc -image="%path\%file%ext"" /> 
Or maybe I need to remove the command line, as it seems the parameters are already in the script?

By the way, about the fullscreen mode, why don't just "ask" the autoit script to input "ALT+ENTER", as it force the emulator into fullscreen?

Anyway, thanks for your help :)

I have a doubt about the script. Do I have to use it the old way (compile it then put the exe link in "mGalaxy_runaway", or do I need to compile it, name it "mGalaxy_Script.exe" then put it in the same directory as the emulator and check the "Use script if available" box ? (though I tried both possibilites and it crash for both).

Can't mGalaxy handle itself the iso loading with the command in the xml? (like the others emulators and the 0.58 version?)

Then, just have the script to send the "ALT+ENTER" combo ? (with something like this : http://www.autoitscript.com/forum/topic ... -send-key/ ?).

The fullscreen is working fine here, it's just it's loaded in windowed mode by default.

By the way, I am wondering why this script (http://www.mgalaxy.com/forum/index.php?topic=453.0) don't work with the old versions? What did they change exactly? I assume even if they changed something about the iso loading, the emulator should, at least, load with this script?
Last edited by davhuit on Sat May 03, 2014 2:15 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

The last script work with the last version so with mGalaxy_Script.exe, if you want to use it in the command line it s the previous version you can find on my last post.

Try with the new offical script + sending alt+enter (3 exemples here)

Code: Select all

Send("!{Enter}") ;
Send("{AltDown}{Enter}") 
Send("{AltDown}{Enter}{AltUp}")
but I think it will be better after

Code: Select all

WinWaitActive ( "gpu" )
this part wait for game load before cotinu.

Last edited by Aeliss on Sat May 03, 2014 3:08 pm, edited 1 time in total.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Okay, let's just forget the last version script, so (because it don't work with the old versions, like the v057 one, even when I modify it).

Okay for the keypress but I still need a "lite" version of the script that do not crash with the 057 version. I tried deleting some lines in the script you posted earlier but it output some errors on some lines so I probably removed some lines I shouldn't.

So to summary, to start, just a autoit script that will able me to load the v057 version of the emulator on Mgalaxy, compatible with that command in the xml, if possible (I suppose it's the fullscreen thing of the script that make the emulator crash/freeze) :

Code: Select all

<Cmd id="0" name="Demul (AutoIt)" value="-run=dc -image="%path\%file%ext"" />
I managed to do some autoit scripts myself (for the splash screen thing for example), but for this, it's too much complicated for my level :/

(Then, I'll try to see myself how I can handle the loading of the iso, but it should probably work natively witht the xml command, as the other emulators ? I even tried to use some others scripts as an exemple, like the pcsx2 one but it didn't work).

Thanks a lot, again, it's really kind to help me!
Last edited by davhuit on Sat May 03, 2014 3:46 pm, edited 1 time in total.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

I'm not sure if I'm really clear about what I say, so I'm talking about this script for a "lite" version :

Code: Select all

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Misc.au3>

__myTaskHS(True)

Opt("WinTitleMatchMode", 1)

;Parsing
Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
local $app = StringLeft ( $CmdLineRaw, $count + 4 )
local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
if not $command then exit 0
   
HotKeySet("{ESC}", "Terminate")

$count = StringInStr($command, "-rom=", 0 , 1, 1)
local $file = StringTrimLeft( $command, $count + 4 )

local $fullscreenmode = 0 ; 0 = normal fullscreen 1 = special Fullscreen

; here you can use different configuration by game
local $option2 = "false"
local $option1 = IniRead("gpuDXv3.ini","main","transformZ", "")

;for naomi rom
if stringInStr($command,"naomi") then
   $type = ' -run=naomi -rom="'
   local $bios2 = 0
   Local $bios1 = IniRead("demul.ini", "main", "naomiBios", "")
   ;Special config for house of dead 2
   if $file = "hotd2" then
	  $bios2 = 17
	  $option2 = "true"
   elseIf $file = "kurucham" then
	   $bios2 = 27
   elseIf $file = "alpildx" then
	   $bios2 = 21
   elseIf $file = "lupinsho" then
	   $bios2 = 21
   elseIf $file = "takoron" then
	   $bios2 = 4
   else
	  $bios2 = 10
   Endif
   If $bios1 <> $bios2 then Iniwrite("demul.ini", "main", "naomiBios", $bios2)
;for atomiswave rom      
elseif stringInStr($command,"Atomiswave") then
   $type = ' -run=atomiswave -rom="'
   $fullscreenmode = 1
;for Dreamcast rom      
elseif stringInStr($command,"DC") then
   $type = ' -run=dc -image="'
   $fullscreenmode = 1
;bug
Else
   Exit 0
Endif

;Set differents options by game
If $option1 <> $option2 then
   Iniwrite("gpuDXv3.ini","main","transformZ", $option2)
Endif

$PID = Run("demul.exe" & $type & $file & '"')
Local $hWnd = WinWaitActive ( "gpu" )

if $fullscreenmode = 1 then
   Local $winX = 0
   Local $winY = 0
   Local $winWidth = @DesktopWidth
   Local $winHeight = @DesktopHeight+20
   
   WinSetStyle($hWnd,$WS_POPUP)
   WinMove("gpu", "", $winX, $winY, $winWidth, $winHeight)
   Send("!{F3}")
   
   _MouseTrap(@DesktopWidth, @DesktopHeight, @DesktopWidth, @DesktopHeight)

   __myTaskHS(True)
else
   Send("!{ENTER}")
endif


ProcessWaitClose("demul.exe")

if $fullscreenmode = 1 then __myTaskHS(False)
   
Exit 0


;functions
Func Terminate()
  While ProcessExists ( $PID )
      ProcessClose ( $PID )
  WEnd
  if $fullscreenmode = 1 then __myTaskHS(False)
  Exit 0
EndFunc


Func WinSetStyle($hWnd, $Style = -1, $ExStyle = 0)
    Local Const $GWL_STYLE = -16
    Local Const $GWL_EXSTYLE = -20
    Local Const $SWP_NOMOVE = 0x2
    Local Const $SWP_NOSIZE = 0x1
    Local Const $SWP_SHOWWINDOW = 0x40
    Local Const $SWP_NOZORDER = 0x4
    Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    If $Style = -1 Then $Style = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $Style)
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $ExStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
            "int", 0, "int", 0, "int", $iFlags)
EndFunc
		 

Func __myTaskHS($f_hide = False)
    Local $h_task = WinGetHandle("[CLASS:Shell_TrayWnd]")
    If Not $h_task Then Return SetError(1, 0, 0)

    Local $h_start = 0
    Local $a_wlist = WinList("[CLASS:Button]")
    If Not IsArray($a_wlist) Then Return SetError(2, 0, 0)

    For $iwin = 1 To $a_wlist[0][0]
        If _WinAPI_GetParent($a_wlist[$iwin][1]) = $h_task Then
            $h_start = $a_wlist[$iwin][1]
            ExitLoop
        EndIf
    Next

    If Not $h_start Then Return SetError(3, 0, 0)

    If $f_hide Then
        _WinAPI_ShowWindow($h_start, @SW_HIDE)
        _WinAPI_ShowWindow($h_task, @SW_HIDE)
    Else
        _WinAPI_ShowWindow($h_start, @SW_SHOW)
        _WinAPI_ShowWindow($h_task, @SW_SHOW)
    EndIf
EndFunc
This script manage to load the emulator withing mGalaxy so that's a great thing but it make the emulator crash/freeze on my pc for an unknow reason (rather than freezing, it seems it's loading the game but don't manage to run it).

What I would need is the same script but with all the optional lines removed (the ones about the fullscreen and such), so just to keep the lines which are required to load the emulator for the dc (I don't need atomiswave/naomi which already works fine with the last emulator version).

That's way, I should be able to run the emulator from mGalaxy without freeze/crash. Then, from that script, I'll see how to deal with the iso loading, if required, then with the "ALT+Screen" thing and it'll be ready :)
Last edited by davhuit on Sat May 03, 2014 6:49 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

Code: Select all

 
   #include <Misc.au3>
    Opt("WinTitleMatchMode", 1)
     
    ;Parsing
    Local $count = StringInStr($CmdLineRaw, ".exe", 0 , 1, 1)
    local $app = StringLeft ( $CmdLineRaw, $count + 4 )
    local $command = StringTrimLeft( $CmdLineRaw, $count + 4 )
    if not $command then exit 0
       
    HotKeySet("{ESC}", "Terminate")
     
    $PID = Run ('"' & $app & '" ' & $command)
     
    ;wait for emul start to hide cursor
    WinWaitActive ( "gpu" )

Send("!{ENTER}")

    _MouseTrap(@DesktopWidth, @DesktopHeight, @DesktopWidth, @DesktopHeight)
     
    While ProcessExists ( $PID )
       sleep(500)
    WEnd
     
    Exit 0
     
    ;functions
    Func Terminate()
        While ProcessExists ( $PID )
              ProcessClose ( $PID )
        WEnd
           
        Exit 0
    EndFunc
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

It's the same that the one on mGalaxy script, right?

Anyway, just tested it and it don't work, the emulator (v057) is not loaded with that script (contrary to the previous script I posted upper).

Edit : Ah, weird, I retried by renaming it "mGalaxy_Script.exe" and this time, the emulator launched, though the script from the website wouldn't want to work with my earlier tries o_o. Thanks a lot!

Ok, so now, I have to find how to add the dc isos launching without breaking everything. An idea about about to do that?
Last edited by davhuit on Sat May 03, 2014 8:30 pm, edited 1 time in total.
Aeliss
Hero Member
Hero Member
Posts: 900
Joined: Thu Apr 04, 2013 5:55 pm

Ok, so now, I have to find how to add the dc isos launching without breaking everything. An idea about about to do that?
IDK, what is the problem ? Demul don't work with gdi in command line ?
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

My bad, the xml had an old command-line, I dunno why :/

It had this one :

Code: Select all

<Cmd id="0" name="Demul (AutoIt)" value="-run=dc -image=%file" />
And with this one, it's working :

Code: Select all

<Cmd id="0" name="Demul (AutoIt)" value="-run=dc -image="%path\%file%ext"" />
Thanks a lot :)

You're right about the fullscreen, I  should have mixed some versions by error because even with the "ALT+ENTER", it flicker.

But I don't really care about the fullscreen, as long as I can launch the version from mGalaxy so it's okay.

About Shenmue, I just remembered why I don't play it on "NullDC", my brother remembered me of the problem. In "NullDC", after a while, the savefile get corrupted so when you reload the game, you have a probability of not being able to reload your previous savefile.

But now, I'll be able to replay Shenmue (and some others games that might have some problems in "NullDC" directly from mGalaxy so thanks a lot to you :))



Last edited by davhuit on Tue May 06, 2014 3:44 am, edited 1 time in total.
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

Bumping this old topic because I don't really know where to put it but I just updated my Demul version (DEmul x86 v0.7 Alpha BUILD 310715) and wanted to say the emulator now use the parameter "awave" for atomiswave (old versions were using the parameter "atomiswave")

I changed the command line in systems.xml manually and it's now working fine, so you might want to add a new command line in the next Mgalaxy.

Actual command line :

<Cmd id="0" name="DEmul [Script]" value="-run=atomiswave -rom=%file"/>

So it would need to be be something like :

<Cmd id="0" name="DEmul 0.5.8.2 or lower [Script]" value="-run=atomiswave -rom=%file"/>
<Cmd id="1" name="DEmul 0.7 or higher [Script]" value="-run=awave -rom=%file"/>

What is nice is that, contrary to older versions, this last one works fine in fullscreen (no more flickering).

Note : Teamviewer prevent the emulator to use fullscreen so if it seems the fullscreen doesn't work and you have teamviewer running on your computer, close it and then it'll work.

Last edited by davhuit on Tue Sep 08, 2015 2:37 pm, edited 1 time in total.
User avatar
mgalaxy
Administrator
Administrator
Posts: 1190
Joined: Tue Dec 05, 2006 7:46 pm

Thanks for the tip davhuit!! I add it immediately!
davhuit
Elite Member
Elite Member
Posts: 173
Joined: Mon Aug 12, 2013 3:06 am

No problem :)

And for those who are interested by the info, another emulator which doesn't like Teamviewer is Epsxe. The emulator will crash once a game is a loaded if Teamviewer is running.
Post Reply