wyatt8740 / gb68k

Ben Ingram's GB68K - a Game Boy emulator for the TI-89/92+/Voyage 200 calculators. Contains historical source code for a few different versions, since the last release (0.5.6) does not work with some GB/GBC hybrid games.
5 stars 0 forks source link

GB68K v0.5.6 by Ben Ingram ingramb AT gmail DOT com (questions welcome, but please at least read this file first) MastaZog on TIGCC boards Zog on most other boards (if I even post) Project Page at: http://www.ti-news.net/project_view.php?project=gb68k

IF YOU DOWNLOADED THIS FROM ANYWHERE EXCEPT TI-NEWS, IT MAY NOT BE THE LATEST VERSION! CHECK THE ABOVE LINK!

DISCLAIMER

Emulation is a touchy legal subject. Primarily, this is due to the use of copyrighted game images, or ROMs. Public domain ROMs do exist, and these are certainly legal to use. This software doesn't include any copyrighted game software. Users of this software are responsible for the decisions they make while using it.

INTRODUCTION

This is a Nintendo Gameboy emulator for the various TI-89 and TI-92+ graphing calculators. It is programmed in a combination of C and ASM using TIGCC. C is used for some initialization and user interface code. The emulation engine itself is pure ASM. Some games work and some don't. Most have small graphics errors, and most run slowly. A few games run fast enough for me to consider them playable.

Currently emulated:

Not emulated:

I'd like to add the second sprite priority and support for raster effects. Link play seems unlikely, but it may be possible. Sound would be neat, but I don't think it will happen. Gameboy color features will never be emulated. Besides a color screen, the GBC has 4 times the ram, twice the VRAM, and (most importantly), a CPU that can run twice as fast. Some gameboy color games will still run on a regular gameboy; these should work on the emulator as well.

USING THE EMULATOR

Required:

The required files are gb68k.89z (launcher), gb68kppg.89y (packed program), and gb68klib.89y (dll). Other launchers can be used. All the files should work regardless of the calculator model.

The first thing to do is convert some Gameboy games for use on the calculator. To do this, you'll need to acquire the ROM images of Gameboy games. The internet has more information on how to do this. I won't answer questions related to the acquisition of commercial ROMs.

Once you have a ROM, it needs to be converted with the included utility. It runs from the command line and has two parameters, plus an optional third parameter. The first is the name of the ROM file; the second is the on calc name you would like. This second name must be 6 characters or less. The utility will generate a number of files with the name you specify, appended with numbers. For example, if you run 'CartConvert mygame.gb mygame', you'll get files mygame00, mygame01, mygameXX. For this to work, mygame.gb will need to be in the same directory as CartConvert. The generated files will also be in this directory. The exact number will depend on the size of the original ROM. Send all these files to your calculator. They should be archived, but they don't have to be.

The optional third parameter is the flag "-pack". This will convert the rom such that it takes MORE space, but fits in fewer files. Normally, roms are packed in files of 48kb each. With the pack option, the base file size is 56kb, and then every other file is padded with 6000 very important extra bytes. Pack mode is useful, because archive memory is divided into blocks of 64kb. There are a limited number of blocks, and files CAN'T be broken up between them. So even if you have archive space left, if each block is filled with a 48kb file, you won't be able to archive anything else over 16kb. You should use pack mode if you're filling most of your archive up with gb roms, or other large files. You should use default mode if you want to archive lots of other, smaller files in addition to gb roms.

Now that you have your rom, send the emulator to your calculator, make sure you have lots of free memory, and run it. You'll get a list of all the ROMs on the calculator. All folders will be scanned. Select the game you want. If all goes well, you should be playing. If not, the emulator will quit with an error message, or maybe crash =(

Press [ESC] during emulation to open the menu. Here you can change options, save or load the state, or quit the emulator. With save states, you can save your progress at any point, even in games that don't normally allow saving. The save state files are compressed, but still quite large. The compression also takes a while (in certain extreme cases, a VERY long while...if your calc seems to freeze, give it at least 5 minutes). The options are as follows:

