0001   0000             	.TITLE	"SHEP	APPLE DOS"
0002   0000             *	6.3	10-6-78
0003   0000             *	8 BIT ASSEMBLER
0004   0000             *	.M6502
0005   0000             *
0006   0000             **************************************************************************************
0007   0000             *	(C)  COPYRIGHT 1978  APPLE COMPUTER, INC
0008   0000             **************************************************************************************
0009   0000             *
0010   0000             #INCLUDE "MOTO.H"
0040+  0000             .LIST
0011   0000             
0012   0000             ORG1	EQU	$1B00
0013   0000             ORG2	EQU	$3600
0014   0000             DISKIO	EQU	$3D00
0015   0000             ASC1	EQU	$3800
0016   0000             AEC1	EQU	$3A8F
0017   0000             ASC2	EQU	$3D00
0018   0000             AEC2	EQU	$3FFF
0019   0000             EDOS	EQU	$4000

Page      1    SHEP	APPLE DOS

0020   0000             	PAGE
0021   1B00             	ORG	ORG1
0022   1B00 4C 7E 1D    BEGIN	JMP	DBINIT
0023   1B03             ;
0024   1B03             DOSREL
0025   1B03             ;
0026   1B03             ;	GET RELOCATION PARMS
0027   1B03             ;
0028   1B03             DR0
0029   1B03             LOC1	EQU	$26
0030   1B03 A9 BF       	LDA	#$BF		; START AT BF00
0031   1B05 8D 41 00    	STA	!ZPGWRK+1	; TO LOOK FOR
0032   1B08 A2 00       	LDX	#0		; HIGH RAM
0033   1B0A 8E 40 00    	STX	!ZPGWRK
0034   1B0D A0 00       	LDY	#0		;APPLE TEST
0035   1B0F             DR1B
0036   1B0F A1 40       	LDA	(ZPGWRK,X)
0037   1B11 85 26       	STA	LOC1
0038   1B13 98          DR1	TYA
0039   1B14 45 26       	EOR	LOC1
0040   1B16 85 26       	STA	LOC1
0041   1B18 98          	TYA
0042   1B19 41 40       	EOR	(ZPGWRK,X)
0043   1B1B 81 40       	STA	(ZPGWRK,X)
0044   1B1D C5 26       	CMP	LOC1
0045   1B1F D0 05       	BNE	DR1A
0046   1B21 C8          	INY
0047   1B22 D0 EB       	BNE	DR1B
0048   1B24 F0 05       	BEQ	DR2		; BR IF TOOK
0049   1B26             DR1A
0050   1B26 CE 41 00    	DEC	!ZPGWRK+1	; NOT RAM
0051   1B29 D0 E8       	BNE	DR1		; TRY NEXT PAGE
0052   1B2B             ;
0053   1B2B             DR2
0054   1B2B             ;	
0055   1B2B AC 41 00    	LDY	!ZPGWRK+1
0056   1B2E C8          	INY			; NEW END OF DOS
0057   1B2F 8C 6A 1C    	STY	NEPAGE
0058   1B32 38          	SEC
0059   1B33 98          	TYA
0060   1B34 ED 6B 1C    	SBC	DOSLNG		; MINUS DOS LENGTH
0061   1B37 8D 69 1C    	STA	NSPAGE		; IS NEW START OF DOS
0062   1B3A 38          	SEC
0063   1B3B ED 67 1C    	SBC	RSPAGE		; MINUS OLD DOS START
0064   1B3E F0 C0       	BEQ	BEGIN		; (BREIF NO DELTA)
0065   1B40 8D 6C 1C    	STA	DELTA		; IS DELTA

Page      2    SHEP	APPLE DOS

0066   1B43             	PAGE
0067   1B43 AD 67 1C    	LDA	RSPAGE		; RESET START PAGE TO NORMAL
0068   1B46 8D 0D 1D    	STA	ASTART+1
0069   1B49             ;
0070   1B49 A9 1D       	LDA	#DBINIT/256	;RESET PI RTN TO NORMAL
0071   1B4B 8D 49 37    	STA	DI3+2
0072   1B4E A9 7E       	LDA	#DBINIT&255
0073   1B50 8D 48 37    	STA	DI3+1
0074   1B53             ;
0075   1B53             ;

Page      3    SHEP	APPLE DOS

0076   1B53             	PAGE
0077   1B53             ;
0078   1B53             ;
0079   1B53             ;	RELOCATE ADR TABLES
0080   1B53             ;
0081   1B53 A2 00       	LDX	#0
0082   1B55 8E 40 00    	STX	!ZPGWRK
0083   1B58             DR3
0084   1B58 BD 1A 1C    	LDA	ADRTAB+1,X
0085   1B5B A8          	TAY
0086   1B5C BD 1B 1C    	LDA	ADRTAB+2,X
0087   1B5F 8D 41 00    	STA	!ZPGWRK+1
0088   1B62 4C 73 1B    	JMP	DR5
0089   1B65             ;
0090   1B65             DR4
0091   1B65 18          	CLC
0092   1B66 B1 40       	LDA	(ZPGWRK),Y
0093   1B68 6D 6C 1C    	ADC	DELTA
0094   1B6B 91 40       	STA	(ZPGWRK),Y
0095   1B6D C8          	INY
0096   1B6E D0 03       	BNE	DR5
0097   1B70 EE 41 00    	INC	!ZPGWRK+1
0098   1B73 C8          DR5	INY
0099   1B74 D0 03       	BNE	DR6
0100   1B76 EE 41 00    	INC	!ZPGWRK+1
0101   1B79             ;
0102   1B79             DR6
0103   1B79 AD 41 00    	LDA	!ZPGWRK+1
0104   1B7C DD 1D 1C    	CMP	ADRTAB+4,X
0105   1B7F 90 E4       	BCC	DR4
0106   1B81 98          	TYA
0107   1B82 DD 1C 1C    	CMP	ADRTAB+3,X
0108   1B85 90 DE       	BCC	DR4
0109   1B87             ;
0110   1B87 8A          	TXA
0111   1B88 18          	CLC
0112   1B89 69 04       	ADC	#4
0113   1B8B AA          	TAX
0114   1B8C EC 19 1C    	CPX	ADRTAB
0115   1B8F 90 C7       	BCC	DR3

Page      4    SHEP	APPLE DOS

0116   1B91             	PAGE
0117   1B91             ;
0118   1B91             ;	RELOCATE CODE
0119   1B91             ;
0120   1B91 A2 00       	LDX	#0
0121   1B93 8E 0B 33    DR7	STX	TEMP1
0122   1B96             ;
0123   1B96 BD 4B 1C    	LDA	CDETAB+1,X	; GET A START OF CODE ADR
0124   1B99 8D 40 00    	STA	!ZPGWRK		; PUT IN ZPG
0125   1B9C BD 4C 1C    	LDA	CDETAB+2,X
0126   1B9F 8D 41 00    	STA	!ZPGWRK+1
0127   1BA2             ;
0128   1BA2 A2 00       DR8	LDX	#0
0129   1BA4 A1 40       	LDA	(ZPGWRK,X)	; GET OP CODE
0130   1BA6 20 8E F8    	JSR	INSDS2		; GO FIND OUT HOW LONG
0131   1BA9             ;
0132   1BA9 AC 2F 00    	LDY	!LENGTH		; GET HOW LONG
0133   1BAC C0 02       	CPY	#2		; IF IT AINT
0134   1BAE D0 11       	BNE	DR9		; 3 THEN DONT RELOC
0135   1BB0 B1 40       	LDA	(ZPGWRK),Y	; GET PAGE FROM INST
0136   1BB2 CD 67 1C    	CMP	RSPAGE		; IF PAGE < REL START
0137   1BB5 90 0A       	BCC	DR9		; THE IGNOR
0138   1BB7 CD 68 1C    	CMP	REPAGE		; IF PAGE >= REL END
0139   1BBA B0 05       	BCS	DR9		; THEN IGNORE
0140   1BBC 6D 6C 1C    	ADC	DELTA		; ELSE ADD DELTA
0141   1BBF 91 40       	STA	(ZPGWRK),Y	; TO RELOCATE
0142   1BC1             ;
0143   1BC1 38          DR9	SEC
0144   1BC2 AD 2F 00    	LDA	!LENGTH		; ADD LENGTH
0145   1BC5 6D 40 00    	ADC	!ZPGWRK		; TO PC
0146   1BC8 8D 40 00    	STA	!ZPGWRK
0147   1BCB A9 00       	LDA	#0
0148   1BCD 6D 41 00    	ADC	!ZPGWRK+1
0149   1BD0 8D 41 00    	STA	!ZPGWRK+1
0150   1BD3             ;
0151   1BD3 AE 0B 33    	LDX	TEMP1		; CHECK FOR END
0152   1BD6 DD 4E 1C    	CMP	CDETAB+4,X	; OF CODE SEGMENT
0153   1BD9 90 C7       	BCC	DR8		; BR NOT END
0154   1BDB AD 40 00    	LDA	!ZPGWRK
0155   1BDE DD 4D 1C    	CMP	CDETAB+3,X
0156   1BE1 90 BF       	BCC	DR8		; BR NOT END
0157   1BE3             ;
0158   1BE3 8A          	TXA	
0159   1BE4 18          	CLC
0160   1BE5 69 04       	ADC	#4		; INCREMENT TABLE INDEX
0161   1BE7 AA          	TAX
0162   1BE8 EC 4A 1C    	CPX	CDETAB		; DONE
0163   1BEB 90 A6       	BCC	DR7		; BR IF NOT
0164   1BED             ;

Page      5    SHEP	APPLE DOS

0165   1BED             	PAGE
0166   1BED             ;
0167   1BED             ;	MOVE TO RELOCATED CODE
0168   1BED             ;
0169   1BED A9 3F       	LDA	#DEPAGE-1
0170   1BEF 8D 41 00    	STA	!ZPGWRK+1	; ZPGWRK=FROM
0171   1BF2 AC 6A 1C    	LDY	NEPAGE
0172   1BF5 88          	DEY
0173   1BF6 8C 43 00    	STY	!ZPGFCB+1	; ZPGFCB = TOO
0174   1BF9 A9 00       	LDA	#0
0175   1BFB 8D 40 00    	STA	!ZPGWRK
0176   1BFE 8D 42 00    	STA	!ZPGFCB
0177   1C01 A8          	TAY
0178   1C02             ;
0179   1C02 B1 40       DR10	LDA	(ZPGWRK),Y	; BYTE FROM
0180   1C04 91 42       	STA	(ZPGFCB),Y	; BYTE TO
0181   1C06 C8          	INY			; INCREMENT
0182   1C07 D0 F9       	BNE	DR10		; BR NOT FULL PAGE
0183   1C09 CE 6D 1C    	DEC	DPGCNT		; DECREMENT PAGE CNT
0184   1C0C F0 08       	BEQ	DR11		; BR IF DONE
0185   1C0E CE 41 00    	DEC	!ZPGWRK+1	; INC FROM PAGE
0186   1C11 CE 43 00    	DEC	!ZPGFCB+1	; INC TOO PAGE
0187   1C14 D0 EC       	BNE	DR10		; MOVE PAGE
0188   1C16             ;
0189   1C16 4C 47 1E    DR11	JMP	DBVECT+3	; DONE

Page      6    SHEP	APPLE DOS

0190   1C19             	PAGE
0191   1C19             DEPAGE	EQU	EDOS/256
0192   1C19             DSPAGE	EQU	STARTT/256
0193   1C19             INSDS2	EQU	$F88E
0194   1C19             LENGTH	EQU	$2F
0195   1C19 24          ADRTAB	DB	9*4
0196   1C1A 00 1D 56 1D 	DW	@@SAT1,@@EAT1
0197   1C1E 58 1D 5A 1D 	DW	@@RUN,@@RUN+2
0198   1C22 62 1D 64 1D 	DW	@@IBVT+2,@@IBVT+4
0199   1C26 6A 1D 6E 1D 	DW	@@AS1VT,@@AS1VT+4
0200   1C2A 74 1D 78 1D 	DW	@@AS2VT,@@AS2VT+4
0201   1C2E 7A 1D 7C 1D 	DW	@@AS2VT+6,@@AS2VT+8
0202   1C32 3A 2A 76 2A 	DW	@@SAT2,@@EAT2
0203   1C36 E4 37 E8 37 	DW	@@BAIOB,@@ADOSLD+2
0204   1C3A EE 37 F0 37 	DW	@@IBDCTP,@@IBDCTP+2
0205   1C3E 00 00 00 00 	DW	@0,@0
0206   1C42 00 00 00 00 	DW	@0,@0
0207   1C46 00 00 00 00 	DW	@0,@0
0208   1C4A             CDETAB
0209   1C4A 18          	DB	6*4
0210   1C4B 7E 1D 17 28 	DW	@@SC1,@@EC1
0211   1C4F 76 2A 06 33 	DW	@@SC2,@@EC2
0212   1C53 00 37 E0 37 	DW	@@SC3,@@EC3
0213   1C57 69 35 FE 35 	DW	@@SDP1,@@EDP1
0214   1C5B 00 38 8F 3A 	DW	@@ASC1,@@AEC1
0215   1C5F 00 3D FF 3F 	DW	@@ASC2,@@AEC2
0216   1C63 00 00 00 00 	DW	@0,@0
0217   1C67             ;
0218   1C67 1D          RSPAGE	DB	DSPAGE
0219   1C68 40          REPAGE	DB	DEPAGE
0220   1C69             ;
0221   1C69 00          NSPAGE	DB	0
0222   1C6A 00          NEPAGE	DB	0
0223   1C6B             ;
0224   1C6B 23          DOSLNG	DB	DEPAGE-DSPAGE
0225   1C6C             ;
0226   1C6C 00          DELTA	DB	0
0227   1C6D 23          DPGCNT	DB	DEPAGE-DSPAGE

Page      7    SHEP	APPLE DOS

0228   1C6E             	PAGE
0229   1D00             	BOUND	256
0230   1D00             ;
0231   1D00             ;	RELOCATION	TABLES
0232   1D00             ;
0233   1D00             START
0234   1D00             SAT1
0235   1D00 D3 1C       FTAB	DW	@@*-45		;START OF FTABS
0236   1D02 5E 1E       CINA	DW	@@CHRIN		;CHAR IN ADR
0237   1D04 8F 1E       COUTA	DW	@@CHROUT		;CHAR OUT ADR
0238   1D06 EF 29       FN1ADR	DW	@@FNAME1
0239   1D08 0D 2A       FN2ADR	DW	@@FNAME2
0240   1D0A DA 29       SVBLA	DW	@@SVBL
0241   1D0C 00 1B       ASTART	DW	@@BEGIN		;CHANGED TO START BY RELOCATE
0242   1D0E 26 35       CCBADR	DW	@@CCB
0243   1D10             ;
0244   1D10             OUTSVT				;CHAR OUTPUT STATE VECTOR TABLE
0245   1D10 B6 1E       	DW	@@COS0-1
0246   1D12 D5 1E       	DW	@@COS1-1
0247   1D14 E6 1E       	DW	@@COS2-1
0248   1D16 F2 1E       	DW	@@COS3-1
0249   1D18 0D 1F       	DW	@@COS4-1
0250   1D1A 1C 1F       	DW	@@COS5-1
0251   1D1C 2C 1F       	DW	@@COS6-1
0252   1D1E             ;				COMMAND EXECUTION TABLE
0253   1D1E             CMDETB
0254   1D1E 03 25       	DW	@@EINIT-1
0255   1D20 C1 23       	DW	@@ELOAD-1
0256   1D22 4C 23       	DW	@@ESAVE-1
0257   1D24 92 24       	DW	@@ERUN-1
0258   1D26 A9 24       	DW	@@ECHAIN-1
0259   1D28 03 22       	DW	@@EDEL-1
0260   1D2A 11 22       	DW	@@ELOCK-1
0261   1D2C 15 22       	DW	@@EUNLK-1
0262   1D2E 90 22       	DW	@@ECLOSE-1
0263   1D30 CF 24       	DW	@@EREAD-1
0264   1D32 6E 25       	DW	@@EEXEC-1
0265   1D34 C1 24       	DW	@@EWRITE-1
0266   1D36 88 25       	DW	@@EPOS-1
0267   1D38 4E 22       	DW	@@EOPEN-1
0268   1D3A 3B 22       	DW	@@EAPND-1
0269   1D3C 24 22       	DW	@@EREN-1
0270   1D3E 20 25       	DW	@@ECAT-1
0271   1D40 D3 21       	DW	@@EMON-1
0272   1D42 DD 21       	DW	@@ENOMON-1
0273   1D44 C9 21       	DW	@@EPR-1
0274   1D46 CE 21       	DW	@@EIN-1
0275   1D48 F1 21       	DW	@@EMAXF-1
0276   1D4A 2C 25       	DW	@@EAS-1
0277   1D4C 50 25       	DW	@@EINT-1
0278   1D4E D8 22       	DW	@@EBSV-1
0279   1D50 04 23       	DW	@@EBLD-1
0280   1D52 38 23       	DW	@@EBRUN-1
0281   1D54 20 22       	DW	@@EVAR-1
0282   1D56             EAT1

Page      8    SHEP	APPLE DOS

0283   1D56             		PAGE
0284   1D56             ;
0285   1D56             ;		NON-RELOCATING ADRS
0286   1D56             ;
0287   1D56             IBASVT
0288   1D56 36 E8       CHAIN	DW	@@IBCHN
0289   1D58 9F 24       RUN	DW	@@IBRUN
0290   1D5A E3 E3       BREAK	DW	@@IBBRK
0291   1D5C 00 E0       GO	DW	@@IBGO
0292   1D5E 03 E0       CONT	DW	@@IBCONT		;BASIC CONT ENTRY POINT
0293   1D60 36 E8 9F 24 IBVT	DW	@@IBCHN,@@IBRUN,@@IBBRK
0293   1D64 E3 E3 
0294   1D66 00 E0 03 E0 	DW	@@IBGO,@@IBCONT
0295   1D6A             IBVTL	EQU	*-IBVT
0296   1D6A             ;
0297   1D6A B6 24 B6 24 AS1VT	DW	@@ASRUN1,@@ASRUN1,@@ASBRK1
0297   1D6E 65 D8 
0298   1D70 00 E0 00 00 	DW	@@IBGO,@@0
0299   1D74             AS1VTL	EQU	*-AS1VT
0300   1D74             ;
0301   1D74 BC 24 BC 24 AS2VT	DW	@@ASRUN2,@@ASRUN2,@@ASBRK2
0301   1D78 67 10 
0302   1D7A 7E 1D 00 00 	DW	@@DBINIT,@@0
0303   1D7E             AS2VTL	EQU	*-AS2VT

Page      9    SHEP	APPLE DOS

0304   1D7E             	PAGE
0305   1D7E             ;
0306   1D7E             ;	EQUATES REQD TO FIND THINGS IN APPLE II
0307   1D7E             ;
0308   1D7E             SETVID	EQU	$FE93
0309   1D7E             SETKBD	EQU	$FE89
0310   1D7E             PROMPT	EQU	$33		;PROMPT CHAR
0311   1D7E             OUTSW	EQU	$36		;OUTPUT VECTOR SWITCH
0312   1D7E             INSW	EQU	$38		;INPUT VECTOR SWITCH
0313   1D7E             ZPGWRK	EQU	$40		;ZERO PAGE WORK CELL
0314   1D7E             CNUM	EQU	$44		;CONVERTED NUMERIC
0315   1D7E             LBUFF	EQU	$200		;LINE BUFFER
0316   1D7E             MULT	EQU	$FB63		;MULT ROUTINE
0317   1D7E             INPRT	EQU	$FE8B		;SET OUT PORT
0318   1D7E             OUTPRT	EQU	$FE95		;SET OUT PORT
0319   1D7E             IBCHN	EQU	$E836		;BASIC RUN
0320   1D7E             IBLMEM	EQU	$4A		;BASIC LOW MEMORY
0321   1D7E             IBHMEM	EQU	$4C		;INTEGER BASIC HIMEM
0322   1D7E             IBSOP	EQU	$CA		;INTEGER BASIC START OF CGM
0323   1D7E             IBBRK	EQU	$E3E3		;BASIC BREAK
0324   1D7E             IBGO	EQU	$E000		;BASIC ENTRY POINT
0325   1D7E             IBCONT	EQU	$E003		;BASIC CONTINUE ENTRY POINT
0326   1D7E             IBSOV	EQU	$CC		;BASIC START OF VARIABLES
0327   1D7E             ASSOP	EQU	$67		;AS START OF PROGRAM
0328   1D7E             ASEOP	EQU	$AF		;AS END OF PROGRAM
0329   1D7E             ASEOP2	EQU	$69		;AS END-OF PGM 2
0330   1D7E             ASHM1	EQU	$73		;AS HIGH MEM 1
0331   1D7E             ASHM2	EQU	$6F		;AS HIGH MEM 2
0332   1D7E             ASLMEM	EQU	ASSOP		;AS LOW MEM
0333   1D7E             ASBRK1	EQU	$D865		;AS ROM BREAK
0334   1D7E             ASBRK2	EQU	$1067		;AS RAM BREAK
0335   1D7E             AITSTL	EQU	$E000		;AS 1 IB TEST LOC
0336   1D7E             ATSTV	EQU	$4C		;AS TEST VALUE
0337   1D7E             ITSTV	EQU	$20		;IB TEST VALUE
0338   1D7E             BOOTSL	EQU	$2E		;BOOT FROM SLOT
0339   1D7E             ZPGFCB	EQU	$42		;ZERO PAGE WORK CELL
0340   1D7E             HOME	EQU	$FC58
0341   1D7E             PRINT	EQU	$FDED
0342   1D7E             GETKEY	EQU	$FD0C

Page     10    SHEP	APPLE DOS

0343   1D7E             	PAGE
0344   1D7E             ;
0345   1D7E             ;	DOS BASIC INTERPRETER  INITIAL ENTRY
0346   1D7E             ;
0347   1D7E             SC1
0348   1D7E             DBINIT
0349   1D7E AD E9 37    	LDA	IBSLOT		;GET BOOT SLOT
0350   1D81 4A          	LSRA
0351   1D82 4A          	LSRA
0352   1D83 4A          	LSRA
0353   1D84 4A          	LSRA
0354   1D85 8D E4 29    	STA	CS		;SET AS CURRENT SLOT
0355   1D88 AD EA 37    	LDA	IBDRVN		;GET BOOT DRIVE NUMBER
0356   1D8B 8D E2 29    	STA	CD		;SET AS CURRENT DRIVE
0357   1D8E AD 00 E0    	LDA	AITSTL		;GET APPLESOFT/IB TEST
0358   1D91 49 20       	EOR	#ITSTV		;IF AS THEN
0359   1D93 D0 11       	BNE	IAS1		;GO TO AS INIT
0360   1D95             ;				;ELSE INIT FOR IB
0361   1D95 8D 30 2A    	STA	ASIBSW		;SET SW FOR IB
0362   1D98 A2 0A       	LDX	#IBVTL		;GET IB VT LENGTH
0363   1D9A BD 5F 1D    IIB1	LDA	IBVT-1,X	;MOVE IB ADDR
0364   1D9D 9D 55 1D    	STA	IBASVT-1,X
0365   1DA0 CA          	DEX
0366   1DA1 D0 F7       	BNE	IIB1
0367   1DA3 4C B6 1D    	JMP	INITAA
0368   1DA6             ;
0369   1DA6             IAS1
0370   1DA6 A9 40       	LDA	#$40		;INDICATE ROM APPLESOFT
0371   1DA8 8D 30 2A    	STA	ASIBSW
0372   1DAB A2 0A       	LDX	#AS1VTL
0373   1DAD BD 69 1D    IAS1A	LDA	AS1VT-1,X	;MOVE ROM AS ADRS
0374   1DB0 9D 55 1D    	STA	IBASVT-1,X
0375   1DB3 CA          	DEX
0376   1DB4 D0 F7       	BNE	IAS1A
0377   1DB6             ;
0378   1DB6             INITAA
0379   1DB6 38          	SEC			;INDICATE INIT
0380   1DB7 B0 12       	BCS	INITA
0381   1DB9             DBRST
0382   1DB9 AD 30 2A    	LDA	ASIBSW		;GET AS/IB FLAG
0383   1DBC D0 04       	BNE	INITA1		;BR IF NOT IB
0384   1DBE A9 20       	LDA	#ITSTV		;GET IB TEST VALUE
0385   1DC0 D0 05       	BNE	INITA2		;GO SET IB
0386   1DC2 0A          INITA1	ASLA			;TST ROM AS
0387   1DC3 10 05       	BPL	INITA3		;BR IF NOT ROM TEST VALUE
0388   1DC5 A9 4C       	LDA	#ATSTV		;GET AS ROM TEST VALUE
0389   1DC7 20 5B 25    INITA2	JSR	SWTST		;GO SET
0390   1DCA             INITA3
0391   1DCA 18          	CLC			;INDICATE RESET
0392   1DCB             ;
0393   1DCB             INITA
0394   1DCB 08          	PHP			;SAVE INIT/RESET
0395   1DCC 20 E4 27    	JSR	MVCSW		;GO MOVE CHAR SWITCH
0396   1DCF A9 70       	LDA	#MC+MI+MO	;SET MONITOR MODES
0397   1DD1 8D D8 29    	STA	MONMOD
0398   1DD4             ;
0399   1DD4 A9 00       	LDA	#0
0400   1DD6 8D CC 29    	STA	OSTATE		;CLEAR OUTSTATE AND EXECUTE STATE
0401   1DD9 28          	PLP			;GET INSTATE
0402   1DDA 6A          	RORA			;SHIFT CARRY TO MSB
0403   1DDB 8D CB 29    	STA	ISTATE		;SAVE INSTATE
0404   1DDE 30 03       	BMI	INITB		;BR IF INIT
0405   1DE0 6C 5E 1D    	JMP	(CONT)		;GO TO CONTINUE ENTRY
0406   1DE3 6C 5C 1D    INITB	JMP	(GO)		;GO TO GO ENTRY

Page     11    SHEP	APPLE DOS

0407   1DE6             	PAGE
0408   1DE6             INITC
0409   1DE6 0A          	ASLA			;OF ISTATE NOT ON
0410   1DE7 10 19       	BPL	INITD		;THEN NOT RAM AS
0411   1DE9 8D 30 2A    	STA	ASIBSW		;SET RAM AS
0412   1DEC A2 0A       	LDX	#AS2VTL
0413   1DEE BD 73 1D    IAS2A	LDA	AS2VT-1,X	;MOVE RAM AS ADRS
0414   1DF1 9D 55 1D    	STA	IBASVT-1,X
0415   1DF4 CA          	DEX
0416   1DF5 D0 F7       	BNE	IAS2A
0417   1DF7 A2 1D       	LDX	#29
0418   1DF9 BD 0D 2A    IAS2B	LDA	FNAME2,X
0419   1DFC 9D EF 29    	STA	FNAME1,X
0420   1DFF CA          	DEX
0421   1E00 10 F7       	BPL	IAS2B
0422   1E02             ;
0423   1E02             INITD
0424   1E02 AD 2B 2A    	LDA	DFNFTS		;GO BUILD FILE TABS
0425   1E05 8D D1 29    	STA	CNFTBS		;AND SET MEM BOUNDS
0426   1E08 20 67 27    	JSR	BLDFTB
0427   1E0B AD 2D 2A    	LDA	ESTATE		;GET EXEC STATE
0428   1E0E F0 09       	BEQ	INITZ		;BR IF NOT EXECTUTE
0429   1E10 48          	PHA			;SVE CHAR
0430   1E11 20 2E 26    	JSR	MVEFTA		;GO MOVE EX FILE TAB ADR TO ZP
0431   1E14 68          	PLA			;GET SAVED CHAR
0432   1E15 A0 00       	LDY	#0
0433   1E17 91 40       	STA	(ZPGWRK),Y	;
0434   1E19             INITZ
0435   1E19 20 EE 26    	JSR	CLRSTS		;SET IN AND OUT STATES TO ZERO
0436   1E1C A2 27       	LDX	#IFBL
0437   1E1E BD 44 1E    INITE	LDA	DBVECT,X	;MOVE RESTART VECTORS	
0438   1E21 9D D0 03    	STA	$3D0,X
0439   1E24 CA          	DEX
0440   1E25 10 F7       	BPL	INITE
0441   1E27 AD D9 29    	LDA	CMDNO		;IF NOT BOOT
0442   1E2A D0 0A       	BNE	INITF		;THEN DONE
0443   1E2C AD EF 29    	LDA	FNAME1		;IF FN1
0444   1E2F 49 A0       	EOR	#$A0		;NOT DONE
0445   1E31 F0 03       	BEQ	INITF		;THEN DONE
0446   1E33 4C 93 24    	JMP	ERUN		;ELSE
0447   1E36             ;
0448   1E36             IFB
0449   1E36             INITF
0450   1E36 AD DC 29    	LDA	SVCMD
0451   1E39 F0 06       	BEQ	INITG
0452   1E3B 8D D9 29    	STA	CMDNO
0453   1E3E 4C 15 21    	JMP	CMDGO
0454   1E41             INITG
0455   1E41 4C 69 1F    	JMP	ORTN
0456   1E44             ;
0457   1E44 4C B9 1D    DBVECT	JMP	DBRST
0458   1E47 4C 7E 1D    	JMP	DBINIT
0459   1E4A 4C 76 2A    	JMP	DOSENT
0460   1E4D 4C 00 3D    	JMP	DISKIO
0461   1E50             CCBLDR
0462   1E50 AD 0F 1D    	LDA	CCBADR+1
0463   1E53 AC 0E 1D    	LDY	CCBADR
0464   1E56 60          	RTS
0465   1E57             IOBLDR
0466   1E57 AD 3B 2A    	LDA	AIOB+1
0467   1E5A AC 3A 2A    	LDY	AIOB
0468   1E5D 60          	RTS
0469   1E5E             IFBL	EQU	*-IFB-1

Page     12    SHEP	APPLE DOS

