Jump to content
IGNORED

Writing code for different bankswitching types?


Recommended Posts

For the program I am writing, I need as much ROM space as possible, and a 512KB Tigervision 3F seems to be my best option. Is there some sort of option I need to set in DASM? Are there any 3F samples so I can see how it's done? None of the tutorials I have seen touch on this topic.

Link to comment
Share on other sites

If you're writing your program in assembly, there's no switches to set-- just make sure the ROM image will be the desired size based on the ORG and RORG addresses in your code, and access the necessary bank-switching hot spots for the type of bank-switching you want to use.

 

On an actual cart, the bank-switching is determined by the cart itself-- i.e., the ROM chip(s), the way the address lines of the cart are wired, etc.-- rather than anything to do with the program per se.

 

Stella and other emulators will either need to be told what type of bank-switching to use with the ROM, or else will try to determine the appropriate bank-switching based on things like the ROM size and the way certain memory locations (i.e., possible bank-switching hot spots) are used/initialized.

 

If you're programming in batari Basic, you'll need to set the romsize for the desired bank-switching, so the batari Basic compiler will know how to set the ORG/RORG addresses in the assembly code that's compiled from your batari Basic code, as well as how to declare the hot spots.

Link to comment
Share on other sites

Ok, I've taken a look at the 3F bankswitching example, and this is my understanding of what I need to do for a 512K ROM: The stuff I want in the fixed page goes in the last 2K bank, including the initialization vectors. Then I put the rest of my data in the lower 255 blocks of 2K. To switch banks, I write the number of the bank I want to $3F. Please correct me if I am wrong.

 

I will only have code in the fixed 2K bank, and the rest will be data that I don't plan on changing often, so I plan on generating the 255*2048 byte data section separately, and then concatenating it with a 2KB ROM I assemble.

 

Also, is bank switching instantaneous once you write to $3F?

Link to comment
Share on other sites

It'll practically always be the case of a fixed bank at the top of memory, otherwise you need to have system vectors for $FFFA-$FFFF in every bank that could appear there.

 

Switching should be instant - generally you'd switch banks from code running outside the bank at the time but it can be a valid technique to switch from within the switchable area and have code that "falls through" ie- continues executing from just after the part that switched the bank, although usually a faster way of doing things can potentially be a pain to debug.

 

Someone else might give more accurate info but AFAIK most/all bankswitching on 2600 carts will activate by a read access to the relevant area since the cart has no write line.

Link to comment
Share on other sites

it can be a valid technique to switch from within the switchable area and have code that "falls through" ie- continues executing from just after the part that switched the bank,

 

With the "fall through" technique where you're switching banks from within a switchable area-- which is the only way to do it if you're using bank-switching schemes that switch all 4K of the cartridge area-- it's usually best to put the bank-switching code at the same spot in all of the banks. That isn't as fast as switching from anywhere in the area, since-- depending on how you do it-- you must JMP or JSR or RTS to get to the where the bank-switching code is, which can also involve some preparation to set things up, and there's also the need to JMP or JSR or RTS from the bank-switching code to wherever the target routine is.

Link to comment
Share on other sites

Ok, I've taken a look at the 3F bankswitching example, and this is my understanding of what I need to do for a 512K ROM: The stuff I want in the fixed page goes in the last 2K bank, including the initialization vectors. Then I put the rest of my data in the lower 255 blocks of 2K. To switch banks, I write the number of the bank I want to $3F. Please correct me if I am wrong.

 

I will only have code in the fixed 2K bank, and the rest will be data that I don't plan on changing often, so I plan on generating the 255*2048 byte data section separately, and then concatenating it with a 2KB ROM I assemble.

 

Also, is bank switching instantaneous once you write to $3F?

 

