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 / PROGRAMS / CLOCKK / MDCLCK13.LBR / BNKBIOS3.DZF / BNKBIOS3.DIF
Text File  |  2000-06-30  |  5KB  |  194 lines

  1. 1c 0
  2. Title    MD-HD Bios for CP/M 3 Copyright 1984 Morrow Designs, Inc. (31_Mar_87)
  3. .
  4. 12c 21974
  5. ; Index (30_Mar_87)
  6. .
  7. 17c 4990
  8. ;        Data Area (Character Tables)
  9. .
  10. 30a 57256
  11. ;        Real Time Clock Support (get only)
  12. .
  13. 92c 29190
  14. ; Local Equates (31_Mar_87)
  15. .
  16. 95c 22801
  17. BioRev        equ    21h        ;Current Bios Revision
  18. .
  19. 137c 33716
  20.     Subttl    Banked Bios -- Data Area (Character Tables)
  21. .
  22. 2646a 20852
  23.  
  24.     Subttl    Resident Bios -- Real Time Clock Support
  25. .
  26. 2650a 23318
  27. ;----------------------------------------------------------------------
  28. ; Real Time Clock Get Routine (31_Mar_87)
  29. ;    (for clock in MDCLCK13.LBR - Mike Allen)
  30. ;------------------------------------------------------------
  31. ;
  32. Time_PA    equ    30h
  33. Time_PB    equ    31h
  34. Time_PC    equ    32h
  35. Time_CT    equ    33h
  36.  
  37. Banked_Time:
  38.     ld    a,0
  39.     cp    c        ;is it a get?
  40.     ret    nz        ;return if not - set code not done yet
  41.     push    de        ;save registers per instructions.
  42.     push    hl
  43.     push    ix
  44.     ld    a,90h        ;set up 8255
  45.     out    (Time_CT),a
  46.     ld    a,20h        ;turn on read
  47.     out    (Time_PC),a    
  48.     ld    hl,RTC        ;initialize loop.  Clock input buffer, ...
  49.     ld    c,Time_PA    ; ... input port, ...
  50.     ld    b,13        ; ... loop count and ...
  51.     ld    a,0        ; ... clock register address.
  52. Time_Loop:
  53.     out    (Time_PB),a    ;output clock register address.
  54.     inc    a        ;set up for next one.
  55.     nop            ;waste some time.  (MSM5832 is SLOW!)
  56.     nop
  57.     nop
  58.     ini            ;read data.
  59.     jr    nz,Time_Loop    ;loop until done.
  60.     ld    a,0h        ;turn off read
  61.     out    (Time_PC),a    
  62.     ld    a,(RTC+5)    ;get hours x10
  63.     and    3h        ;mask off 24hr and pm flags.
  64.     ld    (RTC+5),a    ;put it back
  65.     ld    hl,RTC+4    ;point to hours x1
  66.     call    Make_BCD    ;turn hours into packed bcd
  67.     ld    (@hour),a    ;store it in SCB
  68.     ld    hl,RTC+2    ;point to minutes x1
  69.     call    Make_BCD    ;turn minutes into packed bcd
  70.     ld    (@min),a    ;store it in SCB
  71.     ld    hl,RTC        ;point to seconds x1
  72.     call    Make_BCD    ;turn seconds into packed bcd
  73.     ld    (@sec),a
  74.  
  75. DMY2DRI1:        ;convert reasonable dd/mm/yy format to DRI's
  76.             ;strange one.
  77.  
  78.     ld    a,3        ;days can go to 30
  79.     ld    hl,RTC+8    ;pointer to 10s of days
  80.     call    Make_BIN    ;turn days into binary number
  81.     ld    (RTC),a        ;save it
  82.     ld    a,1        ;tens of month only go to 1.
  83.     ld    hl,RTC+0ah    ;pointer to 10s of mo.
  84.     call    Make_BIN    ;turn months into binary
  85.     ld    (RTC+1),a    ;save it
  86.     ld    a,0ffh        ;full range on years
  87.     ld    hl,RTC+0ch    ;pointer to 10s of tears
  88.     call    Make_BIN    ;turn years into binary
  89.     ld    (RTC+2),a    ;save it
  90.     ld    a,02        ;load feb. compare
  91.     ld    bc,(RTC+1)    ;load year and month
  92.     ld    hl,(RTC)    ;load days
  93.     ld    h,0        ;zero upper half of counter
  94.     ld    ix,DAYS        ;load the day pointer
  95.     dec    c        ;decrement the current month
  96.     jr    z,DMY2DRI3    ;if January then bypass the month adder
  97.     ld    e,c        ;load the month
  98.     ld    d,0        ;zero the upper half
  99.     dec    e        ;decrement the offset
  100.     add    ix,de        ;add the offset
  101.     bit    0,b        ;even year compare
  102.     jr    nz,DMY2DRI2    ;jump out if not
  103.     bit    1,b        ;every other year compare
  104.     jr    nz,DMY2DRI2    ;jump out if not
  105.     cp    c        ;month greater than feb
  106.     jr    nc,DMY2DRI2    ;jump out if not
  107.     inc    l        ;it's a leap year so add a day
  108.     ld    b,0        ;zero the year
  109. DMY2DRI2:
  110.     ld    e,(ix)        ;load the numer of days
  111.     ld    d,0        ;zero the upper half
  112.     add    hl,de        ;add the days in the month
  113.     dec    ix        ;next month
  114.     dec    c        ;count down
  115.     jr    nz,DMY2DRI2    ;loop back if not first month
  116. DMY2DRI3:
  117.     ld    a,(RTC+2)    ;load year
  118.     sub    77        ;subtract 77
  119.     ld    bc,365        ;load 365 days
  120. DMY2DRI4:
  121.     dec    a        ;decrement the year
  122.     jr    z,DMY2DRI5    ;jump out if finished
  123.     add    hl,bc        ;otherwise add 365 days
  124.     bit    0,a        ;check if even
  125.     jr    nz,DMY2DRI4    ;jump back if not
  126.     bit    2,a        ;check if every other year
  127.     jr    nz,DMY2DRI4    ;jump back if not
  128.     inc    hl        ;leap year, add a day
  129.     jr    DMY2DRI4    ;loop back
  130. DMY2DRI5:
  131.     ld    (@date),hl    ;save finished product in SCB
  132.     pop    ix        ;restore registers
  133.     pop    hl
  134.     pop    de
  135.     ret            ;done
  136.  
  137. RTC:    ds    13,0
  138.  
  139. Make_BCD:        ;enter with pointer to units in hl.
  140.             ;assumes tens is one above units
  141.             ;returns with 2 digit BCD in a
  142.  
  143.     ld    a,(hl)        ;put units in a
  144.     inc    hl        ;point to tens
  145.     rld            ;put lo nybble of tens into hi nybble of tens
  146.                 ;put lo nybble of a into lo nybble of tens
  147.     ld    a,(hl)        ;put packed bcd in a
  148.     ret
  149.  
  150. Make_BIN:        ;enter with a pointer to the 10s digit in hl and
  151.             ;a mask for for the 10s digit in a.  Expects to
  152.             ;to find the ones digit one location lower in memory
  153.             ;than the 10s digit.  Exits with binary number in a.
  154.  
  155.     and    (hl)        ;get the 10s digit and mask it.
  156.     ld    b,a        ;save it
  157.     add    a,a        ;x2
  158.     add    a,a        ;x4
  159.     add    a,b        ;x5
  160.     add    a,a        ;x10
  161.     ld    b,a        ;save it
  162.     dec    hl        ;point to ones digit
  163.     ld    a,(hl)        ;get it
  164.     and    0fh        ;mask it
  165.     add    a,b        ;add in the 10s
  166.     ret            ;and go back.
  167.  
  168. DAYS:            ;number of days in month
  169.     db    31    ;January
  170.     db    28    ;February
  171.     db    31    ;March
  172.     db    30    ;April
  173.     db    31    ;May
  174.     db    30    ;June
  175.     db    31    ;July
  176.     db    31    ;August
  177.     db    30    ;September
  178.     db    31    ;October
  179.     db    30    ;November
  180.     db    31    ;December
  181.  
  182. .
  183. 2944a 46651
  184. Time:    ld    hl,Banked_Time        ;Time set/read
  185.     jr    Inter_Bank
  186.  
  187. .
  188. 3037d 19806
  189. $a 21163
  190. .
  191. a,(hl)        ;put units in a
  192.     inc    hl        ;point to tens
  193.     rld            ;put lo nybble of tens into hi nybble of tens
  194.                 ;put lo nybb