Previous Thread
Next Thread
Print Thread
Joined: Feb 2004
Posts: 314
A
Senior Member
Senior Member
A Offline
Joined: Feb 2004
Posts: 314
Hi. I'm looking at MAME again after a couple decades (?!?) away from it.

Specifically the Apple ][ emulation: MAME lists the clock as 1021800 Hz. In the source, I see:
Code
	M6502(config, m_maincpu, 1021800);     /* close to actual CPU frequency of 1.020484 MHz */

Per "Understanding the Apple IIe" by Jim Sather, sec. 3-13, I believe the ~1.02048 figure is the more correct "average" clock rate, taking into account the 16/14 stretch of every 65th cycle.

Can anyone explain why MAME is using 1021800 and how that was derived?
(I'm asking because of sound generation code.)

Joined: Mar 2001
Posts: 17,284
Likes: 268
R
Very Senior Member
Very Senior Member
R Online: Content
Joined: Mar 2001
Posts: 17,284
Likes: 268
MAME's core is not currently capable of emulating the stretched cycle, so every CPU and video cycle is exactly 14 master clocks. The 1021800 adjusts the speed downward slightly to give the same slowing effect as the stretched cycles. I don't remember the exact derivation, but it was pretty straightforward.

Joined: Feb 2004
Posts: 314
A
Senior Member
Senior Member
A Offline
Joined: Feb 2004
Posts: 314
It makes sense to adjust downward to average out the stretching. I'm not sure that 1021800 is the correct adjustment though?

If the master clock is 4x NTSC 14.31818 MHz, then / 14 = 1.0227271429 MHz. Adjusting for stretching, 14.31818 * 65 / (65*14+2) = average rate of 1.0204843202 MHz.

The ratio between 1021800 and 1020484 looks like like the difference between 60 Hz and the actual Apple ][ vertical refresh rate (65 cycles @ 63.695 us x 262 scanlines = 17030 cycles @ 16688 us; 1000000 / 16688 us = ~59.923 Hz, according to Jim Sather.)

Perhaps the derivation assumed the vertical refresh rate was 60 Hz?


Link Copied to Clipboard
Who's Online Now
0 members (), 147 guests, and 0 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,373
Posts122,615
Members5,085
Most Online1,529
Jun 7th, 2025
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Powered by UBB.threads™ PHP Forum Software 8.0.0