Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: [17-09-22] RatRefresh 0.14 - refresh rate switcher, stops LCD tearing  (Read 43931 times)

0 Members and 1 Guest are viewing this topic.

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Metalhammer, I think it's fairly safe to 'underclock' your LCD. Most LCD's I know are 60 or 75Hz native, and pretty much all arcades are just over 60 but mostly range from 55-60Hz in my experience. As long as the LCD syncs to it it's safe as far as I can tell. Setting it to a higher rate than it was designed for would theoretically strain the display a bit more, but all my monitors just give a 'input out of range' message as soon as I yank it up too much.
The 'stability' question I'm not sure about what you mean. If you set a refreshrate to 59.59, your videocard will send 59.59 frames a second, not more, not less. These devices all have very accurate frequency generators and I have so far not seen any issues. When I set my display to an 'odd' resolution, it just stays there and works.
Hardware dependent is not as much of the issue as software is. You will need a driver that supports EDID override. Now NVidia and AMD already do, Intel does and is currently implementing that on multiple driver branches. So the chances are yours already supports it, if mot the beta driver might work out. On my system I still run the beta driver although I believe by now the final version with EDID support is out.

Another part is the monitor itself. My screen work from about 49 - 64Hz from the top of my head, others might do more or less. But practically all games I play work with something between 55-61Hz.

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Hi Rataplan,

I agree my question about stability was not so clear  ;)
I mainly meant if you can keep you screen at a custom resolution for some time without keeping handy an extinguisher  :P

On the cabinet I'll have a Fujitsu Scenicview B19-5 with a n NV Gtx 1050 while at the moment I can play with a Gtx 460 and an old Samsung (cannot remember the model!)  ;)

I did today few test on my rig (the proper one I use daily) and I set some custom resolution even though Nvidia panel don't allow you to use fractions for the refresh rate.
The outcome was absolutely disappointing since I tried to come as close as possible to the game refresh rate but tearing started to appear and was pretty terrible  :-[

For example Double Dragon (running @57.44Hz) when viewed at 57Hz looked way worse than at 60Hz  ???
... I really hope the decimals will be able to do the trick otherwise my enthusiasm will go straight through the drain  :angry:

Take care and speak to you soon  :)

I'll keep you posted !

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Now that's exactly where EDID overrides come in. Usually the custom resolution settings from the graphics card vendors themselves only allow for integers for refreshrate, but an EDID override steers on a specific pixelclock which enables you to get a very specific refreshrate. So you could use CRU to set the exact refreshrate (with decimals). Or just use RatRefresh of course ;)

Also, to get the best results, use syncrefresh 1 and disable vsync in your mame.ini. That makes the game sync to the refreshrate rather than the other way around, which keeps everything smooth as butter even if the set refreshrate is off by 0.01 Hz or something. With regular vsync you would then skip a frame every so many frames.

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Ok, so if I got it right,  I need to use synch to monitor refresh rate and triple buffer together, right ? ... if so, it's my actual config already  ;)

One thing I didn't (probably) get: RatRefresh forces a specific resolution into the register/CRU and then turns it into the current one ?
In other words, do I need to use CRU in order to be able to set a specific refresh rate or can I simply run RatRefresh and it will take care of everything ?

If the latter, what about passing the tool a not supported resolution ? Will windows black screen and will I need to boot in safe mode  :( ?

Cheers  :)

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
If refreshrate matches and sync refresh is on I'd not enable triple buffering as it just generates a little overhead then.

You can supply a -min and -max switch with minimum and maximum refrrshrates for your setup. If the requested rate is beyond the tool just quits (or sets 60Hz, I'm not sure at the moment). I tested it by using ratrefresh from command line, setting rates until my monitor stopped syncing to the signal. Of course it's black screen than. But you press up or f3 to get the previous command back on the prompt, delete the last so many characters with backspace and just type in another refresh rate. You could always boot in vga-mode but thats too cumbersome in my opinion.

For now you need CRU one time to get the proper registry key for your monitor. After that you'll only need RatRefresh. I think the opening post is very complete. Read that again and just try - really you'll enjoy your games much more!

I currently have a testversion ready where you can query the system, it'll reply with the detected monitors, and then you can just pass the display name to the tool and it'll work the rest out. But there's a few bug I'll first have to work out.

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Thanks RatRefresh, I'll follow your hint and read the initial post once more  ;)

One question which popped up recently in my mind: if I'm not mistaking, RatRefresh overwrites the 'main' refresh rate in the registry so it can set that one up, according to the game you want to play.
Doing so I imagine you're going to write again and again over the same disk sector  :-\ ... if so, do you think this could be an issue, especially with SSD  :-[ ?

Thanks !

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Registry doesn't work that way, it's more of a database and (at least up to win 7) it's mostly append that it does. That's why the registry sometimes grows extremely big while the actual content isn't that big.
Your SSD is safe. SSD does TRIM which does exactly prevent what you say. It makes sure if you write a million times to sector / block 1 those writes are spread out over the disk. An SSD holds like a making table containing all logical blocks and the actual physical blocks where a logical block correctly resides. In theory every block on your SSD will get the same amount of writes. Google for SSD TRIM. Also look at this:
http://techreport.com/review/27909/the-ssd-endurance-experiment-theyre-all-dead Of course nothing will live forever, but a typical SSD will outlive your pc anyway.


Why so scared of everything?
« Last Edit: April 01, 2017, 04:10:17 am by Rataplan626 »

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
[...]
Why so scared of everything?
You should know the old way of saying "better safe than sorry"  :P

Thanks Rataplan for the insight into SSD writes and all the assistance ;)