0470   1E5E             	PAGE
0471   1E5E             ;
0472   1E5E             ;	CHRIN  CHAR RCVD VIA IN SWITCH
0473   1E5E             ;
0474   1E5E             CHRIN
0475   1E5E 20 A3 1E    	JSR	SVREGS
0476   1E61 AD CB 29    	LDA	ISTATE		;IF NOT DISKIN
0477   1E64 F0 0D       	BEQ	CHIN1		;THEN BRANCH, ELSE
0478   1E66 10 03       	BPL	CHIN0
0479   1E68 4C E6 1D    	JMP	INITC
0480   1E6B             CHIN0
0481   1E6B AD D6 29    	LDA	SVA
0482   1E6E 91 28       	STA	($28),Y
0483   1E70 4C D5 25    	JMP	ICFD		;AND GET CHAR FROM DISK
0484   1E73             CHIN1
0485   1E73 AD 2D 2A    	LDA	ESTATE
0486   1E76 F0 03       	BEQ	CHIN2
0487   1E78 4C 13 26    	JMP	NXTEXC
0488   1E7B             CHIN2
0489   1E7B A9 03       	LDA	#3		;SET OUT CHAR
0490   1E7D 8D CC 29    	STA	OSTATE		;STATE TO INPUT ECHO
0491   1E80 20 6C 1F    	JSR	LDREGS
0492   1E83 20 8C 1E    	JSR	GETIN
0493   1E86 8D D6 29    	STA	SVA
0494   1E89 4C 69 1F    	JMP	ORTN
0495   1E8C             ;
0496   1E8C 6C 38 00    GETIN	JMP	(INSW)
0497   1E8F             ;
0498   1E8F             ;	CHROUT  CHAR RCVD VIA OUTPUT SWITCH
0499   1E8F             ;
0500   1E8F             CHROUT
0501   1E8F 20 A3 1E    	JSR	SVREGS		;SAVE REGS
0502   1E92             
0503   1E92 AD CC 29    	LDA	OSTATE		;GET OUT SPARE
0504   1E95 0A          	ASLA
0505   1E96 AA          	TAX
0506   1E97 BD 11 1D    	LDA	OUTSVT+1,X	;GET ROUTINE ADR
0507   1E9A 48          	PHA
0508   1E9B BD 10 1D    	LDA	OUTSVT,X
0509   1E9E 48          	PHA
0510   1E9F AD D6 29    	LDA	SVA
0511   1EA2 60          	RTS			;GO TO ROUTINE
0512   1EA3             ;
0513   1EA3             ;	SVREGS  SAVE REGS WHILE PROCESSING CHARS
0514   1EA3             ;
0515   1EA3             SVREGS
0516   1EA3 8D D6 29    	STA	SVA		;SAVE ACU
0517   1EA6             SVRGSA
0518   1EA6 8E D4 29    	STX	SVX		;SAVE X
0519   1EA9 8C D5 29    	STY	SVY		;SAVE Y
0520   1EAC A2 03       	LDX	#3		;SET FOR FOUR BYTE MOVE
0521   1EAE BD CD 29    SVRB	LDA	SVOUTS,X	;MOVE SAVED OUT AND IN SW
0522   1EB1 95 36       	STA	OUTSW,X		;TO APPLE OUT/IN SW
0523   1EB3 CA          	DEX
0524   1EB4 10 F8       	BPL	SVRB
0525   1EB6 60          	RTS			;DONE

Page     13    SHEP	APPLE DOS

0526   1EB7             	PAGE
0527   1EB7             ;
0528   1EB7             ;	COS0  1ST CHAR OF PRINTED OUTPUT LINE
0529   1EB7             ;		CHECK FOR CNTL-D
0530   1EB7             ;
0531   1EB7             COS0
0532   1EB7 AE CB 29    	LDX	ISTATE		;IS IN STATE NOT ZERO
0533   1EBA F0 08       	BEQ	COS01
0534   1EBC C9 BF       	CMP	#'?'+$80	;THEN IS THIS?
0535   1EBE F0 6D       	BEQ	COS6		;THEN PRINT ONLY IF MONITOR
0536   1EC0 C5 33       	CMP	PROMPT
0537   1EC2 F0 69       	BEQ	COS6
0538   1EC4             COS01
0539   1EC4 A2 02       	LDX	#2
0540   1EC6 8E CC 29    	STX	OSTATE
0541   1EC9 CD 2C 2A    	CMP	CCHAR		;IF NOT CNTL-D
0542   1ECC D0 19       	BNE	COS2		;THEN GO TO STATE 2
0543   1ECE CA          	DEX
0544   1ECF 8E CC 29    	STX	OSTATE		;ELSE STATE = 1
0545   1ED2 CA          	DEX
0546   1ED3 8E D7 29    	STX	LBUFD		;AND LBUFD=0
0547   1ED6             ;
0548   1ED6             ;	COS1  ACCUMULATE CMD FROM PRINTED OUTPUT
0549   1ED6             ;
0550   1ED6             COS1
0551   1ED6 AE D7 29    	LDX	LBUFD		;GET LINE BUFF DISPL
0552   1ED9 9D 00 02    COS1A	STA	LBUFF,X		;PUT CHAR IN BUFF
0553   1EDC E8          	INX			;INCR PTR
0554   1EDD 8E D7 29    	STX	LBUFD		;SAVE PTR
0555   1EE0 C9 8D       	CMP	#$8D		;WAS THIS A CR
0556   1EE2 D0 67       	BNE	CMDRTN		;IF NOT THEN PR CHAR
0557   1EE4             ;
0558   1EE4 4C 85 1F    	JMP	SCNCMD		;GO SCAN COMMAND
0559   1EE7             ;
0560   1EE7             ;	COS2  PRINTED OUTPUT, NOT FIRST CHAR
0561   1EE7             ;
0562   1EE7             COS2
0563   1EE7 C9 8D       	CMP	#$8D		;IS IT A CR
0564   1EE9 D0 6F       	BNE	PRRTN		;BR IF NOT
0565   1EEB A2 00       	LDX	#0		;SET FOR POSSIBLE C-D NEXT
0566   1EED 8E CC 29    	STX	OSTATE		;NEXT STATE
0567   1EF0 4C 5A 1F    	JMP	PRRTN		;GO PRINT CHAR

Page     14    SHEP	APPLE DOS

0568   1EF3             	PAGE
0569   1EF3             ;
0570   1EF3             ;	COS3  KEY IN ECHO PRINT
0571   1EF3             ;
0572   1EF3             COS3
0573   1EF3 A2 00       	LDX	#0
0574   1EF5 8E CC 29    	STX	OSTATE		;RESET OUT STATE
0575   1EF8 C9 8D       	CMP	#$8D		;IS IT CR
0576   1EFA F0 07       	BEQ	COS3A		;IS CR THEN CMD CHECK
0577   1EFC             COS3B
0578   1EFC AD 2D 2A    	LDA	ESTATE		;ELSE IF NOT EXECUTE
0579   1EFF F0 59       	BEQ	PRRTN		;THEN PRINT CHAR
0580   1F01 D0 50       	BNE	DRTNI		;ELSE PRINT IF MON INPUT
0581   1F03             COS3A
0582   1F03             ;
0583   1F03 20 F9 25    	JSR	TSTRUN
0584   1F06 B0 F4       	BCS	COS3B
0585   1F08 AE D4 29    	LDX	SVX		;GET LINE INDEX
0586   1F0B 4C D9 1E    	JMP	COS1A
0587   1F0E             ;
0588   1F0E             ;	COS4  DISK OUTPUT MODE
0589   1F0E             ;
0590   1F0E             COS4
0591   1F0E C9 8D       	CMP	#$8D		;IS IT CR
0592   1F10 D0 05       	BNE	COS4A		;BR IF NOT CR
0593   1F12 A9 05       	LDA	#5		;SET STATE FOR CNTL-D
0594   1F14 8D CC 29    	STA	OSTATE		;EXAMINE
0595   1F17 20 BD 25    COS4A	JSR	OCTD		;GO OUTPUT CHAR TO DISK
0596   1F1A 4C 4F 1F    	JMP	DRTNO		;GO TO DATA RETURN (OUT)
0597   1F1D             ;
0598   1F1D             ;	COS5  DISK OUTPUT MODE  1ST CHAR OF A LINE
0599   1F1D             ;
0600   1F1D             COS5
0601   1F1D CD 2C 2A    	CMP	CCHAR		;IS IT CNTL D
0602   1F20 F0 95       	BEQ	COS0		;BR IF CNTL D
0603   1F22 C9 8A       	CMP	#$8A		;LINE FEED?
0604   1F24 F0 F1       	BEQ	COS4A
0605   1F26 A2 04       	LDX	#4
0606   1F28 8E CC 29    	STX	OSTATE		;SET NEW OUT STATE
0607   1F2B D0 E1       	BNE	COS4		;BR IF NOT CNTL D
0608   1F2D             ;
0609   1F2D             ;	COS6  DISK INPUT ECHO
0610   1F2D             ;
0611   1F2D A9 00       COS6	LDA	#0
0612   1F2F 8D CC 29    	STA	OSTATE		;RESET OUT STATE = 0
0613   1F32 F0 1F       	BEQ	DRTNI		;GO TO DATA IN RETURN

Page     15    SHEP	APPLE DOS

0614   1F34             	PAGE
0615   1F34             ;
0616   1F34             ;	PRRTN  PRINT CHAR RETURN
0617   1F34             ;
0618   1F34             ;
0619   1F34             ;	CMDRTN  PRINT CHAR IF MONITOR CMBS MODE
0620   1F34             ;	DRTNO  PRINT CHAR IF MONITOR DATA OUT
0621   1F34             ;	DRTNI  PRINT CHAR IF MONITOR DATA IN
0622   1F34             ;
0623   1F34             CERTN
0624   1F34 AD 00 02    	LDA	LBUFF		;CHECK FOR PRINTED COMMAND
0625   1F37 CD 2C 2A    	CMP	CCHAR	
0626   1F3A F0 0F       	BEQ	CMDRTN		;IF PC THEN NO RESET X REG
0627   1F3C A9 A0       	LDA	#$A0		;BLANK
0628   1F3E 8D 00 02    	STA	LBUFF
0629   1F41 A9 8D       	LDA	#$8D		;PLUS CR
0630   1F43 8D 01 02    	STA	LBUFF+1		;TO OUT BUFFER
0631   1F46 A2 00       	LDX	#0		;RESET TO SOL
0632   1F48 8E D4 29    	STX	SVX
0633   1F4B A9 40       CMDRTN	LDA	#MC
0634   1F4D D0 06       	BNE	MODECK
0635   1F4F A9 10       DRTNO	LDA	#MO
0636   1F51 D0 02       	BNE	MODECK
0637   1F53 A9 20       DRTNI	LDA	#MI
0638   1F55             ;
0639   1F55             MODECK
0640   1F55 2D D8 29    	AND	MONMOD		;AND WITH MODE
0641   1F58 F0 0F       	BEQ	ORTN		;BR IF NOT PRINT
0642   1F5A 20 6C 1F    PRRTN	JSR	LDREGS
0643   1F5D 20 77 1F    	JSR	ORTN1
0644   1F60 8D D6 29    	STA	SVA
0645   1F63 8C D5 29    	STY	SVY
0646   1F66 8E D4 29    	STX	SVX
0647   1F69             ;
0648   1F69             ORTN
0649   1F69 20 E4 27    	JSR	MVCSW		;GO MOVE CHAR I/O SWITCH
0650   1F6C             LDREGS
0651   1F6C AD D6 29    	LDA	SVA		;ACU
0652   1F6F AC D5 29    	LDY	SVY		;Y
0653   1F72 AE D4 29    	LDX	SVX		;X
0654   1F75 38          	SEC
0655   1F76 60          	RTS			;BY PASS PRINT
0656   1F77             ;
0657   1F77 6C 36 00    ORTN1	JMP	(OUTSW)
0658   1F7A             ;
0659   1F7A             ;	PRCRIF  PRINT CR IF MON CMDS
0660   1F7A             ;
0661   1F7A             PRCRIF
0662   1F7A 2C D8 29    	BIT	MONMOD		;IF NOT MON CMDS
0663   1F7D 50 05       	BVC	PRCIFR		;THEN RETURN
0664   1F7F A9 8D       	LDA	#$8D		;ELSE PRINT CR
0665   1F81 20 77 1F    	JSR	ORTN1
0666   1F84 60          PRCIFR	RTS

Page     16    SHEP	APPLE DOS

0667   1F85             	PAGE
0668   1F85             ;
0669   1F85             ;	SCNCMD  SCAN COMMAND
0670   1F85             ;
0671   1F85             SCNCMD
0672   1F85 A0 FF       	LDY	#$FF
0673   1F87 8C D9 29    	STY	CMDNO		;RESET COMMAND NUMBER
0674   1F8A C8          	INY
0675   1F8B 8C DC 29    	STY	SVCMD
0676   1F8E             SC0
0677   1F8E EE D9 29    	INC	CMDNO		;INCR CMD NO
0678   1F91 A2 00       	LDX	#0		;RESET LINE INDEX TO 0
0679   1F93 08          	PHP			;SAVE EQ STATUS
0680   1F94 BD 00 02    	LDA	LBUFF,X		;GET 1ST  LINE CHAR
0681   1F97 CD 2C 2A    	CMP	CCHAR		;IS IT CONTROL D
0682   1F9A D0 01       	BNE	SC0A		;BR /IF NOT
0683   1F9C E8          	INX			;INCR OVER CNTLD
0684   1F9D 8E D7 29    SC0A	STX	LBUFD
0685   1FA0             ;
0686   1FA0             SC1X
0687   1FA0 20 3F 21    	JSR	GNBC		;GET NON BLANK INPUT CHAR
0688   1FA3 29 7F       	AND	#$7F		;MSB OF CHAR OFF
0689   1FA5 59 17 28    	EOR	CMDNTB,Y	;EOR WITH INPUT
0690   1FA8 C8          	INY			;INCREMENT TABLE INDEX
0691   1FA9 0A          	ASLA			;IF MSB OF EOR RESULT ON
0692   1FAA F0 02       	BEQ	SC1A		;IF RESULT NOT NOW ZERO
0693   1FAC 68          	PLA			;THEN INPUT DOES NOT
0694   1FAD 08          	PHP			;EQUAL ENTRY
0695   1FAE 90 F0       SC1A	BCC	SC1X		;LOOP FOR END ENTRY
0696   1FB0             ;
0697   1FB0 28          	PLP			;IF INPUT EQUALS END
0698   1FB1 F0 20       	BEQ	SYNTAX		;THEN GO SYNTAX
0699   1FB3             ;
0700   1FB3 B9 17 28    	LDA	CMDNTB,Y	;IF NEXT TABLE CHAR NOT ZERO
0701   1FB6 D0 D6       	BNE	SC0		;THEN SCAN THE NEXT TABLE ENTRY
0702   1FB8             CNF				;COMMAND NOT FOUND
0703   1FB8 AD 00 02    	LDA	LBUFF		;LINE IS A CONTROL-D
0704   1FBB CD 2C 2A    	CMP	CCHAR		;THEN THIS IS A
0705   1FBE F0 03       	BEQ	CNF1		;POSSIBLE SYNTAX ERROR, ELSE
0706   1FC0 4C 5A 1F    	JMP	PRRTN		;ITS A BASIC INPUT LINE
0707   1FC3             CNF1
0708   1FC3 AD 01 02    	LDA	LBUFF+1		;GET  NEXT CHAR
0709   1FC6 C9 8D       	CMP	#$8D		;IS IT A CR
0710   1FC8 D0 06       	BNE	CSERR		;BR IF CR
0711   1FCA 20 EE 26    	JSR	CLRSTS		;CLEAR THE STATES
0712   1FCD 4C 4B 1F    	JMP	CMDRTN		;CNTL-D ONLY
0713   1FD0             ;
0714   1FD0 4C 59 26    CSERR	JMP	ESYNTX

Page     17    SHEP	APPLE DOS

0715   1FD3             	PAGE
0716   1FD3             ;
0717   1FD3             ;	SYNTAX  FIGURE OUT WHAT WE GOT HERE
0718   1FD3             ;
0719   1FD3             SYNTAX
0720   1FD3 AD D9 29    	LDA	CMDNO		;CMDNO=CMDNO*2
0721   1FD6 0A          	ASLA
0722   1FD7 8D D9 29    	STA	CMDNO
0723   1FDA             ;
0724   1FDA A8          	TAY
0725   1FDB A9 20       	LDA	#FN1
0726   1FDD 39 9C 28    	AND	CMDSTB,Y	;IS FN1 REGD
0727   1FE0 F0 63       	BEQ	SN10		;BR IF NOT 
0728   1FE2 20 38 20    	JSR	CLRFNS
0729   1FE5 08          	PHP			;SAVE EG STATUS
0730   1FE6             ;
0731   1FE6             SN2
0732   1FE6 20 3F 21    	JSR	GNBC		;GET NON BLANK CHAR
0733   1FE9 F0 1E       	BEQ	SN6		;BR IF CR OR COMMA
0734   1FEB 0A          	ASLA			;TEST FOR ALPHA
0735   1FEC 90 05       	BCC	SN2A		;BR IF ALPHA
0736   1FEE 30 03       	BMI	SN2A		;BR IS ALPHA
0737   1FF0 4C B8 1F    	JMP	CNF		;LURCH IF NOT ALPHA
0738   1FF3 6A          SN2A	RORA			;RESTORE BITS
0739   1FF4 4C FC 1F    	JMP	SN4		;AWAY WE GO
0740   1FF7 20 2E 21    SN3	JSR	GNXTC		;GO GET NEXT CHAR
0741   1FFA F0 0D       	BEQ	SN6		;BR IF COMMA OR CHAR
0742   1FFC 99 EF 29    SN4	STA	FNAME1,Y	;PUT INTO ILENAME
0743   1FFF C8          	INY			;INC FN INDEX
0744   2000 C0 3C       	CPY	#60		;ATFN FN INDEX
0745   2002 90 F3       	BCC	SN3		;BR IF NOT
0746   2004 20 2E 21    SN5	JSR	GNXTC		;LOOP UNTIL CR OR COMMA
0747   2007 F0 FB       	BEQ	SN5
0748   2009             ;
0749   2009 28          SN6	PLP			;WAS THIS FN2 L OO
0750   200A D0 0F       	BNE	SN7		;BR IF IT WAS
0751   200C             ;
0752   200C AC D9 29    	LDY	CMDNO
0753   200F A9 10       	LDA	#FN2
0754   2011 39 9C 28    	AND	CMDSTB,Y	;IF FN2 NOT REGD THEN
0755   2014 F0 0C       	BEQ	SN8		;BRANCH
0756   2016             ;
0757   2016 A0 1E       	LDY	#30		;SET FN2 INDEX
0758   2018 08          	PHP			;INDICATE FN2 SEEK
0759   2019 D0 CB       	BNE	SN2		;GO LOOK FOR FN2
0760   201B             ;
0761   201B AD 0D 2A    SN7	LDA	FNAME2		;IF 1ST CHAR OF
0762   201E C9 A0       	CMP	#$A0		;FN2 IS BLANK THEN
0763   2020 F0 13       	BEQ	SERR1		;SYNTAX ERROR
0764   2022             ;
0765   2022 AD EF 29    SN8	LDA	FNAME1		;IF 1ST CHAR OF
0766   2025 C9 A0       	CMP	#$A0		;FN1 IS NOT BLANK
0767   2027 D0 45       	BNE	SOPTS		;THEN GO LOOK FOR OPTIONS
0768   2029             ;
0769   2029 AC D9 29    	LDY	CMDNO
0770   202C A9 C0       	LDA	#NPB+NPE	;IF CMD MUST HAVE FILENAME
0771   202E 39 9C 28    	AND	CMDSTB,Y	;THEN
0772   2031 F0 02       	BEQ	SERR1		;THIS IS ERROR ELSE
0773   2033             ;
0774   2033 10 39       	BPL	SOPTS		;ITS EXECUTABLE WITHOUT
0775   2035             ;
0776   2035 4C B8 1F    SERR1	JMP	CNF
0777   2038             ;
0778   2038             CLRFNS
0779   2038 A9 00       	LDA	#0
0780   203A A0 3C       	LDY	#60
0781   203C             CLRFNA
0782   203C A9 A0       	LDA	#$A0
0783   203E 99 EE 29    SN1	STA	FNAME1-1,Y	;CLEAR FN1, FN2
0784   2041 88          	DEY	
0785   2042 D0 FA       	BNE	SN1
0786   2044 60          	RTS

Page     18    SHEP	APPLE DOS

0787   2045             	PAGE
0788   2045             SN10				;FILE NAMES NOT REGD
0789   2045 8D EF 29    	STA	FNAME1
0790   2048 A9 0C       	LDA	#NUM1+NUM2	;IF NEITHER NUM1
0791   204A 39 9C 28    	AND	CMDSTB,Y	;OR NUM2 IS REGD
0792   204D F0 1F       	BEQ	SOPTS		;THEN GO LOOK AT OPTIONS
0793   204F             ;
0794   204F 20 54 21    	JSR	GETNUM		;GO GET NUMERICS
0795   2052 B0 E1       	BCS	SERR1
0796   2054             ;
0797   2054 A8          	TAY			;IF HIGH DIGIT NOT
0798   2055 D0 DE       	BNE	SERR1		;ZERO THEN BAD
0799   2057             ;
0800   2057 E0 11       	CPX	#17		;IF LOW DIGIT GT 16
0801   2059 B0 DA       	BCS	SERR1		;THEN BAD
0802   205B             ;
0803   205B AC D9 29    	LDY	CMDNO
0804   205E A9 08       	LDA	#NUM1
0805   2060 39 9C 28    	AND	CMDSTB,Y	;IF WE WANT NUM2
0806   2063 F0 06       	BEQ	SN11
0807   2065             ;
0808   2065 E0 08       	CPX	#8		;IF NUM2>1
0809   2067 B0 CC       	BCS	SERR1		;THEN ERROR, ELSE
0810   2069 90 03       	BCC	SOPTS		;GO SCAN OPTIONS
0811   206B             ;
0812   206B             SN11
0813   206B 8A          	TXA			;IF NUM1=0
0814   206C F0 C7       	BEQ	SERR1		;THEN ERROR, ELSE
0815   206E             ;

Page     19    SHEP	APPLE DOS

0816   206E             	PAGE
0817   206E             ;
0818   206E             ;	SOPTS  LOOK FOR SYNTAX OPTIONS
0819   206E             ;
0820   206E             SOPTS
0821   206E A9 00       	LDA	#0
0822   2070 8D DF 29    	STA	INOPTS		;CLEAR INPUT OPTIONS
0823   2073 8D EE 29    	STA	IMBITS
0824   2076 8D E6 29    	STA	CL
0825   2079 8D E7 29    	STA	CL+1
0826   207C AD D7 29    	LDA	LBUFD		;SET PASS 1
0827   207F 8D DD 29    	STA	TEMP1A
0828   2082             ;
0829   2082 20 3F 21    SP1	JSR	GNBC		;GO GET NON-BLANK CHAR
0830   2085 D0 1F       	BNE	SP2		;BR IF NOT COMMA OR CR
0831   2087 C9 8D       	CMP	#$8D		;IF CHAR IS COMMA
0832   2089 D0 F7       	BNE	SP1		;THEN GO GET CHAR
0833   208B             ;
0834   208B AE D9 29    	LDX	CMDNO		;OPTIONS INPUT = I
0835   208E AD DF 29    	LDA	INOPTS		;ALLOW OPTS = A
0836   2091 1D 9D 28    	ORA	CMDSTB+1,X	;IF (A OR I)
0837   2094 5D 9D 28    	EOR	CMDSTB+1,X	;XOR A NOT = 0 THEN
0838   2097 D0 9C       	BNE	SERR1		;WE HAVE UNALLOWED OPTIONS
0839   2099             ;
0840   2099 AE DD 29    	LDX	TEMP1A		;IF THIS IS PASS 2
0841   209C F0 77       	BEQ	CMDGO		;THEN DONE,
0842   209E 8D DD 29    	STA	TEMP1A		;ELSE SET PASS
0843   20A1 8E D7 29    	STX	LBUFD		;RESTORE LBUFD AND
0844   20A4 D0 DC       	BNE	SP1		;GO DO PASS 2
0845   20A6             ;
0846   20A6 A2 0A       SP2	LDX	#OPT1L		;COMPARE CHAR HAVE WITH
0847   20A8 DD D3 28    SP3	CMP	OPTAB1-1,X	;CHARS IN OPT TABLE
0848   20AB F0 05       	BEQ	SP4		;IF NOT FOUND CONTINUE
0849   20AD CA          	DEX
0850   20AE D0 F8       	BNE	SP3		;IF NOT FOUND
0851   20B0 F0 60       	BEQ	SERR2		;THEN SYNTAX ERROR
0852   20B2             ;
0853   20B2 BD DD 28    SP4	LDA	OPTAB2-1,X	;IF CORRESPONDING OP TAB 2 IS
0854   20B5 30 47       	BMI	SP8		;MINUS THEN IT MONITOR BITS
0855   20B7 0D DF 29    	ORA	INOPTS
0856   20BA 8D DF 29    	STA	INOPTS
0857   20BD CA          	DEX
0858   20BE             ;
0859   20BE 8E DE 29    	STX	TEMP2A		;ELSE A NUMERIC MUST FOLLOW
0860   20C1 20 54 21    	JSR	GETNUM		;FOLLOW
0861   20C4 B0 4C       	BCS	SERR2
0862   20C6             ;
0863   20C6 AD DE 29    	LDA	TEMP2A		;GET IOTION NUMBER
0864   20C9 0A          	ASLA			;MULT BY 4
0865   20CA 0A          	ASLA
0866   20CB A8          	TAY
0867   20CC             ;
0868   20CC A5 45       	LDA	CNUM+1		;IF RESULT NUM HI IS
0869   20CE D0 09       	BNE	SP5		;GT 0, THEN GT LOW RANGE
0870   20D0 A5 44       	LDA	CNUM		;TEST RESULT LOW
0871   20D2 D9 E8 28    	CMP	OPTAB3,Y		;WITH LOW RANGE (LOW)
0872   20D5 90 3B       	BCC	SERR2		;BR IF RESULT < LR
0873   20D7 A5 45       	LDA	CNUM+1
0874   20D9 D9 EB 28    SP5	CMP	OPTAB3+3,Y	
0875   20DC 90 0B       	BCC	SP6		;BR IF LESS
0876   20DE D0 32       	BNE	SERR2		;BR IF GRREATER
0877   20E0 A5 44       	LDA	CNUM
0878   20E2 D9 EA 28    	CMP	OPTAB3+2,Y
0879   20E5 90 02       	BCC	SP6		;BR IF LESS
0880   20E7 D0 29       	BNE	SERR2		;BR IF GREATER
0881   20E9             ;
0882   20E9 AD DD 29    SP6	LDA	TEMP1A		;IF PASS 1,THEN
0883   20EC D0 94       	BNE	SP1		;DONT STORE RESULT
0884   20EE 98          	TYA
0885   20EF 4A          	LSRA
0886   20F0 A8          	TAY
0887   20F1             ;
0888   20F1 A5 45       	LDA	CNUM+1		;STORE THE RESULT
0889   20F3 99 E1 29    	STA	CUROPT+1,Y
0890   20F6 A5 44       	LDA	CNUM
0891   20F8 99 E0 29    	STA	CUROPT,Y
0892   20FB 4C 82 20    SP7	JMP	SP1		;GO FOR NEXT OPT
0893   20FE             ;
0894   20FE             SP8				;MONITOR REG
0895   20FE 48          	PHA			;SAVE TYPE REG
0896   20FF A9 80       	LDA	#CIO		;SET OPTION OF CIO
0897   2101 0D DF 29    	ORA	INOPTS
0898   2104 8D DF 29    	STA	INOPTS
0899   2107 68          	PLA			;RESTORE REG
0900   2108 29 7F       	AND	#$7F		;CLEAR CIO
0901   210A 0D EE 29    	ORA	IMBITS		;OR WITH PREV IMBITS
0902   210D 8D EE 29    	STA	IMBITS
0903   2110 D0 E9       	BNE	SP7		;GO FOR NEXT
0904   2112             ;
0905   2112 4C B8 1F    SERR2	JMP	CNF

Page     20    SHEP	APPLE DOS

0906   2115             	PAGE
0907   2115             ;
0908   2115             ;	CMDGO  EXECUTE COMMAND
0909   2115             ;
0910   2115             CMDGO
0911   2115 20 EE 26    	JSR	CLRSTS
0912   2118 20 49 21    	JSR	CLRCCB		;GO CLEAR CCB
0913   211B 20 21 21    	JSR	ECMD		;GO EXECUTE
0914   211E 4C 34 1F    	JMP	CERTN
0915   2121             ECMD
0916   2121 AD D9 29    	LDA	CMDNO		;COMMAND NO
0917   2124 AA          	TAX			;IS CMD EXEC TAB INDEX
0918   2125 BD 1F 1D    	LDA	CMDETB+1,X	;GET CMD ADR
0919   2128 48          	PHA			;ONTO STACK
0920   2129 BD 1E 1D    	LDA	CMDETB,X
0921   212C 48          	PHA
0922   212D 60          	RTS			;AND GOTO COMMAND
0923   212E             ;
0924   212E             ;	GNXTC  GET NEXT CHAR
0925   212E             ;
0926   212E             GNXTC
0927   212E AE D7 29    	LDX	LBUFD
0928   2131 BD 00 02    	LDA	LBUFF,X		;GET NEXT CHAR AND IF
0929   2134 C9 8D       	CMP	#$8D		;IT IS A CR
0930   2136 F0 06       	BEQ	GNXTCR		;THEN RETURN WITHOUT
0931   2138 E8          	INX			;INCR TO NEXT CHAR
0932   2139 8E D7 29    	STX	LBUFD
0933   213C C9 AC       	CMP	#','+$80	;TEST FOR COMMA
0934   213E 60          GNXTCR	RTS
0935   213F             ;
0936   213F             ;	GNBC  GET NON BLANK CHAR
0937   213F             ;
0938   213F             GNBC
0939   213F 20 2E 21    	JSR	GNXTC		;GO GET NEXT CHAR
0940   2142 F0 FA       	BEQ	GNXTCR		;BR IF COMMA OR CR
0941   2144 C9 A0       	CMP	#$A0		;IS IT BLANK
0942   2146 F0 F7       	BEQ	GNBC		;BR IF BLANK
0943   2148 60          	RTS			;DONE
0944   2149             ;
0945   2149             ;	CLRCCB  CLEAR CCB
0946   2149             ;
0947   2149             CLRCCB
0948   2149 A9 00       	LDA	#0
0949   214B A0 16       	LDY	#CCBLEN		;CCBLENGTH
0950   214D 99 25 35    CLC1	STA	CCB-1,Y		;CLEAR BYTE
0951   2150 88          	DEY
0952   2151 D0 FA       	BNE	CLC1
0953   2153 60          	RTS

Page     21    SHEP	APPLE DOS

0954   2154             	PAGE
0955   2154             ;
0956   2154             ;	GETNUM  COVERT ASCII INPUT TO NUMERIC
0957   2154             ;
0958   2154             GETNUM
0959   2154 A9 00       	LDA	#0		;CLEAR WORK AREA
0960   2156 85 44       	STA	CNUM
0961   2158 85 45       	STA	CNUM+1
0962   215A 20 3F 21    	JSR	GNBC
0963   215D 08          	PHP
0964   215E C9 A4       	CMP	#$A4
0965   2160 F0 3E       	BEQ	HEXNUM
0966   2162 28          	PLP
0967   2163 4C 69 21    	JMP	GN2A
0968   2166             ;
0969   2166 20 3F 21    GN2	JSR	GNBC		;GET NEXT NON BLANK
0970   2169             GN2A
0971   2169 D0 06       	BNE	GN3		;BR NOT COMMA OR CR
0972   216B A6 44       	LDX	CNUM		;X=RESULT LOW
0973   216D A5 45       	LDA	CNUM+1		;Y=RESULT HI
0974   216F 18          	CLC
0975   2170 60          	RTS			;DONE
0976   2171             ;
0977   2171 38          GN3	SEC
0978   2172 E9 B0       	SBC	#$B0		;SUBTRACT ASCII 0
0979   2174 30 21       	BMI	GN4		;BR IF NOT NUM
0980   2176 C9 0A       	CMP	#10
0981   2178 B0 1D       	BCS	GN4		;BR IF NOT NUM
0982   217A 20 99 21    	JSR	GN5		;OLD*2
0983   217D 65 44       	ADC	CNUM		;PLUS NEW
0984   217F AA          	TAX
0985   2180 A9 00       	LDA	#0
0986   2182 65 45       	ADC	CNUM+1
0987   2184 A8          	TAY
0988   2185 20 99 21    	JSR	GN5		;OLD*4
0989   2188 20 99 21    	JSR	GN5		;OLD*8
0990   218B 8A          	TXA			;OLD*8 + OLD*2 + NEW
0991   218C 65 44       	ADC	CNUM
0992   218E 85 44       	STA	CNUM		;=OLD*10 + NEW
0993   2190 98          	TYA
0994   2191 65 45       	ADC	CNUM+1
0995   2193 85 45       	STA	CNUM+1
0996   2195 90 CF       	BCC	GN2
0997   2197             ;
0998   2197             GN4
0999   2197 38          	SEC
1000   2198 60          	RTS			;DONE
1001   2199             GN5
1002   2199 06 44       	ASL	CNUM		;CNUM * 2
1003   219B 26 45       	ROL	CNUM+1
1004   219D B0 F8       	BCS	GN4
1005   219F 60          	RTS

