                               madNES
                            NES emulator
                         by Roberto Rosario
                      email: skeletor@iname.com
       homepage: http://members.tripod.com/~r_rosario/madnes.htm

What's new
==========

-- V.95

   Changes to the emulator:

      * Sprites are now scanline based in the scanline & tile engines.
        Duck Tales, Shadow Gate, Life Force now display sprites correctly.

      * Implemented the PPU flags for the screen & sprite left column
        clipping (RC Pro AM).

      * Tweaked the timing a little.
        More games run (Duck tales 2) and the emulator no longer hangs up
        on some games (Ninja Gaiden intro).

      * Fixed the scrolling bugs in the graphic engines.
        A lot more games now display correctly (Blaster Master, Chip n'
        Dale, 8 Eyes, Castlevania 2, Bionic Commando)

      * A smaller executable.
        Thanks go to Matthew Conte for the tip.

      * Added 2 new resolutions, 256x256 with scanlines & 256x256 w/o
        scanlines these are resolutions #5 & #6.  These resolutions may not
        be compatible with your monitor/video card.

      * Removed the vsync feature as it was no longer required.

      * Added primitive sound emulation.
        Each channel can be toggled on & off with keys 1, 2, 3, 4, 5.
        Channels 3 & 5 are off by default.

      * Added preliminary IRQ interrupt emulation for mapper 4 games.
        Gremlins 2, Batman, Burai Fighter, Ninja Gaiden 2.

      * Optimized the 640x480 mode.

      * Fixed a bug in the mapper 1 code.
        Thanks go to Joseph Grant for reporting this one.
        Zelda 2, Airwolf and The 3 Stooges now display correctly.

      * Fixed some memory allocation problems.
        The GUI & emulator should be more stable.
        
      * Optimized the graphics engines a bit.

      * Some improvements to the mapper 9 (Punch out).
        Thanks go to Jim Geffre of PCNES for most of the help.

      * Tweaked the mapper 1 name table mirroring code.
        Zelda 1 works a bit better.

      * Better error handling.

   Changes to the GUI:

      * Fixed the menu bar color bug.

      * Added a short help text.

-- V.91

   Changes to the emulator:

      * Added a frames-per-second counter.

      * Small graphic engine speedup.

      * Fixed a color bug in the tile & scanline graphic engines.

      * Fixed a small CPU engine bug.

      * Improved the CPU clock timing.
        Split screen & raster effects work better.
        Thanks go to Eric for the new documentation.

      * CPU engine speedup.
        Simple games (no scrolling, no mappers) now run at 60 FPS with
        no frameskip on a P166.

      * Fixed small bug in control pad emulation.

      * Rewrote some of the memory allocation routines.
        Windows 95 no longer complains about creating a DOS mode shortcut for
        madNES.

      * Added 3 more resolutions (VGA, SVGA, VESA) to the existing MODEX.
        Use the -r #, the -res # command line switch or the resolution
        entry from the INI file.

      * Added joystick emulation w/ remapable buttons (only one joystick
        though).

      * Added a new command line switch -h # or -hblank #, that allows
        to change the default of 115 CPU cycles per scanline.
        (ie: Mach Rider works better at 120 cycles)
        
      * Changed the function keys layout.

      * Added some sound code although no output is still produced.
        Mostly sound drivers, setup code & playback routines.

      * Added the ability to save the current state of a game in a file.
        Use the F2 to save & the F3 to load, the directory where the file
        is to be created can be specified via the statedir entry in the INI
        file.

      * Fixed a bug and improved the mapper 9 code.
        Punch Out looks better.

      * Some changes to the INI file key mapping commands.

      * Fixed the INI file entry bug, trailing spaces before pressing ENTER
        are no longer required.

      * Improved the bank switching code.
        More games run (mapper 3: Buggy Popper, mapper 4: Gremlins 2),
        some look better and others run faster.

      * Most memory leaks have been plugged, the GUI is more stable now.
        There's still a graphic glitch.

      * Fixed a bug in the mapper 15 code.
        Graphics in the 100-in-1 Contra function 16 cart are now correct.

      * Added JPEG support for the screenshots.
        Use the snaptype INI file entry to select screenshot format.

      * Fixed a bug in the game reset code.

      * Improved the sprite w/ scanline collition code.
        Split screen emulation is near perfect.

      * Wrote some experimental code that prevents snow when changing the
        palette without using the -vsync switch.

      * Preliminary lightgun support (light collisions not yet implemented).
        Use Ctrl+G to switch from NES pad#2 to Lightgun and vice-versa.
        Use the 2nd player keys (or joystick) to control the crosshair and
        any of the two buttons (A, B) to fire.

      * Fixed a bug in the scanline engine.
        Some games were displaying random vertical lines on some parts of the
        screen.

      * Fixed a bug in the mapper 1 code.
        Dragon Warrior 2 now displays correctly.

   Changes to the GUI:

      * The load cart dialog now remembers the last directory accessed.

      * Fixed the problem with the screen being clipped horizontally.

      * Cannot switch from GUI to EMU if no game has been loaded.

      * Cannot take snapshots if no game has been loaded.

      * Clicking any mouse button from the emulator will bring up the GUI.

