NintendoAge http://nintendoage.com/forum/ -Sqooner Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2015-12-04T14:48:06 -05.00 bunnyboy 36 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.

  ]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-07-15T02:24:38 -05.00 bunnyboy 36 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.

]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-07-14T22:05:42 -05.00 bunnyboy 36 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 ]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-07-14T21:39:47 -05.00 bunnyboy 36 Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T11:14:12 -05.00 bunnyboy 36
Thanks for clarifying the Mega Man meta-sprite. ]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T10:52:46 -05.00 bunnyboy 36
And BAN used 4 frame animation. Though you can't tell unless you get real close. ]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T10:29:10 -05.00 bunnyboy 36 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.

]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T10:17:21 -05.00 bunnyboy 36
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. ]]>
Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T10:00:12 -05.00 bunnyboy 36 Advanced Nerdy Nights #1 http://nintendoage.com/forum/messageview.cfm?catid=22&threadid=17074 2014-04-04T09:50:49 -05.00 bunnyboy 36 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 https://www.youtube.com/watch?v=O8P7_7YINos&list=UUKDlRHqgdPjOjQq2HFW7VhA

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


]]>