Page     22    SHEP	APPLE DOS

1006   21A0             	PAGE
1007   21A0             ;
1008   21A0             HEXNUM
1009   21A0 28          	PLP
1010   21A1             HN0
1011   21A1 20 3F 21    	JSR	GNBC		;GO GET CHAR
1012   21A4 F0 C3       	BEQ	GN2A		;BR IF CR OR COMMA
1013   21A6             ;
1014   21A6 38          	SEC
1015   21A7 E9 B0       	SBC	#$B0		;CHAR  ASCII0
1016   21A9 30 EC       	BMI	GN4		;BR IF LTO
1017   21AB C9 0A       	CMP	#10		;IS IT LT10
1018   21AD 90 08       	BCC	HN1		;BR IF LT
1019   21AF E9 07       	SBC	#$7		;SUB 7 FOR ASCII A
1020   21B1 30 E4       	BMI	GN4		;BR IF LT A
1021   21B3 C9 10       	CMP	#16		;TEST GT 15
1022   21B5 B0 E0       	BCS	GN4		;BR GT 15
1023   21B7 20 99 21    HN1	JSR	GN5		;OLD*2
1024   21BA 20 99 21    	JSR	GN5		;OLD*4
1025   21BD 20 99 21    	JSR	GN5		;OLD*8
1026   21C0 20 99 21    	JSR	GN5		;OLD*16
1027   21C3 05 44       	ORA	CNUM		;OR IN NEW
1028   21C5 85 44       	STA	CNUM		;SAVE NEW
1029   21C7 4C A1 21    	JMP	HN0		;GO FOR NEXT CHAR

Page     23    SHEP	APPLE DOS

1030   21CA             	PAGE
1031   21CA             ;
1032   21CA             ;	EPR  EXECUTE PR#
1033   21CA             ;
1034   21CA             EPR
1035   21CA A5 44       	LDA	CNUM		;GET PORT
1036   21CC 4C 95 FE    	JMP	OUTPRT		;GO DO IT
1037   21CF             ;
1038   21CF             ;	EIN  EXECUTE IN#
1039   21CF             ;
1040   21CF             EIN
1041   21CF A5 44       	LDA	CNUM		;GET PORT
1042   21D1 4C 8B FE    	JMP	INPRT		;GO DO IT
1043   21D4             ;
1044   21D4             ;	EMON  EXECUTE MONITOR CMD
1045   21D4             ;
1046   21D4             EMON
1047   21D4 AD D8 29    	LDA	MONMOD		;GET CURRETN BITS
1048   21D7 0D EE 29    	ORA	IMBITS		;OR IN NEW BITS
1049   21DA 8D D8 29    	STA	MONMOD		;SET NEW MODE
1050   21DD 60          	RTS
1051   21DE             ;
1052   21DE             ;	ENOMON  EXECUTE NO MONITOR CMD
1053   21DE             ;
1054   21DE             ENOMON
1055   21DE 2C EE 29    	BIT	IMBITS
1056   21E1 50 03       	BVC	ENM1
1057   21E3 20 7A 1F    	JSR	PRCRIF
1058   21E6             ENM1
1059   21E6 A9 70       	LDA	#$70
1060   21E8 4D EE 29    	EOR	IMBITS		;INVERT INPUT BITS
1061   21EB 2D D8 29    	AND	MONMOD		;AND WITH CURRENT
1062   21EE 8D D8 29    	STA	MONMOD		;SET NEW MODE
1063   21F1 60          	RTS

Page     24    SHEP	APPLE DOS

1064   21F2             	PAGE
1065   21F2             ;
1066   21F2             ; 	EMAXF  EXECUTE MAX FILES
1067   21F2             ;
1068   21F2             EMAXF
1069   21F2 A9 00       	LDA	#0		;RESET EXECUTE
1070   21F4 8D 2D 2A    	STA	ESTATE
1071   21F7 A5 44       	LDA	CNUM		;SAVE NEW NO FILES
1072   21F9 48          	PHA
1073   21FA 20 BE 22    	JSR	CLALL		;GO CLOSE ALL TBLS
1074   21FD 68          	PLA
1075   21FE 8D D1 29    	STA	CNFTBS		;SET NEW NO FILE TBLS
1076   2201 4C 67 27    	JMP	BLDFTB		;GO BUILD NEW ONES
1077   2204             ;
1078   2204             ;	EDEL  DELETE A FILE
1079   2204             ;
1080   2204             EDEL
1081   2204 A9 05       	LDA	#CRQDEL		;DELETE REQUEST
1082   2206 20 51 22    	JSR	OPEN		;GO OPEN
1083   2209 20 F7 26    	JSR	FILSRC		;FIND FILE
1084   220C A0 00       	LDY	#0
1085   220E 98          	TYA
1086   220F 91 40       	STA	(ZPGWRK),Y	;RESET FN
1087   2211 60          	RTS
1088   2212             ;
1089   2212             ;	ELOCK  LOCK A FILE
1090   2212             ;
1091   2212             ELOCK
1092   2212 A9 07       	LDA	#CRQLCK		;SET LOCK
1093   2214 D0 02       	BNE	ELGO
1094   2216             ;
1095   2216             ;	EUNLK  UNLOCK A FILE
1096   2216             ;
1097   2216             EUNLK
1098   2216 A9 08       	LDA	#CRQUNL		;SET UNLOCK
1099   2218             ELGO
1100   2218 20 51 22    	JSR	OPEN		;OPEN FILE & UNLOCK
1101   221B 20 42 23    	JSR	TSTFNF
1102   221E 4C 91 22    	JMP	ECLOSE
1103   2221             ;
1104   2221             ;	EVAR  VERIFY A FILE
1105   2221             ;
1106   2221             EVAR
1107   2221 A9 0C       	LDA	#CRQVAR		;SET VARIFY
1108   2223 D0 F3       	BNE	ELGO

Page     25    SHEP	APPLE DOS

1109   2225             	PAGE
1110   2225             ;
1111   2225             ;	EREN  RENAME A FILE
1112   2225             ;
1113   2225             EREN
1114   2225 AD 08 1D    	LDA	FN2ADR		;MOVE FILE NAME2
1115   2228 8D 28 35    	STA	CCBFN2
1116   222B AD 09 1D    	LDA	FN2ADR+1
1117   222E 8D 29 35    	STA	CCBFN2+1
1118   2231 A9 09       	LDA	#CRQRNM
1119   2233 8D DD 29    	STA	TEMP1A		;SET RENAME
1120   2236 20 6F 22    	JSR	EO3		;GO OPEN AND RENAME
1121   2239 4C 91 22    	JMP	ECLOSE		;GO CLOSE
1122   223C             ;
1123   223C             ;	EAPND  OPEN FILE FOR APPEND
1124   223C             ;
1125   223C             EAPND
1126   223C 20 4F 22    	JSR	EOPEN		;GO OPEN
1127   223F A9 06       	LDA	#CREFNF
1128   2241 CD 30 35    	CMP	CCBSTA		;IF FILE CREATED
1129   2244 D0 01       	BNE	AP1
1130   2246 60          	RTS
1131   2247             AP1
1132   2247 20 1D 26    	JSR	RBYTE		;READ A BYTE
1133   224A D0 FB       	BNE	AP1		;BR IF NOT ZERO
1134   224C             ;
1135   224C 4C FB 24    	JMP	RWP3		;GO RE-POSITION

Page     26    SHEP	APPLE DOS

1136   224F             	PAGE
1137   224F             ;
1138   224F             ;	EOPEN  OPEN A FILE
1139   224F             ;
1140   224F             EOPEN
1141   224F A9 01       	LDA	#CRQOPN
1142   2251             OPEN
1143   2251 8D DD 29    	STA	TEMP1A
1144   2254 AD E6 29    	LDA	CL		;IF NO LENGTH ENTERED
1145   2257 D0 0A       	BNE	EO1		;THEN SET DEFAULT OF 1
1146   2259 AD E7 29    	LDA	CL+1
1147   225C D0 05       	BNE	EO1
1148   225E A9 01       	LDA	#1
1149   2260 8D E6 29    	STA	CL
1150   2263             EO1
1151   2263 AD E6 29    	LDA	CL		;MOVE REC LENGTH
1152   2266 8D 28 35    	STA	CCBRLN
1153   2269 AD E7 29    	LDA	CL+1
1154   226C 8D 29 35    	STA	CCBRLN+1
1155   226F             EO3
1156   226F 20 91 22    	JSR	ECLOSE		;GO CLOSE IF OPEN
1157   2272             EO4
1158   2272 A5 45       	LDA	CNUM+1		;GET AVALL ENTRY
1159   2274 D0 03       	BNE	EO5		;BR IF ONE AVAIL
1160   2276 4C 5D 26    	JMP	ENFA		;DONE  NO FILES AVAIL
1161   2279             EO5
1162   2279 85 41       	STA	ZPGWRK+1	;MOVE AVAIL SLOT TO ZPG
1163   227B A5 44       	LDA	CNUM
1164   227D 85 40       	STA	ZPGWRK
1165   227F             EO6
1166   227F 20 D6 26    	JSR	MVFN1		;GO MOVE FILE NAME
1167   2282 20 E1 26    	JSR	MVBUFP		;GO MOVE BUF PTRS
1168   2285 20 AD 26    	JSR	OPNSUP		;GO SET UP OPEN
1169   2288 AD DD 29    	LDA	TEMP1A		;SET OPEN REG
1170   228B 8D 26 35    	STA	CCBREQ
1171   228E 4C 39 26    	JMP	DOSGO		;GO OPEN

Page     27    SHEP	APPLE DOS

1172   2291             	PAGE
1173   2291             ;
1174   2291             ;	ECLOSE  EXECUTE CLOSE FILE COMMAND
1175   2291             ;
1176   2291             ECLOSE
1177   2291 AD EF 29    	LDA	FNAME1
1178   2294 C9 A0       	CMP	#$A0
1179   2296 F0 26       	BEQ	CLALL
1180   2298 20 F7 26    	JSR	FILSRC		;GO FIND FILE
1181   229B B0 06       	BCS	ECL1		;BR IF NOT FOUND
1182   229D 20 A4 22    	JSR	CLOSE		;GO CLOSE
1183   22A0 4C 91 22    	JMP	ECLOSE		;GO SEE IF ANY MORE OPEN
1184   22A3 60          ECL1	RTS
1185   22A4             ;
1186   22A4             ;	CLOSE  CLOSE A FILE
1187   22A4             ;
1188   22A4             CLOSE
1189   22A4 20 42 27    	JSR	TSTEXC
1190   22A7 D0 05       	BNE	CLX
1191   22A9 A9 00       	LDA	#0
1192   22AB 8D 2D 2A    	STA	ESTATE
1193   22AE             CLX
1194   22AE A0 00       	LDY	#0		;CLEAR 1ST FN
1195   22B0 98          	TYA			;CHAR TO ZERO
1196   22B1 91 40       	STA	(ZPGWRK),Y
1197   22B3 20 E1 26    	JSR	MVBUFP		;MOVE BUFFER PTRS
1198   22B6 A9 02       	LDA	#CRQCLS		;SET CLOSE
1199   22B8 8D 26 35    	STA	CCBREQ
1200   22BB 4C 39 26    	JMP	DOSGO		;GO CLOSE
1201   22BE             ;
1202   22BE             ;	CLALL  CLOSE ALL FILES
1203   22BE             ;
1204   22BE             CLALL
1205   22BE 20 25 27    	JSR	TSINIT		;GO INIT FILE SEARCH
1206   22C1 D0 05       	BNE	CL1
1207   22C3             CL0
1208   22C3 20 2D 27    	JSR	TSNXT		;NEXT ENTRY
1209   22C6 F0 10       	BEQ	CL2		;BR IF NO MORE
1210   22C8             CL1
1211   22C8 20 42 27    	JSR	TSTEXC
1212   22CB F0 F6       	BEQ	CL0
1213   22CD 20 3D 27    	JSR	TSTOPN		;GOL TEST OPEN
1214   22D0 F0 F1       	BEQ	CL0		;BR NOT OPEN
1215   22D2 20 A4 22    	JSR	CLOSE		;GO CLOSE
1216   22D5 4C BE 22    	JMP	CLALL		;START OVER
1217   22D8 60          CL2	RTS			;DONE

Page     28    SHEP	APPLE DOS

1218   22D9             	PAGE
1219   22D9             ;
1220   22D9             ;	EBSV  EXECUTE BINARY SAVE
1221   22D9             ;
1222   22D9             EBSV
1223   22D9 A9 09       	LDA	#A+L		;IF A+L
1224   22DB 2D DF 29    	AND	INOPTS
1225   22DE C9 09       	CMP	#A+L	
1226   22E0 F0 03       	BEQ	EBSV1
1227   22E2 4C B8 1F    	JMP	CNF		;THEN ERROR
1228   22E5             EBSV1
1229   22E5 A9 04       	LDA	#4		;SET BINARY FILE
1230   22E7 20 84 23    	JSR	SV1		;GO OPEN & TEST
1231   22EA AD ED 29    	LDA	CA+1		;OUTPUTADR OF BLOCK
1232   22ED AC EC 29    	LDY	CA
1233   22F0 20 8F 23    	JSR	SV2
1234   22F3 AD E7 29    	LDA	CL+1		;GO OPEN AND TEST
1235   22F6 AC E6 29    	LDY	CL
1236   22F9 20 8F 23    	JSR	SV2		;OUTPUT LENGTH
1237   22FC AD ED 29    	LDA	CA+1		;GET ADR GIVEN
1238   22FF AC EC 29    	LDY	CA
1239   2302 4C AE 23    	JMP	SV3		;OUTPUT BLOCK
1240   2305             ;
1241   2305             ;	EBLD  EXECUTE BINARY LOAD
1242   2305             ;
1243   2305             EBLD
1244   2305 20 4F 22    	JSR	EOPEN
1245   2308 20 42 23    	JSR	TSTFNF
1246   230B             EBLD2
1247   230B A9 7F       	LDA	#$7F
1248   230D 2D 2D 35    	AND	CCBFUC
1249   2310 C9 04       	CMP	#4
1250   2312 F0 03       	BEQ	EBLD3
1251   2314 4C 69 26    	JMP	ENBF
1252   2317             EBLD3
1253   2317 A9 04       	LDA	#4		;SET BINARY FILE
1254   2319 20 84 23    	JSR	SV1		;GO OPEN $ TEST
1255   231C 20 30 24    	JSR	LD2		;GO GET ADR
1256   231F AA          	TAX
1257   2320 AD DF 29    	LDA	INOPTS
1258   2323 29 01       	AND	#A		;IF ADR NOT GIVEN
1259   2325 D0 06       	BNE	EBLD1
1260   2327 8E EC 29    	STX	CA		;THEN USE ADR FROM FILE
1261   232A 8C ED 29    	STY	CA+1
1262   232D             EBLD1
1263   232D 20 30 24    	JSR	LD2		;GET LENGTH
1264   2330 AE EC 29    	LDX	CA		;GET GIVEN ADR
1265   2333 AC ED 29    	LDY	CA+1
1266   2336 4C 61 24    	JMP	LD3		;GO GET BLOCK
1267   2339             ;
1268   2339             ;	EBRUN  EXECUTE BINARY RUN
1269   2339             ;
1270   2339             EBRUN
1271   2339 20 05 23    	JSR	EBLD		;GO LOAD FILE
1272   233C 20 E4 27    	JSR	MVCSW		;GO RESTORE CHAR I/O SW
1273   233F 6C EC 29    	JMP	(CA)		;GO EXEC THE STUFF
1274   2342 A9 06       TSTFNF	LDA	#CREFNF		;FILE NOT FOUND ERROR CODE
1275   2344 CD 30 35    	CMP	CCBSTA		;TEST FILE NOT FOUND
1276   2347 F0 01       	BEQ	FNF		;BR IF FILE NOT FOUND
1277   2349 60          	RTS			;FILE FOUND, RETURN
1278   234A 4C CF 23    FNF	JMP	KLUTZ		;GO FIX THINGS

Page     29    SHEP	APPLE DOS

1279   234D             	PAGE
1280   234D             ;
1281   234D             ;	ESAVE  EXECUTE SAVE REQUEST
1282   234D             ;
1283   234D             ESAVE
1284   234D AD 30 2A    	LDA	ASIBSW		;IF IB THEN
1285   2350 F0 19       	BEQ	EIBSV		;GO TO IB SAVE
1286   2352 A9 02       	LDA	#2		;GET APPLESOFT PGM
1287   2354 20 84 23    	JSR	SV1		;GO OPEN AND TEST
1288   2357             ;
1289   2357 38          	SEC			;BLOCK LENGTH
1290   2358 A5 AF       	LDA	ASEOP		;=EOP-SOP
1291   235A E5 67       	SBC	ASSOP
1292   235C A8          	TAY
1293   235D A5 B0       	LDA	ASEOP+1
1294   235F E5 68       	SBC	ASSOP+1
1295   2361 20 8F 23    	JSR	SV2		;GO OUTPUT LENGTH
1296   2364             ;
1297   2364 A5 68       	LDA	ASSOP+1		;BLOCK ADR
1298   2366 A4 67       	LDY	ASSOP		;=SOP
1299   2368 4C AE 23    	JMP	SV3		;GO OUTPUT BLOCK
1300   236B             ;
1301   236B             EIBSV
1302   236B A9 01       	LDA	#1		;SET IB PGM
1303   236D 20 84 23    	JSR	SV1		;GO OPEN AND TEST
1304   2370             ;
1305   2370 38          	SEC			;BLOCK LENGTH
1306   2371 A5 4C       	LDA	IBHMEM		;=HIMEM-SOP
1307   2373 E5 CA       	SBC	IBSOP
1308   2375 A8          	TAY
1309   2376 A5 4D       	LDA	IBHMEM+1
1310   2378 E5 CB       	SBC	IBSOP+1
1311   237A 20 8F 23    	JSR	SV2		;GO OUTPUT LENGTH
1312   237D             ;
1313   237D A5 CB       	LDA	IBSOP+1		;BLOCK ADR
1314   237F A4 CA       	LDY	IBSOP		;=SOP
1315   2381 4C AE 23    	JMP	SV3		;GO OUTPUT
1316   2384             ;
1317   2384             SV1
1318   2384             SV1A
1319   2384 8D 2D 35    	STA	CCBFUC		;SET BLOCK	PGM TYPE
1320   2387 48          	PHA			;SAVE PGM TYPE
1321   2388 20 4F 22    	JSR	EOPEN		;GO OPEN FILE
1322   238B 68          	PLA			;GET SAVE TYPE
1323   238C 4C 57 27    	JMP	TSTFUC		;GO CHECK
1324   238F             ;
1325   238F             SV2
1326   238F 8C 2C 35    	STY	CCBBLN		;SET BLOCK LENGTH
1327   2392 8C 2E 35    	STY	CCBDAT		;AND DATA BYTE
1328   2395 8D 2D 35    	STA	CCBBLN+1
1329   2398 A9 04       	LDA	#CRQWR		;INDICATE WRITE
1330   239A 8D 26 35    	STA	CCBREQ
1331   239D A9 01       	LDA	#CRMNBT		;NEXT BYTE
1332   239F 8D 27 35    	STA	CCBRQM
1333   23A2 20 39 26    	JSR	DOSGO		;GO WRITE
1334   23A5 AD 2D 35    	LDA	CCBBLN+1	;OTHER BYTE TOO
1335   23A8 8D 2E 35    	STA	CCBDAT
1336   23AB 4C 39 26    	JMP	DOSGO
1337   23AE             ;
1338   23AE 8C 2E 35    SV3	STY	CCBBBA		;SET BLOCK ADR
1339   23B1 8D 2F 35    	STA	CCBBBA+1
1340   23B4 A9 02       	LDA	#CRMNBL		;INDICATE BLOCK I/L
1341   23B6 8D 27 35    	STA	CCBRQM
1342   23B9 20 39 26    	JSR	DOSGO		;GO DO IT
1343   23BC 4C 91 22    	JMP	ECLOSE		;CLOSE FILE

Page     30    SHEP	APPLE DOS

1344   23BF             	PAGE
1345   23BF 4C 65 26    NBPER	JMP	ERNU1
1346   23C2             ;
1347   23C2             ;	ELOAD  EXECUTE LOAD REQUEST
1348   23C2             ;
1349   23C2             ELOAD
1350   23C2 20 BE 22    	JSR	CLALL		;GO CLOSE ALL
1351   23C5 20 4F 22    	JSR	EOPEN		;OPEN FILE
1352   23C8 A9 06       	LDA	#CREFNF
1353   23CA CD 30 35    	CMP	CCBSTA		;WAS FILE FOUND
1354   23CD D0 08       	BNE	ELD1		;BR IF FOUND
1355   23CF             ;
1356   23CF 20 04 22    KLUTZ	JSR	EDEL		;DELETE NEW FILE
1357   23D2 A9 06       	LDA	#CREFNF		;FILE NOT FOUND MSG
1358   23D4 4C 6B 26    	JMP	ERROR		;GO
1359   23D7             ;
1360   23D7             ELD1
1361   23D7 A9 7F       	LDA	#$7F		;MASK PROTECT BIT
1362   23D9 2D 2D 35    	AND	CCBFUC		;OUT OF FUC
1363   23DC F0 E1       	BEQ	NBPER		;BR IF ERROR
1364   23DE 29 03       	AND	#$03		;ISOLOLATE IB & AS
1365   23E0 F0 DD       	BEQ	NBPER		;BR IF ERROR
1366   23E2 8D 2D 35    	STA	CCBFUC		;SAVE IB/AS ONLY
1367   23E5 AD 30 2A    	LDA	ASIBSW		;IF IB THEN
1368   23E8 F0 22       	BEQ	EIBL		;GO TO IB LOAD
1369   23EA A9 02       	LDA	#2
1370   23EC 20 73 24    	JSR	LD1		;GO OPEN AND TEST
1371   23EF             ;
1372   23EF 20 30 24    	JSR	LD2		;GO GET BLOCK LENGTH
1373   23F2             ;
1374   23F2 18          	CLC
1375   23F3 65 67       	ADC	ASSOP		;ADD BLOCK LENGTH TO SOP
1376   23F5 AA          	TAX
1377   23F6 98          	TYA
1378   23F7 65 68       	ADC	ASSOP+1
1379   23F9             ;
1380   23F9 C5 74       	CMP	ASHM1+1		;IF BL+SOP >=HMEM
1381   23FB B0 70       	BCS	MFULL		;THEN WONT FIT
1382   23FD             ;
1383   23FD             EASL1
1384   23FD 85 B0       	STA	ASEOP+1		;SET NEW EOP ADR
1385   23FF 85 6A       	STA	ASEOP2+1
1386   2401 86 AF       	STX	ASEOP
1387   2403 86 69       	STX	ASEOP2
1388   2405 A6 67       	LDX	ASSOP		;GET ADR WHERE TO LOAD
1389   2407 A4 68       	LDY	ASSOP+1
1390   2409 4C 61 24    	JMP	LD3		;GO LOAD
1391   240C             ;
1392   240C             EIBL
1393   240C A9 01       	LDA	#1		;SET IB PGM
1394   240E 20 73 24    	JSR	LD1		;GO OPEN AND TEST
1395   2411             ;
1396   2411 20 30 24    	JSR	LD2		;GO GET BLOCK LENGTH
1397   2414             ;
1398   2414 38          	SEC			;HMEM  BLOCK LENGTH
1399   2415 A5 4C       	LDA	IBHMEM		;IS NEW SOP
1400   2417 ED DA 29    	SBC	SVBL
1401   241A AA          	TAX
1402   241B A5 4D       	LDA	IBHMEM+1
1403   241D ED DB 29    	SBC	SVBL+1
1404   2420 90 4B       	BCC	MFULL
1405   2422 A8          	TAY
1406   2423             ;
1407   2423 C4 4B       	CPY	IBLMEM+1	;IF NEW SOP <= LMEM
1408   2425 90 46       	BCC	MFULL
1409   2427 F0 44       	BEQ	MFULL
1410   2429 84 CB       	STY	IBSOP+1		;SET NEW SOP
1411   242B 86 CA       	STX	IBSOP
1412   242D 4C 61 24    	JMP	LD3
1413   2430             ;
1414   2430             LD2
1415   2430 AD 0A 1D    	LDA	SVBLA		;MOVE ADR OF WHERE
1416   2433 8D 2E 35    	STA	CCBBBA		;TO PUT DATA TO
1417   2436 AD 0B 1D    	LDA	SVBLA+1		;CCBN
1418   2439 8D 2F 35    	STA	CCBBBA+1
1419   243C A9 00       	LDA	#0
1420   243E 8D 2D 35    	STA	CCBBLN+1	;READ INTO
1421   2441 A9 02       	LDA	#2
1422   2443 8D 2C 35    	STA	CCBBLN
1423   2446 A9 03       	LDA	#CRQRD		;READ
1424   2448 8D 26 35    	STA	CCBREQ
1425   244B A9 02       	LDA	#CRMNBL		;BLOCK
1426   244D 8D 27 35    	STA	CCBRQM
1427   2450 20 39 26    	JSR	DOSGO
1428   2453 AD DB 29    	LDA	SVBL+1
1429   2456 8D 2D 35    	STA	CCBBLN+1
1430   2459 A8          	TAY
1431   245A AD DA 29    	LDA	SVBL
1432   245D 8D 2C 35    	STA	CCBBLN
1433   2460 60          	RTS
1434   2461             ;
1435   2461             LD3
1436   2461 8E 2E 35    	STX	CCBBBA		;SET BLOCK ADR
1437   2464 8C 2F 35    	STY	CCBBBA+1
1438   2467 20 39 26    	JSR	DOSGO		;GEET BLOCK
1439   246A 4C 91 22    	JMP	ECLOSE		;GO CLOSE FILE
1440   246D             ;
1441   246D             MFULL
1442   246D 20 91 22    	JSR	ECLOSE		;GO CLOSE FILE
1443   2470 4C 61 26    	JMP	MFERR		;AND GIVE ERR MSG
1444   2473             LD1
1445   2473 CD 2D 35    	CMP	CCBFUC		;TEST TYPE
1446   2476 F0 1A       	BEQ	LD1C		;BR IF MATCH
1447   2478 AE D9 29    	LDX	CMDNO
1448   247B 8E DC 29    	STX	SVCMD
1449   247E 4A          	LSRA
1450   247F F0 03       	BEQ	LD1A		;BR IF PGM IS AS
1451   2481 4C 51 25    	JMP	EINT		;GO FOR INTO BASIC
1452   2484             ;
1453   2484             LD1A
1454   2484 A2 1D       	LDX	#29		;SAVE FILE NAME
1455   2486 BD EF 29    LD1B	LDA	FNAME1,X	;INCASE IS RAM APPLESOFT
1456   2489 9D 0D 2A    	STA	FNAME2,X	
1457   248C CA          	DEX
1458   248D 10 F7       	BPL	LD1B
1459   248F 4C 2D 25    	JMP	EAS		;GO FOR AS
1460   2492             ;
1461   2492 60          LD1C	RTS

Page     31    SHEP	APPLE DOS

1462   2493             	PAGE
1463   2493             ;
1464   2493             ;	ERUN  EXECUTE RUN REQUEST
1465   2493             ;
1466   2493             ERUN
1467   2493 20 C2 23    	JSR	ELOAD		;LOAD PGM
1468   2496 20 7A 1F    	JSR	PRCRIF
1469   2499 20 E4 27    	JSR	MVCSW		;GO RESTORE CHAR I/O SW
1470   249C 6C 58 1D    	JMP	(RUN)
1471   249F             ;
1472   249F             ;	IBRUN  INT BASIC RUN
1473   249F             ;
1474   249F             IBRUN
1475   249F A5 4A       	LDA	IBLMEM		;RESET START OF VARS
1476   24A1 85 CC       	STA	IBSOV
1477   24A3 A5 4B       	LDA	IBLMEM+1
1478   24A5 85 CD       	STA	IBSOV+1
1479   24A7 6C 56 1D    	JMP	(CHAIN)
1480   24AA             ;
1481   24AA             ;	EHCAIN  EXECUTE CHAIN REQUEST
1482   24AA             ;
1483   24AA             ECHAIN
1484   24AA 20 C2 23    	JSR	ELOAD		;LOAD PGM
1485   24AD 20 7A 1F    	JSR	PRCRIF
1486   24B0 20 E4 27    	JSR	MVCSW		;GO RESTORE CHAR I/O SW
1487   24B3 6C 56 1D    	JMP	(CHAIN)
1488   24B6 20 65 D6    ASRUN1	JSR	$D665		;ROM
1489   24B9 4C D2 D7    	JMP	$D7D2
1490   24BC 20 65 0E    ASRUN2	JSR	$E65		;RAM
1491   24BF 4C D4 0F    	JMP	$FD4

Page     32    SHEP	APPLE DOS

1492   24C2             	PAGE
1493   24C2             ;
1494   24C2             ;	EWRITE  WRITE CMD EXECUTE
1495   24C2             ;
1496   24C2             EWRITE
1497   24C2 20 DB 24    	JSR	RWPOSN		;GO POSITION FILE IF REGD
1498   24C5 20 42 23    	JSR	TSTFNF
1499   24C8 A9 05       	LDA	#5
1500   24CA 8D CC 29    	STA	OSTATE		;SET OSTATE=5
1501   24CD 4C 34 1F    	JMP	CERTN		;DONE
1502   24D0             ;
1503   24D0             ;	EREAD  READ COMD EXECUTE
1504   24D0             ;
1505   24D0             EREAD
1506   24D0 20 DB 24    	JSR	RWPOSN		;GO POSITION FILE IF REGD
1507   24D3 A9 01       	LDA	#1
1508   24D5 8D CB 29    	STA	ISTATE		;SET ISTATE = DISK INPUT 
1509   24D8 4C 34 1F    	JMP	CERTN		;DONE
1510   24DB             ;
1511   24DB             ;	RWPOSN  POSITION FOR READ/WRITE
1512   24DB             ;
1513   24DB             RWPOSN
1514   24DB 20 F7 26    	JSR	FILSRC		;FIND THE FILE
1515   24DE 90 06       	BCC	RWP1		;BR IF FILE FOUND
1516   24E0 20 4F 22    	JSR	EOPEN		;GO OPEN FOR KLUTZ
1517   24E3 4C E9 24    	JMP	RWP2		;THEN SKIP NEXT LINE
1518   24E6             RWP1
1519   24E6 20 E1 26    	JSR	MVBUFP		;MOVE BUFF POINTERS
1520   24E9             RWP2
1521   24E9 AD DF 29    	LDA	INOPTS		;GET IN OPTIONS
1522   24EC 29 06       	AND	#R+B		;WAS IT B OR R
1523   24EE F0 13       	BEQ	RWPR		;BR IF NOT
1524   24F0 A2 03       	LDX	#3
1525   24F2 BD E8 29    RWP2A	LDA	CR,X		;MOVE REL REC
1526   24F5 9D 28 35    	STA	CCBRRN,X	;AND REL BYTE
1527   24F8 CA          	DEX
1528   24F9 10 F7       	BPL	RWP2A
1529   24FB             RWP3
1530   24FB A9 0A       	LDA	#CRQPOS		;INDICATE POSITION REQUIRED
1531   24FD 8D 26 35    	STA	CCBREQ
1532   2500 20 39 26    	JSR	DOSGO
1533   2503 60          RWPR	RTS			;DONE

