kc5tja wrote:
BigDumbDinosaur wrote:
The result is the 128 will run slightly faster regardless of which clock speed has been selected.
I want to see proof of this. My understanding of the DEN bit of the VIC-IIe controls
not only the video refresh, but
also the CPU speed. This is why you cannot run the 8502 in 2MHz mode while displaying a 40-column screen full-time (you can during borders and sync, but that's it).
The reason is that the VIC-IIe is phase-locked against the CPU (more precisely, vice versa, but who's counting?), since the VIC-IIe uses phase-1 of the bus. Driving the CPU at 2MHz would alter the VIC-IIe timings so far out of NTSC spec that you wouldn't be able to see anything anyway.
From Mapping the Commodore 128:
53296 $D030 CLKRATE
Processor clock rate control register
Bit 0: This bit controls the processor clock speed. (Remember, the VIC chip is the source of most of the system's timing signals.) When the bit is set to %0, the processor operates at its normal 1-MHz rate. To be precise, the clock frequency is 1.02273 MHz for NTSC (North American) systems and 0.98525 MHz for PAL (European) systems. Setting this bit to %1 doubles the clock rate, providing what is commonly referred to as 2-megahertz (MHz) mode. This is also known as fast mode, the old standard speed being disparagingly referred to as slow mode. During the reset and RUN/STOP-RESTORE sequences, the IOINIT routine [$E109] sets this bit to %0 for slow mode. Fast mode does have a few limitations. While the 8502 microprocessor and the VDC 80-column video chip have no problems operating at the higher clock rate, most of the other I/O chips cannot keep up at this speed. The VIC chip itself cannot maintain its video display at this speed—the 40-column screen becomes a colorful pattern of rapidly flashing squares. It is common practice to set bit 4 of the VIC register at 53265/$D011 to %0 to blank the 40-column screen display while operating in 2-MHz mode. For example, the BASIC routine for the FAST statement [$77B3] includes this step. The VDC provides an alternative to the VIC for fast mode, but other I/O chips have no substitutes. In these cases, the system employs an elaborate technique known as clock stretching, where the clock period is extended to create an effective 1-MHz rate for the portion of the clock cycle when the I/O chip is being accessed.
Because some serial bus and tape communications routines depend on software loops for timing functions, the system is usually switched to the slower clock frequency when serial bus or tape operations are being performed. The contents of this register are stored in location 2615/$0A37 during the operation, and restored to the register when the operation is completed. You can prevent this by setting bit 7 of the custom mode flag (location 2618/$0A3A) to %1. In this case, the clock rate will not be changed during tape and serial operations.
Bit 1: This bit is described in Commodore literature as a test bit. The IOINIT routine [$E019] sets the bit to %0, and no other 128 ROM routine changes that setting. Some programmers have discovered that setting this bit to %1 will blank the 40-column screen display, and have even used this as an alternative to clearing bit 4 of location 53265/$D011 when switching the processor to fast mode. While this does appear to work without side effects, such undocumented "features" are best avoided.
Now, the above was written in 1985 before the full extent of the C-128 hardware had been explored. The author (Ottis R. Cowper) was mostly working from Commodore literature, and his own experimenting to see what was what. I too was able to get the early developer docs for the 128 and in passing, learned from Fred Bowen that setting bit 1 of register $30 not only blanked the display it shut down the VIC to the extent where all it did was DRAM refreshes. Because the VIC was no longer accessing RAM to maintain the 40 column display, the 8502 had unrestricted access to the address and data buses, and thus got more done when measured against wall clock time. My own experimenting subsequently determined that the 8502's effective throughput increased about 8 percent in pure compute-bound processing.
A side-effect of setting bit 1 in register $30 is that the VIC will stop generating raster interrupts, which in the 128 are the source of the jiffy IRQs that, among other things, call the keyboard scanning routine. In other words, setting this bit from an immediate mode POKE would appear to crash the machine, since the required POKE to reverse the process could no longer be entered. This effect is easily observed by putting a logic probe on *IRQ and observing the cessation of activity when bit 1 is set.
I'm probably the worst person for you to argue with about the C-128 hardware. May I suggest that you stop by
http://www.commodore128.org sometime and look for postings by BigDumbDinosaur? Also, if you have a real C-128 (or 128D), not an emulator, please try out Clock-Calendar 128 and 80 Column Display Manager so you can get a taste of just how much I might actually know about the C-128 hardware.