It is currently Sat Nov 18, 2017 6:11 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Fri Oct 06, 2017 8:35 am 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 137
Location: Hungary
Here's an idea that may or may not be useful, but I thought it would be worth sharing here. So the frame counter allows for clocking the length counters at a ~96Hz rate with the 5-step mode selected, and writing to $4017 clocks all the hardware timer units. By writing $18 to $400F and then $C0 to $4017 at the end of VBlank, you could set up another (albeit fixed timer) flag ($4015 noise bit) to poll for a raster effect that would be reliably lowered after 14 914 CPU cycles, since the $4017 write immediately decrements the 2-clock length counter table entry you have selected in $400F. Once the flag is lowered, an immediate write to $400F with say $08 would ensure that then oise channel would immediately start playing again, without causing any audible artifacts in the sound.
Could this be useful for a two-player split-screen game for example? (Provided that the first half of the frame can be filled with fixed-time or mostly fixed-time processes)


Top
 Profile  
 
PostPosted: Fri Oct 06, 2017 1:10 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1823
Location: DIGDUG
Quote:
14 914 CPU cycles


14 914 APU cycles.

To quote the wiki...

Quote:
In this mode, the interrupt flag is set every 29830 CPU cycles, which is slightly slower than the 29780.5 CPU cycles per NTSC PPU frame.


If set-up at the top of the frame, the IRQ wouldn't fire until past the bottom of the screen. I think, what you were proposing were useful, someone would have used it.

But, feel free to do some tests on hardware, and test it out. Prove me wrong.

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


Top
 Profile  
 
PostPosted: Fri Oct 06, 2017 1:34 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5822
Location: Canada
dougeff wrote:
IRQ

This isn't an IRQ, this is polling $4015 for when the noise shuts off. The "length counter" is ticked 2 times per frame, and can be synchronized with $4017 writes.

I'm not exactly sure why noise specifically is being suggested here. Wouldn't this work with any channel? The triangle's "linear counter" has a 4x per frame resolution instead, which might be more useful. I guess probably the brief interruption of noise would be the least noticeable of the 4 channels...? I think on any channel that's not silent you will get a 60hz buzz from the regular interruption, but it might be acceptably quiet.

The big drawback here is just not being able to time it very conveniently. You can't easily move it around like sprite 0. Seems like even DPCM would usually be a better option with its IRQ.

You could even position $4017's IRQ directly by writing it mid-screen. (Though it might start to gradually slip vs. NMI? I don't think it has the exact same timing as the NMI, but I haven't tested it.)


Top
 Profile  
 
PostPosted: Fri Oct 06, 2017 1:39 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
rainwarrior wrote:
You could even position $4017's IRQ directly by writing it mid-screen. (Though it might start to gradually slip vs. NMI? I don't think it has the exact same timing as the NMI, but I haven't tested it.)

Yeah, unfortunately the frame IRQ is slightly longer than the NMI period (as you can see in the quote in dougeff's post). It would be wayyy more useful if it was slightly shorter than NMI instead. :/

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Oct 07, 2017 6:17 am 
Offline
User avatar

Joined: Fri Jan 24, 2014 9:05 am
Posts: 137
Location: Hungary
dougeff wrote:
Quote:
14 914 CPU cycles


14 914 APU cycles.

I did mean CPU cycles. Since the write immediately decrements the length counter of the channel in question, only 2 frame counter steps out of the 5 have to occur before the length counter gets clocked again, which amounts to 7456.5 APU cycles.

rainwarrior wrote:
I'm not exactly sure why noise specifically is being suggested here. Wouldn't this work with any channel? The triangle's "linear counter" has a 4x per frame resolution instead, which might be more useful. I guess probably the brief interruption of noise would be the least noticeable of the 4 channels...? I think on any channel that's not silent you will get a 60hz buzz from the regular interruption, but it might be acceptably quiet.

That's the basic idea, I thought it would be a lot less apparent with the noise, especially when it's playing at lower pitches, since the buzz (if any) would be buried in mix anyway, and whenever the time period of the channel stopping and you rewriting $400F again would line up with a 0 output bit from the LFSR, there really shouldn't be any artifacts present. Also, the linear counter stopping the channel is not reflected in the state of the triangle flag at $4015, all of those bits care about the corresponding length counters only.


Top
 Profile  
 
PostPosted: Sat Oct 07, 2017 8:19 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3950
Speaking of silly stupid ideas, you could also start with a sprite 0 hit, then set an APU frame IRQ to go off one frame and ~200 dots later. The Frame IRQ could interrupt code that runs long and prevents the sprite 0 polling loop from getting reached in time.

APU frame IRQ has the advantage of not interfering with anything else sound-wise, except for the sweep trick to set high bits of square channels. Nobody should be using the length counters and envelopes anyway.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


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

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