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: 13
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Sinegorie
Contact:

Re: Bank Switching

Post by Guyver » Fri Sep 01, 2017 4:49 am

No one will help? :oops:

na_th_an
Posts: 543
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an » Fri Sep 01, 2017 5:44 am

bank switching in MMC1 is nothing like bankswitching in UNROM. You have to write the bits sequentially. Check the wiki!

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

Re: Bank Switching

Post by Guyver » Sat Sep 02, 2017 2:14 pm

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: 543
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an » Sun Sep 03, 2017 11:48 pm

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: 13
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Sinegorie
Contact:

Re: Bank Switching

Post by Guyver » Mon Sep 04, 2017 3:31 am

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: 543
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an » Tue Sep 05, 2017 4:13 am

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: 13
Joined: Sat Aug 19, 2017 5:47 pm
Location: Russia, Sinegorie
Contact:

Re: Bank Switching

Post by Guyver » Tue Sep 05, 2017 6:20 am

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: 543
Joined: Mon May 27, 2013 9:40 am

Re: Bank Switching

Post by na_th_an » Mon Sep 11, 2017 2:58 am

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