Page 2 of 2

Posted: Tue Jan 23, 2007 12:40 pm
by never-obsolete
attribute tables allow you to change where portions of your background get their colors from.

Posted: Tue Jan 23, 2007 12:45 pm
by mog123
aah, i still don't understand.

how do i know which pallete color I'm using? what colors is the background using? random colors from my palette?

I just ****ing cant get it and im close to depression.

http://img109.imageshack.us/my.php?image=qweqwe6wk.png

This is my pallette file

None of the colors from my screen shot earlier are close to each other, i can't understand this.


Would loading a palette like this work? :

Code: Select all

lda #$3F
sta $2006
lda #00
sta $2006
lda #$0F     ;load black
sta #2007   ;into 2007

lda #$3F
sta $2006
lda #01
sta $2006
lda #$30     ;white
sta #2007   ;into 2007
and so on?

Posted: Tue Jan 23, 2007 12:51 pm
by tokumaru
mog123 wrote:so, i use either of these methods:

load a pal file

or load the values by hand to the 2007?
Yup. The code you posted was loading each value directly, not using the included file. To change the palette that way you'd have to change the number after each LDA command to the numbers of the colors you want.
What you see here is most likely the first tile in your CHR file, repeated all over the screen using the first palette. This is because the emulator you are using probably clears all the PPU memory, so you get tile $00 using palette $00.

In order to have a blank screen, you have to fill the name table being displayed with a blank tile, of the color you'd like to display. And also, fill the attribute tables with the indexes of the palettes you wish to use.

Writing to the name tables and attribute tables is done exactly as it is for the palette: set the address through $2006 and then write the data to $2007.

This code will fill the first name table with a specific tile:

Code: Select all

	lda #$20	;set the address of the first name table
	sta $2006
	lda #$00
	sta $2006
	lda #$80	;the number of the tile - change the number to test
	ldx #$F0	;repeat 240 times
ClearNT:
	sta $2007	;240 * 4 writes = 960 (number of tiles in a name table)
	sta $2007
	sta $2007
	sta $2007
	dex
	bne ClearNT
Just look for a blank tile and use it in place of the #$80 I used above.

Posted: Tue Jan 23, 2007 12:55 pm
by tokumaru
mog123 wrote:Would loading a palette like this work? :

Code: Select all

lda #$3F
sta $2006
lda #00
sta $2006
lda #$0F     ;load black
sta #2007   ;into 2007

lda #$3F
sta $2006
lda #01
sta $2006
lda #$30     ;white
sta #2007   ;into 2007
and so on?
Yes, but this is wasteful, since the PPU address is incremented automatically after each write to $2007. So, after the first write to $2007 (that places your color value at PPU address $3F00), the PPU address register will already be pointing to $3F01, so there is no need to set it to that value.

Posted: Tue Jan 23, 2007 12:55 pm
by mog123
read my next post.

the problem is that i don't know which palette value is which x.x
they aren't signed in anyway(see the link from my last reply)

I just have some colors and that's all

about the first tile, i knew it was all repeated.
But why does it use those colors?

Posted: Tue Jan 23, 2007 1:00 pm
by never-obsolete
because your attribute table is full of zeros, so the whole background uses palette "group" 0. go read up on attribute tables.

Posted: Tue Jan 23, 2007 1:01 pm
by tokumaru
mog123 wrote:But why does it use those colors?
Those must be the first colors in your palette.

How did you make that .pal file, and why aren't those the colors you expected?

Just for reference, here are the numbers of all colors:
Image

Please explain why those weren't the ones you expected.

Posted: Tue Jan 23, 2007 1:01 pm
by mog123
but which one is the palette group 0?

from where to where is group 0, then group 1, 2 ,3?

Posted: Tue Jan 23, 2007 1:05 pm
by mog123
tokumaru wrote:Please explain why those weren't the ones you expected.
http://img329.imageshack.us/my.php?imag ... qwe3yc.jpg

because they are the first 4 colours so i thought they are the 0 group

Posted: Tue Jan 23, 2007 1:05 pm
by Bregalad
Well, mog123, you should definitely go read a miminum amount of tutorials before coming asking questions. About each starter kit out there include some sample code to clear name tables, attributes tables, set a known palette and so on. Some tutorials contains minor errors, but after all we cannot teach all basics to each individuall wich just refuses to read tutorials.

So yeah, there is nothing complicated for a newbie in clearing the name table, attribute table and set the palette, just type down the code some of us posted above after having done the standard reset procedure, then turn the screen 'on' via $2001.

Posted: Tue Jan 23, 2007 1:07 pm
by mog123
I've read yoshi's nestech.txt, gbaguy's nes tutorials and the NESPrgmn, and I'm stuck with doing the palette.
I just don't know why are the colors used, insead of those i showed in the border on the screenshot.
Because everyone is telling that the colors from group 0 are loaded, It's logical that the first ones are always loaded, but which ones are the first ones
tell me that by looking at the screen i posted.

Posted: Tue Jan 23, 2007 1:10 pm
by never-obsolete
the wiki explains it all pretty well...

http://nesdevwiki.ath.cx/index.php/NES_PPU

Posted: Tue Jan 23, 2007 1:11 pm
by tokumaru
Well, if those are not the colors in the first palette (the first 4 colors) maybe the attribute table was not cleared with 0's. You should try doing it yourself (BTW, never rely on unitialized values! If you expect memory to have certain values, put the values there yourself!).

Have $2006 point to $23C0 and then write 64 0's to $2007, and see if then you get the colors in the first palette.

Posted: Tue Jan 23, 2007 1:25 pm
by mog123
HA! I've made it! I'm so darn happy :D

I loaded the pallete repeatedly, with:
white ; 30
red ; 16
black; 0F
blue; 01

And here's my result:

http://img440.imageshack.us/img440/2672/qw6fs.jpg


Thank you everybody for the supportive help.
Now(tomorrow) i'm going to go with name tables, and assigning palette groups.

If i'll have some questions, i'll ask here.

Posted: Tue Jan 23, 2007 4:41 pm
by tokumaru
mog123 wrote:I loaded the pallete repeatedly, with:
white ; 30
red ; 16
black; 0F
blue; 01
Well, if you only want to use one palette, that's one way to do it! =) Like this you don't have to even worry about the attribute tables (it doesn't matter what palette is pointed by them, since they're all the same).

But as soon as you want to use different palettes you have to master the attribute tables.