Atari 2600
Switch banking 4k+4k
I declare some constants in the Bank 0.
I need to use them, even, in the Bank 1.
Is it possibile to declare them only once in the Bank 0?
Because if I declare again in the Bank 1, it is necessary to change their name.
Thanks
Global Constants in 4k+4k
Re: Global Constants in 4k+4k
The answer probably depends on which assembler you are using - which is it?
Re: Global Constants in 4k+4k
I think some more context would be helpful. How exactly is the banking done?
The 2600 uses a 6507, which has only 13 address pins. The resulting 8K of externally addressable memory gets mirrored eight times in the 64K space that code can see. That 8K is further divided into 4K of I/O and RAM and 4K of ROM. Games that need more than 4K of ROM have to arrange some kind of banking.
But there are many ways of doing that, and I don't know which are used. There are too many options for speculation to be very helpful. I will speculate anyway.
Since the 4K ROM is mirrored throughout the 64K address space, you could assemble each bank to a different target address. So one thinks it's at $1000, another thinks it's at $3000, and so on. Even though only one is available at a time, you can still assemble them together and not worry about overlapping code confusing the assembler.
If the banking is only partial, and you're swapping 2K blocks while keeping 2K fixed, you could have common things in the fixed block. It sounds like that's not the case here though. If the whole 4K gets swapped, they have to be completely independent. If you've got anything that you need to place in more than one bank, they have to be independent copies. In that case, there's no need for the copies to be at the same locations. I think I would find it much less confusing if the banks were treated as completely independent things, with different names to make it clear what bank data is in.
But don't listen to me. I have never done 2600 development, and I don't know how the people who have do things. There must be a 2600 development community out there somewhere. They'd be the best people to ask if you want to know good ways to manage it. This is really a 2600 question, not a 6502 one: the same problems would arise whatever processor was used.
The 2600 uses a 6507, which has only 13 address pins. The resulting 8K of externally addressable memory gets mirrored eight times in the 64K space that code can see. That 8K is further divided into 4K of I/O and RAM and 4K of ROM. Games that need more than 4K of ROM have to arrange some kind of banking.
But there are many ways of doing that, and I don't know which are used. There are too many options for speculation to be very helpful. I will speculate anyway.
Since the 4K ROM is mirrored throughout the 64K address space, you could assemble each bank to a different target address. So one thinks it's at $1000, another thinks it's at $3000, and so on. Even though only one is available at a time, you can still assemble them together and not worry about overlapping code confusing the assembler.
If the banking is only partial, and you're swapping 2K blocks while keeping 2K fixed, you could have common things in the fixed block. It sounds like that's not the case here though. If the whole 4K gets swapped, they have to be completely independent. If you've got anything that you need to place in more than one bank, they have to be independent copies. In that case, there's no need for the copies to be at the same locations. I think I would find it much less confusing if the banks were treated as completely independent things, with different names to make it clear what bank data is in.
But don't listen to me. I have never done 2600 development, and I don't know how the people who have do things. There must be a 2600 development community out there somewhere. They'd be the best people to ask if you want to know good ways to manage it. This is really a 2600 question, not a 6502 one: the same problems would arise whatever processor was used.
Re: Global Constants in 4k+4k
John West wrote:
Since the 4K ROM is mirrored throughout the 64K address space, you could assemble each bank to a different target address. So one thinks it's at $1000, another thinks it's at $3000, and so on. Even though only one is available at a time, you can still assemble them together and not worry about overlapping code confusing the assembler.
Re: Global Constants in 4k+4k
It seems odd to me that it would be economical to use a cut-down CPU and supplement it with custom banking logic, rather than using the full 6502 in the first place. But I guess the banking logic ICs were in the cartridges, not the main system itself, and these banked cartridges could have been made much later when the price of components or PLDs had maybe dropped a lot, making it economical after all.
Re: Global Constants in 4k+4k
gfoot wrote:
It seems odd to me that it would be economical to use a cut-down CPU and supplement it with custom banking logic, rather than using the full 6502 in the first place. But I guess the banking logic ICs were in the cartridges, not the main system itself, and these banked cartridges could have been made much later when the price of components or PLDs had maybe dropped a lot, making it economical after all.
It was pretty amazing at the time though!
-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Re: Global Constants in 4k+4k
The idea of making a cheap-as-possible console and then having (some) of the cartridges add extra hardware, that seems like quite a good idea to me. It's true that the later and larger games needed quite complex schemes, but then the game itself can perhaps cost more. And surely the 2600 being cheap to make and cheap to buy must have been a major factor in its success.
(An ultimate example of this might be Star Fox with a 16 bit RISC in the cart. Although that's for a different platform.)
(An ultimate example of this might be Star Fox with a 16 bit RISC in the cart. Although that's for a different platform.)
- Sheep64
- In Memoriam
- Posts: 311
- Joined: 11 Aug 2020
- Location: A magnetic field
Re: Global Constants in 4k+4k
If you, for example, define a table which can be banked out then may have to define the table in two places or do some hooky includes. To minimize wasted ROM, define all of the global constants first and then define the constants which are local to each bank.
- Sheep64
- In Memoriam
- Posts: 311
- Joined: 11 Aug 2020
- Location: A magnetic field
Re: Global Constants in 4k+4k
gfoot on Tue 15 Feb 2022 wrote:
It seems odd to me that it would be economical to use a cut-down CPU and supplement it with custom banking logic
Actually, I presume that all of the Atari 2600 game consoles were soldered manually. Soldering 28 pin 6507 rather than 40 pin 6502 would save considerable effort. It would also reduce production line theft because 6507 is less useful with 13 address lines and no NMI.