home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 89 / asm / source / time.asm < prev   
Encoding:
Assembly Source File  |  2001-07-01  |  4.6 KB  |  149 lines

  1. ;-------------------------------------------------------------------------------------------------
  2.         ;1999/03/06
  3.         ;Arie_Benichou@Hotmail.com
  4. ;-------------------------------------------------------------------------------------------------
  5.         include        doorsos.h
  6.         include        graphlib.h
  7. ;-------------------------------------------------------------------------------------------------
  8.         xdef         _ti89   
  9.         xdef         _main   
  10.         xdef          _comment  
  11. ;-------------------------------------------------------------------------------------------------
  12. Laps             equ          100
  13. MaskRow1     equ         %11111101
  14. MaskRow5     equ          %11011111
  15. MaskRow6     equ          %10111111
  16. ;-------------------------------------------------------------------------------------------------
  17. DispValue:     MACRO
  18.          clr.l           d2 
  19.          move.w          \1,d2
  20.          bsr             String
  21.          PxlText         a0,\2,\3,\4,\5
  22.         ENDM
  23. ;-------------------------------------------------------------------------------------------------
  24. Int1_OFF:     MACRO
  25.          clr.l           d0
  26.          move.w          #$0700,d0
  27.          trap            #1
  28.          bclr.b          #2,($600001)  
  29.          move.l          \1,($64)  
  30.          bset.b          #2,($600001)
  31.          trap            #1
  32.         ENDM
  33. ;-------------------------------------------------------------------------------------------------
  34. Int1_ON:        MACRO  
  35.          clr.l           d0   
  36.          move.w          #$0700,d0  
  37.          trap            #1   
  38.          bclr.b          #2,($600001)  
  39.          move.l          ($64),\1
  40.          move.l          \2,($64)  
  41.          bset.b          #2,($600001)
  42.          trap            #1
  43.         ENDM
  44. ;-------------------------------------------------------------------------------------------------
  45. PxlText:        MACRO  
  46.          SetFont          \5
  47.          move.w          \4,-(a7)
  48.          move.l          \1,-(a7)
  49.          move.w          \2,-(a7)
  50.          move.w          \3,-(a7)
  51.          jsr         doorsos::DrawStrXY
  52.          lea             10(a7),a7
  53.         ENDM
  54. ;-------------------------------------------------------------------------------------------------
  55. _main:        Int1_ON          oldint1,#NewInt1
  56.         jsr        graphlib::clr_scr
  57. ;-------------------------------------------------------------------------------------------------
  58. CLEAR:        PxlText        #time,#44,#48,#4,#2
  59.          clr.w            timer
  60.          clr.w            seconds
  61.          clr.w            minutes
  62.          clr.w            hours
  63. ;-------------------------------------------------------------------------------------------------
  64. KeyBoard:    cmp.w            #360,timer
  65.          ble              \MaskRow
  66.          bsr              CheckTime
  67.  
  68. \MaskRow    move.w           #MaskRow1,d0
  69.          bsr              GetKey
  70.          btst.b           #6,d0
  71.          beq              CLEAR
  72.          move.w          #MaskRow5,d0
  73.          bsr              GetKey
  74.          btst.b           #0,d0
  75.          beq              APPS
  76.          move.w           #MaskRow6,d0
  77.          bsr              GetKey
  78.          btst.b           #0,d0
  79.          beq              ESC
  80.  
  81.          bra              KeyBoard
  82. ;-------------------------------------------------------------------------------------------------
  83. APPS:        trap        #4
  84.          bra              KeyBoard
  85. ;-------------------------------------------------------------------------------------------------
  86. ESC:        Int1_OFF        oldint1
  87. Return        rts
  88. ;-------------------------------------------------------------------------------------------------
  89. CheckTime:     clr.w            timer
  90.          add.w            #1,seconds
  91.          cmp.w            #60,seconds
  92.         bne        \DispTime
  93.         clr.w            seconds
  94.          add.w            #1,minutes
  95.          cmp.w            #60,minutes
  96.         bne        \DispTime
  97.          clr.w            minutes
  98.          add.w            #1,hours
  99.          cmp.w            #24,hours
  100.         bne        \DispTime
  101.          clr.w            hours
  102.  
  103. \DispTime    DispValue     seconds,#44,#96,#4,#2
  104.          DispValue     minutes,#44,#72,#4,#2
  105.          DispValue     hours,#44,#48,#4,#2
  106.         rts
  107. ;-------------------------------------------------------------------------------------------------
  108. GetKey:      move.w          d0,$600018
  109.          move.w          #Laps,d0  
  110. \delay           dbra          d0,\delay
  111.          move.b          $60001b,d0 
  112.          rts    
  113. ;-------------------------------------------------------------------------------------------------
  114. NewInt1:        add.w        #1,timer
  115.         rte
  116. ;-------------------------------------------------------------------------------------------------
  117. String:         move.l         #str+8,a0
  118.          clr.b          (a0)
  119.          clr.l          d3
  120.  
  121. \str_loop         add.l          #1,d3
  122.          divu           #10,d2
  123.          swap           d2
  124.          add.b          #48,d2
  125.          move.b         d2,-(a0)
  126.          clr.w          d2
  127.          swap           d2
  128.          tst.w          d2
  129.          bne            \str_loop
  130.          cmp.l          #1,d3
  131.          bne            Return
  132.          clr.l          d2
  133.          add.b          #48,d2
  134.          move.b         d2,-(a0)
  135.          rts
  136. ;-------------------------------------------------------------------------------------------------
  137. _comment:     dc.b          "Time by Arie",0
  138. ;-------------------------------------------------------------------------------------------------
  139. time:        dc.b        "00:00:00"
  140.  
  141.           BSS
  142. str:             ds.b          8
  143. timer:          ds.w          1
  144. seconds:     ds.w          1
  145. minutes:         ds.w          1
  146. hours:           ds.w          1
  147. oldint1:         ds.l          1 
  148. ;-------------------------------------------------------------------------------------------------
  149.         end