It is currently Wed Oct 18, 2017 8:01 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Four 2006 Writes? (SMB3)
PostPosted: Mon Jul 11, 2005 8:32 pm 
In a trace of SMB3 I came across an interesting piece of code. This was traced while Mario was scrolling to the right in-stage. I noticed that 2006 is written to 4 times in a row without any 2002 read in the middle:

$F51D:AD 02 20 LDA $2002 = #$07 A:00 X:00 Y:00 P:nvUbdIZc
$F520:A9 3F LDA #$3F A:07 X:00 Y:00 P:nvUbdIzc
$F522:8D 06 20 STA $2006 = #$20 A:3F X:00 Y:00 P:nvUbdIzc
$F525:A9 00 LDA #$00 A:3F X:00 Y:00 P:nvUbdIzc
$F527:8D 06 20 STA $2006 = #$20 A:00 X:00 Y:00 P:nvUbdIZc
$F52A:8D 06 20 STA $2006 = #$00 A:00 X:00 Y:00 P:nvUbdIZc
$F52D:8D 06 20 STA $2006 = #$00 A:00 X:00 Y:00 P:nvUbdIZc

What do y'all think of that?


Top
  
 
PostPosted: Mon Jul 11, 2005 8:34 pm 
beneficii wrote:
In a trace of SMB3 I came across an interesting piece of code. This was traced while Mario was scrolling to the right in-stage. I noticed that 2006 is written to 4 times in a row without any 2002 read in the middle:

$F51D:AD 02 20 LDA $2002 = #$07 A:00 X:00 Y:00 P:nvUbdIZc
$F520:A9 3F LDA #$3F A:07 X:00 Y:00 P:nvUbdIzc
$F522:8D 06 20 STA $2006 = #$20 A:3F X:00 Y:00 P:nvUbdIzc
$F525:A9 00 LDA #$00 A:3F X:00 Y:00 P:nvUbdIzc
$F527:8D 06 20 STA $2006 = #$20 A:00 X:00 Y:00 P:nvUbdIZc
$F52A:8D 06 20 STA $2006 = #$00 A:00 X:00 Y:00 P:nvUbdIZc
$F52D:8D 06 20 STA $2006 = #$00 A:00 X:00 Y:00 P:nvUbdIZc

What do y'all think of that?


Let me write that again. This thing won't let me delete my old post.

Code:
$F51D:AD 02 20  LDA $2002 = #$07           A:00 X:00 Y:00 P:nvUbdIZc
$F520:A9 3F     LDA #$3F                   A:07 X:00 Y:00 P:nvUbdIzc
$F522:8D 06 20  STA $2006 = #$20           A:3F X:00 Y:00 P:nvUbdIzc
$F525:A9 00     LDA #$00                   A:3F X:00 Y:00 P:nvUbdIzc
$F527:8D 06 20  STA $2006 = #$20           A:00 X:00 Y:00 P:nvUbdIZc
$F52A:8D 06 20  STA $2006 = #$00           A:00 X:00 Y:00 P:nvUbdIZc
$F52D:8D 06 20  STA $2006 = #$00           A:00 X:00 Y:00 P:nvUbdIZc


Top
  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 9:39 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19094
Location: NE Indiana, USA (NTSC)
Writing $3F $00 to $2006 resets the palette pointer. In some cases, when the background is turned off, the PPU will display the color that the palette pointer points to instead of color 0 for the background.

Then writing $00 $00 resets the scroll position to (0, 0) of the $2000 nametable.

Disassemble SMB1 and you'll find the same code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 10:20 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
tepples wrote:
In some cases, when the background is turned off, the PPU will display the color that the palette pointer points to instead of color 0 for the background.


Correct - it does that whenever the VRAM address is pointing at the palette and rendering is turned off.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 11:34 pm 
Quietust wrote:
tepples wrote:
In some cases, when the background is turned off, the PPU will display the color that the palette pointer points to instead of color 0 for the background.


Correct - it does that whenever the VRAM address is pointing at the palette and rendering is turned off.


But the background wasn't off during the part of the game I was tracing. What are the effects if the background is on?


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 12:41 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19094
Location: NE Indiana, USA (NTSC)
Quietust wrote:
tepples wrote:
In some cases, when the background is turned off, the PPU will display the color that the palette pointer points to instead of color 0 for the background.

