Hello,
I'm currently programming to let the C64 mode run in RAM Bank 1 and additionally have a piece of C128 software starting at Reset in C128 mode.
The problem is, that the Reset Vector of the C128, which resides at $FFF8/$FFF9 in Bank 1, is not protected. A solution involves switching on the Common Area from $FC00 to $FFFF with help of the MMU so that all writes in that area go to Bank 0 but this destroys the graphic display, because the VIC always only looks in RAM Bank 1.
My idea now was to move the zero Page (by help of register $D507) to $FF00, so that at the same time writes to $FF00-$FFFF would physically go to $0000-$00FF. By additionally switching on the Common area from $0000 to $0400, these writes would go automatically to Bank 0, so the reset vector is secure !
Moving the zero page in 64 mode works perfectly, but strangely only with zero page adresses smaller than $FC00 with the common area on !!!
Moving the zero page e.g. to $FF00 to Bank 1 with the common area from $0000 to $0400 enabled in C64 mode, has the effect that reads from Kernal ROM from $ff00 to $ffff will result in ROM accesses from $AF00 and $AFFF instead !!
Obviously, the C64 mode won't work this way, because it won't find the correct kernal.
Here is a sample code (for the built-in machine monitor) Start this program with "g 11300" and it will crash because it doesn't find the reset code for C64 mode at $FFFC but instead some Basic ROM. But moving the zeropage to $4000 works without problems ! (which doesn't help to protect the C128 Reset vector)
A 11300 sei
lda #$40
sta $ff00
lda #$01
sta $d50a
sta $d509
sta $d508
lda #$ff 'Replace with "lda #$40" and it works !
sta $d507
lda #$44
sta $d506
lda #$e3
sta $01
lda #$2f
sta $00
lda #$f7
sta $d505
jmp ($fffc)
Anyone can explain why the C128 is accessing $Af00 to $AFFF instead $FF00 to $FFFF in this configuration in C64 mode ? - Can it be avoided somehow ?
Many thanks,
Günther Walter, Vienna.