home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
disks
/
disk439.lzh
/
DeluxeChanger
/
Sources
/
DCRequest.asm
< prev
next >
Wrap
Assembly Source File
|
1991-01-18
|
14KB
|
779 lines
XDEF Request
XREF SysRequest,_DCScrBase
INCLUDE exec/exec_lib.i
INCLUDE intuition/intuition_lib.i
INCLUDE libraries/dos_lib.i
INCLUDE graphics/graphics_lib.i
INCLUDE help.i
SECTION "Request",CODE
Request move.l a0,-(sp) ; Zeiger auf IText merken
bsr OpenLibs ; Librarys öffnen
SADD ReqWindow,a0 ; Zeiger auf Window in a0
move.l _DCScrBase,$1e(a0) ; Screen-Zeiger eintragen
CALLPC _IntuitionBase,OpenWindow ; Window öffnen
beq NoReq ; Fehler ? -> NoReq
move.l d0,a1
lea _ReqWindBase(pc),a0
move.l a1,(a0)
move.l $32(a1),4(a0) ; RastPort merken
move.l $56(a1),8(a0) ; UserPort merken
PEEKL _ReqWindRast,a0
move.l (sp)+,a1
moveq.l #0,d0
moveq.l #10,d1
CALLSYS PrintIText
bsr MakeRBorder
cmpi.l #"READ",Read?
bne BeginRead
bsr RefreshNames
bra WaitReq
BeginRead
bra ReadIn
WaitReq PEEKL _ReqWindUser,a0
CALLEXEC WaitPort
PEEKL _ReqWindUser,a0
CALLSYS GetMsg
move.l d0,a1
move.l $14(a1),d4
move.l $1c(a1),a4
CALLSYS ReplyMsg
cmpi.b #$40,d4
beq.s GadUp
cmpi.b #$20,d4
beq.s GadDown
bra WaitReq
GadUp cmpi.w #"CL",$26(a4)
beq ReqQuit
cmpi.w #"OK",$26(a4)
beq ReqOK
cmpi.w #"DC",$26(a4)
beq.s BeginRead
cmpi.w #"PT",$26(a4)
bne.s NoParent
bsr Parent
bra BeginRead
NoParent
cmpi.w #"F0",$26(a4)
blt.s WaitReq
cmpi.w #"F5",$26(a4)
bgt.s WaitReq
bsr FileOrDir
cmpi.l #"FILE",d7
bne BeginRead
bra WaitReq
GadDown cmpi.w #"PR",$26(a4)
bne WaitReq
PropAg bsr PropClick
cmpi.w #$80,RProp+$c
beq PropAg
bra WaitReq
ReqQuit bsr EndRequest
NoReq moveq.l #0,d0
rts
ReqOK bsr EndRequest
bsr JoinName
move.l #DirFileBuffer,d0
rts
*** Fenster schließen
EndRequest
PEEKL _ReqWindBase,a0
CALLPC _IntuitionBase,CloseWindow
rts
*** Verwaltung der Devices
GetDevs CALLEXEC Forbid ; Multitasking aus
PEEKL _DOSBase,a0
move.l 34(a0),a0
move.l 24(a0),a0
adda.l a0,a0
adda.l a0,a0
move.l 4(a0),a0
adda.l a0,a0
adda.l a0,a0
Dev1 lea Entrys,a2
PEEKL EntryCount,d0
mulu #36,d0
adda.l d0,a2
tst.l 4(a0)
bne.s TakeDev
tst.l 8(a0)
beq.s NoFound
TakeDev move.l 4(a0),d0
addq.l #2,d0
move.b d0,31(a2)
move.l $28(a0),a1
adda.l a1,a1
adda.l a1,a1
move.b (a1)+,d0
subq.l #1,d0
CopyDev move.b (a1)+,(a2)+
dbra d0,CopyDev
move.b #":",(a2)+
move.b #0,(a2)
add.l #1,EntryCount
NoFound tst.l (a0) ; Letzte Device ?
beq EndDev
move.l (a0),a0 ; Wenn nicht dann
adda.l a0,a0 ; nächsten Eintrag
adda.l a0,a0 ; holen und weitersuchen
bra Dev1
EndDev CALLSYS Permit ; Multi an
rts
*** Files einlesen
ReadIn bsr ResetAll
move.l #DirBuffer,d1
moveq.l #-2,d2
CALLPC _DOSBase,Lock
beq NoLock
move.l d0,-(sp)
move.l (sp),d1
move.l #FileInfo,d2
CALLSYS Examine
GetName move.l (sp),d1
move.l #FileInfo,d2
CALLPC _DOSBase,ExNext
beq NoMore
lea FileInfo+8,a0
PEEKL EntryCount,d0
mulu #36,d0
addi.l #Entrys,d0
move.l d0,a1
move.b #0,31(a1)
tst.l 4-8(a0)
bpl CopyName
move.l $7c-8(a0),32(a1) ;File-Länge merken
move.b #1,31(a1)
CopyName
move.b (a0)+,(a1)+
cmpi.b #0,-1(a1)
bne.s CopyName
addi.l #1,EntryCount
bsr SortNames
bsr RefreshNames
bsr RemakeProp
bsr PropClick
PEEKL _ReqWindUser,a0
CALLEXEC GetMsg
tst.l d0
beq NoMsg
move.l d0,a1
move.l $14(a1),d4
move.l $1c(a1),a4
CALLSYS ReplyMsg
cmpi.w #"PT",$26(a4)
bne NoRPar
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
bsr Parent
bra ReadIn
NoRPar cmpi.w #"OK",$26(a4)
bne NoROK
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
bra ReqOK
NoROK cmpi.w #"CL",$26(a4)
bne NoRCL
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
bra ReqQuit
NoRCL cmpi.w #"DC",$26(a4)
bne NoRDC
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
bra ReadIn
NoRDC cmpi.w #"F0",$26(a4)
blt NoMsg
cmpi.w #"F5",$26(a4)
bgt NoMsg
bsr FileOrDir
cmpi.l #"FILE",d7
beq.s NoMsg
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
bra ReadIn
NoMsg cmpi.l #100,EntryCount
blt GetName
SADD TableFull,a0
jsr SysRequest
NoMore POKEL #"READ",Read?
move.l (sp)+,d1
CALLPC _DOSBase,UnLock
NoLock bra WaitReq
EntryCount ds.l 1
Read? dc.l 0
*** Namen sortieren
SortNames
PEEKL EntryCount,d7
cmpi.b #2,d7
blt NoSort
subq.l #2,d7
Sort1 moveq.l #0,d6
Sort2 bsr Compare
cmp.l d7,d6
beq.s Sort3
addq.l #1,d6
bra Sort2
Sort3 dbra d7,Sort1
NoSort rts
*** Namen vergleichen und austauschen
Compare move.l d6,d2
mulu #36,d2
addi.l #Entrys,d2
move.l d2,a0
move.l d2,a1
adda.l #36,a1
move.b 31(a0),d0
move.b 31(a1),d1
cmp.b d0,d1
blt Swap
bgt NoSwap
Com1 move.b (a0)+,d0
move.b (a1)+,d1
bclr #5,d0
bclr #5,d1
cmp.b d0,d1
blt Swap
bgt NoSwap
cmpi.b #0,-1(a0)
beq NoSwap
bra Com1
Swap move.l d2,a0
move.l d2,a1
adda.l #36,a1
moveq.l #36-1,d1
Swap1 move.b (a0),d0
move.b (a1),(a0)+
move.b d0,(a1)+
dbra d1,Swap1
NoSwap rts
*** Parent-Gadget angeklickt ...
Parent lea DirBuffer,a0
ParFind0
cmpi.b #0,(a0)+
bne.s ParFind0
cmpi.b #58,-2(a0)
bne.s ParFindEnd
lea DirBuffer,a0
bra ParMake0
ParFindEnd
suba.l #1,a0
cmpa.l #DirBuffer,a0
beq ParMake0
cmpi.b #47,(a0)
beq.s ParMake0
cmpi.b #58,-1(a0)
beq.s ParMake0
bra ParFindEnd
ParMake0
move.b #0,(a0)
bra RefreshStrings
*** Name angeklickt ...
FileOrDir
moveq.l #0,d7
move.w $26(a4),d0
subi.w #"F0",d0
mulu #4,d0
SADD ITextList,a0
move.l 0(a0,d0.w),a0
move.l $c(a0),a0
cmpi.b #0,(a0)
beq NoEntry
cmpi.b #0,31(a0)
beq DirClick
cmpi.b #1,31(a0)
bgt DevCl
lea FileBuffer,a1
FileToBuffer
move.b (a0)+,(a1)+
cmpi.b #0,-1(a1)
bne.s FileToBuffer
NoEntry move.l #"FILE",d7
bra RefreshStrings
DirClick
lea DirBuffer,a1
DirClFind0
cmpi.b #0,(a1)+
bne.s DirClFind0
suba.l #1,a1
cmpa.l #DirBuffer,a1
beq.s DirToBuffer
cmpi.b #58,-1(a1)
beq.s DirToBuffer
move.b #47,(a1)+
DirToBuffer
move.b (a0)+,(a1)+
cmpi.b #0,-1(a1)
bne.s DirToBuffer
bra RefreshStrings
DevCl lea DirBuffer,a1
DevToBuffer
move.b (a0)+,(a1)+
cmpi.b #0,-1(a1)
bne.s DevToBuffer
bra RefreshStrings
*** Alles zurücksetzen
ResetAll
SADD RPropSpecial,a1
move.w #0,4(a1)
POKEL #0,EntryCount
POKEL #0,Read?
lea Entrys,a0
move.w #36*100-1,d0
ClearEntrys
move.b #0,(a0)+
dbra d0,ClearEntrys
bsr ResetPointers
bsr GetDevs
bsr SortNames
bsr RefreshNames
bsr RemakeProp
rts
*** Pointers zurücksetzen
ResetPointers
SADD ITextList,a0
move.l #Entrys,d0
moveq.l #6-1,d1
ResetP1 move.l (a0)+,a1
move.l d0,$c(a1)
addi.l #36,d0
dbra d1,ResetP1
rts
*** Proportional-Gadget angeklickt ...
PropClick
PEEKL EntryCount,d1
cmpi.b #6,d1
bls NoMove
subq.b #6,d1
move.l #$ffff,d0
divu d1,d0
and.l #$ffff,d0
moveq.l #0,d1
PEEKW RPropSpecial+4,d1
divu d0,d1
and.l #$ffff,d1
mulu #36,d1
add.l #Entrys,d1
SADD ITextList,a0
moveq.l #6-1,d2
move.l (a0),a1
cmp.l $c(a1),d1
beq NoMove
Move move.l (a0)+,a1
move.l d1,$c(a1)
add.l #36,d1
dbra d2,Move
EndMove bsr RefreshNames
NoMove rts
*** File-Namen ausgeben
RefreshNames
bsr ClearRects
bsr MakeLenght
SADD ITextList,a0
moveq.l #6-1,d0
MakeColors
move.l (a0)+,a1
move.l $c(a1),a2
SADD EntryCols,a3
move.b 31(a2),d1
ext.w d1
move.b 0(a3,d1.w),(a1)
dbra d0,MakeColors
PEEKL _ReqWindRast,a0
SADD IText0,a1
moveq.l #0,d0
moveq.l #0,d1
CALLPC _IntuitionBase,PrintIText
rts
EntryCols dc.b 3,2,1,3,1,0
*** Rechtecke löschen
ClearRects
PEEKL _ReqWindRast,a1
moveq.l #0,d0
CALLPC _GfxBase,SetAPen
SADD ITextList,a2
moveq.l #47,d4
moveq.l #6-1,d5
DoRem move.l (a2)+,a3
PEEKL _ReqWindRast,a1
moveq.l #22,d0
move.l $c(a3),a3
MakeX cmpi.b #0,(a3)+
beq XisOK
addq.w #8,d0
cmpi.w #260-8*8,d0
bls MakeX
move.w #260-8*8,d0
XisOK move.l d4,d1
move.l d1,d3
add.l #9,d3
move.w #260-1-7*8,d2
CALLSYS RectFill
add.l #10,d4
dbra d5,DoRem
EndRem rts
*** Proportional-Gadget neu berechnen
RemakeProp
PEEKL EntryCount,d0
cmpi.b #6,d0
bls NoRemakeProp
move.l #$ffff,d1
mulu #6,d1
divu d0,d1
cmp.w RPropSpecial+8(pc),d1
beq.s NoRemakeProp
POKEW d1,RPropSpecial+8
bsr RefreshProp
NoRemakeProp
rts
*** Proportional-Gadget zeichnen
RefreshProp
SADD RProp,a0
PEEKL _ReqWindBase,a1
suba.l a2,a2
CALLPC _IntuitionBase,RefreshGadgets
rts
*** String-Gadgets zeichnen
RefreshStrings
SADD RDir,a0
PEEKL _ReqWindBase,a1
suba.l a2,a2
CALLPC _IntuitionBase,RefreshGadgets
rts
*** Verbindet Directory mit Name
JoinName
lea DirBuffer,a0
lea FileBuffer,a1
lea DirFileBuffer,a2
CopyDir move.b (a0)+,(a2)+
cmpi.b #0,-1(a2)
bne.s CopyDir
suba.l #1,a2
cmpa.l #DirFileBuffer,a2
beq JoinFile
cmpi.b #58,-1(a2)
beq JoinFile
cmpi.b #47,-1(a2)
beq JoinFile
move.b #47,(a2)+
JoinFile
move.b (a1)+,(a2)+
cmpi.b #0,-1(a2)
bne.s JoinFile
rts
*** Datei-Längen berechnen
MakeLenght
SADD ITextList,a2
SADD LTextList,a3
moveq.l #6-1,d3
MakeL move.l (a3)+,a0
move.l (a2)+,a4
move.l $c(a4),a4
cmpi.b #1,31(a4)
bne MakeLDir
move.l 32(a4),d2
bsr D2ToASC
bra MakeDec
MakeLDir
moveq.l #7-1,d4
ClearSize
move.b #32,(a0)+
dbra d4,ClearSize
MakeDec dbra d3,MakeL
rts
*** d2 in ASC wandeln
D2ToASC moveq #6,d0
SADD ASCTens,a1
move.l a0,-(sp)
ASCNext moveq.b #"0",d1
ASCDec addq.b #1,d1
sub.l (a1),d2
bcc.s ASCDec
subq.b #1,d1
add.l (a1)+,d2
move.b d1,(a0)+
dbra d0,ASCNext
move.l (sp)+,a0
moveq.l #5,d0
ASCNill cmpi.b #"0",(a0)
bne.s ASCEnd
move.b #32,(a0)+
dbra d0,ASCNill
ASCEnd rts
ASCTens dc.l 1000000,100000,10000,1000,100,10,1
*** Library-Zeiger suchen und merken
OpenLibs
move.l 4,a6
lea $17a(a6),a0
SADD IntName,a1
CALLSYS FindName
POKEL d0,_IntuitionBase
lea $17a(a6),a0
SADD DOSName,a1
CALLSYS FindName
POKEL d0,_DOSBase
lea $17a(a6),a0
SADD GrafName,a1
CALLSYS FindName
POKEL d0,_GfxBase
rts
IntName INTNAME
DOSName DOSNAME
GrafName GRAFNAME
_IntuitionBase ds.l 1
_DOSBase ds.l 1
_GfxBase ds.l 1
*** Border malen
MakeRBorder
PEEKL _ReqWindRast,a0
SADD RBorder0,a1
moveq.l #0,d0
moveq.l #0,d1
CALLPC _IntuitionBase,DrawBorder
rts
*** Data-Teil
ReqWindow dc.w 160,21,320,158
dc.b -1,-1
dc.l 8!$20!$40,$800!$1000!$10000,RGad0,0,0,0,0
dc.w 0,0,0,0,15
_ReqWindBase ds.l 1
_ReqWindRast ds.l 1
_ReqWindUser ds.l 1
RGad0 dc.l RGad1
dc.w 20,47,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F0"
dc.l 0
RGad1 dc.l RGad2
dc.w 20,57,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F1"
dc.l 0
RGad2 dc.l RGad3
dc.w 20,67,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F2"
dc.l 0
RGad3 dc.l RGad4
dc.w 20,77,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F3"
dc.l 0
RGad4 dc.l RGad5
dc.w 20,87,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F4"
dc.l 0
RGad5 dc.l RCancel
dc.w 20,97,240,10,0,1,1
dc.l 0,0,0,0,0
dc.w "F5"
dc.l 0
RCancel dc.l RParent
dc.w 20,137,80,11,2,1,1
dc.l RBorder2,RBorder4,RCancelText,0,0
dc.w "CL"
dc.l 0
RCancelText dc.b 1,0,0,0
dc.w 40-6*4,2
dc.l 0,RCancelBytes,0
TEXT RCancelBytes,"CANCEL"
RParent dc.l ROK
dc.w 80+2*20,137,80,11,2,1,1
dc.l RBorder2,RBorder4,RParentText,0,0
dc.w "PT"
dc.l 0
RParentText dc.b 1,0,0,0
dc.w 40-6*4,2
dc.l 0,RParentBytes,0
TEXT RParentBytes,"PARENT"
ROK dc.l RProp
dc.w 2*80+3*20,137,80,11,2,1,1
dc.l RBorder2,RBorder4,ROKText,0,0
dc.w "OK"
dc.l 0
ROKText dc.b 1,0,0,0
dc.w 40-8*4,2
dc.l 0,ROKBytes,0
TEXT ROKBytes,"CONTINUE"
RProp dc.l RDir
dc.w 284,49,12,56,0,2,3
dc.l RPropInfo,0,0,0,RPropSpecial
dc.w "PR"
dc.l 0
RPropInfo ds.w 4
RPropSpecial dc.w 1!4!8,0,0,0,$ffff
ds.w 6
RDir dc.l RFile
dc.w 21,28,278,8,0,1,4
dc.l RBorder6,0,0,0,RDirSpecial
dc.w "DC"
dc.l 0
RDirSpecial dc.l DirBuffer,UndoBuffer
dc.w 0,81
ds.w 12
RFile dc.l 0
dc.w 21,118,278,8,0,1,4
dc.l RBorder6,0,0,0,RFileSpecial
dc.w 0
dc.l 0
RFileSpecial dc.l FileBuffer,UndoBuffer
dc.w 0,31
ds.w 12
RBorder0 dc.w 0,0 ;Borders für Fenster-
dc.b 2,0,0,3 ;rahmen
dc.l RPairs0,RBorder1
RPairs0 dc.w 319,0,0,0,0,156
RBorder1 dc.w 0,0
dc.b 1,0,0,3
dc.l RPairs1,RBorder8
RPairs1 dc.w 0,157,319,157,319,1
RBorder2 dc.w 0,0 ;Borders für Bool-Gads
dc.b 2,0,0,3
dc.l RPairs24,RBorder3
RBorder3 dc.w 0,0
dc.b 1,0,0,3
dc.l RPairs35,0
RBorder4 dc.w 0,0
dc.b 1,0,0,3
dc.l RPairs24,RBorder5
RBorder5 dc.w 0,0
dc.b 2,0,0,3
dc.l RPairs35,0
RPairs24 dc.w 79,0,0,0,0,9
RPairs35 dc.w 0,10,79,10,79,1
RBorder6 dc.w -1,-1 ;Borders für Strings
dc.b 1,0,0,3
dc.l RPairs6,RBorder7
RPairs6 dc.w 279,0,0,0,0,8
RBorder7 dc.w -1,-1
dc.b 2,0,0,3
dc.l RPairs7,0
RPairs7 dc.w 0,9,279,9,279,1
RBorder8 dc.w 280,47 ;Border für Prop-Gad
dc.b 1,0,0,3
dc.l RPairs8,RBorder9
RPairs8 dc.w 19,0,0,0,0,58
RBorder9 dc.w 280,47
dc.b 2,0,0,3
dc.l RPairs9,0
RPairs9 dc.w 0,59,19,59,19,1
IText0 dc.b 1,0,1,0
dc.w 22,48
dc.l 0,0,IText1
IText1 dc.b 1,0,1,0
dc.w 22,58
dc.l 0,0,IText2
IText2 dc.b 1,0,1,0
dc.w 22,68
dc.l 0,0,IText3
IText3 dc.b 1,0,1,0
dc.w 22,78
dc.l 0,0,IText4
IText4 dc.b 1,0,1,0
dc.w 22,88
dc.l 0,0,IText5
IText5 dc.b 1,0,1,0
dc.w 22,98
dc.l 0,0,LText0
ITextList dc.l IText0,IText1,IText2,IText3,IText4,IText5
LText0 dc.b 2,0,1,0
dc.w 260-7*8,48
dc.l 0,LBytes0,LText1
TEXT LBytes0,<" ">
LText1 dc.b 2,0,1,0
dc.w 260-7*8,58
dc.l 0,LBytes1,LText2
TEXT LBytes1,<" ">
LText2 dc.b 2,0,1,0
dc.w 260-7*8,68
dc.l 0,LBytes2,LText3
TEXT LBytes2,<" ">
LText3 dc.b 2,0,1,0
dc.w 260-7*8,78
dc.l 0,LBytes3,LText4
TEXT LBytes3,<" ">
LText4 dc.b 2,0,1,0
dc.w 260-7*8,88
dc.l 0,LBytes4,LText5
TEXT LBytes4,<" ">
LText5 dc.b 2,0,1,0
dc.w 260-7*8,98
dc.l 0,LBytes5,0
TEXT LBytes5,<" ">
LTextList dc.l LBytes0,LBytes1,LBytes2,LBytes3,LBytes4,LBytes5
*** Fehler
TableFull dc.b 1,0,0,0
dc.w 140-21*4,0
dc.l 0,TFullBytes,0
TEXT TFullBytes,<"MY FILE TABLE IS FULL">
SECTION "Reserved",BSS
Entrys ds.b 100*36
cnop 0,4
FileInfo ds.b 260
DirBuffer ds.b 82
FileBuffer ds.b 32
DirFileBuffer ds.b 80+30+1+1
UndoBuffer ds.b 82
END