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: How to change default vertical refresh rate, but still keep original game tempo?  (Read 4723 times)

0 Members and 1 Guest are viewing this topic.

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
For example, Popeye was set to 30Hz during mame37, then it switched back to 60Hz in mame60.

I want to modify few drivers (popeye & gberet) in mame37b5 so they work on 60 instead pf 30fps.
So far all I have found is this, in /drivers/popeye.c:

Code: [Select]
30, DEFAULT_30HZ_VBLANK_DURATION

If I change that to 60 and recompile, then the game just runs twice as fast, so obviously there are more stuff that needs to be changed, but I have no clue what or where can that be. Help?


I was also wondering if I could change refresh rate of any game to 50Hz (PAL), but again, in such way so that actual game & sound timer/tempo stays the same as original. Is this possible/easily done?
---Perm Ban, again---

bitbytebit

  • Guest
  • Trade Count: (0)
For example, Popeye was set to 30Hz during mame37, then it switched back to 60Hz in mame60.

I want to modify few drivers (popeye & gberet) in mame37b5 so they work on 60 instead pf 30fps.
So far all I have found is this, in /drivers/popeye.c:

Code: [Select]
30, DEFAULT_30HZ_VBLANK_DURATION

If I change that to 60 and recompile, then the game just runs twice as fast, so obviously there are more stuff that needs to be changed, but I have no clue what or where can that be. Help?


I was also wondering if I could change refresh rate of any game to 50Hz (PAL), but again, in such way so that actual game & sound timer/tempo stays the same as original. Is this possible/easily done?


You might want to try out cabmame and use the "-redraw auto" option to fix the 30Hz issue and possibly some other options it has...

http://community.arcadeinfo.de/showthread.php?t=9555

That has mame version 139, I have an updated 140u3 mame binary with the same hacks applied:

https://sourceforge.net/projects/groovyarcade/files/Mame_Windows_Builds/

It is aimed more at arcade monitors but those hacks do have the ability to do the things your wanting, may have to turn changeres off and possibly cleanstretch, turn hwstretch on, if your not using an arcade monitor.  

I don't think changing Mame would be very easy to run those games differently, since it should be set to the original refresh I think or else they are doing something to make it run properly when emulated (and have probably done a ton of odd things in mame for that which are hard to trace and change, especially if you ever want to upgrade and retain the changes you made).
« Last Edit: December 30, 2010, 12:44:30 pm by bitbytebit »

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
That's not what I'm asking.

I am not asking this as "user", but as "developer".

My question is about modifying source code, not about binaries.


It should be easy to make such modifications, there should not be many places where these numbers are defined in MAME, so the real question I suppose is whether there is anything to be changed in the game ROMs themselves.
---Perm Ban, again---

bitbytebit

  • Guest
  • Trade Count: (0)
That's not what I'm asking.

I am not asking this as "user", but as "developer".

My question is about modifying source code, not about binaries.


It should be easy to make such modifications, there should not be many places where these numbers are defined in MAME, so the real question I suppose is whether there is anything to be changed in the game ROMs themselves.

Ah I see, yeah that definitely sounds interesting, I'm curious about that as well so hopefully someone knows more about how the ROMS and mame work together to produce the vertical refresh rate. 

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
Got it, the first part. It's actually very obvious from 'gberet' driver since it defines both original and bootleg PCBs, and funny enough original refreshes screen at 30 while bootleg at 60 FPS:

*gberet
Code: [Select]
static struct MachineDriver machine_driver_gberet =
{
 /* basic machine hardware */
 {
 {
 CPU_Z80,
 18432000/6, /* X1S (generated by a custom IC) */
 readmem,writemem,0,0,
 gberet_interrupt,32 /* 1 IRQ + 16 NMI (generated by a custom IC) */
 }
 },
 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */

*gberetb
Code: [Select]
...

gberet_interrupt,16 /* 1 IRQ + 8 NMI */
 }
 },
 60, DEFAULT_60HZ_VBLANK_DURATION, /* frames per second, vblank duration */
 

--> "gberet_interrupt,16" : defines how many times will main game loop be updated per animation frame, this is usually "1", and gberet seem to be rather odd exception with 16 interrupts per 1/60 of a second. Anyway, the point is, by changing this number we practically redefine game speed in relation to display refresh rate, which is exactly what my previous modification needed to get the speed back down to normal.


