MAMEWorld >> EmuChat
View all threads Index   Flat Mode Flat  

Bryan Ischo
MAME Fan
Reged: 03/28/10
Posts: 358
Send PM
Another annoying MAME code question
02/11/11 10:45 AM


Hello MAME developers. Believe it or not I am still working on my MAME project, which is a front end that integrates MAME into it and can do some pretty unique stuff as a result. I had some downtime on the project for a while but recently have picked up steam again.

I don't understand a certain behavior of MAME. And that is, I don't understand how it computes the bounding region that it specifies in render_primitives that it returns from the call to render_target_get_primitives().

It appears to me that MAME attempts to map the game into the bounds of the render target for the game such that it fills the render target as much as possible. But it doesn't seem to me that it gets the math right. Let's take Donkey Kong (dkong) as an example.

Donkey Kong's resolution is 224x256. If I specify an arbitrary render_target bounds of 10000x10000 (and a pixel_aspect of 1.0), then I would expect that the height of the bounds would be 10000 (because Donkey Kong is taller than it is wide, it fits into a square at its full height), and the width of the bounds to be 8750 (which is 10000 * (224 / 256)). Now centering this horizontally should yield a render_target bounds of (625, 0), (9375, 10000). This is the same 8750x10000 rectangle, pushed to the right by half of (10000 - 8750). This would result in Donkey Kong being rendered exactly as high as the screen, and with the proper aspect ratio, and centered horizontally on the screen.

However, the bounds that MAME actually delivers are:

(1250, 0), (8750, 10000)

It's like MAME computes the proper width of 8750, but then instead of moving the 8750-wide region to the right the proper amount, it just sets the left X coordinate to (screen_width - right X coordinate). In other words, rather than getting the difference between the game width and screen width, and dividing that by two and then shifting the game over to center it, it just chops off the difference of the game width and screen width from the left side of the game.

The result is the game being rendered to a region that is too narrow and doesn't have the correct aspect ratio. The aspect ratio of the bounding rectangle that MAME gives is 0.75, but the aspect ratio of Donkey Kong is actually 0.875.

What gives?

Another way to demonstrate this same problem is to call render_target_set_bounds with the actual resolution of the game. So for the Donkey Kong case, if we tell MAME that the render_target is 224x256 (same exact size as Donkey Kong), I would expect it to deliver render_bounds of (0, 0), (224, 256); after all, if my screen is exactly the same size as Donkey Kong, then Donkey Kong should perfectly fill my screen.

But what MAME actually delivers is render_bounds of (44, 0), (212, 224). This is a region that is 168x224, when MAME could have fit the whole 224x256 in there. And once again, 168x224 is the same funky 0.75 aspect ratio as before.

Am I misunderstanding what the render_bounds are supposed to represent? Is there some reason that MAME reports bounds that don't make optimal use of the render_target, and aren't even the correct aspect ratio?

As it is, I just ignore the render_bounds that MAME reports and calculate my own bounds from the known size of the game and the size of my screen, and it works perfectly. But I still would like to understand the values I am getting out of MAME.

By the way, I am still using a relatively ancient version of MAME (0.138); I will try with the newest version to make sure that this isn't a bug that was already fixed.







Entire thread
Subject Posted by Posted on
* Another annoying MAME code question Bryan Ischo 02/11/11 10:45 AM
. * Re: Another annoying MAME code question Bryan Ischo  02/11/11 08:31 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/11/11 08:41 PM
. * Re: Another annoying MAME code question R. Belmont  02/12/11 01:29 AM
. * Re: Another annoying MAME code question AaronGiles  02/11/11 05:21 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/11/11 08:13 PM
. * Re: Another annoying MAME code question AaronGiles  02/11/11 08:58 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/11/11 09:08 PM
. * Re: Another annoying MAME code question R. Belmont  02/11/11 10:50 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/12/11 01:05 AM
. * Re: Another annoying MAME code question R. Belmont  02/11/11 05:15 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/11/11 07:55 PM
. * Re: Another annoying MAME code question R. Belmont  02/11/11 10:51 PM
. * Re: Another annoying MAME code question Bryan Ischo  02/12/11 01:38 AM
. * Re: Another annoying MAME code question AaronGiles  02/12/11 02:59 AM
. * Re: Another annoying MAME code question R. Belmont  02/13/11 03:37 AM

Extra information Permissions
Moderator:  Robbbert, Tafoid 
0 registered and 475 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 2695