Wednesday, May 1, 2024

C64 RAM locations for programmable characters

 


Taking the information from Jim Butterfield's interactive program we can determine a few optimal choices for configuring the location of video and character set memory.  They both need to be in the same 16K bank of the C64 memory, video memory needs to be accessible to the KERNAL, and some locations are off limits (offsets $1000-$1FFF within VIC-II 16K banks 0, 2) because the VIC-II only sees D000-DFFF ROM characters there.

Option 1: easiest, video $0400, chars $2000-$2FFF

Option 2: least BASIC free, video $8C00, chars $A000-$AFFF

Option 3: largest free, video $CC00, chars $F000-$FFFF


Option 4: single charset, video $C400, chars $C800-$CFFF


Thanks to Jim Butterfield's SCREENMAP 64 program, it prompts for you to choose between valid options, and then calculates the register and screen page values that you need to change(poke).  Shown above are details for the four options that seem best.  The first three allow for two full sets of characters.  The last one allows for a single character set, or one and a half character sets.

In addition to the steps shown, it may be necessary to install an NMI handler to keep the values set instead of reset to ROM defaults, and it will be necessary to load a font into the desired programable character set address range.

Options 3 and 4 are interesting because they both increase BASIC RAM by 1K more than normal by moving video screen memory elsewhere. Option 1 is the easiest to implement, so is perfect for getting started.


Notes:

1000-1FFF not available for VIC because maps to D000 ROM
5000-5FFF not available for VIC because maps to D000 ROM
9000-9FFF not available for VIC because maps to D000 ROM
D000-DFFF not available for VIC because maps to D000 ROM

C000-CFFF not recommended for prog. chars. because other RAM in that bank not usually available to KERNAL needed for video screen characters.   So if screen characters are there, only room for one set (2K) instead of two sets (4K)

Option 0 (Normal)
0400-07FF screen memory (1K) = 1024
0800-9FFF BASIC RAM (38K) 
C000-CFFF free (4K)
D000-DFFF character ROM banked under I/O

Option 1 (First 16K)
0400-07FF screen memory (1K) = 1024
0800-1FFF free (6K)
2000-2FFF prog. chars. (4K) = 8192
3000-9FFF BASIC RAM (28K)

4000-7FFF is smack dab in the middle of BASIC RAM, seems like a bad idea unless used with 6502 machine language or other assets around it, and not strictly BASIC.

Option 2 (Third 16K)
0400-8BFF BASIC RAM (34K)
8C00-8FFF screen memory (1K) = 35840
9000-9FFF free (4K)
A000-AFFF prog. chars in RAM bank under BASIC ROM = 40960

Option 3 (Fourth 16K)
0400-9FFF BASIC RAM (39K)
C000-CBFF free (3K)
CC00-CFFF screen memory (1K) = 52224
E000-EFFF = 57344 prog. chars in RAM bank under KERNAL ROM *or* F000-FFFF = 61440 *or* under CHAR ROM D000-DFFF = 53248

Option 4 (Fourth 16K)
0400-9FFF BASIC RAM (39K)
C000-C3FF free (1K) or half lowercase character set (no inverse characters)
C400-C7FF screen memory (1K) = 50176
C800-CFFF prog. chars (1 set, 2K only) = 51200


5 comments:

  1. Where does one get this Butterfield program?

    ReplyDelete
    Replies
    1. https://www.commodoreserver.com/PublicDiskDetails.asp?DID=EC0674DABF2E45E08351068F3417F63E

      Delete
  2. > "and some locations are off limits (offsets $1000-$1FFF within the bank) because the VIC-II only sees D000-DFFF ROM characters there"

    Why?

    Also, in this next bit, are these supposed to be offsets?
    >1000-1FFF not available for VIC because maps to D000 ROM
    >5000-5FFF not available for VIC because maps to D000 ROM
    >9000-9FFF not available for VIC because maps to D000 ROM
    >D000-DFFF not available for VIC because maps to D000 ROM

    Why on earth would this even happen?

    ReplyDelete
  3. Commodore 64 Programmer's Reference Guide says this happens for (16K) banks 0 & 2 only. [actually I need to revise if I got it wrong.] ROM characters need to work, so that's how it works. ROM characters needs to be selectable somehow, that's how the VIC-II was designed by Albert Charpentier and team at Commodore. Otherwise you'd see garbage turning on the C64. It's a challenge you just have to get around.

    ReplyDelete
  4. Binary AND with $3FFF to get the offsets. I think in terms of overall addresses, so I went that way.

    ReplyDelete