Jump to content
IGNORED

Atari 7800 Bankswitching Schemes


wavemotion

Recommended Posts

I continue to clean and refine the A7800DS emulator and am focused on ensuring my bank switching is handled correctly for future generations.

 

Ignoring the odd bank switching schemes of Absolute (F-18 Hornet) and Activision (Rampage and Double Dragon) and the one-off Rescue on Fractalus (mirrored RAM at 4000h)...

 

Here are the main 7800 Bankswitching schemes:

  • NORMAL           Anything 48K or less... fits into memory (0xffff downwards) without switching.
  • SUPERCART        Games that are 128+K in size with nothing mapped in at 0x4000
  • SUPERCART_LARGE  Games that are 144+K in size with the extra 16K bank 0 fixed at 0x4000
  • SUPERCART_RAM    Games that are 128+K in size with extra 16K of RAM at 0x4000
  • SUPERCART_ROM    Games that are 128+K in size with bank 6 fixed at 0x4000


For the "Super Carts" the 16K at 0xC000 is the last bank in the ROM.
For the "Super Carts" the 16K at 0x8000 is the bankswapping bank and is switched by writing the bank # to any address in that region.  For Supercart "Large" there are actually two chips (16K fixed and 128K bankswapped) and the bank is relative to the 128K chip so emulators will use (bank+1) to compensate for the extra 16K fixed bank 0 at 0x4000.

 

In theory, since we can write any bank number 0-255 that would allow up to 255 banks of 16k which is a whopping 4096K (4 Megabytes) of ROM but in practice carts seem to limit to 512K or less for practical reasons with a few outstanding tech-demos reaching 1024K. 

How I think these map into the .a78 header (the word at offset 53+54):
  bit 0     = pokey at $4000
  bit 1     = supergame bank switched     - this is SUPERCART
  bit 2     = supergame ram at $4000      - this is SUPERCART_RAM
  bit 3     = rom at $4000                - this is SUPERCART LARGE

  bit 4     = bank 6 at $4000             - this is SUPERCART_ROM
  bit 5     = banked ram                  - Unsure - see question below... is this XM RAM?
  bit 6     = pokey at $450
  bit 7     = mirror ram at $4000         - Unsure - assume this is just for Rescue on Fractalus
 
  bit 8     = activision banking
  bit 9     = absolute banking
  bit 10    = pokey at $440
  bit 11    = ym2151 at $460/$461

  bit 12    = souper
  bit 13    = banksets
  bit 14    = halt banked ram             - Unsure
  bit 15    = pokey@800


 If none of those bankswitching bits are set... assume NORMAL (unless cart > 64K in which case assume SUPERCART).

 

So my questions are mainly this: 

 

  1. Is my understanding of the Supercarts mapped to A78 header bits accurate?
  2. What is the banked ram bit? Is that XM RAM? Does anything take advantage of this (seems most anything that requires more RAM uses the 16K at 4000h option).
  3. What is the mirror ram bit... is that just to handle Fractalus?
  4. What is the halt banked ram bit?
  5. Any other obvious things I've got mixed up / wrong in any of the above?

 

Thanks in advance for any insights the community has!

  • Like 1
Link to comment
Share on other sites

5 hours ago, llabnip said:

I continue to clean and refine the A7800DS emulator and am focused on ensuring my bank switching is handled correctly for future generations.

 

Ignoring the odd bank switching schemes of Absolute (F-18 Hornet) and Activision (Rampage and Double Dragon) and the one-off Rescue on Fractalus (mirrored RAM at 4000h)...

 

Here are the main 7800 Bankswitching schemes:

  • NORMAL           Anything 48K or less... fits into memory (0xffff downwards) without switching.
  • SUPERCART        Games that are 128+K in size with nothing mapped in at 0x4000
  • SUPERCART_LARGE  Games that are 144+K in size with the extra 16K bank 0 fixed at 0x4000
  • SUPERCART_RAM    Games that are 128+K in size with extra 16K of RAM at 0x4000
  • SUPERCART_ROM    Games that are 128+K in size with bank 6 fixed at 0x4000


