home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 511.lha / kd_freq.library_v3.00 / Programming / test.asm < prev    next >
Assembly Source File  |  1991-06-07  |  2KB  |  102 lines

  1. ; FRTest.asm
  2. ;
  3. ; A demo of how to call up my file requester from asm.
  4. ;
  5. ; By:  Khalid Aldoseri.
  6. ;
  7. ;
  8.     include    'libraries/dosextens.i'
  9.     include 'kdbase.i'
  10.  
  11.     XDEF    _LVOFindTask
  12.     XDEF    _LVOOpenLibrary
  13.     XDEF    _LVOCloseLibrary
  14.     XDEF    _LVOGetMsg
  15.     XDEF    _LVOWaitPort
  16.     XDEF    _LVOReplyMsg
  17.  
  18.     SECTION main,CODE
  19.  
  20.     move.l    4,a6            ;get Execbase
  21.     move.l    a6,_ExecBase        ;store execbase
  22.     sub.l    a1,a1            ;clear a1
  23.     jsr    _LVOFindTask(a6)    ;find address of process
  24.     move.l    d0,a0            ;store process address
  25.     move.l    a0,_OurTask         ;in _OurTask
  26.  
  27.     tst.l    pr_CLI(a0)        ;were we run from CLI?
  28.     bne    .Start            ;yes, jump to start
  29.  
  30.     move.l    pr_MsgPort(a0),a0    ;no, get address of pr_MsgPort
  31.     jsr    _LVOWaitPort(a6)    ;WaitPort for the WBmsg
  32.     move.l    _OurTask,a1        ;load address of task
  33.     lea    pr_MsgPort(a1),a0    ;get address of pr_MsgPort
  34.     jsr    _LVOGetMsg(a6)        ;GetMsg the WBmsg
  35.     move.l    d0,_WBMessage        ;store WBmsg
  36.  
  37. .Start    move.l    #KDLIBVERSION,d0    ;request lib version 3 or above
  38.     lea    .kdname,a1        ;load name of kdlib
  39.     jsr    _LVOOpenLibrary(a6)    ;openlibrary kdlib
  40.     tst.l    d0            ;check if lib opened
  41.     beq    .Quit1            ;no, quit
  42.     move.l    d0,_KDBase         ;store KDBase
  43.  
  44. .Main    
  45.     move.l    _KDBase,a6        ;move KDBase into a6
  46.     jsr    _LVOCreateFRequest(a6)    ;initialize a FRequest struct
  47.     tst.l    d0            ;check for success
  48.     beq    .Quit            ;no, quit
  49.     move.l    d0,_freq        ;store FRequest address in _freq
  50.  
  51.     move.l    d0,a0            ;move _freq into a0
  52.     lea    .title,a1        ;move .title into a1
  53.     move.l    a1,kd_fr_reqtitle(a0)    ;store it in kd_fr_reqtitle
  54.  
  55.                     ;set FR flags.. FR_STDFLAGS already
  56.                     ;set by the CreateFRequest call.
  57.  
  58.     move.l    #FR_STDFLAGS,kd_fr_flags(a0)
  59.  
  60.     jsr    _LVONewFReq(a6)        ;call up requester
  61.  
  62.     ;d0 will contain either 0 for cancelled/failed or the address
  63.     ;of kd_fr_fullname if successful.
  64.  
  65.     tst.l    d0
  66.     beq    .freefr
  67.  
  68.     ; do your own stuff here with the filename
  69.  
  70. .freefr
  71.     move.l    _freq,a0        ;move _freq into a0
  72.     jsr    _LVODeleteFRequest(a6)    ;free FRequest struct
  73.  
  74. .Quit
  75.     move.l    _KDBase,a1        ;load KDBase into a1
  76.     move.l    _ExecBase,a6        ;get execbase
  77.     jsr    _LVOCloseLibrary(a6)    ;close library
  78.  
  79. .Quit1    move.l    _OurTask,a0        ;get process pointer
  80.     tst.l    pr_CLI(a0)        ;were we run from WB?
  81.     bne    .Quit2            ;no, quit.
  82.     move.l    _WBMessage,a1        ;yes, load WBmsg into a1
  83.     jsr    _LVOReplyMsg(a6)    ;and reply to it.
  84.  
  85. .Quit2    clr.l    d0
  86.     rts                ;that's all folks!
  87.  
  88.  
  89.     SECTION    info,DATA
  90.  
  91. _ExecBase    dc.l    0
  92. _WBMessage    dc.l    0
  93. _OurTask    dc.l    0
  94. _KDBase        dc.l    0
  95. _freq        dc.l    0
  96.  
  97. .title        dc.b    'File Requester Test',0
  98.  
  99. .kdname        dc.b    'kd_freq.library',0
  100.  
  101.     end
  102.