When you exit the emulator, settings will be stored in two files: mygamesv, and gb68ksv. The fps and archive settings are saved in gb68k. The other settings are game specific, and are stored for each game. If a game has save ram, this will also be compressed and stored in mygamesv.

Press [ON] during emulation to save the state in slot 9, and then exit with no prompt. This feature is included for certain, er...situations where you may need to quickly stop playing games with little warning.

The TI-89 has a resolution of 160 x 100. The bigger calculators have 240 x 128. The Gameboy has 160 x 144. This means that some of the vertical screen will be chopped off. The plus and minus keys can be used to shift the view up and down. The multiply and divide keys will set the view to the top or bottom of the screen.

Controls

All calcs [+/-] - shift view up and down [divide] - shift view to the top [multiply] - shift view to the bottom [ESC] - menu [ON] - quick save and exit

TI-89 Arrow keys [2nd] - A [Shift] - B [Dmd] - select [Alpha] - start

TI-92+ Arrow keys [F1] - A [F5] - B [Enter] - Start (the one below the keypad) [Apps] - Select

V200 Arrow keys [Hand] - A [Q] - B [Enter] - Start (the one below the keypad) [Apps] - Select

Lots of things can go wrong unfortunately. Most likely, a game won't work properly, or just won't work at all. If this happens, first check the exact same ROM using a PC based emulator (VGBA, No$GB, or whatever). If your ROM works on the PC, let me know what ROM you're trying to use, and what's wrong (if it's not obvious). Have a look at the un-emulated features first though. I don't need reports of sprites showing up at the wrong priority, for example. That's not supposed to work right yet.

Less likely, but still possible, the entire calculator could crash. Sorry, but nobody's perfect. If this happens, I'd also like a report. If the emulator crashes at a specific point in a game, a list of steps to get to that point would be nice.

TECHNICAL DETAILS

The emulation is interpretive. It uses the instruction decoding technique described by the author of TEZXAS (http://tezxas.ticalc.org). In the future, I'd like to try some sort of recompiling engine, but I'm not sure how it will work out.

The palette algorithms are based on those in TIGB (http://natsumi.boogersoft.com/projects/tigb). My emulator seems to by quite a bit faster than TIGB. TIGB has more accurate video emulation, and timer emulation. It only emulates MBC1, and doesn't have any support for the window layer (which makes most RPGs unplayable).

Save files are compressed first using rle encoding written by me, and then with the LZFO1 compressor written by Francesco Orabona. My rle code doesn't really help compression ratios, but it often makes the LZFO process MUCH faster by dramatically reducing the input size.

The gameboy_opcodes.S file is automatically generated by the OpcodeGenerator.cpp program. Since each unique opcode has its own function handler, this saves me from having to type lots of duplicate code, and reduces the chance for errors. For example, lots of instructions operate on the memory location addressed by the hl register. The code for finding this memory is the same, regardless of what the final operation will be. This design was inspired by the Generator Sega Genesis emulator. Its author, James Ponder, wrote a very nice report about his emulator, which has provided me with several ideas. I plan to implement some more of his ideas eventually, which will hopefully speed things up.

LICENCE

This software is open source. You can use the source as you see fit, with a few exceptions. First, give credit where it's due. Don't claim my work as your own. Second, I don't want modified versions of this software being distributed. If you want add something, or improve this emulator, send the change to me so I can incorporate it into the official version. I will of course give you credit. If you want to build you own emulator and use pieces of my code, that's fine, as long as most of the code is your own. I realize this is somewhat subjective. Hopefully it won't be a problem.

THANKS

HISTORY

Project started August 2004

v0.1 4/9/2005 initial release

v0.1a 4/14/2005

v0.2.0 4/25/2005

v0.3.0 5/7/2005

v0.3.1 5/17/2005

v0.4.0 5/30/2005

v0.5.0 8/16/2005

v0.5.1 10/5/2005

v0.5.5 11/8/2005

v0.5.6 12/7/2005