iMame
-----

Inroduction:

Speeding up the current Mame version to work well on Windows CE is beyond even 
Gandalf's mightiest spell! Some of you may have tried Gandalf's Mame compiled 
for SH3 (HP Jornada). Well, the work seems to run even slower on the Ipaq, even 
for having 206mhz. Weird. And while I am waiting for my CF Jacket promo-offer,
 1.5MB Mame is taking way too long to download! Therefore, I am experimenting 
 with older Mame versions, so that we will have something to play with until a
 proper Mame port finds it's way to our beloved iPaq. This seems to work well, 
 as many games run full speed with no frame dropping, and many of them at 
at 44100k audio to top it off (this is on 206mhz SA1100 micro).

The performance requirement for iMame is basically playability (which is a 
subjective quality, I suppose). Right now, the drivers that make it into the 
build must be usable without dropping below 30FPS, with the settings of 
Frameskip 1, and 11025 HZ. Furthermore, they must have sound support (samples
or emulated, I don't care). At some point, when I am actually spending 
quality time on emulation code instead of UI code, I expect to up the ante 
on the performance criteria.


Acknowledgements:

Thanks to all the Mame contributors: developers, testers, web-site maintainers, 
 and certainly all of those who use and enjoy MAME are contributors as well. 
Thanks to www.mame.net for hosting MAME and keeping the repository of files and 
 MAME versions on-line! 
Ben Cooley and MameCE...my MAME port was (much more of ) a real mess until I 
 nabbed his WinCE CRT adaptation. Also, I had no clue how to do .WAV sound 
 until I saw it done in MameCE for Casio.
'999' for all the groovy website work!
Anyone who responded to desperate pleas for assistance (notably, Michael Adcock
 and the BSquare guys were very helpful with some troubles I had with remote 
 debugging on Pocket PC). 


Platforms:

You should be able to build for any decent Pocket PC, but you may need to 
tweak the configuration for your platform because I have only maintained the
 settings for PocketPC/ARM. There is no micro specific code. The GAPI is used,
but if you wanted bad enough, you could probably convert the GAPI stuff to 
GameX in order to build on Palm PC (WinCE 2.11).


Setting Up:

Run the Setup program from the desktop PC. Once iMame is running, check the
 online help for specifics. Roms and Samples can go in "Roms" directory and 
 "Samples" directory, or anywhere else that is handy, zipped or unzipped. Just
 make sure you have the right Rom and Sample names for this Mame version.
 If you have trouble with the names of your Rom sets, you may need to rename 
 some of the files to accomodate older naming conventions in this Mame kernel.
 The ".sam" proprietary Mame sample format is used as well, so you may need to 
 do some digging to find the right samples. 


Running:

Launch the File Explorer as appropriate for your device ("Q" menu in iPaq). Use
 the drop down tab to navigate to "\" (My Device). Launch iMame 
 by double-clicking the executable file. Select the game and either 
 double-click it or press "Go".

Hardware buttons have the following functions:
 
  X             X               X               X
  ALT           ESC             1P Start        Coin-up
  

Directional control:
                         Up
                         |
        Left  --    Left CTRL  --  Right
                         |              
                        Down
        (you can bitch about Ipaq's button problem, but I will take it over the
        joypad-less HP product anyday!)  


Issues: 

Sound is a bit funky...older Mame drivers used 8 bit unsigned samples that were
 written directly into the driver code to support Wavetable devices (notably 
 Namco). New drivers store the wavetables in a Prom image.
Dipswitches, other setup not available yet...(TAB key).  
Sound sub-system sounds like crap when running Pokey.
Graphic sub-system trashes on Vector games.
Numerous other things.


Wishlist:

Configurable Keys.
More drivers supported.
8-bit color support, configurable option.
Better UI, button default-focus, etc.
Fix the Ipaq button problem (just kidding).
Numerous other things.


Sources:

Unpack the "MameXXsrc.zip" file into your "imamesrc" directory. 
Unpack the "MameXXceXXXsrc.zip" file into your "imamesrc" directory. 
In your "imamesrc" directory, unpack the zlib sources (zlib113.zip) into a 
 directory "zlib", i.e. "imamesrc/zlib".
The .dsw .dsp files build Mame for the desktop if you have Visual C++ 6.0.
The .vcp and .vcw files build iMame using eMbedded Visual C++ from Microsoft.
Be sure to install the GAPI package with your tools....the eVC++ installer 
 does not do this for you!
There are instructions with the GAPI development files on how to install them.
Please excuse the mess in the sources...it is a work in progress.


Changes:

V006 -  Got sick of unzipping roms and samples, so Zip support was added.
         You can now keep your roms in any directory. Use the options under the 
         "Directories" menu to browse the file system to show iMame where the
         files are. 
        Data alignment problem in Drawgfx went away...difference betw V261 and V27?
        Corrected screwed up 16 bit RGB operation in osd_get_pen.
        Added SuperPac...6809 games seem to do very nicely.
        Added Mooncrst, Ladybug, Galaxian.
	Added Pooyan, Timeplt...these work pretty good for PSG games.        
        I think the problem with PSG games is really more pronounced on ones that
         have a continual music (like frogger...except that frogger has some kind
         of busy loop optimization in it's sndhrdw file which was mysteriously
         removed after V261).
        Overhauled the UI system.
         The new UI system runs the full screen dialog and sports a a cheesy 
         menu-bar, plus there's a nifty new install program that works 
         through ActiveSync (almost acts like a real Pocket PC app!).
        Changed the GAPI use slightly. I originally GAPI'd the main UI window,
         so the GAPI Open and Close calls had been in MameUI.c. Now I GAPI the
         Game Window (the one created in MameWnd.c) but it turns out that it isn't
         so good to Open and Close every time you enter and leave a game...that's
         where the GAPI Suspend and Resume functions come in.
        Fixed up the display to do centering and clipping as appropriate. 
         The title bar on the Game Window sometimes likes to hang around though, 
         even though I try to clear the screen with black before the game starts.
         And how do you make the stupid clock go away? 
         It writes over the screen, even with the GAPI on duty?!??
        Changed to Mame26.1 core. Makes Frogger much faster!! Various changes in 
         Mame 27 for improved quality of PSG sound system, but require more horsepower. 
         Mame 27 had also taken some optimization's out of Frogger sndhrdw
         which is why it has been performing dismally for us on V004 and V005 iMame. 
         There didn't appear to be any easy way around these issues. 
        Grabbed the Mappy support files from Mame27...since I like DigDug2 so much.
         Incredibly, they popped right in to Mame 261.
        Note: some Rom names have changed...check the game-info dialog if
         you have trouble running a driver.
         
	The Installer comes from two origins.	
	1) Scott Ludwig (scottlu@eskimo.com) http://www.eskimo.com/~scottlu
	2) Infozip...the Info-ZIP home page is currently at 
	http://www.cdrom.com/pub/infozip/.

        Greg Roelofs was responsible for the  basic  modifications
        to  UnZip necessary to create UnZipSFX (the self-extracting stub, kind
        of like Winzip-Self-Extractor, except free!).
         

