NEW
  AUTO 3,1
				.LIST OFF
				.OP	65C02
				.OR	$2000
				.TF sys/pm/pm.appletalk
*--------------------------------------
				.INB inc/macros.i
				.INB inc/io.i
				.INB inc/monitor.i
				.INB inc/mli.i
				.INB inc/appletalk.i
*--------------------------------------
TmpPtr1			.EQ	$0
*--------------------------------------
BUF.PREFIX		.EQ $300
*--------------------------------------
AT.INIT			>LDYAI MSG.INIT
				jsr PrintFYA

				lda #$F9
				sta TmpPtr1
				lda	#$C7
				sta TmpPtr1+1

.1				ldy #3

.2				lda (TmpPtr1),y
				cmp SIG.ATLK,y
				bne .3

				dey
				bpl .2

				ldx #0

				ldy #4
				lda (TmpPtr1),y
				cmp #1
				beq .4

				ldx #$80
				cmp #2
				beq .4

				pha
				>LDYAI MSG.FAILED
				jsr PrintFYA
				rts

.3				dec	TmpPtr1+1
				lda TmpPtr1+1
				cmp #$C0
				bne .1

				>LDYAI MSG.NOHW
				jsr PrintFYA
				rts

.4				stx WC.Flag
				tay
				lda TmpPtr1+1
				and #$0f
				pha						Push slot #
				phy						Push Type #
				>LDYAI MSG.HWOK
				jsr PrintFYA

				>LDYA MLI+1
				>STYA GO.OLDMLI+1
				>STYA MLIATALK.PARAMS.OLDMLI
				ldy	#$14
				lda TmpPtr1+1			Cn
				sta MLIALLOCIRQ.PARAMS.SLOT
				>STYA GO.WSCARD+1
				bit WC.Flag
				bmi .5
				>STYA MLI+1

.5				>LDYAI MSG.ATINIT
				jsr PrintFYA

				jsr GO.WSCARD
				.DA #MLIATALK
				.DA MLIATALK.PARAMS
				bcs .9

				>LDYAI MSG.IRQ
				jsr PrintFYA

				jsr MLI
				.DA #MLIALLOCIRQ
				.DA MLIALLOCIRQ.PARAMS
				bcs .9

				cli
				>LDYAI MSG.PREFIX1
				jsr PrintFYA

				jsr GO.OLDMLI
				.DA #MLIGETPREFIX
				.DA MLIGETPREFIX.PARAMS
				bcs .9

				>LDYAI MSG.PREFIX2
				jsr PrintFYA

				jsr GO.WSCARD
				.DA #MLISETPREFIX
				.DA MLIGETPREFIX.PARAMS
				bcs .9

				jsr MLI
				.DA #MLIATALK
				.DA MLI.AT.FINaming
				bcc .8
				
				lda MLI.AT.FINaming+2
				pha
				lda MLI.AT.FINaming+3
				pha
				>LDYAI MSG.AFPKO
				jsr PrintFYA

.8				>LDYAI MSG.OK
				jsr PrintFYA
				rts

.9				pha
				>LDYAI MSG.KO
				jsr PrintFYA
				rts
*--------------------------------------
GO.WSCARD		jmp $ffff				SELF MODIFIED
GO.OLDMLI		jmp $ffff				SELF MODIFIED
*--------------------------------------
				.INB usr/src/shared/x.printf.s
*--------------------------------------
MSG.INIT		.CZ "AppleTalk Driver For A2osX\r"
MSG.FAILED		.CZ "AppleTalk Workstation Card Failed Power Up Diagnostics : EC=%h.\r"
MSG.NOHW		.CZ "AppleTalk Workstation Card Not Found.\r"
MSG.HWOK		.CZ "AppleTalk Workstation Card Type #%d Found In Slot #%d.\r"
MSG.ATINIT		.CZ "Calling ATInit...\r"
MSG.IRQ			.CZ "Setting Up IRQ Vector...\r"
MSG.PREFIX1		.CZ "Getting ProDOS Prefix...\r"
MSG.PREFIX2		.CZ "Setting AppleTalk Prefix...\r"
MSG.AFPKO		.CZ "WARNING : Enabling AFP failed : EC=%h%h.\r"
MSG.OK			.CZ "AppleTalk Driver Successfully Installed.\r"
MSG.KO			.CZ "AppleTalk Driver Install Failed : EC=%h.\r"
*--------------------------------------
SIG.ATLK		.AS "ATLK"
WC.Flag			.BS 1
*--------------------------------------
MLIATALK.PARAMS	.DA #0					Sync
				.DA #1					INIT
				.BS 2					RC
				.DA #$40				??? from ATINIT disassembly
MLIATALK.PARAMS.OLDMLI
				.BS 2					??? from ATINIT disassembly
				.BS 5					??? from ATINIT disassembly
*--------------------------------------
MLIALLOCIRQ.PARAMS
				.DA #2					Param Count
				.BS 1					Int Num returned
				.DA #$19				Lo byte always $19 for WS Card
MLIALLOCIRQ.PARAMS.SLOT
				.BS 1					hi byte : $Cn
*--------------------------------------
MLIGETPREFIX.PARAMS
				.DA #1
				.DA BUF.PREFIX
*--------------------------------------
MLI.AT.FINaming	.DA #0					Synchonous
				.DA #AT.FINaming
				.BS 2					Result Code
				.DA #%11000000			set Bit 7 & 6
				.DA #%10000000			b7=1:Use AFP long Name, b6=0:Update ProDOS dev table
*--------------------------------------
MAN
SAVE usr/src/sys/pm.appletalk.s
ASM
