This is an image of the interior of my VPatrol card. Today I would like to concentrate on the upper left corner:
That is the eEprom Kristof uses to store calibration information, high scores, acchievments and options. You might say “so what” – it is sort of a common thing now to include a permanent saving mechanism to cards.
I dare you – to look a bit closer.
This is the “full” naming/specs: ATMEL 611 AT24C02N 10SU-2.7
- “U” designates Green Package + RoHS compliant.
- Package 8S1
- 8-lead JEDEC SOIC
- AT24C02, 2K Two-wire Serial EEPROM: Internally organized with 32 pages of 8 bytes each, the 2K requires an 8-bit data word address for random word addressing.
Although the datasheet doesn’t say it probably due to copyright reasons this is a I²C compliant device.
The “extraordinary” above is the word “two” instead of “one”.
Before VPatrol all storage devices inside Vectrex cartridges were one wire devices – a tradition that began with Alex Herberts “Protector”.
One wire eEproms (as the name suggests use GND, some Voltage and one Pin for communication) – thus these device often come with 3 connection pins and look a little bit like a classic transistor.
This “one” is/was due to the fact, that the vectrex cartridge port only sports 1 pin that is “programmable” from the Vectrex side. That pin (cartridge port pin 35) is connected directly to VIA and can be read or written to by doing some stuff with (or to) the VIA chip. Namely that is VIA Pin 16 – which, since it is addressed by the 6th bit of Port B, is also often refered to as PB6.
PB6 is famous for communication with all kinds of cartridge internal stuff, like:
The above mentioned AT24C02N 10SU-2.7 (which I will in the following only reference as “Atmel”) is a two wire chip. This means it needs TWO pins to communicate with Vectrex!
- SDA: Serial Data
- SCL: Serial Clock Input
- there are more pins (address pins if you have more than one I²C devices, write protect, etc) – but these do not concern us here
In order to use the chip you must be able to write to the cartridge with one other external (cartridge port – Vectrex) signal.
How is that possible? -> IRQ!
The service manual is not very easy to interprete in this regard – cartridge pin 36 is connected to the ~IRQ pin of the processor.
VIA can generate interrupts (by timer, shifts, control lines etc), the schematics show the VIA ~IRQ pin connected to the RAM chips – which is nonsense. What is not nonsense is the fact that ~IRQ signals of VIA must reach the CPU, otherwise it would not be possible to generate interrupts at all (by VIA).
And once the connection to the processor is made it stands to reason that the same TTL – level will be available at the cartridge port (at said pin 36).
Thus by generating an interrupt (~IRQ = 0) or by no interrupt (~IRQ = 1) you can programmatically change the value of pin 36 of the cartridge port!
VIA interrupts can be very flexibly generated, enabled, disabled etc. Also – even if an interrupt is generated, that does not mean the microprocessor has to interrupt its work – you can (conditional code register – bit 4 – Interrupt Request Mask) tell the processor to ignore interrupts. So if you do it right you can set/unset the interrupt to your likings without disturbing your code.
So how to communicate?
Well essentially like it is stated in the datasheet. But to use Krisof’s words:
“You use the T1 Timer interrupt to put “signals” on the cartridge IRQ port and thus SCL?
I didn’t know that was possible – but your source suggestest it…”
“Yes, correct. The PIA-IRQ pin is in fact an open-drain output and if you look on the vectrex-schematics, a pull-up resistor of 3K3 is already installed on the logic board. The PIA-IRQ pin goes low depending on the flags set in the IER and IFR registers. So, for example, by letting T1 go timeout, you can generate an SCL low signal.
Actually, you can manage the IFR and IER in such a way, that you can always create an IRQ low or IRQ high signal.”
“This makes the serial code much more compact than in Vector Pilot – or so it seems…”
“Yes. It makes it also more robust since classic I²C is by definition a quite robust protocol. Actually, when the program is doing bankswitching via toggling the PB6/SDA-line, it does in fact also massive amounts of START/STOP conditions towards the connected I2C-chip. But this doesn’t seem to be a problem for the I2C-chip.”
“AND THIS MEANS ANOTHER BIG THING: we now can control 2 binary signals PB6 and IRQ, which means extra bankswitching! So instead of having just 2x32K-banks,we now can have 4x32K-banks. “
I added emulation of the Atmel chip. So if in fact you have a binary ROM of VPatrol and for whatever reason want to play it using Vide (which defenitly does not compare to the VPatrol experience on a real Vectrex) – it saves highscores and other stuff – starting with the next version I upload.