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 / MBUG / MBUG020.ARC / M80DATE.MAC < prev    next >
Text File  |  1979-12-31  |  3KB  |  117 lines

  1.                   DATESTAMP PATCH FOR MACRO-80 .PRN FILES
  2.  
  3. ; M80DATE V1.0 04/12/85
  4. ; Graeme Toogood
  5. ; 46 Blandford Crescent
  6. ; North Bayswater
  7. ; Victoria, 3153.
  8. ; date stamps M80 .prn files
  9. ; Modified for the  RTC KIT from Microbee Systems using the Motorola
  10. ; 146818 chip by Darren Breeze 09/01/86
  11. ;
  12. ; To install, assemble M80DATE.MAC and patch M80.COM as follows :-
  13. ; Step 1. M80 =m80date
  14. ; Step 2. L80 m80date,m80date/n/e this generates a .com file but 
  15. ;         don't try to run it by it's self
  16. ; Step 3. CEBUG M80.COM
  17. ; Step 4. Use cebug's A command to patch 103h with JP 4F80
  18. ; Step 5. Use cebug's F and R commands to load M80DATE.HEX into memory 
  19. ;       at 4F80h
  20. ;      -fm80date.com
  21. ;      -r4e80 ,read in at offset of 4e80h+100h=4f80h
  22. ; Step 6. use cebug's F command for the new file name
  23. ;         -fm80d.com
  24. ;      then write the new file with the W command
  25. ;      -w
  26. ;      exit CEBUG and you will have M80D.com when
  27. ;      you use it with the /l switch it will generate
  28. ;      a .PRN file with todays date XX/XX/XX in the heading of each page.
  29.  
  30.     .Z80
  31.     ASEG
  32.     ORG    100H
  33.  
  34. ;rtc constants
  35. rtcdat    equ    7    ; addr of rtc data port
  36. rtcadd    equ    4    ; rtc address port
  37. days    equ    7    ; day of month register
  38. months    equ    8    ; month of year register
  39. years    equ    9    ; year register
  40. update    equ    0ah    ; bit 7 reg 0ah 1= "update in progress" 
  41.  
  42. ; system constants
  43. tpa    equ    0100h
  44. buffer    equ    1af8h        ; Start of M80's signon msg
  45. m80    equ    470CH        ; Normal entry to M80
  46.  
  47.     .phase    4f80h
  48.  
  49. rtcrd:    ld    hl,m80        ; load code addr. for M80
  50.     ld    (0104h),hl    ; fix up patched jump at 103h
  51.     ld    a,0dh        ; address for reg D
  52.     out    (rtcadd),a    ; latch address
  53.     in    a,(rtcdat)    ; bit 7 reg d =1 then rtc is there   
  54.     cp    80h             ; and time is valid                  
  55.     jr    z,ok        ; yes - read dd/mm/yy and store in buffer
  56.     jp    exit        ; else enter M80 normally
  57. ok:    ld    hl,1b04h    ; start of 'MACRO-80 3.44' logo
  58.     ld    de,1b0eh    ; move it a little to the right
  59.     ld    bc,13        ; bytes to moveè    lddr            ; move 'em
  60.     ld    a,20h
  61.     ld    (de),a        ; a space to finish
  62.     ld    hl,buffer-1    ; point to new date buffer loc'n
  63.  
  64. ; get month,day and year
  65.  
  66. notyet:    ld    a,update    ;point to update reg
  67.     out    (rtcadd),a
  68.     in    a,(rtcdat)    ;get reg
  69.     bit    7,a        ;if bit is 1 then update is in progress
  70.     jr    nz,notyet    
  71.  
  72.     ld    a,days        ;point to day reg
  73.     call    number        ;get days
  74.     ld    (hl),'/'    ;put in a slash
  75.     ld    a,months    ;point to month
  76.     call    number        ;get month
  77.     ld    (hl),'/'    ;put in a slash
  78.     ld    a,years        ;point to year
  79.     call    number        ;get year
  80.     ld    (hl),09h    ;put tab
  81.     ld    a,0        ;clear out a?
  82.     jr    exit        ;finished
  83.  
  84. ;number takes register num in A isolates top and bottom nibble
  85. ;and puts then in the buffer. hl points to buffer 
  86.  
  87. number:    out    (rtcadd),a    ;latch address of reg to be read
  88.     in    a,(rtcdat)    ;get  data
  89.     ld    b,a        ;save data
  90.     and    0f0h        ;mask out lower nibble
  91.     
  92.     rrca
  93.     rrca            ;move upper nibble down
  94.     rrca
  95.     rrca    
  96.     
  97.     add    a,30h        ;ascii offset
  98.     inc    hl
  99.     ld    (hl),a        ;put it in buffer
  100.     inc    hl        ;next buffer location
  101.     ld    a,b        ;get data again
  102.     and    0fh        ;mask out upper nibble
  103.     add    a,30h        ;ascii offset
  104.     ld    (hl),a        ;store in buffer
  105.     inc    hl
  106.     ret
  107.  
  108. exit:    ld    hl,rtcrd    ; point to start of rtc pgm.
  109.     ld    de,rtcrd+1    ; point to second byte
  110.     ld    bc,last-rtcrd    ; we're going to zero out
  111.     ld    (hl),0        ; memory used by this prog.
  112.     ldir            ; eliminate !!!
  113. last:    jp    tpa        ; and restart M80, leaving
  114.                 ; only this jump in memory....
  115.  
  116.     end
  117.