Unwanted background tiles (Adventure 4.5.9)

I starting a project in which, after pressing start, the game generates a random map and places the player on it.
Then, by pressing start and proceeding to a sub-screen, you can confirm the map and where you are on it.

This all works mostly as intended so far, but as a side effect of adding the code that draws the map, I sometimes get unwanted background tiles when loading screens, like the one in the red rectangle in the screen shot below, and notably always the same tiles in the same locations, and always on edges.

Here's my code is set up:
When you press start to go to the map screen, on the map screen there is an invisible monster with action code that ticks up a variable called DrawMap and also places the blinking sprite to indicate the player's location on the map.
At the beginning of the NMI, there is a check to see if DrawMap is non-negative. If it is, it executes the code to draw the map. If it is 0, it skips the code and proceeds with the NMI code.
If I comment out all of my added NMI code, the unwanted tiles do not appear,
Is there a better place or way to place my code for drawing the map?
 

Attachments

  • map.png
    map.png
    3.3 KB · Views: 32
  • unwantedTile.png
    unwantedTile.png
    6.3 KB · Views: 33

JamesNES

Well-known member
I get this bug too so it's not something you've done. Every time it happens I'm in the middle of something else so I haven't tracked down yet, and it's hard to reproduce on demand! If I'm trying to catch it, it just doesn't happen. When I do get it I'll post it here
 
I don't know if you've added any code to draw to the background in your NMI.asm, but I've seemed to eliminate the issue by moving my code to line 120, right before "bit $2002". I don't know the details, but I remember reading somewhere that if you want to draw directly to the background, you should do it in certain places near your NMI. So I just tried putting my code in places that seemed logical to me and it seems to be working.

Code:
	LDA soft2001
	BNE doScreenUpdates
	JMP skipScreenUpdates
 doScreenUpdates:
 
 	LDA DrawMap  ; beginning of my code
	BEQ DoneDrawingMap
	JSR DrawMyMap
DoneDrawingMap: ; end of my code
	
	 bit $2002
	 LDA updateScreenData
	 AND #%00000001
	 BNE doPaletteUpdates
	 JMP +
 doPaletteUpdates:

I put the above subroutine at the bottom of the NMI file, after the RTI.
 

JamesNES

Well-known member
If it's after the RTI though it won't be part of the NMI routine. If you're wanting to draw stuff in NMI you should load it into scrollUpdateRam before NMI, then NES Maker is set up to draw them 16 8x8 tiles at a time each NMI.

The bug though is definitely a NES Maker thing, I get it even starting a brand new project. But it just won't happen when I'm looking at it! It catches me off guard, I rewind and turn a breakpoint on for that byte of vram, and then it doesn't happen again. So I give up and do something else!
 
Could just be coincidence, but I think I eliminated the issue by changing the Tile Layout for the row of screens that were causing the issue from Normal (Main/Screen/Path) to Double Main (Main/Main), because I don't use paths anyway - so I'm thinking the issue might be related to paths.
 
I don't know if you've added any code to draw to the background in your NMI.asm, but I've seemed to eliminate the issue by moving my code to line 120, right before "bit $2002". I don't know the details, but I remember reading somewhere that if you want to draw directly to the background, you should do it in certain places near your NMI. So I just tried putting my code in places that seemed logical to me and it seems to be working.

Code:
    LDA soft2001
    BNE doScreenUpdates
    JMP skipScreenUpdates
 doScreenUpdates:
 
     LDA DrawMap  ; beginning of my code
    BEQ DoneDrawingMap
    JSR DrawMyMap
DoneDrawingMap: ; end of my code
  
     bit $2002
     LDA updateScreenData
     AND #%00000001
     BNE doPaletteUpdates
     JMP +
 doPaletteUpdates:

I put the above subroutine at the bottom of the NMI file, after the RTI.
huh? interesting... I have this issue too... but I'm not ready to fix it yet due to two other annoying bugs... so yeah I hope this will solve my problem later!
 
