| |
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 |
|
| |
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
|
| |
Trap
Registered: Jul 2010 Posts: 223 |
erhm, that example also uses DD00. Didn't make me any less confused :) |
| |
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. |
| |
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. |
| |
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;) |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
obviously you need to store the proper values so the other bits dont change =P |
| |
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. |
| |
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) |
| |
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 |