home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / utility / 54 / utl / monotime.s < prev    next >
Encoding:
Text File  |  1986-09-18  |  4.7 KB  |  136 lines

  1. *
  2. *   display current time on monochr. monitor *   use vertical blank interrupt
  3. *   as corrected from Chap.2 'Tricks and Tips' ABACUS 1986  CJPurcell 21AUG'86
  4. *   normally used in autoboot with LOGIKRON or eSTeClock; can be key-clicked
  5. *
  6. gemdos     equ   1
  7. setexec    equ   5
  8. bios       equ   13
  9. xbios      equ   14
  10. gettime    equ   23
  11. super      equ   38   execute routine in supervisor mode
  12. keep       equ   $31
  13. _v_bas_ad  equ   $44e   screen address
  14. hz_200     equ   $4ba   200hz system timer
  15. *
  16. *   system font ATARI ST
  17. *
  18. fontdat   equ   76   ptr to font data
  19. formwd    equ   80   status of next raster line in font
  20. formhg    equ   82   number of raster lines per character
  21. line1   equ     80       bytes per screen line
  22. linea   equ     $a000    linea operator(pseudo instruction)for ATARI
  23. *       .text:
  24.         move.l   4(sp),a0       calculate program size
  25.         move.w   #$100,d6
  26.         add.l    12(a0),d6
  27.         bsr      init           program initialization
  28.         clr      -(sp)
  29.         move.l   d6,-(sp)       number bytes
  30.         move     #keep,-(sp)  
  31.         trap     #gemdos
  32. init    dc.w     linea        get linea pointers for initialization;d0,a0,a1,a2
  33.         moveq    #2*4,d0          font number ; of the three in array of reg a1
  34.         lea      fontptr(pc),a3   use smallest font for color; middle for mono
  35.         move.l   (a1,d0),(a3)    mark font pointer
  36.         move     #gettime,-(sp)
  37.         trap     #xbios
  38.         addq.l   #2,sp
  39.         move     d0,d7
  40.         pea      sup_rout(pc)
  41.         move     #super,-(sp)   execute rest in supervisor mode
  42.         trap     #xbios
  43.         addq.l   #6,sp
  44.         rts
  45. sup_rout:
  46.         move     d7,d0
  47.         and      #%11111,d0
  48.         lsl      #1,d0          seconds in binary
  49.         move     d0,second
  50.         move     d7,d0
  51.         lsr      #5,d0
  52.         and      #%111111,d0
  53.         move     d0,minute
  54.         move     d7,d0
  55.         moveq    #11,d1
  56.         lsr      d1,d0
  57.         move     d0,hour
  58.         move     #$2700,sr      interrupts disabled
  59.         move.l   hz_200,time
  60.         add.l    #200,time
  61.         pea      hz_int(pc)
  62.         move     #$45,-(sp)     timer c interrupt vector
  63.         move     #setexec,-(sp)
  64.         trap     #bios
  65.         addq.l   #8,sp
  66.         move.l   d0,hz_save     200hz vector mark
  67.         rts
  68. hz_int  movem.l  d0-d7/a0-a6,-(sp)      save registers
  69.         move.l   time,d0
  70.         cmp.l    hz_200,d0      one second yet?
  71.         bne      no_show        no
  72.         add.l    #200,time      next second 
  73.         addq     #1,second
  74.         cmp      #60,second     check seconds
  75.         bne      show_time
  76.         clr      second
  77.         addq     #1,minute      next minute
  78.         cmp      #60,minute     ckeck minutes
  79.         bne      show_time
  80.         clr      minute
  81.         addq     #1,hour
  82.         cmp      #24,hour       check hours
  83.         bne      show_time
  84.         clr      hour
  85. show_time:
  86.         move     #68,d6        cursor position;(adj. to allow .BAK op.in edit)
  87.         move     hour,d0        get hour
  88.         bsr      wrtdec
  89.         bsr      wrtcol
  90.         move     minute,d0      get minute
  91.         bsr      wrtdec
  92.         bsr      wrtcol
  93.         move     second,d0      get second
  94.         bsr      wrtdec
  95. no_show movem.l  (sp)+,d0-d7/a0-a6
  96.         move.l   hz_save,-(sp)  address of routine
  97.         rts
  98. wrtdec:
  99.         move     #$2f,d1        number 10
  100. wrtdec1 addq     #1,d1
  101.         sub      #10,d0
  102.         bpl      wrtdec1
  103.         add      #$3a,d0        one digit
  104.         move     d0,-(sp)             
  105.         move     d1,d0           
  106.         bsr      wrtchar        output
  107.         move     (sp)+,d0       unit
  108.         bra      wrtchar        output
  109. wrtcol  moveq    #$3a,d0         ':'
  110. *                               write characters to graphic ram
  111. *                               where: d0 = character
  112. *                                      d6 = cursor column
  113. wrtchar:
  114.         moveq   #0,d1
  115.         move    d6,d1
  116.         addq    #1,d6           move cursor to next column
  117.         move.l  fontptr(pc),a3  get font pointer
  118.         add.l   _v_bas_ad,d1    plus screen address
  119.         move.l  d1,a4
  120.         move.l  fontdat(a3),a0  font data pointer
  121.         move    formwd(a3),d2   offset of next raster line in font
  122.         move    formhg(a3),d7   form height (number pf scan lines)
  123.         subq    #1,d7
  124. loop    move.b  (a0,d0),(a4)    onscreen raster line
  125.         add     #line1,a4       pointer to next screen line
  126.         add     d2,a0           pointer to next raster line in font
  127.         dbra    d7,loop
  128.         rts
  129. fontptr ds.l     1
  130. hz_save ds.l     1
  131. second  ds.w     1
  132. minute  ds.w     1
  133. hour    ds.w     1
  134. time    ds.l     1
  135.         .end
  136.