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.
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.
Screen Transitioning
Moderator: Moderators
Screen Transitioning
- Attachments
-
- NES Game Engine.pdf
- (243.19 KiB) Downloaded 120 times
-
- MenuTest.zip
- (41.1 KiB) Downloaded 120 times
Re: Screen Transitioning
Are you setting the scroll before turning rendering back on after the NT update?
- rainwarrior
- Posts: 8734
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Screen Transitioning
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
Maybe this article will help: https://wiki.nesdev.com/w/index.php/PPU_scrolling
Re: Screen Transitioning
I wasn't trying to attempt scrolling during the transition.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?
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.
Re: Screen Transitioning
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.Lucradan wrote:I wasn't trying to attempt scrolling during the transition.
Re: Screen Transitioning
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.
Re: Screen Transitioning
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.
Re: Screen Transitioning
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
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.
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: Select all
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
Next stop is to build a sprite animation engine and then RLE Compression.
Re: Screen Transitioning
You could use existing libraries, like neslib.s, which works with NES screen tool.Next stop is to build a sprite animation engine and then RLE Compression.
nesdoug.com -- blog/tutorial on programming for the NES