25

I wonder why the Commodore 64 memory map was created as it was. Naively, it seems to be that it would have been more logical to put I/O and the character ROM at $B000 to $BFFF, have the ROMs in a continuous block from $C000 to $FFFF as in the VIC-20, and have the area from $A000 to $AFFF available for BASIC, so that you have 42K of BASIC usable RAM instead of 38K.

Is it known why the real arrangement was chosen instead of the one I described? Was there a conscious decision to keep 4K of non-banked RAM outside of the reach of BASIC to be able to store machine-code subroutines there? Or is the PLA simpler and/or smaller that way? Or is the reason maybe the RAM size detection routine which would have been thrown off if VIC-II registers followed immediately after the last byte of BASIC-usable RAM? The last seems trivially fixable by flipping around VIC-II and SID, however, since the first SID register is write-only.

DrSheldon
  • 15,979
  • 5
  • 49
  • 113
TeaRex
  • 703
  • 3
  • 11

1 Answers1

33

I wonder why the Commodore 64 memory map was created as it was.

As so often it helps to look at a machine's predecessor; in the case of the C64 that's not the VIC 20, but the Max Machine, a very minimalist game system/computer. After all, the C64 is a quick hack, filling that design with 64 KiB of RAM, a second CIA for user port/serial (*1,2) and on-board ROM with BASIC. Thus the C64 memory map is based on the Max Machine's:

$0000-07FF   2 KiB RAM
$0800-7FFF   free for expansion (*3)
$8000-9FFF   8 KiB for ROM module
$A000-BFFF   8 KiB for ROM module
$C000-DFFF   8 KiB for I/O
$E000-FFFF   8 KiB for ROM module

The upper 32 KiB address space of the Max Machine was basically divided into four 8 KiB Blocks with 3 of them for ROM, except there was no ROM on board. ROM was provided on cartridges, including any character ROM (*4).

The C64 was designed to keep maximum compatibility to the Max Machine (*5). That's also why there is the /GAME signal on pin 8 of the cartridge port. Grounded on the Max cartridges, it was pulled high on the C64 to serve as input to the PLA to put the machine into 'Ultimax' mode, making it fully compatible. That way the C64 was able to run all those many Max cartridges that were expect to come (*6).

With /GAME pulled high, all internal ROM (and RAM above $1000) was disabled and to be replaced by cartridge. To still allow the addition of C64 cartridges that can take advantage of all RAM and ROM another signal /EXTROM was added, which when pulled would default to an an 8 KiB area at $8000 for external ROM but everything else as with the default C64. With both pulled, a second 8 KiB at $A000 would be provided instead of BASIC.

Bottom line: The seemingly strange C64 banking is all about compatibility with the Max.

Is it known why the real arrangement was chosen instead of the one I described?

In hindsight much could have been improved with the C64, not just the memory map. Back then it was all about getting it out as fast as possible.

Was there a conscious decision to keep 4K of non-banked RAM outside of the reach of BASIC to be able to store machine-code subroutines there?

As mentioned, compatibility. Easy to see when noting that in Ultimax Mode those 4 KiB are not mapped.


*1 - A second I/O chip was needed to offer the serial IEC as well an user port.

*2 - The expedited development is also the reason why there are two CIAs with two clocks instead of a CIA and a VIA - it was less risky to use the same chip twice.

*3 - For example, used to add 2 KiB of RAM with the 'full' BASIC cartridge.

*4 - This is also the reason why the C64 has the added complication of the character ROM in parallel to I/O: They had to find a place that could not have been used with other cartridges. A place 'outside' the map, but still visible to the VIC. The 4 KiB I/O space is the place the VIC will least likely access for character definition data in RAM or ROM, making that the perfect place to put it.

*5 - After all, the Max was expected to be sold for a longer time, while the C64 was only intended as a short time stop-gap measure until the TEDs were done.

*6 - This turned out to be a gift to piracy. Ultimax mode meant that a cartridge can take over all vectors, which freezers made good use of :))

Toby Speight
  • 1,611
  • 14
  • 31
Raffzahn
  • 222,541
  • 22
  • 631
  • 918
  • Was the Max Machine a "predecessor" to the C64, or a sister product? In the US, I certainly heard about the C64, and even laid hands on one, long before I'd ever even heard of the Max machine (in fairness, I think the first time I heard about the C64 was when I laid hands on one). – supercat Jul 25 '23 at 14:55
  • 1
    @supercat The Max was the genuine reason the 6510 was developed in the first place. Where the VIC-20 and all previous commodore needed two VIA, the low price Max should save one of them by cutting user port and serial bus by putting cassette onto the CPU and replace the other by a CIA adding the TOD clock. When serial IEC was needed again, the second VIA (here CIA) had to be added again, making the investment into the on CPU port useless.. – Raffzahn Jul 25 '23 at 15:22
  • That seems weird. Given that VIC-II interrupts can be used to supply timing for games, I would think using discrete logic for I/O could eliminate the need to use any other I/O chips, and the biggest advantage of the 6510's on-chip I/O is the ability to access it even when all 64K of address space are configured as RAM (a style of configuration that may have a certain elegance, but is actually less useful than would be e.g. having $DF00-$DFFF be bankable to any of 256 banks of RAM while $D000-$DEFF were always banked as I/O). – supercat Jul 25 '23 at 16:14
  • Besides, that doesn't really imply that the Max was a predecessor rather than a sister product, and many aspects of the C64 like the 1Kx4 color RAM seem more driven a desire to facilitate adaptation of VIC-20 code than by a desire to make things as cheap as possible. – supercat Jul 25 '23 at 17:27
  • @supercat The Max had a keyboardwhich des need I/O liens. Likewise timer asre great to do what you describe. Last, why using an 8 bit RAM when only 4 bit values are needed and 4 bit RAMs were plenty on stock (same reason why the VIC20 used them). But serious, instead of trying so hard to make up fantasy worlds, you may enjoy some hours reading according books off Commodore history written by the very people making them. – Raffzahn Jul 25 '23 at 18:06
  • The store where I bought my VIC-20, and first saw the C64, was primarily focused on business machines, and never carried the Max Machine; maybe there were other places in the US that carried it, but I don't know of any. Maybe the Max Machine was conceived before the C64, and maybe it was mass marketed overseas before the C64 was marketed there, but in the midwestern USA the max machine was a non-entity. – supercat Jul 25 '23 at 18:37
  • 1
    @supercat I'm not sure, but the Midwestern US might not be a focus region for new computer delivery. The Max machine and it's chip set (6510/6526/6581/6566) was developed as a project of Commodore Japan (CEO Sam Tramiel) for Japan which was planned to reach the US (Ultimax) and Europe (VIC 10) at later dates. The C64 is a derivation (needing a new VIC, the 6567, because of DRAM) made to make the 1982 CES. Problem was that the Max was the right idea but too much cut down and he C64 eating up it's component supply in 1982, so it got cancelled to allow C64 sales. – Raffzahn Jul 25 '23 at 19:04
  • That would explain why I remember computer magazines introducing both machines at the same time. Popular computer magazines in the US largely ignored what was going on elsewhere in the world, and as someone whose understanding of what was going on in the world of computing came from such magazines, I'd never thought of Commodore as not being primarily an American company. I think it might be clearer to say that the C64 is an offshoot of a small and cheap computer developed for the Japanese market, called the Max Machine. – supercat Jul 25 '23 at 19:47
  • @supercat For many years Germany was the main cash cow of commodore. They maintained a profitable business all the way to the end. Including a good stand in business machines with their later PC compatible. (Not to mention several otehr very nice developments) – Raffzahn Jul 25 '23 at 19:57
  • Of course, I suppose now the next question would be why the Max Machine put I/O at $C000 rather than putting it at $1000 in CPU address space, leaving $2000-$FFFF available for external expansion? – supercat Jul 25 '23 at 22:00
  • 1
    Because that would make any RAM expansion non continuous? Basic 6502 means ROM must be on TOP (for vectors), RAM must be on bottom (for ZP and Stack) and I/O inbetween - usually direct below ROM. By assuming a default module size of (up to) 8 KiB (quite a lot for back then), $C000 is the logical choice, leaving the option of up to 48 KiB continuous RAM. In contrast ROM can be anywhere as it doesn't need to be continuous. Wouldn't do it different. – Raffzahn Jul 25 '23 at 22:37
  • None of the built-in RAM in the first 2K is going to be usefully contiguous with BASIC's main RAM area. Having the expansion area start at $2000 would mean that a version of the BASIC cart with 16K ROM could expand RAM up to 42K, with 40K contiguous, versus 40K with 38K contiguous.l – supercat Jul 25 '23 at 22:45
  • @supercat Not sure what you talk about or where this information is originated. The expansion starts at $0800, right after the internal 2 KiB. That's where the Full BASIC puts it's included 2 KiB. Full BASIC ROM starts at $8000, thus allowing 32 KiB of RAM. – Raffzahn Jul 25 '23 at 23:06
  • The Max Machine was on the market in January of 1982, and the C64 in August of 1982. But they were largely designed concurrently. The Max started as a console using parts designed for the C64, but then the two proceeded in parallel almost until introduction. Very few Max machines were sold. The C64 did so well that almost as soon as it was introduced the Max was discontinued. They were limited by parts supply, and C64's sold for more money. – Jerry Coffin Jul 26 '23 at 02:42