add some programming info

This commit is contained in:
2022-12-15 23:37:41 -08:00
parent b785d72862
commit 2b9e68610a
2 changed files with 103 additions and 1 deletions

102
Programming_Info.md Normal file
View File

@@ -0,0 +1,102 @@
Using the EZCGI
===============
The TMS9918A is mapped into the Apple II's slot I/O memory space at 0xC080+(16*slot#) and 0xC081+(16*slot#). If installed in slot 3, for instance, the two addresses you'll want to use are 0xC0B0 and 0xC0B1. The first of these is the RAM access window (let's call it RAMWND), used to read/write the onboard 16K DRAM in a manner not unlike so-called "slinky RAM" cards: set a start address and start reading/writing; the address autoincrements. The second is the register access window (let's call it REGWND), which is used to set the control registers, set the start address for subsequent RAM access, and read the status register.
This is a summary; for full details, you might want to refer to [the datasheet](https://ia903006.us.archive.org/33/items/Texas_Instruments_TMS9918A/Texas_Instruments_TMS9918A.pdf).
Reading RAM
-----------
Send the start address to REGWND, low byte first, then start reading bytes from RAMWND.
Writing RAM
-----------
OR 0x4000 with the start address, then send it to REGWND, low byte first. Then, start writing bytes to RAMWND.
Reading the Status Register
---------------------------
There's only one, so reading REGWND will retrieve it. It contains the following values:
```
MSB LSB
-----------------------------------------
| | | | | | | | |
| F | 5S | C | 5th Sprite # |
| | | | | | | | |
-----------------------------------------
```
F = interrupt (set at the end of the last line; cleared when read or after reset)
5S = set when five or more sprites are on one horizontal line
C = coincidence (or collision); set when sprites collide
5th Sprite #: if 5S is set, which sprite is considered 5th?
Writing the Control Registers
-----------------------------
The TMS9918A has eight write-only registers, numbered 0 through 7, that will be described in further detail below. To write a value to a register, first send the value to write to REGWND. Then, OR the register number with 0x80 and write the result to REGWND.
```
Reg# MSB LSB
-----------------------------------------
| | | | | | | | |
0 | 0 | 0 | 0 | 0 | 0 | 0 | M3 | EV |
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
1 |Mem |Blnk|Int | M1 | M2 | 0 |Size|Mag |
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
2 | 0 | 0 | 0 | 0 |Name Tbl Base Addr |
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
3 | Color Tbl Base Addr |
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
4 | 0 | 0 | 0 | 0 | 0 |PatGenBaseAddr|
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
5 | 0 | Sprite Attr Tbl Base Addr |
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
6 | 0 | 0 | 0 | 0 | 0 |SprtPatBaseAdr|
| | | | | | | | |
-----------------------------------------
| | | | | | | | |
7 | Text Color | Background Color |
| | | | | | | | |
-----------------------------------------
```
Where zeroes appear in a bit position above, zeroes should be written in that position.
M3/M2/M1: graphics mode selection:
```
M3 M2 M1
0 0 0 Graphics I
1 0 0 Graphics II
0 1 0 Multicolor
0 0 1 Text
```
EV: external video enable
Mem: DRAM size...always set to 1, since we have 16K
Blnk: blank screen if clear
Int: enable interrupts if set
Size: sprite size select (16x16 if set, 8x8 if clear)
Mag: sprite magnification (2x if set, 1x if clear)
Name Tbl Base Addr: base address in RAM of the name table (set on 1K boundaries)
Color Tbl Base Addr: base address in RAM of the color table (set on 64-byte boundaries)
PatGenBaseAddr: base address in RAM of the pattern generator (set on 2K boundaries)
Sprite Attr Tbl Base Addr: base address in RAM of the sprite attribute table (set on 128-byte boundaries)
SprtPatBaseAddr: base address in RAM of the sprite pattern generator (set on 2K boundaries)
Text Color: foreground color for text mode
Background Color: self-explanatory