MasterGear
version 1.3

by Marat Fayzullin

Contents


Disclaimers


New in This Version


History

New in MG 1.2


New in MG 1.1


Introduction

MasterGear (MG) is a portable emulator of several 8bit videogame consoles produced by SEGA: Mark3, MasterSystem, handheld GameGear, and their predecessors SG1000 and SC3000. MG allows to run most of the software written for these consoles on a personal computer, as well as debug this software. As MG is written in a portable C programming language, it runs on many different platforms and operating systems. You can always get latest MG binaries and support files from

http://www.komkon.org/fms/MG/

Currently, MG is able to run about 98% of the SMS/GG/SG1000 carts I have. With the help from friends I hope to make it as close to original machines as possible and emulate some exotic peripherals such as light gun, sports pad, SG1000 keyboard, GameGear on-cart sound chips, and GameGenie. Following is a list of features supported by MG at this moment:


MG Ports

Because of its portability, MG can be compiled on a wide variety of platforms: Unix, Amiga, Macintosh, MSDOS, Windows, etc. Unfortunately, it looks that for each person geniunely interested in hardware hacking and revival of the old videogame experience there is a dozen of adolescent gremlins hungry for a quick fun of playing pirated SEGA games on their PCs. Because of that, I decided against making MG source code publicly available and producing free versions of MG for MSDOS or Windows. I do not want to provide free entertainment for the vermin. I do feel it necessary to apologize for inconvinience created to all the intended users of MG. The complete up-to-date list of MG ports can be obtained from the MG distribution site. Following are the major ports of MG available at the moment:

Unix

MG-Unix is available freely in binary form for various flavors of Unix from the MG distribution site. I am always trying to compile it on as many different Unices as I have handy at the moment.

MacOS

The Macintosh version of MG is being developed by John Stiles. It is available from him as a shareware and can be found at the MG distribution site.

Windows CE

The WindowsCE version of MG is being developed by Jimmy Software. It is available as a shareware and can be found at the MG distribution site.

Windows 95/98/NT

The Windows version of MG is available from me, Marat Fayzullin, for $35US. This fee ensures that you will get you the latest full version of MG-Windows with sound and joystick support, saved preferences, and free updates via email as long as MG-Windows is being updated. For more information about it, take a look at

http://www.komkon.org/fms/MG/MGWindows.html

I do not feel very good about maintaining the Windows version because people pirate it a lot and most Windows users appear to be mentally underdeveloped (judging from their email, anyway). If you do want to see Windows version being developed, please, register it by one of the following methods:

ORDER BY MAIL
Send $35US in cash, money order, or a US bank check to:
     Marat Fayzullin
     6304 Hampton Place
     Elkridge, MD 21075
     USA
Don't forget to include your email address and mention that you want MG-Windows, as I'm selling several other products as well. The software will be emailed to you as soon as I receive the money.

ORDER BY PHONE
Call one of the following numbers in US:
     1-800-242-4775 (extension 15673)
     1-713-524-6394 (extension 15673)
and refer to product #15673 (MG-Windows). This service is provided by Public Software Library (PSL). You can pay them with a credit card. Don't forget to give them your email address. The software will be emailed to you as soon as I receive the notification from PSL.

ORDER ON THE WEB
Tell your WWW browser to go to

http://www.pslweb.com/cgi-win/psl_ord.exe/ITEM15673

and use the online form to register MG-Windows. You can pay with a credit card. They take MasterCard, Visa, Amex, or Discover. The software will be emailed to you as soon as I receive the notification from PSL.

MSDOS

You may find older versions of MG (<=1.1) for MSDOS on the Net, but there are no newer versions currently available, neither freeware nor shareware. Please, do not mail me asking for it: I won't answer to you. I won't allow anyone to do an MSDOS port of MG either. See above for the reasons why.

Linux

Currently, MG-Linux (ELF, GLIBC, X11) is compiled from the same source as all other Unix versions. You can get it for free from the MG distribution site. Please, do not ask me for an SVGALib version though: I do not consider SVGALib as a viable standard and will not develop for it.

Registered Users

If you registered MG-Windows, please do not give your copy to anybody. And I do mean anybody. There was a couple of cases when registered users gave MG away to their friends, relatives, or just "KeWl" guys on the Net, and then I found it pirated, put onto WWW pages, and even posted to USENET newsgroups. If I find your personalized copy of MG being spread around, your registration gets automatically cancelled which means no support and no more updates.

I understand that the previous paragraph may sound threating to some people, but this kind of piracy really hurts my profits and feelings. I've put a lot of effort into MG, and can only continue working on it if people do not try to cheat on me.

