[comp.sys.cbm] Cartridge Port

tw0i+@andrew.cmu.edu (Todd Andrew Williamson) (01/20/88)

Can anyone give me a comprehensive idea of what the game and exrom lines on 
the cartridge port of the 64 do? I think I have a pretty good idea, but I'd 
like to be sure. I heard a nasty rumor that if the game line is held low on 
startup, the 64 goes into a "Max machine" mode, with like 4k of RAM or 
something. I tried all of my usual sources, but I couldn't find any 
information on the PLA chip. Any information would be appreciated, either a 
post or EMAIL. 


Thanks in advance,

-Todd.

elg@killer.UUCP (Eric Green) (01/22/88)

in article <gVxAJay00V4GzOU05v@andrew.cmu.edu>, tw0i+@andrew.cmu.edu (Todd Andrew Williamson) says:
> Can anyone give me a comprehensive idea of what the game and exrom lines on 
> the cartridge port of the 64 do? I think I have a pretty good idea, but I'd 
> like to be sure. I heard a nasty rumor that if the game line is held low on 
> startup, the 64 goes into a "Max machine" mode, with like 4k of RAM or 
> something. I tried all of my usual sources, but I couldn't find any 
> information on the PLA chip. Any information would be appreciated, either a 
> post or EMAIL. 

Look on pages 263-267 of the Programmer's Reference Guide. Yes
indeedy, if you pull down the *GAME line without pulling down the *EXROM
line, it goes into "ULTIMAX video game memory map". Interesting thing about
Ultimax mode... only 4K of RAM is accessible. Period. You can't read any other
RAM, and, what's even more mystifying, you can't WRITE any other RAM. Boggles
one's mind... "WHAT the HECK is THAT in there for?!".

'Nother interesting thing is the snafu of p266 (bottom), the 16K cartridge
memory map, and page 265 (bottom), the 8K BASIC expander memory map. Look
carefully at LORAM and HIRAM for both (those are two bits in location $01, see
the memory map). They're identical! In actuality, one is supposed to be
LORAM=1,HIRAM=0.  Something else interesting is that my copy of Abacr*p's "The
Anatomy of the Commodore 64" has those very same memory maps in it -- complete
with that error! So much for proof-reading......

--
Eric Lee Green  elg@usl.CSNET     Asimov Cocktail,n., A verbal bomb
{cbosgd,ihnp4}!killer!elg              detonated by the mention of any
Snail Mail P.O. Box 92191              subject, resulting in an explosion
Lafayette, LA 70509                    of at least 5,000 words.

-Pete-@cup.portal.com (01/23/88)

 The following comes from the book 'Programming the Commodore 64' by Raeto
Collin West, copyright March 1985 by COMPUTE! Publications Inc.  I intend the
following to be treated the same as though I had let someone read from the
book.

 Memory with Cartridge and BASIC

 At power up, this arrangement has an 8K cartridge, usually designed to auto-
start, 4K free RAM, and BASIC with 30K ROM, which you may or may not be returne
to. Most cartridges using 8K or less--even pure ML--use this arrangement, since
they can also borrow BASIC subroutines. Some utilities coexist with BASIC or
intercept BASIC in order to add their own commands. Some utilities relocat
their cartridge ML to RAM at $c000, altering BASIC vectors, then switch them-
selves out by resetting EXROM high. This allows nother cartridge to operate, bu
means that RAM from $c000 must remain untouched.
  If EXROM is grounded with no cartridge present, the 64 will print 30719
bytes free when turned on; it loses 8K of ROM, so $8000-$9fff is read as
garbage, but written as RAM. If GAME alone is grounded when the computer is
turned on, the 64 crashes, since the Kernal is deactivated. The following
figure shows how the PLA detects cartridge presence.
     Software         Hardware
CHAREN HIRAM LORAM   EXROM GAME
  1      1     1       0    1     $d000-$e000 is I/O ROM
  0      1     1       0    1     $d000-$e000 is Char. ROM

  All other configurations are identical to those of no cartridge being
present.

  Memory with Cartridge but Without BASIC

  This allows a 16K ML autostart cartridge to use Kernal and I/O. It's often
called the application configuration, based on the theory that 16K will hold
a serious program. However, it's often not enough and it's common to find
cartridges using bank switching themselves. COMAL (a structured programming
language) has four banks here, using 64K RO.

 MAX

 Intended to allow a 16K autostart cartridge, including its own I/O routines
with 4K of RAM.
     Software         Hardware    Config.
CHAREN HIRAM LORAM   EXROM GAME   0   1000    8000    A000    D000   E000   FFF
    --- ANY ---        1     0     RAM    Unused  8K Cart  Unused  I/O  8K Cart

 Overview of 64 Memory Maps

 64K of RAM is available under ROM. This is because the PLA insures that when-