For the "Super Carts" the 16K at 0xC000 is the last bank in the ROM.
For the "Super Carts" the 16K at 0x8000 is the bankswapping bank and is switched by writing the bank # to any address in that region.  For Supercart "Large" there are actually two chips (16K fixed and 128K bankswapped) and the bank is relative to the 128K chip so emulators will use (bank+1) to compensate for the extra 16K fixed bank 0 at 0x4000.

 

In theory, since we can write any bank number 0-255 that would allow up to 255 banks of 16k which is a whopping 4096K (4 Megabytes) of ROM but in practice carts seem to limit to 512K or less for practical reasons with a few outstanding tech-demos reaching 1024K. 

How I think these map into the .a78 header (the word at offset 53+54):
  bit 0     = pokey at $4000
  bit 1     = supergame bank switched     - this is SUPERCART
  bit 2     = supergame ram at $4000      - this is SUPERCART_RAM
  bit 3     = rom at $4000                - this is SUPERCART LARGE

  bit 4     = bank 6 at $4000             - this is SUPERCART_ROM
  bit 5     = banked ram                  - Unsure - see question below... is this XM RAM?
  bit 6     = pokey at $450
  bit 7     = mirror ram at $4000         - Unsure - assume this is just for Rescue on Fractalus
 
  bit 8     = activision banking
  bit 9     = absolute banking
  bit 10    = pokey at $440
  bit 11    = ym2151 at $460/$461

  bit 12    = souper
  bit 13    = banksets
  bit 14    = halt banked ram             - Unsure
  bit 15    = pokey@800


 If none of those bankswitching bits are set... assume NORMAL (unless cart > 64K in which case assume SUPERCART).

 

So my questions are mainly this: 

 

  1. Is my understanding of the Supercarts mapped to A78 header bits accurate?
  2. What is the banked ram bit? Is that XM RAM? Does anything take advantage of this (seems most anything that requires more RAM uses the 16K at 4000h option).
  3. What is the mirror ram bit... is that just to handle Fractalus?
  4. What is the halt banked ram bit?
  5. Any other obvious things I've got mixed up / wrong in any of the above?

 

Thanks in advance for any insights the community has!

Stock can also be 52K.

  • Like 1
Link to comment
Share on other sites

5 hours ago, llabnip said:

I continue to clean and refine the A7800DS emulator and am focused on ensuring my bank switching is handled correctly for future generations.

 

Ignoring the odd bank switching schemes of Absolute (F-18 Hornet) and Activision (Rampage and Double Dragon) and the one-off Rescue on Fractalus (mirrored RAM at 4000h)...

 

Here are the main 7800 Bankswitching schemes:

  • NORMAL           Anything 48K or less... fits into memory (0xffff downwards) without switching.
  • SUPERCART        Games that are 128+K in size with nothing mapped in at 0x4000
  • SUPERCART_LARGE  Games that are 144+K in size with the extra 16K bank 0 fixed at 0x4000
  • SUPERCART_RAM    Games that are 128+K in size with extra 16K of RAM at 0x4000
  • SUPERCART_ROM    Games that are 128+K in size with bank 6 fixed at 0x4000


For the "Super Carts" the 16K at 0xC000 is the last bank in the ROM.
For the "Super Carts" the 16K at 0x8000 is the bankswapping bank and is switched by writing the bank # to any address in that region.  For Supercart "Large" there are actually two chips (16K fixed and 128K bankswapped) and the bank is relative to the 128K chip so emulators will use (bank+1) to compensate for the extra 16K fixed bank 0 at 0x4000.

 

In theory, since we can write any bank number 0-255 that would allow up to 255 banks of 16k which is a whopping 4096K (4 Megabytes) of ROM but in practice carts seem to limit to 512K or less for practical reasons with a few outstanding tech-demos reaching 1024K. 