So, applying this to "popeye.c"...
Code: [Select]

static struct MachineDriver machine_driver_popeyebl =
{
 /* basic machine hardware */
 {
 {
 CPU_Z80,
 4000000, /* 4 Mhz */
 readmem,writemem,readport,writeport,
 nmi_interrupt,2
 }
 },
 30, DEFAULT_30HZ_VBLANK_DURATION, /* frames per second, vblank duration */
 

CHANGE: "nmi_interrupt,1"
CHANGE: "60, DEFAULT_60HZ_VBLANK_DURATION"


Similarly, in 'gberet' change the number of loops from 32 to 16, together with changing 30 to 60 in the line below, just like it is defined for bootleg gberet PCB in the same file. Ok, this was easy since 30Hz mode looks like hack/derivate of 60Hz to start with, but unfortunately this logic can not help us with setting up global arbitrary refresh rates (without impacting original game speed) ...unless perhaps we define number of loops as float instead of integer, but that just sounds like awful thing to do with 'counter' variable.


Btw, I want to lock all games to 50Hz as some of my SCART TVs (PAL) can't quite sync above 53-54Hz, but if you have arcade monitor then you'd probably want to lock games to 60Hz, and if you use PC monitor you might even go for 100Hz and above, but now this 'temporal resolution' would be unrelated to game spatial resolution properties such as size/shape and number of pixels. Yes, no? Good, bad? Possible, impossible? Authentic emulation, or unforgivable hack?
---Perm Ban, again---

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
I'm not sure I understand how the end result is any different from the redraw option.

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
* 2nd part: One frame-rate to rule them all
==================================

Ok, so far this was completely useless to most, but solving this second part concerns everyone, it's sort of "philosopher's stone", the solution to almost every visual problem, which mainly come about due to mismatch of original game timings VS. properties of given monitors and graphic adapters. In other words, this would make everything perfectly smooth for everyone regardless of their particular display type and its limitations or incompatibility in relation to authentic hardware.


But first, I'd like to start a little argument as I believe there is valid objection this would not produce accurate/authentic emulation, whatever that means. For start, let me underline that I am not talking about what SmoothMAME does/did, they simply changed only that last parameter I was talking about above, overriding specific value given by the particular game driver to 60, but as is obvious from my first attempt changing that value also directly impacts general game speed too, so characters move slower/faster than they should and music/sound has wrong tempo and pitch.

And so, I want to suggest here display refresh rate is independent visual property from 'game speed', and although tightly related on actual hardware, within an emulator we can handle them as completely separate and unrelated. I'm arguing the game stays accurate/authentic as long as the main game logic, sound and input sampling still run at the same speed as original hardware, so then the number of times screen updates within a second is more a measure of visual "flicker" than "defining" aspect of the game play.


In any case, the proposed 'solution' should produce something like SmoothMAME, only better - more authentic/accurate. Has anyone thought of this before, did I miss something and maybe wrongly concluded how magnificently fantastic would this solution be to overcome all visual problems, for everyone?
---Perm Ban, again---

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
I'm not sure I understand how the end result is any different from the redraw option.

I am not sure I know about "redraw" option. What does it do? Is it part of mainstream MAME, since what version? -- I don't think that would be the same, but If "redraw" indeed does what I hallucinated here, then everyone should be talking about it!  :D
---Perm Ban, again---

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
From the link in the very first reply to your question:
Quote
Redraw
To stay short.
Redraw allows MAME to output frames multiple times, for example 30Hz games running on 60HZ, or 60Hz games running "lowres" on a VGA Monitor (using 120Hz)

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
cotmm68030: "I'm not sure I understand how the end result is any different from the redraw option."

I know what is "redraw" now, but I still do not know what "end result" you are comparing it to? -- In any case, I do not see how "redraw" can help with any of it. How do you suggest "redraw" can set all games to refresh @ 50Hz and sync perfectly with PAL-only TVs? What do you think is the same?


The only similarity I see is that "redraw" can too reduce 'flicker', but it is not what initializes/defines resolution... [DELETED]
« Last Edit: December 31, 2010, 11:51:18 am by abaraba »
---Perm Ban, again---

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
I suppose I need to re-read what it is you're trying to achieve.

No, redraw would not help in the case where the original frame rate is higher than the target frame rate. Though I'm not sure what you can do in that instance other than running the game at a slower speed to match the target refresh rate. As I understand it this is what the 'refresh speed' option does.

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
Ok I've read what you've posted about three times now and I'll just have to show my ignorance, because I cannot understand what you're trying to suggest happen in the scenario for your PAL tvs.

This is what I'm understanding you want to do, please correct me if it's wrong:

Display is a PAL tv, locked to 50Hz.
Game in question runs at a non-50Hz rate, such as your example of 54Hz.
You want the game to be locked at 50Hz, but not slowed down, nor pitch changed, nor timings changed.


If this is correct, I do not understand how this can happen without skipping a frame, or some how drawing frames 'on top' of each other.


While we're on the topic of temporal resolutions; I'd sure love to see a 'filter' that interpolates motion between filler frames similar to how the newer 120hz LCDs produce in-between frames. It certainly wouldn't work in all situations, but it would be a novelty none the less. Particularly with very nice CRTs that can run at 180hz and higher. Bonus points if it works on systems with 'layers' independently of one another.

Calamity

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7463
  • Last login:Yesterday at 04:03:33 am
  • Quote me with care
And so, I want to suggest here display refresh rate is independent visual property from 'game speed', and although tightly related on actual hardware, within an emulator we can handle them as completely separate and unrelated. I'm arguing the game stays accurate/authentic as long as the main game logic, sound and input sampling still run at the same speed as original hardware, so then the number of times screen updates within a second is more a measure of visual "flicker" than "defining" aspect of the game play.

This is a very interesting subject, although I completely disagree the paragraph above. My objection is not only conceptual, but more technical.

Of course, in the context of emulation, you can handle game speed unrelated to display refresh rate. However. you'll achieve the infamous emulated-game-look we're trying to fight against.

In other words, there's no possible way you can render a 60Hz game keeping it's original 'game speed' on fixed 50Hz frequency TV without ruining the scroll.

BTW, the -redraw patch is only useful when we want to render the game at an integer multiple of its original fps, that's why it works with games like gberet.
Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead of pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
I suppose I need to re-read what it is you're trying to achieve.

No, redraw would not help in the case where the original frame rate is higher than the target frame rate. Though I'm not sure what you can do in that instance other than running the game at a slower speed to match the target refresh rate. As I understand it this is what the 'refresh speed' option does.

Yes, actually yes. I got confused, so I deleted the silly part above. Still though, the question is how is that implemented,  how to apply that to 'popeye.c' (mame37b5) example above? -- And so, does this "redraw" work fantastically amazing for everyone as I imagined, or are there still some visual artifacts?
---Perm Ban, again---

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
This is what I'm understanding you want to do, please correct me if it's wrong:

Display is a PAL tv, locked to 50Hz.
Game in question runs at a non-50Hz rate, such as your example of 54Hz.
You want the game to be locked at 50Hz, but not slowed down, nor pitch changed, nor timings changed.

Yes.

Quote
If this is correct, I do not understand how this can happen without skipping a frame, or some how drawing frames 'on top' of each other.

Yes, you are right, but let me underline this is not the same "skipping a frame" as when CPU is too slow, this can be done to look absolutely smooth since everything gets done in time and in regular time intervals, as scheduled.

It surely does not sound too good to loose 10 frames, but this should still produce the "same" game as much as, say Genesis games for NTSC and PAL markets are the same, but if these games are generally considered "very different" in playability or gameplay, so one can be easier/harder than the other, then I am wrong.
« Last Edit: December 31, 2010, 12:33:08 pm by abaraba »
---Perm Ban, again---

Calamity

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 7463
  • Last login:Yesterday at 04:03:33 am
  • Quote me with care
Yes, you are right, but let me underline this is not the same "skipping a frame" as when CPU is too slow, this can be done to look absolutely smooth since everything gets done in time and in regular/symmetric time intervals, as scheduled.

I'm afraid that's not possible.

It surely does not sound too good to loose 10 frames, but this should produce the "same" game as much as, say Genesis games for NTSC and PAL markets are the same, but if these games are generally considered "very different" in playability or gameplay, so one can be easier/harder than the other, then I am wrong.

Have a look at this link:

http://en.wikipedia.org/wiki/PAL_region

Important note: posts reporting GM issues without a log will be IGNORED.
Steps to create a log:
 - From command line, run: groovymame.exe -v romname >romname.txt
 - Attach resulting romname.txt file to your post, instead of pasting it.

CRT Emudriver, VMMaker & Arcade OSD downloads, documentation and discussion:  Eiusdemmodi

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
A lost frame, regardless of if it is intentionally skipped or unable to be drawn in time due to CPU speed, is going to have the exact same visual effect.

How exactly do you expect a smoothly scrolling action to look visually uninterrupted when part of the sequence is missing?

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
Quote from: Calamity
This is a very interesting subject, although I completely disagree the paragraph above. My objection is not only conceptual, but more technical.

Ok, so what exactly is objection?


Quote
Of course, in the context of emulation, you can handle game speed unrelated to display refresh rate. However. you'll achieve the infamous emulated-game-look we're trying to fight against.

What are you talking about and why exactly is that so?


Quote
In other words, there's no possible way you can render a 60Hz game keeping it's original 'game speed' on fixed 50Hz frequency TV without ruining the scroll.

I hear what you saying, but you are not explaining reasoning behind it, how did you come up with that conclusion?
 
---Perm Ban, again---

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
In the simplest of examples you would have a pixel moving one pixel per frame. If I'm only able to draw 50 of those frames in a second and the pixel has moved 60 spaces, some of that motion will be inconsistent because a greater range of motion elapsed between drawn frames than some other interval.

newmanfamilyvlogs

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1694
  • Last login:June 15, 2022, 05:20:38 pm
    • forum.arcadecontrols.com/index.php/topic,103584.msg1096585.html#msg1096585
    • Newman Family Vlogs
And couldn't you have registered with a username that didn't tie back to your blog? Weren't you banned?

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
Quote from: Calamity
I'm afraid that's not possible.

Why do you think so?


Quote from: Calamity
Have a look at this link:

http://en.wikipedia.org/wiki/PAL_region

Ok, some games have lousy ports, even to the point that actual game speed differs between regions, but if the port is done properly there should be no actual difference in the gameplay. The differences should be more along the lines of watching TV in UK vs. USA, or watching it via projector, eyes should not be able to tell the difference - and what's most important if you hold joystick to the right same amount of seconds you should move the same amount of pixels regardless of FPS/region, no matter how many frames flashed on the screen, if done properly.
---Perm Ban, again---

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
Quote from: cotmm68030
A lost frame, regardless of if it is intentionally skipped or unable to be drawn in time due to CPU speed, is going to have the exact same visual effect.

No. The "smoothness" of animation is not about the number of frames, but about time spacing between the frames.

Code: [Select]
. . . . . . . . . . . . . . . . . . . . . . .   Smooth/High FPS

.   .   .   .   .   .   .   .   .   .   .   .   Smooth/Low FPS


.... . ..... ..... .............. ...... .... Not smooth/High FPS


Do you think you would notice the difference whether you are playing original gberet (30Hz) or bootleg (60Hz)? Do you think then the original is "missing" 30 frames every second, and is worse/different because of it?



Quote
How exactly do you expect a smoothly scrolling action to look visually uninterrupted when part of the sequence is missing?

The sequence is not "absolute" but relative, the important thing is that if you push joystick certain amount of second that your character moves certain amount of pixels. Imagine you play some PCB that runs @ 60FPS and you plug its RGB output to S-video & PAL converter so to display picture on your PAL TV. Yes, frames will be missing, but the animation will remain smooth and gameplay 'authentic', right?

« Last Edit: December 31, 2010, 10:50:05 pm by abaraba »
---Perm Ban, again---

abaraba

  • ---Perm Ban---
  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 138
  • Last login:July 30, 2011, 08:42:58 am
In the simplest of examples you would have a pixel moving one pixel per frame. If I'm only able to draw 50 of those frames in a second and the pixel has moved 60 spaces, some of that motion will be inconsistent because a greater range of motion elapsed between drawn frames than some other interval.

No. In proper implementation, the speed of characters in the game is no longer relative to refresh rate, there is no such speed as "per frame", so instead of one pixel per frame it is more correctly described as one pixel per 1/60 sec, or 60 pixels per second.

So, if the character moves 60 pixels per second, then it moves 60 pixels per second, regardless of how many times you blinked, or refresh the screen. I suppose blind people could even play games with monitor turned off - zero frames per second, but they would still be playing authentic game, no?
« Last Edit: December 31, 2010, 11:26:07 pm by abaraba »
---Perm Ban, again---