ô 128 File DFS Extension ô By David Lawrence ô For BBC B/B+/M (ô (c) Acorn User Sept 1987 2: <ë 7 F òvars P òassemble Zòchecksums d òsave nà x: ‚ Ý òvars Œ"loc1=&70 : loc2=&71 : loc3=&72 –"loc4=&73 : loc5=&74 : loc6=&75  !loc7=&76 : loc8=&77 : blk=&80 ªbuf1=&900 : buf2=&A00 ´osnewl=&FFE7 ¾osasci=&FFE3 Èosword=&FFF1 Òoswrch=&FFEE Üosbyte=&FFF4 æ D%=&2000 ðá ú: Ý òassemble ã I%=0 ¸ 2 ˆ 2  P%=&6000 " [OPT I% , .start 6OPT ¤equb(0) @OPT ¤equb(0) JOPT ¤equb(0) TJMP service+D% ^OPT ¤equb(129) hOPT ¤equb(copy) rOPT ¤equb(1) | .title †OPT ¤equb(13) 'OPT ¤equs("128 file DFS extension") šOPT ¤equb(13) ¤OPT ¤equb(0) ®OPT ¤equs("1.00") ¸ .copy ÂOPT ¤equb(0) Ì(OPT ¤equs("(C) David Lawrence 1986") ÖOPT ¤equb(0) à.hlp êOPT ¤equs("128 file DFS") ôOPT ¤equb(13) þOPT ¤equb(13) OPT ¤equs(" *LOG") OPT ¤equb(13) )OPT ¤equs(" *PUT file/*,") &OPT ¤equb(13) 0OPT ¤equs(" *GET file/*") :OPT ¤equb(13) DOPT ¤equs(" *INIT") NOPT ¤equb(13) XOPT ¤equs(" *ERASE") bOPT ¤equb(255) l .service v STA &8E €TXA ŠPHA ”TYA žPHA ¨ LDA &8E ² CMP #4 ¼ BEQ com Æ CMP #9 Ð BEQ help ÚJMP out+D% ä .help îLDA (&F2),Y ø CMP #&D  BEQ name  LDX #0  .help0  LDA (&F2),Y * CMP #&D 4 BEQ help1 >CMP title+1+D%,X H BNE out RINY \INX fJMP help0+D% p .help1 zJSR osnewl „ LDX #0 Ž .help2 ˜LDA hlp+D%,X ¢ CMP #&FF ¬ BEQ help3 ¶JSR osasci ÀINX ÊJMP help2+D% Ô .help3 ÞJSR osnewl èJMP out+D% ò.out üPLA TAY PLA TAX $ LDA &8E .RTS 8 .name B LDX #0 L .name1 VLDA title+D%,X ` BEQ out jJSR osasci tINX ~ BNE name1 ˆ.com ’ STY loc5 œ LDY #4 ¦.c1 °LDA (&F2),Y ºCMP cmd1+D%,Y Ä BNE next1 ÎDEY Ø BNE c1 âJMP dir+D% ì .next1 ö LDY#4 .c2  LDA (&F2),Y CMP cmd2+D%,Y  BNE next2 (DEY 2 BNE c2 <JMP get+D% F .next2 P LDY #4 Z.c3 dLDA (&F2),Y nCMP cmd3+D%,Y x BNE next3 ‚DEY Œ BNE c3 –JMP put+D%   .next3 ª LDY #5 ´.c4 ¾LDA (&F2),Y ÈCMP cmd4+D%,Y Ò BNE next4 ÜDEY æ BNE c4 ðJMP init+D% ú .next4  LDY #6 .c5 LDA (&F2),Y "CMP cmd5+D%,Y , BNE out 6DEY @ BNE c5 JJMP erase+D% T .load ^ STA blk+2 h STX blk+7 r STY blk+8 |LDX #blk ƒ 256 †LDY #blk 256  LDA #&53 š STA blk+6 ¤ LDA #&7F ®JSR osword ¸RTS  .save Ì STA blk+2 Ö STX blk+7 à STY blk+8 êLDX #blk ƒ 256 ôLDY #blk 256 þ LDA #&4B  STA blk+6  LDA #&7F JSR osword &RTS 0 .loadtrk : STA blk+2 D STX blk+7 N LDA #0 X STA blk+8 bTYA lCLC v ADC #&20 € STA blk+9 ŠLDX #blk ƒ 256 ”LDY #blk 256 ž LDA #&53 ¨ STA blk+6 ² LDA #&7F ¼JSR osword ÆRTS Ð LDA #&21 Ú STA blk+9 äRTS î .savetrk ø STA blk+2  STX blk+7  LDA #0  STA blk+8  TYA *CLC 4 ADC #&20 > STA blk+9 HLDX #blk ƒ 256 RLDY #blk 256 \ LDA #&4B f STA blk+6 p LDA #&7F zJSR osword „ LDA #&21 Ž STA blk+9 ˜RTS ¢ .setblk ¬ LDX #10 ¶ .set1 ÀLDA blk1+D%,X Ê STA blk,X ÔDEX Þ BPL set1 è LDX #0 ò LDY #0 ü LDA #&A JSR load+D%  LDX #6  .set2 $LDA buf2+&8,X .CMP mess3+D%,X 8 BNE wrong BDEX L BPL set2 VRTS ` .wrong jLDX #err5 ƒ 256 tLDY #(err5+D%) 256 ~JMP error+D% ˆ .blk1 ’OPT ¤equd(0) œOPT ¤equd(&300) ¦OPT ¤equd(&2100) ° .cmd1 ºOPT ¤equs(" LOG") ÄOPT ¤equb(13) Î .cmd2 ØOPT ¤equs(" GET ") â .cmd3 ìOPT ¤equs(" PUT ") ö .cmd4 OPT ¤equs(" INIT") OPT ¤equb(13)  .cmd5 OPT ¤equs(" ERASE") (OPT ¤equb(13) 2 .err1 <BRK FOPT ¤equb(255) POPT ¤equs("File not found") ZOPT ¤equb(0) d .err2 nBRK xOPT ¤equb(254) ‚OPT ¤equs("Pardon?") ŒOPT ¤equb(0) – .err3  BRK ªOPT ¤equb(253) ´OPT ¤equs("Disk full") ¾OPT ¤equb(0) È .err4 ÒBRK ÜOPT ¤equb(252) æOPT ¤equs("Cat full") ðOPT ¤equb(0) ú .err5 BRK OPT ¤equb(251) !OPT ¤equs("Not 128 DFS disc") "OPT ¤equb(0) , .err6 6BRK @OPT ¤equb(250) JOPT ¤equs("Catalog empty") TOPT ¤equb(0) ^ .mess1 hOPT ¤equs(" files. &") rOPT ¤equb(0) | .mess2 †OPT ¤equs(" free sectors") OPT ¤equw(&D) š .mess3 ¤OPT ¤equs("128 DFS") ® .mess4 ¸4OPT ¤equs("0 track initialise -- Sure? (Y/N) :") ÂOPT ¤equw(7) Ì*.mess5 OPT ¤equs(" -- Erase? (Y/N) :") ÖOPT ¤equw(7) à .data1 êOPT ¤equd(&20383231) ôOPT ¤equd(&A4534644) þ .data2 OPT ¤equd(&00020001) OPT ¤equd(&00850128)  .data3 &OPT ¤equd(&00020001) 0OPT ¤equd(&00150350) : .data4 DOPT ¤equd(&0DF50128) NOPT ¤equd(&02301E00) X .error b STX loc4 l STY loc5 v LDY #1 € .error1 ŠLDA (loc4),Y ”STA &100,Y žBEQ error2 ¨INY ²JMP error1+D% ¼ .error2 Æ LDA #0 Ð STA &100 Ú JMP &100 ä.dir îJSR setblk+D% ø LDA #0  STA loc4 STA loc5  LDA #2 STA loc2 * .dir1 4 LDX #0 > LDY loc2 H LDA #&A RJSR load+D% \ LDY #0 f .dir2 pLDA buf2,Y zBEQ dirend „SED Ž LDA loc5 ˜CLC ¢ ADC #1 ¬ STA loc5 ¶ BCC miss À INC loc4 Ê .miss ÔCLD Þ LDX #12 è .dir3 òLDA buf2,Y üJSR oswrch INY DEX  BNE dir3 $INY .INY 8 LDA #32 BJSR oswrch LLDA buf2,Y VJSR tohex+D% ` LDA #32 jJSR oswrch tINY ~LDA buf2,Y ˆJSR tohex+D% ’ LDA #32 œJSR oswrch ¦JSR oswrch °INY º CPY #0 Ä BNE dir2 Î INC loc2 Ø LDA loc2 â CMP #10 ì BNE dir1 ö .dirend  LDX #0  LDY #0  LDA #&A JSR load+D% (JSR osnewl 2JSR osnewl < LDA loc4 FBEQ dirend1 P LDA #49 ZJSR oswrch dJMP dirend2+D% n .dirend1 x LDA #48 ‚JSR oswrch Œ .dirend2 – LDA loc5  JSR tohex+D% ª LDX #0 ´ .dirend3 ¾LDA mess1+D%,X ÈBEQ dirend4 ÒJSR osasci ÜINX æJMP dirend3+D% ð .dirend4 úLDA buf2+&FD JSR tohex+D% LDA buf2+&FE JSR tohex+D% " LDX #0 , .dirend5 6LDA mess2+D%,X @BEQ dirend6 JJSR osasci TINX ^JMP dirend5+D% h .dirend6 r LDA #0 | STA &8E †JMP out+D%  .findname š LDX #12 ¤ LDA #32 ® LDY #5 ¸ .get1 ÂSTA buf1,X ÌDEX Ö BNE get1 à LDX #0 ê .get2 ôLDA (&F2),Y þ CMP #&D  BEQ get3 STA buf1,X INY &INX 0 CPX #12 : BNE get2 D .get3 N LDA #2 X STA loc2 b .get4 l LDX #0 v LDY loc2 € LDA #&A ŠJSR load+D% ” LDY #0 ž LDX #15 ¨ .move ²LDA buf2+&F0,X ¼STA buf1+&F0,X ÆDEX Ð BPL move Ú .get5 äLDA buf2,Y îBEQ notfound ø LDX #0  .get6  LDA buf1,X  CMP #42  BEQ found *CMP buf2,Y 4 BNE get7 >INY HINX R CPX #12 \ BEQ found fJMP get6+D% p .get7 zINY „INX Ž CPX #16 ˜ BNE get7 ¢ CPY #0 ¬ BNE get5 ¶ INC loc2 À LDA loc2 Ê CMP #10 Ô BNE get4 Þ .notfound èLDX #err1 ƒ 256 òLDY #(err1+D%) 256 üJMP error+D%  .found INY INX $ CPX #16 . BNE found 8RTS B.get LJSR setblk+D% VJSR findname+D% ` STY loc7 jLDA buf1+&FC,Y t STA loc1 ~LDA buf1+&FD,Y ˆ STA loc2 ’LDA buf1+&FE,Y œ STA loc3 ¦ STA loc8 °LDA buf1+&FF,Y º STA loc4 ÄCLC Î ADC loc3 Ø STA loc6 â .found1 ì LDA loc2 ö BNE load1  LDY loc4  CPY #11  BCC ok  LDY #10 (.ok 2 STY loc5 < DEC loc5 F LDX loc1 P LDA loc3 ZJSR loadtrk+D% d LDA loc3 nCLC x ADC loc5 ‚ STA loc3 Œ LDA loc4 –SEC   SBC loc5 ª STA loc4 ´ LDA loc2 ¾CLC È ADC loc5 Ò STA loc2 ÜJMP load2+D% æ .load1 ð LDX loc1 ú LDY loc2  LDA loc3 JSR load+D%  .load2 " DEC loc4 , INC loc3 6 LDA loc3 @ CMP loc6 JBEQ found2 T INC loc2 ^ LDA loc2 h CMP #10 rBNE found1 | LDA #0 † STA loc2  INC loc1 šJMP found1+D% ¤ .found2 ® LDA loc7 ¸SEC  SBC #16 ÌTAY ÖLDA buf2,Y à CMP #—"!" êBNE found3 ô LDA loc8 þ STA &18  LDA #138  LDX #0  LDY #—"O" &JSR osbyte 0 LDY #—"." :JSR osbyte D LDY #13 NJSR osbyte X LDY #—"R" bJSR osbyte l LDY #—"U" vJSR osbyte € LDY #—"N" ŠJSR osbyte ” LDY #13 žJSR osbyte ¨ .found3 ² LDA #0 ¼ STA &8E ÆJMP out+D% Ð.hex ÚINY äLDA (&F2),Y î CMP #71 ø BCS nohex  CMP #48  BCC nohex  CMP #58  BCC okhex1 * CMP #65 4BCS okhex2 > .nohex H LDA #&FF RRTS \ .okhex1 fSEC p SBC #48 zRTS „ .okhex2 ŽSEC ˜ SBC #55 ¢RTS ¬ .tohex ¶TAX À LSR A Ê LSR A Ô LSR A Þ LSR A èJSR outhex+D% òTXA ü € #&F JSR outhex+D% RTS  .outhex $ CMP #10 .BCS outhex2 8CLC B ADC #48 LJSR oswrch VRTS ` .outhex2 jCLC t ADC #55 ~JSR oswrch ˆRTS ’.put œJSR setblk+D% ¦ LDX #16 ° LDA #32 º LDY #5 Ä .put1 ÎSTA buf1,X ØDEX â BNE put1 ì LDX #0 ö .put2 LDA (&F2),Y  CMP #13  BEQ put4  CMP #44 ( BNE put3 2INX < .put3 FINY PJMP put2+D% Z .put4 d CPX #2 n BEQ put5 x CPX #0 ‚ BNE wot ŒJMP replace+D% –.wot  LDX #err2 ƒ 256 ªLDY #(err2+D%) 256 ´JMP error+D% ¾ .put5 È LDA #0 Ò STA loc7 Ü LDY #5 æ LDX #0 ð .put6 úLDA (&F2),Y  CMP #44  BEQ put8 STA buf1,X "INY ,INX 6 CPX #12 @ BNE put6 J .put7 TLDA (&F2),Y ^ CMP #44 h BEQ put8 rINY |JMP put7+D% † .put8 JSR hex+D% š CMP #255 ¤ BEQ wot ® ASL A ¸ ASL A  ASL A Ì ASL A Ö STA loc6 àJSR hex+D% ê CMP #255 ô BEQ wot þCLC  ADC loc6 STA buf1+&E INY &JSR hex+D% 0 CMP #255 : BEQ wot D ASL A N ASL A X ASL A b ASL A l STA loc6 vJSR hex+D% € CMP #255 Š BEQ wot ”CLC ž ADC loc6 ¨STA buf1+&F ² STA loc5 ¼CLC ÆADC buf1+&E Ð STA loc1 Ú LDX #0 ä LDY #0 î LDA #&A øJSR load+D% LDA buf2+&FA  CMP #10 BEQ catfull  LDA buf2+&F8 *STA buf1+&C 4LDA buf2+&F9 >STA buf1+&D HLDA buf1+&E R STA loc6 \ DEC loc6 f .put9 p INC loc6 z LDA loc6 „ CMP loc1 Ž BEQ put10 ˜LDA buf2+&F9 ¢ BNE save1 ¬ LDY loc5 ¶ CPY #11 À BCC ok2 Ê LDY #10 Ô.ok2 Þ STY loc4 è DEC loc4 òLDX buf2+&F8 ü LDA loc6 JSR savetrk+D%  LDA loc5 SEC $ SBC loc4 . STA loc5 8LDA buf2+&F9 BCLC L ADC loc4 VSTA buf2+&F9 ` LDA loc6 jCLC t ADC loc4 ~ STA loc6 ˆJMP save2+D% ’ .save1 œLDX buf2+&F8 ¦LDY buf2+&F9 ° LDA loc6 ºJSR save+D% Ä .save2 Î DEC loc5 ØINC buf2+&F9 âLDA buf2+&F9 ì CMP #10 ö BNE put9  LDA #0  STA buf2+&F9 INC buf2+&F8 LDA buf2+&F8 (CMP buf2+&FC 2 BNE put9 < .diskfull FLDX #err3 ƒ 256 PLDY #(err3+D%) 256 ZJMP error+D% d .catfull nLDX #err4 ƒ 256 xLDY #(err4+D%) 256 ‚JMP error+D% Œ .put10 – LDA loc7   CMP #1 ªBEQ replaced ´LDA buf2+&FA ¾ STA loc2 ÈLDA buf2+&FB Ò STA loc1 ÜCLC æ ADC #16 ðSTA buf2+&FB ú BNE put11 INC buf2+&FA  .put11 LDA buf2+&FE "SEC ,SBC buf1+&F 6STA buf2+&FE @LDA buf2+&FD J SBC #0 TSTA buf2+&FD ^ LDX #0 h LDY #0 r LDA #&A |JSR save+D% † LDX #0  LDY loc2 š LDA #&A ¤JSR load+D% ® LDY loc1 ¸ LDX #0  .put12 ÌLDA buf1,X ÖSTA buf2,Y àINY êINX ô CPX #16 þ BNE put12  LDX #0  LDY loc2  LDA #&A &JSR save+D% 0 .replaced : LDA #0 D STA &8E NJMP out+D% X .replace bJSR findname+D% lLDA buf1+&FC,Y vSTA buf2+&F8 €LDA buf1+&FD,Y ŠSTA buf2+&F9 ”LDA buf1+&FE,Y ž STA loc6 ¨LDA buf1+&FF,Y ² STA loc5 ¼CLC Æ ADC loc6 Ð STA loc1 Ú DEC loc6 ä LDA #1 î STA loc7 øJMP put9+D% !JSR findname+D% ! .init ! LDX #10 ! .sblk1 !*LDA blk1+D%,X !4 STA blk,X !>DEX !H BPL sblk1 !R LDX #0 !\ LDY #1 !f LDA #9 !pJSR load+D% !zLDA buf1+&6 !„ ASL A !ŽCLC !˜ ADC #50 !¢TAY !¬ LDX #0 !¶TXA !À.clr !ÊSTA buf1,X !ÔSTA buf2,X !ÞINX !è BNE clr !òTYA !ü CMP #52 "BEQ init40 " CMP #56 "BEQ init80 "$JMP wot+D% ". .sure "8 STX loc4 "B STY loc5 "L LDY #0 "V .sure1 "`LDA (loc4),Y "j BEQ sure2 "tJSR osasci "~INY "ˆJMP sure1+D% "’ .sure2 "œ LDA #15 "¦JSR osbyte "° LDX #&FF "º LDY #&7F "Ä LDA #&81 "ÎJSR osbyte "ØTXA "â CMP #—"N" "ì BEQ sure3 "ö CMP #—"Y" # BNE sure2 # JSR oswrch #JSR osnewl #RTS #( .sure3 #2JSR oswrch #<JSR osnewl #F LDA #0 #P STA &8E #ZPLA #dPLA #nJMP out+D% #x .init40 #‚JSR oswrch #ŒLDX #mess4 ƒ 256 #–LDY #(mess4+D%) 256 # JSR sure+D% #ª LDX #7 #´ .init401 #¾LDA data2+D%,X #ÈSTA buf1+&F8,X #ÒDEX #ÜBPL init401 #æ LDA #1 #ðSTA buf2+&6 #ú LDA #&90 $STA buf2+&7 $JMP init2+D% $ .init80 $"JSR oswrch $,LDX #mess4 ƒ 256 $6LDY #(mess4+D%) 256 $@JSR sure+D% $J LDX #7 $T .init801 $^LDA data3+D%,X $hSTA buf1+&F8,X $rDEX $|BPL init801 $† LDA #3 $STA buf2+&6 $š LDA #&20 $¤STA buf2+&7 $® .init2 $¸ LDA #48 $ÂJSR oswrch $Ì LDX #7 $Ö .init3 $àLDA data1+D%,X $êSTA buf1+&8,X $ôLDA data4+D%,X $þSTA buf2+&8,X %DEX % BPL init3 % LDA #8 %&STA buf2+&5 %0 LDX #4 %: LDA #0 %D .init4 %NSTA buf2,X %XDEX %b BPL init4 %l LDX #0 %v LDY #0 %€ LDA #9 %ŠJSR save+D% %” LDA #49 %žJSR oswrch %¨ LDX #0 %² LDY #1 %¼ LDA #&A %ÆJSR save+D% %Ð LDX #0 %ÚTXA %ä .init5 %îSTA buf1,X %øINX & BNE init5 & LDY #2 & STY loc2 & .init6 &* LDA loc2 &4CLC &> ADC #48 &HJSR oswrch &R LDX #0 &\ LDY loc2 &f LDA #9 &pJSR save+D% &z INC loc2 &„ LDA loc2 &Ž CMP #10 &˜ BNE init6 &¢JSR osnewl &¬ LDA #0 &¶ STA &8E &ÀJMP out+D% &Ê .erase &Ô LDX #0 &Þ LDY #0 &è LDA #9 &òJSR load+D% &üLDA buf1+&FB 'BNE erase1 'DEC buf1+&FA 'LDA buf1+&FA '$ CMP #1 '.BEQ erase4 '8 .erase1 'BLDA buf1+&FB 'LSEC 'V SBC #16 '`STA buf1+&FB 'j LDX #0 'tLDY buf1+&FA '~ LDA #&A 'ˆJSR load+D% '’LDY buf1+&FB 'œ LDX #12 '¦ .erase2 '°LDA buf2,Y 'ºJSR oswrch 'ÄINY 'ÎDEX 'ØBNE erase2 'âLDX #mess5 ƒ 256 'ìLDY #(mess5+D%) 256 'öJSR sure+D% (LDA buf1+&FB ( CLC ( ADC #&C (TAY ((LDA buf2,Y (2STA buf1+&F8 (<INY (FLDA buf2,Y (PSTA buf1+&F9 (ZINY (dINY (nLDA buf2,Y (x STA loc6 (‚LDY buf1+&FB (Œ LDX #16 (– LDA #0 (  .erase3 (ªSTA buf2,Y (´INY (¾DEX (ÈBNE erase3 (ÒLDA buf1+&FE (ÜCLC (æ ADC loc6 (ðSTA buf1+&FE (úLDA buf1+&FD ) ADC #0 )STA buf1+&FD ) LDX #0 )" LDY #0 ), LDA #9 )6JSR save+D% )@ LDX #0 )JLDY buf1+&FA )T LDA #&A )^JSR save+D% )h LDA #0 )r STA &8E )|JMP out+D% )† .erase4 )LDX #err6 ƒ 256 )šLDY #(err6+D%) 256 )¤JMP error+D% )®.end )¸BRK )Â] )Ìí )Öá )à: )êÝ ¤equb(b%) )ô?P%=b% : P%=P%+1 )þ= I% *: *Ý ¤equw(b%) *?P%=b% ƒ 256 *&P%?1=b% 256 *0 P%=P%+2 *:= I% *D: *NÝ ¤equd(b%) *X!P%=b% : P%=P%+4 *b= I% *l: *vÝ ¤equs(b$) *€$P%=b$ : P%=P%+©(b$) *Š= I% *”: *žÝ òchecksums *¨òcheck("start","com",22297) *² òcheck("com","setblk",25669) *¼ òcheck("setblk","dir",23850) *Æòcheck("dir","get3",27414) *Ð!òcheck("get3","found2",26061) *Ú òcheck("found2","wot",20910) *äòcheck("wot","save2",25331) *î òcheck("save2","sure",27644) *ø òcheck("sure","init6",24862) +òcheck("init6","end",22802) + á +: + Ý òcheck(from$,to$,value) +* total%=0 +4ã x%= (from$) ¸  (to$) +>total%=total%+?x% +Hí +Rç total%=value á +\4ñ"Checksum error between ";from$;" and ";to$;"." +fà +p: +z Ý òsave +„ñ"Code assembled OK." +ŽPñ'"Insert the disc on which you wish to save the code and press "; +˜ õ ý ¦-99 +¢ñ +¬$*SAVE ROM128 6000 6900 8000 8000 +¶á ÿ