                         ******* interNES *******
                     The Portable NES/Famicom Emulator 
                         version 0.2 (05/10/1996)
                based on the original code by Alex Krasivsky

                            by Marat Fayzullin


                         email: fms@freeflight.com
                                IRC: RST38h
                    WWW: http://www.freeflight.com/fms/




                               * DICLAIMERS *

* Nintendo Entertainment System and Famicom are registered trademarks of 
  Nintendo.
* The author is in no way affiliated with Nintendo.
* The author is in no way affiliated with any pirate group out there.
* The author can not provide you with NES/Famicom games.



                         * NEW IN THIS VERSION *

* Some types of multi-paged cartridges work now.
* A nasty CPU bug in LDX is fixed.
* Battery-backed RAM support impemented.
 


                            * INTRODUCTION *

  iNES is a portable emulator of the Nintendo Entertainment System (aka
Famicom in Korea and Japan), written in C. The original code was written
by Alex Krasivsky from Moscow. I added missing CPU commands, wrote screen
drivers, and did some thorough hacking to make the emulator run about 70%
of games. Given enough support, I hope to make it even more compatible
with real NES in the future. You can always get the latest iNES binaries
and support files from

                 http://www.freeflight.com/fms/iNES/

  Because of its portability, iNES can be compiled on a wide variety of
platforms: Unix, Amiga, Macintosh, MSDOS, Windows, etc. Nevertheless, due
to the nasty experience dealing with pirate wannabes of the Net after
Virtual GameBoy emulator was released, I decided not to release the iNES
source code, and not to create MSDOS and Windows versions of iNES at this
moment. The only released version will be distributed in binary form for
various flavors of Unix.

  I may also create a commercial version of iNES for Windows in the near
future, but it will not have a demo version like Virtual GameBoy did. 
Sorry folks, send your thanks and fan mail to the person who cracked VGB
demo and removed my name from "About" dialog box. If you wanna play with
iNES, install Unix. If you want iNES-Windows and are willing to register
($35, the usual fee), let me know and I will count you. 

  If you have any information on NES/Famicom, or the ROM-images which can
be used for testing, and are willing to help, feel free to send mail to
fms@freeflight.com. Any *intelligent* help is greatly appreciated :).



                 * FOR OUR LEARNING-DISABLED READERS *

#ifdef FLAME
  It is unnecessary to say, but for some people out there, let us
repeat it: 

1. I DO NOT HAVE ANY NINTENDO GAMES.
2. I DO NOT KNOW WHERE TO GET THEM.
3. I DO NOT KNOW WHERE TO GET A COPIER.
4. IT IS PIRACY TO DISTRIBUTE ROM-IMAGES OF NES/FAMICOM GAMES, AND
   PRETTY BAD ONE, AS THEY ARE STILL SOLD.

  Please, do not send me mail dealing with above-mentioned questions.
#endif



                           * WHAT IS INCLUDED *

  Following files are included into the distribution:

  ines     - iNES executable file [ines -help for options]
  dasm     - Little 6502 disassembler
  iNES.doc - This documentation
  CART.NES - Sample cartridge which contains a testing program for NES
  CART.ASM - The source code of a testing program



                         * BUTTONS/OPTIONS/ETC. *

  iNES is controlled by following buttons:

  [SPACE] - A button (also: A,S,D,F,G,H,J,K,L)
  [LALT]  - B button (also: Z,X,C,V,B,N,M)
  [TAB]   - SELECT button
  [ENTER] - START button
  [ESC]   - Quit emulation

  [SHIFT] and [CAPSLOCK] switch between joypads.

  When compiled with #define DEBUG:
  [F1]    - Turn tracing on/off
  [F2]    - Shift ChrTab down by $0400
  [F3]    - Shift ChrTab up by $0400
  [F4]    - Shift ChrGen down by $1000
  [F5]    - Shift ChrGen up by $1000
  [F6]    - Show LCD controller registers
  [F7]    - Show sprite attributes

  iNES can be started with following options:

  Usage: ines [-option1 [-option2...]] <filename>
  <filename> = name of file to load as cartridge [CART.NES]
  [-option]   =
  -verbose <level>    - Select debugging messages [5]
                        0 - Silent           1 - Startup messages
                        2 - Illegal writes   4 - Illegal CPU ops
                        8 - Bank switching
  -vperiod <period>   - Set VBlank interrupts period [10000ops]
  -uperiod <period>   - Number of interrupts per screen update [2]
  -help               - Print this help page
  -shm/-noshm         - Use/don't use MIT SHM extensions for X [-shm]
  -saver/-nosaver     - Save/don't save CPU when inactive [-saver]

  When compiled with #define DEBUG:
  -trap <address>     - Trap execution when PC reaches address [FFFFh]



                         * CARTRIDGE FILE FORMAT *

  The iNES distribution includes a single cartridge image with a program
allowing to test the emulator. There is also a source code of this program
included. Following is the format of ROM-image files used by iNES (.NES
extension): 

byte    contents
-------------------------------------------------------------------------
0-3       String "NES^Z"
4         Number of 16kB ROM banks
5         Number of 8kB VROM banks
6         bit 0     1 for vertical mirroring, 0 for horizontal mirroring
          bit 1     1 for battery-backed RAM at $6000-$7FFF
          bit 2-3   Reserved
          bit 4-7   Type of ROM bank selector
                     0 - None
                     1 - Megaman2,Bomberman2,Destiny,etc.
                     2 - Castlevania,LifeForce,etc.
                    15 - 100-in-1 cartridge (experimental)
7-15      Reserved
16-...    ROM banks, in ascending order
...-EOF   VROM banks, in ascending order
-------------------------------------------------------------------------

  Note that this format will most likely change in the next version of 
iNES, therefore do not take it for something permanent. The general 
structure will stay the same though.

  The Vertical/Horizontal Mirroring flag requires an additional
explanation. In the real NES/Famicom cartridges, either A10 or A11 line of
the address bus can be connected. Depending on it, video memory may either
contain two screens at addresses $2000/$2400 mirrored at $2800/$2C00
(Vertical Mirroring), or two screens at $2000/$2800 mirrored at
$2400/$2C00 (Horizontal Mirroring). The games which only use one screen do
not care about the mirroring. The games using two screens require an
appropriate mirroring though. 



---------------
Marat Fayzullin
