I've just recently started to mess about with 128k bank switching.
Am I correct when I say that Bank 0 is the default Bank paged at boot and can thus be freely translated (for my understanding) as "main memory"?
Regarding Bank 2: in the docs it says "also at 0x8000", which I discover to mean that everything you write to 49152 and up, will also appear at 32768 and up.
What surprises me though is that it seems that when switching back to Bank 0, whatever was also written to 32768 and up is not restored?
To test things, I created the following BASIC file:
Code: Select all
10 CLEAR 32767
15 REM Currently in Bank 0 - "Main Memory"
20 REM Print values at 32768 & 49152
30 GO SUB 160
40 REM Switch to bank 2
50 LET a=2+16
60 GO SUB 130
65 REM Put a value in bank, which will also be placed at shadow main RAM
70 POKE 49152,255
75 REM Print values at 32768 & 49152
80 GO SUB 160
85 REM Switch to bank 0 - main memory
90 LET a=0+16
100 GO SUB 130
105 REM Print values at 32768 & 49152
110 GO SUB 160
120 STOP
130 POKE 23388,a: OUT 32765,a
150 RETURN
160 PRINT "23388: ";PEEK 23388: PRINT "32768: ";PEEK 32768: PRINT "49152: ";PEEK 49152: PRINT
170 RETURN
Code: Select all
23388: 16
32768: 0
49152: 0
23388: 18
32768: 255
49152: 255
23388: 16
32768: 255
49152: 0
What is going on here?
PS: the way I discovered this is because I had corruption of my code between 32768-49152, when writing to 49152-65535.
Hadn't the corruption not been in text printed on screen but somewhere in my code area, I'd probably never have discovered why my code would crash...