Page     33    SHEP	APPLE DOS

1534   2504             	PAGE
1535   2504             ;
1536   2504             ;
1537   2504             ;	EINIT  EXECUTE INIT COMMAND
1538   2504             ;
1539   2504             EINIT
1540   2504 A9 40       	LDA	#V		;MUST HAVE
1541   2506 2D DF 29    	AND	INOPTS		;VOL OPTION
1542   2509 F0 13       	BEQ	INER
1543   250B AD E0 29    	LDA	CV
1544   250E F0 0E       	BEQ	INER		;BE GT 0
1545   2510 AD 0D 1D    	LDA	ASTART+1
1546   2513 8D 27 35    	STA	CCBBSA
1547   2516 A9 0B       	LDA	#CRQFMT
1548   2518 20 51 22    	JSR	OPEN
1549   251B 4C 4D 23    	JMP	ESAVE
1550   251E             ;
1551   251E 4C B8 1F    INER	JMP	CNF
1552   2521             ;
1553   2521             ;	ECAT  PRINT CATALOG
1554   2521             ;
1555   2521             ECAT
1556   2521 A9 06       	LDA	#CRQDIR
1557   2523 20 51 22    	JSR	OPEN		;GO PRETEND OPEN
1558   2526 AD 2A 35    	LDA	CCBVOL
1559   2529 8D E0 29    	STA	CV
1560   252C 60          	RTS

Page     34    SHEP	APPLE DOS

1561   252D             	PAGE
1562   252D             ;
1563   252D             ;	EAS  EXECUTE APPLESOFT REQUEST
1564   252D             ;
1565   252D             EAS
1566   252D A9 4C       	LDA	#ATSTV		;GET APPLESOFT TEST VALUE
1567   252F 20 5B 25    	JSR	SWTST		;GO SWITCH AND TEST
1568   2532 F0 24       	BEQ	GOINIT		;GO SWITCH AND TEST
1569   2534 A9 00       	LDA	#0
1570   2536 8D 30 2A    	STA	ASIBSW
1571   2539             ;
1572   2539             EAS0
1573   2539 A0 1E       	LDY	#30
1574   253B 20 3C 20    	JSR	CLRFNA
1575   253E A2 09       	LDX	#FASBL
1576   2540 BD 30 2A    EAS1	LDA	FASB-1,X	;MOVE SYSTEM FILE NAME
1577   2543 9D EE 29    	STA	FNAME1-1,X
1578   2546 CA          	DEX
1579   2547 D0 F7       	BNE	EAS1
1580   2549             ;
1581   2549             EAS2
1582   2549 A9 C0       	LDA	#$C0
1583   254B 8D CB 29    	STA	ISTATE		;FOR RAM APPLESOFT
1584   254E 4C 93 24    	JMP	ERUN		;GO LOAD AND RUN
1585   2551             ;
1586   2551             ;	EINT  EXECUTE INTEGER REQUEST
1587   2551             ;
1588   2551             EINT
1589   2551 A9 20       	LDA	#ITSTV		;GET IB TEST VALUE
1590   2553 20 5B 25    	JSR	SWTST		;GO SWITCH AND RUN
1591   2556 D0 D5       	BNE	EAS		;BR IF NOT IB
1592   2558             GOINIT
1593   2558 4C 7E 1D    	JMP	DBINIT		;GO INIT DOS
1594   255B             SWTST
1595   255B CD 00 E0    	CMP	AITSTL		;TEST CURRENT VALUE
1596   255E F0 0E       	BEQ	SWTR
1597   2560 8D 80 C0    	STA	$C080		;TRY SWITCH 1
1598   2563 CD 00 E0    	CMP	AITSTL		;TEST AGAIN
1599   2566 F0 06       	BEQ	SWTR		;BR IF NOW SAME
1600   2568 8D 81 C0    	STA	$C081		;TRY SWITCH 2
1601   256B CD 00 E0    	CMP	AITSTL		;TEST AND
1602   256E 60          SWTR	RTS
1603   256F             ;

Page     35    SHEP	APPLE DOS

1604   256F             	PAGE
1605   256F             ;
1606   256F             ;	EEXEC  EXEC CMD
1607   256F             ;
1608   256F             EEXEC
1609   256F 20 4F 22    	JSR	EOPEN		;OPEN FILE
1610   2572 20 42 23    	JSR	TSTFNF
1611   2575 AD C9 29    	LDA	CFTABA		;MOVE TABLE POINTERS
1612   2578 8D 2E 2A    	STA	EFTABA
1613   257B AD CA 29    	LDA	CFTABA+1
1614   257E 8D 2F 2A    	STA	EFTABA+1
1615   2581 AD EF 29    	LDA	FNAME1		;USE FILENAME
1616   2584 8D 2D 2A    	STA	ESTATE		;SET EX STATE NON ZERO
1617   2587 D0 11       	BNE	EXP2
1618   2589             ;
1619   2589             ;
1620   2589             ;	EPOS  EXECUTE POSITION
1621   2589             ;
1622   2589             EPOS
1623   2589 20 F7 26    	JSR	FILSRC
1624   258C 90 09       	BCC	EXP1
1625   258E 20 4F 22    	JSR	EOPEN
1626   2591 20 42 23    	JSR	TSTFNF
1627   2594 4C 9A 25    	JMP	EXP2
1628   2597 20 E1 26    EXP1	JSR	MVBUFP
1629   259A             EXP2
1630   259A AD DF 29    	LDA	INOPTS		;GET OPTIONS
1631   259D 29 04       	AND	#R		;TEST R
1632   259F F0 1B       	BEQ	EX2		;BR NOT R
1633   25A1             ;
1634   25A1 AD E8 29    EX0	LDA	CR		;IF CR NOT ZERO
1635   25A4 D0 08       	BNE	EX1A		;THEN DECREMENT
1636   25A6 AE E9 29    	LDX	CR+1
1637   25A9 F0 11       	BEQ	EX2
1638   25AB CE E9 29    	DEC	CR+1
1639   25AE CE E8 29    EX1A	DEC	CR
1640   25B1 20 1D 26    EX1	JSR	RBYTE		;AND READ A RCORD
1641   25B4 F0 38       	BEQ	ICFD4
1642   25B6 C9 8D       	CMP	#$8D		;UNTIL CR
1643   25B8 D0 F7       	BNE	EX1
1644   25BA F0 E5       	BEQ	EX0		;THEN TEST CR AGAIN
1645   25BC             ;
1646   25BC 60          EX2	RTS			;DONE

Page     36    SHEP	APPLE DOS

1647   25BD             	PAGE
1648   25BD             ;
1649   25BD             ;	OCTD  OUTPUT A CHAR TO DISK
1650   25BD             ;
1651   25BD             OCTD
1652   25BD 20 F9 25    	JSR	TSTRUN		;GO TEST RUN
1653   25C0 B0 48       	BCS	ICFDB
1654   25C2 AD D6 29    	LDA	SVA		;CHAR IN SAVED ACU
1655   25C5 8D 2E 35    	STA	CCBDAT		;PUT INTO CCBDATA AREA
1656   25C8 A9 04       	LDA	#CRQWR		;SET WRITE
1657   25CA 8D 26 35    	STA	CCBREQ
1658   25CD A9 01       	LDA	#CRMNBT		;SET NEXT BYTE
1659   25CF 8D 27 35    	STA	CCBRQM
1660   25D2 4C 39 26    	JMP	DOSGO		;GO WRITE BYTE
1661   25D5             ;
1662   25D5             ;	INCFD  INPUT A CHAR FROM DISK
1663   25D5             ;
1664   25D5             ICFD
1665   25D5 20 F9 25    	JSR	TSTRUN		;GO TEST RUN
1666   25D8 B0 30       	BCS	ICFDB
1667   25DA A9 06       	LDA	#6		;SET OUT STE = 6
1668   25DC             ICFD3
1669   25DC 8D CC 29    	STA	OSTATE		;TO CATCH ECHO
1670   25DF 20 1D 26    	JSR	RBYTE
1671   25E2 D0 0F       	BNE	ICFD1		;BR IF NOT ZERO CHAR
1672   25E4             ICCFD2
1673   25E4 20 A4 22    	JSR	CLOSE
1674   25E7 A9 03       	LDA	#3
1675   25E9 CD CC 29    	CMP	OSTATE
1676   25EC F0 08       	BEQ	ICFD0
1677   25EE             ICFD4
1678   25EE A9 05       	LDA	#CREEOF
1679   25F0 4C 6B 26    	JMP	ERROR		;GO TO ERROR
1680   25F3             ICFD1
1681   25F3 8D D6 29    	STA	SVA		;PUT INTO SAVED ACU
1682   25F6             ICFD0
1683   25F6 4C 69 1F    	JMP	ORTN		;GO RESTORE REGS AND RTS
1684   25F9             ;
1685   25F9             TSTRUN
1686   25F9 AD 30 2A    	LDA	ASIBSW		;GET AS/INT BASIC SWITCH
1687   25FC F0 06       	BEQ	TR1		;BR IF INT
1688   25FE A6 76       	LDX	$76		;TEST AS RUN
1689   2600 D0 06       	BNE	NOTRUN		;BR IF NOT RUN
1690   2602 18          TR0	CLC
1691   2603 60          	RTS
1692   2604             TR1
1693   2604 A5 D9       	LDA	$D9		;GET INT RUN FLAG
1694   2606 30 FA       	BMI	TR0		;BR IF RUN
1695   2608 38          NOTRUN	SEC
1696   2609 60          	RTS
1697   260A             ICFDB				;NOT RUN MODE
1698   260A 20 A4 22    	JSR	CLOSE		;GO CLOSE FILE
1699   260D 20 EE 26    	JSR	CLRSTS		;GO CLEAR STATES
1700   2610 4C 69 1F    	JMP	ORTN

Page     37    SHEP	APPLE DOS

1701   2613             	PAGE
1702   2613             ;
1703   2613             ;	NXTEXC  NEXT EXECUTE CHAR
1704   2613             ;
1705   2613             NXTEXC
1706   2613 20 2E 26    	JSR	MVEFTA
1707   2616 20 E1 26    	JSR	MVBUFP		;GO MOVE PTRS
1708   2619 A9 03       	LDA	#3
1709   261B D0 BF       	BNE	ICFD3
1710   261D             ;
1711   261D             ;	RBYTE  READ NEXT BYTE
1712   261D             ;
1713   261D             RBYTE
1714   261D A9 03       	LDA	#CRQRD		;SET READ
1715   261F 8D 26 35    	STA	CCBREQ
1716   2622 A9 01       	LDA	#CRMNBT		;SET NEXT BYTE
1717   2624 8D 27 35    	STA	CCBRQM
1718   2627 20 39 26    	JSR	DOSGO		;GO TO DOS
1719   262A AD 2E 35    	LDA	CCBDAT		;GET THE DATA BYTE
1720   262D 60          	RTS
1721   262E             MVEFTA
1722   262E AD 2F 2A    	LDA	EFTABA+1	;MOVE TABLE ADR
1723   2631 85 41       	STA	ZPGWRK+1	;NO ZPG
1724   2633 AD 2E 2A    	LDA	EFTABA
1725   2636 85 40       	STA	ZPGWRK
1726   2638 60          	RTS

Page     38    SHEP	APPLE DOS

1727   2639             	PAGE
1728   2639             ;
1729   2639             ;	DOSGO  GOTO DOS
1730   2639             ;
1731   2639             DOSGO
1732   2639 20 76 2A    	JSR	DOSENT		;GO TO DOS
1733   263C B0 01       	BCS	DG1		;BR IF ERROR
1734   263E 60          	RTS			;DONE
1735   263F             ;
1736   263F             DG1				;*** ERROR ***
1737   263F 20 F7 26    	JSR	FILSRC		;GET FILE TABLE
1738   2642 B0 05       	BCS	DG2		;BR IF NOT FOUND
1739   2644 A9 00       	LDA	#0
1740   2646 A8          	TAY
1741   2647 91 40       	STA	(ZPGWRK), Y	;CLOSE FILE HERE
1742   2649             DG2
1743   2649 AD 30 35    	LDA	CCBSTA		;GET STATUS OF I/O
1744   264C C9 05       	CMP	#CREEOF		;EOF ?
1745   264E D0 06       	BNE	DG3		;BR IF NOT
1746   2650 A2 00       	LDX	#0		;SET OTHER EIF
1747   2652 8E 2E 35    	STX	CCBDAT		;DONE
1748   2655 60          	RTS
1749   2656             DG3
1750   2656 4C 6B 26    	JMP	ERROR		;GO DO ERROR
1751   2659             ;

Page     39    SHEP	APPLE DOS

1752   2659             	PAGE
1753   2659             ;
1754   2659             ;	ERROR ROUTINE
1755   2659             ;
1756   2659 A9 0B       ESYNTX	LDA	#CREFLK+1
1757   265B D0 0E       	BNE	ERROR
1758   265D A9 0C       ENFA	LDA	#CREFLK+2
1759   265F D0 0A       	BNE	ERROR
1760   2661 A9 0E       MFERR	LDA	#CREFLK+4
1761   2663 D0 06       	BNE	ERROR
1762   2665 A9 0D       ERNU1	LDA	#CREFLK+3
1763   2667 D0 02       	BNE	ERROR
1764   2669 A9 0F       ENBF	LDA	#CREFLK+5
1765   266B             ;
1766   266B             ERROR
1767   266B 8D D6 29    	STA	SVA		;SAVE MSG NUMBER
1768   266E 20 EE 26    	JSR	CLRSTS
1769   2671 AD 30 2A    	LDA	ASIBSW		;GET AS/IN BASIC SWITCH
1770   2674 F0 04       	BEQ	ERNAS		;BR IF NOT APPLESOFT
1771   2676 A5 D8       	LDA	$D8		;GET ON ERR FLAG
1772   2678 30 10       	BMI	ERRTN		;BRT IF ON ERR IS GO
1773   267A             ERNAS
1774   267A A2 00       	LDX	#0
1775   267C 20 95 26    	JSR	EMPR		;GO OUTPUT
1776   267F AE D6 29    	LDX	SVA		;GET SAVE MSG
1777   2682 20 95 26    	JSR	EMPR		;GO OUTPUT MSG 
1778   2685 A2 10       	LDX	#CREFLK+6
1779   2687 20 95 26    	JSR	EMPR
1780   268A 20 E4 27    ERRTN	JSR	MVCSW		;GO MOVE CHAR I/ SW
1781   268D AE D6 29    	LDX	SVA
1782   2690 A9 03       	LDA	#03
1783   2692 6C 5A 1D    	JMP	(BREAK)
1784   2695             ;
1785   2695             EMPR
1786   2695 BD B8 29    	LDA	EMDTB,X		;GET ITS DISPL
1787   2698 AA          	TAX			;INTO X
1788   2699             EMPR1
1789   2699 8E DD 29    	STX	TEMP1A		;SAVE DISPL
1790   269C BD 04 29    	LDA	EMSG,X		;GET MSG CHAR
1791   269F 48          	PHA			;SAVE CHAR
1792   26A0 09 80       	ORA	#$80		;SET MSB ON
1793   26A2 20 77 1F    	JSR	ORTN1		;OUTPUT CHAR
1794   26A5 AE DD 29    	LDX	TEMP1A		;GET INDEX
1795   26A8 E8          	INX			;INCREMENT IT
1796   26A9 68          	PLA			;RE-LOAD CHAR
1797   26AA 10 ED       	BPL	EMPR1		;BR IF MORE CHARS
1798   26AC 60          	RTS			;DONE

Page     40    SHEP	APPLE DOS

1799   26AD             	PAGE
1800   26AD             ;
1801   26AD             ;	OPNSUP  OPEN SET UP
1802   26AD             ;
1803   26AD             OPNSUP	
1804   26AD AD E0 29    	LDA	CV		;VOLUME
1805   26B0 8D 2A 35    	STA	CCBVOL
1806   26B3 AD E2 29    	LDA	CD		;DRIVE
1807   26B6 8D 2B 35    	STA	CCBDRV
1808   26B9 AD E4 29    	LDA	CS		;SLOT
1809   26BC 8D 2C 35    	STA	CCBSLT
1810   26BF AD 06 1D    	LDA	FN1ADR		;FILENAME 1 ADR
1811   26C2 8D 2E 35    	STA	CCBFN1
1812   26C5 AD 07 1D    	LDA	FN1ADR+1
1813   26C8 8D 2F 35    	STA	CCBFN1+1
1814   26CB A5 40       	LDA	ZPGWRK
1815   26CD 8D C9 29    	STA	CFTABA
1816   26D0 A5 41       	LDA	ZPGWRK+1
1817   26D2 8D CA 29    	STA	CFTABA+1
1818   26D5 60          	RTS
1819   26D6             ;
1820   26D6             ;	MVFN1  MOVE FILE NAME 1 TO FILE PTR
1821   26D6             ;
1822   26D6             MVFN1
1823   26D6 A0 1D       	LDY	#29
1824   26D8 B9 EF 29    MVFN1A	LDA	FNAME1,Y
1825   26DB 91 40       	STA	(ZPGWRK),Y
1826   26DD 88          	DEY
1827   26DE 10 F8       	BPL	MVFN1A
1828   26E0 60          	RTS
1829   26E1             ;
1830   26E1             ;	MVBUFP  MOVE BUFFER PTRS TO CCB
1831   26E1             ;
1832   26E1             MVBUFP
1833   26E1 A0 1E       	LDY	#30
1834   26E3 B1 40       MVBP1	LDA	(ZPGWRK),Y
1835   26E5 99 14 35    	STA	CCBFCB-30,Y
1836   26E8 C8          	INY
1837   26E9 C0 26       	CPY	#38
1838   26EB D0 F6       	BNE	MVBP1
1839   26ED 60          	RTS
1840   26EE             ;
1841   26EE             ;	CLRSTS  CLEAR STATES
1842   26EE             ;
1843   26EE             CLRSTS
1844   26EE A0 00       	LDY	#0
1845   26F0 8C CB 29    	STY	ISTATE
1846   26F3 8C CC 29    	STY	OSTATE
1847   26F6 60          	RTS

Page     41    SHEP	APPLE DOS

1848   26F7             	PAGE
1849   26F7             ;
1850   26F7             ;	FILSRC  SEARCH FOR FILE NAME1
1851   26F7             ;
1852   26F7             FILSRC
1853   26F7 A9 00       	LDA	#0		;CLEAR SV AVAIL
1854   26F9 85 45       	STA	CNUM+1
1855   26FB             ;
1856   26FB 20 25 27    	JSR	TSINIT		;GO INIT SEARCH
1857   26FE 4C 06 27    	JMP	FLS1A
1858   2701 20 2D 27    FLS1	JSR	TSNXT		;LOOK AT NEXT
1859   2704 F0 1D       	BEQ	FLS4		;BR IF NO NEXT
1860   2706             ;
1861   2706 20 3D 27    FLS1A	JSR	TSTOPN		;GO TEST OPEN
1862   2709 D0 0A       	BNE	FLS2		;BR IF OPEN
1863   270B             ;
1864   270B A5 40       	LDA	ZPGWRK		;SAVE AVAIL ENTRY ADR
1865   270D 85 44       	STA	CNUM
1866   270F A5 41       	LDA	ZPGWRK+1
1867   2711 85 45       	STA	CNUM+1
1868   2713 D0 EC       	BNE	FLS1		;GO LOOK SOME MORE
1869   2715             ;
1870   2715 A0 1D       FLS2	LDY	#29		;FILE HAD 30 CHARS
1871   2717 B1 40       FLS3	LDA	(ZPGWRK),Y	;GET CHAR
1872   2719 D9 EF 29    	CMP	FNAME1,Y		;TEST CHAR
1873   271C D0 E3       	BNE	FLS1		;BR NOT
1874   271E 88          	DEY
1875   271F 10 F6       	BPL	FLS3		;LOOK AT 30 CHARS
1876   2721 18          	CLC			;FOUND
1877   2722 60          	RTS			;DONE
1878   2723             ;
1879   2723 38          FLS4	SEC			;NOT FOUND
1880   2724 60          	RTS			;DONE

Page     42    SHEP	APPLE DOS

1881   2725             	PAGE
1882   2725             ;
1883   2725             ;	TSINIT  INITIALIZE FOR FTAB SEARCH
1884   2725             ;	TSNXT  GET NEXT FTAB ENTRY
1885   2725             ;
1886   2725             TSINIT
1887   2725 AD 00 1D    	LDA	FTAB		;GET 1ST PTR ADR
1888   2728 AE 01 1D    	LDX	FTAB+1
1889   272B D0 0A       	BNE	TSST
1890   272D             TSNXT
1891   272D A0 25       	LDY	#37		;GET LINK
1892   272F B1 40       	LDA	(ZPGWRK),Y
1893   2731 F0 09       	BEQ	TSR		;BR IF NO LINK
1894   2733             ;
1895   2733 AA          	TAX
1896   2734 88          	DEY
1897   2735 B1 40       	LDA	(ZPGWRK),Y
1898   2737             TSST
1899   2737 86 41       	STX	ZPGWRK+1
1900   2739 85 40       	STA	ZPGWRK
1901   273B 8A          	TXA			;SET NE CC
1902   273C 60          TSR	RTS			;RTN
1903   273D             ;
1904   273D             ;	TSTOPN  TST FOR OPEN FILE
1905   273D             ;
1906   273D             TSTOPN
1907   273D A0 00       	LDY	#0		;GET 1ST CHAR OF FN
1908   273F B1 40       	LDA	(ZPGWRK),Y
1909   2741 60          	RTS
1910   2742             ;
1911   2742             ;	TSTEXC  TEST CURRENT FILE FOR EXECUTE
1912   2742             ;
1913   2742             TSTEXC
1914   2742 AD 2D 2A    	LDA	ESTATE		;IF ESTATE = 0
1915   2745 F0 0E       	BEQ	TXC1		;THEN NO EXECUTE FILE
1916   2747 AD 2E 2A    	LDA	EFTABA		;TEST CURRENT
1917   274A C5 40       	CMP	ZPGWRK
1918   274C D0 08       	BNE	TXC2		;IS NOT
1919   274E AD 2F 2A    	LDA	EFTABA+1
1920   2751 C5 41       	CMP	ZPGWRK+1
1921   2753 F0 01       	BEQ	TXC2		;IS
1922   2755 CA          TXC1	DEX			;IS NOT
1923   2756 60          TXC2	RTS			;DONE

Page     43    SHEP	APPLE DOS

1924   2757             	PAGE
1925   2757             ;
1926   2757             ;	TSTFUC  TEST FILE USE CODE FOR PGM
1927   2757             ;
1928   2757             TSTFUC
1929   2757 4D 2D 35    	EOR	CCBFUC
1930   275A F0 0A       	BEQ	TFUCR
1931   275C 29 7F       	AND	#$7F
1932   275E F0 06       	BEQ	TFUCR
1933   2760 20 91 22    	JSR	ECLOSE		;GO CLOSE THE SOB
1934   2763 4C 65 26    	JMP	ERNU1
1935   2766 60          TFUCR	RTS

Page     44    SHEP	APPLE DOS

1936   2767             	PAGE
1937   2767             ;
1938   2767             ;	BLDFTB  BUILD FILE TABLES
1939   2767             ;	TABLE MAP:
1940   2767             ;		HIMEM,SOP
1941   2767             ;		SBUFF N		(256)
1942   2767             ;		DBUFF N		(256)
1943   2767             ;		FTB   N		(FCBLEN)
1944   2767             ;		HEADER N	(38)
1945   2767             ;
1946   2767             ;
1947   2767             ;		SBUFF	1
1948   2767             ;		DBUFF	1
1949   2767             ;		FTB	1
1950   2767             ;		HEADER	1
1951   2767             ;		THIS PROGRAM
1952   2767             ;
1953   2767             ;	HEADER MAP:
1954   2767             ;		FILENAME (30)
1955   2767             ;		FTB PTR	 (2)
1956   2767             ;		DBUF PTR (2)
1957   2767             ;		SBUF PTR (2)
1958   2767             ;		LINK	 (2)
1959   2767             ;
1960   2767             BLDFTB
1961   2767 38          	SEC
1962   2768 AD 00 1D    	LDA	FTAB		;START OF FTAB AREA
1963   276B 85 40       	STA	ZPGWRK		;IS 1ST FTB PTR
1964   276D AD 01 1D    	LDA	FTAB+1		;HEADER
1965   2770 85 41       	STA	ZPGWRK+1
1966   2772 AD D1 29    	LDA	CNFTBS		;MOVE NO FTABS
1967   2775 8D DD 29    	STA	TEMP1A		;TO TEMP
1968   2778             ;
1969   2778 A0 00       BFT1	LDY	#0
1970   277A 98          	TYA
1971   277B 91 40       	STA	(ZPGWRK),Y	;1ST CHAR FN=0
1972   277D A0 1E       	LDY	#30		;INC Y TO FCB PTR
1973   277F 38          	SEC
1974   2780 A5 40       	LDA	ZPGWRK		;END OF PTR HEADER
1975   2782 E9 2D       	SBC	#FCBLEN		;MINUS FTAB LENGTH
1976   2784 91 40       	STA	(ZPGWRK),Y	;IS START OF FTB
1977   2786 48          	PHA			;SAVE LOW ADR BYTE
1978   2787 A5 41       	LDA	ZPGWRK+1
1979   2789 E9 00       	SBC	#0
1980   278B C8          	INY
1981   278C 91 40       	STA	(ZPGWRK),Y
1982   278E AA          	TAX
1983   278F CA          	DEX			;FTB ADR  256
1984   2790 68          	PLA			;IS ADR DIR BUFF
1985   2791 48          	PHA
1986   2792 C8          	INY
1987   2793 91 40       	STA	(ZPGWRK),Y	;SET DIR BUF PTR
1988   2795 8A          	TXA
1989   2796 C8          	INY
1990   2797 91 40       	STA	(ZPGWRK),Y
1991   2799 AA          	TAX
1992   279A CA          	DEX			;DIR BUFF  256
1993   279B 68          	PLA			;IS SBUFF ADR
1994   279C 48          	PHA
1995   279D C8          	INY
1996   279E 91 40       	STA	(ZPGWRK),Y
1997   27A0 C8          	INY
1998   27A1 8A          	TXA
1999   27A2 91 40       	STA	(ZPGWRK),Y
2000   27A4             ;
2001   27A4 CE DD 29    	DEC	TEMP1A		;DECREMENT TABLE INDEX
2002   27A7 F0 17       	BEQ	BFT2		;COUNT AND BR IF DONE
2003   27A9 AA          	TAX
2004   27AA 68          	PLA
2005   27AB 38          	SEC
2006   27AC E9 26       	SBC	#38		;SBUFF ADR  38
2007   27AE C8          	INY
2008   27AF 91 40       	STA	(ZPGWRK),Y	;IF ADR OF NEXT TAB
2009   27B1 48          	PHA			;WHICH GOES INTO
2010   27B2 8A          	TXA			;LINK
2011   27B3 E9 00       	SBC	#0
2012   27B5 C8          	INY
2013   27B6 91 40       	STA	(ZPGWRK),Y
2014   27B8 85 41       	STA	ZPGWRK+1	;AND INTO ZPGWRK
2015   27BA 68          	PLA			;FOR NEXT ENTRY
2016   27BB 85 40       	STA	ZPGWRK		;BUILD
2017   27BD 4C 78 27    	JMP	BFT1		;GO BUILD NEXT
2018   27C0             ;
2019   27C0             BFT2
2020   27C0 48          	PHA
2021   27C1 A9 00       	LDA	#0		;SET LAST LINK
2022   27C3 C8          	INY			;TO ZERO
2023   27C4 91 40       	STA	(ZPGWRK),Y
2024   27C6 C8          	INY
2025   27C7 91 40       	STA	(ZPGWRK),Y
2026   27C9             ;
2027   27C9 AD 30 2A    	LDA	ASIBSW		;IF IB THEN GO
2028   27CC F0 0B       	BEQ	BFTIB
2029   27CE             ;
2030   27CE 68          	PLA			;SET APPLESOFT
2031   27CF 85 74       	STA	ASHM1+1		;UPPER MEM LIMITS
2032   27D1 85 70       	STA	ASHM2+1
2033   27D3 68          	PLA
2034   27D4 85 73       	STA	ASHM1
2035   27D6 85 6F       	STA	ASHM2
2036   27D8 60          	RTS
2037   27D9             ;
2038   27D9             BFTIB
2039   27D9 68          	PLA			;SET IB
2040   27DA 85 4D       	STA	IBHMEM+1	;UPPER MEM LIMITS
2041   27DC 85 CB       	STA	IBSOP+1
2042   27DE 68          	PLA
2043   27DF 85 4C       	STA	IBHMEM
2044   27E1 85 CA       	STA	IBSOP
2045   27E3 60          	RTS

Page     45    SHEP	APPLE DOS

2046   27E4             	PAGE
2047   27E4             ;
2048   27E4             ;	MVISW  MOVE INPUT SWITCH
2049   27E4             ;
2050   27E4             MVCSW
2051   27E4 A5 39       	LDA	INSW+1
2052   27E6 CD 03 1D    	CMP	CINA+1
2053   27E9 F0 12       	BEQ	MVOSW
2054   27EB 8D D0 29    	STA	SVINS+1
2055   27EE A5 38       	LDA	INSW		;SAVE CHAR INSWITCH
2056   27F0 8D CF 29    	STA	SVINS
2057   27F3             ;
2058   27F3 AD 02 1D    	LDA	CINA		;SET DB CHAR IN ADR
2059   27F6 85 38       	STA	INSW
2060   27F8 AD 03 1D    	LDA	CINA+1
2061   27FB 85 39       	STA	INSW+1
2062   27FD             ;
2063   27FD             ;
2064   27FD             ;	MVOSW  MOVE OUTPUT SWITCH
2065   27FD             ;
2066   27FD             MVOSW
2067   27FD A5 37       	LDA	OUTSW+1
2068   27FF CD 05 1D    	CMP	COUTA+1
2069   2802 F0 12       	BEQ	MVSRTN
2070   2804 8D CE 29    	STA	SVOUTS+1
2071   2807 A5 36       	LDA	OUTSW		;SAVE CHAR OUT SWITCH
2072   2809 8D CD 29    	STA	SVOUTS
2073   280C             ;
2074   280C AD 04 1D    	LDA	COUTA		;SET DB CHAR OUT ADR
2075   280F 85 36       	STA	OUTSW
2076   2811 AD 05 1D    	LDA	COUTA+1
2077   2814 85 37       	STA	OUTSW+1
2078   2816             MVSRTN
2079   2816 60          	RTS

Page     46    SHEP	APPLE DOS

