Sunday, 11 November 2018

Atari 400 48K RAM boards

In the last blog post, I upgraded the RAM in an Atari 400 from 16K to 48K. Here are the new boards to make that process easier.
On that first 400, I tried soldering a 32K RAM chip under the board, and reassigning the original 16K RAM card to sit after that giving 48K of RAM.
That worked nicely, but wasn't as neat as original planned, as I needed to add a NAND gate, and two OR gates to complete the circuit, so I went back to the idea of replacing the original 16K RAM card with a new one.
The new RAM card is a lot smaller than the original 16K card, but fits in the same slot.
The problem with that approach, is the cartridge is only wired for a maximum of 32K RAM. The card can be used like that, without any modification to the Atari 400, this will give 32K of RAM.
However, to get the full 48K, the missing signals can be connected to some unused pins on the connector.
Four links in total are required, connecting from the cartridge port to the RAM card slot, as follows:
  • RAM slot M → Cart slot A (pulled high by cartridge when S4 area in use)
  • RAM slot N → Cart slot 1 (/S4 signal)
  • RAM slot R → Cart slot 14 (pulled high by cartridge when S5 area in use)
  • RAM slot T → Cart slot 12 (/S5 signal)
With those modifications, you get 48K, which can be used when loading from disk or tape.
In BASIC, as with any Atari, 8K of that is hidden behind the ROM cartridge, so the maximum BASIC sees is 40K.
The labelling is slightly unusual, as one side is number 1-22, the other is A-Z (missing out G, I, O and Q). The cartridge is port is 1-14, A-S.
The sides facing the front is the letters, with pins 1 and A on the right hand side. The chips on both cards face the back of the unit.
The 48K RAM card is available now from my Tindie store, either as an assembled unit, ready to go.
Or as a kit, complete with ready programmed GAL chip.
Once that is installed and the Atari 400 is reassembled, it's pretty much an Atari 800, certainly in terms of software compatibility.

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.

Sunday, 4 November 2018

Atari 400 48K internal RAM upgrade

In the previous blog post, I started upgrading an Atari 400 by fitting a composite video modification.
That was all working nicely, but was a little limited when it came to tape based software, due to only having 16K.
On the Atari, PRINT FRE(0) will show how many bytes are free, here showing 13596 bytes, the 16K less memory used by BASIC and the OS.
The Atari is a multi board system, the base board mainly handles IO, and there are two plug in cards permanently installed.
The first is the CPU board, this contains the 6502C, GTIA and ANTIC. On this particular board, I had to replace the GTIA chip on the left as it seemed to have issues with sprites. It was otherwise fine, but when a sprite like the hammer on Donkey Kong was used, there would be vertical interference around that area, which would follow the sprite around.
The second board is the 16K RAM.
This is made up of 8x4116 chips. I beleive there was also an 8K version with 4108 chips, but the 16K version is most common.
The Atari 800 is the bigger brother of the 400, but shared many parts, including these two boards. The 800 was designed to be upgraded, so the boards are in cases, and the slots are accessible by lifting up the lid. This didn't get used much, as most 800s had the full 48K installed from new when the price of RAM fell sufficiently.
The 800 had three slots for RAM cartridges, so could support up to 48K, as demonstrated by the handy guide on the back of the RAM cartridges.
The Atari address space is organised into eight 8K blocks, as follows.

Address
Atari 400
Atari 800
0000-1FFF
RAM
RAM
2000-3FFF
RAM
RAM
4000-5FFF
-
RAM
6000-7FFF
-
RAM
8000-9FFF
-
Right Cart or RAM
A000-BFFF
Left Cart
Left Cart or RAM
C000-DFFF
I/O + OS
I/O + OS
E000-FFFF
OS
OS