You might want to consider using the 3E bank-switching method-- essentially the same as 3F, but writing to $3E lets you select one of up to 256 banks of 1K expansion RAM, so the maximum is 512K ROM and 256K RAM. Also, the bank-switching hotspots are limited to just $3E and $3F-- in the original 3F scheme, writing to any address from $00 to $3F triggered a switch. And I might be mistaken, but I think the original 3F scheme didn't actually go up to 512K ROM-- although I don't see why that would have been a limitation of the scheme itself, so it might have simply been that no cartridges using the 3F scheme ever went past a certain amount of ROM for monetary reasons. And of course if you do decide to use the 3E scheme, you don't need to use 512K of ROM and 256K of RAM.

Link to comment
Share on other sites

You might want to consider using the 3E bank-switching method-- essentially the same as 3F, but writing to $3E lets you select one of up to 256 banks of 1K expansion RAM, so the maximum is 512K ROM and 256K RAM. Also, the bank-switching hotspots are limited to just $3E and $3F-- in the original 3F scheme, writing to any address from $00 to $3F triggered a switch. And I might be mistaken, but I think the original 3F scheme didn't actually go up to 512K ROM-- although I don't see why that would have been a limitation of the scheme itself, so it might have simply been that no cartridges using the 3F scheme ever went past a certain amount of ROM for monetary reasons. And of course if you do decide to use the 3E scheme, you don't need to use 512K of ROM and 256K of RAM.

Interesting. So 3E is a superset of 3F? I don't think I'll need it thouhgh it's good to have the option available. I've got everything I want stored in a 512K 3F ROM and Stella runs it fine. I think you're right about no actual 512K cartridges being produced though. When it's finished, my program will probably only ever be run on real hardware (if it ever does) through a flashcart.
Link to comment
Share on other sites

So 3E is a superset of 3F?

 

I don't think "superset" is the right term-- I guess it would be if not for the change to the hotspots. It's my understanding that with the original version of 3F, accessing any location from $00 through $3F would switch banks-- so any 3F games that switched ROM banks by accessing $00 through $3E wouldn't be a subset of 3E. I don't know whether any 3F games actually accessed $00 through $3E to switch banks, at least deliberately-- but it could certainly happen by accident if the programmer tried to access a TIA register and forgot to use an address higher than $3F.

Link to comment
Share on other sites

I've figured out a use for the additional RAM in the 3E cartridges. The problem is, I need to use 256K of it, and Stella seems to be limiting me to only 32K of RAM. Writing 32-255 to $3F just switches me to the respective bank from 0-31. Is there a setting I have to change to enable all 256 banks of RAM?

Edited by fb39ca4
Link to comment
Share on other sites

Armin Vogel and I designed the 3E scheme. It was the preliminaries for writing Boulder Dash. The scheme itself is limited to 480K (from memory) to make it compatible with running on the Cuttle Cart. The idea is that 32K of the CC was needed to implement the RAM, and hence the rest could be ROM. So there, in one go, is your reason for the 32K RAM limit and the 480K ROM limit. 480+32 = 512K, the CC capacity. However, in principle, the 3E could handle 256 ROM banks and 256 RAM banks. In short, it would be a trivial modification to Stella to allow bank support for > 32 RAM banks, but if it's not working now then it's probably specifically restricted to ensure compatibility with the strict definition of the bankswitch scheme capabilities.

Cheers

A

Link to comment
Share on other sites

But if the limitations were related to using 3E bankswitching on a Cuttle Cart, does that mean an actual 3E cartridge could have 512K ROM and 256K RAM? If so, it would be nice for Stella to support that, in case anyone ever wants to develop a 3E game with 512K ROM and 256K RAM.

Link to comment
Share on other sites

An actual cartridge could have 512K ROM and 256K RAM, but then it wouldn't, strictly speaking, be a 3E format cartridge.

The bankswitch scheme was, to keep compatibility with Cuttle Cart capability, 480K max ROM and 32K max RAM.

If you want to go the whole hog, then technically it's a different scheme. 3E(b) or something.

Cheers

A

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...