| |
El Stocko
Registered: Jul 2006 Posts: 16 |
Bank switching and C000 - CFFF
Apologies if this is basic knowledge, but this is something that's caught me out and from the info I've seen online, I don't properly understand why it happens..
Existing code that I've been referencing switches off all ROM banks..
LDA #$30
STA $01
Absolutely fine, but when I was replicating this code at C000, my code would crash every time. It took me a long time to figure out that switching off all ROMS seems to work anywhere in memory EXCEPT if your code is running at C000-CFFF. According to the Mode Table outlined at https://www.c64-wiki.com/wiki/Bank_Switching C000-CFFF is always RAM unless there's a cartridge, and the Bank Switching Zones section lists it as RAM or "unmapped", whatever that means.
Maybe I haven't Googled the right thing, but I haven't seen anything that says switching off ROMS should affect C000-CFFF. Can some genius explain this to me please? :) |
|
| |
TWW
Registered: Jul 2009 Posts: 543 |
If memory serves, use:
lda #$34
sta $01
to bank 64k ram.
Use #$35 if your code uses IO @ $d000 - dfff.
However it's 6:55 in the morning so excuse me if it's wrong... |
| |
chatGPZ
Registered: Dec 2001 Posts: 11293 |
My guess would be that you don't disable interrupts, and thats why it crashes :) |
| |
tlr
Registered: Sep 2003 Posts: 1762 |
Quoting El StockoAbsolutely fine, but when I was replicating this code at C000, my code would crash every time. It took me a long time to figure out that switching off all ROMS seems to work anywhere in memory EXCEPT if your code is running at C000-CFFF.
This implies (but doesn't spell out) that you tested this exact same code in several other places. Did you do that? |
| |
Martin Piper
Registered: Nov 2007 Posts: 699 |
Quote: Apologies if this is basic knowledge, but this is something that's caught me out and from the info I've seen online, I don't properly understand why it happens..
Existing code that I've been referencing switches off all ROM banks..
LDA #$30
STA $01
Absolutely fine, but when I was replicating this code at C000, my code would crash every time. It took me a long time to figure out that switching off all ROMS seems to work anywhere in memory EXCEPT if your code is running at C000-CFFF. According to the Mode Table outlined at https://www.c64-wiki.com/wiki/Bank_Switching C000-CFFF is always RAM unless there's a cartridge, and the Bank Switching Zones section lists it as RAM or "unmapped", whatever that means.
Maybe I haven't Googled the right thing, but I haven't seen anything that says switching off ROMS should affect C000-CFFF. Can some genius explain this to me please? :)
Post a link of the executable and it'll probably be easy to spot why. :) |
| |
El Stocko
Registered: Jul 2006 Posts: 16 |
Thanks for the responses guys. Sorry, I think I messed up.
@TWW Yeah, I'm ok with the basics of bank switching, it's just in my instance I actually need to use $30.
@Groepaz I did mean to add to my post that interrupts are disabled.
@tlr/@Martin Piper - I did a simple test in VICE with dummy code in several places and after seeing that is what led to me posting here. Embarrasingly, I've just tried the same test again and it's fine so I must have somehow messed up the test last night :(( What I'm doing actually relies on a real C64 with a Tapecart.. yes I know that has its own $01 implications but that's not the problem in this case.
So I still have the problem, but probably not what I described above. I need to have a rethink. |
| |
Martin Piper
Registered: Nov 2007 Posts: 699 |
In Vice monitor (alt-M) using "watch load fffa ffff" will definitely trigger if the code tries to use an IRQ/NMI/BRK.
If that triggers, you can use "chis 10" to show the last 10 instructions before it entered the IRQ/NMI/BRK.
The Tapecart isn't in ULTIMAX mode is it? |
| |
chatGPZ
Registered: Dec 2001 Posts: 11293 |
Tapecart connects to the tape port.... :) |
| |
Martin Piper
Registered: Nov 2007 Posts: 699 |
Quote: Tapecart connects to the tape port.... :)
Ah ha, the name is a very misleading thingy. |
| |
El Stocko
Registered: Jul 2006 Posts: 16 |
Yeah, when is a cart not a cart? :)
I think I've sorted my problem, and the bank switching was a complete red herring. Sorry, it was late last night when I was looking at it and it was my messed up VICE test that prompted me to post. Turns out it came down to a BEQ instead of a BNE. Doh!
Thanks for the tip on IRQ though Martin, I'll keep it in mind for the future and I do need to make more use of chis |
| |
oziphantom
Registered: Oct 2014 Posts: 488 |
BTW unmapped means "no internal chips will respond to the address"
so when you are in that mode, accessing C000 will not reference any internal chip, i.e it is "open bus", unless you have something one the expansion port that does react to the address. |
... 5 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 - Next |