2080   2817             	PAGE
2081   2817             ;
2082   2817             ;	COMMAND NAME TABLE
2083   2817             ;
2084   2817             EC1
2085   2817             CMDNTB
2086   2817 49 4E 49 D4 	DB01	"INIT"
2087   281B 4C 4F 41 C4 	DB01	"LOAD"
2088   281F 53 41 56 C5 	DB01	"SAVE"
2089   2823 52 55 CE    	DB01	"RUN"
2090   2826 43 48 41 49 	DB01	"CHAIN"
2090   282A CE 
2091   282B 44 45 4C 45 	DB01	"DELETE"
2091   282F 54 C5 
2092   2831 4C 4F 43 CB 	DB01	"LOCK"
2093   2835 55 4E 4C 4F 	DB01	"UNLOCK"
2093   2839 43 CB 
2094   283B 43 4C 4F 53 	DB01	"CLOSE"
2094   283F C5 
2095   2840 52 45 41 C4 	DB01	"READ"
2096   2844 45 58 45 C3 	DB01	"EXEC"
2097   2848 57 52 49 54 	DB01	"WRITE"
2097   284C C5 
2098   284D 50 4F 53 49 	DB01	"POSITION"
2098   2851 54 49 4F CE 
2099   2855 4F 50 45 CE 	DB01	"OPEN"
2100   2859 41 50 50 45 	DB01	"APPEND"
2100   285D 4E C4 
2101   285F 52 45 4E 41 	DB01	"RENAME"
2101   2863 4D C5 
2102   2865 43 41 54 41 	DB01	"CATALOG"
2102   2869 4C 4F C7 
2103   286C 4D 4F CE    	DB01	"MON"
2104   286F 4E 4F 4D 4F 	DB01	"NOMON"
2104   2873 CE 
2105   2874 50 52 A3    	DB01	"PR#"
2106   2877 49 4E A3    	DB01	"IN#"
2107   287A 4D 41 58 46 	DB01	"MAXFILES"
2107   287E 49 4C 45 D3 
2108   2882 46 D0       	DB01	"FP"
2109   2884 49 4E D4    	DB01	"INT"
2110   2887 42 53 41 56 	DB01	"BSAVE"
2110   288B C5 
2111   288C 42 4C 4F 41 	DB01	"BLOAD"
2111   2890 C4 
2112   2891 42 52 55 CE 	DB01	"BRUN"
2113   2895 56 45 52 49 	DB01	"VERIFY"
2113   2899 46 D9 
2114   289B 00          	DB	0

Page     47    SHEP	APPLE DOS

2115   289C             	PAGE
2116   289C             ;
2117   289C             ;	COMMAND SYNTAX OP EQUATES FOR SYNTAX BYTE ONE
2118   289C             ;
2119   289C             NPB	EQU	$80		;NO PARMS OK, COMMAND GOES TO BASIC
2120   289C             NPE	EQU	$40		;NO PARMS OK, COMMAND TO EXECUTION RTN
2121   289C             FN1	EQU	$20		;FILE NAME1 REGD
2122   289C             FN2	EQU	$10		;FILE NAME2 REGD
2123   289C             NUM1	EQU	$08		;NUMERIC 0-7 REGD
2124   289C             NUM2	EQU	$04		;NUMERIC 1-10 REGD
2125   289C             ;
2126   289C             ;	COMMAND SYNTAX OP EQUATES FOR SYNTAX BYTE TWO
2127   289C             ;
2128   289C             V	EQU	$40		;VOLUME ALLOWED
2129   289C             D	EQU	$20		;DRIVE ALLOWED
2130   289C             S	EQU	$10		;SLOT ALLOWED
2131   289C             L	EQU	$08		;LENGTH ALLOWED
2132   289C             R	EQU	$04		;RECORD NUMBER ALLOWED
2133   289C             B	EQU	$02		;BYTE NUMBER ALLOWED
2134   289C             A	EQU	$01		;ADDRESS
2135   289C             CIO	EQU	$80		;C,I, OR O ALLOWED
2136   289C             ;
2137   289C             ;	COMMAND SYNTAX TABLE
2138   289C             ;	EACH COMMAND HAS TWO BYTE ENTRY
2139   289C             ;
2140   289C             CMDSTB
2141   289C 20 70       	DB	FN1,V+D+S	;INIT
2142   289E A0 70       	DB	NPB+FN1,V+D+S	;LOAD
2143   28A0 A0 70       	DB	NPB+FN1,V+D+S	;SAVE
2144   28A2 A0 70       	DB	NPB+FN1,V+D+S	;RUN
2145   28A4 20 70       	DB	FN1,V+D+S	;CHAIN
2146   28A6 20 70       	DB	FN1,V+D+S	;DELETE
2147   28A8 20 70       	DB	FN1,V+D+S	;LOCK
2148   28AA 20 70       	DB	FN1,V+D+S	;UNLOCK
2149   28AC 60 00       	DB	NPE+FN1,0	;CLOSE
2150   28AE 20 06       	DB	FN1,B+R		;READ
2151   28B0 20 74       	DB	FN1,R+V+D+S	;EXEC
2152   28B2 20 06       	DB	FN1,B+R		;WRITE
2153   28B4 20 04       	DB	FN1,R		;POSITION
2154   28B6 20 78       	DB	FN1,L+V+D+S	;OPEN
2155   28B8 20 78       	DB	FN1,L+V+D+S	;APPEND
2156   28BA 30 70       	DB	FN1+FN2,V+D+S	;RENAME
2157   28BC 40 70       	DB	NPE,V+D+S	;CATALOG
2158   28BE 40 80       	DB	NPE,CIO		;MONITOR
2159   28C0 40 80       	DB	NPE,CIO		;NO MONITOR
2160   28C2 08 00       	DB	NUM1,0		;PR#
2161   28C4 08 00       	DB	NUM1,0		;IN#
2162   28C6 04 00       	DB	NUM2,0		;MAXFILES
2163   28C8 40 70       	DB	NPE,V+D+S	;APPLESOFT
2164   28CA 40 00       	DB	NPE,0		;INT
2165   28CC 20 79       	DB	FN1,V+D+S+A+L	;BSAVE
2166   28CE 20 71       	DB	FN1,V+D+S+A	;BLOAD
2167   28D0 20 71       	DB	FN1,V+D+S+A	;BRUN
2168   28D2 20 70       	DB	FN1,V+D+S	;VERIFY

Page     48    SHEP	APPLE DOS

2169   28D4             	PAGE
2170   28D4             ;
2171   28D4             ;	OPTAB  OPTIONAL PARMS SYNTAX TABLES
2172   28D4             ;
2173   28D4             OPTAB1
2174   28D4 D6 C4 D3 CC 	DB11	"VDSLRBACIO"
2174   28D8 D2 C2 C1 C3 
2174   28DC C9 CF 
2175   28DE             OPT1L	EQU	*-OPTAB1
2176   28DE             OPTAB2
2177   28DE 40 20 10 08 	DB	V,D,S,L,R,B,A,CIO+MC,CIO+MI,CIO+MO
2177   28E2 04 02 01 C0 
2177   28E6 A0 90 
2178   28E8             OPTAB3
2179   28E8 00 00 FE 00 	DW	@@0,254		;VOL RANGE
2180   28EC 01 00 02 00 	DW	@@1,@@2		;DRIVE RANGE
2181   28F0 01 00 07 00 	DW	@@1,@@7		;SLOT RANGE
2182   28F4 01 00 FF 7F 	DW	@@1,32767	;LENGTH RANGE
2183   28F8 00 00 FF 7F 	DW	@@0,32767	;REC NO RANGE
2184   28FC 00 00 FF 7F 	DW	@@0,32767	;REC BYTE NO RANGE
2185   2900 00 00 00 C0 	DW	@@0,@@$C000	;ADDRESS RANGE

Page     49    SHEP	APPLE DOS

2186   2904             	PAGE
2187   2904             ;
2188   2904             ;	ERROR MESSAGE TABLES
2189   2904             ;
2190   2904             EMSG
2191   2904 0D 07       	DB	$0D,$07
2192   2906 2A 2A 2A 44 	DB01	"***DISK: "
2192   290A 49 53 4B 3A 
2192   290E A0 
2193   290F             EM1	EQU	*-EMSG
2194   290F             EM2	EQU	*-EMSG
2195   290F             EM3	EQU	*-EMSG
2196   290F 53 59 D3    	DB01	"SYS"
2197   2912             EM4	EQU	*-EMSG
2198   2912 57 52 49 54 	DB01	"WRITE PROTECT"
2198   2916 45 20 50 52 
2198   291A 4F 54 45 43 
2198   291E D4 
2199   291F             EM5	EQU	*-EMSG
2200   291F 45 4E 44 20 	DB01	"END OF DATA"
2200   2923 4F 46 20 44 
2200   2927 41 54 C1 
2201   292A             EM6	EQU	*-EMSG
2202   292A 46 49 4C 45 	DB01	"FILE NOT FOUND"
2202   292E 20 4E 4F 54 
2202   2932 20 46 4F 55 
2202   2936 4E C4 
2203   2938             EM7	EQU	*-EMSG
2204   2938 56 4F 4C 55 	DB01	"VOLUME MISMATCH"
2204   293C 4D 45 20 4D 
2204   2940 49 53 4D 41 
2204   2944 54 43 C8 
2205   2947             EM8	EQU	*-EMSG
2206   2947 44 49 53 4B 	DB01	"DISK I/O"
2206   294B 20 49 2F CF 
2207   294F             EM9	EQU	*-EMSG
2208   294F 44 49 53 4B 	DB01	"DISK FULL"
2208   2953 20 46 55 4C 
2208   2957 CC 
2209   2958             EM10	EQU	*-EMSG
2210   2958 46 49 4C 45 	DB01	"FILE LOCKED"
2210   295C 20 4C 4F 43 
2210   2960 4B 45 C4 
2211   2963             EM11	EQU	*-EMSG
2212   2963 43 4D 44 20 	DB01	"CMD SYNTAX"
2212   2967 53 59 4E 54 
2212   296B 41 D8 
2213   296D             EM12	EQU	*-EMSG
2214   296D 4E 4F 20 46 	DB01	"NO FILE BUFFS AVAIL"
2214   2971 49 4C 45 20 
2214   2975 42 55 46 46 
2214   2979 53 20 41 56 
2214   297D 41 49 CC 
2215   2980             EM13	EQU	*-EMSG
2216   2980 4E 4F 54 20 	DB01	"NOT BASIC PROGRAM"
2216   2984 42 41 53 49 
2216   2988 43 20 50 52 
2216   298C 4F 47 52 41 
2216   2990 CD 
2217   2991             EM14	EQU	*-EMSG
2218   2991 50 52 4F 47 	DB01	"PROGRAM TOO LARGE"
2218   2995 52 41 4D 20 
2218   2999 54 4F 4F 20 
2218   299D 4C 41 52 47 
2218   29A1 C5 
2219   29A2             EM15	EQU	*-EMSG
2220   29A2 4E 4F 54 20 	DB01	"NOT BINARY FILE"
2220   29A6 42 49 4E 41 
2220   29AA 52 59 20 46 
2220   29AE 49 4C C5 
2221   29B1             ;
2222   29B1             EML	EQU	*-EMSG
2223   29B1 20 45 52 52 	DB	" ERROR"
2223   29B5 4F 52 
2224   29B7 8D          	DB	$8D
2225   29B8             EMDTB
2226   29B8 00 0B 0B 0B 	DB	0,EM1,EM2,EM3,EM4
2226   29BC 0E 
2227   29BD 1B 26 34 43 	DB	EM5,EM6,EM7,EM8,EM9
2227   29C1 4B 
2228   29C2 54 5F 69 7C 	DB	EM10,EM11,EM12,EM13,EM14
2228   29C6 8D 
2229   29C7 9E AD       	DB	EM15,EML

Page     50    SHEP	APPLE DOS

2230   29C9             	PAGE
2231   29C9             ;
2232   29C9             ;	MISC BUT REQD CELLS
2233   29C9             ;
2234   29C9 00 00       CFTABA	DW	@0		;CURRENT FILE TABLE POINTER
2235   29CB 00          ISTATE	DB	0		;INPUT STATE
2236   29CC 00          OSTATE	DB	0		;OUTPUT STATE
2237   29CD 00 00       SVOUTS	DW	@0		;SAVED OUT SWITCH
2238   29CF 00 00       SVINS	DW	@0		;SAVED IN SWITCH
2239   29D1 00          CNFTBS	DB	0		;CURRENT NO FILE TABLES
2240   29D2 03          DFNFTB	DB	3		;DEFAULT NO FILE TABLES
2241   29D3 00          SVSTK	DB	0		;SAVED STACK PTR
2242   29D4 00          SVX	DB	0		;DSAVED X REG
2243   29D5 00          SVY	DB	0		;SAVED Y REG
2244   29D6 00          SVA	DB	0		;SAVED ACU
2245   29D7 00          LBUFD	DB	0		;LINE BUFF DSPL
2246   29D8 00          MONMOD	DB	0		;MONITOR MODE BITS
2247   29D9             MC	EQU	$40		;MONITOR CMDS
2248   29D9             MI	EQU	$20		;MONITOR INPUT
2249   29D9             MO	EQU	$10		;MONITOR OUTPUT
2250   29D9 FF          CMDNO	DB	$FF		;COMMAND NO
2251   29DA 00 00       SVBL	DB	0,0
2252   29DC 00          SVCMD	DB	0
2253   29DD 00          TEMP1A	DB	0
2254   29DE 00          TEMP2A	DB	0
2255   29DF 00          INOPTS	DB	0		;INPUT OPTIONS
2256   29E0             CUROPT				;CURRENT OPTIONS
2257   29E0 00 00       CV	DW	@@0		;VOLUME
2258   29E2 00 00       CD	DW	@@0		;DRIVE
2259   29E4 00 00       CS	DW	@@0		;SLOT
2260   29E6 01 00       CL	DW	@@1		;RECORD LENGTH
2261   29E8 00 00       CR	DW	@@0		;RECORD NUMBER
2262   29EA 00 00       CB	DW	@@0		;RECORD BYTE
2263   29EC 00 00       CA	DW	@@0		;ADDRESS
2264   29EE 00          IMBITS	DB	0
2265   29EF             FNAME1	RMB	30		;FILENAME 1
2266   2A0D             FNAME2	RMB	30		;FILENAME 2
2267   2A2B 03          DFNFTS	DB	3		;DEFAULT FILE TABLES = 3
2268   2A2C 84          CCHAR	DB	$84		;CONTROL CHAR
2269   2A2D 00          ESTATE	DB	0		;EXECUTE STATE
2270   2A2E 00 00       EFTABA	DB 	0,0		;EXECUTE FILE TABLE POINTER
2271   2A30 00          ASIBSW	DB	0		;APPLESOFT, IB SWITCH
2272   2A31 C1 D0 D0 CC FASB	DB11	"APPLESOFT"
2272   2A35 C5 D3 CF C6 
2272   2A39 D4 
2273   2A3A             FASBL	EQU	*-FASB

Page     51    SHEP	APPLE DOS

2274   2A3A             	PAGE
2275   2A3A             ;
2276   2A3A             ;	DOS ADR TABLES (RELOCATED)
2277   2A3A             ;
2278   2A3A             SAT2
2279   2A3A E8 37       AIOB	DW	@@IOB		;5-ADR IOB
2280   2A3C 26 33       AVTOC	DW	@@VTOC		;6-ADR VTOC
2281   2A3E 26 34       AVOLDR	DW	@@VOLDIR	;7-ADR VOLDIR
2282   2A40 00 40       AEND	DW	@@EDOS		;FEND OF DOS
2283   2A42             ;
2284   2A42 F1 32       CMDVT	DW	@@GOODIO-1	;0-NULL
2285   2A44 91 2A       	DW	@@FOPEN-1	;1-OPEN FILE
2286   2A46 59 2B       	DW	@@FCLOSE-1	;2-CLOSE FILE
2287   2A48 AB 2B       	DW	@@FREAD-1	;3-READ FILE
2288   2A4A C3 2B       	DW	@@FWRITE-1	;4-WRITE DATA
2289   2A4C 81 2C       	DW	@@FDEL-1	;5-DELETE FILE
2290   2A4E EE 2C       	DW	@@RDIR-1	;6-READ DIRECTORY
2291   2A50 42 2C       	DW	@@FLOCK-1	;7-LOCK A FILE
2292   2A52 49 2C       	DW	@@FUNLCK-1	;8-UNLOCK A FILE
2293   2A54 8D 2B       	DW	@@FRNME-1	;9-RENAME
2294   2A56 65 2C       	DW	@@FPOSTN-1	;10-POSITION A FILE
2295   2A58 E3 2D       	DW	@@FFMT-1	;FORMAT
2296   2A5A 6B 2C       	DW	@@FVAR-1	;VARIFY
2297   2A5C F1 32       	DW	@@GOODIO-1	;11-SPARE
2298   2A5E             ;
2299   2A5E             RVT
2300   2A5E F1 32       	DW	@@GOODIO-1
2301   2A60 DD 2B       	DW	@@RNXBYT-1	;1-RD NEXT BYTE
2302   2A62 E9 2B       	DW	@@RNXBLK-1	;1-RD NEXT BLOCK
2303   2A64 DA 2B       	DW	@@RSPBYT-1	;2-RD SPECIFIC BYTE
2304   2A66 E6 2B       	DW	@@RSPBLK-1	;3-RD SPECIFIC BLOCK
2305   2A68 F1 32       	DW	@@GOODIO-1	;4-SPARE
2306   2A6A             ;
2307   2A6A             WVT
2308   2A6A F1 32       	DW	@@GOODIO-1
2309   2A6C 11 2C       	DW	@@WNXBYT-1	;1-WR NEXT BYTE
2310   2A6E 1D 2C       	DW	@@WNXBLK-1	;WR NEXT BLOCK
2311   2A70 0E 2C       	DW	@@WSPBYT-1	;2-WR SPECIFIC BYTE
2312   2A72 1A 2C       	DW	@@WSPBLK-1	;3-WR SPECIFIC BLOCK
2313   2A74 F1 32       	DW	@@GOODIO-1	;4- SPARE
2314   2A76             EAT2

Page     52    SHEP	APPLE DOS

2315   2A76             	PAGE
2316   2A76             ;
2317   2A76             ;	DOSENT  DOS EXTERNAL ENTRY POINT
2318   2A76             ;		EXIT PARM
2319   2A76             ;				CARRY CLEAR = OPERATION
2320   2A76             ;				CARRY SET = ERROR
2321   2A76             ;
2322   2A76             SC2
2323   2A76             DOSENT
2324   2A76 BA          	TSX
2325   2A77 8E 0A 33    	STX	ENTSTK
2326   2A7A 20 C0 2D    	JSR	CLCFCB		;GO CALCULATE FCB
2327   2A7D AD 26 35    	LDA	CCBREQ		;GET REQUEST
2328   2A80 C9 0D       	CMP	#CRQMAX		;TTEST REQ RANGE
2329   2A82 B0 0B       	BCS	ERR2		;BR OUT OF RANGE
2330   2A84 0A          	ASLA			;REQ CODE *2
2331   2A85 AA          	TAX
2332   2A86 BD 43 2A    	LDA	CMDVT+1,X	;PUSH ADR ONTO STACK
2333   2A89 48          	PHA
2334   2A8A BD 42 2A    	LDA	CMDVT,X
2335   2A8D 48          	PHA
2336   2A8E 60          DENRTS	RTS
2337   2A8F 4C D6 32    ERR2	JMP	ERROR2

Page     53    SHEP	APPLE DOS

2338   2A92             	PAGE
2339   2A92             ;
2340   2A92             ;	FOPEN  OPEN A FILE
2341   2A92             ;
2342   2A92             FOPEN
2343   2A92 20 98 2A    	JSR	DOPEN
2344   2A95 4C F2 32    	JMP	GOODIO
2345   2A98             ;
2346   2A98             DOPEN
2347   2A98             ;
2348   2A98 20 30 2B    	JSR	DCBSUP
2349   2A9B             ;
2350   2A9B             ;
2351   2A9B A9 01       	LDA	#1
2352   2A9D 8D 4E 35    	STA	DCBSDL+1
2353   2AA0 AE 29 35    	LDX	CCBRLN+1	;MOVE RECORD LENGTH
2354   2AA3 AD 28 35    	LDA	CCBRLN
2355   2AA6 D0 05       	BNE	F02
2356   2AA8 E0 00       	CPX	#0
2357   2AAA D0 01       	BNE	F02
2358   2AAC E8          	INX			;SET RL=256
2359   2AAD 8D 53 35    F02	STA	DCBRCL
2360   2AB0 8E 54 35    	STX	DCBRCL+1
2361   2AB3             ;
2362   2AB3 20 3C 31    	JSR	FNDFIL		;GO FIND FILE
2363   2AB6 90 42       	BCC	F03		;BR IF FOUND
2364   2AB8             ;				;CREATE FILE
2365   2AB8 A9 00       	LDA	#0
2366   2ABA 9D 53 34    	STA	VDFILE+34,X
2367   2ABD A9 01       	LDA	#1
2368   2ABF 9D 52 34    	STA	VDFILE+33,X
2369   2AC2 8E 0B 33    	STX	TEMP1		;SAVE VDIR INDEX
2370   2AC5 20 B7 31    	JSR	GETSEC		;GO ALLOCATE SECTOR
2371   2AC8 AE 0B 33    	LDX	TEMP1
2372   2ACB 9D 32 34    	STA	VDFILE+1,X	;PUT SECTOR INTO VDIR
2373   2ACE 8D 3D 35    	STA	DCBFDS		;PUT SECTOR AS 1ST FILE DIR
2374   2AD1 8D 3F 35    	STA	DCBCDS		;PUT SECTOR AS CURRENT FILE DIR
2375   2AD4             ;	
2376   2AD4 AD 5C 35    	LDA	DCBATK		;GET ALLOCATED TRACK
2377   2AD7 9D 31 34    	STA	VDFILE,X		;PUT INTO VDIR
2378   2ADA 8D 3C 35    	STA	DCBFDT		;AND AS 1ST FILE DIR
2379   2ADD 8D 3E 35    	STA	DCBCDT		;AND AS CURRENT FILE DIR
2380   2AE0             ;
2381   2AE0 AD 2D 35    	LDA	CCBFUC		;SET USE CODE
2382   2AE3 9D 33 34    	STA	VDFILE+2,X	;INTO DIRECTORY
2383   2AE6             ;
2384   2AE6 20 AA 2F    	JSR	WRVDIR		;GO WRITE VOL DIRECTORY
2385   2AE9             ;
2386   2AE9 20 76 2E    	JSR	MVFCBD		;MOVE FILE DIR ADR TO ZP
2387   2AEC 20 87 2E    	JSR	CLRSEC		;GO CLEAR IT
2388   2AEF 20 AD 2E    	JSR	WRFDGO		;GO WRITE FILE DIRECTORY DONE CREATION
2389   2AF2             ;
2390   2AF2 AE 0B 33    	LDX	TEMP1		;RE-GET INDEX
2391   2AF5 A9 06       	LDA	#CREFNF
2392   2AF7 8D 30 35    	STA	CCBSTA
2393   2AFA             ;
2394   2AFA             F03
2395   2AFA BD 31 34    	LDA	VDFILE,X	;MOVE FILE DIR TRACK
2396   2AFD 8D 3C 35    	STA	DCBFDT
2397   2B00 BD 32 34    	LDA	VDFILE+1,X	;MOVE FILE DIR SECTOR
2398   2B03 8D 3D 35    	STA	DCBFDS
2399   2B06 BD 33 34    	LDA	VDFILE+2,X	;70VE FILE USE CODE
2400   2B09 8D 2D 35    	STA	CCBFUC
2401   2B0C 8D 61 35    	STA	DCBFUC
2402   2B0F BD 52 34    	LDA	VDFILE+33,X
2403   2B12 8D 59 35    	STA	DCBNSA
2404   2B15 BD 53 34    	LDA	VDFILE+34,X
2405   2B18 8D 5A 35    	STA	DCBNSA+1
2406   2B1B 8E 44 35    	STX	DCBVDI		;SAVE DIR INDEX
2407   2B1E             ;
2408   2B1E A9 FF       	LDA	#255		;INDICATE NO SECTOR
2409   2B20 8D 4B 35    	STA	DCBCMS		;IN MEMORY
2410   2B23 8D 4C 35    	STA	DCBCMS+1
2411   2B26 AD 4D 33    	LDA	VTDMS		;MOVE MAX FD SECTS
2412   2B29 8D 45 35    	STA	DCBDMS		;TO DCB
2413   2B2C 18          	CLC
2414   2B2D 4C D1 2E    	JMP	RDFDIR		;READ 1ST DIRECTORY RECORD
2415   2B30             ;
2416   2B30             ;
2417   2B30             ;
2418   2B30             ;
2419   2B30             DCBSUP
2420   2B30 A9 00       	LDA	#0
2421   2B32 AA          	TAX
2422   2B33 9D 3C 35    F01	STA	FCBDCB,X	;CLEAR DCB
2423   2B36 E8          	INX
2424   2B37 E0 2D       	CPX	#DCBLEN
2425   2B39 D0 F8       	BNE	F01
2426   2B3B             ;
2427   2B3B AD 2A 35    	LDA	CCBVOL		;MOVE VOL
2428   2B3E 49 FF       	EOR	#$FF		;INVERT VOL BITS
2429   2B40 8D 64 35    	STA	DCBVOL
2430   2B43 AD 2B 35    	LDA	CCBDRV		;MOVE DRIVE
2431   2B46 8D 63 35    	STA	DCBDRV
2432   2B49 AD 2C 35    	LDA	CCBSLT		;GET USER SPEC SLOT
2433   2B4C 0A          	ASLA			;SLOT*16
2434   2B4D 0A          	ASLA
2435   2B4E 0A          	ASLA
2436   2B4F 0A          	ASLA
2437   2B50 AA          	TAX
2438   2B51             F01A	
2439   2B51 8E 62 35    	STX	DCBSLT
2440   2B54 A9 11       	LDA	#17
2441   2B56 8D 65 35    	STA	DCBVTN
2442   2B59 60          	RTS

Page     54    SHEP	APPLE DOS

2443   2B5A             	PAGE
2444   2B5A             ;
2445   2B5A             ;	FCLOSE  CLOSE A FILE
2446   2B5A             ;
2447   2B5A             FCLOSE
2448   2B5A 20 90 2E    	JSR	WRSECT		;WRITE OPEN SECTOR
2449   2B5D 20 A7 2E    	JSR	WRFDIR		;GO WRITE FILE DIRECTORY
2450   2B60 20 36 32    	JSR	FRETRK		;FREE UNUSED SECTORS
2451   2B63 A9 02       	LDA	#IBCWTS
2452   2B65 2D 40 35    	AND	DCBWRF
2453   2B68 F0 21       	BEQ	FC2
2454   2B6A             ;
2455   2B6A 20 6A 2F    	JSR	RDVTOC		;READ VTOC
2456   2B6D A9 00       	LDA	#0
2457   2B6F 18          	CLC
2458   2B70             FC1
2459   2B70 20 84 2F    	JSR	RDVDIR		;READ VDIR
2460   2B73 38          	SEC
2461   2B74 CE 43 35    	DEC	DCBVDR
2462   2B77 D0 F7       	BNE	FC1		;BR IF NOT
2463   2B79 AE 44 35    	LDX	DCBVDI		;GET FILES INDEX
2464   2B7C AD 59 35    	LDA	DCBNSA		;MOVE NO SECTIONS ALLOCATED
2465   2B7F 9D 52 34    	STA	VDFILE+33,X
2466   2B82 AD 5A 35    	LDA	DCBNSA+1
2467   2B85 9D 53 34    	STA	VDFILE+34,X
2468   2B88 20 AA 2F    	JSR	WRVDIR		;WRITE VOL DIR REC
2469   2B8B             ;
2470   2B8B             ;
2471   2B8B             FC2
2472   2B8B 4C F2 32    	JMP	GOODIO		;DONE

Page     55    SHEP	APPLE DOS

2473   2B8E             	PAGE
2474   2B8E             ;
2475   2B8E             ;	FRNME  RENAME A FILE
2476   2B8E             ;
2477   2B8E             FRNME
2478   2B8E 20 98 2A    	JSR	DOPEN		;GO OPEN FILE
2479   2B91 AD 61 35    	LDA	DCBFUC		;GET USE CODE
2480   2B94 30 2B       	BMI	ER10		;BR IF LOCKED
2481   2B96 AD 28 35    	LDA	CCBFN2		;MOVE NEW FN
2482   2B99 85 42       	STA	ZPGFCB		;PTR TO ZPG
2483   2B9B AD 29 35    	LDA	CCBFN2+1
2484   2B9E 85 43       	STA	ZPGFCB+1
2485   2BA0 AE 0B 33    	LDX	TEMP1		;GET VDIR INDEX
2486   2BA3 20 8F 31    	JSR	MVFN		;GO MOVE FILE NAME
2487   2BA6 20 AA 2F    	JSR	WRVDIR		;GO WRITE FILE VDIR
2488   2BA9 4C F2 32    	JMP	GOODIO		;DONE RENAME

Page     56    SHEP	APPLE DOS

2489   2BAC             	PAGE
2490   2BAC             ;
2491   2BAC             ;	FREAD  READ A FILE
2492   2BAC             ;
2493   2BAC             FREAD
2494   2BAC             ;
2495   2BAC AD 27 35    	LDA	CCBRQM		;GET REQ MOD
2496   2BAF C9 05       	CMP	#CRMMAX		;TEST LIMIT
2497   2BB1 B0 0B       	BCS	ERR3A
2498   2BB3             ;
2499   2BB3 0A          	ASLA			;CODE*2
2500   2BB4 AA          	TAX
2501   2BB5 BD 5F 2A    	LDA	RVT+1,X		;GET READ ROUTINE
2502   2BB8 48          	PHA			;VECTOR ADR
2503   2BB9 BD 5E 2A    	LDA	RVT,X
2504   2BBC 48          	PHA			;AND
2505   2BBD 60          	RTS			;GO TO IT
2506   2BBE             ;
2507   2BBE 4C DA 32    ERR3A	JMP	ERROR3
2508   2BC1 4C EE 32    ER10	JMP	ERRR10
2509   2BC4             ;
2510   2BC4             ;	FWRITE  WRITE A FILE
2511   2BC4             ;
2512   2BC4             FWRITE
2513   2BC4 AD 61 35    	LDA	DCBFUC		;IS FILE LOCKED
2514   2BC7 30 F8       	BMI	ER10		;BR IF LOCKED
2515   2BC9 AD 27 35    	LDA	CCBRQM		;GET REQ MOD
2516   2BCC C9 05       	CMP	#CRMMAX		;IN RANGE
2517   2BCE B0 EE       	BCS	ERR3A		;BR IF NOT IN RANGE
2518   2BD0             ;
2519   2BD0 0A          	ASLA
2520   2BD1 AA          	TAX
2521   2BD2 BD 6B 2A    	LDA	WVT+1,X		;GET ROUTINE ADR
2522   2BD5 48          	PHA
2523   2BD6 BD 6A 2A    	LDA	WVT,X
2524   2BD9 48          	PHA
2525   2BDA 60          	RTS			;AND GO TO IT

Page     57    SHEP	APPLE DOS

