It is currently Fri Dec 14, 2018 3:19 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Thu Dec 06, 2018 6:02 pm 
Offline

Joined: Thu Dec 06, 2018 5:46 pm
Posts: 5
I'm very new to coding for the NES, and even newer to bank switching. I've been able to swap the full 8K without problem, however whenever I try swapping anything lower, I always get weird results, mostly it just flat out doesn't work. I'm sure I'm writing to the correct address ($C000), but whenever I go to switch CHR banks, instead of switching to the graphics I want, it blanks it out. I've tried using both 8K, 1K CHR incbin files for the bank switching, but no luck. Can anyone give me a rundown on how 1K CHR bank switching works on the VRC7?


Top
 Profile  
 
PostPosted: Thu Dec 06, 2018 6:47 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7016
Location: Canada
The VRC7 has 8 separate 1k CHR pages, each controlled via its own address: wiki reference


Top
 Profile  
 
PostPosted: Thu Dec 06, 2018 6:53 pm 
Offline

Joined: Thu Dec 06, 2018 5:46 pm
Posts: 5
Alrighty, I get that, however whenever I try and switch one of those banks, instead of putting the CHR data I want, it blanks the section I'm switching. I've tried using 8K CHR files where the stuff I'm trying to switch to is in the first kilobyte of data, 8K where the stuff I wanna switch to is in the same place as the place I'm switching, and I've also tried using 1K CHR files, but none of that seems to be working.


Top
 Profile  
 
PostPosted: Thu Dec 06, 2018 7:04 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7016
Location: Canada
Well, I wouldn't do anything in 8k chunks if you're using a 1k banking mapper like this.

The only things I can't suggest from your description of the problem:

1. Make sure the iNES header CHR size matches the amount of CHR data you have in the file. (Yes this size value has an 8k multiplier, but it doesn't have anything to do with the mapper itself, which uses 1k pages. i.e. If you have 8 1k pages, put a 1 in this field, if you have 16 put a 2, etc.)

2. Make sure your total CHR data size is a power of 2. (8k, 16k, 32k, 64k, 128k, 256k) Other sizes are not possible on the cartridge and some emulators will deal with impossible sizes in a very poor way.


Otherwise maybe describe what you're doing in more detail, share a ROM, a pastebin of relevant code, etc. might help diagnose the problem.


Top
 Profile  
 
PostPosted: Thu Dec 06, 2018 7:08 pm 
Offline

Joined: Thu Dec 06, 2018 5:46 pm
Posts: 5
Ah yeah I completely forgot to update the header, also thank you for the second tip, I had no idea about that, I'll try that stuff.


Top
 Profile  
 
PostPosted: Fri Dec 07, 2018 3:36 pm 
Offline

Joined: Thu Dec 06, 2018 5:46 pm
Posts: 5
Alright, I've done some more testing, and it's still not working for me. I've made sure that I'm using 1K chr files, and that I'm using 8 of them, and I've also put a 1 in the 8K chr bank field in the header. The first chr bank ($00) is working properly, but none of the other banks are loading in no matter where I try to load them in, instead writing $FF everywhere, so the affected area is filled with the 4th color of the palette.

Here's what I think is all the relevant code:
Code:
                           ; In the NMI I have this code:
  LDA controller1 ; This is just a variable which I can easily control by pressing the d-pad
  STA $A000        ; This *should* be loading in one of the banks I have specified, and does for the first bank, but not any others

                           ; At the end of my program I have this code:
  .bank2
  .org $0000
  .incbin "Rex.chr"       ; A chr bank with some graphics in it, I've also made sure that all of the incbins are spelled properly

  .bank3
  .incbin "Leekboi.chr" ; same here, do I need to have another .org command here? I've tried it with .org $0000, .org $1000, and without, but none
                                  ; worked, which one do I need to do?

  .bank4
  .incbin "Legion.chr" ; More graphics

...

  .bank9
  .incbin "Blank.chr" ; This is just filled with $00, and so should be the background color.


Do I need a .org in every bank? If so what should it start at?


Top
 Profile  
 
PostPosted: Fri Dec 07, 2018 3:58 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7016
Location: Canada
I'm not really an expert in NESASM, but I believe the .bank directive has nothing to do with the banks the mapper uses. I think it just divides the output ROM into 8k blocks, and each .bank is one of those blocks, and otherwise it's up to you to make sure they're organized correctly.

What I think you need to do is more like:
Code:
.bank 2
.incbin "0.chr" ; each of these is 1k in size
.incbin "1.chr"
.incbin "2.chr"
.incbin "3.chr"
.incbin "4.chr"
.incbin "5.chr"
.incbin "6.chr"
.incbin "7.chr"

.bank 3
.incbin "8.chr"
;... etc.


The .org shouldn't matter AFAIK, I think that's only useful for code, not binary data.


Top
 Profile  
 
PostPosted: Fri Dec 07, 2018 4:02 pm 
Offline

Joined: Thu Dec 06, 2018 5:46 pm
Posts: 5
Ohhh yeah that makes far more sense, I checked it and it's working now. Thank you so much for the help!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: qalle and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group