ever ROM coexists with RAM, reading comes from ROM, but writing goes to the
hidden RAM (or the I/O chips). You'll need to alter the LORAM or HIRAM bits
to read the RAM back. However, the VIC-II chip is wired to read RAM--except
where it sees character ROM. Also, of course, the PLA has to switch in external
ROM cartridges when detected, giving them priority over internal RAM and ROM.
Note that, when the 64 is turned on, CHAREN, HIRAM, and LORAM are all set to 1,
so the maps with ots of RAM must be switched in using software. They aren't
necessarily easy to use; the Kernal and I/O are important if you wish to use
the keyboard and screen, for example.
  There are several limitations on the amount of external ROM which the 64 can
take. No external ROM can be added below $8000 without external decoding (so
you must use RAM below $8000), and ROM above $8000 is confined to several
blocks, arranged around the BASIC, Kernal, and character ROMs. Paradoxically,
the system is in some ways less flexible than the VIC-20, where several chunks
of empty memory can be filled with ROM or RAM packs.
  Turnkey (ready to go) systems use the $8000 autostart feature. A cartridge
can be mimicked in RAM by poking five bytes into $8004-$8008 to defeat a reset
switch (unless EXROM is grounded). However, a cartridge which uses its own
area of underlying RAM won'T work if it's simply copied into RAM, and an
external RAM pack, which would mimic ROM, can't be written to. So, from the
software security point of view, this design is good.

 Commodore 64 Ports
  Cartridge Port. This is the port at the left of the 64, looking from the
rear. It has 44 connections, 22 on each side, all of which are connected. Two
tracks, usually wired together, carry the +5-volt power supply to the cart-
ridge; these are pins 2 and 3, near the top right, from the back of the 64.
(The VIC-20 has a reversed numbering convention.) These tracks are rather
close, and the possibilities of a short-circuit or arcing make it inadvisable
to insert or remove cartridges when the power is on, though with care it is
generally safe. Note that edge connectors are designed for the replacement
of faulty computer parts during maintenance; they aren't really ideal for
cartridges.

Top  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
Bot  A B C D E F G H I  J  K  L  M  N  O  P  Q  R  S  T  U  V

The pins function as described below:
Top
---
 1     Ground. All four ground lines are usually tied together.
 2,3   5-volt power supply to the cartridge.
 4     IRQ. As long as this is low, it requests an interrupt.
 5     R/W line. Reads when low, writes when high.
 6     8MHz dot clock input, for your own video control.
 7     I/O1 goes low when 64 detects use of $de00-$deff; can be used with CP/M.
 8     GAME replaces BASIC ROM with external cartridge ROM when grounded.
 9     EXROM replaces RAM from $8000-$9fff when EXROM is low; needs address
       A0-A12.
 12    BA (Bus Acknowledge). To use, pull DMA low. An external device ca
       control the 64 while BA is high.
 13    DMA (Direct Memory Access). See BA.
 14-21 D7 through D0. The data bus carries eight bits of data.
 22    Ground.

Bottom
------
 A     Ground.
 B     ROMH selects external ROM at $a000-$bfff (or $e000-$ffff, for MAX) when
       GAME or EXROM is low; needs address bits A0-A12.
 C     RESET detects a positive voltage, resetting when rising from ground to
       +5 volts.
 D     NMI connects to 6510 Non-Maskable Interrupt line. It is spike sensitiv
       --needs a pulse in either direction. Normally high, so many devices can
       signal NM=I.
 E     02 system clock. Essential for I/O timing, but not necessary for externa
       ROM. (Note: 0 is the small circle w/ the slash through it.)
 F,H,J,K,L,M,N,P,R,S,T,U,V,W,X,Y, Address bus (A15-A0). The full 16 address
       lines are necessary for DMA.
 Z     Ground.

  A typical 16K game or word processor on cartridge uses the ground and power
lines, GAME and EXROM, ROML and ROMH (for access to cartridge ROM at $800
$bfff), and the data bus, plus address lines A0-A12. All ROM addresses from 0X
through 1XXX, plus ROML and ROMH, are therefore accessible. An 8K cartridge
doesn't need GAME or ROMH.
  Interfaces typically use I/O1 or I/O2 to control two storage buffers and R/W
and 02 to control timing.


  (Programming the Commodore 64, pages 114-120, slightly modified.)

  I hope that this has been a help to you.

                                -Peter Cook
Unison: [DCUNSN]PETERCOOK
sun!DCUNSN.DAS.NET!MAX::PETERCOOK
sun!portal!cup.portal.com!Peter_Thomas_Cook
Portal: -Pete-

fred@cbmvax.UUCP (Fred Bowen) (01/29/88)

In article <3021@killer.UUCP>, elg@killer.UUCP (Eric Green) writes:
> Ultimax mode... only 4K of RAM is accessible. Period. You can't read any other
> RAM, and, what's even more mystifying, you can't WRITE any other RAM. Boggles
> one's mind... "WHAT the HECK is THAT in there for?!".
> 
> Eric Lee Green  elg@usl.CSNET     Asimov Cocktail,n., A verbal bomb

