>AutoSource (Po85)  By David Lawrence ! For BBC B/B+/M/C/E with SWR (' (C) BAU January 1992 & March 1988 2: < vars Fass P check Z" 13;"Checked OK"'"Saving..." d3 "*SAVE Autorom "+~code+" "+~O%+" 8000 8000" n x: vars  code 2000 cr$=13 z$=0 mem=&70:ext=&70 len=&70:from=&72 to=&74:ptr=&F2 err=&100:finfo=&100 fname=&112:index=&8800 store=&8900 oswrch=&FFEE:osnewl=&FFE7 osasci=&FFE3:osbyte=&FFF4 osfile=&FFDD:osargs=&FFDA osfind=&FFCE:oscli =&FFF7  : " ass , pass=4 6 2 6P%=&8000:O%=code @ [OPT pass J .start TRTS ^RTS hRTS rJMP service | EQUB 129  EQUB copy  EQUB 1  .title EQUS "AutoROM"+z$+"1.00"  .copy #EQUS z$+"(C)1988 Acorn User"+z$ :  .service PHP PHA  CMP #9  BNE not9  JMP help  .not9  CMP #4  BNE not4 &JMP starcom 0 .not4 :PLA DPLP NRTS X: b .error l STX mem v STY mem+1  LDY #1  .xerror LDA (mem),Y  STA err,Y INY  CMP #0 BNE xerror  LDA #0  STA err  JMP err :  .mess  STX mem  STY mem+1  LDY #&FF  .pmess  INY *LDA (mem),Y 4JSR osasci > BNE pmess HRTS R: \ .loadzero f LDX #5 p .lzero zLDA zero,X  STA ext,X DEX  BPL lzero RTS  .savezero  LDX #5  .szero  LDA ext,X STA zero,X DEX  BPL szero RTS : .hex PHA  LSR A $ LSR A . LSR A 8 LSR A B JSR dig LPLA V #&F `.dig j CMP #10 t BCC isnum ~CLC  ADC #7  .isnum  ADC #48 JMP oswrch :  .help TXA PHA TYA PHA JSR savezero LDA (ptr),Y  CMP #13  BEQ nonly  LDX #&FF DEY ( .help1 2INX <INY FLDA hword,X P CMP #13 ZBEQ bighelp dLDA (ptr),Y nCMP # "." xBEQ bighelp  #&DF CMP hword,X  BEQ help1 .out JSR loadzero PLA TAY PLA TAX PLA PLP RTS  .nonly JSR nameonly  JMP out : " .bighelp ,JSR nameonly 6LDX #hlptxt 256 @LDY #hlptxt 256 J JSR mess T LDA index ^BEQ nomore hLDX #fcached 256 rLDY #fcached 256 | JSR mess  LDX #0  STX tmp  .hloop  LDX tmp LDA index,X  BEQ hdone  LDY #4  JSR spcs  LDY #8  .names LDA index,X BNE notend  LDA #32  .notend JSR oswrch INX &DEY 0 BNE names : LDY #8 D JSR spcs N LDA tmp XCLC b ADC #16 l STA tmp v BCC hloop  .hdone  LDA #&86 JSR osbyte  CPX #0 BEQ nomore JSR osnewl  .nomore  JMP out :  .nameonly JSR osnewl  LDY #&FF  .pname INY  LDA title,Y JSR oswrch  BNE pname *JSR osnewl 4RTS >: H .spcs R LDA #32 \ .spcsl fJSR oswrch pDEY z BNE spcsl RTS :  .bmove  LDY #0  .move  LDA len  A len+1 BEQ bmoved LDA (from),Y STA (to),Y  INC from BNE notfhi INC from+1  .notfhi  INC to BNE notthi $ INC to+1 . .notthi 8 DEC len B LDA len L CMP #&FF V BNE move ` DEC len+1 j LDA len+1 t CMP #&FF ~ BNE move .bmoved RTS : .starcom TXA PHA TYA PHA JSR savezero LDX #0 STY tmp .com1 LDA coms,X CMP #255  BEQ nocom  LDY tmp ( .com2 2LDA coms,X <BEQ gotcom FLDA (ptr),Y P #&DF ZCMP coms,X dBNE nextone nINY xINX BNE com2 .nextone INX LDA coms,X BNE nextone INX INX INX BNE com1 .gotcom INX LDA coms,X STA mem LDA coms+1,X  STA mem+1  .movey "LDA (ptr),Y , CMP #13 6BEQ ymoved @INY J CMP #32 T BEQ movey ^DEY h .ymoved r JMP (mem) |: .nocom LDX #0 STX ind .chkind LDX ind LDA index,X BEQ none LDY tmp LDA #8 STA count .cloop LDA index,X BEQ gotind LDA (ptr),Y  #&DF CMP index,X &BNE nextind 0INY :INX D DEC count N BNE cloop X .gotind bLDA (ptr),Y l CMP #32 v BEQ indok CMP #13 BEQ indok .nextind LDA ind CLC ADC #16 STA ind BCC chkind .none JMP out .indok LDX ind LDA index+8,X  STA from LDA index+9,X STA from+1 LDA index+10,X * STA to 4LDA index+11,X > STA to+1 HLDA index+14,X R STA len \LDA index+15,X f STA len+1 p JSR bmove zLDA index+12,X STA jsr+1 LDA index+13,X STA jsr+2 LDA ptr STA optr LDA ptr+1 STA optr+1 LDY #0 .moveptr INC ptr BNE notphi INC ptr+1 .notphi LDA (ptr),Y CMP # "*" BEQ moveptr $CMP # " " .BEQ moveptr 8JSR loadzero BPLA LTAY V STY y `PLA jTAX t STX x ~PLA  STA a PLA  STA p PHA  LDA a PLP .jsr  JSR &CAFE  LDA optr  STA ptr LDA optr+1  STA ptr+1  LDX x  LDY y  LDA p PHA ( LDA #0 2PLP <RTS F: P .comout ZJSR loadzero dPLA nTAX xPLA TAX PLA  LDA #0 PLP RTS :  .clear  CMP #13 BNE notclr  LDY #0 TYA  .clrind STA index,Y DEY BNE clrind LDX #store 256 " STX mem ,STX index+8 6LDX #store 256 @ STX mem+1 JSTX index+9 T LDA #&C0 ^SEC h SBC mem+1 rSTA memfree+1 | LDA #0  STA iptr  STA num STA memfree JMP comout  .notclr  JMP out :  .data  CMP #13 BNE notclr  LDA index  BEQ sdone LDX #dhead 256 LDY #dhead 256  JSR mess  LDX #0 & STX tmp 0 .snames : LDX tmp DLDA index,X N BEQ sdone X LDY #8 b .dloop lLDA index,X v BNE nospc  LDA #32  .nospc JSR oswrch INX DEY  BNE dloop  LDA tmp CLC  ADC #10 PHA TAY  JSR pdata INY INY  JSR pdata INY  INY * JSR pdata 4PLA >TAY HDEY RDEY \ JSR pdata fJSR osnewl p LDA tmp zCLC  ADC #16  STA tmp BCC snames  .sdone LDA # "&" JSR oswrch LDA memfree+1  JSR hex LDA memfree  JSR hex LDX #dfoot 256 LDY #dfoot 256  JSR mess JMP comout :  .pdata $ LDA #32 .JSR oswrch 8JSR oswrch BLDA index+1,Y L JSR hex VLDA index,Y ` JMP hex j: t .cache ~ CMP #13 BNE docache LDX #csyn 256 LDY #csyn 256  JMP error  .docache  LDX #0  .xname LDA (ptr),Y STA fname,X INY INX  CMP #13  BNE xname  LDX #fname 256 LDY #fname 256  LDA #&40 (JSR osfind 2 CMP #0 <BEQ nofile FTAY P LDX #ext Z LDA #2 dJSR osargs n LDA #0 xJSR osfind  LDA num  CMP #16 BEQ noroom  LDA ext+2  A ext+3 BNE toobig  LDA ext+1 CMP memfree+1  BCC ok BNE toobig  LDA ext CMP memfree  BEQ ok  BCC ok :  .toobig "LDX #ftb 256 ,LDY #ftb 256 6 JMP error @ .nofile JLDX #fnf 256 TLDY #fnf 256 ^ JMP error h .noroom rLDX #nis 256 |LDY #nis 256  JMP error : .ok  LDY #&11  LDA #&FF  .clrblk STA finfo,Y DEY BNE clrblk LDA #fname 256  STA finfo LDA #fname 256 STA finfo+1 LDX #finfo 256 LDY #finfo 256  LDA #&FF &JSR osfile 0 LDY iptr :LDA finfo+2 D STA from NSTA index+10,Y XLDA finfo+3 bSTA from+1 lSTA index+11,Y vLDA index+8,Y  STA to LDA index+9,Y  STA to+1 LDA finfo+6 STA index+12,Y LDA finfo+7 STA index+13,Y  LDA ext STA index+14,Y  LDA ext+1 STA index+15,Y LDA memfree SEC  SBC len  STA memfree LDA memfree+1  SBC len+1 *STA memfree+1 4 JSR bmove > LDX #0 H .fret RINX \LDA fname,X f CMP #32 p BEQ ndot z CMP #13  BNE fret  .ndot DEX  BEQ gotit LDA fname,X CMP # "."  BNE ndot INX  .gotit  LDY #8  STY tmp  LDY iptr  .mname LDA fname,X  CMP #32 BEQ mndone $ CMP #13 .BEQ mndone 8STA index,Y BINX LINY V DEC tmp ` BNE mname j .mndone t LDA num ~ CMP #15  BEQ noinc  LDA iptr CLC  ADC #16  STA iptr TAY  LDA to STA index+8,Y  LDA to+1 STA index+9,Y  .noinc  INC num JMP comout  :  .scrap  CMP #13 (BNE doscrap 2LDX #ssyn 256 <LDY #ssyn 256 F JMP error P .doscrap Z LDX #0 d .scrap1 nLDA (ptr),Y xSTA fname,X  CMP #13  BEQ eoc  CMP #32  BEQ eoc INY INX  CPX #8 BNE scrap1 JMP nofile .eoc  LDX #0  STX tmp  .fscrap  LDX tmp LDA index,X BEQ notthere " LDY #0 , LDA #8 6 STA count @ .comploop JLDA index,X TBEQ comped ^CMP fname,Y h BNE ncomp rINX |INY  DEC count BNE comploop  .notthere JMP nofile :  .ncomp  LDA tmp CLC  ADC #16  STA tmp BCC fscrap JMP nofile  .comped LDA fname,Y  CMP #32 BEQ compok & CMP #13 0 BNE ncomp :: D .compok N LDX tmp XLDA index+14,X b STA len lLDA index+15,X v STA len+1  CPX #&F0 BEQ justdel LDA index+8,X  STA to LDA index+9,X  STA to+1 LDA index+24,X  STA from LDA index+25,X STA from+1  LDY #0  .shuffle LDA (from),Y STA (to),Y  INC to  BNE shuf1  INC to+1 * .shuf1 4 INC from >BNE shuffle HINC from+1 RLDA from+1 \ CMP #&C0 fBNE shuffle p LDA tmp zTAX CLC  ADC #16 TAY  .shufind LDA index,Y STA index,X INX INY BNE shufind  LDX tmp  .sublen LDA index+8,X SEC  SBC len STA index+8,X LDA index+9,X $ SBC len+1 .STA index+9,X 8TXA BCLC L ADC #16 VTAX `BCC sublen j LDA num t CMP #16 ~BEQ justdel  LDA iptr SEC  SBC #16  STA iptr  .justdel  DEC num LDA memfree CLC  ADC len STA memfree LDA memfree+1  ADC len+1 STA memfree+1  LDA #0  LDY #&F0  .deloop ( CPY #&F8 2 BNE noiny <INY FINY P .noiny ZSTA index,Y dINY nBNE deloop xJMP comout : #.hlptxt EQUS " Commands:"+cr$ ) EQUS " *CACHE "+cr$ ) EQUS " *SCRAP "+cr$ " EQUS " *CLEAR"+cr$ ! EQUS " *DATA"+cr$  EQUB 0 *.fcached EQUS " Files cached:"+cr$+z$ ;.dhead EQUS "Filename Load Exec Size Addr"+cr$+z$ '.dfoot EQUS " bytes free."+cr$+z$ 2.fnf BRK:EQUB 255:EQUS "File not found"+z$ 0.ftb BRK:EQUB 254:EQUS "File too big"+z$ 4.nis BRK:EQUB 253:EQUS "No room in index"+z$ 9.csyn BRK:EQUB 252:EQUS "Syntax: *CACHE "+z$ 9.ssyn BRK:EQUB 251:EQUS "Syntax: *SCRAP "+z$ .hword EQUS "AUTOROM"+cr$ ").coms EQUS "CACHE"+z$ : EQUW cache ,) EQUS "SCRAP"+z$ : EQUW scrap 6) EQUS "CLEAR"+z$ : EQUW clear @( EQUS "DATA"+z$ : EQUW data J EQUB -1 T.zero EQUD 0 ^ EQUW 0 h.tmp EQUB 0 r.memfree EQUW 0 |.iptr EQUB 0 .num EQUB 0 .count EQUB 0 .ind EQUB 0 .a EQUB 0 .x EQUB 0 .y EQUB 0 .p EQUB 0 .optr EQUW 0 .end EQUB 0 ]  :  check  "Checking..."; sum("start","out",20044) sum("out","bmove",16661) & sum("bmove","gotind",23629) 0sum("gotind","data",28004) :sum("data","toobig",26887) D sum("toobig","scrap",24762) N!sum("scrap","shufind",21955) X"sum("shufind","hlptxt",12223) bsum("hlptxt","end",20901) l: v: sum(from$,to$,value) total%=0  x%= (from$) (to$) total%=total%+?x%   total%=value : 7 '"Checksum error between ";from$;" and ";to$;".";