Dobbertin Smart Watch:RTC routines

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search

These are the low level routines of FutureOS to read and write the Dobbertin RTC, written by TFM. They show how to read and write the RTC itself.

;TFM of FutureSoft - part of FutureOS
;All rights reserved

;Dobb.Uhr Daten ins RAM ab UHR_00 ; AKT_ROM ein
;Mani; AF,BC,DE,HL

LUHR LD BC,(UHR_ROM)

 OUT  (C),C
 LD   A,(&C004)
 LD   DE,&C000
 LD   HL,&C001
 CALL KOAS
 CALL KOAS
 LD   E,4  ;DE=&C004

     LD HL,UHR_00
     LD B,8
RDUL LD A,(DE)

 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  A,(DE)
 RRA
 RR  C
 LD  (HL),C
 INC HL

 DJNZ RDUL
 LD   BC,(AKT_ROM)
 OUT  (C),C
 RET

KOAS LD A,(HL)

 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)
 LD A,(DE)
 LD A,(HL)
 LD A,(HL)
 LD A,(HL)
 LD A,(DE)
 LD A,(HL)
 LD A,(DE)

 RET
;Uhr-Daten schreiben
;-------------------
;DE=8 Bytes in.Page, Dobb.komp
;Mani; AF,BC,E,HL,BC',DE',HL'
;AKT_ROM aktiv

SUHR EXX

 LD BC,(UHR_ROM):OUT (C),C
 LD A,(&C004)
 LD DE,&C000
 LD HL,&C001
 CALL KOAS
 CALL KOAS
 EXX
 LD BC,&0800
 LD H,&C0

SUGL LD A,(DE):SCF
SUNB RR A:JR Z,SUZZ

 LD L,C
 RL L
 LD L,(HL)
 JR SUNB

SUZZ INC E

 DJNZ SUGL
 LD BC,(AKT_ROM):OUT (C),C
 RET