[4.5.9] Objects overlap to oposite side of screen at scroll edge...

Jonny

Well-known member
Is this normal for scrolling games?
My objects are drawing / overlaping to the right edge of screen when they scroll onto the screen.
The right half of the heart goes away once past the scroll edge but if player stops here, the object is split over left and right side.

Probably haven't explained this very well. Does anyone know why this might be happening?

game_000.png
 

TakuikaNinja

Active member
Remember that objects are made up of 8x8 characters. The position of each character is typically calculated relative to a certain character (usually top left, unless NESmaker uses the centre of the object). This means that in cases where one side is on the edge of the screen, it would cause the other side's characters to be positioned on the other edge (i.e a position over/underflow).
Using the PPU's left side masking feature might make the issue less noticeable. You just need to change the value written to soft2001 in doLoadScreen.asm to do that.
There's always the option of assuming the overscan will hide it on most CRTs.
 

Jonny

Well-known member
Thank you for the explanation. That's exactly what I was looking for.
I've been playing a lot of scrolling games recently and was wondering why some have a hotizontal mask on the left side. I guess this is one of the reasons for that but tbh I think the masking is worse, especially when a lot of people will be playing on a modern screen using an emulator.
Unless it's possible to mask the objects only and not the background tiles?
In fact, I would happily do that on both scroll edges and have all objects appear slighly late by a sprites width. I need to learn a lot more before I attempt anything like that.
 

TakuikaNinja

Active member
Unless it's possible to mask the objects only and not the background tiles?
In fact, I would happily do that on both scroll edges and have all objects appear slighly late by a sprites width. I need to learn a lot more before I attempt anything like that.
You can do that, though the masking feature is only for the left side.
It's not that difficult to implement anyway. Near the bottom of the script I mentioned (look in loadAllSubroutines.asm for the file path), a binary value is written to a variable called soft2001. This variable is what's written to the PPU register $2001 during the NMI.
This is how the value written to $2001 affects the rendering, taken from the nesdev wiki:
Code:
7  bit  0
---- ----
BGRs bMmG
|||| ||||
|||| |||+- Greyscale (0: normal color, 1: produce a greyscale display)
|||| ||+-- 1: Show background in leftmost 8 pixels of screen, 0: Hide
|||| |+--- 1: Show sprites in leftmost 8 pixels of screen, 0: Hide
|||| +---- 1: Show background
|||+------ 1: Show sprites
||+------- Emphasize red (green on PAL/Dendy)
|+-------- Emphasize green (red on PAL/Dendy)
+--------- Emphasize blue
In your case, you want to set bit 2 to zero to hide the sprites on the left 8 pixels and keep everything else the same. (#%00011010)
 

Jonny

Well-known member
That's excellent, thanks again for your time. I'll head to the nesdev page, see if I can learn some extra stuff while im on this subject. This solution will work perfectly for what I need.
 

CutterCross

Active member
I've been playing a lot of scrolling games recently and was wondering why some have a hotizontal mask on the left side. I guess this is one of the reasons for that but tbh I think the masking is worse, especially when a lot of people will be playing on a modern screen using an emulator.
The background masking is usually for games that have multidirectional scrolling, or simply scroll horizontally with horizontal mirroring. It's implemented to hide attribute artifacts on the left side of the screen due to how close the left scroll seam is to the viewable window.

View: https://www.youtube.com/watch?v=wfrNnwJrujw
 
Last edited:

Jonny

Well-known member
Thanks again @TakuikaNinja and @CutterCross

I only just got around to using the soft2001 tip and it does almost what I hoped. What I didn't think of was the rest of the object would still appear on the left, so unless the object is 8 pixels wide, there's a 8px masked area, then the rest of the object is seen. Some people just can't be pleased haha!

So, I decided to take a look at some old official horizontal scolling games to try and figure out how they did it (i.e not have objects on right seam appear on the left while scrolling right). Curiously, what I noticed of the games I tried was that the object itself didn't 'spawn' until way past the seam (over 8px) but with NM the object draws as soon as its theoretically in view. This could be the way to go about it if I don't want anything to appear on the left. With a lot of people using emulators / modern screens I think the better solution is to have the object created when its past the seam rather than when its on it.

Maybe this sort of thing is what the 'Spawn Type' was intended for? Now I just need to figure out the better way to go about it. Do I attempt to make objects invisible until they get past a certain X axis position :unsure: I think I might need to be able to control when the object is actually being created. Not sure at the moment.
 

mouse spirit

Well-known member
This is an issue I had with my sword item when I was at an edge of the screen. Possibly try taking off screenwrap for the object. If non of these good answers satisfy.
Sadly what I did was make the sword disappear or destroy.
 

Jonny

Well-known member
This is an issue I had with my sword item when I was at an edge of the screen. Possibly try taking off screenwrap for the object. If non of these good answers satisfy.
Sadly what I did was make the sword disappear or destroy.

Where is screenwrap handled? I've not come accross that before.

Anyway, in the end it ended up being the easiest thing I've ever had to fix in NM. The code is already there, it's just commented out.

In doHandleObjects.asm

Code:
;CLC
;ADC #$10 ;; arbitrary - approximate width of objects

I'm not sure why it was decided to comment it out unless more people wanted objects to draw exactly within the camera and were happy with the wrapping?
 

CutterCross

Active member
This is an issue I had with my sword item when I was at an edge of the screen. Possibly try taking off screenwrap for the object. If non of these good answers satisfy.
Sadly what I did was make the sword disappear or destroy.
On the hardware level, sprites will wrap around to the other side of the screen when they leave the screen's borders. It's not an arbitrary decision by the object system, that's on the hardware level. It's up to the programmer to determine when to stop rendering each sprite to compensate for this.

PE_VscrollPauseTransitionGLITCH1.gif
 

Jonny

Well-known member
Looks kinda spooky!

Thanks for clarifying. I'm happy with how it looks now.
It feels more 'NES-like' for the diamonds to appear late.

EDGE.gif
 
Last edited:
Top Bottom