Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!husc6!think!ames!pasteur!ucbvax!sdcsvax!ucsdhub!esosun!seismo!uunet!portal!cup.portal.com!-Pete- From: -Pete-@cup.portal.com Newsgroups: comp.sys.cbm Subject: Re: Cartridge Port Message-ID: <2665@cup.portal.com> Date: 22 Jan 88 18:23:21 GMT Organization: The Portal System (TM) Lines: 137 XPortal-User-Id: 1.1001.3286 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-