V005 -  More drivers...Mappy, DigDug2, Dkong, Bagman.
        Added "GameInfo" dialog...shows you what Roms/Samples are needed and 
         available. A '+' indicates that the file was found in the Mamebin 
         directory. 
        Changed sample subsystem back to using the proprietary SAM format. Dig 
         out your old .SAM files! 
        Changed the Keys...thanks to 999 for pointing out that the middle 
         joypad position is not subject to the Stop-n-Shoot crap.
        Put the framerate display as an option on the UI.
        A couple of simple changes to common.c, so that you can put your roms 
         in a directory "roms". On the handheld, this must be absolute 
         directory "/mameroms/<gamenames>"...put your samples in 
         "/mamebin/<gamenames>" as well. On the desktop, this can be relative 
         to the current working directory for the iMame executable.

V004 - Changed to Mame27 kernel.
       More Drivers! Many, many will not work yet though, such as: stuff with 
        pokey, stuff with vector, games in the mappy driver, and on and on.

       Do some cleanup in osd_exit...there's probably more, but we really need
        to find out what is leaking or whatever and causing the game to crawl 
        after repeated usage of iMame.
 
       For the desktop, use SetDIBColorTable to put colors in the DIBsection 
        instead of needing to run osd_obtain_pen before running 
        osd_create_display (the former approach required change to mame.c)

       Found the problem with using the osd_bitmap structure....
        osd_create_bitmap was only allocating "height-1" which caused Windows
        to trash us when freeing tmpbitmap from vidhrdw/generic.c (need to 
        allocate "height-0").

       Add WIN32 to preprocessor defines so that Mame.c will compile correctly.
       Copied "run_game()" to win32.c so that I wouldnt' have to change 
        "main()" to "run_game()" in Mame.c

       When clipping, drawgfx() we were sometimes getting the dreaded 
        "Application mame27ce.exe has performed an illegal operation and will
        be shut down." This was caused by writes to "out of clip rect" that 
        are not multiples of 4, such as -2. drawgfx() then tries to read an int
        from the source graphic array at offset of 2, which ARM won't permit.
        In "common.c", the problem line is marked with this comment // GN: TEST
        (unaligned access, get out!) So far, DigDugAt and Mpatrol have shown up
        this problem...If I get to looking more at the graphics engine, then we
        will see what we can do to fix this correctly.
          
       Very odd problem observed with frogger...it would only get 30FPS...
        couldn't figure it out, finally found that it ran at full speed when I
        left out several drivers and other files from the build: strange!
          
       Fixed a bug in the AY8910 and PSG code whereby PSG was mistakenly 
        allocating its own buffers, but then was freeing ours after we already
        free'd them. See files for more description. This bug was present in
        the original Mame27 release. Guess that's why they release Mame28!

       Colors are sometimes funky when running more than one game on one 
       instance of iMame. Also, iMame often acts sluggish after running 
       multiple times without soft-resetting the iPaq. Frogger practically 
       requires a reset after every play.
       

