It is currently Mon Dec 18, 2017 4:12 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Wed May 03, 2017 11:58 am 
Offline

Joined: Mon Jan 30, 2017 5:20 pm
Posts: 303
Location: Colorado USA
Could I have it so that during Vblank, I could put Sprite Zero at the top corner so that I could use Sprite Zero Hit to know when the Vblank is over, and then once it's over, move sprite zero to where I need it to change scroll mid-screen?


Top
 Profile  
 
PostPosted: Wed May 03, 2017 12:14 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10172
Location: Rio de Janeiro - Brazil
No, because once the sprite 0 hit flag is set, it stays that way until the end of the frame (that and changing the OAM mid frame is far from trivial). The good news is that you can still use it to detect the end of vblank, because it gets cleared near the end of vblank (at beginning of the pre-render scanline), along with the sprite overflow flag and the vblank flag (if it hasn't been manually cleared by a $2002 read). So, as long as there was a sprite 0 hit in the previous frame, you can wait for it to be cleared in order to detect the end of vblank. Normally you'd only need that if you had raster effects near the top of the screen, though.


Top
 Profile  
 
PostPosted: Wed May 03, 2017 12:40 pm 
Offline
User avatar

Joined: Sat Sep 07, 2013 2:59 pm
Posts: 1517
DementedPurple wrote:
Speaking of sprite-zero-hit, it doesn't mention anywhere in the wiki how I would access it. It doesn't say anything about any memory addresses.

Yes, of course it does. From the link I was pointing you to:

http://wiki.nesdev.com/w/index.php?title=PPU_OAM&redirect=no#Sprite_zero_hits wrote:
While the PPU is drawing the picture, when an opaque pixel of sprite 0 overlaps an opaque pixel of the background, this is a sprite zero hit. The PPU detects this condition and sets bit 6 of PPUSTATUS ($2002) to 1 starting at this pixel, letting the CPU know how far along the PPU is in drawing the picture.


DementedPurple wrote:
Could I have it so that during Vblank, I could put Sprite Zero at the top corner so that I could use Sprite Zero Hit to know when the Vblank is over, and then once it's over, move sprite zero to where I need it to change scroll mid-screen?

Is there a specific reason why you want to know when vblank is over?
What operations do you want to do that need to be done exactly after vblank?

Usually, you set the scrolling position to 0,0 during vblank for the status bar and then you set it to the actual value when sprite 0 hits.

If you want a second scanline split, you can use the sprite overflow bit for the first split (simply put nine empty sprites at the desired location) and sprite 0 for the second one.
Sprite overflow has some issues though that you need to pay attention to.

_________________
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg


Top
 Profile  
 
PostPosted: Wed May 03, 2017 1:15 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
Quote:
That's really vague, the NES has a lot of memory addresses.


I suppose 'memory address' was wrong. The tech docs says it's an 'internal memory'...'control register' on the PPU chip (2C02), which is accessible from the CPU through the $2002 'PPU STATUS' register.

Also, in case you are confused. You can't write to OAM (sprite memory) during rendering. Only during V-blank. And, you SHOULD write to the OAM every frame (during V-blank), as OAM memory is volatile, and corrupts very quickly, if it is not written to. (Most emulators don't do this, but the real NES does).

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

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