How does Donkey Kong have two CHR banks on screen?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

DementedPurple
Posts: 318
Joined: Mon Jan 30, 2017 5:20 pm
Location: Colorado USA

How does Donkey Kong have two CHR banks on screen?

Post by DementedPurple » Wed May 03, 2017 11:10 am

When you look at the graphics of games like Donkey Kong or Super Mario Bros, you would notice that the CHR bank has one bank of 255 tiles for the nametable, and has another 255 tiles for the sprites. How is it able to have them both be on screen at the same time?

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How does Donkey Kong have two CHR banks on screen?

Post by tokumaru » Wed May 03, 2017 11:21 am

DementedPurple wrote:When you look at the graphics of games like Donkey Kong or Super Mario Bros
Or pretty much every other NES game, really.
How is it able to have them both be on screen at the same time?
Because they're referenced in different places. Background tiles are referenced in the name tables, while sprite tiles are referenced in the OAM, so it's possible to point them to different pattern tables. This is completely optional though, since the PPU control register ($2000) lets you choose which pattern table is used for which layer.

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: How does Donkey Kong have two CHR banks on screen?

Post by tokumaru » Wed May 03, 2017 11:46 am

Oh, and there's also the case of 8x16-pixel sprites, that can use tiles from both pattern tables. Since 8x16 sprites use pairs of tiles, we can address 256 pairs, or 512 tiles. When sprites are set to 8x16 mode, the sprite pattern table bit is ignored.

User avatar
DRW
Posts: 1913
Joined: Sat Sep 07, 2013 2:59 pm

Re: How does Donkey Kong have two CHR banks on screen?

Post by DRW » Wed May 03, 2017 12:54 pm

I really think you should start working through an NES development tutorial, like Nerdy Nights or Doug's tutorial.
Your current questions are pretty basic and you could probably answer them yourself if you had a general understanding of the system.

Nerdy Nights:
http://nintendoage.com/forum/messagevie ... eadid=7155

Doug's tutorial:
https://nesdoug.com/
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

DementedPurple
Posts: 318
Joined: Mon Jan 30, 2017 5:20 pm
Location: Colorado USA

Re: How does Donkey Kong have two CHR banks on screen?

Post by DementedPurple » Wed May 03, 2017 1:05 pm

DRW wrote:I really think you should start working through an NES development tutorial, like Nerdy Nights or Doug's tutorial.
Your current questions are pretty basic and you could probably answer them yourself if you had a general understanding of the system.
I already knew a lot, I'm just making sure I understand what I'm reading. I think I have enough knowledge to reprogram Donkey Kong with my own code. And I don't mean to be rude, but I'm sorry my curiosity annoys you. I doubt you were any better when you were 12 years old. I have a hard time believing you were ever a newbie. I'm just curious about something that I have a passion for, and I'm looking at the pros for help. Imagine if you asked Steve Jobs how a computer works, and all he said was "That's a stupid question". That would be pretty disappointing.

User avatar
rainwarrior
Posts: 7669
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: How does Donkey Kong have two CHR banks on screen?

Post by rainwarrior » Wed May 03, 2017 1:30 pm

DementedPurple wrote:Imagine if you asked Steve Jobs how a computer works, and all he said was "That's a stupid question". That would be pretty disappointing.
Yet completely in character for Steve Jobs.

(Steve Wozniak on the other hand would probably love to explain...)

User avatar
gauauu
Posts: 648
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: How does Donkey Kong have two CHR banks on screen?

Post by gauauu » Wed May 03, 2017 1:34 pm

DementedPurple wrote: I already knew a lot, I'm just making sure I understand what I'm reading.
That's fine. You might ask in a way that explains what you DO know, and explains why you think your answer wasn't answered by the standard docs.
I think I have enough knowledge to reprogram Donkey Kong with my own code. And I don't mean to be rude, but I'm sorry my curiosity annoys you. I doubt you were any better when you were 12 years old. I have a hard time believing you were ever a newbie. I'm just curious about something that I have a passion for, and I'm looking at the pros for help.
Your curiosity doesn't annoy us, and we're glad you have a passion for it. Everyone here has been a newbie at some point (heck, I still am). But he's just suggesting that the questions you are asking are clearly explained in a lot of the documentation. (And you might also post it in the newbie help center, where people would expect questions like this)
Imagine if you asked Steve Jobs how a computer works, and all he said was "That's a stupid question". That would be pretty disappointing.
That's actually the kind of jerk answer I would have expected from Steve Jobs. (dang, rainwarrior beat me to it)