The RAM from 8000-BFFF is shared with the cartridge slot. When the cartridge is plugged in, the RAM is disabled. It should be possible to upgrade the 400 to work like that, and with this upgrade, the two machines should be functionally identical. The main address decoding on the Atari 400 uses a 74LS42 chip, a 4-10 decoder, a slightly unusual choice over the ususal 74LS138 3-8 decoder, especially as there is already a 138 on the BOM, so it would surely have been cheaper to use two of those instead?
This generates eight active low select lines, S0-S7. S0-S3 represent the lower 32K of RAM, and all four of these are connected to the RAM slot on the 400. Lines S4 and S5 go to the cartridge slot. S6 and S7 go to the ROM chips and on to the IO decoding (using the 74LS138). Based on that, it should be possible to create a 32K RAM cartridge that would replace the 16K one, but there is no access to the S4 and S5 lines, so that's not ideal as it wouldn't be possible to use this as well as the original 16K cart to get 48K.
My first plan was to use one of my PET ROM/RAM boards to add the extra RAM, but the position of the CPU board precludes the use of a plug in daughter board as it is too close to the edge of the metalwork. I then briefly considered a replacement CPU card which included RAM, but there's a bit too much stuff going on. Also the schematic I had for the CPU card doesn't match the boards I have (they appear to include 245 buffers on the address bus which are not necessary with the 6502C version of the CPU that has the additional halt pin).
So, what next? Well a plan was starting to develop here. The control lines we need are not on the cartridge port, so it's not going to be possible to create a 48K RAM board, at least not without modifying the 400 main board as well.
There are three ROM chips on the 400 main board. These are 24 pin ROMs, the pinout of which is a reasonable match to the lower 24 pins of a 32K RAM chip.
A chip such as this, the IDT 71256, which is a narrow version of the standard 62256 32K x 8 SRAM chip. My thinking was to use wire this chip to most of the lines on the 24 pin ROM, and then connect the rest as appropriate.
That looked like it was going to work. The RAM chip here is facing into the board, so it is the same orientation as the ROM chip.
The only lines not soldered directly to the board were A13 and A14 on the top right, 5V on the top left, then the /WE pin, which was connected to R/W Early (more on that later), A12 and the /OE and /CS lines. I could have generated the enable for the RAM by ANDing S0,S1,S2 and S3, but in the end it is just the A15 line. Low for 0000-7FFF, high for 8000-FFFF, which is exactly what we need.
That didn't work as expected, so I spent a while working out the way the timing worked on the Atari. The standard 6502 R/W line isn't passed on from the CPU card, instead there are R/W Early and R/W Late lines. Early is close to the standard line, and Late is delayed to be the second half of the write cycle, by which time the data should have settled.
After trying various things, it seemed to the problem was on the read side, and I mimicked the original RAM board by generating the /OE signal from /REFRESH and R/W LATE. That means adding a little 5 pin single gate NAND gate chip to the side. Not the neatest solution.
But it worked. The Atari was now reporting 29710 bytes free, so the 32K was recognised, and I was also able to load various things from tape that hadn't worked with 16K.
Such a Rodman. This should be a 16K game, and it will run in 16K on the emulator, but unfortunatley the loader takes it just over 16K and so won't run on a standard Atari 400. It now runs fine on this newly modified 32K Atari 400.
So that is 32K, what about the next 16K to make it the full 48K machine?
On the Atari 800, the lower 32K go to two of the slots, and there are two OR gates controlling the next 16K. Pin 14 on the cartridge is connected to 5V by the cartridge PCB, so that when the cartridge is plugged in, the OR gate will disable that section of RAM. The 680R resistor pulls this line low when a cartridge is not installed and enables the RAM. Pin A does the same for the right cartridge.
There is a slightly confusing arrangement of control lines going on, you can see on the rear of the RAM cartridge PCB that pin T is connected to S, N to M and R-P. This is different on the 8K version (N-P, R-S, T-U), to allow different combinations of 8K and 16K RAM modules to be used in the correct order.
What this boils down to is there are two inputs, 18 and U either of which will enable the RAM when low. On the Atari 400, those are connected to S0 and S1, so the RAM is mapped from 0000-3FFF. On the Atari 800, when you have two 16K boards installed, those two enable lines on the third card end up connected to the two OR gates. That means that we can copy part of the Atari 800 design, and fit OR gates to check the S4 and S5 lines, and the cartridge present lines to generate enable lines for the 8000-BFFF range, and those can be connected to the two pins on the original unmodified 16K RAM board.
Again, not the prettiest modification, a 74LS32 OR gate soldered upside down to the bottom of the board. I've implemented both gates, as although the 400 does not have a right cartridge slot like the 800, the right cart address range is also present on the left cartridge slot.
The output of the two OR gates connect to the PCB pads where the S0 and S1 signals would normally come out of the 74LS42 chip, but I have bent up the legs instead of cutting the tracks, so there is no clash, and so this can be reversed.
With that, Atari BASIC is now reporting 37902 bytes free, the maximum you will get as it's actually only 40K as the BASIC cartridge takes 8K out of that.
Without the BASIC cartridge, the full 48K should be available, and I have tested that with some large (must be, based on loading time) games, including my favourite Spellbound which got a lot of play on my Atari 800XL back in the day.
I also found a demo tape, showing off the capabilities of the Atari.
Those all seem to be working well, I think we have a 48K Atari here. It's not very neat though, I probably wouldn't recommend anyone actually do it like this.
It's all hidden out of the way, and there was a cardboard separator between the board and the metal case, so it is protected from shorts and will not been seen in normal operation.
I've been looking at alternative options, and I've designed a 48K RAM cartridge. This will not work on an unmodified Atari 400, but all it will take is four wires to be soldered between the cartridge port and the RAM slot, but it should be acceptable.
The logic in the cartridge is slightly different that implemented on the hard wired upgrade, there the A14 and A15 lines are not present, so the RAM /CS line has to be generated from the S0-S3 signals. It would be possible I suppose to go for bank switching like the 130XE. This has a bank switching register to allocate 4 additional banks of RAM to the 4000-7FFF range. Not sure that extra complexity would be of much benefit, was there much 130XE only software, and how much of it would you really want to run on your souped up Atari 400?
At the last minute, I decided to play it safe and redesigned the board to use a GAL chip, so I could tinker with the logic equations if necessary. There will be a follow up blog post when the PCBs arrive, showing a much neater version of the mod. In the mean time, more change to try out some of my Atari tapes from the 80s.
Just one addendum (as if this blog post wasn't already long enough). I found a game I remember I could never get to load.
It would always get to 1 block from the end, then fail.
Unfortunately, this was already the other side as that same damage stopped the first side loading as well. I decided to see if modern technology could save this (ignoring the easier option of buying another copy of the tape, creating one from an online copy of the game, or just loading it with an SIO2SD).

You can clearly see the damage at the start of side 1 and the end of side 2. So I spliced the start of side 2 with the end of side 1 and created a new wav file.
I wrote this to tape and tried loading it. It got all the way to the last block...
and then, 30 years after I got this tape, I finally got it to load.
Was it worth the wait. Probably not.

Update:

See the following blog post for more info, 48K RAM upgrades are now available from my Tindie store.

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.