Why do games do this

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Why do games do this

Post by Disch » Mon Jan 03, 2005 10:51 pm

LDA #$3F
STA $2006
LDA #$00
STA $2006
STA $2006
STA $2006


I've seen this in several games, and even some demos (Q's Copper Bars). They're even usually followed by more $2006 or $2005 writes... which makes it seem pretty useless.

Anyone know what's up with that? Thanks

tepples
Posts: 22284
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Jan 03, 2005 11:14 pm

Fragment 1:

Code: Select all

lda #$3f
sta $2006
lda #$00
sta $2006
This sets a PPU-internal palette pointer to 0. You should do this after a partial palette update, or Bad Things will happen to your background color

Fragment 2:

Code: Select all

lda #$00
sta $2006
sta $2006
This sets the VRAM address to $0000, which has the effect of scrolling to (0, 0) of nametable $2000. Loopy's scrolling doc explains this in more detail.

Nessie
Posts: 134
Joined: Mon Sep 20, 2004 11:13 am
Location: Sweden
Contact:

Post by Nessie » Mon Jan 03, 2005 11:51 pm

tepples wrote:This sets a PPU-internal palette pointer to 0. You should do this after a partial palette update, or Bad Things will happen to your background color
PPU-internal palette pointer?
Hmm, are you saying that this:

Code: Select all

lda #$3f
sta $2006
lda #$10
sta $2006
would result in the sprite palette being used for the background?

User avatar
Quietust
Posts: 1687
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust » Tue Jan 04, 2005 10:24 am

There are no palette entries at addresses 3F10/3F14/3F18/3F1C - they simply point to 3F00/3F04/3F08/3F0C. The reason you set the palette address to 3F00 at all is so the screen will be set to the correct color when rendering is disabled; otherwise, the PPU will output whatever palette entry was selected last (which is usually NOT what you want).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
laughy
Posts: 41
Joined: Wed Nov 17, 2004 12:34 pm
Contact:

o_o

Post by laughy » Thu Jan 06, 2005 3:00 am

Did I miss a doc explaining the extra workings of $2006...

Post Reply