home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / misc / prog_bar.lha / prog_bar / Assembler / Demo / Demo.a < prev    next >
Encoding:
Text File  |  1997-01-12  |  5.0 KB  |  211 lines

  1.  
  2.    include exec/libraries.i
  3.    include intuition/intuition.i
  4.    include intuition/intuition_lib.i
  5.    include exec/exec_lib.i
  6.    include graphics/graphics_lib.i
  7.    include exec/memory.i
  8.    include libraries/dos_lib.i
  9.    include libraries/dos.i
  10.    include libraries/gadtools_lib.i
  11.    include utility/utility_lib.i
  12.  
  13.    include libraries/prog_bar.i
  14.  
  15.    include easystart.i
  16.  
  17.  
  18. * firstly open the intuition library
  19.    lea   intname(pc),a1
  20.    moveq #0,d0                   dont care which version
  21.    CALLEXEC OpenLibrary
  22.    tst.l d0
  23.    beq   goawayfast              if didnt open
  24.  
  25.    move.l   d0,_IntuitionBase    store lib pointer
  26.  
  27. * and open the graphics library
  28.    lea   grafname(pc),a1
  29.    moveq #0,d0
  30.    CALLEXEC OpenLibrary
  31.    tst.l d0
  32.    beq   goawaycloseint
  33.    move.l   d0,_GfxBase
  34.  
  35. * and open a DOS library
  36.    lea   dosname(pc),a1
  37.    moveq #0,d0
  38.    CALLEXEC OpenLibrary
  39.    tst.l d0
  40.    beq   goawayclosegraf
  41.    move.l   d0,_DOSBase
  42.  
  43. * and open a Gadtools library
  44.    lea   gadname(pc),a1
  45.    moveq #0,d0
  46.    CALLEXEC OpenLibrary
  47.    tst.l d0
  48.    beq   goawayclosedos
  49.    move.l   d0,_GadToolsBase
  50.  
  51. * and open the Utility library
  52.    lea   utilityname(pc),a1
  53.    moveq #0,d0
  54.    CALLEXEC OpenLibrary
  55.    tst.l d0
  56.    beq   goawayclosegadtools
  57.    move.l   d0,_UtilityBase
  58.  
  59. * open a window next
  60.    lea   windowdef(pc),a0
  61.    CALLINT  OpenWindow
  62.    tst.l d0
  63.    beq   goawaycloseall          if no window
  64.    move.l   d0,windowptr         store the pointer
  65.  
  66. * create the progress bar
  67.    pea.l    pbar_tags
  68.    move.l   max_size,-(sp)
  69.    move.l   #30,-(sp)
  70.    move.l   #300,-(sp)
  71.    move.l   #65,-(sp)
  72.    move.l   #100,-(sp)
  73.    move.l   windowptr,-(sp)
  74.    jsr      _CreateProgBarA
  75.    move.l   d0,PBar_ptr
  76.    lea      28(sp),sp
  77.    tst.l    d0
  78.    beq      closewindow
  79.  
  80. mainloop
  81. * now see if a message is waiting for me
  82. messagetest
  83.    move.l      windowptr(pc),a0
  84.    move.l      wd_UserPort(a0),a0      windows message port
  85.    CALLEXEC    GetMsg
  86.    tst.l       d0
  87.    beq.s       nomessage
  88.  
  89. * there was a message, which in our case must be CLOSEWINDOW,
  90. * so we should reply then go away
  91.    move.l      d0,a1
  92.    CALLEXEC    ReplyMsg
  93.    bra.s       killbar
  94.  
  95. * no messages waiting, so suspend myself for a short while then
  96. * do it all again
  97. nomessage
  98.    move.l      counter,D0
  99.    addq.l      #1,D0
  100.    move.l      max_size,D1
  101.    addq.l      #1,D1
  102.    cmp.l       D1,D0
  103.    bcs         no_reset
  104.  
  105.    move.l      PBar_ptr,-(sp)
  106.    jsr         _ResetProgBar
  107.    addq.l      #4,sp
  108.    moveq.l     #0,D0
  109.  
  110. no_reset
  111.    move.l      D0,counter
  112.  
  113.    move.l      D0,-(sp)
  114.    move.l      PBar_ptr,-(sp)
  115.    jsr         _UpdateProgBar
  116.    addq.l      #8,sp
  117.  
  118.    moveq       #5,D1
  119.    CALLDOS     Delay
  120.    bra         mainloop
  121.  
  122. * close clicked so kill the progress bar and close the window
  123. killbar
  124.    move.l      PBar_ptr,-(sp)
  125.    jsr         _FreeProgBar
  126.    addq.l      #4,sp
  127.  
  128. closewindow
  129.    move.l   windowptr(pc),a0
  130.    CALLINT     CloseWindow
  131.  
  132. * close all the libraries
  133.  
  134. * close the utility library
  135. goawaycloseall
  136.    move.l   _UtilityBase,a1
  137.    CALLEXEC CloseLibrary
  138.  
  139. * close the gadtools library
  140. goawayclosegadtools
  141.    move.l   _GadToolsBase,a1
  142.    CALLEXEC CloseLibrary
  143.  
  144. * close the graphics library
  145. goawayclosedos
  146.    move.l   _DOSBase,a1
  147.    CALLEXEC CloseLibrary
  148.  
  149. * close the graphics library
  150. goawayclosegraf
  151.    move.l   _GfxBase,a1
  152.    CALLEXEC CloseLibrary
  153.  
  154. * finished so close Intuition library
  155. goawaycloseint
  156.    move.l   _IntuitionBase,a1
  157.    CALLEXEC CloseLibrary
  158.  
  159. goawayfast
  160.    moveq #0,d0
  161.    rts
  162.  
  163.  
  164. * window definition here
  165. windowdef   dc.w  50,50       x posn, y posn
  166.    dc.w  500,150              width,height
  167.    dc.b  -1,-1                default pens
  168.    dc.l  CLOSEWINDOW          easy IDCMP flag
  169.    dc.l  WINDOWDEPTH!WINDOWCLOSE!SMART_REFRESH!ACTIVATE!WINDOWDRAG
  170.    dc.l  0                    no gadgets
  171.    dc.l  0                    no checkmarks
  172.    dc.l  windowtitle          title of window
  173.    dc.l  0                    no screen
  174.    dc.l  0                    no bitmap
  175.    dc.w  0,0,0,0              minimum, irrelevant as no sizing gadget
  176.    dc.w  WBENCHSCREEN         in workbench
  177.  
  178. * prog_bar taglist
  179. pbar_tags
  180.    dc.l  PB_BorderType,PBBT_RIDGE
  181.    dc.l  PB_TextMode,PBTM_PERCENT
  182.    dc.l  PB_TextPosition,PBTP_CENTRE
  183.    dc.l  TAG_DONE
  184.  
  185. * strings here
  186. intname        INTNAME           name of intuition lib
  187. grafname       GRAFNAME          name of graphics library
  188. dosname        DOSNAME           name of dos library
  189. gadname        GADNAME           name of gadtools library
  190. utilityname    UTILITYNAME       name of utility library
  191.  
  192. windowtitle dc.b  ' Prog_Bar Demo Program in Assembler',0
  193.  
  194. * variables here
  195. _IntuitionBase    dc.l  0        for int library
  196. _GfxBase          dc.l  0        for graphics library
  197. _DOSBase          dc.l  0        for dos library
  198. _GadToolsBase     dc.l  0        for gadtools library
  199. _UtilityBase      dc.l  0        for Utility library
  200.  
  201.    XDEF     _IntuitionBase
  202.    XDEF     _GfxBase
  203.    XDEF     _DOSBase
  204.    XDEF     _GadToolsBase
  205.    XDEF     _UtilityBase
  206.  
  207. windowptr         dc.l  0        for window ptr
  208. counter           dc.l  0        for loop counter
  209. max_size          dc.l  200      for bar size
  210. PBar_ptr          dc.l  0        for prog_bar pointer
  211.