Could just be coincidence, but I think I eliminated the issue by changing the Tile Layout for the row of screens that were causing the issue from Normal (Main/Screen/Path) to Double Main (Main/Main), because I don't use paths anyway - so I'm thinking the issue might be related to paths.
sorry to ask but can I see your JSR DrawMyMap code? I'm trying to change tiles the way you are too... during a loading screen
 
sorry to ask but can I see your JSR DrawMyMap code? I'm trying to change tiles the way you are too... during a loading screen

Sure, but I'm actually starting to think the issue is more a conflict with having a Tile Layout that includes paths, rather than the placement of the code in the NMI.asm, which I had originally thought. At any rate, I placed the six lines of code below in the NMI.asm around line 130, below LDA soft2001, as shown below:

Code:
	LDA soft2001
	BNE doScreenUpdates
	JMP skipScreenUpdates
 doScreenUpdates:
 
 	LDA DrawMap
	BEQ DoneDrawingMap
	SwitchBank #$19
	JSR DrawMyMap
	ReturnBank
DoneDrawingMap:

I'll also attach the subroutine that I JSR too, though I'm not sure it will be very helpful, but here it is:
 

Attachments

  • DrawMyMap.txt
    3.8 KB · Views: 2
Sure, but I'm actually starting to think the issue is more a conflict with having a Tile Layout that includes paths, rather than the placement of the code in the NMI.asm, which I had originally thought. At any rate, I placed the six lines of code below in the NMI.asm around line 130, below LDA soft2001, as shown below:

Code:
    LDA soft2001
    BNE doScreenUpdates
    JMP skipScreenUpdates
 doScreenUpdates:
 
     LDA DrawMap
    BEQ DoneDrawingMap
    SwitchBank #$19
    JSR DrawMyMap
    ReturnBank
DoneDrawingMap:

I'll also attach the subroutine that I JSR too, though I'm not sure it will be very helpful, but here it is:
Thanks for the script dude! I'll see what I can do with it!
 

JamesNES

Well-known member
Could just be coincidence, but I think I eliminated the issue by changing the Tile Layout for the row of screens that were causing the issue from Normal (Main/Screen/Path) to Double Main (Main/Main), because I don't use paths anyway - so I'm thinking the issue might be related to paths.
Funny! I removed all the path stuff from one of the screen loading scripts and haven't had the problem since (I wasn't even using paths). I haven't given it enough time yet to truly say it fixed it though, was a rare bug to start with.
 

dale_coop

Moderator
Staff member
Yes... the path engine causes graphical glitches in the 4.5.x version of nesmaker.
I really hope Joe will fix that in a future version.
 
Yes... the path engine causes graphical glitches in the 4.5.x version of nesmaker.
I really hope Joe will fix that in a future version.
Is there an easy way to remove all path related code? For starters, I've set my Handle Path Data script as a blank script.
I had managed to eliminate these errors for a long time, but after I started implementing music they have started occurring again. I'd greatly appreciated any help or ideas regarding this.
 

dale_coop

Moderator
Staff member
Yep, modify your "doLoadNametableData.asm" script (located in the "GameEngineData\Routines\BASE_4_5\Game\Subroutines\" folder).
Around line 101, you'll find:
Code:
doGetSingleMetaTileValues:
    STA temp

Just after the "STA temp" line, add this one:
Code:
JMP notPath

Your script should now looks like that:

2023-03-13 16_10_31-● doLoadNametableData.asm - Visual Studio Code.png


Voilà, no more path.
 
Thanks Dale, after some testing, it seems to have eliminated (or at the least greatly reduced) the issue :)

Does this also mean I could safely comment out some of the code related to paths in this file?
 
Yes, of course, to save some ROM space, you could remove some code from that script.

Just out of curiosity, I implemented the above "skip paths" code in a old project (one that uses scrolling), and I could play through the entire game without the "vertical column of incorrect tiles" glitch occurring. I can't for say sure if it eliminated the issue without more testing, but do you think the issue could also be related to paths?
 

SciNEStist

Well-known member
I'm afraid not. The vertical column issue can still present itself even after completely gutting all path related code.
 
Top Bottom