>HADFS3 v5.78  Pathname scanning  ================= ( 07/06/1992, 4:30pm 2# 20/11/1994, RunExec now in #2 < Solved find_blank problem F" 26/08/1996: Rewritten OsFile P/ 28/07/1998: Bugfix for =TIME$ on MOS 5.xx ZG DiskMainLoop now with disk access code, path scanning now in here d v5.52 %name allowed n' v5.61 LookForEntry checks BigDirs x% v5.78 :name converted to :.name :  "Assembling S.HADFS3" O%=P%-Block%+mcode% [OPT0 : .GetOptNum 2TXA:PHA:LDA OPTNUM: #4:BNE GetOptNumOk:LDX #7 /.GetOptLp1:LDA addr,X:PHA:DEX:BPL GetOptLp1 +LDX #URD-CSD:JSR DIRtoSect:JSR GetToFSM MLDA FSM+&12:A #4:STA OPTNUM :\ Also updates user b8-b11 and PRIV flag 9LDA FSM+&13:STA USERNUM :\ User number b0-b7 =LDX #0:.GetOptLp2:PLA:STA addr,X:INX:CPX #8:BNE GetOptLp2 .GetOptNumOk  PLA:TAX .GetOptNum2 LDA OPTNUM: #3:RTS ": ,0\ Checking names may result in a disk access 6'\ This will corrupt addr/sect/drive @C\ ------------------------------------------------------------- JC\ CheckNames - Checks context and names, disk name on CSD drive T4\ CheckNames2 - Checks names, disk name on drive ^\ Corrupts A,X,Y hC\ ------------------------------------------------------------- r.CheckNames |CCLC:EQUB &A9 :\ LDA #nn to skip following byte .CheckNames2 SEC 4LDX #7:.ChkNamSv:LDA addr,X:PHA:DEX:BPL ChkNamSv 8BCS ChkName1 :\ CS=Check names only $JSR CheckContext:JSR SetDriveCSD :  .ChkName1 BLDA VFLG:BPL ChkDisk :\ Disk name not valid, fetch it G #31:CMP drive:BEQ ChkCSD :\ Valid name for this drive, jump past  .ChkDisk JSR CheckHADFSDisk  .ChkCSD BIT VFLG:BVS ChkLIB %JSR CSDtoSect:JSR GetToFSM:LDX #9  .ChkCSDlp  LDA &F00,X:STA DIRNAME,X:DEX &BPL ChkCSDlp:JSR DoIOwnFSM 05 #64:LDY #&BF:JSR MaskIntoOPTFLG :\ Set DirOwned :LDA VFLG:A #64:STA VFLG D .ChkLIB NLDA VFLG: #32:BNE ChkNmEnd XLDX #LIB-CSD:JSR DIRtoSect bJSR GetToFSM:LDX #9 l .ChkLIBlp v LDA &F00,X:STA LIBNAME,X:DEX BPL ChkLIBlp:JSR DoIOwnFSM 5 #32:LDY #&DF:JSR MaskIntoOPTFLG :\ Set LibOwned LDA VFLG:A #32:STA VFLG  .ChkNmEnd =LDX #0:.ChkNamRes:PLA:STA addr,X:INX:CPX #8:BNE ChkNamRes RTS : .CheckContextXY JSR XYtoF2 .CheckContext TYA:PHA:TXA:PHA *LDA CSD:A CSD+1:A CSD+2:BNE ChkCtxOk 9JSR SetContext :\ Look for drives  .ChkCtxOk  +LDA URD:A URD+1:A URD+2:BNE ChkCtxLib 8STA VFLG:LDX #URD-CSD:JSR CSDtoDIR :\ Set URD to CSD  .ChkCtxLib *+LDA LIB:A LIB+1:A LIB+2:BNE ChkCtxEnd 4&STA VFLG:JSR FindLib:BNE ChkCtxEnd >8LDX #LIB-CSD:JSR CSDtoDIR :\ Set LIB to CSD H.ChkCtxEnd RPLA:TAX:PLA:TAY:RTS \: f: pB\ ------------------------------------------------------------ zB\ Set context by scanning drives looking for defaults to mount B\ ------------------------------------------------------------ .SetContext GTYA:PHA:LDY #31 :\ Test drives from 31 downwards .SetCtxLp1 @STY drive:JSR ReadFSM:BNE SetCtxNxt:\ Not HADFS disk, ignore 8LDA &F1F:ROL A :\ Get disk flags DEY:CPY #2:BCS SetCtxLp1 :\ Don't check floppies ALDY #8+d :\ 4 bytes per CSD/LIB/URD .SetCtxLp2 JTYA:PHA:LSR A:LSR A:CLC:ADC #64 :\ Convert offset into Osbyte value JTAY:JSR Osbyte90_6:PLA:TAY :\ See if any ROMs want to override CTXA:BMI P%+5:STA CSD,Y :\ Set drive if ROM responds $DDEY:DEY:DEY:DEY:BPL SetCtxLp2 :\ Loop through URD, LIB, CSD .>LDA #0:STA VFLG:STA CSD+2 :\ Clear validity flags 88STA CSD+1:LDA #71:STA CSD+0 :\ Set CSD to '$' BPLA:TAY:RTS L: V$\ ------------------------------ `$\ Look for a $.Library directory j$\ ------------------------------ t .FindLib ~TXA:PHA:TYA:PHA LDA &F2:PHA:LDA &F3:PHA LDA LIB+d:STA drive JSR ReadFSM:BNE NoLibDrv LDA #LibName 255:STA &F2 LDA #LibName 256:STA &F3 )LDY #0:JSR LookFromRoot2:BNE NoLibDrv LDX #LIB-CSD:JSR SectToDIR  .NoLibDrv PLA:STA &F3:PLA:STA &F2 PLA:TAY:PLA:TAX #LDA LIB+0:A LIB+1:A LIB+2:RTS :  .LibName  EQUS "Library":EQUB 13 : .LookFromRoot:\ A=drive ( STA drive 2.LookFromRoot2 <$JSR SectRoot:JSR SearchPathEntry FCMP #2:RTS P: Z.SearchPathXY dJSR XYtoF2 n.SearchPathBadNF xJSR SearchPathname BMI errBadFilename BEQ errNotFound .SearchPathOk RTS .SearchPathNF JSR SearchPathname BNE SearchPathOk .errNotFound 1JSR file_errors:EQUB 214:EQUS "not found":BRK .SearchPathBad JSR SearchPathname BPL SearchPathOk .errBadFilename /JSR errors:EQUB 204:EQUS "Bad filename":BRK .CheckPath BIT pathflg:BPL errNotFound "RTS ,: 6 .PathChar @CLC:JSR GSREAD:BCS PathEnd J\.check_valid_char T' #127:CMP #"!":BCC errBadFilename ^#CMP #127:BCS errBadFilename:RTS h: r .SetAbs |LDA #&40:BNE SearchFlag  .PathEnd  LDA #128 .SearchFlag A pathflg:STA pathflg:RTS : .CheckSpecial JSR SetAbs .CheckSpecial2 LDA OBJECT+1:CMP #32 BNE errBadFilename:RTS : .SearchPathname JSR CheckContext .SearchPath2 JSR CSDtoSect:STA DRVTMP .SearchPathEntry &\ (&F2),Y=>pathname 0)LDA #0:STA pathflg:\ not end, not abs :CLC:JSR GSINIT:BEQ PathEnd D: N.SearchPathLp XLDX #0:.SearchPathLp2 bJSR PathChar:BCS SearchDot lCMP #".":BEQ SearchDot vSTA OBJECT,X:INX:CPX #11 BCC SearchPathLp2 .Bad_Fname2 -JMP errBadFilename:\ object name too long .SearchDot  LDA #32 .SearchDotLp STA OBJECT,X:INX:CPX #11 BCC SearchDotLp .SearchDot1 LDA OBJECT+0 CMP #32:BEQ Bad_Fname2 CMP #"^":BEQ SearchUp CMP #"@":BEQ SearchCSD CMP #":":BEQ SearchSpecial  CMP #"'":BCS SearchNotRoot CMP #"$":BCS SearchSpecial  .SearchNotRoot *LDA DRVTMP:CMP drive 4BEQ SearchDot2 >.JSR CheckHADFSDisk :\ This now saves sect H.SearchDot2 RJSR look_in_this_dir \BEQ SearchExit:\ A=0, NF f BIT pathflg:BPL SearchNotEnd pTAX:\ Set Z flag z.SearchExit  RTS:\ A=0,1,2; (fptr)=entry; \ (sect)=sector : .SearchNotEnd $CMP #2:BNE P%+5:JMP SearchPathLp JMP errNotDir : .SearchUp:\ ^ JSR CheckSpecial2 JSR get_chk_dir:JSR GetUp JMP SpecialCheckEnd : .SearchCSD LDX #CSD-CSD:BEQ SearchDIR : '.SearchSpecial :\ A='$','%','&' $BEQ SearchRoot :\ A='$' .0LDX #URD-CSD :\ X=URD, prepare for '&' 8CMP #"&":BEQ SearchDIR BLDA OBJECT+1:CMP #" " L%BNE SearchNotRoot :\ Allow %name V)LDX #LIB-CSD :\ X=>LIB, for '%' `.SearchDIR jJSR CheckSpecial tJSR DIRtoSect ~.SpecialCheckEnd $BIT pathflg:BMI SearchSpecialEnd JMP SearchPathLp .SearchSpecialEnd %LDA #&FF:STA fptr+1:\ abs pointer #LDA #2:RTS:\ dir, (sect)=sector : .SearchRoot .LDA OBJECT+2:CMP #" ":BNE SrchRt0 :\ $xy ,LDA OBJECT+1:CMP #" ":BEQ SrchRt2 :\ $ /\BNE SrchRt1 :\ $x : .SrchRt1 JSR CheckDrive:STA drive .SrchRt2 'JSR SectRootAbs:BEQ SpecialCheckEnd : ( .SrchRt0 2 LDX #&F6 < .SrchRtLp F;LDA OBJECT-&F6+1,X:STA OBJECT-&F6+0,X :\ Change $abcdef P8INX:BNE SrchRtLp :\ to $.abcdef Z&JSR SectRootAbs:JMP SearchDot1 :\2 d: n.GetDriveEQ xJSR GetChar:BEQ GetDrvOk .GetDrive LDA CSD+d:STA drive JSR GetChar:BEQ GetDrv2 JSR CheckDrive:INY:STA drive .GetDrv2 LDA drive:CMP #&FF .GetDrvOk RTS : .CheckDrive CMP #"0":BCC errBadDrive CMP #":":BCC GoodDrive CMP #"A":BCC errBadDrive  #&5F:SBC #8 .GoodDrive SBC #47: #31:RTS ": ,.errBadDrive 6,JSR errors:EQUB 205:EQUS "Bad drive":BRK @: J>.SetDriveCSD :\ Set drives from CSD drive T LDA CSD+d ^6.SetDrives :\ Set drives from A h #31:STA drive:STA DRVTMP rRTS |: .look_in_this_dir ;TYA:PHA:\ JSR GetOptNum:\ Ensure account number fetched .LookDirStart JSR get_chk_dir "JSR dirInit:BEQ look_none_here .LookDirLp #JSR dirNext:BEQ look_step_entry JSR DoIOwn:BPL LookDirLp1 +LDY #7:LDA (fptr),Y:BMI look_next_entry .LookDirLp1 LDY #0 .LookDirLp2 .LDA OBJECT,Y:CMP #"#":BEQ look_char_match !CMP #"*":BEQ look_file_match LDA (fptr),Y: #127 $CMP OBJECT,Y:BEQ look_char_match & #32:CMP OBJECT,Y 0BNE look_next_entry :.look_char_match DINY NCPY #10:BNE LookDirLp2 X.look_file_match bJSR GetSectAddr lLDY #8:LDA (fptr),Y:ROL A v PLA:TAY LDA #0:ADC #1:RTS :\ 1=file :\ 2=dir :\ sect holds sector start :\ fptr points to entry :\ .look_next_entry DEC files .look_step_entry LDA files:BNE LookDirLp .look_none_here !JSR GetLINK:BEQ look_no_match BIT &FF:BMI errEscape JMP LookDirStart .look_no_match PLA:TAY:LDA #0:RTS .errEscape *(JSR errors:EQUB 17:EQUS "Escape":BRK 4: >: H.CheckForDir RCMP #2:BNE ChkForDirOk \(LDA fptr+1:CMP #&FF:BEQ CheckForDir1 fLDA #2:.ChkForDirOk p A #0:RTS z.CheckForDir1 9LDA sect+2:BNE CheckForDir4 :\ Valid directory 9LDA sect+1:BNE CheckForDir4 :\ Valid directory :LDA sect+0:CMP #2:BCC CheckForDir3 :\ Invalid, use '$' 9CMP #70:BCC CheckForDir4 :\ Valid directory 9CMP #74:BCS CheckForDir4 :\ Valid directory .CheckForDir3 9LDA #71:STA sect+0:LDA #&80:RTS :\ Set sect to '$' .CheckForDir4 JSR SectToStart JSR GetDir:JSR GetUp JSR get_chk_dir =\ fall through to find this directory in parent directory : K\ --------------------------------------------------------------------- K\ Look for a non-zero length directory entry based on it's sector start K\ --------------------------------------------------------------------- $.LookForEntry .?TYA:PHA:TXA:PHA :\ Don't need to stack X 8.LookForLp1 BJSR dirInit:BEQ LookForNxt L.LookForLp2 VJSR dirNext:BEQ LookForSkip `1JSR GetSectorHigh:CMP start+2:BNE LookForStep j0DEY:LDA (fptr),Y:CMP start+1:BNE LookForStep t0DEY:LDA (fptr),Y:CMP start+0:BNE LookForStep ~"DEY:LDA HDR+&0C:BMI LookForBig (DEY:LDA (fptr),Y: #7:BPL LookForChk .LookForBig  LDA (fptr),Y:DEY:A (fptr),Y .LookForChk DEY:A (fptr),Y =DEY:A (fptr),Y:BNE LookForOk :\ Must be non-zero length .LookForStep  DEC files .LookForSkip LDA files:BNE LookForLp2 .LookForNxt  JSR NextChunk:BNE LookForLp1 >\.errBrokenDir :\ Couldn't find object  3JSR errors:EQUB 168:EQUS "Broken directory":BRK .LookForOk JSR GetSectAddr (PLA:TAX:PLA:TAY:LDA #2:RTS 2: <] F& 11;20,9);(O%-mcode%);" bytes" P>"S.HADFS4"