It is currently Tue Oct 24, 2017 12:36 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Mar 29, 2017 3:25 am 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 133
Location: Hungary
For one of my stages in my game with lava at the bottom, I'd like to create a sine wave movement pattern to make things look more interesting. However, my game is small and is based on very simple cart hardware so I use the DMC for raster effects. I know that I need to do this with timed code because for the effect to look nice I have to be able to change the X scroll every scanline, which is not possible with DMC IRQs alone. I have minimized the jitter from the uneven timing but there's still up to about half a scanline's worth of difference and I'd have to start my timed code at the same pixel (or close to the same pixel) every frame. Is there any way to do this without bringing sprite 0 into the picture? My only idea is that I'd wait for an IRQ a bit above the lava and then start polling the sprite 0 bit to get the proper timing, but I can't afford to risk missing one of these hits because I also need the sprite 0 bit to be set during the frame to wait for the end of Vblank at the end of the frame (needed for the IRQ timing adjustment).


Top
 Profile  
 
PostPosted: Wed Mar 29, 2017 6:05 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7235
Location: Chexbres, VD, Switzerland
Quote:
Is there any way to do this without bringing sprite 0 into the picture?

Short answer : Probably not, the DMC only has approximate timing and can serve as a way to get a broad IRQ approximately before an expected sprite zero hit, but it does not replace the said sprite zero hit.

Long answer : Actually it's possible to work around this by using 2 interrupts and measure time before the 1st one gets triggered and compensate for that. Look at Tepple's "letterbox" demo in order to have an example of how to achieve that. This is however highly non-standard and you shouldn't expect emulators or famiclones to behave correctly on this one.

Depending on what your game is you might not even need DMC at all, just run your game logic and poll sprite zero hit afterwards - however if your game logic takes too long then you'll have problems, while with DMC it's safer and you know that slow-downs will be handled correctly. So if you are afraid your game would slow down and you want the graphics to continue to look fine even through there is slow down, then keep your DMC system. (Plenty of games such as Super Mario Bros or Double Dragon have glitches when they slow down but they didn't care).

Quote:
but I can't afford to risk missing one of these hits because I also need the sprite 0 bit to be set during the frame to wait for the end of Vblank at the end of the frame (needed for the IRQ timing adjustment).

Then you have to set up your graphics so that there's a reliable sprite zero hit anyway, no ? Then I don't see how make it just before your lava section changes a thing - there's plenty of ways to make your sprite zero invisible, the most obvious one is to use a black sprite behind BG and on a background colour set to black, but that's not the only way.


Top
 Profile  
 
PostPosted: Wed Mar 29, 2017 6:37 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1787
Location: DIGDUG
If you switch to MMC3, you can do a scanline count IRQ, which is more reliable than other IRQs.

Probably other mappers too. IDK.

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 7 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