home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / BYE5 / B5C-LB36.INS < prev    next >
Text File  |  2000-06-30  |  4KB  |  153 lines

  1. ; B5C-LB36.INS        Wayne Masters
  2. ;  05/05/86        Potpourri, 408-378-7474
  3. ;
  4. ;  This is an insert, not an overlay, for BYE5 and the Ampro Little-Board
  5. ;  running a v3.6, or later, BIOS, which uses a spare CTC channel to main-
  6. ;  tain a memory resident date/time clock.
  7. ;
  8. ;  This routine expects the clock to be initialized to the correct date/time
  9. ;  before executing the BYE5 program.
  10. ;
  11. ;  Set the following equates in BYE5:
  12. ;
  13. ; CLOCK   EQU    YES    (Same for KMD)
  14. ; TIMEON  EQU    YES    (Same for KMD)
  15. ; BIN2BCD EQU    YES
  16. ;
  17. ;  Delete the existing TIME routine in BYE5 and replace it with this insert.
  18. ;
  19. ;
  20. CENTURY    EQU    19H        ; Change this every 100 years
  21. LDIR    EQU    0B0EDH        ; Z80 ldir
  22. ;
  23. ;
  24. TIME:    LDA    CPYFLG
  25.     ORA    A        ; See if we have already copied the JMP table
  26.     JNZ    TIME1        ; Yes, skip this
  27. ;
  28.     LXI    D,WBOOT        ; Build BIOS entry table
  29.     LHLD    1        ; Get BIOS start
  30.     LXI    B,51        ; Bytes to move
  31.     DW    LDIR        ; Move it
  32. ;
  33.     CALL    GETTBL        ; Get address of next JMP table
  34.     LXI    D,NXTTBL    ; (HL) has BIOS nxttbl address
  35.     LXI    B,15        ;
  36.     DW    LDIR        ; Move the table
  37.     MVI    A,0FFH
  38.     STA    CPYFLG        ; Set the flag so we only do this once
  39. ;
  40. TIME1:    CALL    TOD        ; Get clock base address
  41. ;
  42. ; (HL) now has address of clock data
  43. ;
  44.     DI            ; Disable interrupts while we do this
  45.     LXI    D,SEC        ; Move time/date
  46.     LXI    B,6
  47.     DW    LDIR        ; Save time/date
  48.     EI            ; Enable interrupts now
  49. ;
  50. ; Everthing needed has been moved into this program area.
  51. ;
  52.     CALL    J2MD        ; Convert Julian date to month/day
  53. ;
  54. ; Now convert and store date/time from binary to bcd and put into BYE5
  55. ;
  56.     MVI    A,CENTURY
  57.     STA    RTCBUF+3    ; Century
  58.     LDA    CYEAR
  59.     CALL    BINBCD
  60.     STA    RTCBUF+4    ; Year
  61.     LDA    TMONTH
  62.     CALL    BINBCD
  63.     STA    RTCBUF+5    ; Month
  64.     LDA    TDAY
  65.     CALL    BINBCD
  66.     STA    RTCBUF+6    ; Day
  67.     LDA    HOUR
  68.     STA    CCHOUR        ; Binary form for cchour
  69.     CALL    BINBCD
  70.     STA    RTCBUF        ; BCD form for buffer hours
  71.     LDA    MIN
  72.     STA    CCMIN        ; Binary minutes
  73.     CALL    BINBCD
  74.     STA    RTCBUF+1    ; BCD minutes
  75.     LDA    SEC
  76.     CALL    BINBCD
  77.     STA    RTCBUF+2    ; Seconds
  78. ;
  79.     RET            ; All done
  80. ;
  81. ;
  82. ;  Convert Julian to month/day
  83. ;
  84. J2MD:    LXI    D,MTHS        ; Intialize month pointer
  85.     LHLD    JDAY        ; Julian day in (HL)
  86.     INX    H        ; Adjust for ordinal 0
  87.     XRA    A
  88.     MOV    B,A        ; Initialize high byte of sub with 0
  89.     INR    A
  90.     STA    TMONTH        ; Initialize month to 1
  91.  
  92. J2MD1:    LDAX    D
  93.     ORA    A        ; Clear carry
  94.     MOV    C,A
  95.     MOV    A,L        ; May be day
  96.     DW    42EDH        ; SBC HL,BC
  97.     JC    J2MD2
  98.     JZ    J2MD2
  99.     LDA    TMONTH
  100.     INR    A        ; Update month
  101.     STA    TMONTH
  102.     INX    D
  103.     JMP    J2MD1
  104.  
  105. J2MD2:    STA    TDAY        ; Set day
  106.     RET
  107. ;
  108.     DB    0
  109. MTHS:    DB    31,29,31,30,31,30,31,31,30,31,30,31
  110. CPYFLG:    DB    0        ; Flag for JMP table copied?
  111. ;
  112. ; BIOS JMP table, moved from the BIOS on first call to TIME
  113. ;
  114. WBOOT:    DB    0,0,0        ; Warm start
  115.     DB    0,0,0        ; Console status
  116.     DB    0,0,0        ; Console character in
  117.     DB    0,0,0        ; Console character out
  118.     DB    0,0,0        ; List character out
  119.     DB    0,0,0        ; Punch character out
  120.     DB    0,0,0        ; Reader character in
  121.     DB    0,0,0        ; Seek to home position
  122.     DB    0,0,0        ; Select disk
  123.     DB    0,0,0        ; Set track number
  124.     DB    0,0,0        ; Set sector number
  125.     DB    0,0,0        ; Set DMA address
  126.     DB    0,0,0        ; Read disk
  127.     DB    0,0,0        ; Write disk
  128.     DB    0,0,0        ; Return list status
  129.     DB    0,0,0        ; Sector translate
  130. ;
  131. GETTBL:    DB    0,0,0        ; Point to more jumps, =>v3.6 BIOS only
  132. ;
  133. NXTTBL:
  134.     DB    0,0,0        ; JMP swap
  135.     DB    0,0,0        ; Get hd table info
  136.     DB    0,0,0        ; Get/set phytab access
  137.     DB    0,0,0        ; Get phytab entry address
  138. TOD:    DB    0,0,0        ; Get base address of clock tick
  139.  
  140. ; Time/Date counters from BIOS
  141.  
  142. SEC:    DB    0
  143. MIN:    DB    0
  144. HOUR:    DB    0
  145. JDAY:    DB    0,0        ; Julian day 0-366 for leap year
  146. CYEAR:    DB    0
  147.  
  148. TMONTH:    DB    0        ; Temp storage for month
  149. TDAY:    DB    0        ; Temp storage for day
  150. ;
  151. ; End of B5C-LB36
  152. ;
  153.