I believe no one (or very few) got the real potential of what you're trying to do here or maybe simply people is too 'coarse' to appreciate that  ;)

Keep up with the good job ! ... I plan to do more extensive testing and report back.

A question: do you think there could be differences between VGA and DVI connections ?
I'm asking this since I'm currently using VGA and I'd like to avoid finding different results when I'll switch to DVI  :-\

Cheers   :)

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
I've never tested on VGA, the only machine I have with still VGA on it is a very old Asus netbook, crappiest thing ever. But please report!

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Unfortunately the monitor I was going to use passed away this morning  :angry:

As such I had to 'kidnap' another one from my mom's house and ... surprise: that one despite being a quite "recent" LG LCD, doesn't have a DVI port  :banghead:

I'll try to go ahead anyway and see what happens ... I'll keep you posted  ;)

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Ok, so let's start with my report but I can anticipate I still have no good news  :(

First of all, there were no entries in my windows registry about "EDID", "EDID_OVERRIDE" or something even slightly similar.
There was one key named 'properties' (under display section of course  ;)) which didn't allow me to read its values no matter what change I tried to made to its security settings  :angry:

Eventually, after spending some time on the web, I managed to find a tool NVIDIA suggested in order to get display EDID value (Monitor Asset Manager).
After running that and playing around with 'export', 'save', etc ... I managed to have EDID entries created into the registry and accessible to me  ;)

Anyway this again was quite different than what you depicted into the initial post since the key name was 'properties' and inside there were no '0' or '1' subkeys but just 'EDID' one.
I used that one (after making other adjustments!) and RatRefresh seemed to lilke it !

When I ran the tool, I saw the monitor changing resolution (a low one like 640x480), then changing immediately back to the one I was using.
Output of the command line was the following:

C:\Users\Metalhammer\Desktop\RatRefresh>RatRefresh.exe -edidfile edid.txt -refresh 57.44
Key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY\GSM56B8\5&2c2b7b9d&0&12345678&01&00\Device Parameters
Value EDID
WantedRefreshRate 57,44
HexCurrentPixelClock 2ea5
CurrentPixelClock 11941
HexHorizontalResolution 0690
HorizontalResolution 1680
HexverticalResolution 041a
VerticalResolution 1050
HexHorizontalBlankingPixels 00a0
HorizontalBlankingPixels 160
HexVerticalBlankingLines 001e
VerticalBlankingLines 30
TotalHorizontalResolution 1840
TotalVerticalResolution 1080
CalculatedPixelClock 11414
HexCalculatedPixelClock 2c96
ReversedEdidHexCalculatedPixelClock 962c
TotalChecksum 9033
Checksum 183
HexChecksum b7

Unfortunately I didn't find any tool to check if the monitor refresh rate had really changed !

I tried to run MAME games with that refresh rate but results were absolutely disappointing: together with the micro stuttering I got also tearing !
I tried to disable/enable triple buffering but difference was not huge (disabling it made the situation worse though).

Since in the registry I found two EDID entries, as if I had two monitors (like your 0 and 1 entries I presume), I tried also to use the 'other' display key (just in case) and while if I run the RatRefresh twice on the 1st I got the message 'refresh already set', if I run the 2nd I see the same resolution swap but never get the message.

I also noticed in CRU that 2nd display has the only resolution/refresh rate set to whatever I set it to while primary always stays to 60Hz.

I'm sure now that unless I have a way to check whether monitor is 'really' using the refresh rate I ask it to use, there will be no progress  :banghead:

Are you 100% sure MAME games, using this tool, don't show anymore the slightest amount of tearing and micro stuttering  :-[?

Cheers  :)

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
No, Device Parameters is not the key you need. You need the EDID override key. So yes it still tries to write to the read-only key you supplied, and restarts the videodriver which is why the screen 'flashes'. But also it's obvious tearing isn't gone as you do NOT actually change refresh rates with that key. I don't know how to make the manual easier to understand as it's already step by step. But here's my guess: you did NOT set a custom resolution with CRU first. In the current version of RatRefresh you will still need to do that.

So start CRU, and create a custom resolution with the native resolution of your monitor, and for example 59Hz or something like that. As soon as you apply that, in the registry under "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY" the monitor you created that resolution for should have an EDID override key. Underneath that there is probably a 0 and 1 value, usually you should use 0. That key, including 0 (or 1 if that's the active screen) and it should work.

Also, if the resolution is finally set, again I'd advice NOT to use triple buffer and/or waitvsync, but only syncrefresh. I have just tried it on a machine with a NVidia GPU and it works perfectly fine. I'd really advice you to thourougly read the opening post and work through it step by step.

The next version will allow to just select a displaydevice and the tool will read the EDID and create the appropriate override key. But for now, you'll need to go through all the hassle (but only once). If it still doesn't work, please report with a screenshot of your display registry key with all keys you have access to expanded, and the output of RatRefresh. I'm sure we can get it to work :) We could also do a Teamviewer session, as I really want to help you to get good results. :cheers:

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
[...]
The next version will allow to just select a displaydevice and the tool will read the EDID and create the appropriate override key. But for now, you'll need to go through all the hassle (but only once). If it still doesn't work, please report with a screenshot of your display registry key with all keys you have access to expanded, and the output of RatRefresh. I'm sure we can get it to work :) We could also do a Teamviewer session, as I really want to help you to get good results. :cheers:
Man, you're gr8  :)

I cannot thank you enough for the assistance in this  ;) really appreciated   :cheers:
... if eventually we'll make it, I'll ask you a photo of yours in order to build a statue and put it next to the cabinet  :lol

I'm now going to try again, following your new advice, and report  8)

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Guys this was thought to be a long post and ideed it was  :-\
... unfortunatelly, after writing for half an hour, I got logged out and I lost everything  :banghead: !!!!

Let's try to start from scratch, but I'm not sure I'll remember everything.

First of all: we made it  8) !!! ... thanks to RataPlan kind assistance I got what I was doing wrong  ;)

In few words, the resolution I put inside CRU, was my monitor native one (1600x1024@60Hz) and Windows/CRU was not picking it up as a real
custom one and, as such, it was not adding the EDID_OVERRIDE key inside the registry.

Adding a more 'exotic' refresh rate (59.59Hz) made the trick  ;) !

After configuring everything as Rataplan suggested, I prepared myself to enter the truth test: running a game with a non 60Hz refresh !

I used Ghost 'n Goblins as my benchmark since this was one of the main reasons for embarking into this 'refresh rate' adventure !
Unfortunatelly results were good but not what I was expecting (slightly better that running @60Hz though)  ???.

What I mean with poor results ?
I mean that the scrolling is not 'smooth' but a bit 'jerky' ... not excessively but still something noticeable  :-\.

Now how can I know there isn't something wrong in my procedure and this is the reason for the disappointing results ?
Just because many, many games are now really close to perfection as never before, no matter how hard I played with the MAME settings  :o!

... here I must thank really much RataPlan for the hard work and I won't quit stressing how this guy didn't (so far) receive the attention and
gratitude he deserves  :applaud:!

How well now Neo-Geo games run, how smooth are Mortal Kombat side scrolling portraits (the ones of the characters when you insert coin)  :applaud:!

So what about GnG  ????

To be honest I got few ideas about it which I'd like to share with you; according to my opinion there could be three reasons:

- my LCD doesn't like/pick up the 59.59Hz refresh rate
- MAME GnG driver is not optimized (other games behave similarly while others are simply perfect)
- the original arcade was exclty the same but I never noticed it (I was 8 at the time!)

To rule out the first one, I ask you the favor to do a test:

could you please run Gng (bootleg @59.59Hz) and compare it to Black Tiger (bootleg @60.00Hz) ?
Have a close look at the background: in GnG, tombstones or the far mountains for example, don't move smoothly while in Black Tiger everything is silk smooth !

Since I'm still stuck in finding a way to check my 'real' monitor refresh rate, I did some research and find a little tool, presented inside this same forum.

The tool is FreqTest and you can find it here:
http://forum.arcadecontrols.com/index.php/topic,135230.0.html

Is it reliable ? Can I succesfully check if my panel took the refresh rate I put inside RatRefresh ?

Now for the to do part  ;):

I noticed, as RataPlan himself said in the beginning, that my MAME frontend (FEEL), whenever I switch refresh rate, crashes (it goes black screen eventually crashing in a couple of minutes)  :'(.

Now, if there's no way to prevent this behavior, I'm scr**d  :timebomb: !!!

Indeed, it won't be feasible, inside a cabinet to manually start/stop applications.

Please tell me there's a solution since I cannot believe we went so far just to surrender now to evil windows events  :cry: !!!

One last thought:

I tried the same procedure on a laptop with Intel graphics; I managed to get the EDID_OVERRIDE key and to run RatRefresh but, according to the tool above (and also to various web based testers) I'm still at 60Hz ! ... obviously I tried mame, just in case, and results were trash (same as without RatRefresh), confirming I'm still at 60Hz  :badmood:.

I'm afraid there's not so much to do with my portable rig since probably the vendor locked something to prevent users tampering around with video settings !

I'll leave you alone guys for the moment, hoping that when I'll come back, someone will have really good news for the front end issue  :notworthy:!

Don't forget I still have some room, on the left of the cabinet, for a second statue (the one on the right is already booked for RataPlan's) :lol

Cheers  ;) !

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
I don't know that tool but ran it after running ratrefresh for Ghosts 'n Goblins (which is in fact in my favorite list in my frontend). Results:


It seems to show the value a bit less as it is (or should be) but at least it's not far off the 59.59. Now Ghosts 'n Goblins is not a good game to test this with, as it has 'native' jerky scrolling. It skips a step every 4 or 5 vertical lines or so when playing the game. When the map is shown at the beginning of a level or when you lost a life the scrolling should actually be smooth.
The game I tested most of the tool with is The New Zealand Story, tnzs. It runs at 59.150 Hz from the top of my head and has full screen smooth scrolling which makes it easy to see if it works or not. If the refreshrate is off you will most probably see vertical jags when you are walking left or right, which will completely vanish with the correct settings and vsync or syncrefresh (as said I prefer syncrefresh but still vsync or triple buffer should be ok as well). Indeed games like Metal Slug should be fine to test as well, although Metal Slug and especially Metal Slug 2 are known for some slowdowns when a lot of sprites are on screen. But that's another thing :) Also if I'm correct Metal Slug srolls with 2 pixels wide at a time, so maybe it's not THAT smooth. But again that's a game-thing, what RatRefresh should do is takeaway the tearing, which is a refresh-rate thing independent of the game you are emulating.

