It is currently Tue Aug 22, 2017 3:40 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Chr-Ram bankswitching
PostPosted: Wed Jun 07, 2017 7:01 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Hey all! Project is winding down. Starting to add some unplanned *flair*. Figured I'd try my hand at injecting some animated background tiles, since I'm using UnRom512 and the mapper supports chr ram bankswitching.

But I'm running against a void in my conceptual understanding, I guess. The game uses CHR-Ram - I have a few banks full of background graphic data that routines load in chunks whenever and wherever needed. No problem.

My conceptual understanding is that I can set up multiple banks (when I load that graphic data, load it's *animated* frame to a different bank location), and then with an easy write to two bits in 8000, I can determine which bank is being pointed to to populate the pattern tables. I have that right? I mean - I get bankswitching fine...obviously, I bankswitch PRG data all over the place.

But I suppose I'm confused how/where to set up these banks in memory. I tried to sort of follow how PRG banks are established, but nothing I tried seemed to work right (most attempts led to gray screen).

Anyone want to give me an easy breakdown of how to set this up so I can test it out? Ultimately, I'm not sure the game needs it, but...might be nice, and now I want to understand it!

Thanks!


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 7:15 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18835
Location: NE Indiana, USA (NTSC)
Switch to CHR bank 0
Load pattern table
Switch to CHR bank 1
Load pattern table
Switch to CHR bank 2
Load pattern table
Switch to CHR bank 3
Load pattern table
Load nametable
Load palette
Turn on display
Switch to CHR bank 0
Wait a few frames
Switch to CHR bank 1
Wait a few frames
Switch to CHR bank 2
Wait a few frames
Switch to CHR bank 3
Wait a few frames

Does this still give a gray screen?

If so, you might have forgotten that a write to the mapper port switches both the PRG bank (bits 4-0) and the CHR bank (bits 6-5). Try doing this from the fixed bank ($C000-$FFFF). And if that doesn't work, try making a minimal, complete, and verifiable example (MCVE), source code that builds yet is short enough for us to look at.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 7:40 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Yeah, I figure it's that simple. I'm a step before that, though. Where in memory are the CHR banks to set up in the first place? I guess that was the crux of my question.

Thanks, friend!


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 7:44 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18835
Location: NE Indiana, USA (NTSC)
To write to CHR RAM bank 0, switch to CHR RAM bank 0 with a mapper write and then write to video memory $0000-$1FFF.
To write to CHR RAM bank 1, switch to CHR RAM bank 1 with a mapper write and then write to video memory $0000-$1FFF.
To write to CHR RAM bank 2, switch to CHR RAM bank 2 with a mapper write and then write to video memory $0000-$1FFF.
To write to CHR RAM bank 3, switch to CHR RAM bank 3 with a mapper write and then write to video memory $0000-$1FFF.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 7:47 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Ok cool...that's what I thought. I figured it was that easy.

I wonder if it's my emulator not emulating this. Hm.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 7:53 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18835
Location: NE Indiana, USA (NTSC)
Does your emulator correctly emulate Videomation? Or an Action 53 build including Sinking Feeling?

I have made CHR RAM bankswitching test ROMs for MMC3 and Action 53, but not UNROM 512.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 8:50 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Can't check right now, but essentially - what I'm trying is simply updating my bankswitch routine, or-ing in writes to bits 5 and 6 and storing them into the currentBank variable prior to the switch. It seems straight forward enough. But any time I make the bits anything other than 0, game freezes.

Without this ORA, the bankswitching routine works fine for PRG bankswitching.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 8:54 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 18835
Location: NE Indiana, USA (NTSC)
If you're using a board that's not self-flashable, you need to avoid bus conflicts when changing the CHR bank. This makes your identity table for bus conflict avoidance four times as large, expanding it from 32 bytes to 128 bytes.


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 6:39 am 
Offline
User avatar

Joined: Sat Aug 15, 2015 3:42 pm
Posts: 97
Location: France
tepples wrote:
Does your emulator correctly emulate Videomation? Or an Action 53 build including Sinking Feeling?

I have made CHR RAM bankswitching test ROMs for MMC3 and Action 53, but not UNROM 512.



Funny, I just made an UNROM 512 / mapper 30 test ROM today !
Hope it helps anyone ...

edit : it uses 1-screen arrangement though

Attachment:
File comment: UNROM 512 / mapper 30 test ROM
mapper30-testROM-20170608.nes [512.02 KiB]
Downloaded 22 times


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 10:50 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Drat. Curses. I was hoping it was the emulator, however, that test file seems to work fine (cycles through chr banks just dandy).

Huh.

Glutock - what does your bankswitch routine look like?


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 11:40 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Disregard the whole thread. The problem was super simple. I didn't have the battery flag checked in the header, which ended up causing bus conflicts (Tepples, you mentioned this, and I didn't even think of it as a header issue! Good call)

Works fine now, and as expected.


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 7:38 pm 
Offline

Joined: Sun Nov 23, 2014 12:16 pm
Posts: 156
Need NES game maker tools now....

NES homebrews for the rest of us non-programmers.


Top
 Profile  
 
PostPosted: Sat Jun 10, 2017 6:35 am 
Offline

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 254
Improving on them every day :-) And the intent for them is absolutely to give new devs some confidence to eventually start getting deeper into the code and going crazy with it :-)


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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