>HADFS8 v5.69 0 Disk Initialisation - *INSTALL and *FORMAT 0 ========================================== ( v5.26 New install routine 2+ v5.27 Fixed install data flag, DiskID <8 v5.53 Updating for 24-bit disk map, *INSTALL xxxxM FA Format code needs re-examining, non-optimal on Master PJ Does DFS need to be selected for OSWORD &7F to work correctly? Z( v5.66 Uses offset directory buffer d( v5.69 System boot runs on Electron n: x "Assembling S.HADFS8" O%=P%-Block%+mcode% [OPT0 : \ ------------------------ \ Check if command enabled \ ------------------------ .CheckEnable !BIT ENABLE:BVC NotEnabled:RTS .NotEnabled TYA:PHA:TXA:PHA $JSR PrText:EQUS "Go? (Y/N) ":BRK LDA #21:LDX #0:JSR OSBYTE PLA:TAX:PLA:TAY JSR OSRDCH:BCS NotEnab2 ! #&DF:CMP #"Y":BNE NotEnab2 JSR OSWRCH:JMP OSNEWL " .NotEnab2 ,.JSR errors:EQUB 189:EQUS "Not enabled":BRK 6: @: J\ ================ T\ *Install routine ^\ ================ h .InstHelp rBLDX #CommInstall-CommTable :\ Point to "INSTALL" text |FLDY #HelpInstall-HelpText :\ Point to *Install help text EJSR HelpLp2 :\ Print a single *Help entry JSR PrText !EQUS " can be:":EQUB 13 5EQUS "L... : Large Disk even if <16M":EQUB 13 )\EQUS "D... - data disk":\EQUB 13 $EQUS " : tracks":EQUB 13 #EQUS "K|M : bytes":EQUB 13 %EQUS "& : sectors":EQUB 13 BRK 4:]: _NoInsHlp%:z%=P%-InstHelp:P%=P%-z%:O%=O%-z% RTS : \ ---------------- \ *Install command \ ----------------  .Install &ELDA CSD+d:STA drive :\ Assume using current drive 0KJSR GetChar:BEQ InstDrive :\ No parameters, do default action :ECMP #"?":BNE P%+5:JMP InstHelp :\ Print out *Install help text DFINY:LDA (&F2),Y:DEY :\ Get char after current char NJCMP #"!":BCS InstDrive :\ If not separator, use current drv XJSR GetDrive bG.InstDrive :\ DRIVE now holds drive to use lBJSR ReadFSM :\ EQ=HADFS disk, NE=blank v9CLC:PHP :\ CC=new install BJSR SkipSpc :\ Look for next parameter ?INY:CMP #"$":BEQ InstRoot :\ '$' -> create new disk GDEY:PLP:BEQ P%+5:JMP NotHADFSDisk :\ Update must be of HADFS disk BSEC:PHP :\ CS=update existing disk :  .InstRoot !\ On entry here, pushed flags 2\ NE=not HADFS disk (ie blank) EQ=HADFS disk 3\ CC=do new install ($) CS=update disk :  AINX:CPX #16:BNE InstTitle :\ Loop for 16 characters  [JMP errBadFilename :\ This disallows titles exactly 16 characters long * .InstPad 4 LDA #" " > .InstSpc H@INX:STA FSM,X :\ Pad title with spaces RCCPX #16:BNE InstSpc :\ Title length is 16 chars \ .InstJGH fALDA JGHName-16,X:STA FSM,X:INX :\ Put validity string in pCPX #24:BNE InstJGH z: .InstNoTitle @LDA #0 :\ Prepare cleared flags MPLP:BCC P%+5:JMP InstUpdate :\ Jump ahead to update existing disk DPHP:BNE InstBlank :\ New install on blank disk PLDA FSM+31:ASL A:BPL InstOverwrite :\ New install on existing unlocked disk FJMP errLocked :\ Can't overwrite locked disk .InstOverwrite JLDA #&C1 :\ Keep BigDisk+Locked+NoDFS flags F.InstBlank :\ **** FAILING SOMEWHERE **** 9 FSM+31:STA FSM+31 :\ Clear disk flags : *\ Overwriting disk - Creating new disk *\ ------------------------------------ ;JSR SkipSpc: #&DF :\ Get next character CMP #"@":BCC P%+3:INY DPLP:PHA:PHP :\ Save any prefix character $: .\ From here on, 8&\ Pushed A='S','L','D', , etc B\ Pushed flags L2\ NE=not HADFS disk (ie blank) EQ=HADFS disk V\ CC=do new install ($) `: jDJSR SkipSpc:BNE InstSize :\ Disk size given, parse it tAPLP:BEQ InstEnable :\ Use existing disk size ~L: :\ If no size given, allow GetNumber E: :\ to generate error later on  .InstSize LPLP:INY:CMP #"&":BEQ InstNum :\ Drop NE/EQ flag, check for §ors =DEY:CLC :\ CC=decimal, CS=hex  .InstNum >PHP:JSR GetNumber :\ Read size parameter DPLP:BCS InstSectors: #&DF :\ &xxxx is actual sector size : ALDY #2:CMP #"K":BEQ InstNumLp :\ Convert xxxxK to sectors ACMP #"M":BNE InstTrk:LDY #12 :\ xxxx is number of tracks .InstNumLp DJSR TimesTwo:DEY:BNE InstNumLp :\ Convert K or M to sectors KBEQ InstSectors :\ TimesTwo returns flags preserved  :  .InstTrk OJSR Times10 :\ Multiply tracks by 10 to get sectors (: 2.InstSectors  BCS P%+5:JSR CheckEnable :\ Is command enabled? LDA #0:STA fptr+0 "DLDA #FSM 256:STA fptr+1 :\ Point to disk creation date ,ASEC:JSR SetCrDateFSM :\ Set disk creation date 6: @FLDA &296:LDX #30 :\ Seed disk ID with part of J .MakeID TFPHA:TYA: FSM+0,X :\ Hash the disk info into an ID ^TAY:PLA:ADC FSM+1,X h5DEX:DEX:BPL MakeID:STA FSM+&18 :\ Set DiskID rC &295:STA FSM+&19 :\ Merge in another part of |: LDX #32:LDA #0 >.InstEmptyFSM :\ Create an empty FSM  CS=update, CC=overwrite 0\ NE/EQ=xxx NE=Data, EQ=Syst 3\---------------------------------------------- .InstUpdate PHP SLDA #0:STA VFLG:JSR SaveFSM :\ Clear names, save the new or updated FSM : Q\ We always update so old versions can understand, even if we lose some space L\ Update SmallData -> dual boot, 16-bit FSM, update any $.HADFSROM file E\ Update SmallSyst -> dual boot, 16-bit FSM, update embedded ROM L\ Update BigDisk -> dual boot, 24-bit FSM, update any $.HADFSROM file \ -\ We always create as disk with dual boot  0\ Create SmallData -> dual boot, 16-bit FSM F\ Create SmallSyst -> dual boot, 16-bit FSM, save $.HADFSROM file  F\ Create BigDisk -> dual boot, 24-bit FSM, save $.HADFSROM file *: 4DLDA FSM+31: #&41:BNE InstNoDFS :\ Don't overwrite sectors 0/1 > .InstDFS HIJSR ClearDIR:JSR dirInit :\ Use DIR buffer, fptr=>DIR, Y=0 R>STY sect+0:STY sect+1:STY sect+2 :\ Set SECT to &000000 \"LDA #BootCode 255:STA addr+0 f"LDA #BootCode 256:STA addr+1 pJSR ClearDIR :\ Use DIR buffer, A=0 j@STA addr+0:LDA #&80 :\ addr=&8000, ROM start t.InstROMlp ~>STA addr+1:PHA :\ Save source address XJSR dirInit:JSR InstCopyMem :\ Copy two pages from addr to fptr, and save it 6PLA:CLC:ADC #2 :\ Update addr =CMP #&C0:BCC InstROMlp :\ Loop to end of ROM : 5\ Any required $.HADFSROM or embedded ROM updated 1\ Now, install blank root directory if needed ,\ pushed P -> CS=update, CC=overwrite 0\ NE/EQ=xxx NE=Data, EQ=Syst 5\------------------------------------------------ .InstNoROM JPLP:BCS InstDone:PHP :\ Updating, so no new root needed IJSR ClearDIR:JSR dirInit:TYA :\ Use DIR buffer, fptr=>DIR, Y=0 .InstRootLp1 DCPY #9:BNE P%+4:LDA #32 :\ First 10 bytes are spaces >STA (fptr),Y:DEY:BNE InstRootLp1 :\ Blank out directory ;LDA #"$":STA (fptr),Y :\ Set directory name (#LDA FSM+24:LDY #16:STA (fptr),Y 25LDA FSM+25:INY:STA (fptr),Y :\ Set DiskID <9LDA FSM+31: #&80 :\ Get BigDisk flag FBLDY #12:STA (fptr),Y :\ If BigDisk, also BigDir P4LDY #10:TAX:BPL P%+4:LDY #&1C :\ Y=>Parent Z7LDA #71:STA (fptr),Y :\ Set Parent=$ dHPLP:BNE InstRootSave :\ Data disk, no $.HADFSROM file n4LDY #12:LDA #1:STA (fptr),Y :\ Entries=1 xKJSR dirNext :\ fptr=>first directory entry, Y=0 .InstRootLp2 LLDA ROMName,Y:STA (fptr),Y :\ Copy 'HADFSROM' filename into dir #INX:INY:CPY #10:BNE InstRootLp2 9LDA #&40:LDY #&13:STA (fptr),Y :\ Length=&004000 9LDA #&06:LDY #&16:STA (fptr),Y :\ Sector=&000006 .InstRootSave KJSR SectRoot:JMP PutDirNoHdr :\ Save the root directory and exit .InstDone 7RTS :\ All finished : )\ Copy data from (addr) to DIR buffer )\ ----------------------------------- .InstCopyMem NLDX #2:LDY #0:STX num :\ Copy two pages, two sectors to save .InstCopyMemLp BLDA (addr),Y:STA (fptr),Y :\ Copy code to DIR buffer "INY:BNE InstCopyMemLp ,=INC addr+1:INC fptr+1 :\ Point to next page 6DEX:BNE InstCopyMemLp @=DEX:STX action :\ action=&FF - Write JGJMP DiskAccDIR :\ Write from DIR, sect updated T: ^/\------------------------------------------ h/\ Boot sector code - 512 bytes of code with r'\ DFS catalogue and !Boot boot code |/\------------------------------------------ %.BootCode:]:BootOff=BootCode-&900 +:]:BootOsw7F=&08C0:BootAddr=BootOsw7F+1 4:]:BootZP=&A8:BootROM=&AA:BootNum=&AC:BootOS=&AD EQUS "HADFS"+0+" D" .BootCmd EQUS "!Boot "+164 9EQUD 13:EQUD 0 :\ Disk Parameter Table 7EQUS "$ ":EQUW &20A0 :\ Fake entry for '$' .ROMName EQUS "HADFSROM " 2EQUW &0000:EQUW &0047 :\ Sector of '$' : .BootGo% 5LDY #0:JSR Osbyte90_6-BootOff :\ Get HADFS status ;TXA:BPL BootUp :\ HADFS present, boot it 4LDX #1: #&40:BNE BootLdROM :\ No HADFS, load it &?LDA #143:LDY #&E:JSR OSBYTE :\ Redeclare shared workspace 0@LDX #2:JSR OSBYTE:STY &244 :\ Redeclare private workspace : .BootUp D@LDY #2 :\ *FX90,6,2 - Boot from HADFS N: XB.Osbyte90_6 :\ Generic Osbyte 90,6,y routine b LDX #6 lB.Osbyte90 :\ Generic Osbyte 90,x,y routine vLDA #90:JMP OSBYTE : .BootLdROM:\ X=1 when here %LDA #0:JSR OSBYTE:TXA:BNE BootLd1 DLDA #&05:STA RomSelOne+3-BootOff:\ Change RomSelect for Electron .BootLd1 ;LDX #15 :\ Look for a bank of RAM .BootLp 8JSR RomSelect-BootOff :\ Select ROM number X 0LDA &8008:INC &8008:CMP &8008 :\ Test if RAM .BNE BootRAMFound :\ RAM found :DEX:BPL BootLp :\ Loop for all 16 banks 1INX:JMP BootPrText-BootOff :\ No RAM found : .BootRAMFound >LDA #0:LDX #&47:LDY #3 :\ Read 3 sectors from &0047 WJSR BootRd-BootOff:LDX #6 :\ Load '$' directory, BootZP=&3000, default sector=6 .BootNxtName *LDY #0:CLC 4FLDA BootZP+0:ADC #24:STA BootZP+0 :\ Step through SmallDir entries >FLDA BootZP+1:ADC #00:STA BootZP+1 :\ Tweek to allow BigDir entries HZCMP #&33:LDA #0:BCS BootEndOfDir :\ End of directory, try embedded ROM at &AAXX=&0006 R.BootChkChr \9LDA (BootZP),Y: #&5F :\ Get filename character fCMP ROMName-BootOff,Y pABNE BootNxtName :\ Not 'HADFSROM', step to next z7INY:CPY #8:BNE BootChkChr :\ Check 8 characters : 6LDY #22:LDA (BootZP),Y:TAX :\ X=sector low byte 7INY:LDA (BootZP),Y :\ A=sector high byte .BootEndOfDir MLDY #&40:JSR BootRd-BootOff :\ Read &40 sectors from &AAXX, returns Y=0 : 6LDX #&40:STY BootROM+0 :\ &40 pages to copy 3LDA #&80:STA BootROM+1 :\ BootROM=>&8000 .BootCopyLp 5LDA (BootZP),Y:STA (BootROM),Y:\ Copy byte to ROM 7INY:BNE BootCopyLp :\ Loop for 256 bytes 4INC BootZP+1:INC BootROM+1 :\ Update pointers 7DEX:BNE BootCopyLp :\ Loop for &40 pages 8\ NB, doesn't actually check if loaded data is a ROM : .BootROMReset $-LDA #3:STA &190+200 :\ *FX200,3 ..TXA:INX:JSR OSBYTE :\ Read host 8@CPX #5:BCS BootReset :\ Compact - don't power reset BJSR ChkMOS350-BootOff LABEQ BootReset :\ MOS 3.50 - don't power cycle V.BootPower `6LDA #151:LDX #78:LDY #127:JSR OSBYTE:\ Power reset j.BootReset t3BIT &27A:BMI BootNoReset :\ If Tube, stall ~DJMP (-4) :\ Otherwise, vector to reset code .BootNoReset @LDX #BootBreak-BootText :\ Point to 'Press BREAK' text .BootPrText 7LDA BootText-BootOff,X:BEQ P% :\ End of text, stall !JSR OSASCI:INX:BNE BootPrText : EQUS &A00-(P%-BootOff),0) EQUS "ISK "+0+8+&20+&02 =EQUW &900:EQUW BootGo%-BootOff:EQUW &0200:EQUB &CC:EQUB 0 : .ChkMOS350 &LDX &EED5:CPX #"M":BNE ChkMOS350a LDX &EEDB:CPX #"5"  .ChkMOS350a RTS : ( .BootRd 2/STX BootZP+0 :\ SectorLo TAY:STY BootZP:LDX #&30:STX BootZP+1 :\ BootZP=&3000, Y=0 RTS : .RomSelect 1LDA #12:JSR RomSelOne-BootOff:TXA:STA &FF30,X .RomSelOne STA &F4:STA &FE30:RTS : \.\BootWantSystem \\LDX #BootSystem-BootText &\\JSR BootPrText-BootOff 0\\CLI:\JSR &FFE0:\JSR &FFE7 :"\\LDX #(BootCmd-BootOff) 255 D-\\LDY #(BootCmd-BootOff) 256:\JMP &FFF7 N: X .BootText b(EQUS "No SRAM":BRK:\ No sideways RAM l.BootBreak v9CMP #"4":BCS FormBadDrv :\ >'3' - Bad drive HB #3:CMP #2:BCC FormDsk4 :\ <'2' - Valid drive number RDJSR ChkROM:BEQ FormBadDrv :\ >'1' and HADFS, Bad drive \ .FormDsk4 fOJSR GrabAbs:STA &F90:STA &F91 :\ &F90=current drive, &F91=start drive pDJSR ClearFSM:LDA #0:STA &F92 :\ &F92=&00 for single-sided zSSTA &F94:PLA:STA &F95 :\ &F94=current track, &F95=tracks per side \STA &F96:CMP #103:BCC FormDsk5 :\ &F96=total tracks, 102 tracks is biggest DFS size XLSR &F95:DEC &F92 :\ Double sided, half number of tracks, &F92=&FF  .FormDsk5  LDA &F90:CMP #2:BCC FormDsk6 ILDA #0:STA &F92 :\ Drive 2/3, set to single-sided  .FormDsk6 'JSR PrText:EQUS "Format drive ":BRK ELDA &F90:JSR PrNyb:JSR OSNEWL :\ Print current drive number CJSR ChkROM:BEQ FormDsk1 :\ HADFS, check ENABLE flag GJSR NotEnabled:JMP FormDsk2 :\ Not HADFS, ask to be enabled  .FormDsk1 JSR CheckEnable :  .FormDsk2 @LDA #7:STA &F93 :\ &F93=Set initial skew .FormDskLoop $@LDA &F90:JSR FormTrack :\ Format a single track .ABIT &FF:BPL P%+5:JMP FormExit :\ Quit if Escape pressed 8BINC &F94:LDA &F94:CMP &F95 :\ Increment current track BCBNE FormDskLoop :\ Loop back until all done LLBIT &F92:BPL FormDsk7a :\ Single-sided -> create blank disk VILDA &F90:CMP #2:BCS FormDsk7a :\ Drive 2/3 -> create blank disk `EA #2:STA &F90 :\ Set to drive 2/3 for side 1 jNLDA #0:STA &F94:BEQ FormDskLoop :\ Reset to track zero, do second side t: ~.FormDsk7a 4JSR OSNEWL:LDA &F91:STA drive :\ Set drive \\.NullKbd_0 H \\.GetChn R\\LDY #0:\LDA (blk),Y \\\RTS:\BRK:\BRK f\\\.DummyCopy pE\\\BRK:\EQUS "(C)JGH" :\ x+0, \\DummyCopy-NullKbd_0 = 0 z\\\.DummyFinal ,\\EQUB JGHName-NullKbd_0:\BRK:\ x+7, x+8 4\\EQUS "SoftRTC":\BRK:\EQUS "0.10 (23 Nov 1992)"  \\BRK \\:  \\ New module header layout  .PutInInfo STA &F00,Y:INY:RTS  .GetChn LDY #0:LDA (blk),Y  .NULL RTS : ?\EQUW Dummy2-2:\ For compatability with old *SMList command  .Dummy1 $JSR Service:JMP Dummy2 .%EQUB 0:EQUB JGHName-Dummy1:EQUB 0 8EQUS "NullKeyboard":EQUB 0 B$EQUS "0.12 (01 Aug 1998)":EQUB 0 L: V?\EQUW Dummy2-4:\ For compatability with old *SMList command ` .Dummy2 jJSR NULL:JMP NULL t%EQUB 0:EQUB JGHName-Dummy2:EQUB 0 ~EQUS "SoftRTC":EQUB 0 $EQUS "0.10 (23 Nov 1992)":EQUB 0 : \\\   .Trk_70 EQUS "(Untitled_Disk) "  .JGHName EQUB 0:EQUS "(C)JGH":EQUB 0  ] $ 11;20,9);O%-mcode%;" bytes" >"S.HADFS9"