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
Wrap
Text File
|
1992-03-31
|
7KB
|
326 lines
OpenLibrary =-552
CloseLibrary =-414
SetFunction =-420
AllocMem =-198
FreeMem =-210
TextRequest =-174
EasyRequestArgs=-588
Write =-48
Output =-60
FindName =-276
Forbid =-132
Permit =-138
Remove =-252
Addport =-354
incdir "include/"
include "exec/types.i"
include "exec/execbase.i"
include "exec/memory.i"
include "intuition/intuition.i"
; This structure is use with the TextRequester function.
STRUCTURE TRStructure,0
APTR TR_Text ;This is the message text, including printf() style formatting if desired.
APTR TR_Controls ;This is the address of the parameter list, if printf() style formatting is used.
APTR TR_Window ;This is an optional (zero if not used) pointer to a window on the screen you
;would like the requester to show up on.
APTR TR_MiddleText ;If non-zero, this is the text for the gadget in the lower middle (returns 2).
APTR TR_PositiveText ;If non-zero, this is the text for the gadget in the lower left hand corner (returns 1).
APTR TR_NegativeText ;If non-zero, this is the text for the gadget in the lower right (returns 0).
APTR TR_Title ;This is the title for the window.
WORD TR_KeyMask ;This is the qualifier mask for the keyboard shortcuts.
;Use $FFFF to allow any qualifiers (or none).
;Zero means that no keyboard shortcuts are allowed.
WORD TR_textcolor ;Color of the text. Uses Color 1 if no Color specified.
WORD TR_detailcolor ;Detail and block color, as in a NewWindow structure. If
WORD TR_blockcolor ;both are left zero, block pen will be set to 1.
WORD TR_versionnumber ;Make SURE this is set to the current version of REQVERSION.
UWORD TR_Timeout ;The timeout value, in seconds.
LONG TR_AbortMask ;
UWORD TR_rfu1
LABEL TR_SIZEOF
STRUCTURE ReqLib,LIB_SIZE
APTR rl_SysLib
APTR rl_DosLib ;These must be kept in the same order,
APTR rl_IntuiLib ;the library expunge code depends on it.
APTR rl_GfxLib ;
APTR rl_SegList
APTR rl_Images ;pointer to the arrow images.
BYTE rl_Flags
BYTE rl_Pad
APTR rl_ConsoleDev ;for RawKeyToAscii
APTR rl_ConsoleHandle ;so we can close the device later
APTR rl_RexxSysBase ;pointer to rexxsyslib.library
LABEL MyLib_Sizeof
STRCOPY: MACRO
STRCOPY_loop\@:
move.b (a0)+,(a3)+
bne.s STRCOPY_loop\@
subq.w #1,a3
ENDM
STRUCTURE MyMsgPort,MP_SIZE
APTR mp_MEMORY
APTR mp_OLDFUNCTION
APTR mp_REQBASE
LABEL mp_SIZE
start:
move.l 4.w,a6
lea.l dosname(pc),a1
moveq #0,d0
jsr OpenLibrary(a6)
lea.l dosbase(pc),a0
move.l d0,(a0)
beq.w ende
move.l d0,a6
jsr Output(a6)
move.l d0,d7
move.l 4.w,a6
cmp.w #36,20(a6)
blo.w nokick2
lea.l PortList(a6),a0
lea.l nt_reqpatchname(pc),a1
jsr FindName(a6)
tst.l d0
bne.w remove
lea.l nt_reqpatchport(pc),a2
move.l #nt_END-nt_START,d0
move.l #MEMF_CLEAR|MEMF_PUBLIC,d1
jsr AllocMem(a6)
move.l d0,mp_MEMORY(a2)
beq.s ende
move.l d0,a1
lea.l nt_START(pc),a0
move.w #nt_END-nt_START-1,d0
copy_loop:
move.b (a0)+,(a1)+
dbra d0,copy_loop
lea.l reqname(pc),a1
moveq #0,d0
jsr OpenLibrary(a6)
move.l d0,mp_REQBASE(a2)
beq.s error
move.l d0,a1
jsr Forbid(a6)
move.l mp_MEMORY(a2),d0
move.w #TextRequest,a0
jsr SetFunction(a6)
move.l d0,mp_OLDFUNCTION(a2)
move.b #NT_MSGPORT,LN_TYPE(a2)
move.l mp_MEMORY(a2),a0
move.l a0,a1
add.w #nt_reqpatchport-nt_START,a1
add.w #nt_reqpatchname-nt_START,a0
move.l a0,LN_NAME(a1)
jsr Addport(a6)
jsr Permit(a6)
move.l dosbase(pc),a6
move.l d7,d1
lea.l message(pc),a0
move.l a0,d2
move.l #message_end-message,d3
jsr Write(a6)
move.l a6,a1
move.l 4.w,a6
jsr CloseLibrary(a6)
ende:
moveq #0,d0
rts
error:
move.l mp_MEMORY(a2),a1
move.l #nt_END-nt_START,d0
jsr FreeMem(a6)
move.l dosbase(pc),a6
move.l d7,d1
lea.l message_2(pc),a0
move.l a0,d2
move.l #message_2_end-message_2,d3
jsr Write(a6)
move.l a6,a1
move.l 4.w,a6
jsr CloseLibrary(a6)
moveq #0,d0
rts
nokick2:
move.l dosbase(pc),a6
move.l d7,d1
lea.l message_1(pc),a0
move.l a0,d2
move.l #message_1_end-message_1,d3
jsr Write(a6)
move.l a6,a1
move.l 4.w,a6
jsr CloseLibrary(a6)
moveq #0,d0
rts
remove:
jsr SetFunction(a6)
move.l dosbase(pc),a6
move.l d7,d1
lea.l message_0(pc),a0
move.l a0,d2
move.l #message_0_end-message_0,d3
jsr Write(a6)
move.l a6,a1
move.l 4.w,a6
jsr CloseLibrary(a6)
moveq #0,d0
rts
dosbase:
dc.l 0
dosname:
dc.b "dos.library",0
reqname:
dc.b "req.library",0
message:
dc.b $9b,"0;33;40mREQ2PATCH V1.01",$9b,"0;31;40m"
dc.b " by Ralph Schmidt",$a
dc.b "EMail: laire@uni-paderborn.de",$a
message_end:
message_0:
dc.b $9b,"0;33;40mREQ2PATCH V1.0",$9b,"0;31;40m is already installed...",$a
message_0_end:
message_1:
dc.b "This program needs Kick V36 or higher",$a
message_1_end:
message_2:
dc.b "Can't open req.library",$a
message_2_end:
cnop 0,2
******************************* newtextrequest*****************************
nt_START:
;a0=TextRequest
move.l TR_AbortMask(a0),d0
or.l TR_Timeout(a0),d0
beq.s nt_start_0
move.l nt_reqpatchport+mp_OLDFUNCTION(pc),a1
jmp (a1)
nt_start_0:
movem.l d2-d7/a2-a6,-(a7)
move.l a0,a5
moveq #0,d2
move.l TR_MiddleText(a5),a0
bsr.w nt_strlength
add.l d0,d2
move.l TR_PositiveText(a5),a0
bsr.w nt_strlength
add.l d0,d2
move.l TR_NegativeText(a5),a0
bsr.w nt_strlength
add.l d0,d2
moveq #es_SIZEOF+2+1,d1 ;2*"|"+END-Mark
add.l d1,d2
move.l d2,-(a7)
move.l d2,d0
move.l #MEMF_CLEAR|MEMF_PUBLIC,d1
move.l 4.w,a6
jsr AllocMem(a6)
tst.l d0
beq.w nt_memerror
move.l d0,a4
lea.l es_SIZEOF(a4),a3
move.l a3,es_GadgetFormat(a4)
move.l TR_PositiveText(a5),a0
move.l a0,d0
beq.s nt_0
STRCOPY
move.b #"|",(a3)+
nt_0:
move.l TR_MiddleText(a5),a0
move.l a0,d0
beq.s nt_1
STRCOPY
move.b #"|",(a3)+
nt_1:
move.l TR_NegativeText(a5),a0
move.l a0,d0
beq.s nt_2
STRCOPY
move.b #"|",(a3)+
nt_2:
clr.b -(a3)
moveq #es_SIZEOF,d0
move.l d0,es_StructSize(a4)
clr.l es_Flags(a4)
move.l TR_Text(a5),es_TextFormat(a4)
move.l TR_Title(a5),es_Title(a4)
move.l TR_Window(a5),a0
move.l a4,a1
move.l TR_Controls(a5),a3
move.l TR_KeyMask(a5),a2 ;?
sub.l a2,a2 ;no idcmp
move.l 4+6*4+4*4(a7),a6 ;a6=Reqbase
move.l rl_IntuiLib(a6),a6
jsr EasyRequestArgs(a6)
exg d0,d1
move.l (a7),d0 ;Length
move.l d1,(a7) ;Ret abspeichern
move.l a4,a1
move.l 4.w,a6
jsr FreeMem(a6)
move.l (a7)+,d0 ;Ret
movem.l (a7)+,d2-d7/a2-a6
rts
nt_memerror:
addq.w #4,a7
movem.l (a7)+,d2-d7/a2-a6
rts
nt_strlength:
;a0=String
;=>d0=Length
move.l a0,a1
move.l a0,d0
beq.s nt_strlength_end
nt_strlength_loop:
tst.b (a1)+
bne.s nt_strlength_loop
subq.w #1,a1
sub.l a0,a1
nt_strlength_end:
move.l a1,d0
rts
nt_reqpatchport:
ds.b mp_SIZE
nt_reqpatchname:
dc.b "REQ2PATCH Port",0
nt_END: