VRC6 CHR Bank Malformed?

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

puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

tokumaru wrote: Wed May 12, 2021 2:28 pm
puppydrum64 wrote: Wed May 12, 2021 2:07 pm

Code: Select all

.include "pad8k.asm"
There's no need to use external files for padding... Any decent assembler will have a directive to fill memory. It looks like NESASM uses DS for this (e.g. .ds 8192 to generate 8KB of zeros). But with NESASM's mandatory BANK directives, I don't think you even need to do any manual padding, each "bank" will be 8KB no matter what you put on it.
Ah, so that's how you use the ".ds" directive. The github page was a little vague about that. I don't think padding is technically necessary either, but NESASM tends to fill empty space with #$ff.
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

Thank you everyone for your help so far. I think I'm starting to understand more about how banks work on NES games. But unfortunately I still don't understand why this is happening, even after setting bit 5 of $B003:

Image
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC6 CHR Bank Malformed?

Post by lidnariq »

puppydrum64 wrote: Wed May 12, 2021 3:53 pm But unfortunately I still don't understand why this is happening, even after setting bit 5 of $B003:
Because you haven't written the correct values to $D000 through $E003.
User avatar
Controllerhead
Posts: 314
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: VRC6 CHR Bank Malformed?

Post by Controllerhead »

puppydrum64 wrote: Wed May 12, 2021 3:53 pm I still don't understand why this is happening
That's the first 1KB of CHR data repeated 8 times. Looks right to me =p

You should try switching those banks.
Image
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

Controllerhead wrote: Wed May 12, 2021 4:00 pm
puppydrum64 wrote: Wed May 12, 2021 3:53 pm I still don't understand why this is happening
That's the first 1KB of CHR data repeated 8 times. Looks right to me =p

You should try switching those banks.
Hmm, so how do I switch banks exactly? I know I need to write to the "PPU registers" but what to write to them?
User avatar
Controllerhead
Posts: 314
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: VRC6 CHR Bank Malformed?

Post by Controllerhead »

puppydrum64 wrote: Wed May 12, 2021 4:21 pm what to write to them?
The KB of CHR data that you want in each bank. So, if you did:

Code: Select all

LDX #$00
STX $D000
INX
STX $D001
INX
STX $D002
INX
STX $D003
INX
STX $E000
INX
STX $E001
INX
STX $E002
INX
STX $E003
The SMB CHR data would be loaded in order.
If i understand VRC6 correctly...
Image
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

Controllerhead wrote: Wed May 12, 2021 4:31 pm
puppydrum64 wrote: Wed May 12, 2021 4:21 pm what to write to them?
The KB of CHR data that you want in each bank. So, if you did:

Code: Select all

LDX #$00
STX $D000
INX
STX $D001
INX
STX $D002
INX
STX $D003
INX
STX $E000
INX
STX $E001
INX
STX $E002
INX
STX $E003
The SMB CHR data would be loaded in order.
If i understand VRC6 correctly...
Funnily enough I literally just tried this before reading your reply and it worked. Thanks! I'm gonna try numbers that go past 7 and see if that loads bank 2. And I'll write a loop that does this more efficiently and with a way to select entire banks. But that might take a while.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: VRC6 CHR Bank Malformed?

Post by unregistered »

Remember that bank switching for VRC6 is described on this page:

https://wiki.nesdev.com/w/index.php/VRC6

But, it’s quite confusing… for me at least; follow the advice given, and if it doesn’t work out, then refer to that page and play with it. :)


Aahhh, so it makes a bit of sense now… if you write #xxxxxx00b, or #%xxxxxx00, to $B003, then your bank switching will work as Controllerhead said.

If you write #%xxxxxx10 to $B003, then the bank switching (or writing, will be quite different. Sry, I’ve got to go.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: VRC6 CHR Bank Malformed?

Post by lidnariq »

In my opinion, VRC6 is one of the most ridiculous mappers ever seen on the Famicom, exceeded only by Namco's 163, the MMC5, and JY Company's mapper. It's unfortunate that it's the one you're starting with, because there's a whole lot more background to have to get through before you can meaningfully understand how to use it.

But if it's its audio capabilities that are your sole inspiration, there's really nothing to be done for that.
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

Only weird thing happening now is, I have my test ROM set up so that pressing A will add 1 to the value in $D000. But for some reason it adds 2 instead, and I don't know why.
User avatar
Controllerhead
Posts: 314
Joined: Tue Nov 13, 2018 4:58 am
Location: $4016
Contact:

