[comp.sys.atari.8bit] 2600 hacking

cabbie@chinet.UUCP (Richard Andrews) (12/14/86)

Just for your info........


                      Atari 2600 Programming Notes
                      ----------------------------


	The Atari 2600 (old version) is a useful and flexible SBC for
general purpose applications.  There are 2 old versions of the 2600
game and they differ only in board layout and physical dimensions.
The early version (the one I worked with) measures approx. 4" X 6"
and has a 6507, 6532, and a TIA chip onboard.  The TIA programming
notes are not available at this time.  The board also has a place on
it for a 24 pin chip.  I installed a socket in this area for my eprom.
I also installed a 7404 inverter for the chip select to the eprom.  The 
memory map is as follows:

	6532 --> $0080 - $0F80
       Eprom --> $1000 - $1FFF (top of memory)
	 TIA --> $0000 - $007F

	The 6532 is a multi-purpose chip and has 128 bytes of RAM, 2 
parallel ports, and an interval timer.  The RAM is mapped to the area
of $0080 - $00FF.  The parallel IO is mapped to $0280 - $0283.  Using 
the same names as Atari did for the 8 bit computers the ports are mapped
as follows:

		PORTA --> $0280
		PACTL --> $0281
		PORTB --> $0282
		PBCTL --> $0283

	Each pin is addressable and can be configured as either input or
output.  To set up a pin for output write a "1" into the DDIR (Pxctl) and
to set up for input write a "0" into the register.  The ports differ 
slightly in output drive capabilities.  PORTA is a TTL drive only and 
PORTB is a push-pull type of output and can drive darlington transistors
directly.  The current available is 3.0 ma at the pin. 

	The 6532 also has an interval timer on board.  The timer can count 
from 1 to 255 divider cycles.  Yup there is a programmable divider on board
the unit.  The divider can be preset to divide by 1, 8, 64, or 1024.  The
input to the divider is the system clock.   The reader is recommended to read 
any data sheet on the 6532 for more details.  

You should install a reset switch onboard the unit so that a reset is
available should the CPU not 'come up' properly.

	The 6507 can address up to 8 k only, therefore program size is
a limitation.  Program code cannot be greater that 4 k in size.  This
is usually sufficiant for most general purpose applications.  The CPU
clock is derived from the TIA.  The TIA divides the crystal clock 
(3.58 Mhz) by three to obtain 1.19 Mhz for use by the CPU.  Not exactly
real high speed, but sufficient for most uses.  I have used the 3.58 Mhz
clock and divided it by two with a J-K flip flop and have had no problems.
The advantage of this is that you don't need the TIA chip and the CPU then
runs a little faster (1.79 Mhz instead of 1.19 Mhz).


                           Programming Caveats
                           -------------------

1) There is no stack therefore JSR's are not allowed. (the system will crash)

2) You have to provide for your own reset vector.  This would be located
   at the very top of your EPROM code.  

3) You can use a 2716 or a 2732 for your EPROM.  I usually use 2716's.

4) Don't forget to CLC, CLV, or CLD before you start your actual program.
   These may be unnecessary for some applications but I leave nothing to
   chance.  Remember: The generation of random numbers is too important
   to be left to chance!

5) There is no IRQ available on the CPU therefore IRQ handling is non- 
   existent.



	The ideal development sytem for this is an Atari 8 bit computer
running MAC-65.  The normal system equates could be used and when it is 
time to actually put the program into EPROM, you would .include the 2600
equates instead of your computer equates.  Don't forget to .set your 
offset so that the code can be used by your PROM programmer.


		            Bit Wise Memory Map
                            -------------------
     

------------------------------CPU addresses---------------------------------

6507 --> |  12 | 11 | 10 | 09 | 08 | 07 | 06 | 05 | 04 | 03 | 02 | 01 | 00 |
----------------------------------------------------------------------------
6532     | cs0 |    |    | rs |    |CS1 |    |    |    |    |    |    |    |
----------------------------------------------------------------------------
EPROM    | CS  |    |    |    |    |    |    |    |    |    |    |    |    | 
----------------------------------------------------------------------------
TIA      | cs0 |    |    |    |    |cs3 |    |    |    |    |    |    |    |
----------------------------------------------------------------------------

* lower case indicates active low.
** rs is ram select line


				More Hacks
                                ----------

	You could remove the TIA chip and replace it with another chip of
your choice.  You will then have to provide a divide by 3 or a divide by
two circuit for the CPU clock.  I have done this and replaced the TIA with
a J-K flip flop in a divide by two configuration and have had no problems. 
This eliminates the need for the TIA and speeds up the processor due to 
the increased clock speed (1.79 Mhz vs. 1.19 Mhz).  Most of the chips
shipped with the 2600 should handle this increased speed.  I got my board
from Best Electronics in California.  A set of prints for the 2600 come in
very handy when configuring (hacking) the system.


							Rich Andrews





-- 
*******************************************************************************
Any opinions expressed above are my own.        Rich Andrews
 They can be yours too.  Please send $19.95 to.....ihnp4!chinet!cabbie
*******************************************************************************