Jump to content
IGNORED

Bankswitching question


Lumi

Recommended Posts

I'm currently experimenting with developing a new 2600 game, and I'm a little confused.

 

Basically, I'm writing a game in assembly and I want to use an 8K ROM size. I'd store important data in the first bank and level data in the second. In my research, I found this document:

http://kevtris.org/files/sizes.txt

Which lists different bankswitching methods. Very interesting to read, but I'm wondering, how do I specify which method I'm using to an emulator/flashcart? For example, I'm happy with just using the standard F8 method. If I start accessing $1FF8 or $1FF9 will the emulator/flashcart automatically catch on to what I'm trying to do, or is there more to this?

 

Also, which method is used by carts from the AtariAge store?

 

Thanks!

Edited by Lumi
Link to comment
Share on other sites

The document you referenced above is pretty old, but it does cover the bankswitching methods used by most legacy 2600 software. Atari's 8K games and most 8K homebrews use the standard Atari F8 bankswitching method as you've described above. You can also use Superchip (SARAM) RAM if you'd like, which is often referred to as the "F8SC" bankswitching method. This gives you an additional 128 bytes of RAM.

 

..Al

Link to comment
Share on other sites

Stella and Harmony will analyze the ROM to try to auto-detect which bankswitch method is being used. If the ROM is 8K in size Stella will run this bit of code:

  else if(size == 8*1024)  // 8K
  {
    // First check for *potential* F8
    uInt8 signature[] = { 0x8D, 0xF9, 0x1F };  // STA $1FF9
    bool f8 = searchForBytes(image, size, signature, 3, 2);

    if(isProbablySC(image, size))
      type = "F8SC";
    else if(memcmp(image, image + 4096, 4096) == 0)
      type = "4K";
    else if(isProbablyE0(image, size))
      type = "E0";
    else if(isProbably3E(image, size))
      type = "3E";
    else if(isProbably3F(image, size))
      type = "3F";
    else if(isProbablyUA(image, size))
      type = "UA";
    else if(isProbablyFE(image, size) && !f8)
      type = "FE";
    else if(isProbably0840(image, size))
      type = "0840";
    else
      type = "F8";
  }



Each of those "is probably" functions look for tell tale signs that an 8K image is not using the most common method of F8. This is the check it uses for 8K cartridges that use 3E:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::isProbably3E(const uInt8* image, uInt32 size)
{
  // 3E cart bankswitching is triggered by storing the bank number
  // in address 3E using 'STA $3E', commonly followed by an
  // immediate mode LDA
  uInt8 signature[] = { 0x85, 0x3E, 0xA9, 0x00 };  // STA $3E; LDA #$00
  return searchForBytes(image, size, signature, 4, 1);
}



while this is the check for UA:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge::isProbablyUA(const uInt8* image, uInt32 size)
{
  // UA cart bankswitching switches to bank 1 by accessing address 0x240
  // using 'STA $240' or 'LDA $240'
  uInt8 signature[3][3] = {
    { 0x8D, 0x40, 0x02 },  // STA $240
    { 0xAD, 0x40, 0x02 },  // LDA $240
    { 0xBD, 0x1F, 0x02 }   // LDA $21F,X
  };
  for(uInt32 i = 0; i < 3; ++i)
    if(searchForBytes(image, size, signature[i], 3, 1))
      return true;

  return false;
}



While rare, Stella can get it wrong. It does provide a way to override it:
  • hit the TAB key on your keyboard to open the in-game menu
  • click on Game Properties
  • Locate Type: at the bottom of the cartridge page.
  • Select correct bankswitch method.
  • Click OK
  • Click Exit Menu
  • Restart emulation by pressing CONTROL-R

Whenever you change something like that Stella keeps track of it and will remember it for next time. It uses the MD5 hash value of the ROM image for that, so you'll have to go through that process again if you make changes to your game.


Harmony doesn't have a menu you control that, instead you can override the auto-detect by using a specific file extension. From the manual:

Ext  Bankswitch_type
.2K  Atari 2K
.4K  Atari 4K (default)
.F8  Atari F8
.F8S Atari F8 with Superchip
.F6  Atari F6
.F6S Atari F6 with Superchip
.F4  Atari F4
.F4S Atari F4 with Superchip
.FA  CBS RAM +
.FE  Activision FE
.3F  Tigervision 3F
.3E  3E (3F with up to 4K RAM)
.E0  Parker Brothers E0
.E7  M-Network E7
.CV  CommaVid
.UA  UA Limited
.AR  Arcadia Supercharger
.DPC DPC (Pitfall 2)
.084 0840 Econobanking
.CU  Custom


If you'd like to see how Stella detects other types then download the source by following the instructions on this page.

  • Like 1
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...