home *** CD-ROM | disk | FTP | other *** search
/ AMIGA PD 1 / AMIGA-PD-1.iso / Programme_zum_Heft / Programmieren / Kurztests / Barfly / Utilities / Req2patch.lha / req2patch.S < prev   
Text File  |  1992-03-31  |  7KB  |  326 lines

  1. OpenLibrary    =-552
  2. CloseLibrary   =-414
  3. SetFunction    =-420
  4. AllocMem       =-198
  5. FreeMem        =-210
  6. TextRequest    =-174
  7. EasyRequestArgs=-588
  8. Write          =-48
  9. Output         =-60
  10. FindName       =-276
  11. Forbid         =-132
  12. Permit         =-138
  13. Remove         =-252
  14. Addport        =-354
  15.  
  16.     incdir    "include/"
  17.     include    "exec/types.i"
  18.     include    "exec/execbase.i"
  19.     include    "exec/memory.i"
  20.     include    "intuition/intuition.i"
  21.  
  22.  
  23. ;         This structure is use with the TextRequester function.
  24.  
  25.  
  26.  
  27.  STRUCTURE TRStructure,0
  28.     APTR    TR_Text            ;This is the message text, including printf() style formatting if desired.
  29.     APTR    TR_Controls        ;This is the address of the parameter list, if printf() style formatting is used.
  30.     APTR    TR_Window        ;This is an optional (zero if not used) pointer to a window on the screen you 
  31.                     ;would like the requester to show up on.
  32.     APTR    TR_MiddleText        ;If non-zero, this is the text for the gadget in the lower middle (returns 2).
  33.     APTR    TR_PositiveText        ;If non-zero, this is the text for the gadget in the lower left hand corner (returns 1).
  34.     APTR    TR_NegativeText        ;If non-zero, this is the text for the gadget in the lower right (returns 0).
  35.     APTR    TR_Title        ;This is the title for the window.
  36.     WORD    TR_KeyMask        ;This is the qualifier mask for the keyboard shortcuts.
  37.                     ;Use $FFFF to allow any qualifiers (or none).
  38.                     ;Zero means that no keyboard shortcuts are allowed.
  39.     WORD    TR_textcolor        ;Color of the text.  Uses Color 1 if no Color specified.
  40.     WORD    TR_detailcolor        ;Detail and block color, as in a NewWindow structure.  If
  41.     WORD    TR_blockcolor        ;both are left zero, block pen will be set to 1.
  42.     WORD    TR_versionnumber    ;Make SURE this is set to the current version of REQVERSION.
  43.     UWORD    TR_Timeout        ;The timeout value, in seconds.
  44.     LONG    TR_AbortMask        ;
  45.     UWORD    TR_rfu1
  46.     LABEL    TR_SIZEOF
  47.  
  48.  
  49.  
  50.  STRUCTURE    ReqLib,LIB_SIZE
  51.     APTR    rl_SysLib
  52.     APTR    rl_DosLib        ;These must be kept in the same order,
  53.     APTR    rl_IntuiLib        ;the library expunge code depends on it.
  54.     APTR    rl_GfxLib        ;
  55.     APTR    rl_SegList
  56.     APTR    rl_Images        ;pointer to the arrow images.
  57.     BYTE    rl_Flags
  58.     BYTE    rl_Pad
  59.     APTR    rl_ConsoleDev        ;for RawKeyToAscii
  60.     APTR    rl_ConsoleHandle    ;so we can close the device later
  61.     APTR    rl_RexxSysBase        ;pointer to rexxsyslib.library
  62.     LABEL    MyLib_Sizeof
  63.  
  64.  
  65. STRCOPY: MACRO
  66. STRCOPY_loop\@:
  67.     move.b    (a0)+,(a3)+
  68.     bne.s    STRCOPY_loop\@
  69.     subq.w    #1,a3
  70.     ENDM
  71.  
  72.  
  73.     STRUCTURE    MyMsgPort,MP_SIZE
  74.     APTR    mp_MEMORY
  75.     APTR    mp_OLDFUNCTION
  76.     APTR    mp_REQBASE
  77.     LABEL    mp_SIZE
  78.  
  79.  
  80.  
  81.  
  82. start:
  83.     move.l    4.w,a6
  84.     lea.l    dosname(pc),a1
  85.     moveq    #0,d0
  86.     jsr    OpenLibrary(a6)
  87.     lea.l    dosbase(pc),a0
  88.     move.l    d0,(a0)
  89.     beq.w    ende
  90.     move.l    d0,a6
  91.     jsr    Output(a6)
  92.     move.l    d0,d7
  93.     move.l    4.w,a6
  94.     cmp.w    #36,20(a6)
  95.     blo.w    nokick2
  96.     lea.l    PortList(a6),a0
  97.     lea.l    nt_reqpatchname(pc),a1
  98.     jsr    FindName(a6)
  99.     tst.l    d0
  100.     bne.w    remove
  101.     lea.l    nt_reqpatchport(pc),a2
  102.     move.l    #nt_END-nt_START,d0
  103.     move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  104.     jsr    AllocMem(a6)
  105.     move.l    d0,mp_MEMORY(a2)
  106.     beq.s    ende
  107.     move.l    d0,a1
  108.     lea.l    nt_START(pc),a0
  109.     move.w    #nt_END-nt_START-1,d0
  110. copy_loop:
  111.     move.b    (a0)+,(a1)+
  112.     dbra    d0,copy_loop
  113.     lea.l    reqname(pc),a1
  114.     moveq    #0,d0
  115.     jsr    OpenLibrary(a6)
  116.     move.l    d0,mp_REQBASE(a2)
  117.     beq.s    error
  118.     move.l    d0,a1
  119.     jsr    Forbid(a6)
  120.     move.l    mp_MEMORY(a2),d0
  121.     move.w    #TextRequest,a0
  122.     jsr    SetFunction(a6)
  123.     move.l    d0,mp_OLDFUNCTION(a2)
  124.     move.b    #NT_MSGPORT,LN_TYPE(a2)
  125.     move.l    mp_MEMORY(a2),a0
  126.     move.l    a0,a1
  127.     add.w    #nt_reqpatchport-nt_START,a1
  128.     add.w    #nt_reqpatchname-nt_START,a0
  129.     move.l    a0,LN_NAME(a1)
  130.     jsr    Addport(a6)
  131.     jsr    Permit(a6)
  132.     move.l    dosbase(pc),a6
  133.     move.l    d7,d1
  134.     lea.l    message(pc),a0
  135.     move.l    a0,d2
  136.     move.l    #message_end-message,d3
  137.     jsr    Write(a6)
  138.     move.l    a6,a1
  139.     move.l    4.w,a6
  140.     jsr    CloseLibrary(a6)
  141. ende:
  142.     moveq    #0,d0
  143.     rts
  144.  
  145. error:
  146.     move.l    mp_MEMORY(a2),a1
  147.     move.l    #nt_END-nt_START,d0
  148.     jsr    FreeMem(a6)
  149.     move.l    dosbase(pc),a6
  150.     move.l    d7,d1
  151.     lea.l    message_2(pc),a0
  152.     move.l    a0,d2
  153.     move.l    #message_2_end-message_2,d3
  154.     jsr    Write(a6)
  155.     move.l    a6,a1
  156.     move.l    4.w,a6
  157.     jsr    CloseLibrary(a6)
  158.     moveq    #0,d0
  159.     rts
  160.  
  161. nokick2:
  162.     move.l    dosbase(pc),a6
  163.     move.l    d7,d1
  164.     lea.l    message_1(pc),a0
  165.     move.l    a0,d2
  166.     move.l    #message_1_end-message_1,d3
  167.     jsr    Write(a6)
  168.     move.l    a6,a1
  169.     move.l    4.w,a6
  170.     jsr    CloseLibrary(a6)
  171.     moveq    #0,d0
  172.     rts
  173.  
  174.  
  175. remove:
  176.     jsr    SetFunction(a6)
  177.     move.l    dosbase(pc),a6
  178.     move.l    d7,d1
  179.     lea.l    message_0(pc),a0
  180.     move.l    a0,d2
  181.     move.l    #message_0_end-message_0,d3
  182.     jsr    Write(a6)
  183.     move.l    a6,a1
  184.     move.l    4.w,a6
  185.     jsr    CloseLibrary(a6)
  186.     moveq    #0,d0
  187.     rts
  188.  
  189. dosbase:
  190.     dc.l    0
  191. dosname:
  192.     dc.b    "dos.library",0
  193. reqname:
  194.     dc.b    "req.library",0
  195.  
  196. message:
  197.     dc.b    $9b,"0;33;40mREQ2PATCH V1.01",$9b,"0;31;40m"
  198.     dc.b    " by Ralph Schmidt",$a
  199.     dc.b    "EMail: laire@uni-paderborn.de",$a
  200. message_end:
  201.  
  202. message_0:
  203.     dc.b    $9b,"0;33;40mREQ2PATCH V1.0",$9b,"0;31;40m is already installed...",$a
  204. message_0_end:
  205. message_1:
  206.     dc.b    "This program needs Kick V36 or higher",$a
  207. message_1_end:
  208. message_2:
  209.     dc.b    "Can't open req.library",$a
  210. message_2_end:
  211.     cnop    0,2
  212.  
  213. ******************************* newtextrequest*****************************
  214.  
  215. nt_START:
  216. ;a0=TextRequest
  217.     move.l    TR_AbortMask(a0),d0
  218.     or.l    TR_Timeout(a0),d0
  219.     beq.s    nt_start_0
  220.  
  221.     move.l    nt_reqpatchport+mp_OLDFUNCTION(pc),a1
  222.     jmp    (a1)
  223.  
  224. nt_start_0:
  225.     movem.l    d2-d7/a2-a6,-(a7)
  226.     move.l    a0,a5
  227.     moveq    #0,d2
  228.     move.l    TR_MiddleText(a5),a0
  229.     bsr.w    nt_strlength
  230.     add.l    d0,d2
  231.     move.l    TR_PositiveText(a5),a0
  232.     bsr.w    nt_strlength
  233.     add.l    d0,d2
  234.     move.l    TR_NegativeText(a5),a0
  235.     bsr.w    nt_strlength
  236.     add.l    d0,d2
  237.     moveq    #es_SIZEOF+2+1,d1        ;2*"|"+END-Mark
  238.     add.l    d1,d2
  239.     move.l    d2,-(a7)
  240.     move.l    d2,d0
  241.     move.l    #MEMF_CLEAR|MEMF_PUBLIC,d1
  242.     move.l    4.w,a6
  243.     jsr    AllocMem(a6)
  244.     tst.l    d0
  245.     beq.w    nt_memerror
  246.     move.l    d0,a4
  247.     lea.l    es_SIZEOF(a4),a3
  248.     move.l    a3,es_GadgetFormat(a4)
  249.     move.l    TR_PositiveText(a5),a0
  250.     move.l    a0,d0
  251.     beq.s    nt_0
  252.     STRCOPY
  253.     move.b    #"|",(a3)+
  254. nt_0:
  255.     move.l    TR_MiddleText(a5),a0
  256.     move.l    a0,d0
  257.     beq.s    nt_1
  258.     STRCOPY
  259.     move.b    #"|",(a3)+
  260. nt_1:
  261.     move.l    TR_NegativeText(a5),a0
  262.     move.l    a0,d0
  263.     beq.s    nt_2
  264.     STRCOPY
  265.     move.b    #"|",(a3)+
  266. nt_2:
  267.     clr.b    -(a3)
  268.     moveq    #es_SIZEOF,d0
  269.     move.l    d0,es_StructSize(a4)
  270.     clr.l    es_Flags(a4)
  271.     move.l    TR_Text(a5),es_TextFormat(a4)
  272.     move.l    TR_Title(a5),es_Title(a4)
  273.     move.l    TR_Window(a5),a0
  274.     move.l    a4,a1
  275.     move.l    TR_Controls(a5),a3
  276.  
  277.     move.l    TR_KeyMask(a5),a2        ;?
  278.     sub.l    a2,a2                ;no idcmp
  279.     move.l    4+6*4+4*4(a7),a6        ;a6=Reqbase
  280.     move.l    rl_IntuiLib(a6),a6
  281.     jsr    EasyRequestArgs(a6)
  282.     exg    d0,d1
  283.     move.l    (a7),d0                ;Length
  284.     move.l    d1,(a7)                ;Ret abspeichern
  285.     move.l    a4,a1
  286.     move.l    4.w,a6
  287.     jsr    FreeMem(a6)
  288.     move.l    (a7)+,d0            ;Ret
  289.     movem.l    (a7)+,d2-d7/a2-a6
  290.     rts
  291.  
  292. nt_memerror:
  293.     addq.w    #4,a7
  294.     movem.l    (a7)+,d2-d7/a2-a6
  295.     rts
  296.  
  297.  
  298.  
  299. nt_strlength:
  300. ;a0=String
  301. ;=>d0=Length
  302.     move.l    a0,a1
  303.     move.l    a0,d0
  304.     beq.s    nt_strlength_end
  305. nt_strlength_loop:
  306.     tst.b    (a1)+
  307.     bne.s    nt_strlength_loop
  308.     subq.w    #1,a1
  309.     sub.l    a0,a1
  310. nt_strlength_end:
  311.     move.l    a1,d0
  312.     rts
  313.  
  314.  
  315. nt_reqpatchport:
  316.     ds.b    mp_SIZE
  317.  
  318.  
  319. nt_reqpatchname:
  320.     dc.b    "REQ2PATCH Port",0
  321.  
  322. nt_END:
  323.  
  324.  
  325.  
  326.