How I think these map into the .a78 header (the word at offset 53+54):
  bit 0     = pokey at $4000
  bit 1     = supergame bank switched     - this is SUPERCART
  bit 2     = supergame ram at $4000      - this is SUPERCART_RAM
  bit 3     = rom at $4000                - this is SUPERCART LARGE

  bit 4     = bank 6 at $4000             - this is SUPERCART_ROM
  bit 5     = banked ram                  - Unsure - see question below... is this XM RAM?
  bit 6     = pokey at $450
  bit 7     = mirror ram at $4000         - Unsure - assume this is just for Rescue on Fractalus
 
  bit 8     = activision banking
  bit 9     = absolute banking
  bit 10    = pokey at $440
  bit 11    = ym2151 at $460/$461

  bit 12    = souper
  bit 13    = banksets
  bit 14    = halt banked ram             - Unsure
  bit 15    = pokey@800


 If none of those bankswitching bits are set... assume NORMAL (unless cart > 64K in which case assume SUPERCART).

 

So my questions are mainly this: 

 

  1. Is my understanding of the Supercarts mapped to A78 header bits accurate?
  2. What is the banked ram bit? Is that XM RAM? Does anything take advantage of this (seems most anything that requires more RAM uses the 16K at 4000h option).
  3. What is the mirror ram bit... is that just to handle Fractalus?
  4. What is the halt banked ram bit?
  5. Any other obvious things I've got mixed up / wrong in any of the above?

 

Thanks in advance for any insights the community has!

The banked RAM bit just means 32K in super with the 5th bit of the bank byte being used for the RAM  bank number.

  • Like 1
Link to comment
Share on other sites

Have a look through TailChao's excellent old world a78 format primer, which may also help to underline things.

 

Some quick answers to your questions:

7 hours ago, llabnip said:
  1. Is my understanding of the Supercarts mapped to A78 header bits accurate?

Looks right to me. The one thing I should point out is that the bit you've called SUPERCART will be set, in addition to any other of the ones being used that start with  "SUPERCART_". Additionally, the one you've labelled SUPERCART_RAM (aka RAM@4000, aka EXRAM) isn't exclusive to the Supergame format. A 32k flat game could also flag this bit to get ram from 4000-7FFF.

 

7 hours ago, llabnip said:
  1. What is the banked ram bit? Is that XM RAM? Does anything take advantage of this (seems most anything that requires more RAM uses the 16K at 4000h option).

Banked ram was a feature of a few CPUWIZ supergame format boards, but I don't believe there are any released roms that use it. The top bits of the bankswitch value will switch between different 16k banks.

 

7 hours ago, llabnip said:
  1. What is the mirror ram bit... is that just to handle Fractalus?

Yes. It's possible it might be used in the future for homebrew, as it's useful for ram-based bitmap games.

 

7 hours ago, llabnip said:
  1. What is the halt banked ram bit?

It's referring to ram that works with the bankset format, providing one 16k bank of ram to Sally, and another 16k bank of ram to Maria. The halt line controls the bankswitch. 

 

  • Like 2
Link to comment
Share on other sites

30 minutes ago, RevEng said:

Banked ram was a feature of a few CPUWIZ supergame format boards, but I don't believe there are any released roms that use it. The top bits of the bankswitch value will switch between different 16k banks.

DragonFly (after last update) and SN cart is already using something similar.

2x16KB RAM hotspot $FFFF bit D0=0 first RAM bank, bit D0=1 second RAM bank

@playsoft used in extended version of 1942 for additional Pokey music.

  • Like 2
Link to comment
Share on other sites

Okay... I read that a78 primer a few times - just awesome information. What a great resource!

 

So as not to spam the threads with yet more questions, I'll just tack on a follow-up question here.

 

For the POKEY enabled games... do any games use the POTs?  I assume not - since there wouldn't really be anything to connect them to inside the cart (i.e. it's more useful when the Pokey is built into the machine where it can handle some IO). Mainly asking so I can remove some POKEY POT handling from my emulator to give it a tiny speed boost. I know some games use the RANDOM feature and, obviously, the 4 sound channels but I haven't come across anything that is hitting the POT registers.  How reasonably safe is it to remove that from emulation to speed up processing?

 

 

  • Like 1
