APPLICATIONSDIVERS ★ Real Time Clock: Clock on with your Amstrad ★

Real Time Clock (Computing with the Amstrad)Applications Divers
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

HAVE you ever been so engrossed in your programming that you've lost all track of time? I bet every programmer's had the annoying experience of missing an appointment in this way. Help's at hand though, with this machine code real time clock for the CPC series.

Most people know of the Amstrad's internal clock system, constantly updating itself every 1 /300th of a second. It is very easy to access it from Basic by typing:

  • PRINT TIME

This will just give you the number of 1/300ths of a second which have passed since the computer was last reset. Although simple to use it wouldn't be very useful as a real time clock.

A better method would be to use Basic's EVERY routine to update our own clock every second. This would take the form:

  • 10 EVERY 50,1 GOSUB 1088

where the clock routine is at line 1000 onwards. The 50 tells the computer to go to the routine every second and the 1 tells it to use timer 1. This works fine if you stay within a program which is being executed, but when you break out the clock stops updating itself.

The solution is to use a machine code routine which is called every second whatever the computer is doing at the time, be it running a program or waiting for a command to be input directly.

This program will display the clock in the top left hand corner of window #7 in the form:

  • HOURS:MINUTES:SECONDS

Once the code is poked into memory via Program I, or Program II if you have an assembler, the clock can be started with:

  • CALL &8000

This initialises a ticker event and sets it calling the clock routine every second. Once this has been set going it can be stopped with:

  • CALL &8017

which takes the event off the ticker list.

Once the ticker event has been initialised you will see. after a second, the time 12:00:01. This will continue to update itself every second whatever you do.

This isn't a lot of good as it is, unless you started the clock at 12 o'clock, as it will not be displaying the correct time. However any clock worth its salt can be adjusted, and to change this one you must type:

  • POKE &80AA,hours 11-12)
  • POKE &80AB,minutes (0-59)
  • POKE &80AC,seconds (0-59)

The clock should now be displaying the correct time.

The routine works by loading the E register with the hour, obtained from location &80AA, L with the minutes stored at &80AB and H with the seconds from &80AC.

H, the seconds, is incremented first and tested to see if it's 60 and if it is then L, the minutes, is also incremented and H set to zero. If L is now 60 the hours in E are also incremented and the minutes in L reset to zero. Finally if the hours reach 13, E is set to 1 and the time can be printed.

The display routine first stores the current position of the text cursor, switches to window #7 and moves the cursor to the top left corner. The hours, minutes and seconds in the E, L and H registers are printed and the cursor replaced.

The machine code routine is called every second so there is a slight slowing down of the Amstrad when it is doing other tasks. The clock itself does not lose much time, except when the computer is doing certain tasks like accessing the disc drive or more noticeably the tape recorder, since the Amstrad switches interrupts off. It is therefore necessary to set the clock again if it does lose a lot of time.

Problems can also occur if you are not working in the default stream #0, as the routine switches to this stream after it has displayed the time.

The machine code can be saved on its own by typing:

  • SAVE "CLOCK.BIN",B,&8000,&BC

Typing:

  • MEMORY &7FFF:LOAD"CLOCK.BIN":CALL &8000

will load the code and call it. You could also have it change the clock to the correct time and set up window #7 so that the top left of the window is where you want the clock to be. For instance:

  • WINDOWS #7,16,25,11,11

would place the clock in the centre of the screen in Mode 1. Window #0 could similarly be defined so that is out of the way of the clock.

Now there will be no excuse for missing meals or your favourite TV program because you didn't realise what the time was - because it will be there in front of your eyes!

CWTA

★ PUBLISHER: Computing With The Amstrad
★ YEAR: 1986
★ CONFIG: ???
★ LANGUAGE:
★ LiCENCE: LISTING
★ COLLECTION: COMPUTING WITH THE AMSTRAD 1986
★ AUTHOR: SIMON HOLDERNESS
 

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listings:
» Clock  on  with  your  Amstrad    (Computing  with  the  Amstrad)    ENGLISHDATE: 2020-07-25
DL: 173
TYPE: ZIP
SiZE: 4Ko
NOTE: 40 Cyls
.HFE: Χ

» Clock  on  with  your  Amstrad    (Computing  with  the  Amstrad)    ENGLISH    LISTINGDATE: 2013-05-06
DL: 366
TYPE: text
SiZE: 2Ko
NOTE:

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » Digital Background Clock / RSX Clock (Computer Team)
» Applications » Big Clock
» Applications » RSX Clock (Pride Utilities)
» Applications » RSX Clock (Popular Computing Weekly)
» Applications » Transmat + R.S.X Clock (Pride Utilities )
» Applications » Clock (Thorsten Giertz/CPC Amstrad International)
Je participe au site:
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 585 millisecondes et consultée 2062 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.