MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Pages: 1

TheElf
MAME Fan
Reged: 07/10/11
Posts: 4
Send PM


Mame scaling help
#322160 - 02/17/14 04:47 PM Attachment: window.zip 14 KB (3 downloads)


Hi!! im new here, greetings

Im building a custom mame for my personal use

I need to do something, but im stuck


I have a custom resolution of 1280x256

I use ddraw, no hardware accel, Mame build is a custom 106 i made for high performance at 60hz

My problem, is that I don't want a integer stretch on width, just on height. Width need to be full stretch

For example,

256x224 > 1280x224 (with black borders on top and bottom)
320x240 > 1280x240 (with black borders on top and bottom)
400x256 > 1280x256
384x224 > 1280x224(with black borders on top and bottom)


I tried "cleanstretch" vertical, horizontal, full, etc, but not luck

Then I decide to tried to change the code, if possible

Any help?

I think there is something in window.c but not luck


Thanks, and sorry my english


PD: I attach my windows.c in case the code to change is in this file

Edited by TheElf (02/17/14 07:21 PM)



R. Belmont
Cuckoo for IGAvania
Reged: 09/21/03
Posts: 9716
Loc: ECV-197 The Orville
Send PM


Re: Mame scaling help new [Re: TheElf]
#322189 - 02/18/14 05:50 PM


> I have a custom resolution of 1280x256
>
> I use ddraw, no hardware accel, Mame build is a custom 106 i made for high
> performance at 60hz

We can't support a MAME build from 2005, sorry.

One free tip however: because you want it to fill the screen, you don't want -cleanstretch, as that switch forces integer scaling only. So turn that off and also turn off aspect ratio preservation. The results will look horrible (game characters will all appear to weigh about 900 pounds), but it'll fill the screen



TheElf
MAME Fan
Reged: 07/10/11
Posts: 4
Send PM


Re: Mame scaling help new [Re: R. Belmont]
#322190 - 02/18/14 06:24 PM


Hi R. Belmont,thanks for reply

Sadly, new Mame builds, are too slow in some games, but 105 works great. Anyways, same happen in latest mame, then the question is valid, i tested latest build of mame, and same problem


I dont understand very well what do you say, now im not use cleanstretch or aspect ratio, just ddraw without any hardware stretching, and the image DONT fill the screen in width


For example, if I use a resolution of 640x240

if the game is 320x224, it FILL the screen, scale to 640x224
if the game is 320x240 it FILL the screen, scale to 640x240
if the game is 256x240 DONīT fill the screen, scale to 512x240 and leave black bars on left/right

If i use a resolution of 512x240 then...

if the game is 256x240 it FILL the screen, scale to 512x240
if the game is 320x240 DONīT fill the screen, dont scale , and remains 1:1 320x240


For what I see, mame scale only in integer ratio, but not more than 3x, then 256x240 > 512x240 or 768x240, and 320x224>640x224>960x224


Thats why I create a 1280x256 resolution, because this cover 256x and 320x in integer ratio, but sadly mame, dont scale to fill the 1280 resolution, it stop, like I say, in 3x (768x for 256 and 960x for 320)


What I want to do, is scale width TO fill 1280 (4x for 320 5x for 256), and height just leave in 1x. In this case, I dont need to do many custom INI for each game, because 1280x256 covers A LOTof games (most games I like are 256x224/240/256 or 320x224/240/256 )


Hope you can understand what I tried to explain

Thanks

Edited by TheElf (02/18/14 09:29 PM)



ole
MAME Porter
Reged: 02/09/14
Posts: 19
Send PM


Re: Mame scaling help new [Re: TheElf]
#322215 - 02/19/14 01:39 AM


Hi,

I'm not a windows expert but looking at the code you provided the entry code for drawing is the function on line 812: draw_video_contents().
In that function there is a selection of technique that will be used to draw/scale the bitmap on the screen / your window. There's 3 ways how to draw in that function:
- either use Direct 3D - which uses 3D graphics (polygons and textures) to draw/stretch the original mame_bitmap. It calls win_d3d_draw(...) function to do it.
- or use DirectDraw - which s probably the accelerated 2D rendering using the DirectDraw api. It calls win_ddraw_draw(...) function to do it.
- finally there is some compatible (probably less optimized) way how to draw usig some DIB api. It calls dib_draw_window(...) function to do it.

I would suggest to try the last option first. To run that code path make sure you disable direct3D and direct draw rendering (probably in your mame.cfg /.ini file).
Look at the function dib_draw_window(...) on line 1661 and put some trace there (printf("I'm here!\n");) to make sure the function is being called. Then look at the line 1740: StretchDIBits(...) - and the comment above it (Look! in the code line 1739 it states that is the actual stretching code!). Google the function name and you will find the parameters:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd145121%28v=vs.85%29.aspx

int StretchDIBits(
_In_ HDC hdc,
_In_ int XDest,
_In_ int YDest,
_In_ int nDestWidth,
_In_ int nDestHeight,
_In_ int XSrc,
_In_ int YSrc,
_In_ int nSrcWidth,
_In_ int nSrcHeight,
_In_ const VOID *lpBits,
_In_ const BITMAPINFO *lpBitsInfo,
_In_ UINT iUsage,
_In_ DWORD dwRop
);


The interesting parameter is the "nDestWidth" which is probably the destination width. Try to change it - let's say put there your window width (1280) and see wheter it will have any effect. If it won't work or if it crashes make the value smaller and test it again. Experiemnt with the value. You will notice it will probably stretch the image, but the left black bar will still be there. Now try to modify the XDest parameter which is probably the destination X posititon. Try to change it to 0 and see the effect.
Hope it helps.



TheElf
MAME Fan
Reged: 07/10/11
Posts: 4
Send PM


Re: Mame scaling help new [Re: ole]
#322220 - 02/19/14 03:27 AM


Hi Ole

many thanks for reply

I check the code you say, and yes, StretchDIBits control the draw in screen for GDI

I test with different values (nDestWidth, etc), and works

Sadly this only affects the GDI draw only

I need to use ddraw without hardware stretch (win_dd_hw_stretch) for scale to 1280px, GDI is too slow, and is not possible


Sad, I don't have ANY idea of ddraw, to realize where is the stretching code

But mny thanks for your help



krick
Get Fuzzy
Reged: 02/09/04
Posts: 4235
Send PM


Re: Mame scaling help new [Re: TheElf]
#322228 - 02/19/14 04:55 AM


I believe that he latest version of GroovyMAME does what you want...

http://forum.arcadecontrols.com/index.php/topic,135823.0.html

Quote:



- Cleanstretch feature (improved): now the -cleanstretch option admits these values:
* 0 (in mame.ini) = auto, this value allows GroovyMAME to decide whether to use integer scaling.
* 0 (in specific .ini or command line) = force fractional scaling.
* 1 = force integer scaling in both axis.
* 2 = fractional scaling for x-axis, integer scaling for y-axis. This option is manual only (can't be selected automatically). As suggested by Cools.






GroovyMAME support forum on BYOAC



TheElf
MAME Fan
Reged: 07/10/11
Posts: 4
Send PM


Re: Mame scaling help new [Re: krick]
#322241 - 02/19/14 03:39 PM


Hi, thanks, groovy mame works well, but is too slow, because is based on new version of mame

For example, some games like Asura Blade, while in 106 works great, in groovymame are so slow that is impossible to play

From what I know, in the arcade comunity, 106 is one of the most common builds, because a lot of arcade machines, have Pentium 3 or Athlon XP inside, like my machine



Anyways in groovymame I don't need to use cleanstretch, because it auto select the correct resolution, because my video card, can do from 212x192 to 768x576 without problem


Now im taking a look to SwitchResWindows, same guys from groovymame, but without luck


Thats why I want to do some changes to mame code, to just make a weight stretch, and solve most of problems, without the slowdown of groovymame or new mame for example



I downloaded the source from new mame, and in directdraw, do the same like 106

Edited by TheElf (02/19/14 04:12 PM)



ole
MAME Porter
Reged: 02/09/14
Posts: 19
Send PM


Re: Mame scaling help new [Re: TheElf]
#322264 - 02/19/14 10:45 PM



> Sad, I don't have ANY idea of ddraw, to realize where is the stretching code
>

You can use the same techique I described you in my previous post. You say you need to use ddraw to render. Ok, then look at the line 855 where the function to draw via ddraw is being called: win_ddraw_draw(). Search for the function in the same file and you won't find it there. Then search it in the other source code in the same directory and you will find it in the "winddraw.c" on line 991. If you look closely: they further split the code path and use either render_to_blit() or render_to_primary() functions. Then look at the render_to_blit() on line 1091 . They fill-in some data structure with the coordinates and scaling ratios. Change these values and bingo!


Pages: 1

MAMEWorld >> Programming
View all threads Index   Threaded Mode Threaded  

Extra information Permissions
Moderator:  Pi 
0 registered and 67 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 3888