home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 28 / amigaformatcd28.iso / -seriously_amiga- / programming / other / gauge / gexample.asm < prev    next >
Encoding:
Assembly Source File  |  1998-04-23  |  8.4 KB  |  327 lines

  1.  
  2.  
  3. ;$VER: Usage of Gauge by Andry of PEGAS 0.1 (16.11.97)
  4.  
  5. ;This example shows how to use the Gauge-code.
  6. ;GAF_SCREEN and GAF_SYSTEMFONT are not demonstrated but their usage
  7. ;is very similar.
  8.  
  9. ;Enjoy.
  10. ;           Andry
  11.  
  12.  
  13.  
  14.         MACHINE    68020
  15.  
  16.         INCDIR    "INCLUDE:"
  17.         INCLUDE "ram:Gauge.i"
  18.         INCLUDE    "lvo/exec_lib.i"
  19.         INCLUDE    "lvo/dos_lib.i"
  20.         INCLUDE    "lvo/intuition_lib.i"
  21.         INCLUDE    "lvo/reqtools_lib.i"
  22.         INCLUDE    "intuition/intuition.i"
  23.         INCLUDE    "libraries/reqtools.i"
  24.  
  25.         XREF    ga_OpenGauge,ga_RedrawGauge,ga_CloseGauge
  26.  
  27. IMAGEWIDTH    = 250
  28. IMAGEHEIGHT    = 100
  29.  
  30. SHOWTEXT    MACRO
  31.         lea    text_\1,a0
  32.         bsr.w    ShowText
  33.         ENDM
  34.  
  35.         SECTION    example,CODE
  36.  
  37.         jmp    _IconStart
  38.  
  39. _main        lea    (EB,pc),a0
  40.         move.l    4.w,(a0)
  41.  
  42.     ;OpenLibraries
  43.         lea    IntuiName,a1
  44.         moveq    #36,d0
  45.         move.l    (EB,pc),a6
  46.         jsr    (_LVOOpenLibrary,a6)
  47.         move.l    d0,IntuiBase
  48.         beq.w    NoIntuition
  49.  
  50.         lea    DosName,a1
  51.         moveq    #0,d0
  52.         move.l    (EB,pc),a6
  53.         jsr    (_LVOOpenLibrary,a6)
  54.         move.l    d0,DosBase
  55.         beq.w    NoDos
  56.  
  57.         lea    ReqtoolsName,a1
  58.         moveq    #0,d0
  59.         move.l    (EB,pc),a6
  60.         jsr    (_LVOOpenLibrary,a6)
  61.         move.l    d0,ReqtoolsBase
  62.         beq.w    NoReqtools
  63.  
  64.     ;open some window
  65.         move.l    IntuiBase,a6
  66.         sub.l    a0,a0    ;NewWindow
  67.         lea    WinTags,a1
  68.         jsr    (_LVOOpenWindowTagList,a6)
  69.         move.l    d0,WindowPtr
  70.         beq.w    NoWindow
  71.     ;now show the advertisment
  72.         move.l    WindowPtr,a0
  73.         moveq    #0,d0
  74.         move.l    d0,d1
  75.         move.b    (wd_BorderLeft,a0),d0
  76.         move.b    (wd_BorderTop,a0),d1
  77.         move.l    (wd_RPort,a0),a0
  78.         lea    AdvertImage,a1
  79.         move.l    IntuiBase,a6
  80.         jsr    (_LVODrawImage,a6)
  81.  
  82.         SHOWTEXT start
  83.     ;init the GaugeParams structure
  84.         lea    Params,a5
  85.         move.w    #200,(gapa_WinPos,a5)    ;x (MSW)
  86.         move.w    #30,(gapa_WinPos+2,a5)    ;y (LSW)
  87.         move.l    WindowPtr,(gapa_ScrWinAdr,a5)
  88.         move.l    #3,(gapa_Delay,a5)
  89.         move.l    #AnotherTitle,(gapa_Title,a5)
  90.         move.w    #300,(gapa_BarWidth,a5)
  91. ;centered in screen (stop)
  92.         SHOWTEXT centerinscreen
  93.         move.l    #GAF_ENABLESTOP!GAF_STRUCTURE,d0
  94.         move.l    a5,a0        ;structure GaugeParams
  95.         jsr    ga_OpenGauge
  96.         bsr.w    ProcessGauge        ;also closes the gauge
  97. ;centered in window
  98.         SHOWTEXT centerinwindow
  99.         move.l    #GAF_ENABLESTOP!GAF_WINDOW!GAF_STRUCTURE,d0
  100.         move.l    a5,a0
  101.         jsr    ga_OpenGauge
  102.         bsr.w    ProcessGauge
  103. ;not centered (but relative to screen's left/top edge)
  104.         SHOWTEXT absscreen
  105.         move.l    #GAF_ENABLESTOP!GAF_NOCENTER!GAF_STRUCTURE,d0
  106.         move.l    a5,a0
  107.         jsr    ga_OpenGauge
  108.         bsr.w    ProcessGauge
  109. ;not centered (but relative to window's left/top edgr)
  110.         SHOWTEXT abswindow
  111.         move.l    #GAF_ENABLESTOP!GAF_NOCENTER!GAF_WINDOW!GAF_STRUCTURE,d0
  112.         move.l    a5,a0
  113.         move.w    #60,(gapa_WinPos,a0)    ;x (MSW)
  114.         move.w    #60,(gapa_WinPos+2,a0)    ;y (LSW)
  115.         jsr    ga_OpenGauge
  116.         bsr.w    ProcessGauge
  117. ;sleeptime
  118.         SHOWTEXT sleeptime
  119.         move.l    #GAF_ENABLESTOP!GAF_WINDOW!GAF_SLEEPTIME!GAF_STRUCTURE,d0
  120.         move.l    a5,a0
  121.         jsr    ga_OpenGauge
  122.         bsr.w    ProcessGauge
  123. ;just a basic gauge (all parameters are ignored)
  124.         SHOWTEXT basic
  125.         moveq    #0,d0
  126.         jsr    ga_OpenGauge
  127.         bsr.w    ProcessGauge    ;faster that the others (no stop button)
  128. ;other label
  129.         SHOWTEXT wintitle
  130.         move.l    #GAF_ENABLESTOP!GAF_WTITLE!GAF_STRUCTURE,d0
  131.         move.l    a5,a0
  132.         jsr    ga_OpenGauge
  133.         bsr.w    ProcessGauge
  134. ;other stoptext
  135.         SHOWTEXT stoptext
  136.         move.l    #GAF_ENABLESTOP!GAF_WTITLE!GAF_STRUCTURE,d0
  137.         move.l    a5,a0
  138.         move.l    #AnotherStop,(gapa_StopText,a0)    ;set new text for stop gadget
  139.         jsr    ga_OpenGauge
  140.         bsr.w    ProcessGauge
  141. ;bar width
  142.         cmpi.l    #GA_STOP,d0
  143.         bne.s    .norm
  144.         SHOWTEXT patience
  145. .norm        SHOWTEXT barwidth
  146.         clr.l    (gapa_StopText,a5)    ;turn the gadget back to default text
  147.         move.l    #GAF_ENABLESTOP!GAF_WIDTH!GAF_STRUCTURE,d0
  148.         move.l    a5,a0
  149.         jsr    ga_OpenGauge
  150.         bsr.w    ProcessGauge
  151.  
  152.  
  153.         SHOWTEXT end
  154.  
  155.         move.l    IntuiBase,a6
  156.         move.l    WindowPtr,a0
  157.         jsr    (_LVOCloseWindow,a6)
  158.  
  159. NoWindow    move.l    (EB,pc),a6
  160.         move.l    ReqtoolsBase,a1
  161.         jsr    (_LVOCloseLibrary,a6)
  162.  
  163. NoReqtools    move.l    (EB,pc),a6
  164.         move.l    DosBase,a1
  165.         jsr    (_LVOCloseLibrary,a6)
  166.  
  167. NoDos        move.l    (EB,pc),a6
  168.         move.l    IntuiBase,a1
  169.         jsr    (_LVOCloseLibrary,a6)
  170. NoIntuition
  171.         rts
  172.  
  173.  
  174. ;--------------------------------------------------------------------
  175. ProcessGauge    move.l    DosBase,a6
  176.         moveq    #0,d2
  177.  
  178. .loop        addq.w    #1,d2
  179.         cmpi.w    #101,d2
  180.         beq.s    .ok
  181.         move.l    d2,d0
  182.         jsr    ga_RedrawGauge
  183.         cmpi.l    #GA_STOP,d0
  184.         beq.s    .stopped
  185.  
  186.         moveq    #2,d1
  187.         jsr    (_LVODelay,a6)
  188.         bra.s    .loop
  189.  
  190. .ok        jsr    ga_CloseGauge
  191.         moveq    #0,d0        ;ok
  192.         rts
  193. .stopped    jsr    ga_CloseGauge
  194.         move.l    #GA_STOP,d0    ;stopped
  195.         rts
  196. ;-----------------------------------------------------------------------
  197. ShowText    ;opens an reqtools requester with informations about
  198.         ;the next gauge
  199.         ;IN: a0-ptr to the text
  200.  
  201.         move.l    ReqtoolsBase,a6
  202.         move.l    a0,a1
  203.         lea    reqtButton,a2
  204.         sub.l    a3,a3
  205.         sub.l    a4,a4
  206.         lea    reqtTags,a0
  207.         jsr    (_LVOrtEZRequestA,a6)
  208.         rts
  209.  
  210. _IconStart    movem.l    d0/a0,-(sp)    ;command line
  211.         sub.l    a1,a1        ;find myself
  212.         move.l    4.w,a6
  213.         jsr    (_LVOFindTask,a6)
  214.         movea.l    d0,a2
  215.         tst.l    ($ac,a2)    ;from WB?    (pr_CLI = $AC)
  216.         bne.s    .From_CLI    ;no
  217.     ;from WorkBench
  218.         lea    ($5c,a2),a2    ;pr_MsgPort
  219.         move.l    a2,a0
  220.         jsr    (_LVOWaitPort,a6)
  221.         move.l    a2,a0
  222.         jsr    (_LVOGetMsg,a6)
  223.         lea    (WBmessage,PC),a0
  224.         move.l    d0,(a0)
  225.         movem.l    (sp)+,d0/a0
  226.         bra.s    .CoWB_run
  227. .From_CLI    movem.l    (sp)+,d0/a0    ;d0 = length of command line including LF
  228.                     ;a0 - ptr. to 1. char of command line (Ucase<>Lcase)
  229.  
  230. .CoWB_run    jsr    _main
  231.  
  232.         move.l    d0,-(sp)    ;returncode
  233.     ;return to CLI or WB ?
  234.         tst.l    (WBmessage,pc)    ;68020+ instruction
  235.         beq.s    .To_CLI
  236.         move.l    4.w,a6
  237.         jsr    (_LVOForbid,a6)
  238.         move.l    (WBmessage,pc),a1
  239.         jsr    (_LVOReplyMsg,a6)
  240. .To_CLI        move.l    (sp)+,d0    ;returncode
  241.         rts
  242.  
  243. WBmessage    dc.l    0
  244. EB    dc.l    0    ;ExecBase
  245.  
  246.         SECTION exampleData,DATA
  247. IntuiBase    dc.l    0
  248. DosBase        dc.l    0
  249. ReqtoolsBase    dc.l    0
  250. IntuiName    dc.b    'intuition.library',0
  251. DosName        dc.b    'dos.library',0
  252. ReqtoolsName    dc.b    'reqtools.library',0
  253.  
  254. AnotherTitle    dc.b    'Andry is the best!',0
  255. AnotherStop    dc.b    'Stop this shit!!!',0
  256. WinTitle    dc.b    'Gauge presentation',0
  257.  
  258.         cnop    0,4
  259. reqtTags    dc.l    RTEZ_Flags,EZREQF_CENTERTEXT
  260.         dc.l    TAG_DONE,0
  261.  
  262. WindowPtr    dc.l    0
  263. WinTags        dc.l    WA_Left,50
  264.         dc.l    WA_Top,50
  265.         dc.l    WA_InnerWidth,IMAGEWIDTH
  266.         dc.l    WA_InnerHeight,IMAGEHEIGHT
  267.         dc.l    WA_Activate,1
  268.         dc.l    WA_SmartRefresh,1
  269.         dc.l    WA_CloseGadget,1
  270.         dc.l    WA_DepthGadget,1
  271.         dc.l    WA_DragBar,1
  272.         dc.l    WA_Title,WinTitle
  273.         dc.l    WA_BusyPointer,1
  274.         dc.l    WA_PointerDelay,1
  275.         dc.l    TAG_DONE,0
  276.  
  277. AdvertImage    dc.w    0,0    ;left,top
  278.         dc.w    IMAGEWIDTH,IMAGEHEIGHT,3    ;w,h,depth
  279.         dc.l    AdvertRaw    ;ImageData
  280.         dc.b    %111,0        ;PlanePick,PlaneOnOff
  281.         dc.l    0        ;NextImage
  282.  
  283. Params        dcb.b    gapa_SIZEOF,0
  284.  
  285. reqtButton    dc.b    'Continue',0
  286.  
  287. text_start        dc.b    'This is a presentation of some features which are',10
  288.             dc.b    'implemented in the Gauge-code by Andry of PEGAS.',10
  289.             dc.b    'Watch it...',0
  290. text_centerinscreen    dc.b    'The first gauge will be just centered',10
  291.             dc.b    'within the VISIBLE bounds of screen.',10
  292.             dc.b    'It will also become a STOP gadget.',0
  293. text_centerinwindow    dc.b    'The next gauge will be centered within bounds',10
  294.             dc.b    'of the opened window.',0
  295. text_absscreen        dc.b    'You can also specify absolute position of the',10
  296.             dc.b    'gauge window. The next will appear at position',10
  297.             dc.b    'Left = 200  and  Top = 30  relative to Left/Top',10
  298.             dc.b    'corner of the SCREEN.',0
  299. text_abswindow        dc.b    'Let',39,'s open at position (60,60) relative to',10
  300.             dc.b    'Left/Top corner of the WINDOW.',0
  301. text_basic        dc.b    'Here comes a gauge which is the simplest you can use.',10
  302.             dc.b    'No STOP gadget, also other features are not used.',10
  303.             dc.b    'This type of gauge you can create with TWO instructions',10
  304.             dc.b    'in your code.',0
  305. text_wintitle        dc.b    'If you want, you can set another title to the gauge window.',10
  306.             dc.b    'Let',39,'s see ...',0
  307. text_stoptext        dc.b    'Of course you are able to set another text',10
  308.             dc.b    'for the STOP gadget.',0
  309. text_patience        dc.b    'Unfortunally, you have to watch it until the end.',10
  310.             dc.b    'But don',39,'t worry, we are almost there.',0
  311. text_barwidth        dc.b    'Another width of the gauge bar may be specified.',0
  312. text_sleeptime        dc.b    'If you don',39,'t want the gauge appear if the operation',10
  313.             dc.b    'takes only few time (e.g. on a 68060 would it just',10
  314.             dc.b    'disturb  :-), you can specify a time period for which',10
  315.             dc.b    'the gauge stays hidden.',10
  316.             dc.b    'The next will appear after about 3 seconds.',0
  317. text_end        dc.b    'So there were some examples. There are more features',10
  318.             dc.b    'and new will come if I see some reactions.',10
  319.             dc.b    'Whatever, it was made for YOU - CODER!',10,10
  320.             dc.b    'So send me suggestions, bug reports or whatever you want',10
  321.             dc.b    '(except bombs, acids ... well if you had some ACID...).',10,10
  322.             dc.b    'CONTACT: Andreas Bednarek, Tyrsova 4, 751 24, PREROV, CZECH REP.',10
  323.             dc.b    ' e-mail: kozubv@vtx.cz   (available until March 1998)',0
  324.  
  325.         SECTION image,DATA_C
  326. AdvertRaw    INCBIN    "ram:Advert.raw"
  327.