home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Emulation / AmigaVGB / VGB.doc < prev    next >
Text File  |  2000-07-08  |  19KB  |  429 lines

  1.  
  2.  
  3.                    ******* Virtual GameBoy *******
  4.                 The Portable Nintendo GameBoy Emulator
  5.                              version 0.7
  6.  
  7.                          by Marat Fayzullin
  8.                       
  9.                       email: fms@freeflight.com
  10.                             IRC:  RST38h
  11.                  WWW: http://www.freeflight.com/fms/
  12.  
  13.          (*) GameBoy is a registered trademark of Nintendo.
  14.  
  15.  
  16.  
  17.                        * NEW IN THIS VERSION *
  18.  
  19. o CPU emulation is somewhat sped up
  20. o CPU cycles (not ops) are now used for synchronization
  21. o LCD controller's state changes are done correctly
  22.   (which may slow things down somewhat)
  23. o Sprite priorities implemented
  24.   (which may slow things down somewhat)
  25. o RAM size bug fixed
  26. o Separate autofire for buttons A and B
  27. o Saving soundtrack into a file
  28. o Separate colors for background, window, and sprites
  29. o -nodelay is made default now
  30.  
  31.  
  32.  
  33.                           * INTRODUCTION *
  34.  
  35.   Please, *carefully* read this manual. Do not write me email with
  36. questions answered in here, as such letters are going to be ignored: I
  37. have too many other things to do to answer the same questions over and
  38. over again.
  39.   *Windows users* will find a special section downgraded in content for
  40. better comprehension. 
  41.  
  42.   Virtual GameBoy (VGB) is a portable emulator of the Nintendo GameBoy
  43. handheld videogame console written in C. Although many things do not work
  44. quite well yet, it was able to run about 85% of games checked with it. You
  45. can always get the latest VGB source code, binaries, and support files
  46. from
  47.  
  48.                   http://www.freeflight.com/fms/VGB/
  49.  
  50. GameBoy-related archives with technical and other info are located at
  51.  
  52.                   http://www.freeflight.com/fms/GameBoy/
  53.                   ftp://ftp.komkon.org/pub/GameBoy/
  54.  
  55.   There are versions of VGB for Amiga, Macintosh, and IBM PC (both
  56. MeSsyDOS and Windoze). Following people are maintaining ports of VGB to
  57. these systems: 
  58.  
  59. MSDOS:      Marcel de Kogel [m.dekogel@student.utwente.nl]
  60. Windows:    Marat Fayzullin [fms@wam.umd.edu]
  61. Macintosh:  John Stiles [jstiles@cello.gina.calstate.edu]
  62.  
  63.   If you would like to port VGB to another system, or make changes in
  64. VGB's code *please*, contact me by email or some other means. Note, that
  65. VGB source code is freely distributable, but it is *not* public domain.
  66. You can not use it in commercial purposes unless you contact me to arrange
  67. the conditions of such usage and get my permission. Feel free to look at
  68. existing drivers as well as at other code. More explanations follow.
  69.  
  70.   This manual covers two different VGB distributions:
  71.  
  72. 1. *** Source Code Distribution ***
  73.   This distribution contains C sources of the emulator, and the
  74. screen/keyboard drivers for Unix/X. Virtual GameBoy has been tested on the
  75. following Unix systems: 
  76.  
  77.   SunOS   Solaris   OSF/1   FreeBSD   HP/UX   Linux   AIX
  78.  
  79. 2. *** VGB-Windows Distribution ***
  80.   Due to the flood of requests from the people who use DOS/Windows running
  81. PCs and are unable to compile the emulator on their own, I have ported VGB
  82. under Microsoft Windows. This distribution contains an executable of a
  83. limited version of VGB-Windows which doesn't allow you to reload a new
  84. game from a menu when emulation is already running, and has an annoying
  85. "Virtual GameBoy DEMO" message across its window. The uncrippled version
  86. of VGB-Windows is available for $35US from
  87.  
  88.   Marat Fayzullin
  89.   6304 Hampton Place
  90.   Elkridge, MD 21227
  91.   USA
  92.  
  93.   VGB-Windows is a 32-bit application which runs under Windows 95 and
  94. Windows NT. It is compiled with Borland C++ and needs Microsoft WinG 
  95. library which can be obtained from
  96.  
  97.   ftp://ftp.microsoft.com/Softlib/MSFILES/WING10.EXE
  98.  
  99.  
  100.  
  101.                * SHORT MANUAL FOR THE WINDOWS USERS *
  102.  
  103.   In order to use VGB-Windows, you will first have to install WinG
  104. graphical library which can be obtained from Microsoft (see address
  105. above). Borland's BWCC32.DLL is *no longer needed*, although you do need
  106. to have Windows95 in order to run VGB (3.xx will not do). 
  107.   All options are stored in the VGB.INI file individually for each game. 
  108. Unregistered version does not support .INI file though, so you won't be 
  109. able to store any options in it.
  110.   VGB-Windows runs in a resizable window with the following menus:
  111.  
  112. o File
  113.   o New
  114.     This option allows to run a new game.
  115.   o Cheat
  116.     This option allows to add and delete GameGenie codes. Codes are stored
  117.     in the .INI file separately for each game. Up to 256 codes per game
  118.     can be entered.
  119.   o Setup
  120.     This option pops up a setup dialog allowing to change all 4 GameBoy's
  121.     colors and some emulation parameters:
  122.     o Palette
  123.       Use this group of controls to select a color and change its RGB
  124.       components. The palette controls may not work very well if you
  125.       run Windows in 256-color mode. Use 16-bit or 24-bit graphical
  126.       mode for best effect. There are 12 colors you can adjust:
  127.       4 background colors, 4 window colors, and 4 sprite colors.
  128.     o VBlank Period
  129.       This parameter determines how many CPU cycles will be executed
  130.       between vertical blanking interrupts. Setting it lower may speed
  131.       up the emulation, but setting it too low will hang it.
  132.     o Update Period
  133.       This parameter determines how many vertical blanking interrupts
  134.       will pass between window refreshes. It is usually set to 2, but
  135.       you can increase it to make VGB work faster. The sprite
  136.       movements become jerky at high update periods though, and some
  137.       sprites may simply disappear.
  138.     o Delay Line Interrupts
  139.       If you see "dirty" horizontal lines in some games, you may turn
  140.       this option on or off to remove them. There is no some universal
  141.       state of this option which will work for all games though.  
  142.     o Check CRC
  143.       With this switch off, VGB will not check the control sums of
  144.       the loaded cartridges.
  145.     o Save CPU
  146.       With this switch on, VGB will suspend the execution when its
  147.       window is inactive.
  148.     o Autofire A
  149.       Turn this on to make the [A] button generate series of keypresses
  150.       instead of a single keypress.
  151.     o Autofire B
  152.       Turn this on to make the [B] button generate series of keypresses
  153.       instead of a single keypress.
  154.     o Reset   
  155.       By pressing this button, you restart VGB.
  156.   o Quit
  157.     Quit the emulation. A .SAV file will be saved if the game has a
  158.     battery-backed RAM.
  159. o Size
  160.   o 1:1  These options change the window size to be the same as in real
  161.   o 2:1  GameBoy, or 2/3/4 times bigger. Please, note that you can change
  162.   o 3:1  window size by simple dragging the bottom-right corner of a
  163.   o 4:1  window with the mouse.
  164. o Help
  165.   o Info
  166.     This option will show information about the current cartridge,
  167.     including its name, likely producer name, size, checksum, etc.
  168.   o About
  169.     This option will display a dialog box with copyright information
  170.     and other legal stuff.
  171.  
  172.  
  173.  
  174.                    * FREQUENTLY ASKED QUESTIONS *
  175.  
  176. 1. What is GameBoy?
  177.   GameBoy is a handheld videogame machine produced by Nintendo. It is
  178. built around a custom CPU similar to Z80, but with some changes. GameBoy
  179. is frequently laughed at because of its reflective green-on-yellow LCD
  180. screen which in fact is its virtue. Due to the low power consumption of
  181. its LCD, GameBoy can work for 35 hours off 4 AA batteries. There is a lot
  182. of good games produced for GameBoy, both classics (Tetris, Pacman,
  183. Asteroids, etc.) and specific ones (Final Fantasy series for GB). It
  184. excells in RPGs and classic games where gameplay is more important than
  185. graphics. More information about GameBoy is available from
  186.  
  187.            http://www.freeflight.com/fms/GameBoy/
  188.  
  189. 2. Where do I get GameBoy games?
  190.   You buy the cartridges. GameBoy software is copyrighted and still sold. 
  191. Therefore, its distribution is an act of piracy. Nothing prohibits you 
  192. from backing up a cartridge you own and playing it on the emulator though.
  193. To back up a GameBoy cartridge, you can use either SmartCard copier (about
  194. $100 for a standalone version), or a self-built copier designed by Pascal 
  195. Felber, description of which is available at
  196.  
  197.            http://www.freeflight.com/fms/GameBoy/
  198.  
  199. Please, DO NOT SEND ME MAIL ASKING TO SEND YOU THE CARTRIDGE FILES OR TELL
  200. YOU WHERE TO FIND THEM. I ignore such letters. 
  201.  
  202. 3. Where is the complete list of command line options of VGB?
  203.   Use -help option. It will tell VGB to display all options available in 
  204. your version. Following are the currently available options:
  205.  
  206.   -verbose <level>    - Select debugging messages [5]
  207.                         0 - Silent           1 - Startup messages
  208.                         2 - Illegal writes   4 - Illegal CPU ops
  209.                         8 - Bank switching
  210.   -vperiod <period>   - Set VBlank interrupts period [69905 cycles]
  211.   -uperiod <period>   - Number of interrupts per screen update [2]
  212.   -help               - Print this help page
  213.   -cheat <GG code>    - Activate a GameGenie cheat
  214.   -delay/-nodelay     - Delay/don't delay line interrupts [-nodelay]
  215.   -crc/-nocrc         - Check/don't check cartridge CRC [-crc]
  216.   -autoa/-noautoa     - Autofire/No autofire for button A [-noautoa]
  217.   -autob/-noautob     - Autofire/No autofire for button B [-noautob]
  218.   -logsnd <filename>  - Write soundtrack to a file [off]
  219.   -trap <address>     - Trap execution when PC reaches address [FFFFh]
  220.   -shm/-noshm         - Use/don't use MIT SHM extensions for X [-shm]
  221.   -saver/-nosaver     - Save/don't save CPU when inactive [-saver]
  222.   -colorN <name>      - Change color #N [white,#989898,#585858,black]
  223.   -bcolorN <name>     - Change background color #N [same]
  224.   -scolorN <name>     - Change sprite color #N [same]
  225.   -wcolorN <name>     - Change window color #N [same]
  226.  
  227. 4. What are the keys used in VGB?
  228.  
  229.   [SPACE] - A button (also: A,S,D,F,G,H,J,K,L)
  230.   [LALT]  - B button (also: Z,X,C,V,B,N,M)
  231.   [TAB]   - SELECT button
  232.   [ENTER] - START button
  233.   [ESC]   - Quit emulation (also: [F12])
  234.  
  235.   [F1]    - Go into built-in debugger (Not implemented in Windows)
  236.   [F2]    - Show LCD controller registers (Not implemented in Windows)
  237.  
  238. 5. Why is the emulator so slow on my PC?
  239.   Because your PC is too slow to run it. The emulator is written entirely
  240. in C language and therefore is quite slow. Although it works on 486/33 and
  241. even 386/33 PCs, it runs best on a Pentium/90 or a DEC Alpha/150. You can
  242. try to speed it up by increasing -uperiod value controlling the number of
  243. interrupts between screen updates to 3-6, and by decreasing -iperiod value
  244. controlling the number of CPU cycles between interrupts.
  245.  
  246. 6. Can I compile the emulator with my Borland/Turbo C compiler?
  247.   You can, given that your compiler creates executables using flat 32bit
  248. memory model. Two PC compilers which do that are WATCOM (using DOS4GW DOS
  249. extender) and GCC (using DJPP extender). The only 32bit Borland/Turbo C  
  250. compiler that I'm aware is for Windows though.
  251.  
  252. 7. Is it legal to spread GameBoy cartridge snapshots?
  253.   NO. Be aware of the fact that by using commercial software you haven't 
  254. bought, you are commencing an act of piracy. Not that I care, anyway...
  255.  
  256. 8. Why some games do not run with VGB?
  257.   As it was said before, VGB emulation is not completely accurate yet.
  258. Also, some games will probably never run on VGB.
  259.  
  260. o If emulator does not even recognize the ROM image, its CRC may be
  261.   wrong. Try turning CRC checking off.
  262.   although you really need to find an uncorrupted ROM image.
  263. o Check you ROM image size: it must be a multiple of 8192. If it is
  264.   512 bytes longer, then you may have a SmartCard copier header
  265.   attached to it. In this case, remove first 512 bytes of the file.
  266. o If a game refuses to work, try increasing -vperiod value, or moving
  267.   a "VBlank Period" knob in the VGB-Windows setup window.
  268. o If you see a group of "dirty" lines on VGB screen, or a game behaves
  269.   strangely, try -delay/-nodelay options, or check/clear the "Delay
  270.   Line Interrupts" checkbox in the VGB-Windows setup window. 
  271. o If some sprites blink or do not appear at all, try changing -uperiod
  272.   value from 1 to 10 (1 will give you the best picture, but the slowest
  273.   emulation), or moving an "Update Period" knob in the VGB-Windows
  274.   setup window.
  275.  
  276. 9. Palette controls in VGB-Windows do not work.
  277.   This probably means that you are running Windows in the 256-color mode.
  278. In this mode, not all of 256 possible colors are available, and you will
  279. be able to choose only from the available colors. Switch Windows into
  280. 16-bit or 24-bit graphics and palette will start working. 
  281.  
  282. 10. I start VGB-Windows, but it tells me that WING.DLL is not found.
  283.   This means that you haven't installed WinG library necessary to run VGB.
  284. Check the information in the beginning of this manual on how to obtain
  285. WinG. 
  286.  
  287. 11. I start VGB-Windows, but it tells me that BWCC32.DLL is not found.
  288.   VGB-Windows comes with a file called BWCC32.DLL. This file should be
  289. either kept in the directory from which VGB runs, or put into
  290. \WINDOWS\SYSTEM directory. If you haven't got this file, you are
  291. probably using an illegal distribution of VGB-Windows. 
  292.  
  293. 12. When compiling emulator under Unix, I get "undefined name" errors.
  294.   This means that your linker can not find the libraries necessary for the
  295. emulator (namely, libX11.a and libXext.a) or some additional libraries
  296. (like libsocket.a and libnsl.a) are required. Find these libraries in your
  297. system and modify the Makefile so that the final invocation of the C
  298. compiler has "-L<path_to_libs>" options. If you have no libXext.a library,
  299. try #undefining MITSHM option.
  300.  
  301. 13. When starting emulator under Unix, I get X_ShmAttach error.
  302.   You are probably trying to run the emulator on a remote Xterminal while
  303. it attempts to use shared memory for interfacing with X. Use -noshm option
  304. to tell it not to use shared memory.
  305.  
  306. 14. The emulation starts under Unix, but then I get X_PutImage error.
  307.   Unix/X version of fMSX currently needs 256-color X. Neither 2-color
  308. nor TrueColor Xterminals will work with the drivers included into
  309. "official" VGB distribution.
  310.  
  311. 15. I start the Unix version of the emulator but the window stays black.
  312.   Some other X application took over all available colors so that the
  313. emulation could not allocate any for itself. Check if you run XV,
  314. Netscape, or something similar.
  315.  
  316. 16. How can I get sound in VGB?
  317.   The Unix/X version has no sound yet, although there are some works going
  318. on in this direction. In the "official" DOS version, use -s option. Your
  319. soundcard should be SoundBlasterPro-compatible though, and the sound is
  320. very rudimentary.
  321.  
  322. 17. How can I get joystick to work with VGB?
  323.   Joystick is not supported yet.
  324.  
  325.  
  326.  
  327.  
  328.                          * COMPILATION TIPS *
  329.  
  330.   If you are compiling the emulator under Unix, use Makefile. Notice that
  331. #define UNIX is present in this case.
  332.   The emulation is written in fairly portable C code and may therefore be
  333. compiled with any decent ANSI C compiler. It relies on a flat 32bit memory
  334. model though, so Borland compilers will choke on it. Standard CC or GCC
  335. should do the job under Unix, although beware of GCC code generation
  336. bugs. If you are working under MeSsyDOS, use WATCOM C which is known to
  337. work. Under (God prohibits) Windows, use Borland C++ which has 32bit
  338. compilation model. On Amiga, use SAS/C. On Macintoshes, use Metrowerks C.
  339.   If you are using an Intel-based computer or any other machine which has
  340. least-significant-byte-first data layout (for example, DEC Alpha), insert
  341.  
  342.                 #define LSB_FIRST
  343.  
  344. in the beginning of Z80.h file. The emulator will not work otherwise.  
  345.   If you put
  346.  
  347.                 #define DEBUG
  348.  
  349. in the beginning of Z80.h, the emulator will print debugging information 
  350. about CPU registers after executing each command. You can turn debugging 
  351. on and off by setting Trace variable to 1 and 0 accordingly. Also, by
  352. setting Trap variable to some address you will make it start tracing when
  353. PC reaches this address (-trap option).
  354.   When you port the program to a new machine, you have to write a set of
  355. drivers for keyboard, sprites, and all the screen modes you want to
  356. emulate.  The emulator comes with a set of drivers for XWindows system.
  357. The common code for these drivers is located in Common.h and can be used
  358. for other systems too. Screen drivers use simple XSIZE*YSIZE array of
  359. bytes to generate image, so in most cases you will only need to adjust   
  360. these drivers to your own needs. Note that the X11 drivers use so-called 
  361. MIT Shared Memory Extension for fast transfers from buffer to a window. If
  362. you do not have MIT SHM extension in your system, remove
  363.  
  364.                 #define MITSHM
  365.  
  366. You can also turn MITSHM off (for example, if you use remote X terminal)
  367. by setting UseSHM variable to 0 before starting the emulation (-noshm
  368. option). 
  369.  
  370.  
  371.  
  372.                           * CODE STRUCTURE *
  373.  
  374.   Several other variables control the behaviour of the emulator. All of
  375. them should be set before starting the emulation in order to take effect:
  376.  
  377. Verbose = 0..31
  378.   Defines amount of debugging information printed by emulator. Default
  379.   value is 1. Each bit of this variable enables printing of some kind
  380.   of debugging info (VDP,CPU,memory,etc.).
  381. VPeriod = 10000..199999
  382.   Defines how many CPU cycles should be executed between two interrupts.
  383.   Normal interrupt rate is 60Hz for NTSC systems or 50Hz for PAL systems.
  384.   Default value of VPeriod is 69905.
  385. CPURunning = 0/1
  386.   Set this variable to 0 to stop CPU and exit the emulation.
  387. AutoA = 0/1
  388.   Emulate autofire on the first fire button. Default value is 0.
  389. AutoB = 0/1
  390.   Emulate autofire on the second fire button. Default value is 0.
  391. SndName = "filename"
  392.   When SndName is not NULL, VGB will open a file with this name, and
  393.   save the soundtrack into it. The default value is NULL.
  394. Trace = 0/1
  395.   Print debugging information about CPU state. Default value is 1.
  396.   #define DEBUG should be present in order to use this option. Tracing
  397.   can be turned on and off during execution, for example, in keyboard
  398.   driver.
  399. Trap = 0x0000..0xFFFF
  400.   Automatically start tracing when PC reaches given address. #define
  401.   DEBUG should be present in order to use this option.
  402. UPeriod = 1..10 
  403.   Defines how many interrupts should pass between two consequent screen
  404.   updates. Default value of UPeriod is 2.
  405. CartName = "cartridge.file"
  406.   Name of a .GB file to load. Default value is "CART.GB". This variable
  407.   is ignored if no file exists.
  408. UseSHM = 0/1
  409.   Use MIT SHM extension in X11 screen drivers. Default value is 1.
  410.   #define MITSHM should be present in order to use this option.
  411.   
  412.   In order to run the emulation:
  413.   
  414.   1. Set all necessary variables.
  415.   2. Initialize screen and keyboard drivers. In the case of X11 drivers,
  416.      it is done by calling InitMachine() implemented in Unix.c and
  417.      returning 1 on success or 0 otherwise,
  418.   3. Call StartGB().
  419.   4. Call TrashGB().
  420.   5. Shut down screen and keyboard. In X11 case, by calling TrashMachine().
  421.   6. Exit the program.
  422.   
  423.   Take a look at VGB.c to see an example of a sequence explained above.
  424.  
  425.  
  426.  
  427. ---------------
  428. Marat Fayzullin
  429.