Home > CBM > BASIC > Keywords > Ti | ||||||||||||||||||||||||||||||||||
* The "token" is really just the character codes for the letters "TI"
A "jiffy" is a unit of time equal to 1/60 of a second. So there are 60 jiffies per second (very similar to minutes, and seconds). The system "Jiffy Clock" operates by adding 1 to a "jiffy counter" (which you can think of as TI) at a periodic rate on NTSC systems. On most PAL systems, where the system update occurs 50 times per second, a bit of trickery is used: each 5th "jiffy" the system actually increments the "jiffy counter" twice! On the one hand, this means that even PAL systems will have 60 jiffies per second. On the other hand, the BASIC programmer must be careful not to test for a specific value because it may be skipped! Whether or not the jiffy clock will skip every fifth value corresponds with the NTSC / PAL secret variable. The system will reset the "jiffy counter" to zero once it reaches 5184000 jiffies or greater. This is equivalant to 24 hours (i.e., 24 hours * 60 minutes/hour * 60 seconds/minute * 60 jiffies/second). You should normally never see this value returned by TI, however you may see this value (or greater) for a brief moment before the next "jiffy counter" update by the system IRQ if you assign a "bad value" to TI$ (see examples). The returned timeJiffies is pretty good for computer use, but rather meaningless to the average user. Conversion to and from a more convient format, like Hours:Minutes:Seconds is rather tedious in CBM BASIC. Fortunately, CBM BASIC also provides a string version (called TI$) which is HHMMSS format. Because the returned value is measured in fractions of a second, very precise timings (for a human) can be accomplished, assuming BASIC is fast enough. The TI variable is (obstensibly) 60 times more precise than the string version, TI$. Like all BASIC variables, only the first two characters of the name are significant. So you may also use (and early documentation shows) TIME if you prefer (note the M and E are superfluous). On most (all?) of the CBM 8-bits, the system time is mainted by software in the KERNAL, even though some machines have hardware which is more reliable. In particular, delays in communicating with external devices (and a few internal operations) will cause the system time to "fall behind" reality (i.e., run slow). Generally the more I/O operations that take place, the less reliable the software clock. The C128 has FAST and SLOW commands to change the CPU speed, and thus the speed of BASIC execution, but the Jiffy Clock works the same at either speed. Unfortunately, none of the CBM BASICs have a DATE variable or function. So you would need to periodically check the TI for "rollover" to detect a change in the date. Examples:
© H2Obsession, 2014 |