9

I'm trying to understand how video memory worked on the Commodore64 in text mode. I see that the VIC-II has a memory setup register (at $D018) that keeps track of some of this information along with the CIA 2's VIC Memory Bank register (at $DD00).

In looking at this description of the C64 memory map, I'm a little confused about what the combination of these 2 registers is pointing at. I think I understand how to construct the appropriate pointer from those values, but I don't think I understand what it's pointing to. I'm wondering if anyone can elucidate this for me?

The memory bank appears to be a pointer to one of 4 16k-aligned areas of memory. The Memory Setup Register is a (bit-shifted) offset from that. It says this about the the memory setup register:

Memory setup register. Bits:

    Bits #1-#3: In text mode, pointer to character memory (bits #11-#13), relative to VIC bank, memory address $DD00. Values:

        %000, 0: $0000-$07FF, 0-2047.

        %001, 1: $0800-$0FFF, 2048-4095.

        %010, 2: $1000-$17FF, 4096-6143.

        %011, 3: $1800-$1FFF, 6144-8191.

        %100, 4: $2000-$27FF, 8192-10239.

        %101, 5: $2800-$2FFF, 10240-12287.

        %110, 6: $3000-$37FF, 12288-14335.

        %111, 7: $3800-$3FFF, 14336-16383.

Values %010 and %011 in VIC bank #0 and #2 select Character ROM instead.

What is "character memory" in this case? Is it some sort of bitmap of what each character should look like, or is it the encoding of actual characters that are on the screen? (Like when you do POKE 1024,1 and it puts an "A" in the upper left of the screen?) The reason I'm confused is because each range is 2 kilobytes, and that seems too little for character bitmaps (only 64 characters) and too big for the number of characters displayed on screen (which can only fit 1000 characters).

  • each char is only 8 bytes, so 256 will fit into a 2k space. – Joe Jul 10 at 22:59
  • Oh! OK, that makes more sense. Would you care to expand that into an answer and explain the format of each 8-byte character? (I assume by character you mean what we'd call a glyph today? i.e. the form of the letter?) – user1118321 Jul 10 at 23:01
  • my details are hazy, so i was waiting to see if one of the folks better versed would chime in with a "real" answer. – Joe Jul 11 at 1:27
  • You might want to take a look at Compute's! First Book of Commodore 64 Sound and Graphics (available here: archive.org/details/…). The book offers very simple and clear explanations for graphics programming on your 64. – Geo... Jul 11 at 11:38
  • @Geo... Thank you so much! That looks very helpful! – user1118321 Jul 12 at 1:26
9

"Character memory" is the bitmapped definitions for each of the characters (e.g. "glyphs") that are displayed in text mode, based on the "character codes" that are poked into the "screen memory".

Depending on which graphics mode you enable, there are several different memory areas that will be accessed by the VIC-II in creating the display. If we only focus on text mode (ignoring bitmapped graphics mode), then the relevant memory areas are:

  1. VIC-II bank - specifies which 16KB bank of the memory map is used by the VIC-II. Default is $0000-$3FFF, and depends on bits 0/1 in $DD00.
  2. Screen memory - for text mode, this is the 1KB used to hold the character codes for each character in the 40x25 screen. Default is $0400-$07FF and depends on bits 4-7 of $D018, given as an offset to the VIC-II bank.
  3. Character memory - for text mode, this is the 2KB used to hold the glyph data for the 256 possible characters, where each character is an 8x8 bitmap. Default is the Character ROM data $D000-$D7FF and depends on bits 1-3 of $D018, also given as an offset. Special provisions are made to tell the VIC-II to use the character ROM vs. user-defined characters in the VIC-II bank memory.
  4. Color memory - for text mode, this is the 1KB used to hold the (normally foreground) color code for each character specified in screen memory. Only the lower nibble is used to specify 1 of 16 possible colors per character glyph. Color memory is always located at $D800-$DBFF.

There are additional memory areas and "complexifiers" if you enable multicolor and bitmap modes.

  • Thank you so much! That helps enormously and makes sense. I'll probably be asking about bitmap mode in the near future. :-) – user1118321 Jul 11 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.