home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 1 / GoldFishApril1994_CD2.img / d4xx / d438 / toollib / examples / clock.s < prev    next >
Text File  |  1991-01-17  |  4KB  |  134 lines

  1. *
  2. *   clock.s
  3. *
  4. *   Just a little demo of how to program with the "tool.library"
  5. *
  6. *   Please change, destruct, molest it for it's PUBLIC DOMAIN
  7. *
  8. *
  9. *   YES NICO, I HAVE BOUGHT POWERPACKER V3.0a ! (P.S. IT'S GREAT !!!)
  10. *
  11.  
  12.                 INCDIR  SYS:Devpac_INC/
  13.                 INCLUDE tool.i
  14.                 INCLUDE intuition/intuition.i
  15.                 INCLUDE tool_lib.i
  16.                 INCLUDE exec/exec_lib.i
  17.                 INCLUDE intuition/intuition_lib.i
  18.                 INCLUDE graphics/graphics_lib.i
  19.  
  20.                 INCLUDE misc/easystart.i
  21.  
  22. *
  23. *   open up the "tool.library" V7++
  24. *
  25.                 lea.l   tool_name(pc),a1
  26.                 moveq   #TOOL_VERSION,d0
  27.                 CALLEXEC    OpenLibrary
  28.                 move.l  d0,_ToolBase
  29.                 beq     NoTOOL
  30. *
  31. *   extract the IntuitionBase and GfxBase poiters
  32. *   so I can use them to call uppon routines of the
  33. *   intuition and graphics.library.
  34. *
  35.                 move.l  d0,a0
  36.                 move.l  tb_IntuitionBase(a0),_IntuitionBase
  37.                 move.l  tb_GfxBase(a0),_GfxBase
  38. *
  39. *   open the clock window, extract rastport
  40. *
  41.                 lea.l   CL_nw(pc),a0
  42.                 CALLINT     OpenWindow
  43.                 move.l  d0,CWindow
  44.                 beq     NoWINDOW
  45.                 move.l  d0,a0
  46.                 move.l  wd_RPort(a0),RPort
  47. *
  48. *   set up a "TimeDelay" structure which puts the task to
  49. *   sleep for a 1/2 second.
  50. *
  51.                 move.l  wd_UserPort(a0),a0
  52.                 move.l  a0,WDPort
  53.                 moveq   #0,d0
  54.                 move.l  #500000,d1
  55.                 CALLTOOL    CreateTimeDelay
  56.                 move.l  d0,TimeDel
  57.                 beq     NoDELAY
  58. *
  59. *   set graphics pens and mode
  60. *
  61.                 move.l  RPort,a1
  62.                 moveq   #2,d0
  63.                 CALLGRAF    SetAPen
  64.                 move.l  RPort,a1
  65.                 moveq   #1,d0
  66.                 CALLGRAF    SetBPen
  67.                 move.l  RPort,a1
  68.                 moveq   #RP_JAM2,d0
  69.                 CALLGRAF    SetDrMd
  70. *
  71. *   main clock loop
  72. *
  73.  
  74. *
  75. *   get the current system date.
  76. *
  77. Loop:           suba.l  a0,a0
  78.                 lea.l   TBuf(pc),a1
  79.                 moveq   #ALL,d0
  80.                 CALLTOOL    GetDate
  81. *
  82. *   set the rastport coordinates and print the date
  83. *
  84.                 move.l  RPort,a1
  85.                 moveq   #28,d0
  86.                 moveq   #7,d1
  87.                 CALLGRAF    Move
  88.                 move.l  RPort,a1
  89.                 lea.l   TBuf(pc),a0
  90.                 moveq   #MINDATE-2,d0
  91.                 CALLGRAF    Text
  92. *
  93. *   put the task to sleep for 1/2 second. everytime this
  94. *   half a second passed it will update the display.
  95. *
  96.                 move.l  TimeDel,a0
  97.                 CALLTOOL    DoTimeDelay
  98.                 tst.l   d0
  99.                 beq     Loop
  100. *
  101. *   "DoTimeDelay" returned true which means that a message
  102. *   came to the window it's userport. Since only CLOSEWINDOW
  103. *   can be the message it cleans up and exits the program.
  104. *
  105.                 move.l  WDPort,a0
  106.                 CALLEXEC    GetMsg
  107.                 move.l  d0,a1
  108.                 CALLEXEC    ReplyMsg
  109.                 move.l  TimeDel,a0
  110.                 CALLTOOL    DeleteTimeDelay
  111. NoDELAY:        move.l  CWindow,a0
  112.                 CALLINT     CloseWindow
  113. NoWINDOW:       move.l  _ToolBase,a1
  114.                 CALLEXEC    CloseLibrary
  115. NoTOOL:         moveq   #0,d0
  116.                 rts
  117.  
  118. _ToolBase:      dc.l    0
  119. _IntuitionBase: dc.l    0
  120. _GfxBase:       dc.l    0
  121. CWindow:        dc.l    0
  122. RPort:          dc.l    0
  123. WDPort:         dc.l    0
  124. TimeDel:        dc.l    0
  125. CL_nw:          dc.w    100,0,270,10
  126.                 dc.b    0,1
  127.                 dc.l    CLOSEWINDOW
  128.                 dc.l    WINDOWCLOSE!WINDOWDRAG!SIMPLE_REFRESH!NOCAREREFRESH!RMBTRAP
  129.                 dc.l    0,0,0,0,0
  130.                 dc.w    0,0,0,0,WBENCHSCREEN
  131. tool_name:      dc.b    'tool.library',0
  132.                 even
  133. TBuf:           dcb.b   MINDATE,0
  134.