Classic99 QI3.0a5 - DirectX TI Emulator for Windows
by M.Brent/Tursi
tursi@yiffco.com

----------
This document is woefully out of date.

----------
PURPOSE

To have fun and tear apart my favourite machine - the TI. The existing
emulators, while cool, aren't precisely what I wanted. This one isn't going
to be either (it'll never be as fast as I want), but at least this one I
can mess around with, and it doesn't cost me a dime. ;)

I should say right here, though, it's not my intention to provide accurate
emulations. Jeff Brown's wonderful software hacks will prolly not work. ;)
This emulator will attempt simulation whereever it's reasonable in order to
simplify things.

It's written entirely in C, though that may change if I get brave in the
distant future, using Microsoft Visual C++ 6.0 and Allegro WIP 4.x. On my P2-400, 
it runs maybe a bit faster than a TI, which is STILL pretty dismal when you 
think about it. ;)

---------
REQUIREMENTS

-A set of TI ROMS (the console ROMs and GROMs, the version 2.1 ROMs may not work, use the
original set). The Speech ROM is optional, but required for XB speech.
-Windows 98 or NT (DOS and 95 no longer supported)
-DirectX 8 to use DirectX/FullScreen modes

---------
SETUP

You should look at the TIDATA file to configure it for what you want to run - if you're
missing a ROM it wants you can't boot.

Extract into a directory... then if you're going to use my TIDATA file, make a subdirectory
called MODS and copy your ROMs into there.

In my config file, the console ROMs are in a single file called 994AROM.BIN, and the
GROMs are in a single file called 994AGROM.BIN. You need at least these two to boot up.
To use speech properly, you need the Speech Synthesizer ROM, which I call SPCHROM.BIN
(actually, Ed Swartz did with V9T9... ;) )

Anything you don't have, just comment out by putting a semicolon (;) at the beginning of
the line. There are lots of examples. ;)

---------
THANKS!

A new section to thank those who have helped in various ways:

Roland Meier - For 9938 video subsystem, vastly improved disk support, and general fixes and
improvements throughout :)

Frank Palazolo - for your TMS5220 emulator for MAME, and for trying to help me way back, 
even though we didn't get it going.

John Butler - For writing the TMS9900 disassembler for MAME, which I borrowed for my monitor
screen. ;)

Raphael Nabet - for freely sharing with me his modified version of the TMS5220 emulator, which
showed me exactly what I had been doing wrong.

Stiletto - for once being Ami99's biggest fan and sounding enthusiastic when he posted

Derek Liauw Kie Fa (Kreed) - for the 2xSaI engine - wonderful work!

SNES9x - Integration code for 2xSaI borrowed from this project :) See the 2xSaI folder for
all the credits.

---------
HISTORY

This project started after I saw V9T9 (then TI Emulator!, just ask Stiletto for a full
history ;) ) I didn't have a PC and wanted an emulator for my Amiga. Not
knowing how to reach the author of V9T9, when PC99 hit the scene, and
written entirely in C, I decided to approach them to do a port.

They sent me a very official No, so I started it myself. The Amiga
version had the CPU core complete, a hacked video driver in place,
and booted the TI and ran TI BASIC. Then I got a PC and didn't need it
anymore.

Curiousity, interest, and whatever muse tends to push me has me keep poking
at this from time to time, and that's why when I found most of the source
code I ported it to the PC, and it goes from there.

In mid April 99, the DOS source code was ported to Win32 with the excellent
WinAllegro library. It actually improved the speed.

In June 99 it was ported to the WIP Allegro 4.0. It hurt the speed badly, but
did help several things start working right, like sound.

In early July 99, the project was prepared to be laid to rest.

On July 10th, 99, I implemented to last functions that I will be giving away. (I thought.)

On Oct 6, 99, I returned to the project to implement the speech functions I had been
playing with. 

On ?? Feb 00, Roland Meier's preliminary 9938 code, improved disk code, and general fixes and
speedups were added. :)

And then again on 10 Nov 01, I revisited the code with the intent of producing a QI
(Quality Improved!) version that solved the long-standing problems.

-------------
NOTES

This emulator will probably never be finished. However, it:

