Clock Changing on a Master

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
james
Posts: 347
Joined: Tue Aug 15, 2023 8:41 pm
Location: NE Hampshire
Contact:

Clock Changing on a Master

Post by james »

Howdy, is there any simple utility that will change a Master’s clock by +- 1 hour when run?

Really just for use when the clocks change and without having to use TIME$=“[stuff]”
User avatar
jgharston
Posts: 5342
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: Clock Changing on a Master

Post by jgharston »

Try this:

Code: Select all

   10 REM > RTCAdj/src
   20 REM Add/Sub one hour to time
   30 DIM mcode% 255
   40 load%=&FFFF0900
   50 OSWORD=&FFF1
   60 PROCasm(+1):PROCasm(-1)
   70 END
   80 :
   90 DEFPROCasm(adj%)
  100 IF adj%<0:fname$="RTCSub"
  110 IF adj%>0:fname$="RTCAdd"
  120 FOR P=0 TO 1
  130   P%=load%:O%=mcode%
  140   [OPT P*3+4
  150   .go%
  160   LDA #1:JSR OswClockRd
  170   LDA ClockBCD+4
  180   ]
  190   IF adj%<0:[OPT P*3+4:SED:SEC:SBC #&01:CLD:]
  200   IF adj%>0:[OPT P*3+4:SED:CLC:ADC #&01:CLD:]
  210   [OPT P*3+4
  220   CMP #&24:BCS errClock
  230   STA ClockBCD+4
  240   LDA #7:STA ClockWr+0
  250   LDX #ClockWr AND 255
  260   LDY #ClockWr DIV 256
  270   LDA #15:JMP OSWORD
  280   .OswClockRd
  290   STA ClockBCD+0
  300   LDX #ClockBCD AND 255
  310   LDY #ClockBCD DIV 256
  320   LDA #14:JMP OSWORD
  330   .ClockWr
  340   EQUB 0
  350   .ClockBCD
  360   EQUD 0
  370   EQUD 0
  380   .errClock
  390   ]
  400   IF adj%<0:[OPT P*3+4:BRK:EQUB 225:EQUS "Yesterday":BRK:]
  410   IF adj%>0:[OPT P*3+4:BRK:EQUB 225:EQUS "Tomorrow":BRK:]
  420 NEXT
  430 A$="SAVE "+fname$+" "+STR$~mcode%+" "+STR$~O%+" "+STR$~(go%OR&FFFF0000)+" "+STR$~load%
  440 PRINT A$;:OSCLI A$:PRINT
  450 ENDPROC

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.45
(C) Copyright J.G.Harston 1989,2005-2024
>_
james
Posts: 347
Joined: Tue Aug 15, 2023 8:41 pm
Location: NE Hampshire
Contact:

Re: Clock Changing on a Master

Post by james »

Thanks, sadly, no joy.

I think the CMOS Clock is being read correctly, if I force the clock to 23:xx:xx and then run RTCAdd I get the expected error.

However, the time is never updated.

If I've understood this right (and referring https://beebwiki.mdfs.net/OSWORD_%260F and pages D.3-24,25 of the Master Reference Manual (MRM) Part 1) then

The MOS 3's OSWORD 15 provides three write functions associated with the CMOS clock.
1. Change the time only (XY=8)
2. Change the date only (XY=15)
3. Change the date and time (XY=24)

But the code is setting XY=7 at line 240

The MRM seems to suggest the parameter block needs to be in a string format (eg "hh:mm:ss" for XY=8) rather than the 7-byte BCD value from the read.

So would a solution "work around" be to make the section after .ClockBCD contain 24 x 0 bytes, and call OSWORD 14 with XY=2 to turn the caluclated BCD value into a string, which could then be set by OSWORD 15, XY=24 ?

Acorn do not seem to have made an espicially easy set of APIs for this.
Last edited by james on Sun May 05, 2024 6:21 pm, edited 2 times in total.
james
Posts: 347
Joined: Tue Aug 15, 2023 8:41 pm
Location: NE Hampshire
Contact:

Re: Clock Changing on a Master

Post by james »

Much to my surprise, the additional conversion step in the middle worked! Here's the result:

Thanks again for creating this.

Code: Select all

   10 REM > RTCAdj/src
   20 REM Add/Sub one hour to time
   30 DIM mcode% 255
   40 load%=&FFFF0900
   50 OSWORD=&FFF1
   60 PROCasm(+1):PROCasm(-1)
   70 END
   80 :
   90 DEFPROCasm(adj%)
  100 IF adj%<0:fname$="RTCSub"
  110 IF adj%>0:fname$="RTCAdd"
  120 FOR P=0 TO 1
  130   P%=load%:O%=mcode%
  140   [OPT P*3+4
  150   .go%
  160   LDA #1:JSR OswClockRd
  170   LDA ClockBCD+4
  180   ]
  190   IF adj%<0:[OPT P*3+4:SED:SEC:SBC #&01:CLD:]
  200   IF adj%>0:[OPT P*3+4:SED:CLC:ADC #&01:CLD:]
  210   [OPT P*3+4
  220   CMP #&24:BCS errClock
  230   STA ClockBCD+4
  240   LDA #2:STA ClockConv
  250   LDX #ClockConv AND 255
  260   LDY #ClockConv DIV 256
  270   LDA #14:JSR OSWORD
  280   :
  290   LDA #24:STA ClockWr
  300   LDX #ClockWr AND 255
  310   LDY #ClockWr DIV 256
  320   LDA #15:JMP OSWORD
  330   .OswClockRd
  340   STA ClockBCD+0
  350   LDX #ClockBCD AND 255
  360   LDY #ClockBCD DIV 256
  370   LDA #14:JMP OSWORD
  380   .ClockWr
  390   EQUB 0
  400   .ClockConv
  410   EQUB 0
  420   .ClockBCD
  430   EQUD 0
  440   EQUD 0
  450   EQUD 0
  460   EQUD 0
  470   EQUD 0
  480   EQUD 0
  490   .errClock
  500   ]
  510   IF adj%<0:[OPT P*3+4:BRK:EQUB 225:EQUS "Yesterday":BRK:]
  520   IF adj%>0:[OPT P*3+4:BRK:EQUB 225:EQUS "Tomorrow":BRK:]
  530 NEXT
  540 A$="SAVE "+fname$+" "+STR$~mcode%+" "+STR$~O%+" "+STR$~(go%OR&FFFF0000)+" "+STR$~load%
  550 PRINT A$;:OSCLI A$:PRINT
  560 ENDPROC
Post Reply

Return to “8-bit acorn software: other”