
;;; prodos source code / patch


look		equ	$0a
apple		equ	$0c
indrcn		equ	$10
devid		equ	$12
dst		equ	$14
unit		equ	$43

glbclk		equ	$bf06
drv1adr		equ	$bf10
drv2adr		equ	$bf20
lstdev		equ	$bf30
devcnt		equ	$bf31
devlst		equ	$bf32
machid		equ	$bf98
slotbyt		equ	$bf99

rwts		equ	$d000

clock64		equ	$239a
whatsit		equ	$25b6

		org	$2681		;blk 4

numdevices	ds	8		;$2681
driveradr	dw	0		;$2689
d2idx		db	0		;$268b
diskins2	db	0		;$268c

64 14		stz	dst
64 15		stz	dst+1
64 10		stz	indrcn		;set up for search
a2 ff		ldx	#$ff
8e 31 bf	stx	devcnt		;device count=none
a9 0e		lda	#14
8d 8b 26	sta	d2idx
a9 c2		lda	#$c2		;quick
85 11		sta	indrcn+1	; check
*******
*--
		jsr	cmpid		;  of
*******
*++
20 ef 26	jsr	instser
*******
		ror	diskins2	;   slot 2
		lda	#$c7		;search slots from high to low
		sta	indrcn+1
findsks1	jsr	cmpid
b0 5c		bcs	nxtdsk
b1 10		lda	(indrcn),y	;check last byte of $cn rom
*******
*--
		beq	diskii		;if =00 then 16 sector disk ii
*******
*++
f0 58		beq	nxtdsk		;skip disk II cards
*******
		cmp	#$ff		;if =ff then 13 sector disk ii
		bcs	nxtdsk		; which is ignored
		sta	driveradr	;otherwise assume intelligent disk
		ldy	#7		;check for smartport device
		lda	(indrcn),y
		bne	nosport
		jmp	smartport

nosport		ldy	#$fe		;get attributes byte
		lda	(indrcn),y
		and 	#$03		;verify it provides needed calls
		cmp	#$03
		sec
		bne	nxtdsk
		jsr	setdevid	;$28E6
		clc
		php			;remember that it's not a disk ii
4a		lsr			;move # units (0=1, 1=2) to carry
a5 11		lda	indrcn+1	;save high byte of addr
d0 0d		bne	adevice		;branch always taken

diskii		equ	*
		sta	devid
		sec			;remember it's a disk ii
		php
		lda	d2blkio		;d2blkio = $2802
		sta	driveradr
		lda	d2blkio+1

adevice		sta	driveradr+1	
		jsr	installdev	;$283E
28		plp			;get back if it's a disk ii
90 1c		bcc	nodisk2

*******
*--
		dex			;most list ptr back
		dex			; (installdev left x set)
		stx	devcnt
		dec	d2idx
		dec	d2idx		;increase the disk ii index
		ldy	d2idx
		inx
		lda	devlst+1,x
		sta	devlst,y
		lda	devlst,x
		sta	devlst+1,y
		dex
*******
*++
instser		equ	*
60		rts
instser		equ	*
A5 11 		lda	indrcn+1
48 		pha
A5 43		lda	unit
8D 30 BF	sta	lstdev
20 ea 28	jsr	setdevid+4
85 11		sta	indrcn+1
A9 01		lda	#1
85 12		sta	devid
20 db 26	jsr	diskii+2
68    		pla
85 11		sta	indrcn+1
60 		rts
----
A9 01		lda	#1
85 12		sta	devid
85 11		sta	indrcn+1
A5 43		lda	unit
8D 30 BF	sta	lstdev
AD 02 28	lda	d2blkio
8D 89 26	sta	driveradr
--
AD 03 28	lda	d2blkio+1
8D 8A 26	sta	driveradr+1
18		clc
20 3E 28	jsr	installdev
60		rts
*******

nodisk2		*
nxtdsk2		clc
nxtdsk		jsr	sltrom		;$2795 (check for clock, etc)
		dec	indrcn+1
		lda	indrcn+1	;set up for next lower slot
		and	#7		;all slots been checked
		bne	findsks1
		jsr	$2919