-boots and runs all console OS functions and TI BASIC correctly (except cassette I/O)
-nearly all modules work correctly
-all three music channels emulated through any DirectSound compatible sound card
-noise channel fully emulated, though user-defined repeat rates are not 100% accurate (they're close!)
-keyboard CRU scanning implemented
-joystick fully working
-partial disk support
-supports AVI recording through any installed CODEC (video only)

The program reads the ASCII file "TIDATA" to select roms to load. This file MUST
be in the same directory as the program.
The data file is sensitive to case and column of data.

Column 0
--------
; - comment
C - CPU data
X - XB Bank 2
G - GROM data
V - VDP data
# - command (see below)

Column 1    - space
Column 2-5  - hex address (4 digits) (absolute address, bank 2 XB is 6000)
Column 6    - space, or '-' to skip 128 bytes for TIFILES headers
Column 7-10 - length of data (4 digits, hex)
Column 11   - space, or '-' to skip 6 bytes for GRAM Kracker header
Column 12   - filename to load

There are several switches which can be set in the TIDATA file...

#FRAMESKIP 1
Set to number of frames to skip before redraw... this setting is nearly obsolete. 0 is 50/60fps, 1 is 25/30fps, etc...

#MAXIPF 5000
Maximum instructions per frame... roughly 5000 is TI speed, but it varies some.

#AVI C:\AVI99.AVI
AVI save filename (Win32 only)

#speedup_float 1
Set to 0 to turn off speedups of the console floating point routines - these should be safe now.

#disk 1 v dsk1\
Up to 9 disks may be defines, using the format #disk <disk#> <type> <folder>
The type is used for defining the save file type. TIFILES is my recommendation for
easier transfer to and from a real TI.
The types are: 
i - Disk image (not fully supported)
v - v9t9 file type
t - TIFILES file
r - raw file (no header)

#Joystick 1
Set to 1 to enable joysticks, or 0 to disabled

#joy1 1
#joy2 0
Set the type for TI joystick 1 and 2. 
0 - keyboard (arrow keys and tab)
1 - PC joystick 1
2 - PC joystick 2

#Aspect 1
Set to 1 to lock aspect ratio in the window, 0 for free sizing

#stretchmode 0
Sets the default video stretching mode.
0 - No Stretch
1 - Stretch DIB
2 - DirectX (requires DX 7 or newer)
3 - Full Screen (requires DX 7 or newer and the fullscreen mode set)

#fullscreenmode 2
Sets the resolution and bitdepth of the full screen mode. Classic99 renders at 16 bit internally
(for simplicity), so more than 16 bit will not improve the graphics. The handling of 8 bit
graphics modes depends on your video driver. If your card does not support the requested
graphics mode, Classic99 will fall back to No Stretch mode.
1 - 320x240x8
2 - 320x240x16
3 - 320x240x24
4 - 320x200x8
5 - 640x480x8
6 - 640x480x16
7 - 640x480x24
8 - 800x600x16
9 - 800x600x24

#volume 200
Volume attenuation, per step. Measured in 100ths of a db with 100db being the maximum
attenuation. The TMS9919, by default, attenuates 2db per step, and has 14 steps plus
silence. Thus the default is 200. A smaller value will make the softer sounds louder
and produce less difference in volume between two adjacent steps. Ranges from 1 to 700.

Sample TIDATA file
------------------

; Sample TI DATA file for Classic99
C 0000 2000 994AROM.BIN
G 0000 6000 994AGROM.BIN

That's enough to boot. You need to get the ROM and GROM images to run it.
A cartridge can be added as so:

G 6000 2000 WUMPUSG.BIN

XB loads like this:

G 6000 8000 TIEXTG.BIN
C 6000 2000 TIEXTC.BIN
X 6000 2000 TIEXTD.BIN

Bad lines are ignored.

------------------
COMPATIBILITY

You can read through the TIDATA file for brief results of the
ROMs I've tested with. Most of the ROMs I used to list here WORK now!! With the support
for loading PROGRAM type files from DSK1, I've tried some of my old demos, and they
also work. 

----------------
Issues:
-*PROBABLY* Still a CPU bug.. 

-----------------------------
Changes moved to 'WhatsNew.txt'