Link to comment
Share on other sites

I'm pretty sure that there aren't  any existing 7800 pokey-cart games that connect the pokey POT lines anywhere. Since there are no controller connections in cart pinouts, any device connected to the POT lines would need to be wired through some external cart connection.

  • Like 4
Link to comment
Share on other sites

57 minutes ago, llabnip said:

You're the man, Rev! Thanks for taking the time to answer questions you've probably already answered before but I've struggled to find answers to!

You're welcome, and not a problem at all. I'm always glad to help out anybody that gifts emulation, tools, or whatever, to the scene. :thumbsup:

  • Like 5
Link to comment
Share on other sites

Cool! Then I'll ask another question related to banks... 

 

My emulator on the DS uses some spare VRAM as a kind of bank swapping area to speed things up (the DS has only 16K of fast working RAM... 3.5MB of main slow RAM and 656k of VRAM which is faster than main RAM but slower than fast RAM).

 

I currently have 256K of spare VRAM to help with bigger ROMs. I currently load half of a 512K SUPERCART (or a quarter of a 1024K ROM) into the VRAM... and I "guessed" at loading the low banks.  That is... a 512K game has 32 banks and I'm loading bank 0-15 into the faster VRAM and banks 16-31 go into the slower main RAM.

 

Is this reasonable? That is: from what folks know about how banks are generally utilized... am I better off "caching" the high banks or the low banks?

Edited by llabnip
Fix VRAM size
Link to comment
Share on other sites

11 minutes ago, llabnip said:

Cool! Then I'll ask another question related to banks... 

 

My emulator on the DS uses some spare VRAM as a kind of bank swapping area to speed things up (the DS has only 16K of fast working RAM... 3.5MB of main slow RAM and 768k of VRAM which is faster than main RAM but slower than fast RAM).

 

I currently have 256K of spare VRAM to help with bigger ROMs. I currently load half of a 512K SUPERCART (or a quarter of a 1024K ROM) into the VRAM... and I "guessed" at loading the low banks.  That is... a 512K game has 32 banks and I'm loading bank 0-15 into the faster VRAM and banks 16-31 go into the slower main RAM.

 

Is this reasonable? That is: from what folks know about how banks are generally utilized... am I better off "caching" the high banks or the low banks?

How much VRAM is used up by the actuall gfx?

Link to comment
Share on other sites

3 minutes ago, Ecernosoft said:

How much VRAM is used up by the actuall gfx?

Sorry... typo in my post I've corrected. The DS has 656K of usable VRAM.

The DS graphics modes I'm using take up 128K for the upper screen, 256K for the lower touch screen and 16K for fast-table-lookups. That leaves 256K of VRAM available for general use by the CPU.

Link to comment
Share on other sites

9 minutes ago, llabnip said:

Sorry... typo in my post I've corrected. The DS has 656K of usable VRAM.

The DS graphics modes I'm using take up 128K for the upper screen, 256K for the lower touch screen and 16K for fast-table-lookups. That leaves 256K of VRAM available for general use by the CPU.

Hmmm… ok.

Most games I know aren’t 512k, so there’s that. Only two I know of are EX0 and Captain conic.

Link to comment
Share on other sites

With the supergame mapper, the only bank that's more likely to see more action than the others is the last non-ephemeral bank (the one that gets mapped in from 0xc000-0xffff) and possibly the second-last bank if EXFIX is used. With them always being present in address space, the game dev will stick things there that get used by the game most of the time. On that basis I'd say you probably want to "cache" the upper 256k.

 

  • Like 4
Link to comment
Share on other sites

8 hours ago, llabnip said:

True... there aren't too many 512k games...  Draker's Quest I and II plus Legend of Silverpeak and Panda Racer are also on that short list. But more will come :)

