Sprites.chr is not appearing in PPU viewer

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
rainwarrior
Posts: 8002
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Sprites.chr is not appearing in PPU viewer

Post by rainwarrior » Thu Oct 16, 2014 9:37 am

3gengames: Please look it up and come back when you can actually explain what you're talking about. $EF-FF has been fine for my experience, and others' here.

By the way, you only have to set the Y component to $EF-FF, you don't have to set the whole unused sprite memory to it. For example, if you're done generating sprites for the frame and need to erase the rest of it, you can just write every 4th byte in the remaining space (i.e. the Y component) to hide them. The other 3 components to each sprite don't really matter in this case, once it's offscreen, it's offscreen.

3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Re: Sprites.chr is not appearing in PPU viewer

Post by 3gengames » Thu Oct 16, 2014 8:02 pm

viewtopic.php?t=4647

#$EF would mean is screen is disables towards the bottom it could trigger the bug with some sprites since you can still disable the screen with those being "calculated"

User avatar
rainwarrior
Posts: 8002
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Sprites.chr is not appearing in PPU viewer

Post by rainwarrior » Thu Oct 16, 2014 8:34 pm

After reading that thread, there is really nothing specific about that problem to $EF, but a problem with disabling rendering late in the frame? From what I could gather, it would only be a problem if you specifically disabled rendering on scanline $EF. Even if you were going to disable rendering late in the frame (a very advanced technique, not really pertinent to this thread), why on earth would you do it as late as scanline $EF?

3gengames
Formerly 65024U
Posts: 2281
Joined: Sat Mar 27, 2010 12:57 pm

Re: Sprites.chr is not appearing in PPU viewer

Post by 3gengames » Thu Oct 16, 2014 8:42 pm

Probably wouldn't, but yet better 100% sure it can't happen.

User avatar
Tsutarja
Posts: 123
Joined: Sun Oct 12, 2014 11:06 am
Location: Finland

Re: Sprites.chr is not appearing in PPU viewer

Post by Tsutarja » Fri Oct 17, 2014 1:03 am

Got it working now. I changed my clear memory part of the reset routine.

Code: Select all

ClearMem:		; Clear internal memory
 LDA #$FF
 STA $0200, x		; Set sprite memory to #$FF to render sprites off screen
 LDA #$00
 STA $0000, x		; Clear Zero Page
 STA $0100, x		; Clear Stack
 STA $0300, x
 STA $0400, x
 STA $0500, x
 STA $0600, x
 STA $0700, x
 DEX
 CPX #$00
 BNE ClearMem
Next I'll be adding boundaries for the player's sprite so it won't screen wrap (should I just check coordinates or use hitbox?). I'm also adding a projectile function to see if I can despawn it once it leaves the screen. Though, I don't know how to make the sprite leave the screen smoothly. At least the player just "disappears" to the other side when the coordinates underflow. Is this a limitation in hardware or is there a way around this? I haven't actually paid attention to this when I have played NES games so I can't say for sure if I have seen this happening or not.
UP SIDE DOWN A B A B B A B A Hidari migi
L R L R STOP & DASH & UP & TALK Ijou nashi

User avatar
Kasumi
Posts: 1292
Joined: Wed Apr 02, 2008 2:09 pm

Re: Sprites.chr is not appearing in PPU viewer

Post by Kasumi » Fri Oct 17, 2014 5:40 am

Next I'll be adding boundaries for the player's sprite so it won't screen wrap (should I just check coordinates or use hitbox?)
Coordinates is fine. Edit: Well... I guess you do still need to add the width or height of the sprite to the coordinates so that going off each side is symmetrical.
Though, I don't know how to make the sprite leave the screen smoothly.
For the right and bottom of the screen, add to the sprite's position. If the carry ends up set (adding 1 to 255 would wrap to 0 and set the carry), don't draw the sprite that frame and destroy the object.

For the top/left of the screen, subtract from the sprite's position. If the carry ends up clear, don't draw the sprite that frame and destroy the object.

Edit: With scrolling or other things that make detecting offscreen more complicated, the above alone can't be used by itself. But that should give you an idea of how to move things offscreen.

You cannot easily make the sprite visually leave smoothly from the top of the screen. The topmost coordinate you can supply is 0, and that still draws the entire sprite. Offscreen = not drawn at all, so all 8 pixels of the sprite would disappear in a frame when leaving from the top.

For the left of the screen, you can mask out the left most 8 pixels of sprites and the background with $2001. This means 0, the leftmost coordinate, is a fully masked sprite. 1 is the rightmost column of pixels in the sprite is drawn, the rest of it is not. Edit: Note that this just kind of makes the leftmost eight pixels a "border" with your background color for sprites to disappear into. The border still occupies screen space.

So... yes, it's a limitation, but only for twoish sides :lol: .

User avatar
rainwarrior
Posts: 8002
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Sprites.chr is not appearing in PPU viewer

Post by rainwarrior » Fri Oct 17, 2014 7:01 am

Tsutarja wrote:

Code: Select all

DEX
CPX #$00
BNE ClearMem
The CPX #$00 is redundant. Most instructions that change a value will set the zero flag if the result is zero, so the DEX instruction will set you up for BNE/BEQ already. It is very rare that you would ever need to explicitly compare against zero.

Post Reply