home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 569a.lha / EdPlayer_v1.1 / TellEd.ASM < prev   
Assembly Source File  |  1991-10-26  |  4KB  |  122 lines

  1. ;
  2. ;     TellEd              by Ed Mackey
  3. ;        (Communicate        PO Box 475
  4. ;         with EdPlayer)     Wayne, PA 19087
  5.  
  6. ;  Here is the source code, assembled with Assempro by Abacus, the same
  7. ;  assembler used to create Ball, MegaBall, and EdPlayer itself.
  8.  
  9. ;  This program should be distributed with EdPlayer.  See EdPlayer.DOC
  10. ;  for usage info.
  11.  
  12. ;  After assembling, type "PROTECT TellEd +P" at a CLI so that the PURE
  13. ;  flag is set.  This program is PURE so that you can make it resident
  14. ;  with "resident" or "Ares" if you have it.
  15.  
  16.        Include 'includes:IncludeMe'
  17.        Include 'includes:exec/types.i'
  18.        Include 'includes:exec/lists.i'
  19.        Include 'includes:exec/memory.i'
  20.  
  21.        ILABEL  'includes:Amiga.L'
  22.  
  23.        move.l  #21,d7    ;Error retcode in case of early exit
  24.        move.l  d0,d5          ;Length of CLI arguments
  25.        beq     MemKicked      ;If no arguments, just exit.
  26.        move.l  EBase,a6
  27.        move.l  #384,d0
  28.        move.l  #MEMF_CLEAR,d1
  29.        move.l  a0,a3       ;Save the args in a3
  30.        jsr     _LVOAllocMem(a6)  ;Dynamic allocation for PURE program!
  31.        move.l  d0,a4   ;0(a4) = MsgPort, 40(a4) = Message,
  32.        tst.l   d0      ;84(a4) = CopyArgs buffer
  33.        beq     MemKicked
  34.        move.b  #4,8(a4)   ;Type = MsgPort
  35.        move.b  #1,9(a4)   ;Pri = 1
  36.        move.b  #5,48(a4)  ;Type = message
  37.        move.l  a3,a0       ;Bring the CLI args back to a0
  38.        move.l  d5,d0
  39.        subq    #1,d0       ;Arg length minus 1
  40.        lea     84(a4),a2      ;I copy the args to a buffer here,
  41. MoreCp:move.b  (a0)+,(a2)+    ;but I probably don't need to.
  42.        dbra    d0,MoreCp
  43.        move.l  d5,d0
  44.        subq.l  #1,d0
  45.        lea     84(a4),a0      ;Trim off funny chars from the args
  46. KillJ: move.l  a0,a1
  47.        tst.b   (a1)+
  48.        beq     RmSpc
  49.        cmp.b   #$a,(a0)+
  50.        bne     NoJ
  51.        move.l  a0,a1
  52. RmSpc: clr.b   -(a1)          ;Remove trailing spaces
  53.        cmp.b   #' ',-1(a1)
  54.        beq     RmSpc
  55. NoJ:   dbra    d0,KillJ
  56.        lea     20(a4),a0      ;Now:  Prepare the replyport!
  57.        NEWLIST a0
  58.        sub.l   a1,a1
  59.        move.l  EBase,a6
  60.        jsr     _LVOFindTask(a6)  ;My task # in replyport
  61.        move.l  a4,a2
  62.        move.l  d0,16(a2)
  63.        lea     40(a4),a3   ;PORT is in A2, MESSAGE is in A3
  64.        move.l  a2,14(a3)
  65.        move.w  #44,18(a3)  ;LENGTH IS .W!
  66.        lea     84(a4),a5
  67.        clr.b   (a5,d5.l)   ;End args with a null  (0x00)
  68.        move.l  a5,40(a3)   ;Put arg pointer in message
  69.        move.l  #-1,d0
  70.        jsr     _LVOAllocSignal(a6)  ;Get a signal for replyport
  71.        cmp.b   #-1,d0
  72.        beq     SigKicked
  73.        move.b  d0,15(a2)
  74.        moveq.l #1,d1
  75.        and.l   #$ff,d0
  76.        lsl.l   d0,d1
  77.        move.l  d1,d6       ;Save signal in expanded (mask) form
  78.        jsr     _LVOForbid(a6)  ;Forbid before using FindPort()
  79.        lea     FindMe,a1
  80.        jsr     _LVOFindPort(a6)  ;Find EdPlayer!
  81.        tst.l   d0
  82.        beq     NoPrt
  83.        move.l  d0,a0
  84.        lea     40(a4),a1
  85.        jsr     _LVOPutMsg(a6)   ;Send message to EdPlayer!
  86.        jsr     _LVOPermit(a6)   ;Don't forget to Permit() AFTER msg sent.
  87. TryAgn:move.l  a4,a0
  88.        jsr     _LVOGetMsg(a6)   ;Look for returned message
  89.        tst.l   d0
  90.        bne     GotIt
  91.        move.l  d6,d0
  92.        jsr     _LVOWait(a6)     ;Or Wait() for returned message
  93.        bra     TryAgn           ;and try again!
  94. GotIt: move.l  d0,a5
  95.        move.l  32(a5),d7        ;Load return code.
  96. ende:
  97.        move.l  EBase,a6
  98.        moveq.l #0,d0
  99.        move.b  15(a4),d0
  100.        jsr     _LVOFreeSignal(a6)   ;Deallocate stuff.
  101. SigKicked:
  102.        move.l  EBase,a6
  103.        move.l  #384,d0
  104.        move.l  a4,a1
  105.        jsr     _LVOFreeMem(a6)
  106. MemKicked:
  107.        move.l  d7,d0
  108.        rts                          ;that's all folks!
  109.  
  110. NoPrt: jsr     _LVOPermit(a6)
  111.        move.l  #21,d7           ;Failure:  EdPlayer not found.
  112.        bra     ende
  113.  
  114.        ;data section!
  115. FindMe:
  116.        dc.b    'EDPLAYER',0   ;Find this port
  117.  
  118.        dc.b    'Telled v1.0 by Ed Mackey',0  ;Just identification
  119.        align
  120.  
  121.        END
  122.