I'm still working to get it to work without having to restart the videodriver but despite all suggestions of the people above, that's unfortunately not how it works and I'm afraid there are vendor or even driver specific calls needed to get that working. I'm currently trying to get things working through the ChangeDisplaySettingsEx API but so far it's the same as everything else - it works as soon as the display driver is restarted, but before that it won't pickup the just-created new resolution.

Laptop: My own Lenovo ultrabook has an Intel 4000 or something like that integrated and a 60Hz panel. However, I can change refreshrates of that panel up to about 120Hz actually which is quite insane :) In fact Lenovo has a tool that brings down the refreshrate to 48Hz in order to save some battery. When that option is enabled if I remember correctly it will be 48Hz no matter what I do - Lenovo probably has an even more direct way to change that refresh rate. But with that option disabled I can freely change the refreshrate and it works perfectly fine otherwise.

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Now Ghosts 'n Goblins is not a good game to test this with, as it has 'native' jerky scrolling. It skips a step every 4 or 5 vertical lines or so when playing the game. When the map is shown at the beginning of a level or when you lost a life the scrolling should actually be smooth.
I knew it, I knew it  :angry:
... so basically also the original arcade behaves like this  :-\ !?

I'm still working to get it to work without having to restart the videodriver but despite all suggestions of the people above, that's unfortunately not how it works and I'm afraid there are vendor or even driver specific calls needed to get that working. I'm currently trying to get things working through the ChangeDisplaySettingsEx API but so far it's the same as everything else - it works as soon as the display driver is restarted, but before that it won't pickup the just-created new resolution.
So at the moment, there's no way to avoid any frontend to crash  :cry: ?
(btw also MAME crashes as soon as you change the refresh rate  :'()

... any hope in having Microsoft developers look into this  :-[ ?

Man, I cannot believe we are stuck at this point after all your efforts ... now that finally I saw the light I need to go back into the darkness  :banghead:


Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Rataplan, what about the following idea ? Do you think is doable  ;) ?

- we know we need to use a FE to run our emulators
- we have the ability to pass parameters to RatRefresh whenever we need to run a specific game (mainly rom name)
- we know FE crashes as soon as RatRefresh restarts the video driver in order to have the change take effect  :'(

And if we(you :P) change RatRefresh to:

- accept some more parameters to:
                                                                1) know what emulator we want to run the game from (ie. path of MAME exe)
                                                                2) know the emulator command line and parameters (basically the rom name)
                                                                3) know the front end (FE exe path)

We could:

- pass RatReftesh the game name which will trigger the refresh rate change
- as soon as RatRefresh is finished with the task it could (somehow) kill the FE and launch MAME with the selected rom (*)
- upon MAME exiting, RatRefresh could start again the FE

... as far as I know, the FE shouldn't keep any state from MAME (but the last selected game) which could prevent it from working correctly once restarted by RatRefresh  :-\

Maybe a RatRefresh .ini could also be useful to avoid passing too many parameters (mainly lenghty paths) and easily change stuff.

What do you think  :-\ ?

(*) we could also think about a way to ask the FE to exit as soon as it's finished passing RatRefresh the parameters it needs ! It will be RatRefresh which will take care of monitoring MAME process and spawn the FE back as soon as it exits  ;)
« Last Edit: April 03, 2017, 09:54:51 am by Metalhammer »

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Oh that's easy to do, and could even be done from a simple batch-file which you could start from your FE in stead of MAME64.exe. However, people might get other issues like a 'front-end startup animation' everything you quit a game and such. For now I still want to invest time in getting it to work the way it should rather than creating workarounds. Because I wanted to keep the tool versatile I did not create a standard ini file, but made it to for example specify an edid file, so you can simply pass another edid file if you have a second screen. But that's all gonna change anyway.

If you want your FE to quit and restart, make a simple batch file of it. Your FE starts MAME with parameters (ie ROM name) which you can fetch in a batch file with %1, %2, %3 and so on, each representing one parameter passed from the FE. From the top of my head you could try something like:

taskkill.exe /fi:frontend.exe (modify that to your FE executable)
ratrefresh /edidfile edid.txt /file refreshrates.txt /get %1;mame
mame64 %1
frontend.exe

Actually I have something like that in my own cab now, and it works but it's not ideal by any (of my) means.

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Obviously I agree with your way of seeing things and that RatRefresh should be working as it is ;)

While you find a suitable and definitive solution, just to avoid not taking advantage of your great job, I'll go for the workaround we just discussed  :)

Thanks mate  :)

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Rataplan, I'd like to ask you something quick:

I'm trying to parse a Mame.xml file with the nice tool you worte (MameXMLParser) anyway, despite it saying 'file written' I get absolutely nothing in my directory  ???

I tried running it with admin privileges, running it in a different folder but all to no good  :-\

Any idea on this  :-\ ?

Fixed: it was my Antivirus preventing it from writing to the disk :angry: ... funny thing is that last time I tried, it worked fine :banghead:
« Last Edit: April 06, 2017, 04:59:09 am by Metalhammer »

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Since I'm confident I piled up now some nice experience with RatRefresh, I'd like to share with you my two cents  ;)

In few words, for whoever could come across this thread and just skip to the last post, I can summarize it as follows:

This tool rocks, period  ;)

It allows to adapt the monitor refresh rate to game's own giving you the definitive experience of arcade emulation (I'm using MAME mainly) on a modern PC and LCD screen. Indeed also when you enable all the tearing fixes inside MAME (synch to monitor refresh and triple buffering) you'll still have stuttering coming from the refresh rate differences  :-[

Pro:
- games run smooth and tear/stutter free as never before  :applaud:

Cons:
- the driver reset crashes the FE in use  :'(

Obviously Rataplan is already working hard to find a suitable solution and I'm really eager to see what he will come up with  ;)

Good job Rataplan !


nipsmg

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1738
  • Last login:Today at 08:44:43 am
  • ROONEY!! ERRGH!!
    • Arcadia
Hey Rataplan,

I'm wondering if it might be worthwhile to have a conversation with some of the FE authors out there (Launchbox, Attract-Mode) and see if they can support handling a graphics device handle loss, and go grab a new device   handle on resume.

Instead of attempting to attack this from your end in, it might make sense to petition for support for this tool from the FE authors themselves.

I REALLY want to use this tool, but the majority of the people who will be using the cab are not tech savvy in any way and will be unable to deal with an FE crash.

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Rataplan626: I got advanced mode working in IntelAddCustomMode. I don't think it's adding the decimal part of the refresh rate but give it a try anyway and let me know your results.

You can cut/paste this command line:
Code: [Select]
IntelAddCustomMode.exe mode=adv verbose=true hactive=1920 hfrontporch=48 hbackporch=80 hsyncwidth=32 vactive=1200 vfrontporch=3 vbackporch=26 vsyncwidth=6 vscanrate=59.150

Hi Headkaze, I totally missed that post, sorry for that. I hope you are still reading this. I've redownloaded your tool but it does not accept decimals:

C:\Users\Rataplan_\Desktop\IntelAddCustomMode>IntelAddCustomMode.exe mode=adv verbose=true hactive=1920 hfrontporch=48 hbackporch=80 hsyncwidth=32 vactive=1200 vfrontporch=3 vbackporch=26 vsyncwidth=6 vscanrate=59.150
dwColor             : 32
bScanType           : 0
dwHActive           : 1920
dwHFrontPorch       : 48
dwHBackPorch        : 80
dwHSyncWidth        : 32
bHSyncPolarity      : 0
dwHScanRate         : 74410,7
dwVActive           : 1200
dwVFrontPorch       : 3
dwVBackPorch        : 26
dwVSyncWidth        : 6
bVSyncPolarity      : 0
dwVScanRate         : 59150
dwHTotal            : 2080
dwVTotal            : 1258
dwPixelClock        : 154774,256
bIsValid            : 0
Setting DELL U2412M (256) to 1920 x 1200 59150 Hz. Success

It says it sets to 59150Hz which could be a cosmetic bug, but the screen does NOT go blank and the actual refreshrate does not change. I test that with setting my display to 60Hz, then run your tool and then play The New Zealand Story (tnzs), I always test with that as it has a full moving screen pixel by pixel at 59.150. At 60Hz it gives tearing. After running the tool with the given commandline it still running at 60Hz.

But it doesn't seem to work with integer refreshrates either on my system. When I set it to 55Hz for example, it accepts it, the screen goes blank for a second as it would do from Intel panel itself, but yet it still runs at the same refreshrate as before. Also it does not show as a custom resolution in the intel panel which I expected it would do (but I could be wrong).



Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Hey Rataplan,

I'm wondering if it might be worthwhile to have a conversation with some of the FE authors out there (Launchbox, Attract-Mode) and see if they can support handling a graphics device handle loss, and go grab a new device   handle on resume.

Instead of attempting to attack this from your end in, it might make sense to petition for support for this tool from the FE authors themselves.

I REALLY want to use this tool, but the majority of the people who will be using the cab are not tech savvy in any way and will be unable to deal with an FE crash.

Well I think it's not feasible to just 'fix' that in the FE. If you are using a device which driver is stopped, well I can imaging your software goes berzerk. I still want to try to fix that though, so a fix is not needed on FE side. By the way, I use AttractMode myself, and I kill it in a batch file which fires when I select a game. It then starts RatRefresh, starts the emu, and after the emulator quits, it starts AttractMode again. Attractmode happens to remember the last played game even if it was brutally killed. So for now, for me, that's a little workaround which still automates everything completely. But being a technician, I don't like workarounds, I want fixes :)

nipsmg

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1738
  • Last login:Today at 08:44:43 am
  • ROONEY!! ERRGH!!
    • Arcadia
I started talking with the AttractMode guys over on their github.  They suggested looking at the "ResFix" plugin to compensate.  Any experience with that?

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
[...]
By the way, I use AttractMode myself, and I kill it in a batch file which fires when I select a game. It then starts RatRefresh, starts the emu, and after the emulator quits, it starts AttractMode again. Attractmode happens to remember the last played game even if it was brutally killed. So for now, for me, that's a little workaround which still automates everything completely. But being a technician, I don't like workarounds, I want fixes :)
This indeed is the same procedure I ended up with (thanks to Rataplan for support) for a different FE (Feel)  ;)
... the only difference is that, instead of 'killing' the process, I ask it to close  :P