2526   2BDB             	PAGE
2527   2BDB             ;
2528   2BDB             ;	RSPBYT  READ A SPECIFIC BYTE
2529   2BDB             ;
2530   2BDB             RSPBYT
2531   2BDB 20 73 32    	JSR	LOCSEC		;GO GET REQD REL SECTOR
2532   2BDE             ;
2533   2BDE             ;	RNXBYT  READ NEXT BYTE
2534   2BDE             ;
2535   2BDE 20 FC 2B    RNXBYT	JSR	GETBYT		;GO GET BYTE
2536   2BE1 8D 2E 35    	STA	CCBDAT		;PUT IN CCB
2537   2BE4 4C F2 32    	JMP	GOODIO		;DONE
2538   2BE7             ;
2539   2BE7             ;	RSPBLK  READ SPECIFIC BLOCK
2540   2BE7             ;
2541   2BE7 20 73 32    RSPBLK	JSR	LOCSEC		;GO LOCATE REL SECTOR
2542   2BEA             ;
2543   2BEA             ;	RNXBLK  READ NEXT BLOCK
2544   2BEA             ;
2545   2BEA             RNXBLK
2546   2BEA 20 28 31    	JSR	DTBLN		;GO DECR LEN (NOT RTN IF=0)
2547   2BED 20 FC 2B    	JSR	GETBYT		;GO GET BYTE
2548   2BF0 48          	PHA
2549   2BF1 20 15 31    	JSR	MIBDA		;GO MOVE BLOCK ADR AND INCR
2550   2BF4 A0 00       	LDY	#0
2551   2BF6 68          	PLA
2552   2BF7 91 42       	STA	(ZPGFCB),Y	;SET DATA BYTE
2553   2BF9 4C EA 2B    	JMP	RNXBLK		;GO FOR NEXT BYTE
2554   2BFC             ;
2555   2BFC             ;	GETBYT  GET A DATA BYTE
2556   2BFC             ;
2557   2BFC             GETBYT
2558   2BFC 20 29 30    	JSR	LOCNXB		;LOCATE NEXT BYTE
2559   2BFF B0 0B       	BCS	EOFIN		;BR IF EOF
2560   2C01 B1 42       	LDA	(ZPGFCB),Y	;BR IF EOF
2561   2C03 48          	PHA			;SAVE IT
2562   2C04 20 CE 30    	JSR	INCRRB		;INCR REC BYTE
2563   2C07 20 07 31    	JSR	INCSCB		;INCR SAVED BYTE
2564   2C0A 68          	PLA			;GET SAVED BYTE
2565   2C0B 60          	RTS			;RETURN
2566   2C0C             ;
2567   2C0C 4C E2 32    EOFIN	JMP	ERROR5		;GO TO EOF RTN

Page     58    SHEP	APPLE DOS

2568   2C0F             	PAGE
2569   2C0F             ;
2570   2C0F             ;	WSPBYT  WRITE SPECIFIC BYTE
2571   2C0F             ;
2572   2C0F             WSPBYT
2573   2C0F 20 73 32    	JSR	LOCSEC		;GO LOCATE SECTOR
2574   2C12             ;
2575   2C12             ;	WNXBYT  WRITE NEXT BYTE
2576   2C12             ;
2577   2C12             WNXBYT
2578   2C12 AD 2E 35    	LDA	CCBDAT		;GET THE BYTE
2579   2C15 20 2E 2C    	JSR	PUTBYT		;GO WRITE BYTE
2580   2C18 4C F2 32    	JMP	GOODIO		;DONE
2581   2C1B             ;
2582   2C1B             ;	WSPBLK  WRITE NEXT BLOCK
2583   2C1B             ;
2584   2C1B             WSPBLK
2585   2C1B 20 73 32    	JSR	LOCSEC		;GO LOCATE SECTOR
2586   2C1E             ;
2587   2C1E             ;	WNXBLK  WRITE BLOCK
2588   2C1E             ;
2589   2C1E             WNXBLK
2590   2C1E 20 15 31    	JSR	MIBDA		;GO MOVE ADR TO ZPG AND DEC
2591   2C21 A0 00       	LDY	#0
2592   2C23 B1 42       	LDA	(ZPGFCB),Y	;GET DATA BYTE
2593   2C25 20 2E 2C    	JSR	PUTBYT		;GO PUT IT
2594   2C28 20 28 31    	JSR	DTBLN		;GO DEC BLK LEN (NOT RTN IF = 0)
2595   2C2B 4C 1E 2C    	JMP	WNXBLK
2596   2C2E             ;
2597   2C2E             ;	PUTBYT  PUT OUT ONE BYTE
2598   2C2E             ;
2599   2C2E             PUTBYT
2600   2C2E 48          	PHA			;SAVE DATA BYTE
2601   2C2F 20 29 30    	JSR	LOCNXB		;GO LOCATE NEXT BYTE
2602   2C32             ;
2603   2C32 68          PB0	PLA			;GO SAVED BYTE
2604   2C33 91 42       	STA	(ZPGFCB),Y	;PUT THE BYTE
2605   2C35 A9 40       	LDA	#$40		;SET WRITE SECTOR REQD
2606   2C37 0D 40 35    	ORA	DCBWRF
2607   2C3A 8D 40 35    	STA 	DCBWRF
2608   2C3D             ;
2609   2C3D 20 CE 30    	JSR	INCRRB		;INCR REL REC BYTE
2610   2C40 4C 07 31    	JMP	INCSCB		;INCR SECTOR BYTE

Page     59    SHEP	APPLE DOS

2611   2C43             	PAGE
2612   2C43             ;
2613   2C43             ;	FLOCK  LOCK A FILE
2614   2C43             ;
2615   2C43 A9 80       FLOCK	LDA	#$80		;REMEMBER LOCK
2616   2C45 8D 0D 33    	STA	TEMP3
2617   2C48 D0 05       	BNE	LCKGO
2618   2C4A             ;
2619   2C4A             ;	FUNLCK  UNLOCK A FILE
2620   2C4A             ;
2621   2C4A A9 00       FUNLCK	LDA	#00		;REMEMBER UNLOCK
2622   2C4C 8D 0D 33    	STA	TEMP3
2623   2C4F             ;
2624   2C4F             LCKGO
2625   2C4F             ;
2626   2C4F 20 98 2A    	JSR	DOPEN		;GO OPEN FILE
2627   2C52 AE 0B 33    	LDX	TEMP1
2628   2C55 BD 33 34    	LDA	VDFILE+2,X	;GET FILE USE CODE
2629   2C58 29 7F       	AND	#$7F		;TURN OFF LOCK
2630   2C5A 0D 0D 33    	ORA	TEMP3
2631   2C5D 9D 33 34    	STA	VDFILE+2,X
2632   2C60 20 AA 2F    	JSR	WRVDIR
2633   2C63 4C F2 32    	JMP	GOODIO
2634   2C66             ;
2635   2C66             ;	FPOSTN  POSITION A FILE
2636   2C66 20 73 32    FPOSTN	JSR	LOCSEC		;GO POSITION
2637   2C69 4C F2 32    	JMP	GOODIO		;DONE
2638   2C6C             ;
2639   2C6C             ;
2640   2C6C             ;	FVAR  VARIFY A FILE
2641   2C6C             ;
2642   2C6C             FVAR
2643   2C6C 20 98 2A    	JSR	DOPEN		;OPEN FILE
2644   2C6F 20 29 30    VAR1	JSR	LOCNXB		;READ A SECTOR
2645   2C72 B0 0B       	BCS	VAR2		;BR IF EOF
2646   2C74 EE 4F 35    	INC	DCBCRS		;INCREMENT SECTOR
2647   2C77 D0 F6       	BNE	VAR1
2648   2C79 EE 50 35    	INC	DCBCRS+1
2649   2C7C 4C 6F 2C    	JMP	VAR1		;READ THIS ONE
2650   2C7F 4C F2 32    VAR2	JMP	GOODIO		;DONE	

Page     60    SHEP	APPLE DOS

2651   2C82             	PAGE
2652   2C82             ;
2653   2C82             ;	FDEL  DELETE A FILE
2654   2C82             ;
2655   2C82             FDEL
2656   2C82 20 98 2A    	JSR	DOPEN		;GO OPEN FILE
2657   2C85             ;
2658   2C85 AE 0B 33    FD2	LDX	TEMP1		;SAVED INDEX
2659   2C88 BD 33 34    	LDA	VDFILE+2,X	;IS FILE LOCKED
2660   2C8B 10 03       	BPL	FD3		;BR NOT LOCKED
2661   2C8D 4C EE 32    	JMP	ERRR10
2662   2C90             ;
2663   2C90             FD3
2664   2C90 AE 0B 33    	LDX	TEMP1		;GET SAVED INDEX
2665   2C93 BD 31 34    	LDA	VDFILE,X	;GET DIR TRACK
2666   2C96 8D 3C 35    	STA	DCBFDT		;SET AS 1ST FD TRACK
2667   2C99 9D 51 34    	STA	VDFILE+32,X	;SAVE IN LC OF FN
2668   2C9C A9 FF       	LDA	#$FF		;DELETED FILE MARKER
2669   2C9E 9D 31 34    	STA	VDFILE,X	;CLEAR ENTRY
2670   2CA1 BC 32 34    	LDY	VDFILE+1,X	;GET DIR SECTOR
2671   2CA4 8C 3D 35    	STY	DCBFDS		;SET AS 1ST FD SEC
2672   2CA7 20 AA 2F    	JSR	WRVDIR		;GO WRITE VOLUME DIR
2673   2CAA 18          	CLC
2674   2CAB 20 D1 2E    FD4	JSR	RDFDIR		;GET 1ST FILE DIR SECTOR
2675   2CAE B0 2A       	BCS	FD7		;BR IF NO MORE
2676   2CB0 20 76 2E    	JSR	MVFCBD		;MOVE DIR TO ZPG
2677   2CB3 A0 0C       	LDY	#FDENT		;POINT Y TO 1ST SEC ENT
2678   2CB5 8C 0B 33    FD5	STY	TEMP1		;SAVE Y
2679   2CB8 B1 42       	LDA	(ZPGFCB),Y	;GET REACK
2680   2CBA 30 0B       	BMI	FD6		;BR IF DONE
2681   2CBC F0 09       	BEQ	FD6		;BR IF END OF FILE
2682   2CBE 48          	PHA			;SAVE TRK
2683   2CBF C8          	INY
2684   2CC0 B1 42       	LDA	(ZPGFCB),Y	;GET SECTOR
2685   2CC2 A8          	TAY			;TO Y
2686   2CC3 68          	PLA			;GET TRK
2687   2CC4 20 E0 2C    	JSR	FDSUB		;GO FREE SECTOR
2688   2CC7 AC 0B 33    FD6	LDY	TEMP1		;GET DIR INDEX
2689   2CCA C8          	INY			;INCR TO NEXT ENTRY
2690   2CCB C8          	INY
2691   2CCC D0 E7       	BNE	FD5		;BR NOT DONE THIS DIR
2692   2CCE AD 3E 35    	LDA	DCBCDT		;GET THIS DIR TRK
2693   2CD1 AC 3F 35    	LDY	DCBCDS		;AND SECTOR
2694   2CD4 20 E0 2C    	JSR	FDSUB		;AND GO FREE IT
2695   2CD7 38          	SEC			;GO
2696   2CD8 B0 D1       	BCS	FD4		;READ NEXT DIR
2697   2CDA             FD7
2698   2CDA 20 6E 2F    	JSR	WRVTOC
2699   2CDD 4C F2 32    	JMP	GOODIO
2700   2CE0             ;
2701   2CE0             FDSUB
2702   2CE0 38          	SEC			;SET FOR RE USE OF SEC
2703   2CE1 20 50 32    	JSR	FRESEC		;GO FREE SECTOR
2704   2CE4 A9 00       	LDA	#0		;CLEAR DCB BIT MAP
2705   2CE6 A2 03       	LDX	#3
2706   2CE8 9D 5B 35    FDS1	STA	DCBALS,X
2707   2CEB CA          	DEX
2708   2CEC 10 FA       	BPL	FDS1
2709   2CEE 60          	RTS

Page     61    SHEP	APPLE DOS

2710   2CEF             	PAGE
2711   2CEF             ;
2712   2CEF             ;	RDIR  PRINT DIRECTORY
2713   2CEF             ;
2714   2CEF             RDIR
2715   2CEF 20 30 2B    	JSR	DCBSUP
2716   2CF2 A9 FF       	LDA	#$FF
2717   2CF4 8D 64 35    	STA	DCBVOL
2718   2CF7 20 6A 2F    	JSR	RDVTOC
2719   2CFA A9 16       	LDA	#22		;SET 21 LINES
2720   2CFC 8D 0C 33    	STA	TEMP2
2721   2CFF 20 85 2D    	JSR	PRCR		;GO PRINT
2722   2D02 20 85 2D    	JSR	PRCR		;PRINT ANOTHER CHAR
2723   2D05 A2 0B       	LDX	#VML		;VOLUME MSG LENGTH
2724   2D07 BD 1A 33    RD0	LDA	VOLMES,X	;GET MSG CHAR
2725   2D0A 20 ED FD    	JSR	PRINT		;PRINT IT
2726   2D0D CA          	DEX			;DECREMENT COUNT
2727   2D0E 10 F7       	BPL	RD0		;BR IF MORE
2728   2D10             ;
2729   2D10 86 45       	STX	CNUM+1	
2730   2D12 AD F6 37    	LDA	IBSMOD		;MOVE VOL NO FOR
2731   2D15 85 44       	STA	CNUM		;CONVERSION
2732   2D17 20 98 2D    	JSR	PRNUM		;GO PRINT VOL NO
2733   2D1A             ;
2734   2D1A 20 85 2D    	JSR	PRCR		;PRINT CR
2735   2D1D 20 85 2D    	JSR	PRCR		;AND AGAIN
2736   2D20             ;
2737   2D20 18          	CLC			;FIRST RECORD
2738   2D21             ;
2739   2D21 20 84 2F    RD1	JSR	RDVDIR		;GO READ REC
2740   2D24 B0 5C       	BCS	RD5
2741   2D26 A2 00       	LDX	#0		;SET INDEX=0
2742   2D28 8E 0B 33    RD2	STX	TEMP1		;SAVE INDEX
2743   2D2B BD 31 34    	LDA	VDFILE,X	;GET TRACK
2744   2D2E F0 52       	BEQ	RD5		;BR IF END OF DIR
2745   2D30 30 49       	BMI	RD4		;BR IF DELETED
2746   2D32             ;
2747   2D32 A0 A0       	LDY	#$A0		;BLANK
2748   2D34 BD 33 34    	LDA	VDFILE+2,X	;GET TYPE
2749   2D37 10 02       	BPL	RD2A		;BR IF NOT LOCKED
2750   2D39 A0 AA       	LDY	#'*'+$80	;AST
2751   2D3B 98          RD2A	TYA			;ACU = AST OR BLANK
2752   2D3C 20 ED FD    	JSR	PRINT		;PRINT ACU
2753   2D3F             ;
2754   2D3F BD 33 34    	LDA	VDFILE+2,X	;GET TYPE
2755   2D42 29 07       	AND	#$07		;MASK OUT MISC
2756   2D44 A0 03       	LDY	#3		;SET INDEX = 3
2757   2D46 4A          RD2B	LSRA			;SHIFT OUT LSB
2758   2D47 B0 03       	BCS	RD2C		;BR IF TYPE BIT OUT
2759   2D49 88          	DEY			;DEC INDEX
2760   2D4A D0 FA       	BNE	RD2B		;BR IF NOT ACC BITS
2761   2D4C             RD2C
2762   2D4C B9 16 33    	LDA	FTTAB,Y		;GET TYPE CODE
2763   2D4F 20 ED FD    	JSR	PRINT		;PRINT IT
2764   2D52 A9 A0       	LDA	#$A0		;BLANK
2765   2D54 20 ED FD    	JSR	PRINT		;PRINT
2766   2D57             ;
2767   2D57 BD 52 34    	LDA	VDFILE+33,X	;MOVE FILE LENGTH
2768   2D5A 85 44       	STA	CNUM		;TO CNUM
2769   2D5C BD 53 34    	LDA	VDFILE+34,X
2770   2D5F 85 45       	STA	CNUM+1
2771   2D61 20 98 2D    	JSR	PRNUM		;GO PRINT NUMBER
2772   2D64 A9 A0       	LDA	#$A0		;BLANK
2773   2D66 20 ED FD    	JSR	PRINT		;PRINT
2774   2D69             ;
2775   2D69 E8          	INX
2776   2D6A E8          	INX
2777   2D6B E8          	INX
2778   2D6C A0 1D       	LDY	#29
2779   2D6E BD 31 34    RD3	LDA	VDFILE,X	;GET CHAR
2780   2D71 20 ED FD    	JSR	PRINT		;PRINT CHAR
2781   2D74 E8          	INX
2782   2D75 88          	DEY
2783   2D76 10 F6       	BPL	RD3
2784   2D78             RD3A
2785   2D78 20 85 2D    	JSR	PRCR		;GO PRINT CR
2786   2D7B 20 A3 31    RD4	JSR	VDINC		;INCR INDEX
2787   2D7E 90 A8       	BCC	RD2		;BR IF MORE IN DIR
2788   2D80 B0 9F       	BCS	RD1		;GO READ NEXT DIR SECT
2789   2D82             ;
2790   2D82 4C F2 32    RD5	JMP	GOODIO		;DONE
2791   2D85             ;
2792   2D85             PRCR
2793   2D85 A9 8D       	LDA	#$8D		;CR
2794   2D87 20 ED FD    	JSR	PRINT		;PRINTED
2795   2D8A CE 0C 33    	DEC	TEMP2		;DEC LINE COUNTER
2796   2D8D D0 08       	BNE	PRCR1		;BR IF NOT ZERO
2797   2D8F 20 0C FD    	JSR	GETKEY		;WAIT FOR INPUT
2798   2D92 A9 15       	LDA	#21		;RESET LINE COUNTER
2799   2D94 8D 0C 33    	STA	TEMP2
2800   2D97 60          PRCR1	RTS			;DONE

Page     62    SHEP	APPLE DOS

2801   2D98             	PAGE
2802   2D98             PRNUM
2803   2D98 A0 02       	LDY	#2		;3 DIGITS
2804   2D9A A9 00       PRN1	LDA	#0		;INIT DIGIT TO ZERO
2805   2D9C 48          	PHA			;SAVE IT
2806   2D9D             ;
2807   2D9D A5 44       PRN2	LDA	CNUM		;GET NUMBER
2808   2D9F D9 13 33    	CMP	CVTAB,Y		;IF NUM < CVTAB ENTRY
2809   2DA2 90 12       	BCC	PRN3		;THEN DONE THIS DIGIT
2810   2DA4             ;
2811   2DA4 F9 13 33    	SBC	CVTAB,Y		;SUBTRACT TABLE ENTRY
2812   2DA7 85 44       	STA	CNUM		;FROM NUM
2813   2DA9 A5 45       	LDA	CNUM+1
2814   2DAB E9 00       	SBC	#0
2815   2DAD 85 45       	STA	CNUM+1
2816   2DAF 68          	PLA			;INCREMENT DIGIT
2817   2DB0 69 00       	ADC	#0
2818   2DB2 48          	PHA
2819   2DB3 4C 9D 2D    	JMP	PRN2		;TRY AGAIN
2820   2DB6             ;
2821   2DB6             PRN3
2822   2DB6 68          	PLA			;GET DIGIT
2823   2DB7 09 B0       	ORA	#$B0		;ADD ASCII
2824   2DB9 20 ED FD    	JSR	PRINT		;PRINT IT
2825   2DBC 88          	DEY			;DECREMENT DIGIT COUNT
2826   2DBD 10 DB       	BPL	PRN1		;BR IF MORE DIGIT
2827   2DBF             ;
2828   2DBF 60          	RTS			;DONE

Page     63    SHEP	APPLE DOS

2829   2DC0             	PAGE
2830   2DC0             ;
2831   2DC0             ;	CLCFCB  GET FCB VIA INDEX AND MOVE IT
2832   2DC0             ;
2833   2DC0             CLCFCB
2834   2DC0             ;
2835   2DC0 20 72 2E    	JSR	MVFCBP		;MOVE FCB PTR TO ZPG
2836   2DC3 A0 00       	LDY	#0
2837   2DC5 8C 30 35    	STY	CCBSTA
2838   2DC8 B1 42       CF3	LDA	(ZPGFCB),Y	;MOVE FCB TO
2839   2DCA 99 3C 35    	STA	FCBB,Y		;FCB WORK AREA
2840   2DCD C8          	INY
2841   2DCE C0 2D       	CPY	#FCBLEN
2842   2DD0 D0 F6       	BNE	CF3
2843   2DD2             ;
2844   2DD2 18          	CLC			;DONE
2845   2DD3 60          	RTS
2846   2DD4             ;
2847   2DD4             ;	RTNFCB  MOVE FCB FROM WORK AREA TO FCB
2848   2DD4             ;
2849   2DD4             RTNFCB
2850   2DD4 20 72 2E    	JSR	MVFCBP		;MOVE FCB ADR TO ZPG
2851   2DD7             ;
2852   2DD7 A0 00       	LDY	#0
2853   2DD9 B9 3C 35    RF1	LDA	FCBB,Y
2854   2DDC 91 42       	STA	(ZPGFCB),Y
2855   2DDE C8          	INY
2856   2DDF C0 2D       	CPY	#FCBLEN
2857   2DE1 D0 F6       	BNE	RF1
2858   2DE3 60          	RTS

Page     64    SHEP	APPLE DOS

2859   2DE4             	PAGE
2860   2DE4             ;
2861   2DE4             ;	FFMT  EXECUTE FORMAT REQUEST
2862   2DE4             ;
2863   2DE4             FFMT
2864   2DE4 20 30 2B    	JSR	DCBSUP		;SET UP DCB
2865   2DE7 A9 04       	LDA	#IBFMT
2866   2DE9 20 CB 2F    	JSR	DCBIO2
2867   2DEC AD 64 35    	LDA	DCBVOL		;SET VOL NO
2868   2DEF 49 FF       	EOR	#$FF
2869   2DF1 8D 2C 33    	STA	VVOLNO
2870   2DF4 A9 11       	LDA	#17
2871   2DF6 8D 56 33    	STA	VALCA1		;ALOCATE BYTE 1
2872   2DF9 A9 01       	LDA	#1
2873   2DFB 8D 57 33    	STA	VALCA2		;ADD BYTE 2
2874   2DFE             ;
2875   2DFE A2 38       	LDX	#VSECAL-VTOC
2876   2E00 A9 00       	LDA	#0
2877   2E02 9D 26 33    NT1	STA	VTOC,X		;CLEAR SECTOR AREA
2878   2E05 E8          	INX
2879   2E06 D0 FA       	BNE	NT1
2880   2E08             ;
2881   2E08 A2 0C       	LDX	#3*4		;START AT TRACK 3
2882   2E0A E0 8C       NT2	CPX	#35*4		;END AT TRACK 35
2883   2E0C F0 14       	BEQ	NT4
2884   2E0E A0 03       	LDY	#3		;4 BYTES OF INFO
2885   2E10 B9 0F 33    NT3	LDA	ALC10S,Y	;10 SECTORS ALLOCATE
2886   2E13 9D 5E 33    	STA	VSECAL,X
2887   2E16 E8          	INX
2888   2E17 88          	DEY
2889   2E18 10 F6       	BPL	NT3
2890   2E1A E0 44       	CPX	#17*4		;AT TRACK 17
2891   2E1C D0 EC       	BNE	NT2		;BR IF NOT
2892   2E1E A2 48       	LDX	#18*4		;SKIP TO 18
2893   2E20 D0 E8       	BNE	NT2
2894   2E22             ;
2895   2E22 20 6E 2F    NT4	JSR	WRVTOC		;WRITE NEW VTOC
2896   2E25             ;
2897   2E25 A2 00       	LDX	#0
2898   2E27 8A          	TXA
2899   2E28 9D 26 34    NT5	STA	VOLDIR,X	;CLEAR VOLDIR
2900   2E2B E8          	INX
2901   2E2C D0 FA       	BNE	NT5
2902   2E2E             ;
2903   2E2E 20 B8 2F    	JSR	MVVDBA		;MOVE BUF PTRS
2904   2E31             ;
2905   2E31 A9 11       	LDA	#17		;TRACK 17
2906   2E33 AC 5B 33    	LDY	VNOSEC
2907   2E36 88          	DEY
2908   2E37 88          	DEY
2909   2E38 8D EC 37    	STA	IBTRK		;INTO IOB
2910   2E3B 8D 27 34    NT6	STA	VDLTRK		;INTO LINK
2911   2E3E 8C 28 34    NT7	STY	VDLSEC
2912   2E41 C8          	INY
2913   2E42 8C ED 37    	STY	IBSECT
2914   2E45 A9 02       	LDA	#IBCWTS
2915   2E47 20 CB 2F    	JSR	DCBIO2
2916   2E4A AC 28 34    	LDY	VDLSEC
2917   2E4D 88          	DEY			;DECREMENT SECTOR
2918   2E4E 30 05       	BMI	NT8		;BR LAST WRITTEN
2919   2E50 D0 EC       	BNE	NT7		;BR NOT LAST
2920   2E52 98          	TYA			;LAST, SET LINK TRK=0
2921   2E53 F0 E6       	BEQ	NT6
2922   2E55             ;
2923   2E55             NT8
2924   2E55 20 5E 2E    	JSR	DLDSUP		;GO SET UP FOR DOSLDR
2925   2E58 20 4A 37    	JSR	WBOOT		;GO WRITE THE BOOT
2926   2E5B 4C F2 32    	JMP	GOODIO		;DONE

Page     65    SHEP	APPLE DOS

2927   2E5E             	PAGE
2928   2E5E             ;
2929   2E5E             ;	DLDSUP  SET UP FOR DOSLDR
2930   2E5E             ;
2931   2E5E             DLDSUP
2932   2E5E AD 27 35    	LDA	CCBBSA
2933   2E61 8D F1 37    	STA	IBBUFP+1	;START ADR
2934   2E64 A9 00       	LDA	#0
2935   2E66 8D F0 37    	STA	IBBUFP
2936   2E69 AD 64 35    	LDA	DCBVOL		;VOL
2937   2E6C 49 FF       	EOR	#$FF
2938   2E6E 8D EB 37    	STA	IBVOL
2939   2E71 60          	RTS

Page     66    SHEP	APPLE DOS

2940   2E72             	PAGE
2941   2E72             ;
2942   2E72             ;	MVFCBX  MOVE FCB ADRS TO ZPGFCB
2943   2E72             ;
2944   2E72 A2 00       MVFCBP	LDX	#0		;MOVE FCB ADR
2945   2E74 F0 06       	BEQ	MVF1
2946   2E76 A2 02       MVFCBD	LDX	#2		;MOVE FCB DIR BUFF
2947   2E78 D0 02       	BNE	MVF1		
2948   2E7A A2 04       MVFCBS	LDX	#4		;MOVE FCB SECTOR BUFF
2949   2E7C             ;
2950   2E7C             MVF1
2951   2E7C BD 32 35    	LDA	CFCBAD,X	;DO THE MOVE
2952   2E7F 85 42       	STA	ZPGFCB
2953   2E81 BD 33 35    	LDA	CFCBAD+1,X
2954   2E84 85 43       	STA	ZPGFCB+1
2955   2E86 60          	RTS
2956   2E87             ;
2957   2E87             ;	CLRSEC  CLEAR SECTOR
2958   2E87             ;
2959   2E87             CLRSEC
2960   2E87 A9 00       	LDA	#0
2961   2E89 A8          	TAY
2962   2E8A 91 42       CS1	STA	(ZPGFCB),Y
2963   2E8C C8          	INY
2964   2E8D D0 FB       	BNE	CS1
2965   2E8F 60          	RTS

Page     67    SHEP	APPLE DOS

2966   2E90             	PAGE
2967   2E90             ;
2968   2E90             ;	WRSECT  WRITE CURRENT SECTOR IF REQD
2969   2E90             ;
2970   2E90             WRSECT
2971   2E90 2C 40 35    	BIT	DCBWRF		;GET WRITE REQD FLAG
2972   2E93 70 01       	BVS	WRSGO		;BR IF WRITE SECTOR REQD
2973   2E95 60          	RTS			;RTS
2974   2E96             ;
2975   2E96             WRSGO
2976   2E96 20 57 2F    	JSR	MVSBA		;GO MOVE SECT BUFF ADR
2977   2E99             ;
2978   2E99 A9 02       	LDA	#IBCWTS		;GET COMMAND
2979   2E9B 20 C5 2F    	JSR	DCBIO		;GO FILL IN IOB AND DO IO
2980   2E9E             ;
2981   2E9E A9 BF       	LDA	#$BF		;SET WRITE SECTOR REQD BIT OFF
2982   2EA0 2D 40 35    	AND	DCBWRF
2983   2EA3 8D 40 35    	STA	DCBWRF
2984   2EA6 60          	RTS			;DONE

Page     68    SHEP	APPLE DOS

2985   2EA7             	PAGE
2986   2EA7             ;
2987   2EA7             ;	WRFDIR  WRITE FILE DIRECTORY IF REQD
2988   2EA7             ;
2989   2EA7             WRFDIR
2990   2EA7 AD 40 35    	LDA	DCBWRF		;GET WRITE REQD FLAG
2991   2EAA 30 01       	BMI	WRFDGO		;BR IF WRITE DIR REQD
2992   2EAC 60          	RTS			;DONE IF NOT
2993   2EAD             ;
2994   2EAD             WRFDGO
2995   2EAD 20 BE 2E    	JSR	MVFDBA
2996   2EB0             ;
2997   2EB0 A9 02       	LDA	#IBCWTS		;GET WRITE CMD
2998   2EB2 20 C5 2F    	JSR	DCBIO		;GO FILL IN IOB AND DO I/O
2999   2EB5             ;
3000   2EB5 A9 7F       	LDA	#$7F		;TURN WRITE DIR REQD BIT OFF
3001   2EB7 2D 40 35    	AND	DCBWRF
3002   2EBA 8D 40 35    	STA	DCBWRF
3003   2EBD 60          	RTS			;DONE
3004   2EBE             ;
3005   2EBE             ;	MVFDBA  MOVE FILE DIRECTORY BUFF ASDR TO IOD
3006   2EBE             ;
3007   2EBE             MVFDBA
3008   2EBE AD 34 35    	LDA	CFCBDR		;MOVE ADR
3009   2EC1 8D F0 37    	STA	IBBUFP
3010   2EC4 AD 35 35    	LDA	CFCBDR+1
3011   2EC7 8D F1 37    	STA	IBBUFP+1
3012   2ECA AE 3E 35    	LDX	DCBCDT		;GET TRACK
3013   2ECD AC 3F 35    	LDY	DCBCDS		;GET SECTOR
3014   2ED0 60          	RTS

Page     69    SHEP	APPLE DOS

