It is currently Mon Dec 17, 2018 1:16 pm

 All times are UTC - 7 hours

 Page 1 of 1 [ 10 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: APU Frame SequencerPosted: Sun Jan 16, 2005 7:31 pm

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Tell me if i have understand well:

The Frame Sequencer has a divider and a sequencer. The divider divides the 240 hz input that recives. If mode is "0", divider is set to "4", that means that the sequencer will be clocked EVERY 60hz. After that the sequencer will clock the corresponding units in steps of 60hz?

Is that right?

_________________
ANes

Top

 Post subject: Re: APU Frame SequencerPosted: Sun Jan 16, 2005 9:40 pm

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
I *think* you almost have it... although the way you word it is kind of funny.

Quote:
that means that the sequencer will be clocked EVERY 60hz

The wording "EVERY 60hz" is awkward. Remeber that "60 Hz" is the same thing as saying "60 times per second". The sequencer itself is actually clocked at roughly 240 Hz (meaning it gets a clock 240 times a second). On every clock, it takes another step through its sequence and the appropriate sound sub-systems get clocked.

Basically... you'll have the frame sequencer take another step through the sequence every 1/240th of a second -- if it would help to think in CPU cycles... that's about once every 7457.5 cpu cycles (1789772.7272 / 239.996 = 7457.5)

If you look at blargg's APU doc (ref: http://www.slack.net/~ant/nes-emu/apu_ref.txt ) he gives examples of what sound sub-systems are to be updated on each step in the sequence... for both modes.

Top

 Post subject: Throwaway?Posted: Mon Jan 17, 2005 5:00 am

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
im almost getting closing to throw away this project (Anes), for the demed APU.
But i will try, maybe after 5 or 6 years later, i will understand that god damnd docs says. I have been studing electronics, i have some concepts of hz and counters and dividers, but i cant get all the information and "dump" it in an emulator. Thats my f**n problem

_________________
ANes

Top

 Post subject: Posted: Mon Jan 17, 2005 7:33 am
 Formerly Fx3

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3155
Location: Brazil
The NES PPU refreshes (AFAIK) at 60Hz (or 60 frames per second). The pAPU uses these modes:

- 60Hz = 1 update in a frame (read 'update' as 'clock').
- 120Hz = 2 updates in a frame.
- 240Hz = 4 updates in a frame.

When 4017h is written & set the frame sequencer, there's 4 ("normal") or 5 steps (+1), up to specific bit \$80. Every step (AFAIK) takes 1/4th of frame.

-- AFAIK = as far as I know of...

_________________
Zepper
RockNES developer

Top

 Post subject: f**n apuPosted: Mon Jan 17, 2005 8:15 am

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Thanks Fx3, but i stil dont uderstand how to converts cpu clock cycles to frame sequencer hz, i dont understand how to implement what apu_ref means with square one, i mean that diagram of Square One that recives the sweep unit, the clock / 2 and all that.

Im almost lost and i think is better not no waste time in me getting explaing me.

MY BRAIN IS DEMAGED
i thougth i could make an emulator and it seems not, better i should to devote to make only "hello world's" messages.

anyway, thank for the help [im was going to put here a emoticon that says "ok man", i mean a pic with that rounded faces with a finger up, but this forum dont have them, so take all this braket as that symbol]

bye

_________________
ANes

Top

 Post subject: helpPosted: Mon Jan 17, 2005 10:20 am

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
ah.. and thanks to disch too, he also tried to help me a lot.
Thanks disch again.

_________________
ANes

Top

 Post subject: Posted: Mon Jan 17, 2005 11:29 am

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1849
You shouldn't give up =). This stuff is tricky and confusing at first, but once you get the hang of it it's a snap... and it's a great learning experience (not to mention I have loads of fun with it). If you stick with it... one day you'll be like "OOOOHhh! That's how it works" and everything will just all of the sudden snap into place.

One helpful thing I always try to do is get everything working in a common base. Having things running at all different rates (in Hz) is a pain in the arse to track... so it helps a whole lot to keep things in CPU cycles.

NTSC system has 179772.7272 cycles per second... knowing this... we can convert any other clock rate (in Hz) to CPU cycles with the following formula:

1789772.7272 / Rate_In_Hz = Rate_In_CPU_Cycles

So if the frame sequencer runs at ~240 Hz... then 1789772.7272 / 240 = ~7457.5. So you'd clock the frame sequencer once every 7457.5 CPU cycles

Now using a section of blargg's APU doc as a reference:
Code:
f = set interrupt flag
l = clock length counters and sweep units
e = clock envelopes and triangle's linear counter

mode 0: 4-step  effective rate (approx)
---------------------------------------
- - - f      60 Hz
- l - l     120 Hz
e e e e     240 Hz

mode 1: 5-step  effective rate (approx)
---------------------------------------
- - - - -   (interrupt flag never set)
l - l - -    96 Hz
e e e e -   192 Hz

You'll keep a counter which tracks your 'step'. Every clock... you'll increase that step by one -- and wrap to zero if it reaches 4 or 5 (depending on the mode -- 4 or 5 step). When the step is 0... the sub-systems in the first column get clocked first. Assuming mode 0... this would be only 'e' (Square 1's Envelope/Decay Unit). When the step is 1... you clock both 'e' and 'l' (Square 1's Length Counter and Sweep Unit)

I hope that clears it up a bit.... don't worry about asking questions... I love this stuff so I don't mind helping any way I can. If you do decide to quit that's okay... but I think you should stick with it ;)

Top

 Post subject: Posted: Mon Jan 17, 2005 12:26 pm

Joined: Mon Sep 27, 2004 11:51 pm
Posts: 101
ANes, check your email (the one found in the profile). I got something for ya.

_________________
http://hydesprojects.cjb.net/

Top

 Post subject: Posted: Mon Jan 17, 2005 1:54 pm
 Formerly Fx3

Joined: Fri Nov 12, 2004 4:59 pm
Posts: 3155
Location: Brazil
"When 4017h is written & set the frame sequencer, there's 4 ("normal") or 5 steps (+1), up to specific bit \$80. Every step (AFAIK) takes 1/4th of frame."

That means => 341/3 CPU clock cycles per scanline.
1/4th of frame implies => (341*262) / (3*4) => 89342 / 12 => 7445 cycles per frame quarter.

So, you update envelope, length counters... it depends of actual frame sequencer order.

_________________
Zepper
RockNES developer

Top

 Post subject: txhPosted: Mon Jan 17, 2005 3:04 pm

Joined: Tue Dec 21, 2004 8:35 pm
Posts: 600
Location: Argentina
Thanks now im understanding better guys and i have started a simple emulation, that i think its accurate, anyway i dont have any sound playing now, but ill keep trying.

Hyde: i checked my e-mail address and there were not a mail from you, and then checked the profile, and the mail address was ok!
Please if you have something interesting let me know!!
Thanks!!

_________________
ANes

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 10 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: Fiskbit and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki