Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Bank switching with fastloaders
2015-08-13 19:35
Trap

Registered: Jul 2010
Posts: 223
Bank switching with fastloaders

Hi,

I've decided that I want to use Spindle for my little project, but I can't seem to get this bank switching done right.

So, normally we bank switch using DD00, but as I read from the documentation (and pretty much everywhere else when fastloaders are mentioned) we should use DD02 for switching instead.

Now, if I just do
lda #$3d
sta $dd02
that should switch the VIC to bank 1 ($4000-$7fff) right? (according to the spindle docs anyway) but that just doesn't happen.

The topic on this over on Codebase uses DD00 too. Looking at the memory map DD02 is 'Data Direction Register' and has absolutely nothing to do with VIC bank select. I'm confused. What am I missing here?

Thanks.
/Trap
2015-08-13 19:58
Peiselulli

Registered: Oct 2006
Posts: 81
Have a look at this example (ACME syntax)
    !cpu 6510
    !to "switch.prg",cbm
    
    * = $0801
    !byte $0b,$08,$01,$00,$9e,$32,$30,$36,$31,0,0,0
    sei    
    lda #$03
    ldx #$00
    stx $dd00
l1: sax $dd02
    ldy #$20
l2: bit $d011
    bpl l2
l3: bit $d011
    bmi l3
    dey
    bne l2
    inx
    jmp l1
2015-08-13 21:00
Trap

Registered: Jul 2010
Posts: 223
erhm, that example also uses DD00. Didn't make me any less confused :)
2015-08-13 21:04
Stone

Registered: Oct 2006
Posts: 172
I never knew about this trick. Pretty cool! I would guess that it only works with the bank selection bits of $dd00 set to 0 and that clearing a bit in $dd02 would cause the VIC chip to read a 1 from the corresponding bit in the bank selection register, otherwise the value from $dd00 is used.
2015-08-13 22:08
Peiselulli

Registered: Oct 2006
Posts: 81
Quote:
erhm, that example also uses DD00. Didn't make me any less confused :)

But only in the initialization before the loop.
2015-08-14 09:00
Copyfault

Registered: Dec 2001
Posts: 478
The "trick" is also used in several FLI-routines. It confused me, too, when I tried it for the first time.

To understand it, one has to know that 1. the vic bank bits of DD00 are low active and 2. the vic bank bits are "masked" depending on the corresponding data direction register DD02.

The "masking" works as already stated by Stein. Only the vic bits with a set mask bit in DD02 gets through. A cleared mask bit fixes the resulting bank selection bit to '1'.

If we want to know the no.of the selected vic bank, we have to take the "low activity" of the bank bits into account. This can be summarized e.g.with the following formula:
vic bank no. = (DD00 eor #$03) and DD02

Setting DD00:=0, the formula gives vic bank no.=DD02, so using DD02 for bank switching has the nice side effect that we can directly put the wanted vic bank no.into a reg and don't have to f**k around with any complements.

The following table shows all possible combinations of DD00/DD02 and the resulting vic bank selected.
  DD00   00   01   10   11
DD02
  00      0    0    0    0
  01      1    0    1    0
  10      2    2    0    0
  11      3    2    1    0


Hope this helps to get rid of the confusion;)
2015-08-14 10:03
Oswald

Registered: Apr 2002
Posts: 5094
I have met with this one when having trouble displaying interlaced pics with Krill's loader, however using this resulted in the same buggy loading instead of fixing it, so I like to think that this "trick" is essentially the same as setting dd00.
2015-08-14 10:12
chatGPZ

Registered: Dec 2001
Posts: 11386
obviously you need to store the proper values so the other bits dont change =P
2015-08-14 10:56
Frantic

Registered: Mar 2003
Posts: 1648
If someone wants to write something brief about this dd00/dd02 thing for codebase, please go ahead and do so. I think it would be useful.
2015-08-14 10:56
Oswald

Registered: Apr 2002
Posts: 5094
obviously you're trolling again. I wonder if you are aware of what you are doing. Its a sign of low self esteem, continously trying to proove everyone is an idiot (but you)
2015-08-14 11:03
Mixer

Registered: Apr 2008
Posts: 452
Didn't Krills loader have an option to put it in a mode so that it does not bother $dd00 writes? This was in some earlier Forum discussion about the subject.

There is a similar thing in the Poor/Bias Crusher fix loader. It sends a commmand to drive to put the drive code into a loop so that one do bank switching with 00 01 02 03 to $dd00 and 0 in the high bits does not bother the drive.

Drive code loop is waiting for specific value written to high bits of $dd00 and once it is received the drive code moves back to basic receiving loop.

Obviously that does not work if bank switching is needed while loading. For that one needs $dd02 or a loader that does lda bits OR #bank sta $dd00 or similar when transfering data.

Anyway, a good feature.
 
... 8 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
csabanw
Guests online: 98
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top NTSC-Fixers
1 Pudwerx  (10)
2 Booze  (9.7)
3 Stormbringer  (9.7)
4 Fungus  (9.6)
5 Grim Reaper  (9.3)

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