It is currently Sat Sep 23, 2017 4:47 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Screen Transitioning
PostPosted: Fri Apr 07, 2017 10:39 am 
Offline
User avatar

Joined: Wed Sep 21, 2016 12:08 pm
Posts: 33
I appreciate all the help this forum has given me so far, but I'm back with another problem.

I currently have a menu screen where you select the next screen by using the d-pad (up, down) and the SELECT button.

This menu works fine, but when it transitions to the next screen I get a strange effect were the top of the screen is filled will a block of 0's.

Attachment:
Untitled.png
Untitled.png [ 65.4 KiB | Viewed 1087 times ]


I am using FCEUX as my emulator and confirmed that the nametable was correctly loaded in the PPU.

I included the ASM6 Project in the .ZIP file attached.

I've included a PDF of the game engine flowchart to help describe the flow.


Attachments:
NES Game Engine.pdf [243.19 KiB]
Downloaded 43 times
MenuTest.zip [41.1 KiB]
Downloaded 37 times
Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Fri Apr 07, 2017 10:56 am 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10012
Location: Rio de Janeiro - Brazil
Are you setting the scroll before turning rendering back on after the NT update?


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Fri Apr 07, 2017 11:02 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5643
Location: Canada
After writing to the PPU with $2006 the scroll position has been overwritten and you need to restore it, usually with two writes to $2005, which will take effect at the end of the next vblank. Your program does not appear to write to $2005 at all?

Maybe this article will help: https://wiki.nesdev.com/w/index.php/PPU_scrolling


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Fri Apr 07, 2017 11:13 am 
Offline
User avatar

Joined: Wed Sep 21, 2016 12:08 pm
Posts: 33
rainwarrior wrote:
After writing to the PPU with $2006 the scroll position has been overwritten and you need to restore it, usually with two writes to $2005, which will take effect at the end of the next vblank. Your program does not appear to write to $2005 at all?


I wasn't trying to attempt scrolling during the transition.
It should be reloading the new nametable, attributes, sprites, etc. over the old table data.
I guess I am just not understanding the write to $2005.

I'll play around with it an see where it should go in the game engine.


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Fri Apr 07, 2017 12:04 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10012
Location: Rio de Janeiro - Brazil
Lucradan wrote:
I wasn't trying to attempt scrolling during the transition.

That doesn't matter. The internal registers used by the PPU to write/read to/from VRAM are the same that are used for rendering/scrolling. If you mess with VRAM, you mess with the scroll, so the scroll must be restored before the picture is displayed, preferably every frame. This means selecting a name table through the lower 2 bits of register $2000, as well as the vertical and horizontal scroll positions through register $2005. Ideally you should do that every frame, after any VRAM updates you might have in your vblank handler.


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Sat Apr 08, 2017 2:36 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7208
Location: Chexbres, VD, Switzerland
Just to make it clear - rewriting to $2005/$2005/$2000 is necessary at the end of each VBlank which had VRAM updates (because $2006 was used, and $2006 is basically $2005 with bits reordered so writing to one register pairs affects the other). Since you usually have VRAM updates often enough, it's simpler to write to $2005/$2005/$2000 every frame without asking questions as Tokumaru suggests. However technically you have to do it only when $2006 was used.


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Sat Apr 08, 2017 2:50 pm 
Online
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10012
Location: Rio de Janeiro - Brazil
That's true. The reason I often suggest setting the scroll every frame is because there are more things that can affect the scroll than just VRAM updates during vblank, such as status bars or other raster effects, so instead of detailing all of that it's just easier to suggest resetting the scroll every frame.


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Mon Apr 10, 2017 9:14 am 
Offline
User avatar

Joined: Wed Sep 21, 2016 12:08 pm
Posts: 33
Thank you everyone.

When I got a chance to play with it, I found all I had to to do was add a few lines to the EnableRendering NMI Code

Code:
LBL.NMI.EnableRendering:
  LDA #%00011110
  STA $2001

  LDA VAR.NMIState.Wait
  STA VAR.NMIState

  ;******New Code**************
  LDA #%10010000   ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
  STA $2000
  LDA #$00        ;;tell the ppu there is no background scrolling
  STA $2005
  STA $2005
  ;****************************

  RTS


This also fixed an issue when I would get a screen full of 0's for a few frames in between the transition.

Next stop is to build a sprite animation engine and then RLE Compression.


Top
 Profile  
 
 Post subject: Re: Screen Transitioning
PostPosted: Mon Apr 10, 2017 10:46 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1731
Location: DIGDUG
Quote:
Next stop is to build a sprite animation engine and then RLE Compression.


You could use existing libraries, like neslib.s, which works with NES screen tool.

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


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

All times are UTC - 7 hours


Who is online

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