Re: [stella] redundant bankswitching advice

Subject: Re: [stella] redundant bankswitching advice
From: Christopher Tumber <christophertumber@xxxxxxxxxx>
Date: Tue, 16 Dec 2003 22:41:54 -0500
Aaron wrote:

>Can anyone tell me what's incorrect in this file and why it works anyway?

I believe the problem is:

	org $1fea
	rorg $dfea
Start2
	LDX $1ff9

Which means Bank 2 will start executing at address $xFED (Changing banks does not affect registers, including the program counter)

However, your code around there in Bank 2 is:

	org $2ff0   ;other bank start
	rorg $fff0  ;
	jmp Start

And there's nothing actually at $xFED (aka $2fed aka $ffed)

So, when your program switches to Bank 2, it presumably hits a BRK ($00). Hitting a BRK causes the program to jump through the BRK vector at $fffe which is where your code has:

	org $2ffc
	rorg $fffc
	.word Start
	.word Start

So hitting the BRK has the unintended side effect of sending your program to the start of Bank 2 which is what you really want and "looks right" so it still works okay.

Similarily, when switching from Bank 2 to Bank 1, there's also nothing at the destination. (Except more BRKs)

There have been a couple 8k bankswitching templates posted to the mailing list (Manuel posted the first one and I posted a revised version that I think is a little cleaner and more straightforeward). You should check those out.

Essentially what you're doing is performing a JMP to a destination where there is no code. When you switch banks, your code continues on from the same point, not at the start of the other bank. So you need to continue your code in the new bank from this spot.


Chris...



----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread