7

My question is about bankswitching behaviour on the Commodore 64.

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):

Bank Switching table summarised https://www.c64-wiki.com/wiki/Bank_Switching

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.)

6

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? – Raffzahn Feb 11 '18 at 12:48
  • 2
    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. – Janka Feb 11 '18 at 13:05
  • 1
    From CPU view, there's nothing but RAM in the $1000..$1fff either. But the PLA does make a distinction between CPU and VIC access. For the VIC, the RAM/ROM select depends on the CIA2 Bit 0 and A12/A13 only. So, for the CPU, the RAM at $d000..$dfff is hard to use, because it overlaps the I/O area. But for the VIC it doesn't matter so it's a good idea to put your RAM character generator/sprites there. – Janka Feb 11 '18 at 13:23
  • 2
    Feel free to downvote, edit, delete, whatever, my answer. – Janka Feb 11 '18 at 13:27
  • 3
    And I thought it was a good answer. – Janka Feb 11 '18 at 14:09
3

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.

  • 1
    > 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. Smith Feb 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. – Raffzahn Feb 10 '18 at 18:52
  • 2
    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. – Janka Feb 10 '18 at 18:52

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.