Comeon! Is this because of 7800basic? I use ASM and none of my stuff has even gone over 48K. Heck, none of it even fills the stock 48K, or even 32K for that matter :) ICT1 comes close, but if ICT3 can fit in 32K (If you are wondering, no, there is no ICT2 7800, and that is because ICT3 follows the story AFTER ICT2 2600) then I might add a "Lock on feature" similar to S&K if @Albert can make a custom cartridge with another cartridge port on top (And if possible, a way to cover it). It would probably be expensive! Like, 50-60 dollars? (US)

Link to comment
Share on other sites

Then, using the $4000-$4FFF space, ANOTHER game could go on-top (Maybe an ICT2 following AFTER ICT3? But currently, ICT1 7800 doesn't exist in the ICT timeline) and a custom chip would map $4000-$4FFF of THAT game to $4000-$4FFF of ICT3. (Or maybe, ICT4 would be the lock-on game and ICT3 would be the cart going on top). Then, ICT4 would have "Extra" ICT3 level data, to expand on the game (And add new zones!). However, if ICT3 needs to be, it might be 52K. (or 36K if it's the lock-on) However, the lock-on chip would be VERY SIMPLE:

 

All it would do is check if pin 14 is high (Starting at pin 0, but if you start at 1, it would be pin 15) and 15 is low, and if that's true, the "Connected" cartridge would be mapped to memory instead of the "Lock-on" cartridge. (Or, you could EOR pin 15 in the circutry and check if both are low)

If that's too complex, a modified ABSOLUTE cart could be used (Allowing all 48 or 52K to be used for the main game) where any bank above 0 is the external cartridge. (So all 48K of that cart could be seen and all 48K of the main cart, which is why it would be modified)

Link to comment
Share on other sites

2 hours ago, Ecernosoft said:

Then, using the $4000-$4FFF space, ANOTHER game could go on-top (Maybe an ICT2 following AFTER ICT3? But currently, ICT1 7800 doesn't exist in the ICT timeline) and a custom chip would map $4000-$4FFF of THAT game to $4000-$4FFF of ICT3. (Or maybe, ICT4 would be the lock-on game and ICT3 would be the cart going on top). Then, ICT4 would have "Extra" ICT3 level data, to expand on the game (And add new zones!). However, if ICT3 needs to be, it might be 52K. (or 36K if it's the lock-on) However, the lock-on chip would be VERY SIMPLE:

 

All it would do is check if pin 14 is high (Starting at pin 0, but if you start at 1, it would be pin 15) and 15 is low, and if that's true, the "Connected" cartridge would be mapped to memory instead of the "Lock-on" cartridge. (Or, you could EOR pin 15 in the circutry and check if both are low)

If that's too complex, a modified ABSOLUTE cart could be used (Allowing all 48 or 52K to be used for the main game) where any bank above 0 is the external cartridge. (So all 48K of that cart could be seen and all 48K of the main cart, which is why it would be modified)

So that's nothing to do with current banking then, which is what the OP was about.

 

If you want to start a discussion on "lock on chips", maybe you should start a new thread instead of derailing this one ?

 

2 hours ago, Ecernosoft said:

Comeon! Is this because of 7800basic? I use ASM and none of my stuff has even gone over 48K. Heck, none of it even fills the stock 48K, or even 32K for that matter :) ICT1 comes close, but if ICT3 can fit in 32K (If you are wondering, no, there is no ICT2 7800, and that is because ICT3 follows the story AFTER ICT2 2600) then I might add a "Lock on feature" similar to S&K if @Albert can make a custom cartridge with another cartridge port on top (And if possible, a way to cover it). It would probably be expensive! Like, 50-60 dollars? (US)

Can I suggest that you don't turn every thread that you comment on into a "It's Conner Time" bibliography? If it's relevant to the actual discussion, sure, but it would be best to keep that in the relevant threads that you already have. 

 

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

11 minutes ago, Muddyfunster said:

So that's nothing to do with current banking then, which is what the OP was about.

 

If you want to start a discussion on "lock on chips", maybe you should start a new thread instead of derailing this one ?

 

Can I suggest that you don't turn every thread that you comment on into a "It's Conner Time" bibliography? If it's relevant to the actual discussion, sure, but it would be best to keep that in the relevant threads that you already have. 

 

 