User avatar
dougeff
Posts: 2614
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: How does Donkey Kong have two CHR banks on screen?

Post by dougeff » Wed May 03, 2017 1:55 pm

Interesting side note, related to the sprite 0 post. You can change which pattern table the BG uses, mid frame.

Haunted Halloween 85, I think, does this for the title screen. Using one table for 'Haunted' and another for the rest.

https://youtu.be/cGf0ivVHPnU

And furthermore, more advanced mappers can change the entire graphics midframe (with magic).

I'll try to find a link to that later....

Oh right. Punch Out!

Edit-
It uses one tileset for the top of the screen, and then swapping (remapping) tiles midscreen, and using a second tileset for Little Mac and Mario. Yes. Little Mac is background. The only sprites are the opponent (and a tiny sprite on the far right which helps it know when to switch tiles).
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
DRW
Posts: 1913
Joined: Sat Sep 07, 2013 2:59 pm

Re: How does Donkey Kong have two CHR banks on screen?

Post by DRW » Wed May 03, 2017 2:43 pm

DementedPurple wrote:And I don't mean to be rude, but I'm sorry my curiosity annoys you. I doubt you were any better when you were 12 years old. I have a hard time believing you were ever a newbie. I'm just curious about something that I have a passion for, and I'm looking at the pros for help.
That's not what I was talking about at all. I was talking about the fact that your questions are very basic and could be answered by simply looking them up or by doing a tutorial first.

You don't ask questions that simply indicate a lack of understanding.

For example, if you asked: "How do I update the screen during gameplay? Whenever I update it, the graphics get corrupted", then the answer might be: "You can only update a limited amount of background data per frame because it has to be done during vblank. You cannot update your whole screen every time. You need to design your game in a way that you can do partial updates. If it doesn't work like that yet, you need to redesign your general code."

This is a question that might justify an answer because even though you read the technical documentation, you might not yet be aware of the fact that you have only very few time during vblank.

A question like: "How did SMB do the status bar?" is also quite justified. But as soon as someone points you to sprite 0 split, you shouldn't ask: "What is a sprite 0 split?" Because that's something that is clearly explained in every beginner's tutorial and wiki and can be easily googled.

Likewise, the two CHR banks is one of the most basic stuff: One bank for background, one bank for sprites. (With the option to use the same bank for both.)

Since you're wondering how "Donkey Kong" has two CHR banks on screen, making it sound like this was some kind of special programming trick instead of the very thing that almost every single NES game does, I have to come to the conclusion that you didn't even read the beginner's tutorial. That's why I advised you to do so.

Yes, I have been a newbie myself. And when I asked a question about something very basic and an expert told me: "You will know this as soon as you finished the introduction tutorial", then guess what: I finished the introduction tutorial first. And then did I ask further questions that were still not clear to me. But often, doing the tutorial first already removed a lot of questions from my list.

Don't try to figure out stuff by asking about every single thing piece by piece. Take a tutorial and work through it.
If you have problems with a certain chapter, ask a specific question about that chapter.
If you have a question that wasn't covered yet ("They showed me how to draw the background, but how can I get it to scroll now?"), don't ask yet. Continue with the tutorial until you have finished it. Maybe the topic will come up and you'll learn it anyway.
If it doesn't come up, you have plenty of time afterwards, asking everything that the tutorial didn't cover or that you didn't understand.


And P.S.: Your "How does a computer work" question is not analoguous to the issue at hand. This one here is more about asking how a counting loop in C works: Asking this means you should do a tutorial first. Because you clearly didn't do a tutorial yet. Because if you did, you would know how a loop in C works and wouldn't have to ask.
Available now: My game "City Trouble".
Sales website: https://megacatstudios.com/products/city-trouble
Gameplay: https://youtu.be/Eee0yurkIW4
Download website: http://www.denny-r-walter.de/city.htm

