Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Critikill (CK) ! (Registered 2024-09-19) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Bank switching and C000 - CFFF
2023-05-11 02:06
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? :)
2023-05-11 06:56
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...
2023-05-11 07:08
chatGPZ

Registered: Dec 2001
Posts: 11290
My guess would be that you don't disable interrupts, and thats why it crashes :)
2023-05-11 08:43
tlr

Registered: Sep 2003
Posts: 1762
Quoting El Stocko
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.

This implies (but doesn't spell out) that you tested this exact same code in several other places. Did you do that?
2023-05-11 09:04
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. :)
2023-05-11 10:57
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.
2023-05-11 11:59
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?
2023-05-11 12:11
chatGPZ

Registered: Dec 2001
Posts: 11290
Tapecart connects to the tape port.... :)
2023-05-11 13:29
Martin Piper

Registered: Nov 2007
Posts: 699
Quote: Tapecart connects to the tape port.... :)

Ah ha, the name is a very misleading thingy.
2023-05-11 14:21
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
2023-05-11 17:17
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
anonym/padua
MWR/Visdom
Guests online: 72
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 Comaland 100%  (9.6)
8 Wonderland XIV  (9.6)
9 No Bounds  (9.6)
10 Unboxed  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 It's More Fun to Com..  (9.5)
7 Morph  (9.5)
8 Dawnfall V1.1  (9.5)
9 Onscreen 5k  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Nostalgia  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.2)
Top Diskmag Editors
1 Magic  (9.8)
2 Jazzcat  (9.5)
3 hedning  (9.4)
4 Elwix  (9.1)
5 Remix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.055 sec.