How did the score bar in Super Mario Bros. not scroll?
Moderator: Moderators
-
DementedPurple
- Posts: 318
- Joined: Mon Jan 30, 2017 5:20 pm
- Location: Colorado USA
Re: How did the score bar in Super Mario Bros. not scroll?
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?
Re: How did the score bar in Super Mario Bros. not scroll?
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.
Re: How did the score bar in Super Mario Bros. not scroll?
Yes, of course it does. From the link I was pointing you to: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.
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.
Is there a specific reason why you want to know when vblank is over?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?
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
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
Re: How did the score bar in Super Mario Bros. not scroll?
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.That's really vague, the NES has a lot of memory addresses.
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