3015   2ED1             	PAGE
3016   2ED1             ;
3017   2ED1             ;	RDFDIR  READ FILE DIRECTORY
3018   2ED1             ;
3019   2ED1             RDFDIR
3020   2ED1 08          	PHP			;SAVE STATUS
3021   2ED2 20 A7 2E    	JSR	WRFDIR		;GO WRITE CURRENT DIR IF REQD
3022   2ED5 20 BE 2E    	JSR	MVFDBA		;GO MOVE DBUFF ADR TO ZPG
3023   2ED8 20 76 2E    	JSR	MVFCBD		;MOVE DBUFF ADR TO ZPG
3024   2EDB 28          	PLP			;GET SAVED STATUS
3025   2EDC B0 09       	BCS	RFDNXT		;BR IF RD NEXT
3026   2EDE             ;
3027   2EDE AE 3C 35    	LDX	DCBFDT		;TRACK
3028   2EE1 AC 3D 35    	LDY	DCBFDS		;SECTOR
3029   2EE4 4C 28 2F    	JMP	RFDIO1		;GO READ
3030   2EE7             ;
3031   2EE7             RFDNXT
3032   2EE7 A0 01       	LDY	#FDLTRK		;GET LINK TRACK
3033   2EE9 B1 42       	LDA	(ZPGFCB),Y
3034   2EEB F0 08       	BEQ	RFDNL		;NR NO LINK
3035   2EED AA          	TAX			;PUT TRACK INTO X
3036   2EEE C8          	INY
3037   2EEF B1 42       	LDA	(ZPGFCB),Y	;SET LINK SECTOR
3038   2EF1 A8          	TAY			;PUT SECTOR INTO Y
3039   2EF2 4C 28 2F    	JMP	RFDIO1		;GO DO I/O
3040   2EF5             ;
3041   2EF5             RFDNL
3042   2EF5 AD 26 35    	LDA	CCBREQ		;THIS A WRITE
3043   2EF8 C9 04       	CMP	#CRQWR
3044   2EFA F0 02       	BEQ	RFDNL1		;BR IF WRITE
3045   2EFC 38          	SEC			;SET EOF
3046   2EFD 60          	RTS			;RETURN
3047   2EFE             ;
3048   2EFE             RFDNL1
3049   2EFE 20 B7 31    	JSR	GETSEC		;GET A SECTOR
3050   2F01 A0 02       	LDY	#FDLSEC
3051   2F03 91 42       	STA	(ZPGFCB),Y	;PUT IN LINK
3052   2F05 48          	PHA			;SAVE SECTOR
3053   2F06 88          	DEY
3054   2F07 AD 5C 35    	LDA	DCBATK		;GET TRACK
3055   2F0A 91 42       	STA	(ZPGFCB),Y	;PUT IN LINK
3056   2F0C 48          	PHA			;SAVE TRACK
3057   2F0D 20 AD 2E    	JSR	WRFDGO		;GO WRITE OLD DIR DEC
3058   2F10             ;
3059   2F10 20 87 2E    	JSR	CLRSEC		;CLEAN OUT DIR
3060   2F13 A0 05       	LDY	#FDFRS		;SET NEW DIR SEC 1ST REL
3061   2F15 AD 49 35    	LDA	DCBDNF		;FILE SECTOR
3062   2F18 91 42       	STA	(ZPGFCB),Y
3063   2F1A C8          	INY
3064   2F1B AD 4A 35    	LDA	DCBDNF+1
3065   2F1E 91 42       	STA	(ZPGFCB),Y
3066   2F20             ;
3067   2F20 68          	PLA			;GET SAVED TRACK
3068   2F21 AA          	TAX			;INTO X
3069   2F22 68          	PLA			;GET SAVED SECTOR
3070   2F23 A8          	TAY			;INTO Y
3071   2F24 A9 02       	LDA	#IBCWTS		;SET WRITE CMD
3072   2F26 D0 02       	BNE	RFDIO2		;GO DO I/O
3073   2F28             ;
3074   2F28 A9 01       RFDIO1	LDA	#IBCRTS		;SET READ CMD
3075   2F2A 8E 3E 35    RFDIO2	STX	DCBCDT		;SET CURR TRACK
3076   2F2D 8C 3F 35    	STY	DCBCDS		;SET CURR SECTOR
3077   2F30 20 C5 2F    	JSR	DCBIO		;GO I/O
3078   2F33             ;
3079   2F33 A0 05       RDFDC	LDY	#FDFRS		;GET POINTER TO FIRST RE SECTOR
3080   2F35 B1 42       	LDA	(ZPGFCB),Y	;GET FRS
3081   2F37 8D 47 35    	STA	DCBDFS		;SET INTO DCB
3082   2F3A 18          	CLC
3083   2F3B 6D 45 35    	ADC	DCBDMS		;ADD MAX SECTORS
3084   2F3E 8D 49 35    	STA 	DCBDNF		;PUT INTO DCB
3085   2F41             ;
3086   2F41 C8          	INY			;DO SAME FOR HI BYTE
3087   2F42 B1 42       	LDA	(ZPGFCB),Y
3088   2F44 8D 48 35    	STA	DCBDFS+1
3089   2F47 6D 46 35    	ADC	DCBDMS+1
3090   2F4A 8D 4A 35    	STA	DCBDNF+1
3091   2F4D             ;
3092   2F4D 18          	CLC
3093   2F4E 60          	RTS			;DONE

Page     70    SHEP	APPLE DOS

3094   2F4F             	PAGE
3095   2F4F             ;
3096   2F4F             ;	RDSECT  READ A SECTOR
3097   2F4F             ;
3098   2F4F             RDSECT
3099   2F4F 20 57 2F    	JSR	MVSBA		;GO MOVE SECTOR BUFFER ADR
3100   2F52             ;
3101   2F52 A9 01       	LDA	#IBCRTS
3102   2F54 4C C5 2F    	JMP	DCBIO		;GO DO I/O
3103   2F57             ;
3104   2F57             ;	MVSBA  MOVE SECTOR BUFFER ADR FOR I/O
3105   2F57             ;
3106   2F57             MVSBA
3107   2F57 AC 36 35    	LDY	CFCBSB		;GET SECTOR BUFF ADR
3108   2F5A AD 37 35    	LDA	CFCBSB+1	
3109   2F5D 8C F0 37    MSB1	STY	IBBUFP		;SET IOB SECTOR
3110   2F60 8D F1 37    	STA	IBBUFP+1	;BUFF PTR
3111   2F63 AE 41 35    	LDX	DCBTRK		;GET TRACK
3112   2F66 AC 42 35    	LDY	DCBSEC		;GET SECTOR
3113   2F69 60          	RTS			;RTN

Page     71    SHEP	APPLE DOS

3114   2F6A             	PAGE
3115   2F6A             ;
3116   2F6A             ;	RDVTOC  READ VTOC
3117   2F6A             ;	WRVTOC  WRITE VTOC
3118   2F6A             ;
3119   2F6A             RDVTOC
3120   2F6A A9 01       	LDA	#IBCRTS		;READ
3121   2F6C D0 02       	BNE	VTIO
3122   2F6E             WRVTOC
3123   2F6E A9 02       	LDA	#IBCWTS		;WRITE
3124   2F70             ;
3125   2F70 AC 3C 2A    VTIO	LDY	AVTOC		;MOVE BUFF ADR
3126   2F73 8C F0 37    	STY	IBBUFP
3127   2F76 AC 3D 2A    	LDY	AVTOC+1
3128   2F79 8C F1 37    	STY	IBBUFP+1
3129   2F7C             ;
3130   2F7C AE 65 35    	LDX	DCBVTN		;GET TRACK
3131   2F7F A0 00       	LDY	#0
3132   2F81 4C C5 2F    	JMP	DCBIO		;GO DO I/O

Page     72    SHEP	APPLE DOS

3133   2F84             	PAGE
3134   2F84             ;
3135   2F84             ;	RDVDIR  READ VOLUME DIRECTOR
3136   2F84             ;
3137   2F84             RDVDIR
3138   2F84 08          	PHP			;SAVES STATUS
3139   2F85 20 B8 2F    	JSR	MVVDBA
3140   2F88             ;
3141   2F88 28          	PLP			;GET STATUS
3142   2F89 B0 08       	BCS	RVDA		;BR IF R0 NEXT
3143   2F8B             ;
3144   2F8B AC 28 33    RVDC	LDY	VDIRSC		;GET LINK SECTOR
3145   2F8E AE 27 33    	LDX	VDIRTK		;GET FIRST TRK
3146   2F91 D0 0A       	BNE	RVDGO		;GO READ
3147   2F93             ;
3148   2F93             RVDA
3149   2F93 AE 27 34    	LDX	VDLTRK		;GET SECTOR
3150   2F96 D0 02       	BNE	RDVC		;BR IF A LINK
3151   2F98 38          	SEC			;SET END OF DIR
3152   2F99 60          	RTS
3153   2F9A             ;
3154   2F9A AC 28 34    RDVC	LDY	VDLSEC		;GET SECTOR
3155   2F9D             RVDGO
3156   2F9D 8E 06 33    	STX	CVDTRK		;SET CUR TRACK
3157   2FA0 8C 07 33    	STY	CVDSEC		;SET CUR SECTOR
3158   2FA3 A9 01       	LDA	#IBCRTS		;GET CMD
3159   2FA5 20 C5 2F    	JSR	DCBIO		;GO DO I/O
3160   2FA8 18          	CLC
3161   2FA9 60          	RTS

Page     73    SHEP	APPLE DOS

3162   2FAA             	PAGE
3163   2FAA             ;
3164   2FAA             ;	WRVDIR  WRITE VOLUME DIRECTORY SECTOR
3165   2FAA             ;
3166   2FAA             WRVDIR
3167   2FAA 20 B8 2F    	JSR	MVVDBA
3168   2FAD             ;
3169   2FAD AE 06 33    	LDX	CVDTRK		;CURRENT TRACK
3170   2FB0 AC 07 33    	LDY	CVDSEC		;CURRENT SECTOR
3171   2FB3 A9 02       	LDA	#IBCWTS		;WRITE COMMAND
3172   2FB5 4C C5 2F    	JMP	DCBIO		;GO DO I/O
3173   2FB8             ;
3174   2FB8             ;	MVVDBA  MOVE VOL DIR BUF ADR TO IOB
3175   2FB8             ;
3176   2FB8             MVVDBA
3177   2FB8 AD 3E 2A    	LDA	AVOLDR		;MOVE ADR
3178   2FBB 8D F0 37    	STA	IBBUFP
3179   2FBE AD 3F 2A    	LDA	AVOLDR+1
3180   2FC1 8D F1 37    	STA	IBBUFP+1
3181   2FC4 60          	RTS

Page     74    SHEP	APPLE DOS

3182   2FC5             	PAGE
3183   2FC5             ;
3184   2FC5             ;	DCBIO  DO I/O FOR A DCB
3185   2FC5             ;
3186   2FC5             DCBIO
3187   2FC5 8E EC 37    	STX	IBTRK		;TRACK
3188   2FC8 8C ED 37    	STY	IBSECT		;SECTOR
3189   2FCB             DCBIO2
3190   2FCB 8D F4 37    	STA	IBCMD		;COMMAND
3191   2FCE C9 02       	CMP	#IBCWTS
3192   2FD0 D0 06       	BNE	DCBIO1
3193   2FD2 0D 40 35    	ORA	DCBWRF
3194   2FD5 8D 40 35    	STA	DCBWRF
3195   2FD8             DCBIO1
3196   2FD8 AD 64 35    	LDA	DCBVOL		;VOL
3197   2FDB 49 FF       	EOR	#$FF		;UNINVERT VOL BITS
3198   2FDD 8D EB 37    	STA	IBVOL
3199   2FE0 AD 62 35    	LDA	DCBSLT		;SLOT
3200   2FE3 8D E9 37    	STA	IBSLOT
3201   2FE6 AD 63 35    	LDA	DCBDRV		;DRIVE
3202   2FE9 8D EA 37    	STA	IBDRVN
3203   2FEC AD 4D 35    	LDA	DCBSDL		;LENGTH
3204   2FEF 8D F2 37    	STA	IBDLEN
3205   2FF2 AD 4E 35    	LDA	DCBSDL+1
3206   2FF5 8D F3 37    	STA	IBDLEN+1
3207   2FF8 A9 01       	LDA	#1		;IOB TYPE
3208   2FFA 8D E8 37    	STA	IBTYPE
3209   2FFD             ;
3210   2FFD AC 3A 2A    	LDY	AIOB		;IOB ADR
3211   3000 AD 3B 2A    	LDA	AIOB+1
3212   3003 20 00 3D    	JSR	DISKIO		;GO DO I/O
3213   3006             ;
3214   3006 AD F6 37    	LDA	IBSMOD
3215   3009 8D 2A 35    	STA	CCBVOL
3216   300C A9 FF       	LDA	#$FF		;RESET VOL
3217   300E 8D EB 37    	STA	IBVOL
3218   3011 B0 01       	BCS	BADIO		;BR IF BAD
3219   3013 60          	RTS			;RTN IF GOOD
3220   3014             ;
3221   3014 AD F5 37    BADIO	LDA	IBSTAT		;GET STATUS
3222   3017 A0 07       	LDY	#CREVMM
3223   3019 C9 20       	CMP	#IBVMME		;WAS IT VOLUME MISMATCH
3224   301B F0 08       	BEQ	BD2		;BR IF YES
3225   301D A0 04       	LDY	#CREPRO
3226   301F C9 10       	CMP	#IBWPER
3227   3021 F0 02       	BEQ	BD2
3228   3023 A0 08       	LDY	#CREIOE
3229   3025 98          BD2	TYA
3230   3026 4C F8 32    	JMP	ERRORB		;GO RTN

Page     75    SHEP	APPLE DOS

3231   3029             	PAGE
3232   3029             ;
3233   3029             ;	LOCNXB  LOCATE NEXT BYTE
3234   3029             ;
3235   3029             LOCNXB
3236   3029 AD 4F 35    	LDA	DCBCRS		;IS THE CURRENT RELATIVE SECTOR
3237   302C CD 4B 35    	CMP	DCBCMS		;EQUAL TO THE CURRENT MEM SECTOR
3238   302F D0 08       	BNE	LNB1		;BR IF NOT EQ
3239   3031 AD 50 35    	LDA	DCBCRS+1
3240   3034 CD 4C 35    	CMP	DCBCMS+1
3241   3037 F0 66       	BEQ	LNB8		;BR IF REQD SECTOR IN MEM
3242   3039             ;
3243   3039             LNB1				;NEED A DIFFERENT SECTOR IN MEM
3244   3039 20 90 2E    	JSR	WRSECT		;GO WRITE SECTOR(IF REQD)
3245   303C             ;
3246   303C AD 50 35    LNB2	LDA	DCBCRS+1	;IS CURRENT REL SECTORY
3247   303F CD 48 35    	CMP	DCBDFS+1	;IS CURRENT DIRECTORY (LOW LIMIT)
3248   3042 90 1C       	BCC	LNB4		;BR IF IN A PREVIOUS DIR
3249   3044 D0 08       	BNE	LNB3		;BR IF MAYBE IN THIS ONE
3250   3046 AD 4F 35    	LDA	DCBCRS		;TEST LOW BYTES
3251   3049 CD 47 35    	CMP	DCBDFS
3252   304C 90 12       	BCC	LNB4		;BR IF IN PREVIOUS DIR
3253   304E             ;
3254   304E AD 50 35    LNB3	LDA	DCBCRS+1	;IS CURRENT REL SECTOR
3255   3051 CD 4A 35    	CMP	DCBDNF+1	;IN CURRENT DIRECTOR (HI LIMIT)
3256   3054 90 10       	BCC	LNB6		;BR IF IN THIS ONE
3257   3056 D0 08       	BNE	LNB4		;BR IF IN A NEXT DIR
3258   3058 AD 4F 35    	LDA	DCBCRS
3259   305B CD 49 35    	CMP	DCBDNF
3260   305E 90 06       	BCC	LNB6		;BR IF IN THIS ONE
3261   3060             ;				;REQD SECTOR IN A NEXT DIRECTORY
3262   3060 20 D1 2E    LNB4	JSR	RDFDIR		;GO READ NEXT FILE DIR
3263   3063 90 D7       	BCC	LNB2		;BR NXT AVAIL
3264   3065 60          	RTS			;RETURN IF EOF DIR
3265   3066             ;
3266   3066             ;
3267   3066             LNB6
3268   3066 38          	SEC			;CALCULATE DISPL INTO DIR
3269   3067 AD 4F 35    	LDA	DCBCRS		;REQD REL SECTOR MINUS
3270   306A ED 47 35    	SBC	DCBDFS
3271   306D 0A          	ASLA			;TIMES 2
3272   306E 69 0C       	ADC	#FDENT		;PLUS DISPL TO 1ST
3273   3070 A8          	TAY
3274   3071 20 76 2E    	JSR	MVFCBD		;MOVE ADR TO ZPG
3275   3074 B1 42       	LDA	(ZPGFCB),Y	;GET TRACK
3276   3076 D0 0F       	BNE	LNB7		;BR IF NOT ZERO
3277   3078 AD 26 35    	LDA	CCBREQ
3278   307B C9 04       	CMP	#CRQWR		;WRITE
3279   307D F0 02       	BEQ	LNB7A
3280   307F 38          	SEC
3281   3080 60          	RTS
3282   3081 20 A7 30    LNB7A	JSR	GNWSEC		;GO GET A NEW SECTOR
3283   3084 4C 93 30    	JMP	LNBCON
3284   3087 8D 41 35    LNB7	STA	DCBTRK		;SET TRK INTO DCB
3285   308A C8          	INY
3286   308B B1 42       	LDA	(ZPGFCB),Y	;GET SECTOR
3287   308D 8D 42 35    	STA	DCBSEC		;PUT INTO DCB
3288   3090 20 4F 2F    	JSR	RDSECT		;GO READ SECTOR
3289   3093 AD 4F 35    LNBCON	LDA	DCBCRS		;MOVE CUR REL SECTOR
3290   3096 8D 4B 35    	STA	DCBCMS
3291   3099 AD 50 35    	LDA	DCBCRS+1	;TO CUR MEM SECTOR
3292   309C 8D 4C 35    	STA	DCBCMS+1
3293   309F             ;
3294   309F             LNB8
3295   309F 20 7A 2E    	JSR	MVFCBS		;MOVE SECTOR BUFF ADR TO ZP
3296   30A2 AC 51 35    	LDY	DCBCSB		;GET SECT BYTE
3297   30A5 18          	CLC			;CARRY CLEAR = ALL OK
3298   30A6 60          	RTS			;DONE

Page     76    SHEP	APPLE DOS

3299   30A7             	PAGE
3300   30A7             ;
3301   30A7             ;
3302   30A7             GNWSEC				;NEED NEW SECTOR
3303   30A7 8C 0C 33    	STY	TEMP2		;SAVE DIR INDEX
3304   30AA 20 B7 31    	JSR	GETSEC		;GET A SECTOR
3305   30AD AC 0C 33    	LDY	TEMP2
3306   30B0 C8          	INY
3307   30B1 91 42       	STA	(ZPGFCB),Y	;SET NEW TRACK
3308   30B3 8D 42 35    	STA	DCBSEC
3309   30B6 88          	DEY
3310   30B7 AD 5C 35    	LDA	DCBATK
3311   30BA 91 42       	STA	(ZPGFCB),Y	;SET NEW TRACK
3312   30BC 8D 41 35    	STA	DCBTRK
3313   30BF             ;
3314   30BF 20 7A 2E    	JSR	MVFCBS
3315   30C2 20 87 2E    	JSR	CLRSEC		;GO CLEAR SECTOR
3316   30C5             ;
3317   30C5             ;
3318   30C5 A9 C0       	LDA	#$C0		;INDICATE BOTH
3319   30C7 0D 40 35    	ORA	DCBWRF		;DIR AND SECTOR
3320   30CA 8D 40 35    	STA	DCBWRF		;MUST BE WRITTEN
3321   30CD 60          	RTS			;DONE

Page     77    SHEP	APPLE DOS

3322   30CE             	PAGE
3323   30CE             ;
3324   30CE             ;	INCRRB  INCREMENT RELATIVE RECORD BYTE
3325   30CE             ;
3326   30CE             INCRRB
3327   30CE AE 55 35    	LDX	DCBCRR		;MOVE BYTE JUST READ OR WRITTEN
3328   30D1 8E 28 35    	STX	CCBRRN
3329   30D4 AE 56 35    	LDX	DCBCRR+1
3330   30D7 8E 29 35    	STX	CCBRRN+1
3331   30DA AE 57 35    	LDX	DCBCRB		;X=REL BYTE (LOW)
3332   30DD AC 58 35    	LDY	DCBCRB+1	;Y=REL BYTE HI
3333   30E0 8E 2A 35    	STX	CCBBYT
3334   30E3 8C 2B 35    	STY	CCBBYT+1
3335   30E6 E8          	INX			;INC REL BYTE (LOW)
3336   30E7 D0 01       	BNE	INCR1		;BR IF NO CARRY
3337   30E9 C8          	INY			;INC REL BYTE (HI)
3338   30EA             ;
3339   30EA CC 54 35    INCR1	CPY	DCBRCL+1	;REL BYTE=REC LENGTH
3340   30ED D0 11       	BNE	INCR2		;BR IF NOT
3341   30EF EC 53 35    	CPX	DCBRCL		;TEST LOW BYTES
3342   30F2 D0 0C       	BNE	INCR2
3343   30F4 A2 00       	LDX	#0
3344   30F6 A0 00       	LDY	#0		;RESET REL BYTE TO ZERO
3345   30F8 EE 55 35    	INC	DCBCRR		;AND INCR
3346   30FB D0 03       	BNE	INCR2		;RELATIVE RECORD
3347   30FD EE 56 35    	INC	DCBCRR+1
3348   3100             ;
3349   3100 8E 57 35    INCR2	STX	DCBCRB		;SAVE NEW RELATIVE BYTE
3350   3103 8C 58 35    	STY	DCBCRB+1	
3351   3106             ;
3352   3106 60          	RTS

Page     78    SHEP	APPLE DOS

3353   3107             	PAGE
3354   3107             ;
3355   3107             ;	INCSCB  INCREMENT SECTOR BYTE
3356   3107             ;
3357   3107             INCSCB
3358   3107 EE 51 35    	INC	DCBCSB		;INC SECTOR BYTE
3359   310A D0 08       	BNE	INCS2		;BR IF NOT FULL
3360   310C EE 4F 35    	INC	DCBCRS		;AND INCR
3361   310F D0 03       	BNE	INCS2		;RELATIVE SECTOR
3362   3111 EE 50 35    	INC	DCBCRS+1	
3363   3114             ;
3364   3114             ;
3365   3114             INCS2
3366   3114 60          	RTS			;DONE

Page     79    SHEP	APPLE DOS

3367   3115             	PAGE
3368   3115             ;
3369   3115             ;	MIBDA  MOVE AND INCREMENT CCBDAT
3370   3115             ;
3371   3115             MIBDA
3372   3115 AC 2E 35    	LDY	CCBBBA		;Y=ADR LOW
3373   3118 AE 2F 35    	LDX	CCBBBA+1	;X=ADR HI
3374   311B 84 42       	STY	ZPGFCB		;PUT ADR INTO ZPG
3375   311D 86 43       	STX	ZPGFCB+1
3376   311F             ;
3377   311F EE 2E 35    	INC	CCBBBA		;INC ADR LOW
3378   3122 D0 03       	BNE	MIB1		;BR IF NOT ZERO
3379   3124 EE 2F 35    	INC	CCBBBA+1	;INC ADR HI
3380   3127 60          MIB1	RTS			;DONE
3381   3128             ;
3382   3128             ;	DTBLN  DECREMENT BLOCK LENGTH AND TEST ZERO
3383   3128             ;
3384   3128             DTBLN
3385   3128 AC 2C 35    	LDY	CCBBLN		;GET LEN LOW
3386   312B D0 08       	BNE	DTB1		;BR IF NOT ZERO
3387   312D AE 2D 35    	LDX	CCBBLN+1	;GET LEN HI
3388   3130 F0 07       	BEQ	DTB2		;BR IF LEN=0
3389   3132 CE 2D 35    	DEC	CCBBLN+1	;DEC LEN (HIGH)
3390   3135 CE 2C 35    DTB1	DEC	CCBBLN		;DEC LEN (LOW)
3391   3138 60          	RTS			;DONE
3392   3139             ;
3393   3139 4C F2 32    DTB2	JMP	GOODIO		;FINISHED BLOCK

Page     80    SHEP	APPLE DOS

3394   313C             	PAGE
3395   313C             ;
3396   313C             ;	FNDFIL  FIND FILE NAME IN VOLUME DIR
3397   313C             ;
3398   313C             FNDFIL
3399   313C 20 6A 2F    	JSR	RDVTOC		;GO GET VTOC
3400   313F AD 2E 35    	LDA	CCBFN1		;MOVE FN PTR
3401   3142 85 42       	STA	ZPGFCB		;TO ZERO PAGE
3402   3144 AD 2F 35    	LDA	CCBFN1+1
3403   3147 85 43       	STA	ZPGFCB+1
3404   3149 A9 01       	LDA	#1
3405   314B 8D 0C 33    FF1	STA	TEMP2
3406   314E A9 00       	LDA	#0
3407   3150 8D 43 35    	STA	DCBVDR
3408   3153 18          	CLC
3409   3154             FF2
3410   3154 EE 43 35    	INC	DCBVDR
3411   3157 20 84 2F    	JSR	RDVDIR		;GO GET VDIR SECTOR
3412   315A B0 51       	BCS	FF4A
3413   315C A2 00       	LDX	#0		;SET FOR 1ST FILE
3414   315E             ;
3415   315E 8E 0B 33    FF3	STX	TEMP1		;SAVE INDEX
3416   3161 BD 31 34    	LDA	VDFILE,X	;GET FILE TRK
3417   3164 F0 1F       	BEQ	FF6		;BR IF LAST ENTRY
3418   3166 30 22       	BMI	FF7		;BR DELETED ENTRY
3419   3168 A0 00       	LDY	#0		;X=X+3
3420   316A E8          	INX
3421   316B E8          	INX
3422   316C E8          FF4	INX
3423   316D B1 42       	LDA	(ZPGFCB),Y	;GET FN CHAR
3424   316F DD 31 34    	CMP	VDFILE,X	;COMPARE TO ENTRY CHAR
3425   3172 D0 0A       	BNE	FF5		;BR IF NOT SAME
3426   3174 C8          	INY
3427   3175 C0 1E       	CPY	#30		;ALL 30 CHARS
3428   3177 D0 F3       	BNE	FF4		;BR IF NOT
3429   3179 AE 0B 33    	LDX	TEMP1		;GET INDEX
3430   317C 18          	CLC			;FILE FOUND
3431   317D 60          	RTS			;RETURN
3432   317E             ;
3433   317E             FF5
3434   317E 20 A3 31    	JSR	VDINC
3435   3181 90 DB       	BCC	FF3
3436   3183 B0 CF       	BCS	FF2
3437   3185             ;
3438   3185 AC 0C 33    FF6	LDY	TEMP2		;LOOKING FOR DELETED
3439   3188 D0 C1       	BNE	FF1		;BR IF NOT (DO)
3440   318A             ;
3441   318A AC 0C 33    FF7	LDY	TEMP2		;LOOKING FOR EMPTY
3442   318D D0 EF       	BNE	FF5		;BR IF NOT
3443   318F             ;
3444   318F             MVFN
3445   318F A0 00       	LDY	#0		;HAVE NEW ENTRY
3446   3191 E8          	INX
3447   3192 E8          	INX
3448   3193 E8          FF8	INX
3449   3194 B1 42       	LDA	(ZPGFCB),Y	;MOVE FILE NAME
3450   3196 9D 31 34    	STA	VDFILE,X
3451   3199 C8          	INY
3452   319A C0 1E       	CPY	#30
3453   319C D0 F5       	BNE	FF8
3454   319E             ;
3455   319E AE 0B 33    	LDX	TEMP1		;GET INDEX
3456   31A1 38          	SEC			;SET NOT OLD
3457   31A2 60          	RTS			;DONE
3458   31A3             VDINC
3459   31A3 18          	CLC
3460   31A4 AD 0B 33    	LDA	TEMP1
3461   31A7 69 23       	ADC	#35
3462   31A9 AA          	TAX
3463   31AA E0 F5       	CPX	#VDFLEN
3464   31AC 60          	RTS
3465   31AD             FF4A
3466   31AD A9 00       	LDA	#0
3467   31AF AC 0C 33    	LDY	TEMP2
3468   31B2 D0 97       	BNE	FF1
3469   31B4 4C EA 32    	JMP	ERROR9

Page     81    SHEP	APPLE DOS

3470   31B7             	PAGE
3471   31B7             ;
3472   31B7             ;	GETSEC  GET A SECTOR
3473   31B7             ;
3474   31B7             GETSEC
3475   31B7 AD 5C 35    	LDA	DCBATK		;GET ALLOCATED TRK
3476   31BA F0 21       	BEQ	GSS1		;BR IF NONE
3477   31BC             ;
3478   31BC             GS0
3479   31BC CE 5B 35    	DEC	DCBALS		;DECREMENT SECTOR NO
3480   31BF 30 17       	BMI	CS2		;BR IF NO SECTORS REM
3481   31C1             ;
3482   31C1 18          	CLC
3483   31C2 A2 04       	LDX	#4		;4 BYTE SHIFT
3484   31C4 3E 5C 35    GS1	ROL	DCBABM-1,X	;SHIFT BYTE LEFT
3485   31C7 CA          	DEX
3486   31C8 D0 FA       	BNE	GS1
3487   31CA 90 F0       	BCC	GS0		;BR IF NO SECTOR
3488   31CC             ;
3489   31CC EE 59 35    	INC	DCBNSA
3490   31CF D0 03       	BNE	GS1A
3491   31D1 EE 5A 35    	INC	DCBNSA+1
3492   31D4             GS1A
3493   31D4 AD 5B 35    	LDA	DCBALS		;GET ALLOCATED SECTOR
3494   31D7 60          	RTS			;RETURN
3495   31D8             ;
3496   31D8 A9 00       CS2	LDA	#0		;CLEAR ALLOCATED
3497   31DA 8D 5C 35    	STA	DCBATK		;TRK
3498   31DD             ;
3499   31DD A9 00       GSS1	LDA	#0		;SET SEARCH STATE=0
3500   31DF 8D 0D 33    	STA	TEMP3
3501   31E2 20 6A 2F    	JSR	RDVTOC		;GET VTOC
3502   31E5             ;
3503   31E5             GS2
3504   31E5 18          	CLC
3505   31E6 AD 56 33    	LDA	VALCA1		;GET LAST ALLOCATED TRK
3506   31E9 6D 57 33    	ADC	VALCA2		;AD (+1) OR (-1)
3507   31EC F0 09       	BEQ	GS3		;BR IF DECK TO ZERO
3508   31EE CD 5A 33    	CMP	VNOTRK
3509   31F1 90 14       	BCC	GS5		;BR IF NOT AT OUTER LIMIT
3510   31F3 A9 FF       	LDA	#$FF		;SET (-1)
3511   31F5 D0 0A       	BNE	GS4
3512   31F7 AD 0D 33    GS3	LDA	TEMP3		;GET SEARCH STATE
3513   31FA D0 37       	BNE	ERR9		;BR IF NOT ZERO
3514   31FC A9 01       	LDA	#1		;SET (+1)
3515   31FE 8D 0D 33    	STA	TEMP3		;SET SEARCH STATE = 1
3516   3201 8D 57 33    GS4	STA	VALCA2		;SET NEW (+1) OR (-1)
3517   3204 18          	CLC
3518   3205 69 11       	ADC	#17		;ADD VTOC TRK NO
3519   3207 8D 56 33    GS5	STA	VALCA1		;SET NEW LAST ALLOCATED
3520   320A 8D 5C 35    	STA	DCBATK		;PUT IN DCB
3521   320D             ;
3522   320D A8          	TAY			;ALLOCATED TRACK
3523   320E 0A          	ASLA			;TIME 4
3524   320F 0A          	ASLA
3525   3210 A8          	TAY
3526   3211 A2 04       	LDX	#4
3527   3213 18          	CLC
3528   3214 B9 61 33    GS6	LDA	VSECAL+3,Y	;MOVE BIT MAP BYTE
3529   3217 9D 5C 35    	STA	DCBABM-1,X
3530   321A F0 06       	BEQ	GS7		;BR IF NO BITS ON
3531   321C 38          	SEC			;SET HAVE A SECTOR
3532   321D A9 00       	LDA	#0		;CLEAR VTOC BYTE
3533   321F 99 61 33    	STA	VSECAL+3,Y
3534   3222 88          GS7	DEY
3535   3223 CA          	DEX
3536   3224 D0 EE       	BNE	GS6		;BR IF MORE TO MOVE
3537   3226 90 BD       	BCC	GS2
3538   3228 20 6E 2F    	JSR	WRVTOC		;GO WRITE VTOC
3539   322B AD 5B 33    	LDA	VNOSEC		;GET NO SECTORS
3540   322E 8D 5B 35    	STA	DCBALS		;SET IN DCB SECTOR BYTE
3541   3231 D0 89       	BNE	GS0		;GO ALLOCATED SECTOR
3542   3233 4C EA 32    ERR9	JMP	ERROR9

