Holger Picker wrote: > Thanks a lot for your help. That was useful information indeed. If you > don't mind I'd like to add a question concerning the clock-stretching > mentioned by David Empson. If I understood it right, then the > videocontroller needs 65 "clock-cycles" compared to the processor to draw > a line on the monitor. Correct. With the stretched cycle, an NTSC IIe has a horizontal scan frequency of almost exactly 15700 Hz, which is close to the NTSC standard of 15734 Hz. It takes 63.695 microseconds to output one line to the video display. The PAL version of the IIe uses a 14.25045 MHz crystal (the PAL IIc apparently uses a 14.25 MHz hybrid circuit). Allowing for the stretched cycle, this gives a 63.998 microsecond line output time for the IIe and 64.000 microseconds for the IIc (it is supposed to be 64.000). > Then 262.5 lines per frame * 65 clock-cycles = 17062.5 clock-cycles per > frame * 60 frames per second (NTSC) = 1023750 clock-cycles per second ~= > about 1.0227 MHz with a master clock frequency of 14.31818 MHz. The Apple II generates non-interlaced video with exactly 262 lines for NTSC (including the vertical retrace and border areas), so the correct calculation is 262 * 65 = 17030 CPU cycles per frame, which is a period of 16688 microseconds. There are actually 59.92 frames displayed per second (the ideal value is 59.94). (All of the above figures are verified by "Understanding the IIe".) > > There is a complication: to comply with NTSC video timing, the Apple ][ > > stretches every 65th CPU clock cycle by two cycles of the 14 MHz clock. > > Ah, I didn't know that (never heard of it)! What does it mean to the > processor? Not much - the CPU itself couldn't care less what the clock frequency is, as long as isn't too high or too low. The 6502 is driven by an external TTL two-phase clock. It may have implications in precise speed calculations, but it only affects the execution speed by 0.2%. I'd be more worried about hardware implications, but there isn't anything critical enough for this to be a serious problem. > Would it mean that after 65 clock-cycles the processor does one/two > (complete) wait-cycle? The processor is completely unaware of it - it just has one cycle out of every 65 in which the clock which drives the processor has a longer period for that cycle. > Or is the difference too small to be noticeable (hearable? What about > processor loops that access \$c030? Could you hear a "background-humming"? If you were trying to generate a precise tone, you would need to allow for this when determining the number of CPU cycles between accesses to \$C030, i.e. work on the assumption that the CPU is executing uniform cycles at 1.0205 MHz instead of 1.0227 MHz. I doubt that the "jitter" introduced by the regularly spaced stretched cycles would be audible. > I've always thought that the 6502 in an AppleII runs at constant speed. > Now it seems it was only true for PAL-Apples. Nope - I was wrong on that count. All Apple II models have this irregularity in the nominal 1 MHz clock. > And, if I may ask, what happens on an AppleIIc+(4Mhz) or an accelerated > AppleIIe if you access the disk-drive (especially writes)? The accelerators are all designed to deal with I/O accesses to speed critical devices by slowing down and running in sync with the motherboard during I/O operations. In the case of the IIc+ (and the Zip Chip, which is the basis of the IIc+ accelerator) there is a 50 ms "slow down" timer triggered on each access to a slot I/O location for a slot which is configured to operate in slow mode (such as the 5.25" disk controller). For some devices the hardware accesses are not timing critical, so the CPU can be left running in accelerated mode, with only the actual I/O cycles operating in sync with the motherboard (at 1 MHz). > P.P.S.: Hmm, I think I had better put up another (earlier) post also in > comp.sys.apple first so to show you what I'm driving at (emulator > programming). Sorry, I'll do that at once. I think I saw you post something on that in comp.emulators.apple2. > As I live in Germany I probably will have no access to these books at all. I live in New Zealand, and I ordered my copy of Understanding the IIe from Byte Works. They posted it to me, but I don't remember whether it was airmail (quite expensive) or surface - the latter is more likely. (This book is a softback, about 8.5 by 11 by 1 inch, or 215 x 280 x 25 mm.) -- David Empson dempson@actrix.gen.nz Snail mail: P O Box 27-103, Wellington, New Zealand