Correct - it does that whenever the VRAM address is pointing at the palette and rendering is turned off.

Does this apply to the 8-pixel mask region at the left side? Does it apply when sprite rendering is turned on but BG rendering is turned off?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 1:29 pm 
Quote:
Correct - it does that whenever the VRAM address is pointing at the palette and rendering is turned off.


Wait! So you mean I can turn the screen off and draw stuff just by pointing to the correct palette entry? Thats like drawing pixel by pixel, except it would take longer then one actual pixel to set the pointer... but it is still usefull! Do any emulators implement this? Man, I think this can be VERY usefull if it works like you're saying...


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 2:03 pm 
toku wrote:
Quote:
Correct - it does that whenever the VRAM address is pointing at the palette and rendering is turned off.


Wait! So you mean I can turn the screen off and draw stuff just by pointing to the correct palette entry? Thats like drawing pixel by pixel, except it would take longer then one actual pixel to set the pointer... but it is still usefull! Do any emulators implement this? Man, I think this can be VERY usefull if it works like you're saying...


What do you mean, Draw stuff just by pointing to the correct palette entry?

Of course emulators have implemented this. This is done in SMB3.


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 2:38 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
beneficii wrote:
What do you mean, Draw stuff just by pointing to the correct palette entry?

Of course emulators have implemented this. This is done in SMB3.


Uhh, no it isn't. Very few emulators (my emulator being one of them) implement turning rendering off and pointing the VRAM address at the palette to draw specific colors on the screen.

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 3:23 pm 
Quietust wrote:
beneficii wrote:
What do you mean, Draw stuff just by pointing to the correct palette entry?

Of course emulators have implemented this. This is done in SMB3.


Uhh, no it isn't. Very few emulators (my emulator being one of them) implement turning rendering off and pointing the VRAM address at the palette to draw specific colors on the screen.


What's your emulator called?


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 3:39 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 10:59 pm
Posts: 1389
My emulator is called Nintendulator and can be found at http://nintendulator.sourceforge.net/

_________________
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 3:48 pm 
Quietust wrote:
My emulator is called Nintendulator and can be found at http://nintendulator.sourceforge.net/


Oh, I have that emulator. It's pretty accurate, but it's fairly slow (perhaps because I have a 366mHz processor computer?).


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 5:40 pm 
beneficii wrote:
What do you mean, Draw stuff just by pointing to the correct palette entry?

Of course emulators have implemented this. This is done in SMB3.


I meant we could draw things to the screen by turning the BG off and change $2006 at hte right times to point to wichever color we want to draw.

Not that obvious as you can see... just because SMB3 runs it doesn't mean it runs perfectly, and the missemulation of this feature might go unnoticed pretty easily...

I think this is great... I was a little upset because I thought color 0 would always be on screen whenever the BG was turned off, so, for me, this is great news.

Why didn't anyone document this before? I've seen discussions about this topic and people always said color 0 would be drawn.

Well, I'm just glad I got to know this! Thanks guys!

-tokumaru-


Top
  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 6:41 pm 
Offline

Joined: Sun Nov 14, 2004 11:24 am
Posts: 330
Do you have any plans to add a full screen mode and/or vsync?
Maybe a scan line option? (25/50/100%)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 12, 2005 7:41 pm 
Offline
User avatar

Joined: Tue Jul 12, 2005 4:37 pm
Posts: 121
Yeah, I never bought color 0 being drawn, because I've seen the screen turned off myself and in one emulator it's always grey when the screen is off.

Oh, so this keeps the screen a particular color when it is turned off?

toku wrote:
beneficii wrote:
What do you mean, Draw stuff just by pointing to the correct palette entry?

Of course emulators have implemented this. This is done in SMB3.


I meant we could draw things to the screen by turning the BG off and change $2006 at hte right times to point to wichever color we want to draw.

Not that obvious as you can see... just because SMB3 runs it doesn't mean it runs perfectly, and the missemulation of this feature might go unnoticed pretty easily...

I think this is great... I was a little upset because I thought color 0 would always be on screen whenever the BG was turned off, so, for me, this is great news.

Why didn't anyone document this before? I've seen discussions about this topic and people always said color 0 would be drawn.

Well, I'm just glad I got to know this! Thanks guys!

-tokumaru-


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: Tomy and 7 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:  
cron
Powered by phpBB® Forum Software © phpBB Group