1. Yeah, true. Except it was- I'm don't know if he has implemented the ACTIVISION and ABSOLUTE banking methods yet.

2. You are right. 

3. Ok, ok. I'm only excited about the ONLY game series I've made.

Link to comment
Share on other sites

On 10/26/2022 at 8:26 PM, RevEng said:

 

 

Yes. It's possible it might be used in the future for homebrew, as it's useful for ram-based bitmap games.

 

 

I agree.

Especially if you have a mode halving the vertical resolution for 160 modes so you can get square pixels.

Edited by Ecernosoft
Link to comment
Share on other sites

Thanks for all the help here guys... I think I have a reasonably good understanding of the various banking bits and the .a78 header bytes. 

 

I'm about to release version 4.0 of A7800DS with all the accumulated improvements. To the best of my ability, I think every original commercial release (NTSC) and every homebrew I tried (about 80 of them) works with the exception of Vikki and Rikki.

Pokey can be at 450 or 4000 only but I'll probably expand that. I don't (yet) support the YM music chip (so 1942 is music-less).

 

I decided to cap the size of games to 1024K of ROM, 16K of extra RAM (@4000) - which should be reasonable "future proofing".  I couldn't find any 52K games to try... but I assume most people would avoid having ROM down that far as it would conflict with the HighScore Cart (which I support - one of my favorite add-ons!).

@Ecernosoft - I know you're passionate about your game so I thought you might like to see it running on the venerable DS handheld.

image.png.864ba47b90adfd38495c73743c37b976.png

  • Like 3
Link to comment
Share on other sites

3 hours ago, llabnip said:

Thanks for all the help here guys... I think I have a reasonably good understanding of the various banking bits and the .a78 header bytes. 

 

I'm about to release version 4.0 of A7800DS with all the accumulated improvements. To the best of my ability, I think every original commercial release (NTSC) and every homebrew I tried (about 80 of them) works with the exception of Vikki and Rikki.

Pokey can be at 450 or 4000 only but I'll probably expand that. I don't (yet) support the YM music chip (so 1942 is music-less).

 

I decided to cap the size of games to 1024K of ROM, 16K of extra RAM (@4000) - which should be reasonable "future proofing".  I couldn't find any 52K games to try... but I assume most people would avoid having ROM down that far as it would conflict with the HighScore Cart (which I support - one of my favorite add-ons!).

@Ecernosoft - I know you're passionate about your game so I thought you might like to see it running on the venerable DS handheld.

image.png.864ba47b90adfd38495c73743c37b976.png

THANK YOU. 😃

In terms of my game, 10.0 is out which finishes @ZeroPage Homebrew's zone as well. (Zero page city)

Link to comment
Share on other sites

3 hours ago, llabnip said:

Thanks for all the help here guys... I think I have a reasonably good understanding of the various banking bits and the .a78 header bytes. 

 

I'm about to release version 4.0 of A7800DS with all the accumulated improvements. To the best of my ability, I think every original commercial release (NTSC) and every homebrew I tried (about 80 of them) works with the exception of Vikki and Rikki.

Pokey can be at 450 or 4000 only but I'll probably expand that. I don't (yet) support the YM music chip (so 1942 is music-less).

 

I decided to cap the size of games to 1024K of ROM, 16K of extra RAM (@4000) - which should be reasonable "future proofing".  I couldn't find any 52K games to try... but I assume most people would avoid having ROM down that far as it would conflict with the HighScore Cart (which I support - one of my favorite add-ons!).

@Ecernosoft - I know you're passionate about your game so I thought you might like to see it running on the venerable DS handheld.

image.png.864ba47b90adfd38495c73743c37b976.png

Also, I know of 1 52K game: Scrapyard dog.

 

And edit: ICT3 will also use the $3000-$3FFF space if it needs to as if Al can get the lock-on solution to work, the boot sequence will be moved from $4000 (Conflicts with Lock on) to $3000 (NO HSC support =/)

Edited by Ecernosoft
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...