I've been reading up on bank switching on Wiki and in particular here which contains the below nice image and have a few questions:

  1. Am I right in thinking that LOAD loads into RAM (dark grey in the image), ignoring any switched-in banks? For example if the .prg had header $01 $08 followed by 63486 zero's then LOAD would effectively zero fill the computers memory from $0801 onward? If I were to switch-out any of BASIC ROM, IO, or Kernal, for example, then PEEKing (LDAing) those areas would return zero?

  2. If I switch out BASIC ROM do I need to disable any interrupts at all?

  3. If IO and Kernal are not switched-out the CPU will see them and not the underlying RAM, but will the VIC see RAM there regardless? If so I was going to use $C000-$FFFF for graphics (character set and sprites) whilst keeping IO and Kernal switched-in for the CPU to see.

enter image description here

  • 1
    LOADing should write into RAM below ROM, except in the I/O area. I/O is writable too – Martin Maciaszek Dec 30 '20 at 10:49

1. Kinda

Any time the CPU writes to memory, it writes to RAM or I/O. Your example will zero out all the RAM, but also will zero any I/O locations. That's going to have the effect of disabling sprites, setting their colour to black, turning any sound off, etc etc. It might send a zero byte to the serial port or something as well, I'm a little hazy on exactly how that works. This is going to have an effect on loading from disk also.

So if you want to write anything into this region of RAM, then you can't do so directly from disk. You need to load it into some other region first, and then move it. (That's as well, since you probably want to decompress it etc).

But if the aim is just to load some data to be displayed, then you could try and fit it all into the upper 8 kilobytes and separately configure the VIC-II to display it.

2. No

The interrupt handlers are part of the KERNAL, and they don't depend on BASIC. The design of the C64 is precisely so that you can page BASIC out without having worry about that kind of thing. But if you want to page out the KERNAL, then of course you need to set up an interrupt handler first (or disable interrupts until you page KERNAL back in)

3. That's right.

The VIC-II's view of memory is completely different from the CPU's view of memory. If the VIC-II is set to bank 3 (starting at $C000), then it will see RAM all the way through those 16K. It'll be up to you to upload whatever charsets you want.

  • thanks @OmarL this seems a bit problematic.... if it's not possible to LOAD into bank 3 (since it will corrupt IO) then how can I upload my charsets/sprites to that area? Do you know of a solution to this? – Pixel Dec 30 '20 at 11:37
  • 2
    @Pixel — load them into some other area from disk, then move them under program control? – Michael Graf Dec 30 '20 at 11:54
  • 1
    As writing data to the $D000-$DFFF region is going to be picked up as I/O by on board and extension devices, the kernal routines cannot load into this space. You can guess what happens when the writes hit CIA registers as the serial bus loading itself is managed by a CIA, for example. If necessary you can load under the I/O space with your own loading routine, using the kernal to read one (or more) bytes, bank out the I/O, store the data, and bank I/O in again. If you don't need to load one continous block of data, it's easier and faster to just load it some place else and transfer it in code. – Retrograde Dec 30 '20 at 12:44

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.