It is currently Sun Sep 15, 2019 7:35 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jan 30, 2019 7:16 am 
Offline
User avatar

Joined: Wed Jan 16, 2019 9:13 pm
Posts: 17
Location: Lower East Side
I've made an example of writing the background of an entire room. Here's the relevant code and nes file which doesn't do anything other than display the background:

Image

If you were making a game that consists of rooms like this, is this a good way of storing and writing backgrounds?

Do folks write backgrounds in different ways? Maybe for different layouts, like side-scrollers?

Thanks to rainwarrior for the starter code!


Last edited by ericandrewlewis on Thu Jan 31, 2019 7:23 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Jan 30, 2019 9:09 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2559
Location: DIGDUG
This is ok for a very small game. A larger game would prefer some kind of compression.

I have an issue with your palette code. The universal background color has mirrors, so writing to (for example) 3f10 would change it.

So the simple fix would be to do a 33rd write, just after you palette code, which would be 3f20, another mirror for the BG color.

LDA palette ;get the 0th color
STA $2007

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Jan 30, 2019 6:40 pm 
Offline
User avatar

Joined: Wed Jan 16, 2019 9:13 pm
Posts: 17
Location: Lower East Side
dougeff wrote:
This is ok for a very small game. A larger game would prefer some kind of compression.


Yeah, this is data is heavy at 960 bytes. Seems like run-length encoding could bring this down significantly.

dougeff wrote:
I have an issue with your palette code. The universal background color has mirrors, so writing to (for example) 3f10 would change it.

So the simple fix would be to do a 33rd write, just after you palette code, which would be 3f20, another mirror for the BG color.

LDA palette ;get the 0th color
STA $2007


The palette loop writes the palette definition into the PPU at $3f00-$3f1f. The definition includes duplicate values ($0f) for the background memory address $3f00 as well as each of its mirror addresses. So $0f is written to $3f00 as well as $3f04, $3f08, $3f0c, $3f10, $3f14, $3f18, and $3f1c.

Is this bad? What would the affect of writing this value to $3f20 be, if the original and mirrors have all been written to the same?

I do notice this in the PPU palettes wiki page:

Le Wiki wrote:
A symptom of not having implemented this correctly in an emulator is the sky being black in Super Mario Bros., which writes the backdrop color through $3F10.


but I'm not sure I understand what that means. Is writing to $3f10, $3f14, $3f18, and $3f1c dangerous even if it's the same universal background color?

Thanks for taking a look!


Top
 Profile  
 
PostPosted: Wed Jan 30, 2019 7:23 pm 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21591
Location: NE Indiana, USA (NTSC)
Writes to $3F14, $3F18, and $3F1C have no effect under normal display conditions. Writes to $3F10 will overwrite $3F00, so if you write both, the one written last takes precedence.

_________________
Pin Eight | Twitter | GitHub | Patreon


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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