Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Applied links to System Call Reference API's

Alarms in the Z88 are organized as a linked list of 'alarm blocks' with the root at some fixed location. Each alarm block contains all the relevant data for the particular alarm; time, date, number of repeats; in fact much the same as the options given in the alarm display in the main alarm popdown. Although there are many system calls which deal with alarms the programmer need only know about four: 

GN_

...

Aab      allocate

...

alarm

...

block
GN_

...

Lab      link

...

alarm

...

block

...

into

...

alarm

...

chain
GN_

...

Uab      unlink

...

alarm

...

block

...

from

...

chain
GN_

...

Fab      free

...

alarm

...

block

The following stages are involved in using alarms: 
 

1. Allocation

GN_Aab is called to allocate space for an alarm block. An extended pointer to the allocated memory is returned in BHL.

...

Once the block has been set up it can be linked into the alarm chain, using GN_Lab. This done, the programmer can forget about the alarm. After expiry the alarm will be removed from the chain and the memory associated with it will be freed.

...

To remove an alarm that has been set, but has not expired, the alarm block is first unlinked from the chain using GN_Uab and the memory associated with the block is then released with GN_Fab.

The format of the alarm block is as follows: 

...

The 'repeat time display units' byte controls what is displayed in the alarm popdown window. It is important to choose a unit appropriate to the repeat time. If you use units of hours, with a repeat time of 2 minutes, then the repeat time will be displayed as 0 hours.

NOTE: The repeat time must be at least ten seconds otherwise it may be difficult to enter the alarm popdown to clear the alarm.

The alarms set up are all lost when a system soft reset occurs, and unfortunately there is no way of saving and loading the currently set alarms. In addition, alarms are suppressed when the machine is in the alarm popdown. This is true even if the machine is in coma. This feature is included to allow a simple way to disable alarms. 
 

Example

The following example sets up an alarm for the entirely arbitrary date and time of "21/05/3934 08:46:20". The alarm has a repeat time of 25 seconds and will occur three time (ie. number of repeats is two). Finally the type of alarm is ALARM and the bleeping is enabled:

 

Code Block
languagenone
include "alarm.def"                 ; alarm definition calls
include "memory.def"                ; memory management definition calls

.set_alarm  oz   GN_Aab             ; allocate alarm block
            ret  c                  ; exit if error (no room)

            push bc                 ; preserve BHL which holds
            push hl                 ; the extended pointer to the block
            ld   c, MS_S1           ; segment 1 specifier
            oz   OS_MBP             ; bind in bank containing block
            ld   a,h
            and  @00111111          ; mask out old segment
            or   MM_S1              ; force into segment 1

            ld   d,a
            ld   e,l                ; alarm block address in DE
            ld   hl, alm_block      ; address of data for alarm block
            ld   bc, sizeof_block
            ldir                    ; copy data into alarm block

            pop  hl
            pop  bc
            oz   GN_Lab             ; link block into alarm chain
            ret
 
; alarm block definition to be copied into allocated block
DEFC sizeof_ablock = end_alm_block - alm_block 

.alm_block  defb 0, 0, 0            ; link to next block (set up by system)
            defm "000"              ; time in internal format
            defm "000"              ; date in internal format
            defm "Message space 24 bytes.", 0
            defb 0, 0, 0            ; repeat time in days
            defb 0, 10, 0           ; repeat time in centiseconds
            defw 2                  ; times to repeat
            defb 1                  ; repeat time display unit (seconds)
            defb 1                  ; alarm status (bleep on expiry)