Bank Switching

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
Guyver
Posts: 14
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Magadan
Contact:

Re: Bank Switching

Post by Guyver »

No one will help? :oops:
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an »

bank switching in MMC1 is nothing like bankswitching in UNROM. You have to write the bits sequentially. Check the wiki!
User avatar
Guyver
Posts: 14
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Magadan
Contact:

Re: Bank Switching

Post by Guyver »

I can not write the working code for NESASM3 example (cyoammc1)... :cry: Could you help with the working code? It is for this example.
I beg you to help, I almost made my game. And I lack only the correct code for switching banks of graphics. I can not write the code myself. I've already tried it ..
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an »

Have you tried the code snippets? there's nothing more to it, I mean, it's pretty straightforward, it's just:

Code: Select all

  lda #<VALUE>   ; vertical mirroring, fixed $C000, 8 KB CHR pages
  sta <REG>  ; (use $0F instead for horizontal mirroring)
  lsr a
  sta <REG>
  lsr a
  sta <REG>
  lsr a
  sta <REG>
  lsr a
  sta <REG>
Where <REG> is the register address you want to write <VALUE> to. You can check the port addresses and what to write to them here http://wiki.nesdev.com/w/index.php/MMC1

You first set up everything writing to port $8000 (mirroring a bank mode). You can change your CHR ROM banks individually using $A000 and $C000, and you can set your PRG bank writing to port $E000.
User avatar
Guyver
Posts: 14
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Magadan
Contact:

Re: Bank Switching

Post by Guyver »

Help me to insert the code here:

download/file.php?id=9998

It will take you 1 minute. (You will spend more time if you try to explain to me how to do it). :roll:

Do you think I have not tried to do this? I can not do it. Help me please not by advice, but by working example. I wrote - I can not do anything on my own. (Forgive me if I do not write clearly, I know English very badly ...)

I could give my own project, but there all the comments are in Russian. I built my game based on the example from NESASM3.
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an »

Sorry, I don't use NESASM3, nor really code in assembly, nor have the time to try and understand a whole bunch of assembly code written by somebody else :)

I understood you want to page in bank 13 to copy CHR data to CHR-RAM, so paging in bank 13 of PRG in MMC1:

Code: Select all

  lda #13   ; Set bank 13
  sta $E000  ; $E000 = set PRG bank.
  lsr a
  sta $E000
  lsr a
  sta $E000
  lsr a
  sta $E000
  lsr a
  sta $E000
User avatar
Guyver
Posts: 14
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Magadan
Contact:

Re: Bank Switching

Post by Guyver »

Alas ... This code does not work for me in this rom. :?

In my example:

Code: Select all

  .inesprg 8   ; 8x 16KB PRG code = 128KB
  .ineschr 0   ; 0x  8KB CHR data = CHR RAM
  .inesmap 1   ; mapper 1 = MMC1
Graphics are taken from the penultimate bank. And I do not know how to change the bank of graphics to another one or add one more and switch him.
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an »

This is a CHR-RAM board, so you have to page in the bank with the graphics and copy them to VRAM via $2006/$2007 writes. The code I posted is for the first part (page in a PRG-ROM bank). You have then top copy the pattern data to the VRAM.

Learn about CHR-RAM here http://wiki.nesdev.com/w/index.php/CHR_ ... to_CHR_RAM
Post Reply