CLOCK For Commodore 128 CP/M Plus Version 1.1 Gene Pizzetta December 6, 1987 CLOCK is a utility to read "The Right Time" clock-calendar and set the system time and date under CP/M Plus on the Commodore 128. The current time and date is also displayed at the console. USAGE: CLOCK No parameters are needed on the command line. Put the CLOCK command in your PROFILE.SUB and the CP/M system time and date will be set automatically everytime you boot up. Your disk file date stamping will always be correct. If you use MAKE+ to compile or assemble programs, it will always work correctly, even if you are crashing the system every 10 or 15 minutes testing a buggy program. CLOCK has one small bug. When you call CLOCK from the CP/M command line, if the system time was previously set to a time later than the real time that the clock provides, the date will be advanced a day by the warm boot. The apparent reason for this is that when the BDOS or CCP checks the time and finds it is earlier than the last time it checked, it is assumed that a new day has arrived and that the date should be incremented. I don't know a way around this, but there may be a flag somewhere that I haven't found yet. This situation should be a rare occurrence for most people. In any case running CLOCK a second time will set the date correctly. THE RIGHT TIME CLOCK: The Right Time is a trademark of Ardelt Engineering Company for their battery-backed clock-calendar for the Commodore 64 and 128. The clock plugs into the User Port and, if you use a 1670 modem, it will plug into the back of the clock. The RTC does not interfere with any CP/M functions, including Drive M: (the RAM disk). You can get more information from: Ardelt Engineering Company 8175 East 39th Avenue Denver, CO 80207 (800) 237-2943 for orders (303) 355-1763 for technical information SOURCE CODE: The source code is pretty well commented throughout. If you want to make some changes, you should not have any trouble figuring out what's going on at any point. Much of this code is not original. For the clock reading routines I relied heavily on the C-128 native mode driver written and copyrighted by Stephen Ardelt of Ardelt Engineering, manufacturers of The Right Time clock-calendar. The most important changes were translating 6502 code to Z80 code and using Z80 "in" and "out" instructions to access the I/O chips, which are not visible in the banks in which CP/M operates (0 and 1). Most of the subroutine to put the date in DRI format was taken from UNDATE.ASM, a procedure written by S. Kluger of the El Paso RCP/M. It is in the public domain. The original routine was written to read the time and date as ASCII strings, so it was modified to accept binary input. CLOCK was developed using SLRMAC, SLR Systems miraculous assembler. The source file can be assembled with MAC and HEXCOM, however, by changing the filetype from .MAC to .ASM. MAC will also require that you have Z80.LIB on the default drive. (Note that MAC will generate a meaningless error when it finds a line with an exclamation point in a comment. Ignore the error; the generated code will be fine.) HISTORY: For the two and a half years that I've been using my C- 128 I've been thinking how nice it would be to have a battery- backed clock like those available for MS-DOS machines. It does get a little tiresome entering the date and time on every boot using DATE.COM, especially when I'm working on a machine language program that keeps crashing the system. About a year ago I heard about a clock that used the Expansion Port (where the RAM expansion goes), but another CP/M user reported that it interfered with the RAM disk, so I considered it no longer. More recently I read about Ardelt Engineering's Right Time clock that plugged into the User Port (where the modem goes), so I called them to find out about it. Stephen Ardelt assured me that his clock would not interfere with the CP/M in any way, but that driver programs were included only for 64 and 128 modes. He suggested that it shouldn't be particularly difficult to write a CP/M utility to read the clock. I bit and he was right on all counts. Version 1.0 -- December 5, 1987 -- original version. It reads and it sets!!! Version 1.1 -- December 7, 1987 -- Added date and time display to console. Please report any bugs or make any suggestions to me by mail, phone, or modem: Gene Pizzetta 481 Revere Street Revere, MA 02151 Voice: (617) 284-0891 CompuServe: 72060,505 GEnie: E.Pizzetta Q-Link: GeneP "The Right Time" is a trademark of Ardelt Engineering Company. "Commodore 64" and "Commodore 128" are trademarks of Commodore Electronics Ltd. "CP/M" and "CP/M Plus" are trademarks of Digital Research Inc.