Re: VRC6 CHR Bank Malformed?

Post by Controllerhead »

puppydrum64 wrote: Wed May 12, 2021 6:13 pm Only weird thing happening now is, I have my test ROM set up so that pressing A will add 1 to the value in $D000. But for some reason it adds 2 instead, and I don't know why.
You realize you can't read the value of the register, right? It will just read the value of the ROM at $D00x or what have you, nor will writing to it change the value that is read. You'll have to keep track of the register value(s) in RAM somewhere manually, if that's your intention.
Image
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

Controllerhead wrote: Wed May 12, 2021 6:49 pm
puppydrum64 wrote: Wed May 12, 2021 6:13 pm Only weird thing happening now is, I have my test ROM set up so that pressing A will add 1 to the value in $D000. But for some reason it adds 2 instead, and I don't know why.
You realize you can't read the value of the register, right? It will just read the value of the ROM at $D00x or what have you, nor will writing to it change the value that is read. You'll have to keep track of the register value(s) in RAM somewhere manually, if that's your intention.
I figured as much. What I did was create seven "soft" registers in zero page RAM. The only time I actually write to the real registers is during vBlank, where I copy the phony registers to the real ones. The button presses increment the soft registers only.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: VRC6 CHR Bank Malformed?

Post by unregistered »

puppydrum64 wrote: Wed May 12, 2021 7:34 pm
Controllerhead wrote: Wed May 12, 2021 6:49 pm
puppydrum64 wrote: Wed May 12, 2021 6:13 pm Only weird thing happening now is, I have my test ROM set up so that pressing A will add 1 to the value in $D000. But for some reason it adds 2 instead, and I don't know why.
You realize you can't read the value of the register, right? It will just read the value of the ROM at $D00x or what have you, nor will writing to it change the value that is read. You'll have to keep track of the register value(s) in RAM somewhere manually, if that's your intention.
I figured as much. What I did was create seven "soft" registers in zero page RAM. The only time I actually write to the real registers is during vBlank, where I copy the phony registers to the real ones. The button presses increment the soft registers only.
This is what debuggers are made for… in Mesen, I’d create a breakpoint that triggered on your soft copy of $D000 for each read and write. (Click on the breakpoint part of the debug window and press insert to create; to edit a debug breakpoint entry, click it and press F2.) Then press F5 and play your game and press A… the debugger will stop at every read and write to that soft register. :) You should be able to figure out what’s happening. (F10 will step through one instruction; F5 will run your game until a breakpoint hits; if you go too far, you can step back with ALT+~ or reset and try debug process again; the breakpoints will not disappear until you delete them. :) )
puppydrum64
Posts: 160
Joined: Sat Apr 24, 2021 7:25 am

Re: VRC6 CHR Bank Malformed?

Post by puppydrum64 »

unregistered wrote: Thu May 13, 2021 8:37 am
puppydrum64 wrote: Wed May 12, 2021 7:34 pm
Controllerhead wrote: Wed May 12, 2021 6:49 pm
You realize you can't read the value of the register, right? It will just read the value of the ROM at $D00x or what have you, nor will writing to it change the value that is read. You'll have to keep track of the register value(s) in RAM somewhere manually, if that's your intention.
I figured as much. What I did was create seven "soft" registers in zero page RAM. The only time I actually write to the real registers is during vBlank, where I copy the phony registers to the real ones. The button presses increment the soft registers only.
This is what debuggers are made for… in Mesen, I’d create a breakpoint that triggered on your soft copy of $D000 for each read and write. (Click on the breakpoint part of the debug window and press insert to create; to edit a debug breakpoint entry, click it and press F2.) Then press F5 and play your game and press A… the debugger will stop at every read and write to that soft register. :) You should be able to figure out what’s happening. (F10 will step through one instruction; F5 will run your game until a breakpoint hits; if you go too far, you can step back with ALT+~ or reset and try debug process again; the breakpoints will not disappear until you delete them. :) )
Yep, that helped me find the error. I forgot an RTS at the end of one of my subroutines and it ended up bleeding into the next one causing it to be called twice.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Re: VRC6 CHR Bank Malformed?

Post by unregistered »

Happy it’s working for you! 😀 When we began our NES game, I forgot an rts too.
Post Reply