Skip navigation
NintendoAge
Welcome, Guest! Please Login or Join
Loading...

Advanced Nerdy Nights #1 CHR Bank switching

Apr 2, 2014 at 11:45:03 PM
removed04092017 (0)
This user has been banned -- click for more information.
< Bowser >
Posts: 7316 - Joined: 12/04/2010
Other
Profile
Best reason is the screen has more pixels then chr-rom can bank in. So switching banks allows for more screen content, since it just adds more graphics available to display. That's basically the whole idea.

Apr 4, 2014 at 9:50:49 AM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile

You can do a lot of things with this. For example:

1. Bank 0 can be your start screen graphics where you have a giant ass picture. Bank 1 could contain main game stuff, 2 the cut screens, and 3 the end screen. Just where you have too many graphics to fit into one CHR bank.

2. You can animate the entire background and sprite set at once. A la


3. Or you can do somthing like this:  http://nintendoage.com/forum/messageview.cfm?catid=22&th...



-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.



Edited: 04/04/2014 at 09:52 AM by Mario's Right Nut

Apr 4, 2014 at 10:00:12 AM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
So a game like centipede would use bank switching to animate the centipede and the objects that you shoot? I assume that each bank is still limited to the same 16 color pallete.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Apr 4, 2014 at 10:17:21 AM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8126 - Joined: 06/21/2007
Florida
Profile
Basically in the game MRN posted, it switches between the two banks to animate the background, instead of attempting to update every single background tile one by one. The two banks have the two "frames" of animation, with the same tiles being used for the same enemy in both sets, so when the bank switches, all tile numbers stay the same but it animates.

I've personally used it for his first example: I generally try to make my title screens a little fancier, so I use an entire pattern table for it. Then I have another pattern table for the gameplay. That way I don't have to try to piece something together from the random tiles I have for the main part of the game. Although I did this for Study Hall and it turned out pretty cool.

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Apr 4, 2014 at 10:29:10 AM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: Mega Mario Man

So a game like centipede would use bank switching to animate the centipede and the objects that you shoot? I assume that each bank is still limited to the same 16 color pallete.

I confused myself. I now see that the animation is the shifting of the enemy back and forth plus they change their form.

I could see how it would be useful in the first example.

Is bank switching how they built Mega Man? I know there was a trick they used in order to get his face a different color than the rest of his body to trick the 4 color limit.


-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Apr 4, 2014 at 10:52:46 AM
Mario's Right Nut (352)
avatar
(Cunt Punch) < Bowser >
Posts: 6636 - Joined: 11/21/2008
Texas
Profile
Mega Man used sprites on top of sprites. i.e. four to make up the body and a different colored fifth one pasted over the top.

And BAN used 4 frame animation. Though you can't tell unless you get real close.

-------------------------

This is my shiny thing, and if you try to take it off me, I may have to eat you.

Check out my dev blog.


Apr 4, 2014 at 11:14:12 AM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
I thought I counted 4 frames.

Thanks for clarifying the Mega Man meta-sprite.

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter

Jul 14, 2014 at 9:39:47 PM
tree of might (0)

< Cherub >
Posts: 3 - Joined: 07/13/2014
England
Profile
Sorry, guys, I just don't get this. At the end of the bankswitch subroutine the value in X gets stored in the bankvalues area, then what? What part of the code actually causes the bank switching to happen? Sorry if this is a dumb question.


Edited: 07/14/2014 at 09:40 PM by tree of might

Jul 14, 2014 at 10:05:42 PM
KHAN Games (89)
avatar
(Kevin Hanley) < Master Higgins >
Posts: 8126 - Joined: 06/21/2007
Florida
Profile
Originally posted by: tree of might

Sorry, guys, I just don't get this. At the end of the bankswitch subroutine the value in X gets stored in the bankvalues area, then what? What part of the code actually causes the bank switching to happen? Sorry if this is a dumb question.

It's storing it into the $8000 address, right?

;;code
STA $8000 ;;new bank to use
RTS

-------------------------

gauauu: look, we all paid $10K at some point in our lives for the privilege of hanging out with Kevin


Jul 15, 2014 at 2:24:38 AM
tree of might (0)

< Cherub >
Posts: 3 - Joined: 07/13/2014
England
Profile
Originally posted by: KHAN Games

Originally posted by: tree of might

Sorry, guys, I just don't get this. At the end of the bankswitch subroutine the value in X gets stored in the bankvalues area, then what? What part of the code actually causes the bank switching to happen? Sorry if this is a dumb question.

It's storing it into the $8000 address, right?

;;code
STA $8000 ;;new bank to use
RTS

What section of the code does it write to $8000? I can't seem to find it.


Dec 4, 2015 at 2:48:06 PM
Mega Mario Man (63)
avatar
(Tim ) < Ridley Wrangler >
Posts: 2743 - Joined: 02/13/2014
Nebraska
Profile
Originally posted by: tree of might
 
Originally posted by: KHAN Games
 
Originally posted by: tree of might

Sorry, guys, I just don't get this. At the end of the bankswitch subroutine the value in X gets stored in the bankvalues area, then what? What part of the code actually causes the bank switching to happen? Sorry if this is a dumb question.

It's storing it into the $8000 address, right?

;;code
STA $8000 ;;new bank to use
RTS

What section of the code does it write to $8000? I can't seem to find it.
 
THIS IS KEY
"The actual switch is done by writing the desired bank number anywhere in the $8000-FFFF memory range."


Bus Conflicts
"When you start running your code on real hardware there is one catch to worry about. For basic mappers, the PRG ROM does not care if it receives a read or a write command. It will respond to both like a read by putting the data on the data bus. This is a problem for bank switching, where the CPU is also trying to put data on the data bus at the same time. They electrically fit in a "bus conflict". The CPU could win, giving you the right value. Or the ROM could win, giving you the wrong value. This is solved by having the ROM and CPU put the same value on the data bus, so there is no conflict. First a table of bank numbers is made, and the value from that table is written to do the bank switch."

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  .bank 0                    ;;Code is stored starting at $C000
  .org $C000
 
  ... code ...

  LDA #$01                     ;;Load A with $01 (For bank 1)
  JSR Bankswitch             ;;jump to bank switching code

... code ...

Bankswitch:
  TAX                         ;;copy $01 into X
  STA Bankvalues, X         ;;Write $01 to Bankvalues,$01 (Which is stored somewhere between $C000-$DFFF). This is done to avoid the Bus Conflict in the paragraph above
  RTS

Bankvalues:
  .db $00, $01, $02, $03     ;;bank numbers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
 
 
Since you write to Bankvalues, that table is stored in $8000-FFFF memory range. You can write to ANY number in that range, so you write the value of X into Bankvalues.

Hope that helps clarify. This is the way I understand it.

 

-------------------------
Current Project
Isometric Survival Horror

Older Projects
Tailgate Party, Power Pad Demo, Happy Hour

Links
Store, Facebook, Twitter