>HADFS1 v5.74  Filing system selection $ ROM support, printout routines ( NullKeyboard, SoftRTC 2- Translated commands, Directory commands <- ======================================= F# 27/11/1993: split from HADFS0 P/ 27/11/1993: New FindLib, usernum extended Z, Power-On message removed to save space d% 17/05/2007: NullKBD temp'y here n( v5.53 Completely rewritten PrDec32 x% v5.63 Workspace can be in Hazel G v5.66 Removed all optional code for _NotHazel%, _IDE16%, OldVRAM% @ v5.71 *HADFS checks for DFS presence, saves workspace flag = v5.72 Optimised MOS350 flag setting, DFS initialisation K v5.73 Sets OPTFLG if DFS doesn't respond to avoid DFS 0.90 OSWORD bug 9 v5.74 OPTFLG set with DFS 2.45 on any Master series > OSWORD 14 copes with date overflow on Compact+ANFS :  "Assembling S.HADFS1" O%=P%-Block%+mcode% [OPT0 \ ======================= \ Filing system selection \ =======================  .HadfsOn  LDY #2  .HadfsOn1 "CLDA &DF00,Y:PHA:DEY:BPL HadfsOn1 :\ Save current FS context ,:LDY #4:JSR fx143fs :\ Initialise DFS 6ILDY #&FD :\ X=&FF if no response from DFS @ .HadfsOn2 J>PLA:STA &DF00-&FD,Y:INY:BMI HadfsOn2 :\ Restore FS context T: ^RLDA &28F:ASL A: #&80:A &F4 :\ Check keyboard link 2, always 0 on Master hVINX:BEQ HadfsOn5 :\ No response from DFS, OPTFLG=&80+HADFS ROM r: |.z% @JSR WhatMOS:LDA #0:BCS HadfsOn5 :\ Not Master, OPTFLG=0 0:]: base$>=5.79:z%=P%-z%:P%=P%-z%:O%=O%-z% .z% @LDA #0:BIT WHATOS:BPL HadfsOn5 :\ Not Master, OPTFLG=0 /:]: base$<5.79:z%=P%-z%:P%=P%-z%:O%=O%-z% NLDA #&08:STA &F6:LDA #&80:STA &F7 :\ (&F6)=&8008, binary version number ELDY XFILEV+2:JSR OSRDRM :\ Read DFS's version number TCMP #&95:LDA #0:BCC HadfsOn5 :\ Earlier than v2.45, no workaround needed GTYA:A #&80 :\ DFS 2.45, OPTFLG=&80+DFS ROM : B\\LDA #0:\JSR ChkMOS350:\BNE HadfsOn5:\ Not MOS 3.50, OPTFLG=0 G\\LDA XFILEV+2:\A #&80 :\ DFS 2.45, OPTFLG=&80+DFS ROM :  .HadfsOn5 PHA : &BLDA #6:JSR FSC :\ Warn vectors about to change 0LDY #0:LDX #27 : .TrapFSlp D:LDA vectors+0,Y:STA &D9F,X :\ Set extended address NLDA vectors+1,Y:STA &DA0,X X=LDA &F4:STA &DA1,X :\ Set extended ROM number b9TXA:STA FILEV,Y :\ Set extended vector lLDA #255:STA FILEV+1,Y v9INY:INY:INX:INX:INX :\ Step to next vector CPX #48:BNE TrapFSlp 5LDX #15:JSR fx143 :\ Vectors changed AJSR GrabAbs :\ Claim and restore workspace : RPLA:STA OPTFLG:LDA #0:RTS :\ Set MOS350+DFSROM, clear OwnDir,OwnLib,NoDFS :  .vectors !EQUW file:EQUW args:EQUW bget !EQUW bput:EQUW gbpb:EQUW find  EQUW fsc : $\ ============================== $\ Arithmetic and number routines $\ ==============================  .BINtoBCD:\ Corrupts tmp PHA:LDA #10:STA tmp:PLA  .BINtoBCDlp *CMP tmp:BCC BCDdone 4ADC #5:PHA >LDA tmp:ADC #16:STA tmp HPLA:BCC BINtoBCDlp R .BCDdone \RTS f: p.BCDtoBIN:\ Corrupts X zTAX:LDA tmp:PHA:TXA  #&F0:LSR A:STA tmp:\ 8s #LSR A:LSR A:CLC:ADC tmp:STA tmp TXA: #15:CLC:ADC tmp:TAX PLA:STA tmp:TXA:RTS : .HexTopDigit LSR A:LSR A:LSR A:LSR A  .HexDigit  #15:BPL DrvChr .GetDrvChr  LDA drive  .DrvChr CMP #10:BCC P%+4:ADC #6 ADC #48:RTS : !.PrDec:\ Print decimal number $JSR BINtoBCD .: 8.PrHex:\ Print hex number B&PHA:JSR HexTopDigit:JSR OSWRCH:PLA L.PrNyb:\ Print hex digit VJSR HexDigit:JMP OSWRCH `: j \.PrZero t\LDA #0:\BEQ PrHex ~: : +\ ------------------------------------- +\ PrDec32 - Print 32-bit decimal number +\ ------------------------------------- \ On entry, numstore=number 9\ numflg=0 or pad character (eg '0' or ' ') .\ On exit, A,X,Y,numstore,numflg corrupted 9\ ---------------------------------------------------  .PrDec32 0LDY #9 :\ 9+1 digits .PrDec32lp 9TYA:PHA:JSR PrComma :\ Save Y=power of ten LDX #3:LDA #0  .Power10lp1 .STA numsub,X:DEX:BPL Power10lp1:\ numsub=0 .INC numsub:LDX #numsub :\ numsub=1 (.Power10lp2 21JSR Times10X:DEY:BNE Power10lp2:\ numsub=10^Y LDA numflg:BEQ PrDig2 :\ No pad character, return =JMP OSWRCH :\ Pad character, print it  .PrDig1 .A #"0":JSR OSWRCH :\ Print digit ;LDA #"0":STA numflg :\ Print zeros from now on  .PrDig2 RTS :  .PrComma CPY #2:BEQ PrComma1 CPY #5:BEQ PrComma1 CPY #8:BEQ PrComma1  .PrComma0 RTS  .PrComma1 JLDX numflg:LDA #"," :\ Prepare a comma if zeros being printed FCPX #"0":BEQ P%+3:TXA :\ Otherwise, print the pad character "ETAX:BEQ PrComma0:JMP OSWRCH :\ Print if not null pad character ,: 6+\ ------------------------------------- @+\ DivideNum - Divide numstore by numsub J+\ ------------------------------------- T&\ On entry, numstore=32-bit number ^%\ numsub=32-bit divisor h,\ On exit, A=numstore numsub, Z=(A=0) r*\ numstore=numstore numsub |(\ Y preserved, X corrupted .\ ---------------------------------------- .DivideNum LDX #255:SEC  .DivLp INX .LDA numstore+0:SBC numsub+0:STA numstore+0 .LDA numstore+1:SBC numsub+1:STA numstore+1 .LDA numstore+2:SBC numsub+2:STA numstore+2 .LDA numstore+3:SBC numsub+3:STA numstore+3  BCS DivLp .LDA numstore+0:ADC numsub+0:STA numstore+0 .LDA numstore+1:ADC numsub+1:STA numstore+1 .LDA numstore+2:ADC numsub+2:STA numstore+2 .LDA numstore+3:ADC numsub+3:STA numstore+3  TXA:RTS : &&\ -------------------------------- 0&\ GetNumber, GetHex - Fetch number :&\ -------------------------------- D\ On entry, (&F2),Y=>number N%\ X=>zero page numstore X"\ CS=hex, CC=decimal b3\ On exit, (&F2),Y=>next item, skipping spaces l \ A=next character v'\ X=>numstore with result '\ ---------------------------------  .Get1Hex JJSR GetHexNum:LDA numstore:RTS :\ Fetch hex and return bottom byte .GetHexNum SEC .GetNumber DLDX #numstore :\ Collect number in numstore ;PHP:JSR GetDigit:BCS errBadNumber :\ Fetch first digit ;STA 0,X :\ Store first digit "LDA #0:STA 1,X:STA 2,X:STA 3,X  .GetNumLp APLP:PHP:JSR GetDigit:BCS GotNumOk :\ End of string of digits CPLP:PHP:PHA:JSR Times10or16 :\ Move current to next unit 7PLA:CLC:ADC 0,X:STA 0,X :\ num=num+digit  LDA 1,X:ADC #0:STA 1,X LDA 2,X:ADC #0:STA 2,X  LDA 3,X:ADC #0:STA 3,X *BCC GetNumLp 4.errBadNumber >-JSR errors:EQUB 252:EQUS "Bad number":BRK H .GotNumOk RPLP:JMP SkipSpc \: f/\ ----------------------------------------- p/\ Times10or16 - Multiply number by 10 or 16 z/\ ----------------------------------------- %\ On entry, X=>zero page numstore (\ CC=times 10, CS=times 16 +\ On exit, X,Y preserved, A,F corrupted +\ -------------------------------------  .Times10 .LDX #numstore :\ Use numstore  .Times10X ,CLC :\ CC for *10 .Times10or16 %JSR TimesTwo :\ n*2 *LDA 3,X:PHA:LDA 2,X:PHA :\ save n*2 LDA 1,X:PHA:LDA 0,X:PHA %JSR TimesTwo:JSR TimesTwo :\ n*8 BCC TimesTen *PLA:PLA:PLA:PLA :\ Drop n*2  .TimesTwo $'PHP:ASL 0,X:ROL 1,X :\ n=n*2 .ROL 2,X:ROL 3,X 8BCS errBadNumber:PLP:RTS B .TimesTen L0PLA:ADC 0,X:STA 0,X :\ n*8+n*2 = n*10 VPLA:ADC 1,X:STA 1,X `PLA:ADC 2,X:STA 2,X jPLA:ADC 3,X:STA 3,X tBCS errBadNumber:RTS ~: \ -------------------------- \ GetDigit - Fetch one digit \ -------------------------- *\ On entry, (&F2),Y=>current character \ CC = decimal \ CS = hex \ On exit, A = digit 0-F \ CC = valid digit "\ CS = invalid digit &\ (&F2),Y=>next character (\ ---------------------------------- .GetDigit PHP:JSR GetChar:BEQ Not1Num CMP #"0":BCC Not1Num CMP #"9"+1:BCC Got1Num PLP:BCC NotNumber ( #&DF 2CMP #"A":BCC NotNumber <CMP #"F"+1:BCS NotNumber FSBC #6:PHP P .Got1Num Z' #15:PLP:INY:CLC:RTS:\ Valid digit d .Not1Num nPLP x.NotNumber +SEC:RTS :\ Invalid digit : : : \ ====================== \ Text printout routines \ ====================== +\ Corrupts tmp at &B2 and tptr at &B0/1 5\ ----------------------------------------------- .PrText 'STA tmp:PLA:STA tptr:PLA:STA tptr+1 TYA:PHA:LDY #1:BNE PrTextInc .PrTextLp +LDY #0:LDA (tptr),Y:BEQ P%+5:JSR OSASCI .PrTextInc $PHP:INC tptr:BNE P%+4:INC tptr+1 "PLP:BNE PrTextLp ,PLA:TAY:LDA tmp:JMP (tptr) 6: @\ ================ J\ Error generation T\ ================ ^D.file_errors :\ generates 'OBJECT errormessage' h=LDA #32:STA OBJECT+10:LDX #0 :\ Ensure OBJECT terminated r .fileErLp |@LDA OBJECT,X:STA &102,X:INX :\ Copy OBJECT to error buffer CMP #32:BNE fileErLp STA &102,X:INX:BNE errors2 : .errorDIR ;JSR ClearDIR :\ Clear directory buffer =.errors :\ Generates 'errormessage' LDX #1:.errors2 "PLA:STA &FD:PLA:STA &FE:LDY #1 LDA (&FD),Y:STA &101 .errorlp:INX:INY:LDA (&FD),Y STA &100,X:BNE errorlp STA &100:JMP &100 : \ ================== \ Workspace routines %\ =============================== &%\ FindWS - Find private workspace 0%\ ------------------------------- :#\ Returns ws=>private workspace D/\ All registers and flags preserved N/\ ----------------------------------------- X .FindWS b&PHP:PHA:TXA:PHA:LDX &F4:LDA &DF0,X l #&DF:CLC:BMI P%+4:ADC #&0E v.STA ws+1:LDA #0:STA ws:PLA:TAX:PLA:PLP:RTS : 3\ ============================================= 3\ GrabAbs - Claim and update absolute workspace 3\ ============================================= %\ Returns all registers preserved %\ ------------------------------- .GrabAbs BPHA:TXA:PHA:TYA:PHA:LDA ws:PHA:LDA ws+1:PHA :\ Save everything KJSR TimeSave:JSR GetOwnWS:BNE GrabAbsOk :\ Exit if I already own ws HLDX #10:JSR fx143:JSR SetOwnWS :\ Claim ws and set flag JSR FindWS:LDY #CSD 255 .GrabAbsLp2 ILDA (ws),Y:STA WS,Y:INY:BNE GrabAbsLp2 :\ Copy info to workspace  LDY #4 .GrabAbsLp3 DLDX ChnInfo,Y:LDA WS,X: #&FC:STA WS,X :\ Clear channel flags DEY:BPL GrabAbsLp3 *IJSR ClearDIR:STA VFLG :\ No directory in memory 4.GrabAbsOk >EPLA:STA ws+1:PLA:STA ws:PLA:TAY:PLA:TAX:PLA :\ Restore everything HRTS R: \\ ============ f\ Line parsing p\ ============ z .SkipSpc1 INY .SkipSpc $LDA(&F2),Y:CMP#" ":BEQ SkipSpc1 .GetChar LDA (&F2),Y:CMP #13 RTS : .XYtoF2 STX &F2:STY &F3:LDY #0:RTS : .F2toXY PHA:TYA:CLC:ADC &F2:TAX LDA &F3:ADC #0:TAY:PLA:RTS : \ ================== \ Null Keyboard code $\ ================== .L.KeyboardChk :\ Insert NullKBD if no keyboard found 8"PHP:SEI:LDA &28F:BNE Serv1bKbd B8LDA &229:BPL Serv1bKbd :\ Already claimed LLDX #7:.Serv1KbdLp VBLDA NewK,X:STA &3D0,X:DEX:BPL Serv1KbdLp :\ Copy new KEYV code `=LDA &228:STA &3D8:LDA &229:STA &3D9 :\ Copy old KEYV jFLDA #&D0:STA &228:LDA #3:STA &229 :\ Point KEYV to new code t.Serv1bKbd ~PLP:JMP Serv1Exit :  .NewK >BVS OldKeyJmp:BCS OldKeyJmp:LDA #0:RTS:.OldKeyJmp:EQUB &4C 7:]: _NoNullKB%:z%=P%-KeyboardChk:P%=P%-z%:O%=O%-z% : \ ====================== \ Time and date routines 4\ ============================================== 1\ TimeSave - Save current , called regularly 4\ ----------------------------------------------  .TimeSave  PHA:TXA:PHA:LDX #2:.SvTimeLp LDA &294,X:STA &3DA,X:DEX  BPL SvTimeLp:PLA:TAX:PLA:RTS : 1\ =========================================== (1\ *SETDATE - Set current date and day of week 21\ =========================================== < .SetDate FJSR Get1Hex:ASL A:ASL A:ASL A :\ Get day, move into b5-b7 8ASL A:ASL A:A &3DE:::BNE setdate2 :\ Store and exit $::\\STA &3DE::\\.setdate3::\\RTS  .setdate1 6STA &3DD:STA &3DF :\ All same=No date  .setdate2 STA &3DE:::.setdate3:RTS : (\ ================================== %\ * - Display current RTC string (\ ================================== $\ Returns A=length of RTC string !\ EQ=no RTC available (\ ----------------------------------  .Time RTC |8LDA &108,X:JSR OSASCI:INX :\ Print RTC string 1CPX #25:BNE TimeLp:TXA :\ Set flags  .NoTime >RTS :\ A=length of RTC string : \ ====================== \ Check if RTC available \ ====================== \ Returns EQ=RTC available !\ NE=No RTC available !\ --------------------------- .CheckClock1 $\ A,X,Y can be corrupted $\ ------------------------------ LDA #0:LDX #255:JSR OSBYTE ;CPX #3:BCC CheckClock :\ BBC - check SoftRTC JCPX #5:BNE CheckClockOk :\ Not Compact - hardware RTC present &;\\JSR WhatOS:\BCC CheckClock :\ BBC - check SoftRTC 0J\\CPX #5:\BNE CheckClockOk :\ Not Compact - hardware RTC present :: D.CheckClock N!\ X must be preserved X!\ --------------------------- b,LDA &3DD:JSR CheckClock2 :\ Date l-LDA &3DE:JSR CheckClock2 :\ Month v,LDA &3DF:JSR CheckClock2b :\ Year .CheckClockOk LDA #0:RTS .CheckClock2 BEQ CheckClockNo .CheckClock2b " #15:CMP #10:BCC CheckClockOk .CheckClockNo ;PLA :\ Drop return address .Osw14Quit1 PLA .Osw14Quit 6LDA #8:RTS :\ A=8 used later : &\ ================================  &\ OSWORD 14 - Read Real Time Clock &\ ================================  .Osword14 *7LDY #0:LDA (&F0),Y:LDY #7 :\ Get action byte 49CMP #2:BCC Osw14RTC:BNE Osw14Quit:\ Check action byte >;.Osw14_2 :\ Convert BCD to text H9LDA (&F0),Y:DEY:STA &100,Y :\ Copy to workspace RBNE Osw14_2 \A.ConvertDate :\ Convert &100-&106 to text fLDY #6:.ConvDate1 p;LDA &100,Y:JSR BCDtoBIN:STA &100,Y :\ Convert to binary z"DEY:BPL ConvDate1:INY:LDA &103 =\ #7:\ADC #12:JSR PutDay :\ BCDtoBIN returns Cy=0 LDA #",":JSR PutChar *LDA &102: #31:JSR PutBCD:JSR PutSpace /LDA &101: #15:JSR PutDayMonth:JSR PutSpace 7\LDA &100:\ #&FF:\CMP #&B0 :\ Ignore 19xx now  \LDA #19:\ADC #0:\JSR PutBCD 6LDA #&20:JSR PutHex :\ Year 20xx 3LDA &102: #&E0:LSR A:CLC:ADC &100 :\ Get year ;CMP #100:BCC P%+4:SBC #100:JSR PutBCD :\ Reduce to 0-99 ;LDA #".":JSR PutChar:LDX #&FD :\ Now put hh;mm;ss .ConvDate2 DEQUB &BD:EQUW &104-&FD,X:\ LDA &104-&FD,X forcing abs addressing 9JSR PutHour:INX:BNE ConvDate2:DEY:LDA #13:JSR PutChar .Osw14Claim LDA #0:RTS : $ .Osw14RTC .9PHA:JSR CheckClock:BNE Osw14Quit1:\ No time available 8/LDA &3DE: #&1F:STA &101 :\ Get month B0LDA &3DF:STA &100 :\ Get year L.LDA &3DD: #&3F:STA &102 :\ Get date V$LDA &3DE:LSR A:LSR A:LSR A:LSR A `7LSR A:STA &103 :\ Get day of week j?LDA &F0:PHA:LDA &F1:PHA :\ Save action and pointer t8LDX #8:.Osw14Save:LDA numsub,X:PHA:DEX:BPL Osw14Save ~>LDA #1:JSR OsTIME :\ Read FLDA #&83:LDY #&D6:LDX #&00:JSR Osw14Div :\ Calculate days IBEQ osw14noflow :\ Not past midnight =LDA #2:JSR OsTIME :\ Set : .osw14noflow GLDA #&05:LDY #&7E:LDX #&40:JSR Osw14Div:STA &104 :\ Calculate hours ILDA #&00:LDY #&17:LDX #&70:JSR Osw14Div:STA &105 :\ Calculate minutes ILDA #&00:TAY:LDX #&64:JSR Osw14Div:STA &106 :\ Calculate seconds I :\ Centisecs ignored ?LDX #0:.Osw14Rest:PLA:STA numsub,X:INX:CPX #9:BNE Osw14Rest 7PLA:STA &F1:PLA:STA &F0 :\ Restore pointer =PLA:BNE P%+5:JMP ConvertDate :\ A=0, return as string LDY #6:.NoDateLp  BLDA &100,Y:STA (&F0),Y:DEY :\ Copy back to control block BPL NoDateLp:JMP Osw14Claim : (.Osw14Div:\ AYX=divisor 2>STX numsub+0:STY numsub+1:STA numsub+2:LDA #0:STA numsub+3 <JSR DivideNum:JMP BINtoBCD F: P .OsTIME Z6LDX #numstore 255:LDY #numstore 256:JMP OSWORD d: n3.PutSpace :\ Store a space xLDA #" ":BNE PutChar =.PutHour :\ Store hour/minute/colon $JSR PutBCD:LDA #":":BNE PutChar  .PutBCD JSR BINtoBCD /.PutHex :\ Store hex #PHA:JSR HexTopDigit:JSR PutChar PLA:JSR HexDigit 7.PutChar :\ Store a character STA (&F0),Y:INY:RTS  .PutDay  #7:ADC #12 A.PutDayMonth :\ Look up and store day/month STA tmp:ASL A:ADC tmp:TAX LDA MonthText-3,X:.PutDayLp STA (&F0),Y:INX:INY LDA MonthText-3,X:CMP #"`" "BCS PutDayLp:RTS ,: 6.MonthText @/EQUS "JanFebMarAprMayJunJulAugSepOctNovDec" J EQUS "SunMonTueWedThuFriSat" T=5.79:z%=P%-z%:P%=P%-z%:O%=O%-z% : : $\ ============================== $\ Save and restore filing system $\ ============================== &.EnsureHADFS 0CLDA #HADFSnum:LDY XFILEV+2 :\ Check if I'm the filing system :CCPY &F4:BEQ EnsHADFSok :\ If I am, just return with A=me D?LDA #0:TAY:JSR OSARGS:PHA :\ Find current filing system N1JSR Hadfs:PLA :\ Select HADFS X.EnsHADFSok bIRTS :\ Return with A=previous filing system l.RestoreFS v.Status:LDX #&29:BNE fx143 :\ Send *STATUS service call A.Config:LDX #&28:BNE fx143 :\ Send *CONFIGURE service call 2:]: _NoStatus%:z%=P%-Status:P%=P%-z%:O%=O%-z% <.Shut :LDX #&26:BNE fx143 :\ Send *SHUT service call : =.Hadfs :\ Select HADFS with *fx143 B.fx143go:LDY #HADFSnum :\ Select HADFS as filing system >.fx143fs:LDX #&12 :\ Select filing system in Y  9.fx143 :LDA #143:JMP OSBYTE :\ Issue a service call :  5.Ex :LDA #9 :BNE FSC_F2 :\ Pass *EX to FSCV *7.Info :LDA #10:BNE FSC_F2 :\ Pass *INFO to FSCV 49.Rename :LDA #12 :\ Pass *RENAME to FSCV >B.FSC_F2 :JSR F2toXY :\ Convert (&F2),Y pointer to XY H.FSC :JMP (FSCV) R: \7.Delete :\ Pass *Ǒ to OSFILE f+LDA #6:JSR OSFile:CMP #0:BNE EnsHADFSok pJMP errNotFound z9.CDir :LDA #8 :\ Pass *CDIR to OSFILE B.OSFile :JSR F2toXY :\ Convert (&F2),Y pointer to XY  .OSFileXY ISTX Ctrl+0:STY Ctrl+1 :\ Store X and Y in control block =LDX #Ctrl 255:LDY #Ctrl 256 :\ Point to control block CJMP OSFILE :\ Jump to do OSFILE action : : '\ ================================= '\ Directory/disk selection commands '\ =================================  .I_AmXY JSR XYtoF2  .I_Am FTYA:PHA:JSR Bye:PLA:TAY :\ Close all and clear workspace 8JSR SetContext :\ Look for drives ELDA URD+d:JSR LookFromRoot :\ Search from '$' on URD drive $;BNE I_Am2 :\ Not found, use '$' .HLDX #CSD-CSD:JSR SectToDIR :\ Set CSD=Sect of found directory 8 .I_Am2 BALDX #URD-CSD:JSR CSDtoDIR :\ Set URD=CSD, ='$' or dir LHLDA LIB+d:PHA :\ LIB=000000, save LIB drive VALDA CSD+d:STA LIB+d :\ Try looking on CSD drive `BJSR FindLib:BNE I_Am4 :\ '$.Library' found, use it j;PLA:CMP LIB+d:BEQ I_Am3 :\ Get LIB drive back tGSTA LIB+d :\ Try original drive if not <00> ~BJSR FindLib:BNE I_Am5 :\ '$.Library' found, use it  .I_Am3 DLDA #71:STA LIB:BNE I_Am5 :\ Set LIB to '$' on lib drive  .I_Am4 PLA  .I_Am5 :LDX #URD-CSD:JSR GetDirX :\ Get URD directory 7LDA HDR+&13:STA USERNUM :\ Get user b0-b7 GLDA HDR+&12:A #4:STA OPTNUM :\ Get user b8-b11 and boot option = #3:BEQ I_AmEnd :\ Option 0 -> do nothing >TAX:LDA BootTable-1,X:TAX :\ Index to Boot command :LDY #Boot1 256:JMP oscli :\ Execute the command : .BootTable  CEQUB Boot1:EQUB Boot2:EQUB Boot3 :\ Low bytes of Boot commands ,EQUS ((P%255)>247)(256-(P%255)),"*") ?.Boot1:EQUS "L." :\ Option 1 - *Load !Boot (>.Boot2:EQUS "!BOOT":EQUB 13 :\ Option 2 - *Run !Boot 2?.Boot3:EQUS "E.!BOOT":EQUB 13 :\ Option 3 - *Exec !Boot (Boot3 &FF00):"WARNING: BootTable overlaps page end"' F: P.Bye Z?JSR Close :\ Should also do Osw90,5 dE :\ Fall through into MountClear n.MountClear xELDA DRVINT:PHA:LDA DRVEXT:PHA :\ Save Internal/External flags LDA OPTFLG:PHA:LDA #0:TAX  .MntClr ?STA WS,X:INX:BNE MntClr :\ Clear entire workspace OPLA: #&9F:STA OPTFLG :\ Restore OPTFLG without DirOwn and LibOwn HPLA:STA DRVEXT:PLA:STA DRVINT :\ Restore Internal/External flags  .I_AmEnd RTS :  .Mount @JSR GetDriveEQ:PHP:PHA :\ Get any drive parameter EJSR MountClear :\ Clear workspace, returns X=0 L\\LDX #0 :\ Forget Spool/Exec if HADFS channels /LDA &256:JSR ChannelRange:BCC P%+5:STX &256 /LDA &257:JSR ChannelRange:BCC P%+5:STX &257 ;PLA:PLP:BEQ MountOk :\ No drive specified >STA CSD+d:STA LIB+d:STA URD+d :\ Mount specified drive "4LDA #71:STA CSD+0 :\ Set CSD='$' ,W\\LDA #0:\STA CSD+1:\STA CSD+2 :\ Superfluous, already set to zero by MountClear 6 .MountOk @RTS J: T .Enable ^GJSR GetChar:BEQ Enable2 :\ No parameters, set enable flag hQPLA:PLA:LDA #4:RTS :\ Pop return address and return 'not done' r .Enable2 |LDA #&FF:STA ENABLE .TryADirOk RTS :  .TryADir $JSR SearchPathname:BMI TryADirOk CMP #2:BEQ TryADirOk CMP #0:BNE errNotDir JMP errNotFound .errNotDir :JSR file_errors:EQUB 190:EQUS "is not a directory":BRK : .Dir 8JSR TryADir:BPL Dir2 :\ Directory found @LDX #URD-CSD:JSR DIRtoSect :\ Null path, set Sect=URD  .Dir2 ;LDX #CSD-CSD:LDA #&3F:BNE SectToDIRa :\ Jump to set CSD &: 0.Lib :&\ StartToSect - Copy Start to Sect H&\ -------------------------------- R.StartToSect \ LDX #2 f.StartToScLp pLDA start,X:STA sect,X zDEX:BPL StartToScLp:RTS : !\ --------------------------- !\ CSDtoSect - Set Sect to CSD !\ --------------------------- .CSDtoSect LDX #CSD-CSD : 7\ ------------------------------------------------- 7\ DIRtoSect - Set Sect to context variable at CSD,X 7\ ------------------------------------------------- .DIRtoSect LDA CSD+0,X:STA sect+0 LDA CSD+1,X:STA sect+1 LDA CSD+2,X:STA sect+2 LDA CSD+d,X:STA drive RTS $: .5\ ----------------------------------------------- 85\ CSDtoDIR - Set context variable at CSD,X to CSD B5\ ----------------------------------------------- L .CSDtoDIR VLDA CSD+0:STA CSD+0,X `LDA CSD+1:STA CSD+1,X jLDA CSD+2:STA CSD+2,X tLDA CSD+3:STA CSD+3,X ~RTS : *\ ------------------------------------ *\ GetFIRST - Get first directory chunk *\ ------------------------------------  .GetFIRST LDX #&14:TXA:BNE GetDirLink : (\ ---------------------------------- (\ GetLINK - Get next directory chunk (\ ----------------------------------  .GetLINK $LDX #&18:LDA #&0E:BNE GetDirLink :  \ ------------------------ \ GetUp - parent directory \ ------------------------ ( .GetUp 2%LDX #&1C:LDA #&0A:\BNE GetDirLink <: F.GetDirLink P?BIT HDR+&0C:BMI GetDirLink24 :\ Get 24-bit link from X Z?TAX:LDA #0:BEQ GetDirLink16 :\ Get 16-bit link from A d.GetDirLink24 n8LDA HDR+&02,X :\ Get link b16-23 x.GetDirLink16 STA sect+2 ALDA HDR+&01,X:STA sect+1 :\ Get directory link b0-15 LDA HDR+&00,X:STA sect+0 =JMP ChkSectZero :\ Return EQ if no link : \ ----------------- \ Get FIRST or CURR \ ----------------- .GetFIRSTorCURR ?JSR GetFIRST:BNE CURRtoSectOk :\ Return if FIRST exists < :\ Otherwise, get CURR : #\ ----------------------------- #\ CURRtoSect - Get CURR to sect #\ ----------------------------- .CURRtoSect:.GetCURR " LDX #3 ,.GetCURRlp 6LDA CURR,X:STA sect,X @DEX:BPL GetCURRlp J.ChkSectZero TA sect+1:A sect+2 ^.CURRtoSectOk hRTS r: |] $ 11;20,9);O%-mcode%;" bytes" >"S.HADFS2"