It is currently Wed Aug 15, 2018 12:12 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Dec 08, 2005 6:43 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2149
Location: Minneapolis, Minnesota, United States
Okay, I really SHOULD already know this, but I don't because I've just used tepples "name" program to make backgrounds. Now. I tried to make just a simple hello world program, and tried changing the attributes manually, and it works, but it skips a section each time. Like do this:

lda #$23
sta $2006
lda #$C0
sta $2006

lda #$01
sta $2007
sta $2007

and it will make 1 2x2 section pallete #$01 rather than #$00, and it will skip one, then color the one right after that. I am sure all of you know that, and know what the heck the deal is. This is why I'm coming to you. Can you help me? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 7:23 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
In the following... when I use the term "block", I mean 2x2 tile squares (16x16 pixels)

Each one byte of the attribute data contains data for FOUR blocks. So everytime you write to the attribute table, you're changing 4 blocks' attribute data (a whole 32x32 pixel area on the screen).

You're writing $01 to the attribute table.. each 2 bits of that byte will set the color for one of the blocks in the respective area.

$01 -> %00000001 -> 00, 00, 00, 01

So you're only setting the upper-left block of the 32x32 area to use palette 1, and the upper-right block is still using palette 0 (along with both lower blocks).

For greater detail on how the attribute table works, I recommend you browse nestech's attribute table section.


To clarify why this is skipping a block:

1) Attribute table starts out zero'd out. So it looks like the following (upper-left corner of the attr table):

000000..
000000..
000000..
000000..
....

2) You're first write to the attribute table (write $01) sets the upper left block to use palette 1, all other blocks in the same area to use palette 0. Attr table now looks like the following (changed sections bolded):

100000..
000000..
000000..
000000..
....

3) The address is incremented on that write, so your next write (another write of $01) changes the next attribute area in the same manner (changed sections bolded):

101000..
000000..
000000..
000000..
....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 08, 2005 7:39 pm 
Offline
User avatar

Joined: Sun Jun 05, 2005 2:04 pm
Posts: 2149
Location: Minneapolis, Minnesota, United States
Oh, thank you! That cleared a whole lot up for me! Thanks Disch! :)


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

All times are UTC - 7 hours


Who is online

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