
 1000  *SAVE S.PRODOS $F142...$F1BE
 1010  *--------------------------------
 1020  *  IF THE PRODOS BOOT RECOGNIZES A THUNDERCLOCK,
 1030  *  A "JMP $F142" IS INSTALLED AT $BF06 AND
 1040  *  THE SLOT ADDRESS IS PATCHED INTO THE FOLLOWING
 1050  *  CODE AT SLOT.A AND SLOT.B BELOW.
 1060  *--------------------------------
 1070  DATE   .EQ $BF90    $BF91 = YYYYYYYM
 1080  *                   $BF90 = MMMDDDDD
 1090  TIME   .EQ $BF92    $BF93 = 000HHHHH
 1100  *                   $BF92 = 00MMMMMM
 1110  MODE   .EQ $5F8-$C0 THUNDERCLOCK MODE IN SCREEN HOLE
 1120  *--------------------------------
 1130         .OR $F142
 1140         .TA $800
 1150  *--------------------------------
 1160  PRODOS.THUNDERCLOCK.DRIVER
 1170         LDX SLOT.B   $CN
 1180         LDA MODE,X   SAVE CURRENT THUNDERCLOCK MODE
 1190         PHA
 1200         LDA #$A3     SEND "#" TO THUNDERCLOCK TO
 1210         JSR $C20B       SELECT INTEGER MODE
 1220  SLOT.A .EQ *-1
 1230  *--------------------------------
 1240  *      READ TIME & DATE INTO $200...$211 IN FORMAT:
 1250  *--------------------------------
 1260         JSR $C208
 1270  SLOT.B .EQ *-1
 1280  *--------------------------------
 1290  *      CONVERT ASCII VALUES TO BINARY
 1300  *      $3E -- MINUTE
 1310  *      $3D -- HOUR
 1320  *      $3C -- DAY OF MONTH
 1330  *      $3B -- DAY OF WEEK
 1340  *      $3A -- MONTH
 1350  *--------------------------------
 1360         CLC
 1370         LDX #4
 1380         LDY #12      POINT AT MINUTE
 1390  .1     LDA $200,Y   TEN'S DIGIT
 1400         AND #$07     IGNORE TOP BIT
 1410         STA $3A      MULTIPLY DIGIT BY TEN
 1420         ASL          *2
 1430         ASL          *4
 1440         ADC $3A      *5
 1450         ASL          *10
 1460         ADC $201,Y   ADD UNIT'S DIGIT
 1470         SEC
 1480         SBC #$B0     SUBTRACT ASCII ZERO
 1490         STA $3A,X    STORE VALUE
 1500         DEY          BACK UP TO PREVIOUS FIELD
 1510         DEY
 1520         DEY
 1530         DEX          BACK UP TO PREVIOUS VALUE
 1540         BPL .1       ...UNTIL ALL 5 FIELDS CONVERTED
 1550  *--------------------------------
 1560  *      PACK MONTH AND DAY OF MONTH,
 1570  *--------------------------------
 1580         TAY          MONTH (1...12)
 1590         LSR          00000ABC--D
 1600         ROR          D00000AB--C
 1610         ROR          CD00000A--B
 1620         ROR          BCD00000--A
 1630         ORA $3C      MERGE DAY OF MONTH
 1640         STA DATE     SAVE PACKED DAY AND MONTH
 1650         PHP          SAVE TOP BIT OF MONTH
 1660  *--------------------------------
 1670  *      CONVERT MONTH, DAY OF MONTH,
 1680  *      AND DAY OF WEEK INTO YEAR.
 1690  *--------------------------------
 1700         AND #$1F     ISOLATE DAY OF MONTH (1...31)
 1710  *      CARRY SET FOR MONTHS 8...12
 1720         ADC YEAR.DAY,Y    COMPUTE DAY OF YEAR
 1730         BCC .2
 1740         ADC #3    ADJUST REMAINDER FOR YEARDAY > 255
 1750  .2     SEC          GET REMAINDER MODULO 7
 1760  .3     SBC #7
 1770         BCS .3       ...UNTIL ALL 7'S REMOVED
 1780         ADC #7       RESTORE TO POSITIVE VALUE
 1790         SBC $3B      SUBTRACT KNOWN DAY OF WEEK
 1800         BCS .4       NO BORROW
 1810         ADC #7       BORROWED, SO ADD 7 BACK
 1820  .4     TAY          ADJUSTED DAY OW WEEK AS INDEX
 1830         LDA YRTBL,Y  GET YEAR (82...87)
 1840         PLP          GET HIGH BIT OF MONTH IN CARRY
 1850         ROL          FORM YYYYYYYM
 1860         STA DATE+1
 1870         LDA $3D      GET HOUR
 1880         STA TIME+1
 1890         LDA $3E      GET MINUTE
 1900         STA TIME
 1910         PLA          RESTORE THUNDERCLOCK MODE
 1920         LDX SLOT.B   GET $CN FOR INDEX
 1930         STA MODE,X
 1940         RTS
 1950  *--------------------------------
 1960  YEAR.DAY   .EQ *-1  OFFSET BECAUSE INDEX 1...12
 1970     .DA #0,#31,#59,#90      JAN,FEB,MAR,APR
 1980     .DA #120,#151,#181,#211 MAY,JUN,JUL,AUG
 1990     .DA #242,#20,#51,#81    SEP,OCT,NOV,DEC
 2000  *--------------------------------
 2010  YRTBL  .DA #84,#84,#83,#82,#87,#86,#85
 2020  *--------------------------------

