NOTE: Silver contacted me asking for help getting this running with the XML that is shipped with a vanilla MAME (I only tested it with AdvanceMAME when I wrote it). Actually he was doing the modifications correctly, but could not get the correct result. Turns out that there was a bug in the script, since it did not handle orientation of vector-games. I changed this, and released this new script, along with an updated example of the output. This version works with both vanilla MAME and AdvanceMAME, although AdvanceMAME has not been updated since 0.106.
In order to get the most bang for the bucks when creating perfect video modes for AdvanceMAME, I decided to make a new list of how many games use each resolution, so I can make custom modes for the most used ones. I did this a while back using sortinfo and a couple of perl-scripts, but since I have lost the scripts, I decided to make a new one, and because AdvanceMAME now outputs the XML-format i decided to make the new script read the XML directly.
The script parses the game-info generated by AdvanceMAME with the --listxml-option. It outputs a list of the different resolutions sorted by the number of games that use each resolution, along with an example of a game that uses a particular resolution (for testing the configured video-mode).
Since the XML-file lists the width and height of the screen-size, the normal mode of operation is to swap the width and height for vertical games (so it relates to x- and y-coordinates of the video mode instead). If you do not want this (e.g. if you cannot rotate your monitor, and run vertical games in a horizontal, you can disable this by calling the script with the -r-option. You can also tell the script to only count horizontal or vertical games (if you only want to run one kind on your cabinet).
The -n=? and -p=? options can be used to stop the listing after a certain number of modes or after a certain percentage of the games.
If you do not use vsync, you probably don't care about the refresh frequency of the modes. In this case you can use the -f-option, which will make the script consider only the resolution (not the refresh frequenzy).
Finally it is possible to tell the script to only count parent-roms (since the clones would use the same resolution).
You can download the script here or view the source. The script uses the XML::Parser perl module, but I believe this module is part of the normal Perl-distribution now, so you probably already have it. It is based on the expat C-library.
Here is an example of what the output from the program looks like. This lists the 100 most used resolutions from the MAME 0.101 romset.
[spiff@spiffship xml] $ ./resolutions.pl -n=100 mame-122.xml 521 256x224@60.00 gtipoker 388 224x256@60.00 rcasino 334 320x224@60.00 2mindril 334 320x240@60.00 finalgdr 243 640x480@60.00 filetto 232 256x240@60.00 jongkyo 230 320x224@59.18 diggerma 223 224x256@60.60 dambustr 197 384x224@60.00 go2000 192 384x224@59.63 hsf2 149 288x224@60.00 genix 144 224x288@60.60 vangrd2 117 336x240@59.92 primraga 89 240x256@60.00 skyarmy 89 288x224@60.60 sws93 86 256x256@60.00 eshb 80 496x384@60.00 eca 80 416x224@60.00 sextriv2 79 240x320@60.00 gstream 68 320x224@60.05 snapper 67 224x288@60.00 ssingles 65 384x240@60.00 spotty 62 224x260@59.54 shuttlei 60 640x240@60.00 twrshaft 59 200x200@60.00 gtcls100 57 320x240@58.00 mirage 57 224x320@60.00 1945kiii 56 336x240@60.00 mjreach1 56 512x240@60.00 bishjan 56 512x224@60.00 lucky8 53 704x513@60.00 magzun 51 512x384@60.00 720gr1 44 512x256@60.00 comebaby 43 399x253@27.40 nbajamt3 42 448x224@60.00 themj 42 240x240@57.00 rockduck 41 240x384@60.00 discoboy 40 384x256@55.00 dbz2 38 352x240@60.00 magic10a 38 304x224@60.00 qgakumon 38 224x384@60.00 eightfrc 35 256x224@60.60 gwarrior 35 320x224@58.97 commandw 35 256x240@58.00 stoneage 34 320x232@58.97 recalh 32 224x240@60.00 noahsark 31 256x192@60.00 pkscram 31 240x224@60.00 sprcrs2a 30 512x480@30.00 pigskin 29 640x480@57.00 cartfury 28 128x128@60.00 awbios 28 800x600@60.00 mfightcc 28 256x240@59.18 gridlee 26 320x224@59.63 smgpj 26 vector@40.00 aztarac 25 248x240@60.00 trvmadns 24 vector@60.00 bwidow 24 256x232@60.00 pottnpkb 23 240x320@54.00 rfjetus 23 vector@38.00 qb3 22 508x384@59.95 racedrg1 22 384x232@60.00 saloon 21 256x240@57.41 bouldshj 21 496x384@58.00 mahmajn2 21 224x256@59.99 tiptop 20 260x224@59.54 astropal 20 256x256@59.99 victorba 20 256x224@57.50 finalttr 19 672x240@59.92 cyberbt1 19 512x288@60.31 hdrivaip 18 208x248@60.00 capitol 18 192x256@60.00 omegafs 17 292x240@60.09 lottofun 17 240x240@60.00 dorachan 17 320x200@60.00 pexs0006 16 240x256@57.00 tagteam 16 671x216@59.99 upscope 16 256x256@76.29 complexx 15 480x640@60.00 kbm3rd 15 399x253@54.81 rmpgwt11 15 224x256@61.24 nibblero 15 671x216@59.97 aplatoon 15 488x384@58.00 bm7thmix 15 384x512@60.00 toobin1 15 192x240@60.00 jjack 14 256x224@60.09 kinstb 14 294x238@60.09 maydayb 14 256x256@55.00 ppmast93 14 240x192@60.00 pbchmp95 14 256x224@59.00 battlcry 13 224x272@60.00 finalizb 13 216x288@60.00 dogosokj 13 240x320@57.55 guwange 13 400x280@50.00 gldncrwn 13 256x256@57.00 starcrus 12 256x240@61.00 wizwarz 12 432x224@59.00 mjikaga 12 240x256@61.00 curvebal 12 240x304@60.00 krzybowl 12 480x512@30.00 trisport 100 modes for 6127/6928 ROMs (88.4%). 0 additional non-runnable.