apu quick question

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Zepper
Formerly Fx3
Posts: 3190
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

apu quick question

Post by Zepper » Wed Nov 17, 2004 1:48 pm

is correct to output 1 sample at every 1.79*60/44.1 CPU clock cycles, or is my logic wrong?

CPU_CLOCK * 60 / SAMPLE_RATE

TKS

User avatar
Disch
Posts: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Wed Nov 17, 2004 1:54 pm

1789772 -- pAPU cycles per second
44100 -- Samples per second (assuming 44KHz output)

therefore: ~40.58 pAPU cycles per sample (CPU_CLOCK / SAMPLE_RATE)

User avatar
Quietust
Posts: 1488
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust » Wed Nov 17, 2004 2:06 pm

Sounds right - this is exactly what my sound core does.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
Zepper
Formerly Fx3
Posts: 3190
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Wed Nov 17, 2004 3:37 pm

Yeah, but slightly different, this way [NTSC PPU clock cycles]:

LINE_CYCLES = 341 PPU cc's
CYCLES_PER_FRAME = 341*262 = 89342
CYCLES_PER_SECOND = 89342*60 = 5360520
SAMPLE_RATE = 44100Hz

then = CYCLES_PER_SECOND / SAMPLE_RATE
then = 5360520 / 44100 = ~121.55 cycles/sample (or ~40.51 CPU cc/sample)

User avatar
laughy
Posts: 41
Joined: Wed Nov 17, 2004 12:34 pm
Contact:

Post by laughy » Thu Nov 18, 2004 12:47 am

This is probably due to the fact the ppu doesn't render at EXACTLY 60 frames per second.

Prolly more accurate to go with the cpu timing, since this is how the apu is clocked.

My question is what about the dead cycle on every odd frame brad was talking about. Does this mean that it's not really 341 * 262 * ~60, but really

(341 * 262 * ~30) + (340 * 262 * ~30) cycles per second?

:|

User avatar
Quietust
Posts: 1488
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust » Thu Nov 18, 2004 1:22 am

The CPU runs at 1.78977272727MHz, with a small amount of variance. The PPU runs at (341*262-1/2)/3 = 29780.5 CPU cycles per frame.
The actual framerate works out to be about 60.0988Hz for NTSC.

As for laughy's question, the cycle difference every other frame only applies to the FIRST scanline, not all 262 of them.

As for PAL, CPU speed is 1.662607MHz, and the PPU runs at (341*312*50)/3.2 = 33247.5 CPU cycles per frame (a test rig made by Kevin Horton showed that the PAL PPU does *not* have the cycle difference every other frame). This works out to 50.00698Hz for PAL.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.

User avatar
laughy
Posts: 41
Joined: Wed Nov 17, 2004 12:34 pm
Contact:

:)

Post by laughy » Thu Nov 18, 2004 10:13 am

Oops:

(341 * 261 * ~30) + (340 * ~30) + (341 * 262 * ~30)

Quietust's equation is mo betta =]

However MINE doesn't require a floating point UNIT!!!

FASTER!

:)

Post Reply