While Rataplan works at a possible fix, this is the only workaround I found which allows me to use this tool in an automatic and almost transparent way.

Personally I strongly believe the benefits far outpass the hassle of going through the procedure of fine tuning the batch/script file  :)

nipsmg

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1738
  • Last login:Today at 08:44:43 am
  • ROONEY!! ERRGH!!
    • Arcadia
I might have to set this up in a couple weeks when I get back from vacation.  Would either of you mind sharing your batch files?

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
No problem Nipsmg, send me a pm when you'll be back and I'll send you my script  ;)

Not sure it could be an issue with the real thing (mame cabinet) but I'll report what I experienced on my test rig (a simple PC with mame, FE and Ratrefresh stuff to play/experiment around):

- over here I use the FE in windowed mode
- 90% of times I leave other windows open (ex. notepad or simply folders), after mame quits and script reopens the FE, I get a Windows Explorer process crash  :-\
- around 40% of the times, again when mame quits and FE respawns, I loose focus on it: I can see the FE window in the application bar blinking but the open window doesn't respond to commands until I click on it  :-\

As I said, I'm not sure the above could be an issue when FE is in fullscreen mode and no other windows are open (as should happen on a dedicated mame cabinet) anyway, it won't be bad to learn something if you have any good idea/hint on the subject ;)

Cheers  :)

nipsmg

  • Trade Count: (+2)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1738
  • Last login:Today at 08:44:43 am
  • ROONEY!! ERRGH!!
    • Arcadia
would using something like crt_emudriver and vmmaker be a potential vector for attacking this problem?  Or are they completely unrelated?

http://geedorah.com/eiusdemmodi/forum/viewtopic.php?id=295


Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
would using something like crt_emudriver and vmmaker be a potential vector for attacking this problem?  Or are they completely unrelated?

http://geedorah.com/eiusdemmodi/forum/viewtopic.php?id=295
Do you mean using a CRT instead of an LCD  ;) ?

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
would using something like crt_emudriver and vmmaker be a potential vector for attacking this problem?  Or are they completely unrelated?

http://geedorah.com/eiusdemmodi/forum/viewtopic.php?id=295

I've never worked with CRTEmu, but I do know it only works on ATI cards. They are somehow related, in the sense that they edit EDID information and use that so set specific resolutions / refresh rates. I don't have any ATI cards myself so I can't test.

But, as stated before so far the issue is that we need to restart the videodriver in order for it to pickup the just-edited EDID values. It's with CRU, and any other tool I've seen so far. I've asked people to confirm they can change to just set custom resolution and refreshrate without restarting the videodriver, but no-one has proven me that yet. The only way I know how to do that is to use the manufacturers control panel. NVidia can pickup custom resolutions without restarting the videodriver, and Intel can as well. But that would mean I'd have to talk to driver-specific DLLs and functions, which might change in any or every driver release, which makes it extremely error-prone especially with Windows 10 were there's little control in updates for average Joe.
My test-systems  as well as my cab runs on Intel GPU. The custom resolutions set with the Intel control panel goes to a completely different registry part, and does not use the default EDID override keys and values. Also when I manually put that registry in, it doesn't pick it up either (until a driver restart). So that means the Intel panel triggers a function which makes it pick up the custom resolutions, which was already clear to me as the screen goes black for a second when you apply them from the panel. The difference is though that using the Intel panel, even when it blanks the screen it does NOT reset the displaydriver, which means that graphic applications like the frontend don't loose their display ports and keep working.

Still looking for a generic solution for this. But I've got some very busy weeks in my company, so I've had very little time to work on it. On the other hand, tools like CRU and other tools can as far as I am aware NOT pickup new resolutions with a reboot or reset of the display driver either. Which sort of means I I wonder if it's possible at all.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Also it does not show as a custom resolution in the intel panel which I expected it would do (but I could be wrong).

I'll have a look when I get a chance. Thanks for the feedback.

BTW Have you tried calling "devcon restart =display" instead of using disable/enable?

And what about reload.zip?

Quote
It just sets GPU scaling to whatever the current setting is for each monitor, which seems to be enough to reload the overrides.
« Last Edit: May 13, 2017, 04:58:27 am by headkaze »

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Hi Headkaze,

could you please share some details about the mysterious 'reload.zip' file you attached  ::) ?

... I'm pretty curious  ::)

Thanks !

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Also it does not show as a custom resolution in the intel panel which I expected it would do (but I could be wrong).

I'll have a look when I get a chance. Thanks for the feedback.

BTW Have you tried calling "devcon restart =display" instead of using disable/enable?

And what about reload.zip?

Quote
It just sets GPU scaling to whatever the current setting is for each monitor, which seems to be enough to reload the overrides.

Headkaze, a million thanks for your help and interest. Devcon restart does the same as disable and restart. In fact I do use restart in my tool, but that still disabled and enabled the driver. The reload.exe seems interesting. Unfortunately it fails with 'Failed to load atiadlxx.dll' which makes me  believe it's only for ATI/AMD cards. Still, I'll see if I can find anything in that direction for NVidia / Intel as well.

Sorry for the late reply again, somethings wrong with the notifications for some reason.

headkaze

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 2943
  • Last login:August 14, 2023, 02:00:48 am
  • 0x2b|~0x2b?
Here is the source to the IntelAddCustomMode utility (IntelAddCustomMode1.1_Source.zip).

It was working for me (both Basic and Advanced) so I'm not sure why it isn't for you. Either way I don't think this tool will allow us to use non-integer refresh rates.

pulp25

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 1
  • Last login:July 18, 2018, 10:44:40 am
  • I want to build my own arcade controls!
Fantastic Software.

I use it with a Nvidia 1030 and a Viewsonic 2365wp (Fv : 50 – 75 Hz) IPS 1080P

I configure .bat for emuloader frontend to test it with mame and all is ok with all filter on (GLSL).

R-Type 55khz -> smooth
Mortal Kombat 55khz -> smooth
Neo-Geo KOF 2000 59.x khz -> wall scrooling smooth

Negative point : The EDID process (windows sound for new device manager [can't cut sample], restarting driver) but it work
                        The Response Time of the LCD Viewsonic 2365wp

Thanks
« Last Edit: October 10, 2017, 06:20:49 am by pulp25 »

Rataplan626

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 63
  • Last login:November 13, 2023, 08:26:53 am
  • I want to build my own arcade controls!
Hi, we are currently about to move back in our completely rebuilt house. Which means I am about to unpack my cab again, and my actual PC, and be able to work on this tool again. Although I've had only 46 downloads (count 'em!) I have some idea's to improve usability. Having said that, for me it works fine with the quircks it has. Are people actually using it?

Metalhammer

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 19
  • Last login:September 11, 2018, 08:05:47 am
  • I want to build my own arcade controls!
Re: RatRefresh - Automated EDID updater for MAME and others - no more LCD tearing
« Reply #77 on: September 11, 2018, 08:00:54 am »
Hi, we are currently about to move back in our completely rebuilt house. Which means I am about to unpack my cab again, and my actual PC, and be able to work on this tool again. Although I've had only 46 downloads (count 'em!) I have some idea's to improve usability. Having said that, for me it works fine with the quircks it has. Are people actually using it?
Hi Rataplan, nice to hear from you again  ;)

Just letting you know every time I power on my cab I cannot help but thank you once more for your tool  :notworthy:
... showing it with pride to everyone who comes around and who grew up playing arcades  ;)

Obviously let me know if there will be further developements: improvements are always welcome  ;D

Take care  ;)

Cheers  :cheers:

ramos8414

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 65
  • Last login:January 09, 2019, 08:27:24 pm
  • I want to build my own arcade controls!
Can you please reupload the example pictures.

ramos8414

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 65
  • Last login:January 09, 2019, 08:27:24 pm
  • I want to build my own arcade controls!
Hi. I've been looking for a tool to automatically change refreshrates on my LCD corresponding the game I start. More like CRU does, but then automated for use with MAME. I was unable to find something like that. So I wrote it myself.

I short: you can run 'RatRefresh.exe -edidfile edid.txt -file refreshrates.txt -get bublbobl;mame' to switch to the exact refresh rate for that game.

A little backstory
Last year I've build me an arcade-cabinet with a LCD screen. We all know that gives issues with refreshrates and tearing. (And I don't want to debate that - I know CRT is 'better' for arcade gaming). We also know we can use CRU or actually EDID overrides to setup custom refreshrates to solve that. But that's quite cumbersome if you need to switch refreshrates between games. Also until a short while ago you would need specific hardware for that, as only ATI and NVidia seem to support EDID override. As my cab uses its Intel Core i3 6300 build in GPU I was out of luck anyway. Until a short while ago when Intel finally released a testdriver with EDID override support. Check https://communities.intel.com/thread/25904?start=150&tstart=0 for more info, and https://downloadcenter.intel.com/download/26504/Intel-Graphics-Test-Driver for that actual driver download. It will relatively soon come out of test and from then on the official Intel driver will probably support EDID override as well. This testdriver was only supposed to support 4th and 5th gen iGPU's with internal panels only. Still I took the plunge and what do you know? It worked! Using CRU I was now able to do custom resolutions and refreshrates on my Intel GPU! If you use that with MAME's -syncrefresh option, it will give you a completely tearing-free experience at the correct game-speed.

The next step was to automate this, so when I select a game, the resolution automatically switches. No tool as such found, so I wrote:

RatRefresh

RatRefresh is a simple tool that updates the EDID information of the first custom resolution to match a given refreshrate. It's mainly intended to switch your display refreshrate to exactly match the MAME game you will play. I've given it some thoughts but for now I've made it quite universal, with both manual command line and input from a file with games/refreshrates in it. You could put anything you want in the inputfile with a specific refreshrate, and it can be picked up. So if you want to automate this to run your mediaplayer at 59.94Hz, you can.

Note that this is currently more or less a testbuild.

Requirements

I use .NET Studio to program. For now though this means .NET 4.5.1 is required. Most of you will already have that on your systems anyway. However this whole tool could have been created in a rather simple VBScript as well, but for now this tool will be written and updated in .NET only.
Reason for only one custom resolution: Windows will automatically switch to the first custom resolution if only one is there, which means no manual resolution-switching is needed after that.

Usage
There are a few initial manual steps involved. As I want to keep it versatile I will keep it that way for now.

  • Unzip the RatRefresh zipfile to a folder on your system
  • Start CRU and create ONE custom resolution for your display. Use whatever resolution you want to play your games in, I use the native resolution of my screen which is 1920x1200@60Hz. If a custom resolution is already there, delete it and recreate to make sure the registry keys are setup correctly. If multiple custom resolutions are there delete all but one. Example:



  • Now start regedit.exe and find the the path to the EDID_OVERRIDE key + value. It is located in "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\DISPLAY" and then some subkey for your  GPU / display. You could search for 'EDID_OVERRIDE' or look for the value 'CRU_Name'. In that key you will probably two REG_BINARY values, 0 and 1. These correspond to the monitor number (I think) and on all my systems this is 0.
    Now right-click the EDID_OVERRIDE key in the left-pane and click 'Copy Key Name'. Then open notepad and paste that key. Now add \ and the monitor number behind that, for example \0.
    It should look like this, but probably with differend ID's in:



    save that file to the RatRefresh folder as edid.txt, or another name if you want, like monitor_1.txt

Basic setup is done now. You can now run RatRefresh as follows (I use edid.txt here):

RatRefresh -edidfile edid.txt -refresh 59.150

This will set the refresh rate of the display setup in edid.txt to 59.150. After it does that it will run devcon64.exe to restart the displaydriver, more on that below.


Automate for MAME
As for now I merely run MAME on my cab, I wanted to automate that. MAME's XML file contains the refreshrates for all machines it supports. However parsing the almost 200MB and growing XML file takes quite a while, even on beefy PC's (using .NET libraries that is). When using the regular XML tooling available in .NET memory usage grows beyond 2GB when processing mame.xml. My cab has 8GB of RAM, but I know there are a lot of machines with maybe only 1GB. So I wrote a little, not so smart mame.xml parser of my own, which is way faster and uses a fraction of the memory. But it might be buggy. Still this would take way too long to do with each game you select, so I went another route.

MameXMLParser.exe
MameXMLParser.exe takes a MAME xml file as input and outputs a plain textfile with the following structure:

<rom name>;mame;<refreshrate>

one rom per line. So you'll end up with a file with as many lines as MAME supports individual machines. To fetch a game out of that file takes a fraction of a second even on the slowest and worst piece of cr@p pc I have still lying around, which is a Intel Atom N330 based netbook.

Usage:
  • First create a MAME xml file by running 'MAME.exe -listxml > mame.xml'. If you run 64bit MAME it will be 'MAME64.exe -listxml > mame.xml'. If you use any other MAME distribution use it's executable name, I think all support the -listXML option.
  • Find out your displays native default refreshrate. Not all MAME machines have a refreshrate set in MAME.XML, for example mechanicals. When no match is found your screen will still need a certain refreshrate :) Usually this is 60.000 or 75.000 but you can use whatever you want if your monitor supports it.
  • Then run 'MameXMLParser.exe -input mame.xml -output refreshrates.txt -default 60.000'
    This will generate rereshratex.txt with all needed info for MAME.
  • Now you can use RatRefresh with this generated refreshrates.txt file:
    RatRefresh.exe -edidfile edid.txt -file refreshrates.txt -get bublbobl;mame
    This will search for the string 'bublbobl;mame' in 'refreshrates.txt' and set the corresponding refreshrate.

You could easily add roms for another emulator to this file with whatever name you want to call it, like
nes;nes;60.000
palgenesis;palgenesis;50.000


When used together with a frontend (more on that below) it can usually supply you the emulator / system name you are starting a game for to use in a commandline.


Issues
  • I have put some error-checking in, but certainly not excessive. Using wrong combinations of commandlines or inputfiles will probably result in a nice errormessage. Read the help again and try again.
  • Frontends: huge issue for me personally: When an EDID resolution is added, it's only picked up when the displaybus is reset. This means restarting the displaydriver works, physically switching the display off and on works, and removing the (DVI at least) cable and reconnecting it works. For now I can only do the first one, restarting the videodriver.
    The issue with this is though that the frontend I use on my cab, AttractMode, crashes. This makes sense as it looses its screen completely when running. However when switching the monitor off and on again or pluging the cable, the new refreshrate is picked up too. So I am still looking for a way to simulate that instead of restarting the whole videodriver.
    For now that means I am personally only using it from commandline. I haven't tested other frontends though.
    Any suggestions to solving this are welcome!
  • Admin permissions required. As the EDID value is stored in HKLM registry, you will need admin rights to modify them. This could be prevented by granting users write permissions to the EDID_OVERRIDE key. However, after that restarting the display driver requires admin permissions as well. Those permissions can also be granted to users, but as I am still looking for a better way to have the EDID values reloaded. For now I use devcon to restart the display driver.
  • I haven't done any testing at all on x86 machines, as I simply don't have x86 running anymore. Feel free to report!

Version history
v0.1 download
initial release


v0.11 download
fixed: bug in calculating horizonatal blanking pixels - thanks to xxDaViDxx for reporting!
Also switched back from using CRU's Restart64.exe to devcon64.exe, to be less dependant of CRU.



I this tool is useful for you, or you have questions or bugreports, feel free to respond. If you test it, please respond if it works for you. If something like this already exists and I am making a fuss out of nothing feel free to respond as well :) Happy gaming!  :cheers:

Fixed the image url's.