★ APPLICATIONS ★ DIVERS ★ ANALOGUE AND DIGITAL CLOCK (THE AMSTRAD USER) ★ |
Analogue and Digital Clock (The Amstrad User) | Applications Divers |
If you're anything like me, even after all the serious work that can be accomplished on the computer has been finished, there's still more work, sadly enough, that is not in the slightest way computer-orientated. In the past your beloved possession sat there displaying "READY" until you remembered to pull it's plug. Now you can turn your Amstrad into an attractive combined digital/analogue display. Features The program is a "no-frills" application so that people can add their own embellishments as they wish. After input of current time, the screen clears, draws a clock face and puts in the hands at the input time. A digital display is also given. The digital readout is the hours:minutes:seconds type and has a leading zeros format so that times such as 4:05:34, for example, do not become 4: 5:34. The appropriate am or pm suffix is appended. The clock face is round (corrections have been incorporated allowing for the Amstrad's vertical distortion) with dashes at every 5 minute mark and dots at each minute mark. There are three hands; the seconds hand is updated each second, the other two updating each minute. Recent amendments to the program include a video reverse function and a dimmer (which can be used to manipulate colour on a colour monitor). Operation Three responses are required. To "hours?" type in the time according to a 24 hour clock (this is how am or pm is selected). Then to "Minute?" give the number of minutes after the hour and to "Seconds?" the number of seconds after the minute. It takes some time to set up the screen so allow about four seconds for total accuracy. Default values arc 24 for hours and 0 for minutes and seconds (midnight). The clock looks best in a darkened room with the brightness and contrast controls turned to a minimum (on a green screen). The background and display colours can be reversed by pressing 'R'. Use the up/down cursor keys to dim or brighten the clock face. Problems and Program details Essentially the program loops inside nested WHILE loops. The seconds-counter is incremented by an AFTER 50 interrupt. This is why the loops appear as never-ending which would be the case if there wasn't an interrupt. The minutes counter advances upon the seconds counter reaching 60 (which is reset to 0). In the next time-bracket the same happens for the hours-counter. Screen preparation is performed by lines 510-610. The hands are drawn in by lines 620-660. Note that XOR ink mode is used (line 630) so that the seconds hand doesn't wipe out the hours and minutes hands in the first revolution. Animation is achieved by drawing over the top of the previous hand position. The first pass draws; the second pass erases. This method comes with some problems however. Initially the program enters the last subroutine at line 640 (as there is no previous hand to erase). So if the time is 4:33:33 initially, the 33 position is drawn 3 times: once each for seconds and minutes and once more when the second hand advances. This leaves the minute hand "dead". The same problem (but less obvious) occurs when hands pass over each other in the course of the program, but the situation is righted as soon as the faster hand moves ahead. One other problem was a language fault. BASIC does not support a leading zeros format directly. For this reason bulky IF statements were required to check the length of mins and sees and channel the print out through the required format (initially lines 240-260). I have kept GOTO statements to a minimum to keep the program reasonably structured, and have indented looped segments (a practice more people should make use of) to improve readability). Variables
Note: This program was written for a 6128 and will require some small modifications to run on a 464. For example lines 70 and 80 use GRAPHICS - delete this word. Also look a the DRAW command in line 630.
|