It may also be a good idea to buy a real cartridge for each cartridge image you use with the emulator. SEGA software is copyrighted, but as long as you own the real cartridge, you are protected by the law allowing customers to backup bought software.


What is Included

Following files are included into the distribution:
  mg          - MG executable file (Unix. mg -help for options)
  mg-debug    - MG with debugger (Unix. mg-debug -help for options)
  mg.exe      - MG executable file (Windows)
  MG.html     - This documentation

What is not Included

Absolutely no ROM images of SEGA games are included. These games are still copyrighted by the companies who produced them, and therefore, I cannot distribute any of them. I'm also unable to tell you where to find these games, so do not send me email asking for them. You will have to look for them on your own.

Buttons

When using SC3000 keyboard, press [CONTROL]+[KEY] to access the special function of a [KEY], if it also performs a keyboard function.
  [SPACE]    - FIRE-A button (also: [LALT],A,S,D,F,G,H,J,K,L)
  [LCONTROL] - FIRE-B button (also: Z,X,C,V,B,N,M)
  [ENTER]    - START button (only in GameGear mode)
  [TAB]      - RESET button (only in MasterSystem mode)
  [BACKSPC]  - PAUSE button (only in MasterSystem mode)
  [ESC]      - Quit emulation (also: [F12])
  [F11]      - Reset hardware
  [F2]       - Turn soundtrack log on/off
  [F3]       - Toggle FIRE-A autofire on/off
  [F4]       - Toggle FIRE-B autofire on/off
  [F6]       - Save emulation state (*.STA)

  [SHIFT] and [CAPSLOCK] switch between MasterSystem joypads

  When compiled with #define SOUND:
  [1]-[4]    - Toggle sound channels on/off
  [0]        - Toggle all sound on/off
  [-]        - Decrease sound volume
  [+]        - Increase sound volume

  When compiled with #define DEBUG:
  [F1]       - Go into built-in debugger

  When compiled with #define MSDOS:
  [F8]       - Toggle joystick 1 on/off
  [F9]       - Toggle joystick 2 on/off
  [F10]      - Make a screen snapshot (SNAPxxxx.GIF)

Command Line Options

These options only work in MG-Unix and other MG ports with the command line interface. MG-Windows takes no command line options, just a file name.
  -verbose <level>    - Select debugging messages [5]
                         0 - Silent             1 - Startup messages
                         2 - Illegal accesses   4 - Illegal Z80 ops
                         8 - Bank switching    16 - Sound
                        32 - VDP registers     64 - VRAM accesses
  -hperiod <period>   - Number of CPU cycles per HBlank [215]
  -vperiod <period>   - Number of CPU cycles per VBlank [65000]
  -uperiod <period>   - Number of VBlanks per screen update [3]
  -help               - Print this help page
  -sc3000/-sms/-gg    - Run in SC3000/MasterSystem/GameGear mode [-sms]
                        (overrides .SC/.SMS/.GG file extensions)
  -engl/-jap          - Run in English/Japanese mode [-engl]
                        (overrides country code in GG carts)
  -autoa/-noautoa     - Autofire/No autofire for button A [-noautoa]
  -autob/-noautob     - Autofire/No autofire for button B [-noautob]
  -delay/-nodelay     - Delay/Don't delay VRAM reads [-nodelay]
  -logsnd <filename>  - Write soundtrack to a MIDI file [LOG.MID]

  When compiled with #define DEBUG:
  -trap <address>     - Trap execution when PC reaches address [FFFFh]
                        When a keyword 'now' is used in place of the
                        <address>, execution will trap immediately.

  When compiled with #define SOUND:
  -sound [<quality>]  - Sound emulation quality [0]
                        0 - Off                1 - Adlib (MSDOS)
                        Values >8191 are treated as wave synthesis
                        frequencies. Default frequency is 22kHz.
  -nosound            - Same as '-sound 0'

  When compiled with #define UNIX:
  -shm/-noshm         - Use/don't use MIT SHM extensions for X [-shm]
  -saver/-nosaver     - Save/don't save CPU when inactive [-saver]
  -sync <frequency>   - Sync screen updates to <frequency> [0]
  -nosync             - Same as '-sync 0'
  -scale <factor>     - Scale window by <factor> [1]

  When compiled with #define MSDOS:
  -back <filename>    - Use <filename> as background picture [MG.GIF]
  -vsync/-novsync     - Sync/Don't sync screen updates [-novsync]

