;TOSAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
;
;Fast Assign Plus Rafik/RDST/SCT idea & first code by Big Foot/RDST
;97-V-29
;97-XII-06 more english, +some instruction for beginers!
; lost my email :(( This one isn't my but im using it.
; brainiax@manta.univ.gda.pl or mars@biomed.eti.pg.gda.pl



;for new in assembler......
;Change 'incdir' to path where you have this source, my macra and lovs
;fe: ram:
;
;Jump to the end of file and follow instruction
;it was written in Trasm'one but should work with AsmOne (not tested)

		incdir	hd1:sources/
		include	macra.s
		include	lvos.i


;Version can be changed here!
;
VERSION:	MACRO
		dc.b	'3.05 (97-XII-6)'
		ENDM


*******************************************************************************
*Program ten tworzy katalog ram:T i assignuje tam t:
*Tworzy równieû assigny:    ENV:, PRINTERS:, CLIPBOARDS:, i pare innych
*Potrzebny system 2.0+
*Eliminuje komendy :
*Assign >NIL: ENV: DH0:ENV
*Assign >NIL: T: RAM:T
*Assign >NIL: CLIPS: DH0:T/Clipboards
*Assign >NIL: REXX: S:			;<nie
*Assign >NIL: PRINTERS: DEVS:Printers
*Assign >NIL: KEYMAPS: DEVS:Keymaps
*Assign >NIL: LOCALE: SYS:Locale
*Assign >NIL: LIBS: SYS:Classes ADD	;<nie
*Assign >NIL: HELP: dh0:Help DEFER
*******************************************************************************



Start:
			moveq	#36,d0
			lea	DosName(pc),a1
			EXEC
			CALL	OpenLibrary
			move.l	d0,DosBase
			beq.w	WrongSys
			move.l	d0,a6

			bsr	ReadArgs

		ml	array(pc),d0
		bne.s	EndTable


			lea	AssignTable(pc),a0
AssignLoop:
			mb	(a0)+,d0
			beq	EndTable
			mb	d0,function	;late or path etc....

			tst.b	(a0)
			beq.s	EndTable
			move.l	a0,d1
.1			tst.b	(a0)+
			bne.s	.1

			bsr	doassign

			move.l	TableAdr,a0
.loop			tst.b	(a0)+
			bne.s	.loop
			bra.s	AssignLoop

********************
EndTable:
			CALL	Output
                        move.l  d0,d1
			beq.s	CloseLib

			move.l	#AboutTXT,d2
			move.l  #AboutTXTEnd-AboutTXT-1,d3
			CALL	Write

**************
CloseLib:
			move.l	a6,a1
			EXEC
			CALL	CloseLibrary
			moveq	#0,d0
			rts
WrongSys:
			moveq	#-1,d0
			rts

assigndest:	dc.l	0

*********************************************************
doassign:
			ml	d1,assigndest
			move.l	a0,TableAdr
			cmp.b	#3,function
			bpl.s	Path_or_Late

			moveq	#-2,d2	;mode read
			CALL	Lock
			move.l	d0,d2
			bne.s	.doit
;-----------create dir if not exist!
;d1 name
			ml	assigndest,d1
			CALL	CreateDir
			move.l	d0,d1
			beq.s	.skip	;cant create dir, skipping
			CALL	UnLock

			ml	assigndest,d1
			moveq	#-2,d2	;mode read
			CALL	Lock
			ml	d0,d2
			beq.s	.skip
.doit
			move.l	d0,Lock
			move.l	TableAdr,d1
			cmp.b	#1,function
			beq.s	.doassignlock
			CALL	AssignAdd
			bra.s	.cont
.doassignlock:
			CALL	AssignLock	;d2lock d1name
.cont
			tst.l	d0
			bne.s	.ok
;bîâd przy assignie!
			move.l	Lock,d1
			CALL	UnLock
.ok

.skip
			rts

Path_or_Late:
		ml	a0,d2
		cmp.b	#4,function
		beq	a_Path

		JUMP	AssignLate

a_Path:
		JUMP	AssignPath

ReadArgs:	
		ml	#template,d1	;template
		ml	#array,d2
		q0	d3
		CALL	ReadArgs
		ml	d0,_readargs
		beq.w	rts

	;	bsr	request

		ml	array+4,d0
		beq.s	.skip
		ml	d0,a5
.loop
		tst.l	(a5)
		beq.s	.skip
		ml	(a5)+,a0	;offset volume: name
;--------------------------cut :----------------
		ml	a0,a2
.loo		tst.b	(a2)
		beq.s	.esc
		cmp.b	#':',(a2)+
		bne.s	.loo
		clr.b	-1(a2)
.esc
;--------------------------cut :---------------
		tst.l	(a5)
		beq.s	.skip
		ml	(a5)+,d1	;offset name

		bsr	doassign
		bra.s	.loop
.skip
		ml	_readargs,d1
		CALL	FreeArgs

rts		rts


DosBase:		dc.l	0
array:			dc.l	0,0,0

_readargs:		dc.l	0

function:	dc.b	0	;late, path etc...

			even

TableAdr:		;uûywa adresu DosName poniewaû po otwarciu biblioteki
			;text dos.library nie jest juû nam potrzebny!
Lock:	equ	*+4	;adres DosName+4 tak jak wyûej
DosName:		dc.b	'dos.library',0	;tu wrzucam baze tabeli assig

template:		dc.b	'ARGONLY/S,DIRS/M',0

			dc.b	'$VER:'
AboutTXT:		dc.b	' FastAssign '
			VERSION
			dc.b	' by Rafik & Big Foot of RDST',$a
			dc.b	' email: brainiax@manta.univ.gda.pl',$a
			dc.b	0
AboutTXTEnd:




*Assign >NIL: ENV: DH0:ENV
*Assign >NIL: T: RAM:T
*Assign >NIL: CLIPS: DH0:T/Clipboards
*Assign >NIL: PRINTERS: DEVS:Printers
*Assign >NIL: KEYMAPS: DEVS:Keymaps
*Assign >NIL: LOCALE: SYS:Locale
*Assign >NIL: HELP: dh0:Help DEFER	;na ram:t/ help!

*Assign >NIL: LIBS: SYS:Classes ADD	;<-NO
*Assign >NIL: REXX: S:			;<-NO

assign:	MACRO
	dc.b	1,'\2',0,'\1',0
	ENDM
assignadd:	MACRO
	dc.b	2,'\2',0,'\1',0
	ENDM

assignlate:	MACRO
	dc.b	3,'\1',0,'\2',0
	ENDM

assignpath:	MACRO
	dc.b	4,'\1',0,'\2',0
	ENDM



;assign 1
;assign path 2
;assign add 3
;assign late 4


*******************************************************************************
* Here is an assign table. All you have to do is to add your own assign

* fe: assignlate MUI,mdh3:system/mui
* fe: assign MUI,sys:MUI
*              ^
* DON'T add ':' after first argument !!!


* no ' in name allowed, space is allowed (at least in Trasm'one)

* To assemble this whith ASM or TSM
* just Find asseble in menu. Than WO (Write Object) to save the exe!
* Asm'one 1.30 is now on Aminet

* options
*	assign				;normal assign
*	assignadd			;as add in dos
*	assignlate			;as late option in dos
*	assignpath			;as path in dos

*note: assignpath & late won't create directory!


***********************************
AssignTable:		;podajesz gdzie zaasignowaê i nazwe assigna!

	;	assign		ENV,ram:env
		assign		ENV,sys:env
		assign		T,ram:T
		assign		CLIPS,ram:t
		assign		PRINTERS,devs:printers
		assign		KEYMAPS,devs:keymaps
		assign		LOCALE,sys:locale
		assign		HELP,ram:
		assign		MUI,sys:mui
		assignadd 	LIBS,sys:mui/libs

	;	assignlate	test,obrazki:

***********
		dc.b	0,0	;END OF TABLE Dont delete this !!!!