-- V. 88
      * First public release  

Introducion
===========
  madNES is an emulator for the Nintendo Entertainment System written
entirely in C language.  It's compiled using DJGPP,  Allegro is currently
used to fuel the graphics engine and SEAL is currently used for sound.
Although madNES is DOS based, the source code is very modular and rather
easy to port.  However no ports are planned for this release.  This emulator
is freeware, you can distribute it free of charge, but please don't
distribute it with any ROMs.

Requirements
====================
 Minimun: 
 486 IBM PC compatible
 MSDOS 6.22
 (75 Mhz for reasonable minimun gameplay)

 Recommended:
 Pentium 150 MHz and up

 My goal: 
 Low end pentiums

Usage
=====
From the command line type:

madnes [options] <NES game>
options:
  -s # or -screentype #   Selects graphics engine.
      0 - full screen - no scrolling
      1 - tile based - fast but jerky
      2 - line based - smooth but slow

  -f # or -frameskip #    # of frames to skip.

  -i or -gameinfo         Display games stats when loaded.

  -gg or -gamegenie       Enter Game Genie(tm) code (may enter more than one).

  -r # or -res #          Selects from predefined resolutions.
   1: VGA   320x200
   2: MODEX 256x240
   3: SVGA  640x480
   4: VESA  320x240
   5: VGA   256x256 w/ scanlines
   6: VGA   256x256

  -h # or -hblank         Specifies the number of cpu cycles per scanline.

  -vol # or -volume       Sets the master volume.

  -ns or -nosound         Disables sound emulation.

  -?                      Show usage syntax.

Or type madNES without specifing a game to go to the front end directly
(if the GUI is enabled).

Once madNES is running:

NES pad 1 
---------
Up       - Up arrow keys
Down     - Down arrow keys
Left     - Left arrow keys
Right    - Right arrow keys
B        - Alt
A        - Ctrl
Start    - Enter
Select   - Space

NES pad 2
---------
Up       - Home
Down     - End
Left     - Delete
Right    - Page Down
B        - Y
A        - U
Start    - I
Select   - O

other
---------------
ESC - Toggles between the GUI and the emulator (if the GUI is enabled).
Ctrl + X - Exits madNES.
Ctrl + S - Switches the graphic engine.
Ctrl + R - Resets the emulated game.
Ctrl + G - Toggles between Control pad #2 and Lightgun.
F2 - Save current game state.
F3 - Load game state.
F4 - Decrease volume.
F5 - Increase volume.
F6 - Decrease hblank.
F7 - Increase hblank.
F8 - Decreases the frame skip.
F9 - Increases the frame skip.
F11 - Show the frames per second counter.
F12 - Saves a screenshot in the PCX or JPEG format (madNESxx.pcx or
      madNESxx.jpg).
        
What it does or emulates
========================
        - MCS6502 (aparently bug free).
        - Almost all PPU registers.
        - Sprites (8x8 & 8x16).
        - Partial trainer support.
        - Battery-backed RAM.
        - All 4 Name table mirroring modes (h, v, 4vram and 1->3vram layout).
        - Sprite flipping.
        - Sprite clipping.
        - Sprite priorities.
        - Scrolling.
        - 3 different rendering engines (full screen, tile based, scanline
          based).
        - iNES mappers 0, 2, 3, and partial 1, 4, 7, 9, 10, 11, 15, 16.
        - Very accurate NES timing.
        - Near perfect palette (using a modified Loopy's palette).
        - Screen snapshots (PCX & JPEG supported).
        - Control pad 1 & 2 emulated thru keyboard or joystick.
        - User configurable key & joystick button mappings.
        - A small GUI.
        - Split screen support.
        - Raster effects support.
        - Game Genie support (6 & 8 character codes).
	- Configuration file (madNES.INI).
        - Command line switches with long equivalents.
        - Runs at decent speed on a P150.
        - Game state saving.
        - Preliminary lightgun support.
        - Primitive sound emulation.

To do (What's missing)
=====
        - Auto fire.
        - Improve the GUI.
        - GIF support (not likely, due to copyright stuff).
        - More speed.
        - More mappers and/or improve the existing ones.
        - Improve sound emulation.
        - New graphic engine (merge the current engines into 1).
        - Improve lightgun emulation (if possible, there's no info available).
        - Improve the IRQ support to mapper 4.

INI file entries
================
resolution = #          Emulator resolution
                        1 = VGA 320x200
                        2 = 256x240 tweaked modeX
                        3 = SVGA 640x480
                        4 = VESA 320x240
                        5 = 256x256 tweaked VGA w/scanlines
                        6 = 256x256 VGA

volume = #              Sets the master volume
                        0 - 255

soundboard = #          Sound card driver
                        0 = nosound, 1 = Sound Blaster

frameskip = #           1/# frames to skip

screentype = #          Selects the graphic engine
                        0 = Full screen - no scrolling
                        1 = Tile based - rought scrolling
                        2 = Line based - Smooth scrolling

gui = ON/OFF            Enables/Disables GUI

snaptype = #            Snapshot graphic format
                        1 = PCX, 2 = JPEG

snapdir = <dir>         Snapshots save directory

savedir = <dir>         Battery-backed RAM file load/save directory

romdir = <dir>          ROMS default directory

statedir = <dir>        State file save/load directory

NES-port0 = #           Select data source for the NES port
NES-port1 = #           1-KEYBOARD, 2-JOYSTICK
                        
Joystick-Buttons =      Joystick button mappings for joystick emulation
                        order: A B SELECT START

NES-port0-keymap =      Scan codes for the NES pad 1 key mapping
                        order: A B SELECT START UP DOWN LEFT RIGHT

NES-port1-keymap =      Scan codes for the NES pad 2 key mapping
                        order: A B SELECT START UP DOWN LEFT RIGHT

Important bugs
==============
- Some mapper 4 games may exit with a Unknown opcode error, this is not
  a CPU problem (because all the opcodes the NES uses have been implemented)
  but rather a bank switching problem still present in the mapper 4 code.
                                                                          
Information I need
==================
  I'm looking for information or documents regarding: 4-player devices.

Thanks go to:
=============
Eric "warpath" Gonzalez (eric.gonzalez@usa.net) for suggestions, testing,
moral support, for comming up with the name of this emulator and for
annoying me every day of my life so I wouldn't die of boredom :).

Y0SHI and everybody who contributed in one way or another with nestech.doc
and for helping emulator programmers in so many ways; looking forward to see
parodius.com online once again.

Loopy for releasing his NES emulator palette so others may use it.

Marat Fayzullin for his document on how to write emulators.

Marat Fayzullin and the MAME team for their great emulators and for proving
that decent emulators CAN be written using only C language.

Shawn Hargreaves and all the people responsible for ALLEGRO.

Deloire Software and all the people that made DJGPP a reality.

Benzene of Digital Emutations for the Game Genie Doc.

The following web sites mantainers for their support:
* EMU News Service.
* Archaic Ruins.
* Zophar's Domain.

Eric Vannier for his IJG JPEG library port.

All the people who wrote me and encouraged me to continue madNES.

The beta testers:
* Eric Gonzalez
* Joseph Grant
* others that wish to remain anonymous.

Egerter Software for the their Synthetic Audio Library (SEAL).

All the emulator authors for keeping alive the games we all love, throu the
magic of emulation.

Disclaimers 
===========
The author holds no warranties of any kind on this product. It is at your own
risk that you use madNES. The author may not be held liable or responsible
for any consequences as a result of the use or the inability to use this
program, its contents or its documentation in any way, shape, or form. There
are no warranties either expressed or implied.

madNES may not be sold or distributed with ROMs.

You may distribute madNES as long as all the files are included and remain
unmodified.

NES is a registered trademark of Nintendo Co., Ltd.

Nintendo Entertainment System is a registered trademark of Nintendo Co., Ltd.

Game Genie is a registered trademark of Lewis Galoob Toys, Inc.

I am not affiliated with Nintendo in any way, nor do I support the piracy
of NES ROMs.