Frequently Asked Questions

  1. I WANNA PLAY GAMES!!!! WHERE DO I GET GAMES???????
    I do not know. I can't give you any due to both legal and moral reasons. Please, do not mail me asking for games. I will delete your mail right away, and you won't get an answer.

  2. How do I copy games from cartridges to a computer?
    You can use a special device called cartridge copier. Pascal Felber has made such a copier. Its schematics and software are available at

    http://lsewww.epfl.ch/~felber/IO-56/

    You can also buy this copier from Pascal, either in parts or as a pre-built kit.

  3. What is MasterSystem/GameGear? How its hardware works?
    Over years, SEGA has produced several different 8bit videogame consoles. They all had similar hardware built around a generic Z80 CPU, TMS9918 video chip, and SN76489 sound chip.

    The oldest members of the family, SG1000 and SC3000, had an original TMS9918 VDP and apparently weren't sold outside of Japan. Some of these machines came with a keyboard and BASIC in ROM.

    The MasterSystem, widely sold in the US, had an additional screen mode not available in the standard TMS9918 VDP. Most MasterSystem games relied on this screen mode. The compatibility with TMS9918 screen modes was retained though, so MasterSystem could play SG1000/SC3000 games.

    The GameGear only had the MasterSystem native screen mode truncated to fit smaller screen, but not TMS9918 screen modes. It also had an extended color palette of 2x16-out-of-512 colors, as compared to MasterSystem's 2x16-out-of-64 colors.

    SEGA machines have no BIOS ROM as in MSX or ColecoVision. Instead, they have a small bootup ROM which initializes the hardware and then switches itself off, passing control to the cartridge.

  4. How system selection and localization work?
    MG works with "raw" ROM images, and therefore the default file extension is .ROM. It may be a wise idea to use .SMS and .GG extensions to distinguish between MasterSystem and GameGear ROMs though. Since version 0.6, MG checks the file extension and forces emulation into MasterSystem or GameGear mode if extension is .SMS or .GG.

    For SG1000 and SC3000 ROMs, it is sufficient to use the .SMS extension, as the MasterSystem is backward compatible with both machines.

    In the MasterSystem mode, MG defaults to the US/Europe localization (-engl). In the GameGear mode, MG checks the country code. If the cartridge is either for Japan or US/Europe only, the localization switch is forced into an appropriate state. It may be overridden by giving a localization option (-engl/-jap).

  5. There is no version of MG for my Unix!
    I am trying to compile Unix binaries for as many flavors of Unix as possible, but as I do not have access to many machines, do not expect immediate support for every Unix flavor out there. Don't mail me asking for the source either: MG source code is no longer publicly distrbutable, as much as I regret to say this :(.

  6. Where do I get MG for MSDOS?
    This is explained in the beginning of this document.

  7. Game comes up with wrong colors and trash on the screen.
    This may happen when you are trying to run a MasterSystem or SG1000 game in the GameGear mode or vice versa. By default, MG will try to recognize game type by .SMS/.GG extensions. If your files have different extensions, you can use -sms/-gg options in MG-Unix or "GameGear Mode" option in the setup window of MG-Windows.

  8. My favorite game doesn't work on MG. What do I do?
    There may be several reasons why a game has problems running on MG or does not run at all:

  9. Why is MG so slow on my machine?
    Because your machine is too slow to run MG. My experience shows that you need at least a Pentium/90 machine with fast video to run MG at a reasonable speed. Following are the ways to speeds thing up:

  10. MG is too fast on my machine! How do I slow it down?
    Frankly, when I started writing MG, I never expected that it will be too fast on any machine :). But times change...

  11. What is that EMUTools package and where do I get it?
    EMUTools is a set of utilities which may be useful for both emulator authors and users. They allow to list and verify different ROM images, convert music files, disassemble and compare ROMs. EMUTools can be obtained from MG WWW site.

  12. Do I need to unpack GZIPped ROM images to run them on MG?
    No, unless your copy of MG has been compiled without #define ZLIB. MG-Windows and most versions of MG-Unix are compiled with this option. It allows MG to recognize and automatically unpack GZIPped and singular PKZIPped files. To find out whether your MG-Unix supports this feature, run it with -help option and see if there is anything said about GZIP support.

  13. When starting MG-Unix, ld says that libz library isn't found.
    Some MG-Unix binaries are compiled with #define ZLIB option to make them automatically recognize and unpack GZIPped files. This option requires ZLib library which can be obtained from

    http://www.cdrom.com/pub/infozip/zlib/zlib.html

  14. I entered registration code into MG-MacOS and now it says I pirated it!
    MG-MacOS will lock up if you try to "register" it without paying for registration and using the correct registration code. It will then refuse to work on your computer. If you think that you have been mistreated for a simple typing error, contact John Stiles for help.

  15. When starting MG-Unix, ld says that some library isn't found.
    This may happen if the versions of your shared libraries are older than the ones for which MG has been compiled. A decent way to deal with this is to upgrade your Unix. A quick and dirty way is to make a symbolic link from the existing library to a name required by MG.

  16. When starting MG-Unix, I get X_ShmAttach error.
    You are probably trying to run MG-Unix on a remote Xterminal while it attempts to use shared memory for interfacing with X. Use -noshm option to tell it not to use shared memory.

  17. When starting MG-Unix, I get X_PutImage error.
    MG-Unix version currently needs 8bit, 16bit, or 32bit X. Neither 2-color nor 16-color Xterminals will work. 24bit Xterminals may work, but don't count on it.

  18. When starting MG-Unix, the window stays black.
    Some other X application took over all available colors so that the emulation could not allocate any for itself. Check if you run XV, Netscape, or something similar.

  19. The sound is distorted in the MG-Windows. How do I fix it?
    The wave-synthetized sound in MG-Windows may become distorted on slow or highly loaded machines (no graphics acceleration, for example). There are several ways you can improve sound:

  20. Does MG-Windows support joystick? My joystick doesn't work!
    MG-Windows supports joystick. If your joystick does not work, go into Windows Control Panel to see if it is configured and calibrated properly. Also, some new joysticks working in esoteric standards (like GRiP) are known to have problems.

  21. MG-Windows starts, but then quits immediately!
    Check the pathname to wherever your MG is located. It should not contain spaces. For example, "C:\Program Files\MG" is a bad place for MG, while "C:\MG" will work. This bug is caused by an old version of C compiler I am using. I hope to get rid of it when I switch to a new compiler.

  22. Colors are all screwed up in MG-Windows!
    When running Windows in 256-color mode, it will try to approximate colors to existing ones, but it won't always get an exact match. I'm working on fixing this. For now, switch Windows into 16bit or better graphics to get perfect colors.

  23. Black window in MG-Windows!
    If you are running Windows in 256-color mode, then this is most likely the cause of a problem. Try switching Windows into 16bit or better screen mode.

  24. Command line options don't work in MG-Windows!
    They shouldn't. The demo version of MG-Windows supports no command line interface at all. The full version will only accept the ROM file name at the command line, but no options. All configuration is done via Setup Panel and MG.INI file.

  25. Volume control works strangely in MG-Windows!
    It is a result of the volume control being shared between MG and other Windows applications. You can usually restore normal volume by leaving MG window and then activating it again.

  26. Will MG-Windows work on Windows 3.xx?
    It may, but I can't guarantee it. MG-Windows has never been tested on Windows 3.xx. Maybe it is time to upgrade.

  27. I'm a registered MG-Windows user and some games no longer run!
    It is quite possible that your MG.INI file no longer works with the new version of MG. It is my suggestion to delete MG.INI every time you get a new version of MG. You can still use some ASCII editor (Notepad or DOS Editor) to migrate some of your old settings into new MG.INI.

  28. What is SC3000 mode and how do I use it?
    In SC3000 mode, MG will emulate SC3000 keyboard and also provide 32kB of RAM. This allows to run BASIC Level 3, Music Editor, and other SC3000 programs. Following is list of non-obvious keyboard equivalents for SC3000 keys:
    SC3000       MasterGear
    -------------------------
    [SHIFT]      [SHIFT]
    [CONTROL]    [CONTROL]
    [ALT]        [ALT]
    [FUNCTION]   [TAB]
    [GRAPHLOCK]  [CAPSLOCK]
    [DEL/INS]    [BS]
    [CLS/HOME]   [HOME]
    [YEN]        [`]
    [PI]         [END]
    [^]          [=]
    [@]          [\]
    [:]          [']
    
    Take notice that all special MG functions accessed with the keys used by SC3000 keyboard (such as [0]..[4]) are still accessible if you press these keys with [CONTROL].

  29. How do I save and load the machine state during the game?
    The machine state can be saved by pressing [F6] button. The resulting data file will have the same name as your cartridge file, but its extension is going to be .STA. This state file will be loaded automatically next time you start MG. The same state file is not guaranteed to work for versions of MG running on a different hardware. State saving is not perfect yet, so for some games state may not be correctly saved.

Thanks

I would like to thank Richard Aplin, Chris Shay, Neil Harding, who helped with invaluable technical information about MasterSystem and GameGear. Thanks also go to (alphabetically):
© Copyright by Marat Fayzullin (fms@cs.umd.edu)