User avatar
dustmop
Posts: 135
Joined: Wed Oct 16, 2013 7:55 am

Re: How does Donkey Kong have two CHR banks on screen?

Post by dustmop » Wed May 03, 2017 3:56 pm

DementedPurple wrote:I think I have enough knowledge to reprogram Donkey Kong with my own code.
Looking forward to your 2017 compo entry!

User avatar
toggle switch
Posts: 131
Joined: Fri Sep 30, 2016 8:57 pm

Re: How does Donkey Kong have two CHR banks on screen?

Post by toggle switch » Wed May 03, 2017 10:16 pm

it's more like steve jobs wrote a book about how computers work, and when you asked him how computers work, he said, "read the book"

curiosity is fine (and commendable) but you should absolutely extend it to reading actual documentation. it will help you. a lot.
Last edited by toggle switch on Wed May 03, 2017 10:19 pm, edited 1 time in total.

User avatar
gauauu
Posts: 648
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: How does Donkey Kong have two CHR banks on screen?

Post by gauauu » Wed May 03, 2017 10:17 pm

dustmop wrote:Looking forward to your 2017 compo entry!
Dang it, I want a "like" button on phpBB

User avatar
Bregalad
Posts: 7766
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: How does Donkey Kong have two CHR banks on screen?

Post by Bregalad » Wed May 03, 2017 11:28 pm

Your current questions are pretty basic and you could probably answer them yourself if you had a general understanding of the system.
I completely second what DRW said. This board is not stack overflow, we're not here to build a "database of question", and you're not encouraged to ask a question if you already know the answer. If your question can be answered by reading documenation about hardware (in this case it can) then I don't think it deserve to be asked here. I have nothing against newbie or anything - if you actually tried to do something but didn't understand I'd gladly answer without protesting.

But here you're basically asking "how does register $2000.3 and $2000.4 works" and you're even saying you already know the answer, so this therad is completely pointless. So please do not ask pointless questions - if you want to do so "just to build a database of questions and answer please use https://retrocomputing.stackexchange.com/ or anything else, not this site.
I doubt you were any better when you were 12 years old.
I was about this age when I understood the basic working of the NES, and I understood the concept of left and right pattern table very easily - and I had to do so with english doccumentation when I only started learning that language since a single year ! There was much less documentation long ago, no tutorial, no wiki. Only magic kit and nesticle, and Yoshi's docs and the WWWThread forum. So sorry but yes I personally "was any better".
Yet completely in character for Steve Jobs.

(Steve Wozniak on the other hand would probably love to explain...)
Not only that, but also I don't think Steve Jobs himself knew much about computers and programmings - he was the marketing guy.
Dang it, I want a "like" button on phpBB
Please no, this isn't facebook.

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: How does Donkey Kong have two CHR banks on screen?

Post by Memblers » Thu May 04, 2017 2:09 am

Stuff like this probably should be the newbie section, but it's not a huge deal.

Even though there is a lot of documentation and tutorials, more than there was in the past, it's still useful to ask about basic things. Especially for a beginner, sometimes you don't exactly know what question to ask, and that makes it hard to look up the answer. As the saying goes, "you don't know what you don't know". A little bit of insight and follow-up questions, if needed, can set someone in the right direction. The newbie section was originally intended for exactly this kind of thing.

I can hardly believe it's been that long, but over the last 20 years I've seen it happen several times where someone young and excited shows up with a lot of questions. It can annoy people, but it's definitely a good thing. I was about 16 when I got into NESdev, and I was very annoying, it's a little embarrassing to think about. :lol: But I learned a lot.

User avatar
Bregalad
Posts: 7766
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: How does Donkey Kong have two CHR banks on screen?

Post by Bregalad » Thu May 04, 2017 8:25 am

Memblers wrote:It's still useful to ask about basic things. Especially for a beginner, sometimes you don't exactly know what question to ask, and that makes it hard to look up the answer. As the saying goes, "you don't know what you don't know".
I have absolutely nothing against them asking the questions, but they should ask the smart way, and do a miniumum of preliminary reasearch. If he asked something he tried to understand that'd have been constructive. In this case it's not constructive because the question is trivial, and he even claims he already have the answer.

Post Reply