1
0
mirror of https://github.com/option8/OUP-M.git synced 2024-07-24 20:29:17 +00:00
OUP-M/BDOS.s
2018-10-10 15:59:20 -04:00

2478 lines
61 KiB
ArmAsm

12640 ;OUP/M BDOS WRITTEN BY SHAO, JIAN - XIONG
12650 ;ERROR NO. LISTING
12660 ;$02 DISK NO. TOO LARGE
12670 ;$03 FUNCTION NO. TOO LARGE
12680 ;$04 DISK WRITING PROTECTION
12690 ;$05 DUPLICTED FILE WHEN MAKE FILE
12700 ;$06 CHECK AREA NOT MATCH
12710 ;$07 FILE WRITING PROTECTION
12720 ;$08 FILE NOT OPEN
12730 *=$D93A
12740 START=$00 ;WARM BOOT ADDR.
12750 IOBYTE=$03 ;I/O BYTE
12760 CREG=$08 ;WORK STORAGE
12770 DEREG=$09
12780 HLREG=$08
12790 HLREG1=$0D
12800 USERSP=$10
12810 RTNFLG=$18 ;RETURN FLAG
12820 TEMP=$1F
12830 CDTDRN=$25 ;'DR' RESERVATION
12840 SCNPTS=$38 ;SCREEN LINE START POINTER
12850 CHRNUB=$3E ;CHAR. NOS IN INPUT BUFFER
12860 CSBUFS=$3F ;OFFSET OF LAST CHAR TO
12870 ;STARING ADDRESS OF THE BUFFER
12880 COUNT=$3D
12890 BRHTAB=$DBC3 ;BDOS
12900 ADCOFS=$DC80
12910 STRTFG=$DFDA
12920 RETURN=$E3D8
12930 R$TURN=$E3EE
12940 WBOOT=$E477 ;BIOS
12950 CSLTET=$E560
12960 CLINN=$E57A
12970 CLOUTT=$E591
12980 LITOUT=$E5A9
12990 ERROR=$E928
13000 BANBAC .BYTE$00 ;NO. COUNTER OF BACK SPACE
13010 PRTFLG .BYTE$00 ;PRINTER ON/OFF FLAG
13020 SCNPNT .BYTE$00 ;SCREEN LINE COUNTER
13030 PRECHR .BYTE$00 ;PREVIOUS CHARACTER
13040 WMBCOT .BYTE$2D ;
13050 ;
13060 BDOS=*
13070 ;
13080 STX CREG ;STORE PARAMETERS
13090 STA DEREG
13100 STY DEREG+1
13110 LDA #$00 ;INIT. SOME LOCATIONS FOR
13120 STA CRTDRN ;RETURN ROUTINE
13130 STA RTNFLG
13140 STA RTNFLG+1
13150 STA RTNFLG+2
13160 LDA #RETURN-1/256
13170 PHA ;SET RETURN ROUTINE ADDR.
13180 LDA #RETURN-1
13190 PHA
13200 LDA CREG ;CHECK FUNCTION NO. LEGALITY
13210 CMP #$29
13220 BCC B$0S
13230 LDA #$03 ;IF ILLEGAL, ERR!
13240 JMP ERROR
13250 B$OS=*
13260 ASL A
13270 LDX #BRHTAB ;ADDRESS FROM BRHTAB
13280 STX HLREG
13290 LDX #BRHTAB/256
13300 STX HLREG+1
13310 LDY #$00
13320 STY TEMP
13330 JSR ADCOFS
13340 LDA (HLREG),Y
13350 STA HLREG1
13360 INY
13370 LDA (HLREG),Y
13380 STA HLREG1+1
13390 LDA DEREG
13400 JHP (HLREG1) ;JMPE TO DESIRED ROUTINE
13410 REV1*=*+40
13420 ;
13430 ;******************************************************
13440 ;*
13450 ;* FUNCTION 0 : SYSTEM RESET
13460 ;*
13470 ;********************************************************
13480 ;*
13490 ;* ENTRY PARAMETERS :
13500 ;* REGISTER X : $00
13510 ;*
13520 ;*******************************************************
13530 ;
13540 SYMRST=*
13550 ;
13560 JMP WBOOT;
13570 ;
13580 INCHR=* ;GET A CHARACTER FROM CONSOLE
13590 ;
13600 LDA PRECHR
13610 BEQ I$CHR
13620 LDX #$00
13630 STX PRECHR
13640 RTS
13650 I$CHR=*
13660 LDX #$00
13670 STX PRECHR
13680 JMP CLINK
13690 RESV2*=*+4
13700 ;
13710 ;*****************************************************
13720 ;*
13730 ;* FUNCTION 1 : CONSOLE INPUT
13740 ;*
13750 ;*****************************************************
13760 ;*
13770 ;* ENTRY PARAMETERS :
13780 ;* REGISTER X : $01
13790 ;*
13800 ;* RETURNED VALUE :
13810 ;* REGISTER A : ASCII CHARACTER
13820 ;*
13830 ;***************************************************
13840 ;
13850 CSLIN=*
13860 ;
13870 JSR INCHR ;GET A CHAR FROM CONSOLE
13880 JSR C$LIN ;HANDLING CONTROL CHARACTER
13890 BCC CS$IN ;IF CONTROL CHAR EXCEPT
13900 ;'CR','LF','BA','TAB',THEN RETURN
13910 PHA
13920 JSR CSLOUT
13930 PLA
13940 CS$IN=*
13950 JMP STRTFG
13960 C$LIN=*
13970 CMP #$011 ;'CR'?
13980 BNE CSLIN1
13990 RTS
14000 CSLIN1=*
14010 CMP #$0A ;'LF'?
14020 BNE CSLIN2
14030 RTS
14040 CSLIN2=*
14050 CMP #$09 ;'TAB'?
14060 BNE CSLIN3
14070 RTS
14080 CSLIN3=*
14090 CMP #$08 ;'BA'?
14100 BNE CSLIN4
14110 RTS
14120 CSLIN4=*
14130 CMP #$20
14140 RTS
14150 ;
14160 INTPHD=* ;INTERUPTING CHAR HANDLING
14170 ;
14180 LDA PRECHR ;CHECK IF THERE IS A PREVIOUS CHAR
14190 BNE INTPH$
14200 JSR CSLTET ;TEST IF CONSOLE IS READY
14210 AND #$01
14220 BEQ I$TPHD
14230 JSR CLINN ;IF READY,READ A CHAR.
14240 CMP #$13 ;CONTROL-S?
14250 SHE IN%PHD
14260 INT$HD=*
14270 JSR CLINN ;IF IT IS CONTROL-S,WAIT UNTIL NEXT
14280 ;CHAR COMING IN.
14290 CMP #$03 ;CONTROL-C?
14300 SHE INTP$D
14310 JMP $0000 ;IF IS,TO WARM BOOT
14320 INTP$B=.
14330 LDA $00 ;IF ANOTHER CHARACTER,RETURN
14340 RTS
14350 INSPHD=*
14360 STA PRECHR ;WHEN FIRST RENDING IS NOT CTRL-S
14370 ;STORE IT TO PREV. CHAR. LOCATION
14380 INTPH$=*
14390 LDA IBFF
14400 ISTPHD=*
14410 RTS
14420 ;
14430 OUTCHR=* ;OUTPUT A CHARACTER
14440 ;
14450 PHA
14460 LDA BANBAC ;TO SEE IF THIS IS FROMN 'BA'
14470 SHE OSTCHR ;IF IS,NOT OUTPUT TO CSL
14480 JSR INTPHD ;HANDLING INTERUPTING CHAR.
14490 PLA
14500 PHA
14510 JSR CLOUTT ;OUTPUT TIS CHAR TO CONSOLE
14520 PLA
14530 PHA
14540 LDX PRTFLG ;TO SEE IF PRINTER
14550 BEQ OSTCHR
14560 JSR LITOUT ;IF ON,ALSO SENT TO PRINTER.
14570 OSTCHR=*
14580 PLA
14590 CMP #$7F ;IF IS 'DEL' ,RETURN,THAT IS, NOT
14600 ;INCREASING SCNPNT
14610 BNE OUSCHR
14620 RTS
14630 OUSCHR=*
14640 INC SCNPNT ;IF IT LESS THAN $7F, GREATER THEN
14650 ;EQUALTO $20, SCNPNT INCREASED
14660 ;BY 1
14670 CMP #$20
14680 BCC OUT$HR
14690 RTS
14700 OUT$HR=*
14710 DEC SCNPNT ;IF IT IS CTRL CHAR.,THAT IS, LESS
14720 ;THAN $20
14730 LDX SCNPNT ;THEN, NOTCHANGE SCNPNT
14740 BNE OUTC$R
14750 RTS
14760 OUTC$R=*
14770 CMP #$08 ;IF IS 'BA',SCNPNT DECREASED BY 1
14780 ONE OUTCH$
14790 DEC SCNPNT
14800 RTS
14810 OUTCH$=*
14820 CMP #$0A ;IF IS 'LF',SCNPNT SHOULD BE SET
14830 ;TO ZERO
14840 ONE OUTC$$
14850 LDA #$00
14860 STA SCNPNT
14870 OUTC$$=1
14880 RTS
14890 CSLOU$=*
14900 JSR C$LIN ;DISTINGUISH CTRL & NO-CTRL CHAR
14910 BCS CSLOUT ;EXCEPT 'CR','LF','BA','TAB'
14920 PHA
14930 LDA #$5E ;IF CTRL CHAR, OUTPUT '~', FOLLOWED
14940 ;BY A CHAR CORRES, THIS DESIRED
14950 ;CONTROL CHARACTER
14960 JSR OUTCHR
14970 PLA
14980 ORA #$40
14990 ;
15000 ;*******************************************************
15010 ;*
15020 ;* FUNCTION 2 : CONSOLE OUTPUT *
15030 ;*
15040 ;********************************************************
15050 ;*
15060 ;* ENTRY PARAMETERS :
15070 ;* REGISTER X : $02
15080 ;* REGISTER A : ASCII CHARACTER
15090 ;*
15100 ;*******************************************************
15110 ;
15120 CSLOUT=*
15130 ;
15140 CMP #$09 ;CHECK FOR 'TAB'
15150 BEQ C$LOUT
15160 JMP OUTCHR
15170 CLOUT=*
15180 LDA #$20 ;IF IS 'TAB',OUTPUT SOME SPACE TO
15190 JSR OUTCHR ;FIT THE NEEDS OF THE 'TAB'
15200 LDA SCNPNT
15210 AND #$07
15220 ONE C$LOUT
15230 RTS
15240 RESV*=*+1
15250 ;
15260 ;
15270 ;
15280 ;
15290 ;
15300 ;
15310 ;
15320 ;*****************************************************
15330 ;*
15340 ;* FUNCTION 3 : LIST OUTPUT
15350 ;*
15360 ;******************************************************
15370 ;*
15380 ;* ENTRY PARAMETERS :
15390 ;* REGISTER X : $03
15400 ;******************************************************
15410 ;
15420 LITOTT=*
15430 ;
15440 JMP LITOUT
15450 ;
15460 ;*******************************************************
15470 ;*
15480 ;* FUNCTION 4 : DIRECT CONSOLE I/0
15490 ;*
15500 ;********************************************************
15510 ;*
15520 ;* ENTRY PARAMETERS :
15530 ;* REGISTER X : $04
15540 ;* REGISTER A : $FF (INPUT) OR CHAR(OUTPUT)
15550 ;*
15560 ;* RETURNED VALUE :
15570 ;* REGISTER A : CHARACTER OR STATUS
15580 ;*
15590 ;*******************************************************
15600 ;
15610 DRCSIO=*
15620 ;
15630 TAX
15640 INX ;CHECK FOR INPUT OR OUTPUT
15650 BEQ D$CSIO
15660 JMP CLOUTT ;OUTPUT THIS CHARACTER
15670 D$CSIO=*
15680 JSR CSLTET ;TEST IF CONSOLE IS READY INPUT
15690 AND #$01
15700 BEQ DR$SIO ;IF NOT READY,RETURN
15710 JSR CLINN ;INPUT A CHARACTER
15720 DR$SIO=*
15730 JMP STRTFG
15740 REESV*=*+3
15750 ;
15760 ;
15770 ;
15780 ;
15790 ;
15800 ;
15810 ;
15820 ;
15830 ;
15840 ;
15850 ;
15860 ;********************************************************
15870 ;*
15880 ;* FUNCTION 5 : BUFFER OUTPUT
15890 ;*
15900 ;********************************************************
15910 ;*
15920 ;* ENTRY PARAMETERS :
15930 ;* REGISTER X : $05
15940 ;* REGISTER Y,A : STARTING ADDRESS OF THE BUFFER
15950 ;*
15960 ;******************************************************
15970 ;
15980 OUTBUF=*
15990 ;
16000 LDY #$00
16010 OU$BUF=*
16020 LDA (DEREG),Y
16030 CMP #$24 ;'$'?
16040 BNE O$TBUF ;IF IS,END
16050 RTS
16060 O$TBUF=*
16070 JSR CSLOUT ;IF NOT,OUTPUT THIS CHARACTER UNTIL
16080 ;$ IS MET.
16090 INY
16100 BNE OU$BUF
16110 INC DEREG+1
16120 BNE OU$BU
16130 ;
16140 BKSPAC=* ;BACK SPACE ONE CHARACTER
16150 ;
16160 JSR B$SPAC
16170 LDA 11,20
16180 JSR CLOUTT
16190 B$SPAC=*
16200 LDA #$08
16210 JMP CLOUTT
16220 ;
16230 NWLNHD=* ;POSITION CURSOR TO THE LOCA. OF NEW
16240 ;LINE CORRESPONDING TO THE ORIGINAL
16250 ;POSITION IN CURRENT LINE
16260 LDA #$23 ;OUTPUT # TO ENDED CURRENT LINE
16270 JSR OUTCHR
16280 JSR CRLFHD ;CURSOR TO A NEW LINE
16290 NW$NHD=*
16300 LDA SCNPNT ;POSITION CURSOR TO THE LOCA.
16310 ;CORRESPONDING THE ORIGINAL ONE
16320 CMP SCNPTS
16330 BCC N$LNHD
16340 RTS
16350 N$LNHD=*
16360 LDA #$20
16370 JSR OUTCHR
16380 JMP NW$NHD
16390 ;
16400 CRLFH11=*: ;CR AND LF HANDLING
16410 ;
16420 LDA #$011
16430 JSR OUTCHR
16440 LDA #$0A
16450 JMP OUTCHR
16460 ;
16470 ;*******************************************************
16480 ;*
16490 ;* FUNCTION 6 : READ CONSOLE BUFFER
16500 ;*
16510 ;*******************************************************
16520 ;*
16530 ;* ENTRY PARAMETERS ;
16540 ;* REGISTER X ; $06
16550 ;* REGISTER Y,A: STARTING ADDRESS OF THIS BUFFER *
16560 ;*
16570 ;* RETURNED VALUE :
16580 ;* CONSOLE CHARACTERS IN THE BUFFER
16590 ;*
16600 ;*******************************************************
16610 ;
16620 RDCSBF=*
16630 ;
16640 CLD
16650 LDA SCNPNT ;STORE THE INIT VALUE OF SCREEN
16660 ;LINE POINTER TO SCREEN STAR POINTER
16670 STA SCNPTS
16680 LDA #$00
16690 LDY #$01
16700 STA CHRNUB ;KEEP COUNTER OF CURRENT CHAR.S
16710 STY CSBUFS ;AND OFFSET OF THE LAST CHAR TO START
16720 ;ADDRESS OFTHEBUFFER.
16730 RD$SBF=*
16740 JSR INCHR ;GET A CHARACTER
16750 AND #$7F
16760 CMP #30D ;'CR'?
16770 BEQ RD$$$F
16780 CMP #$0A ;'LF'?
16790 BNE RDC$$$
16800 RD$$$F=*
16810 JMP RDC$$F
16820 RDC$$$=*
16830 CMP 1308 ;'BA`?
16840 BNE RDC$BF
16850 LDA CHRNUB ;'BA' HANDLING
16860 BEQ RD$SBF
16870 DEC CHRNUB ;COUNTER DECREASE BY 1
16880 LDA SCNPNT ;STORE SCREEN LINE POINTER
16890 STA BANBAC ;TO BACK SPACE NUMBER ACCOUNTER
16900 JMP RD$$BF
16910 RDC$BF=*
16920 NOP
16930 CMP #$7F ;'DEL'?
16940 BNE RDCS$F
16950 LDX CHRNUB
16960 BEQ RD$SBF
16970 DEC CHRNUB ;NUMBER ACCOUNTER AND BUFFER
16980 DEC CSBUFS ;OFFSET DECREASE BY 1 TO ELIMMINATE
16990 ;THE LAST WORD
17000 JMP RD$SB$
17010 RDCS$F=*
17020 CMP #$05 ;CONTROL-E?
17030 BNE RDCSB$
17040 JSR CRLFHD ;GIVING A 'CR','LF'COMMAND
17050 LDA #$00 ;SET SCREEN START POINTER TO ZERO
17060 STA SCNPTS
17070 JMP RD$SBF ;GET NEXT CHARACTER
17080 RDCSB$=*
17090 CMP #$10 ;CONTROL-P?
17100 BNE R$$SBF
17110 LDA #$B0 ;REVERSE THE PRINTER FLAG
17120 FOR PRTFLG
17130 STA PRTFLG
17140 JMP RD$SBF ;GET NEXT CHARACTER
17150 R$$SBF-*
17160 CMP #$18 ;'CONTROL-X '?
17170 BNE R$C$BF
17180 RDCSB1=*
17190 LDA SCMPTS ;KEEP BACKING SPACE UNTIL THE START
17200 ;POSITION OF CURRENT LINE ARRIVED
17210 CMP SCNPNT
17220 BCS RDCSBF
17230 DEC SCNPNT
17240 JSR BKSPAC
17250 JMP RDCSB1
17260 R$C$BF=*
17270 CMP #$15 ;'CONTROL U'?
17280 BNE R$CS$F
17290 JSR NWLNHD ;CREATE A NEW LINE
17300 JMP RDCSBF
17310 R$CS$F=*
17320 CMP #$12 ;'CONTROL-R'?
17330 BNE R$CSB$
17340 RD$$BF=*
17350 JSR NWLNHD ;NEW LINE HANDLING
17360 LDY #$01 ;START TO WRITE A NEW LINE FROM THE
17370 ;FIRST CHARCACTER OF CURRENT LINE IN
17380 ;CONSOLE BUFFER
17390 STY CSBUFS
17400 LDA CHRNUB
17410 STA TEMP
17420 RIICSB2=*
17430 BEQ RD$S$F
17440 INC CSBUFS ;INCRE. OFFSET TO WRITE NEXT CHAR
17450 LDY CSBUFS
17460 LDA (DEREG),Y
17470 JSR CSLOU$ ;WRITE NEXT CHARACTER
17480 DEC TEMP
17490 JMP RDCSB2
17500 RD$S$F=1
17510 LDA BANBAC ;IF AL CHAR HAVE RETYPED,CHECK FOR
17520 BNE RDCSBS
17530 JMP RD$SBF ;IF BANBAC=0
17540 RDCSB5=*
17550 SEC
17560 SBC SCNPNT ;TO FIND THE DIFFERENCE NO. BETWEEN
17570 ;CURRENT ACCOUNTER AND PREVIOUS
17580 ;ACCOUNTER
17590 STA BANBAC
17600 RDCSB3=*
17610 JSR BKSPAC ;BACK SPACE UNTIL CURRENT ACCOUNTER
17620 DEC BANBAC ;MATCHING PREVIOUS ONE
17630 BNE RDCSB3
17640 JMP RD$SBF
17650 R$C3B$=*
17660 INC CSBUFS ;SET UFFSET TO CURRENT CHAR.
17670 LDY CSBUFS
17680 STA (DEREG),Y ;STORE THE CHAR INTO CORRESPONDING
17690 ;LOCATIONN
17700 INC CHRNUB ;INCREASING CHR NUMBER 1
17710 RD$SB$=*
17720 PHA
17730 JSR CSLOU$ ;TYPE IT
17740 PLA
17750 CMP #$03 ;CHECK FOR CONTROL-C
17760 BNE RDCSB4
17770 LDA CHRNUB
17780 CMP #$01
17790 BNE RDCSB4
17800 JMP $0000 ;IF IS CTRL-C AND IN STARTING
17810 ;POSITION,GO TO WARM BOOT
17820 REICSB4=*
17830 NOP
17840 NOP
17850 LDY #$00 ;TO COMPARE CHAR NO. WITH MAX NO.
17860 LDA (DEREG),Y
17370 CMP CHRNUB
17880 BEQ RDC$$F
17890 JMP RD$SBF ;IF LESS THAN,GET NEXT CHAR.
17900 RDC$$F=*
17910 LDY #$01 ;STORE CHR NO. TO CONSOLE BUFFER
17920 ;WHEN RETURN
17930 LDA CHRNUB
17940 STA (DEREG),Y
17950 JMP CRLFHD
17960 ;
17970 ;
17980 ;
17990 ;
18000 ;
18010 ;
18020 ;*******************************************************
18030 ;*
18040 ;* FUNCTION 7 : GET INPUT/OUTPUT BYTE
18050 ;*
18060 ;*******************************************************
18070 ;*
18030 ;* ENTRY PARAMETERS :
18090 ;* REGISTER X : $07
18100 ;*
18110 ;* RETURNED VALUE :
18120 ;* REGISTER A : INPUT/OUTPUT BYTE VALUE
18130 ;*
18140 ;*******************************************************
18150 ;
18160 GTIOBY=*
18170 ;
18180 LDA IOBYTE
18190 JMP STRTFG
18200 ;
18210 ;*******************************************************
18220 ;*
18230 ;* FUNCTION 8 : SET INPUT/OUTPUT BYTE
18240 ;*
18250 ;******************************************************* *
18260 ;*
18270 ;* ENTRY PARAMETERS :
18280 ;* REGISTER X : $08
18290 ;* REGISTER A : INPUT/OUTPUT BYTE VALUE
18300 ;*
18310 ;*******************************************************
18320 ;
18330 STIOBY=*
18340 ;
18350 STA IOBYTE
18360 RTS
18370 ;
18380 ;******************************************************* *
18390 ;*
18400 ;* FUNCTION 9 : GET CONSOLE STATUS *
18410 ;*
18420 ;******************************************************* *
18430 ;*
18440 ;* ENTRY PARAMETERS :
18450 ;* REGISTER X : $09
18460 ;*
18470 ;* RETURNED VALUE :
18480 ;* REGISTER A : CONSOLE STATUS
18490 ;*
18500 ;*******************************************************
18510 ;
18520 GTCLST=*
18530 ;
18540 JSR INTPHEI
18550 JNP STRTFG
18560 *=$DBCO
18570 START=$00
18580 CREG=$08
19590 DEREG=$09
18600 HLREG=$08
18610 HLREG1=$0D
18620 FLAG=$0F ;BIT3:'1' FOR BUILD UP CHECK AREA
18630 ;BIT4:'1' FOR R/W SECTOR
18640 ;BIT5:'1' FOR ADD MAP BIT
18650 ;BIT6:'1' FOR WRITE
18660 ;BIT7:'1' FOR DIR ENTRY FINISH
18670 DIRBFA=$12 ;DIR BUFFER
18680 MAPBFA=$14 ;MAP AREA
18690 CHKBFA=$16 ;CHECK AREA
18700 RTNFLG=$18 ;THREE RETURN FLAGS
18710 DRERNB=$1C ;DIR ENTRY#
18720 DREROF=$1D ;DIR ENTRY OFFSET
18730 TEMP=$1F
18740 BLKNUB=$21 ;BLOCK NUMBER
18750 TRKNUB=$22 ;TRACK NUMBER
18760 TEMP1=$23
18770 PRVDSK=$24 ;PREVIOUS DISK#
18780 CRTDRN=$25 ;RESERVED FOR DR OF FCB
18790 CMERCT=$27 ;NUMBER OF MATCHING FCB WITH DIR
18800 DERDSK=$29 ;DESIRED DISK#
18810 RTNFG1=$2A ;AXULIRARY RETURN FLAG
18820 FLAG2=$2C
18830 CRRCNB=$2D ;CR
18840 TLRCNB=$2E ;RC
18850 EXNTNB=S2F ;EX
18860 SECNUB=$30 ;SECTOR# WITHIN A TRACK
18870 TEMP2=$37
18880 BKRBLK=$31 ;BACK BLOCK#
18890 ADVBLK=$33 ;ADVANCED BLOCK#
18900 BKOSFG=$35 ;BLOCK OFFSET FLAG
18910 BLKOFS=$36 ;BLOCK OFFSET
18920 IOBFFG=$39 ;'FLUSH' FLAG
18930 CRTDSK=$3A ;CURRENT DISK NO.
18940 CBADRV=$55 ;RESERVED FOR SERCH NEXT
18950 FLAG1=$58
18960 SYMRST=$D9A6 ;BDO1
18970 CSLIN=$D9C0
18980 CSLOUT=$DA5C
18990 LITOTT=$DA71
19000 DRCSIO=$DA74
19010 OUTBUF=$DA8B
19020 RDCSBF=$DACD
19030 GTIOBY=$D8B2
19040 STIOBY=$D8B7
19050 GTCLST=$DBBA
19060 PAMTAB=$E41F ;BIOS
19070 LITOUT=$E5A9
19080 HOMEHD=$E5F5
19090 DKSEL1=$E643
19100 SETTR1=$E665
19110 SETSC1=$E668
19120 SETBL1=$E66B
19130 STDMA1=$E66E
19140 WRTIRK=$E822
14150 RWDBS1=$E887
19160 ERROR=$E928
19170 SIOBDK=$E90A
19180 DFBUFA=$E965
19190 DIRBUF=$EB65
19200 MAPAR0=$ED65
19210 MAPAR1=$EDA5
19220 CHKAR0=SEDE5
19230 CHKAR1=$EDF3
19240 FLCTBK=$EE01
19250 IOBUF=$B000
19260 USERCD .BYTE $01 ;USER CODE
19270 WPTVCT .BYTE $00 ;R/O VECTOR
19280 LOGVTR .BYTE $00 ;LOGIN VECTOR
19290 ;BRANCH TABLE
19300 BRHTAB .WORD SYMRST,CSLIN,CSLOUT,LITOTT,DRCSIO
19310 .WORD OUTBUF,RDCSBF,GTIOBY,STIOBY,GTCLST
19320 .WORD RSDKSM,GTLGVT,GTCRDK,GTMPLT,SETWPT
19330 .WORD GTROVT,GTDKPA,SGTUCD,SETDMA,SELDSK
19340 .WORD MAKFIL,DELFIL,OPNFIL,CLSFIL,RDRCSO
19350 .WORD WTRCSO,RDRCRM,WIRCRM,SHFIST,SHNEXT
19360 .WORD RENAME,CHATRB,CPFISZ,STRDRC,SIODSK
19370 ;
19380 ;*******************************************************
19390 ;*
19400 ;* FUNCTION 10 : RESET DISK SYSTEM
19410 ;*
19420 ;*******************************************************
19430 ;*
19440 ;* ENTRY PARAMETERS :
19450 ;* REGISTERX : $0A
19460 ;*
19470 ;*******************************************************
19480 ;
19490 RSDKSM=*
19500 ;
19510 LDA #$00 ;INITIALIZE WRITING PROTECT VECTOR
19520 STA LOGVTR ;& DISK LOG VECTOR
19530 STA WPTVCT
19540 STA DERDSK ;SELECT DISK A
19550 JSR S$LDSK
19560 LDA #DFBUFA ;SELECT DEFAULT BUF FOR DMA
19570 LDX #DFBUFA/256
19580 JMF STDMA1
19590 ;
19600 ;
19610 ;
19620 ;*******************************************************
19630 ;*
19640 ;* FUNCTION 11 : GET LOGIN VECTOR
19650 ;*
19660 ;*******************************************************
19670 ;*
19680 ;* ENTRY PARAMETERS :
19690 ;* REGISTER X : $0B
19700 ;*
19710 ;* RETURNED VALUE :
19720 ;* REGISTER A : LOGIN VECTOR
19730 ;*
19740 ;******************************************************
19750 ;
19760 GTLGVT=*
19770 ;
19780 LDA LOGVTR
19790 JMP STRTFG
19800 ;
19810 ;*******************************************************
19820 ;*
19830 ;* FUNCTION 12 : GET CURRENT DISK NUMBER *
19840 ;*
19850 ;*******************************************************
19860 ;*
19870 ;* ENTRY PARAMETERS :
19830 ;* REGISTER X : $0C
19890 ;*
19900 ;* RETURNED VALUE :
19910 ;* REGISTER A : CURRENT DISK NUMBER
19920 ;*
19930 ;*******************************************************
19940 ;
19450 GTCRDK=*
19960 LDA CRTDSK
19970 JMP STRTFG
19980 ;
19990 ;********************************************************
20000 ;*
20010 ;* FUNCTION 13 : GET MAP ADDRESS OF CURRENT DISK *
20020 ;*
20030 ;********************************************************
20040 ;*
20050 ;* ENTRY PARAMETERS :
20060 ;* REGISTER X : $0D
20070 ;*
20080 ;* RETURNED VALUE :
20090 ;* REGISTER Y,A : MAP ADDRESS OF CURRENT DISK *
20100 ;*
20110 ;********************************************************
20120 ;
20130 GTMPLT=*
20140 ;
20150 LDA MAPBFA
20160 STA RTNFLG+1
20170 LDA NAPBFA+1
20180 STA RTNFLG+2
20190 RTS
20200 ;
20210 ;********************************************************
20220 ;*
20230 ;* FUNCTION 14 : SET WRITING PROTECT VECTOR
20240 ;*
20250 ;********************************************************
20260 ;*
20270 ;* ENTRY PARAMETERS :
20280 ;* REGISTER X : $0E
20290 ;*
20300 ;****************************************************
20310 ;
20320 SETWPT=*
20330 ;
20340 LDA CRTDSK ;GET BIT PATTERN FOR CURRENT
20350 JSR BNYBIT ;DISK
20360 ORA WPTVCT
20370 STA WPTVCT ;SET R/O FOR CURRENT DISK
20380 RTS
20390 ;
20400 ;********************************************************
20410 ;*
20420 ;* FUNCTION 15 : GET READ ONLY VECTOR
20430 ;*
20440 ;******************************************************
20450 ;*
20460 ;* ENTRY PARAMETERS :
20470 ;* REGISTER X : $0F
20480 ;*
20490 ;* RETURNED VALUE :
20500 ;* REGISTER A : READY ONLY VECTOR
20510 ;*
20520 ;********************************************************
20530 ;
20540 GTROVT=*
20550 ;
20560 LDA WPTVCT
20570 JMP STRTFG
20580 ;
20590 ;
20600 ;
20610 ;
20620 ;
20630 ;
20640 ;
20650 ;
20660 ;
20670 ;
20680 ;
20690 ;
20700 ;*****************************************************
20710 ;*
20720 ;* FUNCTION 1 6 : GET PARAMETER TABLE ADDRESS OF
20730 ;* CURRENT DISK
20740 ;*
20750 ;*****************************************************
20760 ;*
20770 ;* ENTRY PARAMETERS :
20780 ;* REGISTER X : $10
20790 ;*
20800 ;* RETURNED VALUE :
20810 ;* REGISTER Y,A : PARAMETER TABLE ADDRESS
20820 ;*
20830 ;********************************************************
20840 ;
20850 GTDKPA=*
20860 ;
20870 LDA CRTOSK
20880 LDX #$03
20890 JSR ASLDSR
20900 LDX #PAMTAB ;GET CORRES. ADDR.
20910 STX HLREG
20920 LDX #PAMTAB/256
20930 STX HLREG+1
20940 LDX #$00
20950 STX TEMP
20960 JSR ADCOFS
20970 LOA HLREG ;RETURN THE ADDR.
20980 STA RTNFLG+1
20990 LOA HLREG+1
21000 STA RTNFLG+2
21010 RTS
21020 ;
21030 ;*********************************************************
21040 ;*
21050 ;* FUNCTION 17 : SET/GET USERCODE
21060 ;*
21070 ;*********************************************************
21080 ;*
21090 ;* ENTRY PARAMETERS :
21100 ;* REGISTER X : $11
21110 ;* REGISTER A : $FF (GET) OR USERCODE (SET)
21120 ;*
21130 ;* RETURNED VALUE :
21140 ;* REGISTER A :CURRENT CODE OR (NO VALUE)
21150 ;*
21160 ;*********************************************************
21170 ;
21180 SGTUCD=*
21190 CMP #$FF ;CHECK WETHER SET OR GET
21200 ONE S$TUCD
21210 LDA USERCD ;GET IT
21220 JMP STRTFG
21230 S$TUCD=*
21240 AND #$1F
21250 STA USERCD ;GET IT
21260 RTS
21270 ;
21280 ;*********************************************************
21290 ;*
21300 ;* FUNCTION 18 : SET DMA ADDRESS
21310 ;*
21320 ;*****************************************************
21330 ;*
21340 ;* ENTRY PARAMETERS :
21350 ;* REGISTER X : $12
21360 ;* REGISTER Y,A : DMA ADDRESS
21370 ;
21380 ;*********************************************************
21390 ;
21400 SETDMA=*
21410 ;
21420 LDA DEREG
21439 LUX DEREG+1
21440 JMP STDMA1
21450 ;
21460 ASLDSR=* ;VALUE*(2**(X))
21470 ; ;WHERE VALUE IS IN A & TEMP
21480 ;
21490 ASL A
21500 ROL TEMP
21510 DEX
21520 BNE ASLDSR
21530 RTS
21540 ;
21550 ADCOFS=* ;ADD OFFSET TO THE ADDR.
21560 ;
21570 CLC
21530 ADC HLREG
21590 STA HLREG
21600 LDA TEMP
21610 ADC HLREG+1
21620 STA HLREG+1
21630 RTS
21640 ;
21650 GETENT=* ;GET DESIRED DIR ENTRY ADDR.
21660 ;
21670 LDA DIRBFA
21680 STA HLREG
21690 LDA DIRBFA+1
21700 STA HLREG+1
21710 LDA DREROF+1
21720 STA TEMP
21730 LDA DREROF
21740 JMP ADCOFS
21750 ;
21760 BNYBIT=* ;ENTRY:A BINARY
21770 ;EXIT:A BIT PATTERN
21780 ;
21790 TAX
21800 LDA #$01
21810 B$YBIT=*
21820 DEX
21830 BMI BN$BIT
21840 ASL A
21850 JMP B$YBIT
21860 BN$BIT=*
21870 RTS
21880 ;
21890 ;FOR THE INPUT PHYSICAL BLOCK NO.IN A &TEMP
21900 ;CACULATE THE CORRS. BYTE OFFSET FROM BIT MAP
21910 ;AND STORE IT TO Y,THE BIT PATTERN WITHIN THE
21920 ;BYTE ANDSTORE IT TO A
21930 ;
21940 GTMAPB=*:
21950 ;
21960 PHA ;LOW BYTE R-SHIFT 3 TIMES
21970 LSR A
21980 LSR A
21990 LSR A
22000 LDX #$05
22010 G$MAPB=*
22020 ASL TEMP ;HIGH BYTE L-SHIFT 5 TIMES
22030 DEX
22040 BNE G$MAPB
22050 ORA TEMP ;THE RESULT: PHY. BLOCK NO./8
22060 TAY
22070 PLA
22080 AND #$07 ;GET THE CORRES. BIT PATTERN
22090 STA TEMP+1
22100 LDA #$07
22110 SEC
22120 SBC TEMP+1
22130 JMP BNYBIT
22140 ;
22150 GTBKNB=* ;GET PHYSICAL BLOCK NO.
22160 ;AND STORE IN A & TEMP
22170 ;
22180 LDA #$00
22190 STA TEMP
22200 LDA (HLREG1),Y ;GET LOGICAL BLOCK NO.
22210 LDX #$01 ;AND *2
22220 JSR ASLDSR
22230 TAX
22240 TYA
22250 LSR A ;ODD OR EVEN?
22260 BCS G$BKNB ;ODD, -1
22270 JSR G$BKNB ;EVEN, -2
22280 G$BKNB=*
22290 CPX #$00
22300 BNE GT$KNB
22310 DEC TEMP
22320 GT$KNB=*
22330 DEX
22340 TXA
22350 RTS
22360 ;
22370 MDFMPB=* ;BUILD OR MODIFY BIT MAP
22380 ;
72390 JSR GTBKNB ;GET PHSICAL BLOCK NO.
22400 JSR GTMAPB
22410 PHA
22420 LDA #$20 ;ADD OR DELETE?
22430 BIT FLAG
22440 BEQ M$FMPB
22450 PLA
22460 ORA (MAPBFA),Y ;SET CORRES. BIT
22470 STA (MAPBFA),Y
22480 RTS
22490 M$FMPB=*
22500 PLA
22510 EOR #$FF
22520 AND (MAPBFA),Y ;RESET CORRES. BIT
22530 STA (MAPBFA),Y
22540 RTS
22550 ;
22560 MDFMAP=* ;BUILD OR MODIFY BIT MAP FOR
22570 ;WHOLE ENTRY'
22580 ;
22590 LDA HLREG ;DIR ADDR. STORE TO HLREG1
22600 STA HLREG1
22610 LDA HLREG+1
22620 STA HLREG1+1
22630 LDY #$0F
22640 MD$MAP=*
22650 INY
22660 CPY #$20 ;16 BYTES DONE?
22670 BNE M$FMAP ;NO, KEEP DOING
22680 RTS
22690 M$FMAP=*
22700 LDA (HLREG1),Y ;GET LOGICAL BLOCK NO.
22710 BEQ MD$MAP ;IF 0, SKIP IT
22720 STY TEMP1
22730 JSR MDFMPB ;IF NO 0, MODIFY CORRE. BIT MAP
22740 LDY TEMP1
22750 JMP MD$MAP
22760 ;
22770 ADDDIR=* ;GET THE CHECKSUM OF THE DIR
22780 ;BLOCK AND STORE IT TO X & TEMP
22790 ;EXIT:X,TEMP SUM OF WHOLE DIR
22800 ;
22810 LDX #$02
22820 LDY #$00
22830 LDA #$00
22840 A$DDIR=*
22850 CLC ;ADD UP ALL BYTES IN THE BLOCK
22860 ADC (HLREG),Y
22870 BCC AD$DIR
22880 INC TEMP
22890 AD$DIR=*
22900 INY
22910 BNE A$DDIR
22920 INC HLREG+1
22930 DEX
22940 BNE A$DDIR ;TWO PAGE DONE?
22950 TAX
22960 RTS
22970 ;
22980 DIRCHK=* ;BUILD OR CHECK CHECKSUM
22990 ;
23000 LDA BLKNUB ;GET OFFSET FROM CHECKSUM AREA
23010 LDX #$01 ;FOR DESIRED DIR BLOCK
23020 JSR ASLDSR
23030 PHA
23040 LDA #$00 ;SET DIR BUFFER ADDR.
23050 STA TEMP
23060 LDA DIRBFA
23070 STA HLREG
23080 LDA DIRBFA+1
23090 STA HLREG+1
23100 JSR ADDDIR ;GET CKECKSUM FOR THIS DIR BLOCK
23110 PLA
23120 TAY
23130 TXA
23140 LDA #$08
23150 BIT FLAG ;BUILD OR CHECK?
23160 BNE D$RCHK
23170 TXA ;CHECKING CHECKSUM
23180 CMP (CHKBFA),Y
23190 BNE DI$CHK
23200 INY
23210 LDA TEMP
23220 CMP (CHKBFA),Y
23230 BNE DI$CHK
23240 RTS
23250 DI$CHK=*
23260 JSR SETWPT ;IF NOT MATCH, SET CORRES. DISK
23270 LDA #$06 ;TO R/O AND DISPALY ERR
23280 JMP ERROR
23290 D$RCHK=*
23300 TXA ;BUILDING CHECKSUM
23310 STA (CHKBFA),Y
23320 INY
23330 LDA TEMP
23340 STA (CHKBFA),Y
23350 RTS
23360 ;
23370 DSKPRM=* ;GET CORRES. DISK PARAMS.
23380 ;& STORE THEM TO DIRBFA,MAPBFA
23390 ;AND CHKBFA
23400 ;
23410 LDA CRTDSK
23420 JSR DKSELI
23430 LDY #$05
23450 D$KPRM=*
23460 LDA (HLREG),Y
23470 STA DIRBFAsY
23480 DEY
23490 BPL D$KPRM
23500 ;
23510 RWDRBK=* ;READ OR WRITE DIR BLOCK
23520 ;
23530 JSR R$DRBK ;SET DIR BUFFER FOR DMA
23540 JSR RWDBS1 ;R/W A DIR BLOCK
23550 LDA #DFBUFA ;RECOVE DMA TO DEFAULT BUFFER
23560 LDX #DFBUFA/256
23570 JMP STDMA1
23580 R$DRBK=*
23590 LDA DIRBFA
23600 LDX DIRBFA+1
23610 JMP STDMA1
23620 ;
23630 RDDIRB=* ;READ DIR BLOCKS TO DIR BUFFER
23640 ;AND BUILD UP CHECKSUM
23650 ;
23660 INC DRERNB ;SET CURRENT ENTRY NO,
23670 LDA DRERNB
23680 CMP #$70 ;112 ENTRIES DONE?
23690 BCC R$DIRB
23700 LDA #$80 ;IF DONE, SET FLAG DONE
23710 ORA FLAG
23720 STA FLAG
23730 RTS
23740 R$DIRB=*
23750 AND #$0F ;GET CORRES, ENTRY OFFSET
23760 LDX #$05 ;AWAY FROM THE DIR BUFFER
23770 LDY #$00
23780 STY TEMP
23790 JSR ASLDSR
23800 STA DREROF ;STORE IT
23810 LDA TEMP
23820 STA DREROF+1
23830 ORA DREROF ;FIRST ENTRY?
23840 BEQ BDD$RB
23850 BIT FLAG1
23860 BMI BDD$RB
23870 RTS ;IF NO, RETURN
23880 BDD$RB=*
23890 STA FLAG1
23900 LDA DRERNB
23910 AND #$F0
23920 LSR A
23930 LSR A
23940 LSR A
23950 LSR A
23960 STA BLKNUB ;SET BLOCK NO.
23970 JSR SETBL1
23980 LDA #$03
23990 STA TRKNUB ;SET DIR TRACK NO.
24000 JSR SETTR1
24010 JSR RWDRBK ;READ THIS DIR BLOCK
24020 JMP DIRCHK ;BUILD UP CHECKSUM
24030 ;
24040 BUDMAP=* ;BUILD UP BIT MAP FOR
24050 ;CURRENT DISK'
24060 ;
24070 LDA #$00 ;INIT. BIT MAP TO 0
24080 LDY #$3 F
24090 B$DMAP=*
24100 STA (MAPBFA),Y
24110 DEY
24120 BPL B$DMAP
24130 LDA #$F F ;INIT. ENTRY COUNTER
24140 STA DRERNB
24150 LDA #$2 8 ;SET FLAG INDICATING READ BLOCK
24160 STA FLAG ;, BUILD BIT AMAP & CHECKSUM
24170 BUD$AP=*
24180 JSR RDDIRB ;READ A DIR BLOCK
24190 BIT FLAG ;112 ENTRIES DONE?
24200 BPL BUSMAP
24210 RTS ;YES, RETURN
24220 BU$MAP=*
24230 JSR GETENT ;GET CORRES. ENTRY ADDR.
24240 LDA $#E5
24250 LDY #$00
24260 CMP (HLREG),Y
24270 BEQ BUD$AP ;SKIP THE EMPTY ONE
24280 JSR MDFMAP ;BUILD UP THE BIT MAP FOR THE ENTRY
24290 JMP BUDSAP
24300 ;
24310 LGNMAP=* ;LOG IN CURRENT DISK
24320 ;
24330 JSR DSKPRM ;GET DISK PARA. FOR CURRENT DISK
24340 LDA CRTDSK
24350 JSR BNYBIT ;GET BIT PATTERN
24360 BIT LOGVTR
24370 BEQ L$GMAP
24380 RTS
24390 L$GMAP=*
24400 ORA LOGVTR
24410 STA LOGVTR ;LOG IN CURRENT DISK
24420 JMP BUDMAP ;BUILD UP BIT MAP & CHECKSUM
24430 RESV11*=*+3
24440 ;
24450 ;
24460 ;
24470 ;
24480 ;
24490 ;
24500 ;*********************************************************
24510 ;*
24520 ;* FUNCTION 19 : SELECT DISK
24530 ;*
24540 ;**********************************************************
24550 ;*
24560 ;* ENTRY PARAMETERS :
24570 ;* REGISTER X : $13
24580 ;* REGISTER A : SELECT DISK
24590 ;*
24600 ;**********************************************************
24610 ;
24620 SELDSK=*
24630 ;
24640 STA DERDSK ;CHECK LEGALITY
24650 CMP #$02
24660 BCC SE$DSK
24670 LDA #$02
24680 JMP ERROR
24690 SE$DSK=*
24700 CMP CRTDSK ;=CURRENT DISK?
24710 BNE S$LDSK ;IF NOT, SELECT IT AS CURRENT
24720 RTS
24730 S$LDSK=*
24740 JSR SIOBDK ;SEND LAST TRACK IN BUF TO DISK
24750 LDA DERDSK
24760 STA CRTDSK
24770 JMP LGNMAP ;BUILD UP BIT MAP & CHECKSUM FOR IT
24780 ;
24790 MDFYS2=* ;SET FCB.S2 TO INDICATE FCB HAS BEEN
24800 ;ACTIVED
24810 ;
24820 LDY #$0E
24830 LDA #380
24840 STA (DEREG),Y
24850 RTS
24860 ;
24870 FCBINZ=* ;SELECT DISK ACCORDING TO FCB
24880 ;PUT USER'S CODE TO FCB. DR
24890 ;
24900 LDA #$FF ;INIT. RETURN FLAG
24910 STA RTNFLG
24920 LDY #$00
24930 LDA (DEREG),Y ;CURRENT DISK IS DESIRED?
24940 AND #$1F
24950 BEQ F$BINZ
24960 STA DERDSK ;IF NOT, STORE IT AS DESIRED
24970 DEC DERDSK
24980 LDA CRTDSK ;KEEP CURRENT DISK
25990 STA PRVDSK
25000 LDA (DEREG),Y
25010 STA CRTDRN
25020 AND #$E0
25030 STA (DEREG),Y
25040 LDA DERDSK ;SELECT DESIRED DISK
25050 JSR SELDSK
25060 F$BINZ=*
25070 LDA USERCD ;STORE USERCODE TO FCB.DR
25080 LDY #$00
25090 ORA ( DEREG ),Y
25100 STA (DEREG),Y
25110 RTS
25120 ;
25130 TETWPT=* ;TEST FOR DISK WRITING PROTECT
25140 ;
25150 JSR T$TWPT
25160 BNE TE$WPT
25170 RTS
25130 TE$WPT=*
25190 LDA #$04
25200 JMP ERROR
25210 T$TWPT=*
25220 LDA CRTDSK
25230 JSR BNYBIT
25240 BIT WPTVCT
25250 RTS
25260 ;
25270 FBDRMH=* ;MATCHING FCB WITH DIR
25230 ;
25290 LDA #$FF ;INIT. ENTRY COUNTER
25300 STA RTNFG1
25310 FBD$$$=*
25320 STA DRERNB
25330 STX CMERCT ;KEEP MATCH NUMBERS
25340 FBDR$$=*
25350 LDA #$00 ;SET CHECKING,DIR NOT FINISH
25360 STA FLAG ;AND READING BLOCK FLAG
25370 FB$RMH=*
25380 JSR RDDIRB ;READA DIR BLOCK
25390 BIT FLAG ;112 ENTRIES DONE?
25400 BMIFBD$$H
25410 JSR GETENT ;IF NOT, GET DESIRED ENTRY ADDR.
25420 LDX CMERCT
25430 DEX ;TEST FOR MAKING FILE
25440 BEQ FED$MH
25450 INX
25460 LDY I$FF
25470 F$DRMH=*
25480 INY
25490 DEX
25500 BMIFBDR$H ;YES, FILE NAMEFOUND
25510 CPY #$0D
25520 BEQ F$DRMH
25530 LDA (DEREG),Y ;GET CURRENT CHAR AND MATCH IT
25540 JMP F$$RMH
25550 FBD$MH=*
25560 LDA #$E5 ;IF MAKE FILE, MATCH $E5
25570 LDY #$00 ;TO FIND AN EMPTY ENTRY
25580 FS$RMH=*
25590 CMP #$3F ;'?'?
25600 BEQ F$DRMH
25610 SEC
25620 SBC (HLREG),Y
25630 AND #$7F
25640 BEQ F$DRMH ;NEXT BYTE EXPECTED
25650 BNE FB$RMH ;NEXT ENTRY EXPECTED
25660 FBDR$H=*
25670 LDA DRERNB ;IF MATCH FOUND, SET MATCKED
25680 STA RTNFLG+1 ;ENTRYNO.
25690 STA RTNFG1
25700 RTS
25710 FBD$$H=*
25720 LDA #$F F ;IF NOT, SET $FF
25730 STA RTNFLG+1
25740 RTS
25750 ;
25760 PTFBBK=* ;PUT FCB TO DISK
25770 JSR GETENT ;GET DESIRED ENTRY ADDR,.
25780 LDY #$00
25790 P$FBDK=*
25800 LDA (DEREG),Y ;COPY DESIRED CHARS. FROM FCB
25810 STA (HLREG),Y ;TO DIR ENTRY
25820 INY
25830 DEX
25840 BNE P$FBDK
25850 PT$BDK=*
25860 LDA #$48
25870 ORA FLAG ;SET WRITING BLOCK FLAG
25880 STA FLAG
25890 JSR DIRCHK
25900 LDA BLKNUB ;SET DIR BLOCK
25910 JSR SETBL1
25920 LDA #$03 ;SET DIR TRACK NO.
25930 JSR SETTR1
25940 JMP RWDRBK ;WRITE DIR BLOCK TO DISK
25950 ;
25960 MKFILE=*
25970 ;
25980 JSR TETWPT ;DISK WRITE PROTECTED
25990 LDA #$10 ;ORIGINAL MAKING?
26000 BIT FLAG2
26010 BEQ M$FILE
26020 LDX #$0C
26030 JSR FBDRMH ;YES, CHECK FOR DUPLICATION
26040 BIT FLAG
26050 BMI M$FILE
26060 LDA #$05 ;IF DUPLICATED, ERR
26070 JMP ERROR
26080 M$FILE=*
26090 LDX #$01
26100 JSR FBDRMH ;GO TO FIND AN EMPTY DIR
26110 BIT FLAG ;MATCHED?
26120 BPL MK$ILE
26130 RTS
26140 MK$ILE=*
26150 LDY #$0D
26160 LDA #$00
26170 MKF$LE=*
26180 STA (DEREG),Y ;RESET REST BYTE IN FCB TO 0
26190 INY
26200 CPY$$20
26210 BNEMKF$LE
26220 LDX$$20
26230 JSR PTFBDK ;WRITE IT BACK TO DIR TRACK
26240 JMP MDFYS2 ;SET BIT 7 OF S2 TO INDICATE ACTIVED
26250 ;
26260 ;******************************************************* *
26270 ;*
26280 ;* FUNCTION 20 : MAKE FILE *
26290 ;*
26300 ;******************************************************* *
26310 ;*
26320 ;* ENTRY PARAMETERS :
26330 ;* REGISTER X : $14
26340 ;* REGISTER Y,A : FCB ADDRESS
26350 ;*
26360 ;* RETURNED VALUE :
26370 ;* REGISTER A : $FF DIRECTORY SPACE OVERFLOW
26380 ;* DIRECTORY ENTRY NUMBER IF SUCCESS*
26390 ;*
26400 ;******************************************************* ;
26410 ;
26420 MAKFIL=*
26430 ;
26440 JSR FCBINZ
26450 LDA #$10 ;SET BIT 4 OF FLAG2 TO INDICATE
26460 STA FLAG2 ;ORIGINAL MAKING
26470 JMP MKFILE
26480 ;
26490 SETRTN=*
26500 ;
26510 LDA RTNFG1
26520 JMP STRTFG
26530 ;
26540 TETFWT=* ;TEST FOR FILE WRITE PROTECT
26550 ;
26560 JSR GETENT ;GET DIR ENRTRY ADDR.
26570 LDY #$09 ;GET DIR.T1 AND CHECK IT'S BIT 7
26580 LDA (HLREG),Y
26590 TE$FWT=*
26600 ASL A
26610 BCS T$TFWT
26620 RTS
26630 T$TEWT=*
26640 LDA #$07
26650 JMP ERROR
26660 ;
26670 DLFILE=*
26680 ;
26690 JSR TETWPT ;DISK WRITE PROTECTED
26700 LDX #$0C ;FIND DESIRED DIR ENTRY
26710 JSR FBDRMH
26720 DL$ILE=*
26730 BIT FLAG
26740 BPL D$FILE
26750 RTS
26760 D$FILE=*
26770 JSR TETFWT ;FILE WRITE PROTECTED
26780 JSR GETENT ;GET DESIRED ENTRY ADDR.
26790 LDY #$00 ;SET $E5 TO INDICATE DELETED
26800 LDA #$E 5
26810 STA (HLRE6),Y
26820 JSR MDFMAP ;MODIFY MAP
26830 JSR PT$BDK ;PUT DIR TO DISK
26840 JSR FBDR$$
26850 JMP DL$ILE ;KEEP DOING, TILL ALL DONE
26860 RESV12*=*+3
26870 ;
26380 ;*******************************************************
26690 ;*
26900 ;* FUNCTION 2 1 : DELETE FILE
26910 ;*
26920 ;*******************************************************
26930 ;*
26940 ;* ENTRY PARAMETERS :
26950 ;* REGISTER X : $15
26960 ;* REGISTER Y,A: FCB ADDRESS
26970 ;*
26980 ;* RETURNED VALUE :
26990 ;* REGISTER A : $FF FILE NOT FOUND
27000 ;* DIRECTORY ENTRY NUMBER IF SUCCESS *
27010 ;*
27020 ;*******************************************************
27030 ;
27040 DELFIL=*
27050 ;
27060 JSR FCBINZ
27070 JSR DLFILE
27080 JMP SETRTN
27090 ;
27100 CPDRFB=* ;COPY DIR ENTRY TO FCB
27110 ;
27120 JSR GETENT
27130 LDY #$00
27140 C$DRFB=*
27150 LDA (HLREG),Y
27160 STA (DEREG),Y
27170 INY
27180 CPY #$20
27190 BNE C$DRFB
27200 RTS
27210 ;
27220 OPFILE=*
27230 ;
27240 LDX #$0D ;FIND DESIRED DIR ENTRY
27250 JSR FBDRMH
27260 BIT FLAG
27270 BPL O$FILE
27280 RTS
27290 O$FILE=*
27300 JSR CPDRFB ;COPY DIR ENTRY TO FCB
27310 JMP MDFYS2
27320 ;
27330 ;*******************************************************
27340 ;*
27350 ;* FUNCTION 22 : OPEN FILE
27360 ;*
27370 ;*******************************************************
27380 ;*
27390 ;* ENTRY PARAMETERS :
27400 ;* REGISTER X : $16
27410 ;* REGISTER Y,A : FCB ADDRESS
27420 ;*
27430 ;* RETURNED VALUE :
27440 ;* REGISTER A : $FF FILE NOT FOUND
27450 ;* DIRECTORY ENTRY NUMBER IF SUCCESS *
27460 ;*
27470 ;*******************************************************
27480 ;
27490 OPNFIL=*
27500 ;
27510 JSR FCBINZ
27520 JMP OPFILE
27530 ;
27540 CLFILE=*
27550 ;
27560 LDA #$00
27570 STA RTNFLG+1
27580 JSR TETWPT ;DISK WRITE PROTECTED
27590 LDY #$0E
27600 LDA (DEREG),Y
27610 ASL A
27620 ASL A
27630 BCS C$FILE
27640 RTS
27650 C$FILE=4
27660 LDX #$0D ;FIND A MATCHED ENTRY
27670 JSR FBDRMH
27680 BIT FLAG
27690 BPL CL$ILE
27700 RTS
27710 CL$ILE=*
27720 JSR GETENT ;GET THE ADDR.
27730 LDY #$10
27740 CLFI$$=*
27750 ;COPY FILE LOCATION AREA IN FCB TO THE DIR ENTRY'
27760 ;NOTE : IF (CORRS. BYTES NOT MATCH) AND (NONE OF '
27770 ;THEM ARE 0 , THEN ERR. OTHERWISE, COPY NONE 0 BYTE'
27780 ;TO 0 BYTE IF ONE OF THEM IS 0; OR LEAVE MATCHED'
27790 ;PAIR ALONE'
27800 LDA (DEREG),Y ;COPY FILE LOCATION AREA IN FCB
27810 BNE CLF$LE
27820 LDA (HLREG),Y
27830 STA (DEREG),Y
27840 CLF$LE=*
27850 LDA (HLREG),Y
27860 BNE CLFI$E
27870 LDA (DEREG),Y
27880 STA (HLREG),Y
27890 CLFI$E=*
27900 LDA (DEREG),Y
27910 CMP (HLREG),Y
27920 BNE CLFIL$
27930 INY
27940 CPY #$20
27950 BNE CLF#$$
27960 LDY #$0F ;COPY 'RC' FROM FCB TO DIR ENTRY
27970 LDA (DEREG),Y
27980 STA (HLREG),Y
27990 JMP PT$BDK ;PUT DIR BLOCK TO DISK
28000 CLFIL$=*
28010 DEC RTNFLG+1 ;IF ERR, SET $FF TO INDICATE NOT SUECC.
28020 RTS
28030 ;
28040 ;*********************************************************
28050 ;*
28060 ;* FUNCTION 23 : CLOSE FILE
28070 ;*
28080 ;*********************************************************
28090 ;*
28100 ;* ENTRY PARAMETERS :
28110 ;* REGISTER X : $17
28120 ;* REGISTER Y,A: FCB ADDRESSS;
28130 ;*
28140 ;* RETURNED VALUE :;
28150 ;* REGISTER A : $FF FILE NOT FOUND;
28160 ;* DIRECTORY ENTRY NUMBER IF SUCCESS
28170 ;*
28180 ;*********************************************************
28190 ;
28200 CLSFIL=*
28210 ;
28220 JSR FCBINZ
28230 JMP CLFILE
28240 ;
28250 STRTFG=* ;SET RETURN FLAG
28260 ;
28270 STA RTNFLG+1
28280 RTS
28290 ;
28300 FLEDRT=* ;FILE END RETURN
28310 ;
23320 LDA #$01
28330 JMP STRTFG
23340 ;
28350 GETREC=* ;GET RC,EX,CR AND STORE THEM
28360 ;
28370 LDY #$0C
28380 LDA (DEREG),Y
28390 STA EXNTNB
28400 LDY #$0F
28410 LDA (DEREG),Y
28420 STA TLRCNB
28430 LDY #$20
28440 LDA (DEREG),Y
28450 STA CRRCNB
28460 RTS
28470 ;
28480 TETOPN=* ;;TEST FOR FCB OPENING
28490 ;
28500 LDY #$0E
28510 LDA (DEREG),Y
28520 ASL A
28530 RCS T$TOPN
28540 LDA #$08
28550 JMP ERROR
28560 T$TOPN=*
28570 RTS
28580 ;
28590 GTBKOF=* ;KNOWING FCB.RC TO GET CURRENT
28600 ;POSITION IN FCB FILE LOCATION AREA'
28610 ;TO Y AND SECTOR# WITHIN THIS BLOCK
28620 ;TO TEMP2
28630 ;
28640 LDA #$03
28650 AND CRRCNB
28660 STA TEMP2
28670 LDA CRRCNB
28680 LSR A
28690 LSR A
28700 CLC
28710 ADC #$10
28720 TAY
28730 RTS
28740 ;
28750 GTRLBS=* ;GET PHYSICAL BLOCK NO. AND
28760 ;SECTOR NO. WITHIN THE BLOCK
28770 ;
28780 JSR GTBKOF ;GET CURRENT POSITION AND
28790 ;SECTOR NO. WITIHIN THE BLOCK
28800 LDA (DEREG),Y ;GET LOGICAL BLOCK NO.
28810 BEQ G$RLBS ;SKIP 0
28820 LDX DEREG
28830 SIX HLREG ;CACULATE PHYSICAL BLOCK NO.1
28340 LDX DEREG+1
28850 STX HLREGI+1
28360 JSR GTBKNB
28870 LDX #$01
28380 GSRLBS=*
28890 RTS
28900 ;
28910 GTTKSC=* ;GET TRACK# AND PHYSICAL SECTOR
28920 ;WITHIN THIS TRACK
28930 ;ENTRY PHYSICAL BLOCK# IN A,TEMP
28940 ;EXIT X TRACK#,A PHYSICAL SECTOR
28950 ;
28960 LDX #$FF
28970 G$TKSC=*
28980 SEC
28990 INX ;BLOCK# DIV 7 TO GET TRACK NO.
29000 SBC #$07
29010 BCS GSTKSC
29020 DEC TEMP
29030 BPL G$TKSC
29040 ADC #$07 ;BLOCK# MOD 7
29050 ASL A
29060 ASL A ;(BLOCK# MOD 7)*4
29070 CLC
29080 ADC TEMP2 ;ADDING THE SECTOR NO. WITHIN
29090 ;THE BLOCK TO GET SECTOR NO. '
29100 ;WITHIN THE TRACK
29110 PHA
29120 TXA
29130 SED
29140 ADC #$04 ;
29150 CLD
29160 TAX ;PUT TRACKNO.TO X
29170 PLA ;PUT SECTOR NO. TO A
29180 RTS
29190 ;
29200 RWSCDF=* ;READ A SECTOR INTO DEFAULT BUFFER
29210 ;
29220 STX TRKNUB
29230 JSR SETSC1
29240 TXA
29250 JSR SETTR1 ;SET TRACK NO.
29260 JMP RWDBS1
29270 ;
29280 MDFFCB=* ;MODIFY FCB TO FIT NEXT OPERATION
29290 ;
29300 BIT FLAG2 ;RAN. OR SEQ. MODE?
29310 BPL M$FFCB
29320 INC CRRCNB
29330 M$FFCB=*
29340 LDA CRRCNB
29350 LDY #$20
29360 STA (DEREG),Y ;STORE TO FCB.CR
29370 LDA TLRCNB
29380 LDY #$0F
29390 STA (DEREG),Y ;STORE TO FCB.RC
29400 RTS
29410 ;
29420 HDNTEN=* ;DEAL WITH NEXT EXTENT ENTRY
29430 ;
29440 JSR CLFILE ;CLOSE THE CURRENT EXTENT
29450 LDX RTNFLG+1 ;$FF MEANS NOT SUCCES.
29460 INX
29470 ONE H$NTEN ;SUCCES! CONTINUE.
29480 RTS
29490 H$NTEN=*
29500 LDY #$0C
29510 LDA #$01
29520 CLC
29530 ADC (DEREG),Y ;INCREAMENT 'EX' BY 1
29540 STA (DEREG),Y
29550 LDX #$0D ;FIND A CORRES. 'EX' IN DIR
29560 JSR FBDRMH
29570 BIT FLAG ;FOUND?
29580 BPL H$$TEN
29590 BIT FLAG2 ;IF NOT, CHHECK R OR W?
29600 BVC HDN$EN
29610 JMP FLEDRT ;IF R, ERR
29620 HDN$EN=*
29630 JSR MKFILE ;IF W, CREATE A NEW 'EX'
29640 BIT FLAG
29650 BPL HDNT$N
29660 LDA #$03
29670 JMP STRTFG
29680 H$$TEN=*
29690 JSR O$FILE ;COPY CORRES. BYTES IN DIR TO FCB
29700 HEINT$N=4
29710 JSR GETREC ;GET 'EX','RC','CR' AND STORE THEM
29720 LDA #$00
29730 JMP STRTFG ;SET SUCCES.FLAG
29740 ;
29750 RDRCS1=*
29760 ;
29770 JSR TETOPN ;FILE OPENED?
29780 LDA #$E0 ;SET FLAG2 TO INDICATE SEQ. R
29790 STA FLAG2
29800 RDRCS$=*
29810 JSR GETREC
29820 LDA CRRCNB ;'CR'<'RC'?
29830 CMP TLRCNB
29840 BCC R$RCSQ ;YES, GO AHEAD TO READ
29850 CMP #$40 ;NO, CHECK 'CR'=$40?
29860 BEQ RD$CSQ
29870 JMP FLEDRT ;IF NOT,ERR
29880 RD$CS0=*
29890 JSR HDNTEN ;CLOSE CURRENT 'EX', OPEN NEXT
29900 LDA #$00 ;RESET CRRCNB
29910 STA CRRCNB
29920 LDA RTNFLG+1 ;SUCCES.
29930 BEQ R3RCSO
29940 JMP STRTFG
29950 R$RCSQ=*
29960 JSR GTRLBS ;GET PHY. BLOCK NO.
29970 BNE RDRC$Q
29980 LDA #$02 ;IF CORRES. LOG. BLO. NO.=0, ERR
29990 JMP STRTFG
30000 RDRC$Q=*
30010 JSR GTTKSC ;GET TRACK NO. & SECTOR NO.
30020 LDY #$10
30030 STY FLAG
30040 JSR RWSCDF ;READ A SECTOR
30050 JMP MDFFCB ;MODIFY BIT MAP
30060 ;
30070 ;*******************************************************
30080 ;*
30090 ;* FUNCTION 24 : READ SEQUENTIALLY
30100 ;*
30110 ;*******************************************************
30120 ;
30130 ;* ENTRY PARAMETERS
30140 ;* REGISTER X : $18
30150 ;* REGISTER Y , A : FCB ADDRESS
30160 ;*
30170 ;* RETURNED VALUE
30180 ;* REGISTER A:$00 SUCCESS
30190 ;* $01 FILE END
30200 ;* $02 RECORD NOT IN DISK
30210 ;*
30220 ;*******************************************************
30230 ;
30240 RDRCSQ=1
30250 ;
30260 JSR FCBINZ
30270 JMP RDRCS1
30280 ;
30290 FNDEPT=* ;FIND EMPTY BLOCK,ENTRY A,TEMP
30300 ;PHY. BLOCK OF THE ONE BEFORE IT
30310 ;EXIT A,TEMP EMPTY PHY. BLOCK#
30320
30330 STA BKRBLK ;SET BK. & AD. COUNTER
30340 STA ADVBLK
30350 LDA TEMP
30360 STA BKRBLK+1
30370 STA ADVBLK+1
30380 LDA #$01 ;SET CURRENT POINTER ODD OR EVEN FLAG
30390 AND BLKOFS
30400 STA BKOSFG
30410 F$$EPT=*
30420 LDA BKRBLK ;BK. SEARCK REACH BOTTOM?
30430 ORA BKRBLK+1
30440 BEQ F$DEPT ;YES:GO TO AD. SEARCH
30450 FNS$PT=*
30460 LDA BKRBLK
30470 BNE FN$EPT ;BK. SEARCH
30480 DEC BKRBLK+1
30490 FN$EPT=*
30500 DEC BKRBLK
30510 LDA BKRBLK ;BK. COUNTER MATCH THE E/O FLAG SET BEF?
30520 AND #$01
30530 CMP BKOSFG
30540 BNE F$$EPT
30550 LDA BKRBLK ;NO, SKIP IT
30560 LDX BKRBLK+1 ;YES, GET CORRES. BYTE & BIT PATTERN
30570 STX TEMP ;IN BIT MAP AREA
30580 JSR GTMAPB
30590 TAX
30600 AND (MAPBFA),Y
30610 BNE F$DEPT ;OCCUPIED?
30620 TXA :YES: TO AD. SEARCH
30630 ORA (MAPBFA),Y ;NO,SET BIT MAP
30640 STA (MAPBFA),Y
30650 LDA BKRBLK+1
30660 STA TEMP ;BK. COUNTER AS FOUND PHY. BLOCK
30670 LDA BKRBLK ;NO. THEN RETURN
30680 RTS
30690 F$DEPT=*
30700 LDA ADVBLK
30710 CMP #$FF ;AD. SEARCH TOP REACHED?
30720 BNE FNDSPT
30730 LDA ADVBLK+1
30740 CMP #$01
30750 BEQ FNDE$T ;YES: TO CHECK IF BA. BOTTOM REACHED?
30760 FNDSPT=*
30770 INC ADVBLK ;INCREMENT AD. COUNTER BY 1
30780 BNE FNDE$$
30790 INC ADVBLK+1
30800 FNDE$$=*
30810 LDA ADVBLK ;THE SAME PROCESS AS IN BA. SEARCH
30820 AND #$01
30830 CMP BKOSFG
30840 BNE F$DEPT
30850 LDA ADVBLK
30860 LDX ADVELK+1
30870 STX TEMP
30880 JSR GTMAPB
30890 TAX
30900 AND (MAPBFA),Y
30910 BNE F$$EPT
30920 TXA
30930 ORA (MAPBFA),Y
30940 STA (MAPBFA),Y
30950 LDA ADVBLK+1
30960 STA TEMP
30970 LDA ADVBLK
30980 RTS
30990 FNDE$T=*
31000 LDX BKRBLK+1 ;BA. BOTTOM ALSO REACHED?
31010 INX
31020 BNE FN$$PT ;NO, TO BA. SEARCH
31030 LDA #$A8 ;REPORT MAP OVERFLOW
31040 STA FLAG2
31050 RTS
31060 ;
31070 RELFOM=* ;PHY. BLOCK# TO LOGICAL ONE
31080 ;EXIT X LOGICAL BLOCK#
31090 ;
31100 LDX TEMP
31110 STX TEMPI
31120 PHA
31130 INC BLKOFS ;GET CURRENT POSITION IN
31140 LDA BLKOFS ;FCB FILE LOCATION AREA
31150 LSR A ;EVEN OR ODD?
31160 PLA
31170 ADC #$01 ;EVEN/ADD 1;ODD,ADD 2
31180 BCC R$LFOM ;TO PHY. BLOCK#
31190 INC TEMP1
31200 R$LFOM=*
31210 LSR A ;DIVIDED BY 2
31220 LSR TEMPI
31230 BCC RE$FOM
31240 ORA #$80
31250 RE$F0M=*
31260 TAX
31270 DEC BLKOFS
31280 RTS
31290 ;
31300 WTRCS1=*
31310 ;
31320 JSR TETOPN ;OPENED?
31330 LDA #$A0 ;SET FALG2 TO INDICATE SEQ. W
31340 STA FLAG2
31350 WTRCS$=*
31360 JSR TETWPT ;DISK W PROTECTED?
31370 LDY #$09
31380 LDA (DEREG),Y
31390 JSR TE$FWT ;FILE W PROTECTED?
31400 JSR GETREC
31410 LDA CRRCNB ;'CR'<$40
31420 CMP #$40
31430 BCC W$RCSO
31440 JMP FLEDRT
31450 W$RCSQ=*
31460 JSR GTBKOF ;GET CUR. RECORD POST. IN
31470 ;FILE LOCATION AREA'
31480 STY BLKOFS
31490 LDA (DEREG),Y ;GET LOG. BLOCK NO.
31500 BEQ WTR$$3 ;IF 0,GO TO FIND EMPTY BLOCK
31510 JSR GTRLBS ;NO,GET CORRES. PHY. BLOCK NO.
31520 WTRC$$=*
31530 JSR GTTKSC ;GET TRACK# & SECTOR#
31540 LDY #$50
31550 STY FLAG ;SET 'WRITE' TO FLAG
31560 JSR RWSCDF ;WRITE A RECORD
31570 LDY #$0E
31580 LDA #$C0
31590 STA (DEREG),Y ;SET 'WRITTEN' FLAG IN FCB.S2
31600 LDA CRRCNB ;'CR'<'RC'
31610 CMP TLRCNB
31620 BCC WTR$$Q ;GO AHEAD WITH NO INCRESE 'RC'
31630 STA TLRCNB ;STORE 'CR' TO 'RC'
31640 INC TLRCNB ;INCRESE 'RC' BY 1
31650 WTR$$G=*
31660 CMP #$3P ;'CR'=$3F?
31670 BNE WT$$SG ;NO,MODIFY FCB & RETURN
31680 BIT FLAG2 ;OTHERWISE, CHECK RANDOM
31690 BPL WT$$S0
31700 JSR MDFFCB ;IF SEG. CLOSE THIS EXTENT &
31710 JSR HDNTEN ;OPEN NEXT
31720 LDA RTNFLG+1
31730 BNE W$$CSQ ;IF UNSUCC., LEAVE 'CR'=$3F ALONE
31740 LDA #$FF ;IF SUCC., SET 'CR'=$FF
31750 STA CRRCNB
31760 W$$CS0=*
31770 LDA #$00
31780 STA RTNFLG+1
31790 WT$$SQ=*
31800 JMP MDFFCB
31810 WTR$$$=* ;MODIFY FCB, 'CR' WILL BE $40 OR $00
31820 STA TEMP ;FIND AN EMPTY BLOCK
31830 LDA #$01
31840 CPY #$10
31850 BEQ WT$CDSO ;FIRST POINTER?
31860 BEY ;YES, SET BASS PHY. BLOCK# TO $01
31870 LDA (DEREG),Y
31880 BEQ WT$CSO ;NO, GET PHY. BLOCK# BEFORE IT
31890 LDA DEREG ;0?
31900 STA HLREG1 ;NO, CONVERT IT TO BASS BLOCK#
31910 LDA DEREG+1
31920 STA HLREG1+1
31930 JSR GTBKNB
31940 WT$CSQ=*
31950 JSR FNDEPT ;TO FIND AN EMPTY BLOCK
31960 TAX
31970 LDA #$08 ;MAP OVERFLOW?
31980 BIT FLAG2
31990 BEQ WIR$S0
32000 LDA #$02
32010 JMP STRTFG
32020 WTR$S0=*
32030 TXA
32040 PHA
32050 JSR RELFOM ;NO,CHANGE FOUND# TO CORRES, LOGICAL#
32060 LDY BLKOFS
32070 NOP
32080 NOP
32090 NOP
32100 TXA
32110 STA (DEREG),Y ;STORE TO COORES POINTER
32120 PLA ;WRITE THE RECORD TO FIRST
32130 JMP WTRC$$ ;SECTOR OF FOUND BLOCK
32140 ;
32150 ;
32160 ;
32170 ;********************************************************
32180 ;*
32190 ;* FUNCTION 2 5 : WRITE SEQUENTIALLY
32200 ;*
32210 ;************************************************
32220 ;*
32230 ;* ENTRY PARAMETERS
32240 ;* REGISTER X : $19
32250 ;* REGISTER Y,A : FCB ADDRESS
32260 ;*
32270 ;* RETURNED VALUE:
32280 ;* REGISTER A : #$00 SUCCESS
32290 ;* $01 CAN'T CLOSE OR OPEN NEXT
32300 ;* EXTENT
32310 ;* $02 MAP OVERFLOW
32320 ;*
32330 ;*******************************************************
32340 ;
32350 WTRCSQ=*
32360 ;
32370 JSR FCBINZ
32380 JMP WTRCS1
32390 ;
32400 ;
32410 FNDCRN=* ;FIND CURRENT LOGIC RECORD#
32420 ;AND EXTENT
32430 ;
32440 LDY #$21 ;GET R0
32450 LDA (DEREG),Y
32460 AND I9;3F ;CACULATE DESIRED RECORD#
32470 LDY #$20
32480 STA (DEREG),Y ;STORE TO FCB.CR
32490 INY
32500 LDA (DEREG),Y ;GET R0 AGAIN
32510 STA TEMP1
32520 INY
32530 LDA (DEREG),Y ;GET R1
32540 STA EXNTNB ;CACULATE THE 'EX' DESIRED
32550 ROL TEMP1
32560 ROL EXNTNB
32570 ROL TEMPI
32580 ROL EXNTNB
32590 LDA EXNTNB ;DESIRED 'EX'=CURRENT 'EX'?
32600 LDY #$0C
32610 CMP (DEREG),Y
32620 BE0 FNSCRN
32630 JSR CLFILE ;IN NOT, CLOSE CURRENT EXTENT
32640 LDX RTNFLG+1 ;SUCCESS?
32650 LDA #$03
32660 INX
32670 BEQ FNDCR$
32680 LDA EXNTNB ;YES,STORE DESIRED TO FCB.CR
32690 LDY #$0C
32700 STA (DEREG),Y
32710 JSR OPFILE ;OPEN THIS EXTENT
32720 LDX RTNFLG+1 ;SUCCESS?
32730 INX
32740 BNE FN$CRN
32750 LDA #$04 ;IF NOT, CHECK R OR W
32760 BIT FLAG2
32770 BVS FNDCR$
32780 JSR MKFILE ;IF W, CREATE A NEW NEXT
32790 LDA #$05
32800 LDX RTNFLG+1 ;SUCCESS?
32810 INX
32820 BEQ FNDCR$ ;IF NOT REPORT ERR
32830 FN$CRN=*
32840 LDA #$00
32850 FNDCRS=*
32860 JMP STRTFG
32870 ;
32880 RDRCR1=*
32890 ;
32900 JSR TETOPN
32910 LDA #$60 ;SET FLAG TO INDICATE RANDOM R
32920 STA FLAG2
32930 JSR FNDCRN ;FOND 'EX' & 'CR' DESIRED
32940 BNE R$RCRM
32950 JMP RDRCS$ ;IF SUCCESS, READ THE RECORD
32960 R$RCRM=*
32970 RTS
32980 ;
32990 ;*******************************************************
33000 ;*
33010 ;* FUNCTION 26 :READ RANDOM
33020 ;*
33030 ;*******************************************************
33040 ;*
33050 ;* ENTRY PARAMETERS :
33060 ;* REGISTER X #$1A
33070 ;* REGISTER Y,A: FCB ADDRESS
33080 ;*
33090 ;* RETURNED VALUE :
33100 ;* REGISTER A : $00 SUCCESS
33110 ;* $01 READ UNWRITTEN DATA
33120 ;* $03 CAN'T CLOSE CURRENT EXTENT
33130 ;* $04 SEEK TO UNWRITTEN EXTENT
33140 ;*
33150 ;*******************************************************
33160 ;
33170 RDRCRM=*
33180 ;
33190 JSR FCBINZ
33200 JMP RDRCR1
33210 ;
33220 WIRCR1=4
33230 ;
33240 JSR TETOPN ;DISK W PROTECTED?
33250 LDA #$20 ;SET FLAG TO INDICATE RANDOM W
33260 STA FLAG2
33270 JSR FNDCRN ;FIND 'EX' & 'CR' DESIRED
33280 BNE W$RCRM
33290 JMP WTRCS$ ;IF SUCCESS, WRITE THIS RECORD
33300 W$RCRM=*
33310 RTS
3