V003 - Correct Mame21 sound interfaces will be used. In previous versions, I 
        had basically hardwired the Namco and Samples sound interfaces to make
        things work. The mixer code came from Mame36 core code, but has now 
        been pushed back into the "OS dependent" area of the iMame code, per 
        Mame21 architecture. 
       Streaming-PSG sound is enabled now...so Frogger has sound!
       Sound Enable check box works now (case IDC_SOUNDEN) from main UI message
        proc, the state of the check is now initialized to "checked" at 
        startup,and retrieved by SendMessage. 
       Sound frequency can be adjusted. For example, running Galaga at 11025 
        instead of 44100 makes Galaga run about 50fps as opposed to 45.
       Some UI problems...can't set a default selction in the game 
        selection-list box without causing the cursor-pad not to work on the 
        list-box. Can't get the pad-center to act as a "game-start" key.
       Trying out btime driver...forgot that you had to turn-to-shoot...crap
        ...oh well, it is showing up the deficiencies in the current color 
        system, I will fix the color and then take out the driver.

V002 - Change osd_play_sample() interface in win_os.c to sample_start()
       Add invaders support.
       Change NUMWAVEHDRS from 4 to 16. This was causing the system to trash
        memory when running a second game within the same Mame instance. Also
        makes a noticeable sound improvement when running on a desktop machine.
        Seems to have remedied the intermittent crashes when running a game.
       Fixed GAMEX stuff. GAMEX cannot be closed and reinitialized in the same
        program instance. Caused MAME to fail when running second game. Must 
        use GXSuspend and GXResume instead.
      Protect the entire "case WM_PAINT" in MAME32_MessageProc. This seems to 
        fix the problem where the initial Mame Disclaimer only partially 
        displayed.                     
      You can set the frameskip now.
      Framerate is displayed by pressing the "center" of the joypad.

V001 - First release, very buggy.
