Retrocomputing Stack Exchange is a question and answer site for vintage-computer hobbyists interested in restoring, preserving, and using the classic computer and gaming systems of yesteryear. Join them; it only takes a minute:

I'm writing a C64 game for a 16kb cartridge with EXROM and GAME pulled low, so the available bankswitching modes are (according to c64-wiki):

The VIC-II display registers are memory-mapped into $D000-$D3FF. On boot up, CHAREN, HIRAM and LORAM will all be 1, so the system will start in mode 7, with I/O access enabled within that memory region.

Does CPU access to the VIC-II registers fall under the category of I/O?

If I switch to mode 4 to allow access to the 'full' ~64kB of RAM, will I still be able to access VIC-II registers from the CPU, or will I have to switch to mode 5 to put I/O back into the memory map?

(Assume my code has been copied to some location in RAM first (e.g. $6000) at that point so it won't be affected by any mode changes.)

2 Answers
2

Does CPU access to the VIC-II registers fall under the category of I/O?

Yes. To access the RAM below the I/O, you have to use a function copied to RAM which does exactly that. A common use for that area however is to put a custom character generator and/or sprites there, because in the $4000..$7fff and $c000..$ffff area, the VIC always reads from RAM.

" in the $4000..$7fff [...] area, the VIC always reads from RAM." ? Err, what else should it read then RAM?
– RaffzahnFeb 11 '18 at 12:48

1

In the $1000..$1fff area, the VIC reads out the CHAR ROM, regardless of the CHAREN/HIRAM setting. Because the VIC only decodes 14 address bits, one could assume it's the same for $5000..5fff and $d000..$dfff, but in the odd 16K pages, it's always RAM.
– JankaFeb 11 '18 at 13:05

Hmm. How on this world could someone come to this conclusion? After all, there is noting but RAM in this area. Not to mention, that the Question was about the CPU's view, wasn't it?
– RaffzahnFeb 11 '18 at 13:20

Does CPU access to the VIC-II registers fall under the category of I/O?

Yes

If I switch to mode 4 to allow access to the 'full' ~64kB of RAM, will I still be able to access VIC-II registers from the CPU,

No, as you switched it off.

or will I have to switch to mode 5 to put I/O back into the memory map?

Exactly. Under on address(region) only one component can be reached at one time. So if you want to use the I/O, the 4 KiB at $Dxxx have to be switched to I/O (mode 5/6/7 of that table), and the RAM at this address will be invisible. If the RAM is accessible there (Mode 0/1/4), you won't see any registers.

Assume my code is running from $6000 at that point so it won't be affected by mode changes.

It's always a good idea not to switch of the active programm, isn't it?

> BTW: $6000 is not part of any cardridge ROM. - Yes, I know. :) If I want to access ram at $D000-DFFF, I will have to page the cartridge ROM out too: there's no mode where both the cartridge is active and the IO is switched out. So I'll have to copy some of my code to somewhere in RAM first.
– E. SmithFeb 10 '18 at 18:39

@E.Smith Well, if space is such a premium with your application, it may be more apropriate to think about the programm structure than doing much fliping just for 4 KiB.
– RaffzahnFeb 10 '18 at 18:52

1

You should use the RAM at $1000-$1ffff and $9000-$9fff for program code, because the VIC always reads the character generator ROM in these regions. In the ancient past, a cartridge would had it's own character generator at $9000-$9fff, but it's such a huge waste of space when it's not compressed on the cartridge not even Commodore did it that way in the later 4in1 cartridges.
– JankaFeb 10 '18 at 18:52