Page     82    SHEP	APPLE DOS

3543   3236             	PAGE
3544   3236             ;
3545   3236             ;	FRETRK  FREE TRACK OF SECTORS
3546   3236             ;
3547   3236             FRETRK
3548   3236 AD 5C 35    	LDA	DCBATK		;GET ALLOCATED TRACK
3549   3239 D0 01       	BNE	FT1		;BR IF NONE
3550   323B 60          	RTS			;DONE
3551   323C 48          FT1	PHA
3552   323D 20 6A 2F    	JSR	RDVTOC		;GET VTOC
3553   3240 AC 5B 35    	LDY	DCBALS		;GET SECTORS
3554   3243 68          	PLA			;GET TRACK
3555   3244 18          	CLC			;SET FREE
3556   3245 20 50 32    	JSR	FRESEC		;GO FREE
3557   3248 A9 00       	LDA	#0		;CLEAR ALLOCATED TRK
3558   324A 8D 5C 35    	STA	DCBATK
3559   324D 4C 6E 2F    	JMP	WRVTOC		;WRITE VTOC
3560   3250             ;
3561   3250             ;	FRESEC  FREE A SECTOR
3562   3250             ;		A=TRK, Y=SECTOR, C=ON/OFF
3563   3250             ;
3564   3250             FRESEC
3565   3250 A2 FC       FS1	LDX	#252		;4 BYTE SHIFT
3566   3252 7E 61 34    FS2	ROR	DCBABM-252,X	;SHIFT IN CARRY
3567   3255 E8          	INX			;NEXT BYTE
3568   3256 D0 FA       	BNE	FS2		;BR IF NOT DONE
3569   3258 C8          	INY			;INC SECTOR NO
3570   3259 CC 5B 33    	CPY	VNOSEC		;NORMAL
3571   325C D0 F2       	BNE	FS1		;BR IF NOT
3572   325E             ;
3573   325E 0A          	ASLA			;TRACK*4
3574   325F 0A          	ASLA
3575   3260 A8          	TAY
3576   3261 F0 0F       	BEQ	FS4
3577   3263 A2 04       	LDX	#4
3578   3265 BD 5C 35    FS3	LDA	DCBABM-1,X	;GET BIT MAP BYTE
3579   3268 19 61 33    	ORA	VSECAL+3,Y	;GET BIT MAP BYTE
3580   326B 99 61 33    	STA	VSECAL+3,Y	;OR WITH VTOC BM
3581   326E 88          	DEY
3582   326F CA          	DEX
3583   3270 D0 F3       	BNE	FS3
3584   3272 60          FS4	RTS			;DONE

Page     83    SHEP	APPLE DOS

3585   3273             	PAGE
3586   3273             ;
3587   3273             ;	LOCSEC  LOCATE SECTOR FOR RECORD I/O
3588   3273             ;
3589   3273             ;	RELSEC = (REL REC * RECLEN + RELBYTE)/256
3590   3273             ;	SECBYT = REMAINDER
3591   3273             ;
3592   3273             LOCSEC
3593   3273 AD 28 35    	LDA	CCBRRN		;RELATIVE RECORD NUMBER
3594   3276 8D 51 35    	STA	DCBCSB		;TO CSB FOR MULT
3595   3279 8D 55 35    	STA	DCBCRR		;AND CRR FOR SAVE
3596   327C AD 29 35    	LDA	CCBRRN+1
3597   327F 8D 4F 35    	STA	DCBCRS
3598   3282 8D 56 35    	STA	DCBCRR+1
3599   3285 A9 00       	LDA	#0
3600   3287 8D 50 35    	STA	DCBCRS+1	;HIGH CRS=0
3601   328A A0 10       	LDY	#16		;16 BIT MULT
3602   328C             ;
3603   328C AA          LS1	TAX			;SAVE MS BYTE
3604   328D AD 51 35    	LDA	DCBCSB
3605   3290 4A          	LSRA			;IF NO CARRY THEN NO PART PROD
3606   3291 B0 03       	BCS	LS1A
3607   3293 8A          	TXA
3608   3294 90 0E       	BCC	LS2
3609   3296 18          LS1A	CLC
3610   3297 AD 50 35    	LDA	DCBCRS+1	;FPORM PARTIAL PROD
3611   329A 6D 53 35    	ADC	DCBRCL
3612   329D 8D 50 35    	STA	DCBCRS+1
3613   32A0 8A          	TXA
3614   32A1 6D 54 35    	ADC	DCBRCL+1
3615   32A4             ;
3616   32A4 6A          LS2	RORA			;MULT BY 2
3617   32A5 6E 50 35    	ROR	DCBCRS+1
3618   32A8 6E 4F 35    	ROR	DCBCRS
3619   32AB 6E 51 35    	ROR	DCBCSB
3620   32AE 88          	DEY			;DEC BIT COUNT
3621   32AF D0 DB       	BNE	LS1		;BR IF MORE BITS
3622   32B1             ;
3623   32B1 AD 2A 35    	LDA	CCBBYT		;LADD REL BYTE RESULT
3624   32B4 8D 57 35    	STA	DCBCRB		;(SAVE REL BYTE)
3625   32B7 6D 51 35    	ADC	DCBCSB
3626   32BA 8D 51 35    	STA	DCBCSB
3627   32BD AD 2B 35    	LDA	CCBBYT+1
3628   32C0 8D 58 35    	STA	DCBCRB+1	;(SAVE REL BYTE)
3629   32C3 6D 4F 35    	ADC	DCBCRS
3630   32C6 8D 4F 35    	STA	DCBCRS
3631   32C9 A9 00       	LDA	#0
3632   32CB 6D 50 35    	ADC	DCBCRS+1
3633   32CE 8D 50 35    	STA	DCBCRS+1
3634   32D1 60          	RTS

Page     84    SHEP	APPLE DOS

3635   32D2             	PAGE
3636   32D2 A9 01       ERROR1	LDA	#CREFUN
3637   32D4 D0 22       	BNE	ERRORA
3638   32D6 A9 02       ERROR2	LDA	#CRERR
3639   32D8 D0 1E       	BNE	ERRORA
3640   32DA A9 03       ERROR3	LDA	#CREMRE
3641   32DC D0 1A       	BNE	ERRORA
3642   32DE A9 04       ERROR4	LDA	#CREPRO
3643   32E0 D0 16       	BNE	ERRORA
3644   32E2 A9 05       ERROR5	LDA	#CREEOF
3645   32E4 D0 12       	BNE	ERRORA
3646   32E6 A9 06       ERROR6	LDA	#CREFNF
3647   32E8 D0 0E       	BNE	ERRORA
3648   32EA A9 09       ERROR9	LDA	#CRENSA
3649   32EC D0 0A       	BNE	ERRORA
3650   32EE A9 0A       ERRR10	LDA	#CREFLK
3651   32F0 D0 06       	BNE	ERRORA
3652   32F2 AD 30 35    GOODIO	LDA	CCBSTA
3653   32F5 18          	CLC			;CARRY=CLR
3654   32F6 90 01       	BCC	RETURN		;GO RETURN
3655   32F8             ERRORA
3656   32F8 38          ERRORB	SEC			;CARRY=SET
3657   32F9             RETURN
3658   32F9 08          	PHP
3659   32FA 8D 30 35    	STA	CCBSTA		;SET STA
3660   32FD 20 D4 2D    	JSR	RTNFCB		;GO RTN FCB
3661   3300 28          	PLP			;GET STATUS
3662   3301 AE 0A 33    	LDX	ENTSTK		;GET ENT STACK
3663   3304 9A          	TXS			;RESTORE STACK
3664   3305 60          	RTS			;DONE
3665   3306             EC2

Page     85    SHEP	APPLE DOS

3666   3306             	PAGE
3667   3306             ;
3668   3306             ;	MISC DOS WORK CELLS
3669   3306             ;
3670   3306 00          CVDTRK	DB	0		;CUR VOL DIR TRK
3671   3307 00          CVDSEC	DB	0		;CUR VOL DIR SECTOR
3672   3308 00 00       CURCCB	DB	0,0		;CURRENT CCB ADR
3673   330A 00          ENTSTK	DB	0		;ENTRY STACK POINTER
3674   330B 00          TEMP1	DB	0		;TEMP BYTE 1
3675   330C 00          TEMP2	DB	0		;TEMP BYTE 2
3676   330D 00          TEMP3	DB	0		;TEMP BYTE 3
3677   330E 00          ENTSLT	DB	0		;BOOT SLOT SAVED
3678   330F 00 00 F8 FF ALC10S	DB	0,0,$F8,$FF	;ALLOCATATION TRACK BIT MAP
3679   3313 01 0A 64    CVTAB	DB	1,10,100	;CONVERSION TABLE
3680   3316 D4 C2 C1 C9 FTTAB	DB11	"TBAI"		;FILE TYPE CONVERSION TABLE
3681   331A A0 C5 CD D5 VOLMES	DB11	" EMULOV KSID"
3681   331E CC CF D6 A0 
3681   3322 CB D3 C9 C4 
3682   3326             VML	EQU	*-VOLMES-1

Page     86    SHEP	APPLE DOS

3683   3326             	PAGE
3684   3326             ;
3685   3326             ;	VTOC RECORD AREA
3686   3326             ;
3687   3326             VTOC
3688   3326 02          VDOST	DB	2		;DOS TYPE
3689   3327 11          VDIRTK	DB	17		;COLUME DIRECTORY SECTOR
3690   3328 0C          VDIRSC	DB	12		;VOLUME DIRECTORY SECTOR
3691   3329 02          VDOSRN	DB	2		;DOS RELEASE NUMBER
3692   332A 00          	DB	0		;SPARE
3693   332B 00          	DB	0		;SPARE
3694   332C 00          VVOLNO	DB	0		;VOLUME NUMBER
3695   332D             	RMB	32		;SPARE
3696   334D 7A          VTDMS	DB	122		;MAX SECTORS IN A FILE DIR
3697   334E             VSPARE	RMB	8		;SPARES
3698   3356             ;
3699   3356 11          VALCA1	DB	17		;ALOCATION ALGORITHM BYTE 1
3700   3357 01          VALCA2	DB	1		;AA BYTE 2
3701   3358 00          VALCA3	DB	0		;AA BYTE 3
3702   3359 00          VALCA4	DB	0		;AA BYTE 4
3703   335A 23          VNOTRK	DB	35		;NO TRACKS ON VOL
3704   335B 0D          VNOSEC	DB	13		;NO SECTORS PER TRACK
3705   335C 00 01       VSECLN	DW	256		;NO BYTES PER SECTOR
3706   335E             ;
3707   335E             VSECAL	EQU	*		;SECTOR ALLOCATION AREA
3708   335E             ;				SECTORS ALLOCATED BY BIT MAP
3709   335E             ;				4 BYTES OF BITS PER TRACK
3710   335E             ;				LEFT MOST BIT REPRESENTS SECTOR N
3711   335E             ;				WHERE N=NO SECTORS PER TRACK
3712   335E             ;
3713   335E             ;

Page     87    SHEP	APPLE DOS

3714   335E             	PAGE
3715   3426             	ORG	VTOC+256
3716   3426             ;
3717   3426             ;	VOLUME DIRECTORY AREA
3718   3426             ;
3719   3426             VOLDIR
3720   3426 02          VDTCDE	DB	2		;VOLUME DIRECTORY TYPECODE
3721   3427             VDLTRK	RMB	1		;VD LINK TRACK
3722   3428             VDLSEC	RMB	1		;VD LINK SECTOR
3723   3429             VDNF	RMB	1		;VD NUMBER FILES THIS SECTOR
3724   342A             VDSPAR	RMB	7		;SPARES
3725   3431             ;
3726   3431             VDFILE	EQU	*		;FILE ALLOCATION AREA (7 FILES)
3727   3431             ;				EACH FILE
3728   3431             ;					FILE DIR TRK
3729   3431             ;					FILE DIR SECTOR
3730   3431             ;					FILE USE CODE
3731   3431             ;				 FILE NAME (30)
3732   3431             ;				FILE SECTOR COUNT (2)
3733   3526             	ORG	VOLDIR+256
3734   3526             VDEND	EQU	*
3735   3526             VDLEN	EQU	*-VOLDIR
3736   3526             VDFLEN	EQU	*-VDFILE
3737   3526             ;

Page     88    SHEP	APPLE DOS

3738   3526             	PAGE
3739   3526             ;
3740   3526             ;	COMMAND CONTROL BLOCK (CCB)
3741   3526             ;
3742   3526             CCB
3743   3526             CCBREQ	RMB	1		;USER REQUEST BYTE
3744   3527             CRQNUL	EQU	0		;0-NO REQUEST
3745   3527             CRQOPN	EQU	1		;1-OPEN FILE
3746   3527             CRQCLS	EQU	2		;2-CLOSE FILE
3747   3527             CRQRD	EQU	3		;3-READ DATA
3748   3527             CRQWR	EQU	4		;WRITE DATA
3749   3527             CRQDEL	EQU	5		;5-DELETE FILE
3750   3527             CRQDIR	EQU	6		;6-READ DIRECTORY
3751   3527             CRQLCK	EQU	7		;7-LOCK FILE
3752   3527             CRQUNL	EQU	8		;8-UNLOCK FILE
3753   3527             CRQRNM	EQU	9		;9-RENAME
3754   3527             CRQPOS	EQU	10		;10-POSITION FILE
3755   3527             CRQFMT	EQU	11		;11-FORMAT
3756   3527             CRQVAR	EQU	12		;12-VERIFY
3757   3527             CRQMAX	EQU	13
3758   3527             ;
3759   3527             CCBBSA				;FORMAT  BOOT START ADR PAGE
3760   3527             CCBRQM	RMB	1		;REQUEST MODIFIER BYTE
3761   3528             CRMNUL	EQU	0		;NO MODIFIER
3762   3528             CRMNBT	EQU	1		;R/W  1  NEXT BYTE
3763   3528             CRMNBL	EQU	2		;R/W  2  NEXT BLOCK
3764   3528             CRMSBT	EQU	3		;R/W  3  SPECIFC BYTE
3765   3528             CRMSBL	EQU	4		;R/W  4  SPECIFIC BLOCK
3766   3528             CRMMAX	EQU	5
3767   3528             ;
3768   3528             CCBRRN				;I/O  RELATIVE RECORD NUMBER
3769   3528             CCBFN2				;RENAME  FILE NAME 2 PTR
3770   3528             CCBRLN	RMB	2		;OPEN  RECORD LENGTH
3771   352A             ;
3772   352A             CCBBYT				;I/O  RELATIVE RECORD NO(2 BYTES)
3773   352A             CCBVOL	RMB	1		;OPEN  VOL NO.
3774   352B             CCBDRV	RMB	1		;OPEN  DRIVE
3775   352C             ;
3776   352C             CCBBLN				;I/O  BLOCK LENGTH (2 BYTES)
3777   352C             CCBSLT	RMB	1		;OPEN  SLOT NO.
3778   352D             CCBFUC	RMB	1		;OPEN - FILE USE CODE
3779   352E             ;
3780   352E             CCBFN1				;OPEN, DELETE, LOCK, UNLOCK, RENAME  FILENAME P
3781   352E             CCBBBA				;BLCOKK I/O  BLOCK BUFFER PTR
3782   352E             CCBDAT	RMB	2		;BYTE I/O  DTA BYTE
3783   3530             ;
3784   3530             CCBSTA	RMB	1		;RESULT STATUS
3785   3531             CREFUN	EQU	1		;FCB UNALLOCATED
3786   3531             CRERR	EQU	2		;CCB REQ RANGE ERR
3787   3531             CREMRE	EQU	3		;REQ MOD RANGE ERR
3788   3531             CREPRO	EQU	4		;WRITE PROTECT
3789   3531             CREEOF	EQU	5		;END OF FILE ON READ
3790   3531             CREFNF	EQU	6		;FILE NOT FOUND
3791   3531             CREVMM	EQU	7		;VOL MIS MATCH
3792   3531             CREIOE	EQU	8		;I/O ERR
3793   3531             CRENSA	EQU	9		;NO SECTORS AVAILABLE
3794   3531             CREFLK	EQU	10		;FILE LOCKED
3795   3531             ;
3796   3531             CCBSM	RMB	1		;STATUS MODIFIER
3797   3532             CCBFCB	RMB	2		;FCB PTR
3798   3534             CCBDBP	RMB	2		;DIR BUF PTR
3799   3536             CCBSBP	RMB	2		;SECTOR BUF PTR
3800   3538             CCBSPR	RMB	4		;SPARE
3801   353C             CCBLEN	EQU	*-CCB		;CCB LENGTH
3802   353C             CFCBAD	EQU	CCBFCB
3803   353C             CFCBDR	EQU	CCBDBP
3804   353C             CFCBSB	EQU	CCBSBP

Page     89    SHEP	APPLE DOS

3805   353C             	PAGE
3806   353C             ;
3807   353C             ;	FILE CONTROL BLOCK (FCB) DEFINITION
3808   353C             ;		DCB  FILE DATA CONTROL BLOCK
3809   353C             ;
3810   353C             FCBB
3811   353C             ;
3812   353C             ;	DATA CONTROL BLOCK
3813   353C             ;
3814   353C             FCBDCB
3815   353C             DCBFDT	RMB	1		;1ST FILE DIRECTORY TRACK
3816   353D             DCBFDS	RMB	1		;1ST FILE DIRECTORY SECTOR
3817   353E             DCBCDT	RMB	1		;CURRENT FILE DIRECTORY
3818   353F             DCBCDS	RMB	1		;CURRENT FILE DIRECTORY
3819   3540             DCBWRF	RMB	1		;WRITE REQD FLAG
3820   3541             ;				;$80=WRITE FILE DIR
3821   3541             ;				;$40=WRITE SECTOR DIR
3822   3541             DCBTRK	RMB	1		;SECTOR TRACK ADR
3823   3542             DCBSEC	RMB	1		;SECTOR ADR
3824   3543             DCBVDR	RMB	1		;VOL DIR REC
3825   3544             DCBVDI	RMB	1		;VOL DIR INDEX
3826   3545             DCBDMS	RMB	2		;MAX NO DIRECTORY SECTORS
3827   3547             DCBDFS	RMB	2		;CURRENT DIR 1ST REL SECTRO
3828   3549             DCBDNF	RMB	2		;REL SECTOR OF NXT DIR
3829   354B             DCBCMS	RMB	2		;SECTOR CURRENTLY IN MEMORY
3830   354D             DCBSDL	RMB	2		;SECTOR DATA LENGTH
3831   354F             DCBCRS	RMB	2		;CURRENT RELATIVE SECTOR
3832   3551             DCBCSB	RMB	2		;REL SECTOR OF NXT DIR
3833   3553             DCBRCL	RMB	2		;SECTOR CURRENTLY IN MEMORY
3834   3555             DCBCRR	RMB	2		;SECTOR DATA LENGTH
3835   3557             DCBCRB	RMB	2		;CURRENT RELATIVE SECTOR
3836   3559             DCBNSA	RMB	2		;NO SECTORS ALLOCATED
3837   355B             ;
3838   355B             DCBALS	RMB	1		;ALLOCATION SECTOR BYTE
3839   355C             DCBATK	RMB	1		;ALLOCATION TRACK
3840   355D             DCBABM	RMB	4		;ALLOCATION TRACK SECTOR BIT MAP
3841   3561             ;
3842   3561             DCBFUC	RMB	1		;FILE USE CODE
3843   3562             DCBSLT	RMB	1		;SLOT NUMBER
3844   3563             DCBDRV	RMB	1		;DRIVE NUMBER
3845   3564             DCBVOL	RMB	1		;VOLUME DRIVER
3846   3565             DCBVTN	RMB	1		;VTOC TRACK NUMBER
3847   3566             ;
3848   3566             DCBSPR	RMB	3		;SPARES
3849   3569             ;
3850   3569             DCBLEN	EQU	*-FCBDCB	;DCB LENGTH
3851   3569             FCBLEN	EQU	*-FCBB		;FCB LENGTH

Page     90    SHEP	APPLE DOS

3852   3569             	PAGE
3853   3569             ;
3854   3569             ;	DOS	PATCH AREA 1
3855   3569             SDP1
3856   3569             EDP1	EQU	ORG2-2
3857   3569             
3858   3569             ;
3859   3569             ;	DOSLDR  DOS LOADER AND WRITTER
3860   3569             ;
3861   3600             	ORG	ORG2
3862   3600             DOSLDR
3863   3600             ;	GARBAGED BOOT REC 0 HERE
3864   3600             	RMB	254
3865   36FE 00          GRSPG	DB	0
3866   36FF 00          GRPGC	DB	0

Page     91    SHEP	APPLE DOS

3867   3700             	PAGE
3868   3700             SC3
3869   3700             ;
3870   3700             ;	READ DOS AFTER BOOT
3871   3700             ;;
3872   3700 8E E9 37    	STX	IBSLOT		;SET BOOT SLOT
3873   3703 8E F7 37    	STX	IBPSLT		;SET PREVIOUS SLOT
3874   3706 A9 01       	LDA	#1		;SET PREV DRIVE
3875   3708 8D F8 37    	STA	IBPDRV
3876   370B 8D EA 37    	STA	IBDRVN
3877   370E             ;
3878   370E AD E0 37    	LDA	NDPGS		;COPY NO PAGES TO GET
3879   3711 8D E1 37    	STA	BRWCNT
3880   3714 A9 00       	LDA	#0
3881   3716 8D EC 37    	STA	IBTRK		;SET TRACK 0
3882   3719             ;
3883   3719 AD E2 37    	LDA	BSDSEC		;COPY START DOS SECTOR
3884   371C 8D ED 37    	STA	IBSECT
3885   371F             ;
3886   371F AD E3 37    	LDA	BGNDOS		;COPY STARTR DOS ADR
3887   3722 8D F1 37    	STA	IBBUFP+1
3888   3725             ;
3889   3725 A9 01       	LDA	#IBCRTS		;SET READ
3890   3727 8D F4 37    	STA	IBCMD
3891   372A             ;
3892   372A 8A          	TXA			;SET PREV TRACK = 0
3893   372B 4A          	LSRA
3894   372C 4A          	LSRA
3895   372D 4A          	LSRA
3896   372E 4A          	LSRA
3897   372F AA          	TAX
3898   3730 A9 00       	LDA	#0
3899   3732 9D F8 04    	STA	$4F8,X
3900   3735 9D 78 04    	STA	$478,X
3901   3738 20 93 37    	JSR	BOOTIO		;GO READ DOS
3902   373B             ;
3903   373B             ;	DOSINT  INITIALIZE DOS
3904   373B             ;
3905   373B             DOSINT
3906   373B A2 FF       	LDX	#$FF
3907   373D 9A          	TXS
3908   373E 8E EB 37    	STX	IBVOL
3909   3741 20 93 FE    	JSR	SETVID
3910   3744 20 89 FE    	JSR	SETKBD
3911   3747             ;
3912   3747 4C 03 1B    DI3	JMP	DOSREL		;GO TO POST INIT ROUTINE

Page     92    SHEP	APPLE DOS

3913   374A             	PAGE
3914   374A             WBOOT
3915   374A AD F1 37    	LDA	IBBUFP+1	;GET START OF DOS
3916   374D 8D E3 37    	STA	BGNDOS		;SAVE IR
3917   3750 38          	SEC
3918   3751 AD E7 37    	LDA	ADOSLD+1	;CALCULATE
3919   3754 ED E3 37    	SBC	BGNDOS
3920   3757 8D E0 37    	STA	NDPGS		;NO DOS PAGES
3921   375A             ;
3922   375A A9 00       	LDA	#0
3923   375C 8D EC 37    	STA	IBTRK		;TRACK=0
3924   375F 8D ED 37    	STA	IBSECT		;SECTOR=0
3925   3762 8D F0 37    	STA	IBBUFP
3926   3765             ;
3927   3765 AD E7 37    	LDA	ADOSLD+1	;GET BOOT START ADR
3928   3768 8D F1 37    	STA	IBBUFP+1	;TO BUFP
3929   376B 8D FE 36    	STA	GRSPG		;TO GARBAGE RECORD
3930   376E             ;
3931   376E A9 0A       	LDA	#10		;NO OF BOOT PAGES
3932   3770 8D E1 37    	STA	BRWCNT		;TO BOOT I/O COUNTER
3933   3773 8D E2 37    	STA	BSDSEC
3934   3776 A9 48       	LDA	#$48
3935   3778 8D FF 36    	STA	GRPGC
3936   377B             ;
3937   377B A9 02       	LDA	#IBCWTS		;SET WRITE
3938   377D 8D F4 37    	STA	IBCMD
3939   3780             ;
3940   3780 20 93 37    	JSR	BOOTIO		;GO WRITE BOOT SECTORS
3941   3783             ;
3942   3783 AD E3 37    	LDA	BGNDOS		;SET START OF DOS
3943   3786 8D F1 37    	STA	IBBUFP+1
3944   3789             ;
3945   3789 AD E0 37    	LDA	NDPGS
3946   378C 8D E1 37    	STA	BRWCNT
3947   378F 20 93 37    	JSR	BOOTIO		;GO WRITE DOS
3948   3792             ;
3949   3792 60          	RTS			;DONE

Page     93    SHEP	APPLE DOS

3950   3793             	PAGE
3951   3793             BOOTIO
3952   3793 AD E5 37    	LDA	BAIOB+1
3953   3796 AC E4 37    	LDY	BAIOB
3954   3799 20 00 3D    	JSR	DISKIO
3955   379C             
3956   379C AC ED 37    	LDY	IBSECT		;GET SECTOR
3957   379F C8          	INY			;INCREMENT TO NEXT
3958   37A0 C0 0D       	CPY	#13		;AT END OF TRACK
3959   37A2 D0 05       	BNE	BIO1		;BR IF NOT SECTOR ZERO
3960   37A4 A0 00       	LDY	#0		;SET TO SECTOR ZERO
3961   37A6 EE EC 37    	INC	IBTRK
3962   37A9 8C ED 37    BIO1	STY	IBSECT		;SET NEXT SECTOR
3963   37AC             ;
3964   37AC EE F1 37    	INC	IBBUFP+1	;INCREMENT BUFFER POINTER
3965   37AF CE E1 37    	DEC	BRWCNT		;DECREMENT PAGE COUNTER
3966   37B2 D0 DF       	BNE	BOOTIO		;BR IF NOT DONE
3967   37B4 60          	RTS
3968   37B5             ;

Page     94    SHEP	APPLE DOS

3969   37B5             	PAGE
3970   37B5             ;
3971   37B5             ;	DOS PATCH AREA 1
3972   37B5             ;
3973   37B5             DP1	EQU	*
3974   3800             	BOUND 256
3975   37E0             	ORG	*-$20
3976   37E0             EC3
3977   37E0 00          NDPGS	DB	0
3978   37E1 00          BRWCNT	DB	0
3979   37E2 00          BSDSEC	DB	0
3980   37E3 00          BGNDOS	DB	0
3981   37E4 E8 37       BAIOB	DW	@@IOB
3982   37E6 00 36       ADOSLD	DW	@@DOSLDR

Page     95    SHEP	APPLE DOS

3983   37E8             	PAGE
3984   37E8             ;
3985   37E8             ;	IOB  INPUT / OUTPUT CONTROL BLOCK
3986   37E8             ;	      THE IOB IS USED FOR THE INTERFACE
3987   37E8             ;	      BETWEEN DOS AND THE DISK I/O ROUTINES
3988   37E8             ;
3989   37E8             IOB
3990   37E8 01          IBTYPE	DB	1		;IOB TYPE CODE
3991   37E9 07          IBSLOT	DB	7		;CONTROLLER SLOT NO.
3992   37EA 00          IBDRVN	DB	0		;DRIVE NUMBER
3993   37EB FF          IBVOL	DB	$FF		;VOLUME NUMBER
3994   37EC 00          IBTRK	DB	0		;TRACK NUMBER
3995   37ED 00          IBSECT	DB	0		;SECTOR NUMBER
3996   37EE FB 37       IBDCTP	DW	@@DCT
3997   37F0 00 00       IBBUFP	DW	@@0		;POINTER TO BUFFER
3998   37F2 00 01       IBDLEN	DW	256		;DATA LENGTH
3999   37F4 00          IBCMD	DB	0		;COMMAND 
4000   37F5             IBCNUL	EQU	0		;0-NULL COMMAND
4001   37F5             IBCRTS	EQU	1		;1-READ TRACK, SECTOR
4002   37F5             IBCWTS	EQU	2		;2-WRITE TRACK, SECTOR
4003   37F5             IBFMT	EQU	4		;4-FORMAT DISK
4004   37F5             IBBOOT	EQU	8		;8-WRITE BOOT
4005   37F5 00          IBSTAT	DB	0		;STATUS 
4006   37F6             IBRERR	EQU	$80		;READ ERR
4007   37F6             IBDERR	EQU	$40		;DRIVE ERR
4008   37F6             IBVMME	EQU	$20		;VOLUME MISMATCH
4009   37F6             IBWPER	EQU	$10		;WRITE PROTECT ERROR
4010   37F6 00          IBSMOD	DB	0		;STATUS MODIFIER BYTE
4011   37F7 00          IBPSLT	DB	0		;PREVIOUS SLOT
4012   37F8 00          IBPDRV	DB	0		;PREVIOUS SLOT
4013   37F9             IBSPAR	RMB	2		;IOB SPARES
4014   37FB 00 01 EF D8 DCT	DB	0,1,$EF,$D8

Page     96    SHEP	APPLE DOS

4015   37FF             	PAGE
4016   37FF             ;
4017   37FF             ;	FILE DIRECTORY DEFINITION
4018   37FF             ;
4019   0000             	ORG	0
4020   0000             FILDIR
4021   0000             FDUCDE	RMB	1		;FILE USE CODE
4022   0001             FDLTRK	RMB	1		;LINK TO NXT DIR TRACK
4023   0002             FDLSEC	RMB	1		;LINK TO NEXT DIR SECTOR
4024   0003             FDNSA	RMB	1		;NO SECTOR ALLOCATED
4025   0004             FDLSDL	RMB	1		;LAST SECTOR DATA LENGTH
4026   0005             FDFRS	RMB	2		;1ST RELATIVE SECTOR IN THIS DIR
4027   0007             FDSPAR	RMB	5		;SPARES
4028   000C             ;
4029   000C             FDENT	RMB	1		;START OF FILE ENTRIES (122)
4030   000D             FDTRK	EQU	0		;TRACK 
4031   000D             FDSEC	EQU	1		;SECTOR
4032   000D             ;
4033   000D             FDLAST	EQU	FILDIR+256

Page     97    SHEP	APPLE DOS

4034   000D             	PAGE
4035   000D             	END

       Number of errors = 0