The Ultimax (aka Max Machine) was intended to be the cheapest CBM system,
below or possibly replacing the VIC-20.  It was primarily a game machine
using the VIC-II chip, just like his brother the C64.  He did not even have
BASIC in ROM, although a BASIC cartridge was to be available.  Well, in the
US at least, Max died in infancy but not before leaving his mark on the C64,
which was (ta-da) two machines in one, a Max and a C64.

(So I suppose you could say then that the C128 is really FOUR machines in
one, with Max still in its heart ;-)

--
-- 
Fred Bowen			uucp:	{ihnp4|rutgers|caip}!cbmvax!fred
				arpa:	cbmvax!fred@RUTGERS.EDU
				tele:	215 431-9100

Commodore Electronics, Ltd.,  1200 Wilson Drive,  West Chester,  PA,  19380

elg@killer.UUCP (Eric Green) (01/31/88)

in article <3231@cbmvax.UUCP>, fred@cbmvax.UUCP (Fred Bowen) says:
> In article <3021@killer.UUCP>, elg@killer.UUCP (Eric Green) writes:
>> Ultimax mode... only 4K of RAM is accessible. Period. You can't read any other
>> RAM, and, what's even more mystifying, you can't WRITE any other RAM. Boggles
>> one's mind... "WHAT the HECK is THAT in there for?!".
> The Ultimax (aka Max Machine) was intended to be the cheapest CBM system,
> below or possibly replacing the VIC-20.  It was primarily a game machine
> using the VIC-II chip, just like his brother the C64.  He did not even have
> BASIC in ROM, although a BASIC cartridge was to be available.  Well, in the
> US at least, Max died in infancy but not before leaving his mark on the C64,
> which was (ta-da) two machines in one, a Max and a C64.

Another mind-boggling thing: The VIC-][ chip in the C64 can't see the regular
character-set ROM if the Ultimax mode is enabled. I guess the character set
had to be on the plug-in cartridges? Beats me... all I know was that I wrote a
short program at $900 that banked Ultimax in (via a jumper to a CIA), paused
for a few secs (with irq's off, of course), then banked Ultimax out -- and the
character set evaporated during that pause. Which means that anybody who wants
to take advantage of Ultimax had better make sure that it only takes over
while BA and S02 are both high (i.e., when the VIC-][ chip isn't active). As
for why one would want Ultimax, figure out for yourself how you could get your
own custom Kernal into the machine without a ROM swap....

--
Eric Lee Green  elg@usl.CSNET     Asimov Cocktail,n., A verbal bomb
{cbosgd,ihnp4}!killer!elg              detonated by the mention of any
Snail Mail P.O. Box 92191              subject, resulting in an explosion
Lafayette, LA 70509                    of at least 5,000 words.

fred@cbmvax.UUCP (Fred Bowen) (02/02/88)

In article <3162@killer.UUCP>, elg@killer.UUCP (Eric Green) writes:
> Another mind-boggling thing: The VIC-][ chip in the C64 can't see the regular
> character-set ROM if the Ultimax mode is enabled. I guess the character set
> had to be on the plug-in cartridges?

	Yep.  Most games were bit mapped or used their own characters anyhow.
	Also remember the VIC sees the character ROM not at $D000 like the
	processor but in bank 0 or 2 only, at $2000 and $9000, thru the same
	magical PLA that dreams up Max mode when the /game goes down.

> ... anybody who wants
> to take advantage of Ultimax had better make sure that it only takes over
> while BA and S02 are both high (i.e., when the VIC-][ chip isn't active).

	Ultimax mode is (was?) intended for game cartridges which are
	installed at power up, so this is no problem.

> ...why one would want Ultimax, figure out for yourself how you could get your
> own custom Kernal into the machine without a ROM swap....

	Not using Max mode unless you are playing truly bizarre "hardware"
	games with /game.  Even so, in Max mode the image of the "kernel"
	ROM also appears at $3000, and all but 2-4K of RAM evaporate. Add
	to this the VIC-ercises you mentioned above, and you get some idea
	why it's so hard to maintain compatiblity in newer computers with
	fellas like yourself running around :-)  But I guess that's why the
	64 type computer still lives, eh?

> Eric Lee Green  elg@usl.CSNET     Asimov Cocktail,n., A verbal bomb
> {cbosgd,ihnp4}!killer!elg              detonated by the mention of any
> Snail Mail P.O. Box 92191              subject, resulting in an explosion
> Lafayette, LA 70509                    of at least 5,000 words.
--
-- 
Fred Bowen			uucp:	{ihnp4|rutgers|caip}!cbmvax!fred
				arpa:	cbmvax!fred@RUTGERS.EDU
				tele:	215 431-9100

Commodore Electronics, Ltd.,  1200 Wilson Drive,  West Chester,  PA,  19380