home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d778 / multireq.lha / MultiReq / ASM / SimpleDemo.asm < prev    next >
Assembly Source File  |  1992-12-06  |  8KB  |  377 lines

  1. ; my includes
  2.  
  3.     include "exec/types.i"
  4.     include    "exec/execbase.i"
  5.     include    "libraries/dosextens.i"
  6.     include "libraries/multireq.i"
  7.     include "libraries/multireq_lib.i"
  8.  
  9. ; some Functions not defined yet
  10.  
  11. _ExecBase    =    4
  12.  
  13. _LVOOpenLibrary    =    -552
  14. _LVOCloseLibrary =    -414
  15.  
  16. _LVOWait    =    -318
  17. _LVOGetMsg    =    -372
  18. _LVOReplyMsg    =    -378
  19.  
  20. _LVOOutput    =    -60
  21. _LVOOpen    =    -30
  22. _LVOClose    =    -36
  23. _LVODelay    =    -198
  24. _LVOWrite    =    -48
  25.  
  26. ; the startup-code for WBStart
  27.  
  28. _startup:
  29.         move.l    _ExecBase,a6
  30.     move.l    ThisTask(a6),a4        ;pointer to this task (better than FindTask !)
  31.     move.l    pr_CLI(a4),d0        ;has this task a CLI
  32.     bne.s    start_main        ;program started from CLI
  33.  
  34. ; Started from WorkBench
  35.  
  36.     lea    pr_MsgPort(a4),a0
  37.     moveq    #1,d0
  38.     moveq    #0,d1
  39.     move.b    MP_SIGBIT(a0),d1
  40.     asl.l    d1,d0
  41.     jsr    _LVOWait(a6)        ;Wait for a msg from WorkBench
  42.  
  43.     lea    pr_MsgPort(a4),a0
  44.     jsr    _LVOGetMsg(a6)        ;Get msg from WorkBench
  45.     lea    _WBMsg(pc),a0
  46.     move.l    d0,(a0)
  47.  
  48. start_main:
  49.     bsr.s    _main
  50.  
  51.     move.l    _WBMsg(pc),d0        ;is there a WorkBench msg ?
  52.     beq.s    go_home
  53.  
  54.         move.l    d0,a1
  55.         move.l    _ExecBase,a6
  56.         jsr    _LVOReplyMsg(a6)
  57.  
  58. go_home:
  59.         moveq    #0,d0
  60.         rts
  61.  
  62.  
  63. _WBMsg:    dc.l    0    ; Set if started from WorkBench
  64.  
  65.  
  66.  
  67. ; the main program
  68.  
  69. _main:
  70.     move.l    _ExecBase,a6
  71.     lea    DOSName(pc),a1
  72.     moveq    #0,d0
  73.     jsr    _LVOOpenLibrary(a6)        ;Open dos.library
  74.     lea    _DOSBase(pc),a0
  75.     move.l    d0,(a0)                ;get DOSBase
  76.     beq    _exit
  77.  
  78.     move.l    _WBMsg(pc),d0        ; started from WBench ?
  79.     bne.s    out_win            ; I was started from WBench
  80.  
  81.     move.l    _DOSBase(pc),a6            ;DOSBase
  82.     jsr    _LVOOutput(a6)            ;get output handle
  83.     bra.s    set_output
  84.  
  85. out_win:
  86.     move.l    _DOSBase(pc),a6            ;DOSBase
  87.     lea    OutWin(pc),a0
  88.     move.l    a0,d1
  89.     move.l    #MODE_NEWFILE,d2
  90.     jsr    _LVOOpen(a6)
  91.  
  92. set_output:
  93.     lea    _output(pc),a0
  94.     move.l    d0,(a0)                ;save output handle
  95.  
  96.     move.l    _ExecBase,a6
  97.     lea    MultiName(pc),a1
  98.     moveq    #0,d0
  99.     jsr    _LVOOpenLibrary(a6)        ;Open multireq.library
  100.     lea    _MultiReqBase(pc),a0
  101.     move.l    d0,(a0)                ;get MultiReqBase
  102.     bne.s    multi_ok
  103.  
  104.     move.l    _DOSBase(pc),a6
  105.     lea    NoMultiReq(pc),a0
  106.     move.l    a0,d2                ;buffer
  107.     move.l    _output(pc),d1            ;handle
  108.     moveq    #30,d3                ;length
  109.     jsr    _LVOWrite(a6)
  110.  
  111.     bra.s    no_multi
  112.  
  113. multi_ok:
  114.  
  115. ; Create a FileReq-structure
  116.  
  117.     move.l    _MultiReqBase(pc),a6
  118.     lea    _fr(pc),a0        ;address of pointer to FileReq
  119.     moveq    #2,d0            ;this version only supports 2 filelists
  120.     jsr    _LVOInitFileReq(a6)
  121.  
  122.     move.l    _fr(pc),d0    ;tst.l
  123.     bne.s    fr_ok
  124.  
  125.     move.l    _DOSBase(pc),a6
  126.     lea    NoFileReq(pc),a0
  127.     move.l    a0,d2                ;buffer
  128.     move.l    _output(pc),d1            ;handle
  129.     moveq    #37,d3                ;length
  130.     jsr    _LVOWrite(a6)
  131.  
  132.     bra.s    no_fr
  133.  
  134. fr_ok:                    ;FileReq-structure ok
  135.  
  136. ; Set some sample parameters
  137.  
  138.     bsr    _SetParameters
  139.  
  140. req_loop:
  141.  
  142. ; start FileRequester on WorkBench-screen
  143.  
  144.     move.l    _MultiReqBase(pc),a6
  145.     move.l    _fr(pc),a0        ;FileReq-structure
  146.     sub.l    a1,a1            ;use WorkBench-Screen
  147.     jsr    _LVOFileRequester(a6)
  148.     move.w    d0,d7            ;ReturnStatus
  149.  
  150. ;Say how the FileRequester was ended
  151.  
  152.     bsr    _WriteAction
  153.  
  154.     cmp.w    #RET_OKAY,d7        ; should I start again ?
  155.     beq.s    req_loop
  156.  
  157.  
  158. ; Delete the FileReq-structure and free the memory */
  159.  
  160.     move.l    _MultiReqBase(pc),a6
  161.     lea    _fr(pc),a0        ;address of pointer to FileReq
  162.     jsr    _LVOFreeFileReq(a6)
  163.  
  164.  
  165. no_fr:                    ; Close the multireq.library
  166.     move.l    _ExecBase,a6
  167.     move.l    _MultiReqBase(pc),a1
  168.     jsr    _LVOCloseLibrary(a6)
  169.  
  170. no_multi:                ; Close the dos.library
  171.     move.l    _WBMsg(pc),d0        ; started from WorkBench ?
  172.     beq.s    cl_multi        ; I was started from CLI
  173.  
  174.     move.l    _DOSBase(pc),a6
  175.     moveq    #100,d1
  176.     jsr    _LVODelay(a6)        ;wait 2 seconds
  177.  
  178.     move.l    _output(pc),d1
  179.     jsr    _LVOClose(a6)
  180.  
  181. cl_multi:
  182.     move.l    _ExecBase,a6
  183.     move.l    _DOSBase(pc),a1
  184.     jsr    _LVOCloseLibrary(a6)
  185.  
  186. _exit:
  187.     rts                ; everything done, bye !
  188.  
  189.  
  190.  
  191. ;    some important data
  192.  
  193. _MultiReqBase:    dc.l    0    ; a pointer to the multireq.library base
  194. _DOSBase:    dc.l    0    ; a pointer to the dos.library base
  195. _fr:        dc.l    0    ; memory for the pointer to the FileReq-structure
  196. _output:    dc.l    0    ; output handle
  197.  
  198. ;    the name of the needed libraries
  199.  
  200. DOSName:    dc.b    'dos.library',0
  201. MultiName:    dc.b    'multireq.library',0
  202.  
  203. NoMultiReq:    dc.b    "Can't open multireq.library !",10
  204. NoFileReq:    dc.b    "Unable to create FileReq-structure !",10
  205.  
  206. OutWin:        dc.b    "CON:0/14/400/100/SimpleDemo output window",0
  207.  
  208. ; This routine is a example how to interpret the ReturnStatus of the
  209. ; FileRequester (notice the value ReturnStatus is identical to that returned
  210. ; by the FileRequester-function
  211.  
  212.  
  213. ; some texts
  214.  
  215. Error:    dc.b    "Unable to open FileRequester !",10
  216. Cancel:    dc.b    "You've clicked on the Cancel-gadget",10
  217. Close:    dc.b    "You've clicked on the Close-gadget",10
  218. File:    dc.b    "You've pressed <RETURN> in the File-gadget",10
  219. Double:    dc.b    "You've done a DoubleClick on a File",10
  220. Okay:    dc.b    "You've pressed on the Okay-gadget",10
  221.     dc.b    "  => the FileRequester is started again",10
  222. Sel:    dc.b    10,"The follwing file was selected:"
  223. CR:    dc.b    10,10
  224.  
  225.     EVEN
  226.  
  227.  
  228. _WriteAction:
  229.     move.l    _fr(pc),a0
  230.     move.w    fr_ReturnStatus(a0),d0
  231.  
  232.     cmp.w    #RET_ERROR,d0        ; start successfull ?
  233.     bne.s    cancel_case
  234.  
  235.     lea    Error(pc),a0            ;text
  236.     moveq    #31,d3                ;length
  237.     bra.s    wr_act
  238.  
  239. cancel_case:
  240.     cmp.w    #RET_CANCEL,d0        ; Cancel-gadget pressed
  241.     bne.s    close_case
  242.  
  243.     lea    Cancel(pc),a0            ;text
  244.     moveq    #36,d3                ;length
  245.     bra.s    wr_act
  246.  
  247. close_case:
  248.     cmp.w    #RET_CLOSE,d0        ; Close-gadget pressed
  249.     bne.s    file_case
  250.  
  251.     lea    Close(pc),a0            ;text
  252.     moveq    #35,d3                ;length
  253.     bra.s    wr_act
  254.  
  255. file_case:
  256.     cmp.w    #RET_FILE,d0        ; RETURN pressed
  257.     bne.s    double_case
  258.  
  259.     lea    File(pc),a0            ;text
  260.     moveq    #43,d3                ;length
  261.     bra.s    wr_act
  262.  
  263. double_case:
  264.     cmp.w    #RET_DOUBLE,d0        ; DoubleClick on File
  265.     bne.s    okay_case
  266.  
  267.     lea    Double(pc),a0            ;text
  268.     moveq    #36,d3                ;length
  269.     bra.s    wr_act
  270.  
  271. okay_case:
  272.     cmp.w    #RET_OKAY,d0        ; Okay-gadget pressed
  273.     bne.s    wa_ret            ; what status is this ?????
  274.  
  275.     lea    Okay(pc),a0            ;text
  276.     moveq    #74,d3                ;length
  277.  
  278. wr_act:                ; Write done action
  279.  
  280.     move.l    _DOSBase(pc),a6
  281.     move.l    _output(pc),d1            ;file handle
  282.     move.l    a0,d2                ;buffer
  283.     jsr    _LVOWrite(a6)            ;d3 already set
  284.  
  285.     lea    Sel(pc),a0
  286.     move.l    a0,d2                ;buffer
  287.     move.l    _output(pc),d1            ;file handle
  288.     moveq    #33,d3                ;length
  289.     jsr    _LVOWrite(a6)
  290.  
  291.     move.l    _MultiReqBase(pc),a6
  292.     move.l    _fr(pc),a0
  293.     move.l    fr_FileNameBuff(a0),a0
  294.     jsr    _LVOStrLen(a6)
  295.  
  296.     move.l    _DOSBase(pc),a6
  297.     move.l    d0,d3                ;length
  298.     move.l    _output(pc),d1            ;file handle
  299.     move.l    _fr(pc),a0
  300.     move.l    fr_FileNameBuff(a0),d2        ;buffer
  301.     jsr    _LVOWrite(a6)
  302.  
  303.     lea    CR(pc),a0
  304.     move.l    a0,d2                ;buffer
  305.     move.l    _output(pc),d1            ;file handle
  306.     moveq    #2,d3                ;length
  307.     jsr    _LVOWrite(a6)
  308. wa_ret:
  309.     rts
  310.  
  311.  
  312.  
  313. ; the following part contains some parameters for the FileRequester
  314. ; all this parameters are optional, cause FileRequester also works, when no
  315. ; parameters are set (InitFileReq has done this for you)
  316.  
  317.  
  318. ;    again some texts
  319.  
  320. Title:    dc.b    "The multitasking FileRequester by Andreas Krebs",0
  321. OkayT:    dc.b    "go on",0
  322.  
  323. Dir1:    dc.b    "SYS:",0
  324. Dir2:    dc.b    "DEVS:",0
  325. FileT:    dc.b    "SampleFile",0
  326. Show:    dc.b    "*.*|*-*",0        ; Show all files with a . or - in it
  327. Hide:    dc.b    "*+*",0            ; Hide all files with a + in it
  328.  
  329.     EVEN
  330.  
  331. _SetParameters:
  332.     move.l    _fr(pc),a3
  333.  
  334.     lea    Title(pc),a0
  335.     move.l    a0,fr_TitleString(a3)        ;Set title of FileRequester
  336.  
  337.     lea    OkayT(pc),a0
  338.     move.l    a0,fr_OkayString(a3)        ;Set text of Okay-gadget
  339.  
  340.     move.w    #20,fr_LeftEdge(a3)        ;Set LeftEdge of FileRequester
  341.     move.w    #10,fr_TopEdge(a3)        ;Set TopEdge of FileRequester
  342.  
  343.     move.b    #1,fr_ActiveList(a3)        ;Show filelist 2 first
  344.     move.b    #HIDE_INFO,fr_ShowInfo(a3)    ;Don't show .info-files
  345.  
  346.     move.l    _MultiReqBase(pc),a6
  347.     lea    FileT(pc),a0
  348.     move.l    fr_FileBuff(a3),a1
  349.     jsr    _LVOStrCpy(a6)            ;File to be displayed in File-Gadget
  350.  
  351.     lea    Show(pc),a0
  352.     move.l    fr_ShowBuff(a3),a1
  353.     jsr    _LVOStrCpy(a6)            ;Files to be shown
  354.  
  355.     lea    Hide(pc),a0
  356.     move.l    fr_HideBuff(a3),a1
  357.     jsr    _LVOStrCpy(a6)            ;Files to be hidden
  358.  
  359.     lea    Dir1(pc),a0
  360.     move.l    fr_FileList1+flt_DrawerBuff(a3),a1
  361.     jsr    _LVOStrCpy(a6)            ;Set name of first directory
  362.  
  363.     move.w    #NO_AUTOREAD,fr_FileList1+flt_AutoRead(a3)
  364.                 ; Do not automatically readin first directory
  365.  
  366.     lea    Dir2(pc),a0
  367.     move.l    fr_FileList2+flt_DrawerBuff(a3),a1
  368.     jsr    _LVOStrCpy(a6)            ;Set name of second directory
  369.  
  370.     move.w    #DO_AUTOREAD,fr_FileList2+flt_AutoRead(a3)
  371.                 ; Do automatically readin second directory
  372.  
  373.     rts
  374.  
  375.  
  376.     END
  377.