; ; File - DEC9 ; ; Assorted useful routines ; starlo ; Enters here if the user wants to load a file ;Translates into an osfile for open disordered, then does ;lots of get byte calls. Also should do tubular stuff if reqd. LDAIM 0 ; *** Tim *** Clear *RUN flag STA lowest ; | starvv ; | STX cblow ; *** Tim *** Following code cribbed from TFS patch and STY cbhigh ; | put where it should be in ROM for *LOAD ; | with a few changes to cope with tube ; *** Tim *** *LOAD FRED 2000 passes the ENTIRE string as the filename to ; | OSFILE. ; | -- the filename must therefore be stripped off. ; | -- It is not enough just to poke a CR into the space character ; | -- because OSCLI("LOAD FRED") in a basic program would ; | -- get corrupted by the cr being inserted in the middle of ; | -- the literal text. ; | ** The remedy is to copy the string elsewhere, and tweak ; | ** the pointer. ; *** Tim *** LDYIM 0 ; | LDAIY cb ; | STA from ; | INY ; | LDAIY cb ; | STA from+1 ; | LDAIM 0 ; | TAY ; | STA count ; | STAIY cb ; | INY ; | TYA ; | STA count+1 ; | STAIY cb ; | ; | Using stack as workspace - not nice LDYIM 0 ; | cps LDAIY from ; | STAIY count ; | CMPIM 33 ; | BCC ends ; | INY ; | BNE cps ; | ends ; | LDAIM 13 ; | STAIY count ; | LDAIM 7 ; | LDX cblow ; | LDY cbhigh ; | JSR opendi ; | Open disorded LDA lowest ; | Read *RUN flag BEQ lowwww ; | LDYIM 6 ; | LDAIY cb ; | Read exec address flag BEQ lowwww ; | Branch if it exists JSR dobrk ; | Force error = &FE ; | ***** Tempory error number = "Cannot execute" ; | BRK ; | ; | lowwww ; | LDAIM 0 ; | STA count ; | STA count+1 ; | loadup ; | LDYIM 14 ; | JSR doosbg ; | Do a BGET BCC gotbyt ; | CMPIM &FE ; | BEQ endoff ; | CMPIM 2 ; | BNE skipth ; | ; | End of block. Get new load addr LDAIM 5 ; | LDX cblow ; | LDY cbhigh ; | Info to get block addr JSR getadd ; | LDYIM 2 ; | loopfy ; | LDAIY cb ; | STAAY temp-2 ; | INY ; | CPYIM 6 ; | Get 4 byte address - changed from 2 byte ; | address used in the original patch. BNE loopfy ; | skipth ; | CLC ; | BCC loadup ; | gotbyt ; | STA TTEMP2 ; | LDAIM 1 ; | LDXIM :LSB: temp ; | Point X and Y to address of temp LDYIM :MSB: temp ; | JSR poke ; | Send byte - tubed or otherwise INC temp ; | BNE zz3 ; | INC temp+1 ; | zz3 ; | INC count ; | BNE zz4 ; | INC count+1 ; | zz4 ; | CLC ; | BCC loadup ; | endoff ; | LDYIM &0A ; | LDAIY cb ; | PHA ; | **** Push No-exec flag LDA count ; | STAIY cb ; | Y = &A LDA count+1 ; | INY ; | STAIY cb ; | Y = &B LDAIM 0 ; | INY ; | STAIY cb ; | INY ; | STAIY cb ; | Y = &C &D - fill in length PLA ; | INY ; | STAIY cb ; | **** Put No-exec flag in attributes byte RTS ; | ; ; *** Tim *** ; starru ; *** Tim *** *RUN implementation. Uses *LOAD routine ; | above then sets it going - either across ; | the tube or otherwise depending on tube ; | presence and the start address. ; | LDAIM 1 ; | STA lowest ; | Set *RUN flag JSR starvv ; | Load in file LDYIM 6 ; | srun2 ; | LDAIY cb ; | Copy execution address to "lowest" STAAY lowest-6 ; | INY ; | CPYIM 10 ; | BNE srun2 ; | JSR istube ; | Is there a second proc.? BEQ tyes ; | Yes - then branch JMI lowest ; | Execute program tyes ; | JSR claim ; | Claim tube PHP ; | SEI ; | LDAIM 4 ; | LDXIM :LSB: lowest ; | Point X and Y to address in 2nd proc. LDYIM :MSB: lowest ; | JSR tube ; | Cause other side to execute JSR letgo ; | Release tube PLP ; | Restore interrupts RTS ; *** Tim *** Exit ; notimp JSR dobrk = &CF = "Data not available" BRK starit LdaIY zp0 Clc AdcIM 2 Jmp sc starch LdaIY zp0 sc sec SbcIM "1" ; 1->0 ETC... pha pha pha SEC Jmp locsel ; setFF ;Set all to FF LdxIM 7 LdaIM &FF pl1 StaAX ARGcon Dex Bne pl1 RTS ;CB+1 .. CB+7 starpa Jsr setFF ;\\\\\\ Must count and vet parameters LdaIY zp0 CmpIM "." Bne pl2 Iny pl2 LdaIY zp0 ;From CLI Iny CmpIM 13 Beq pl3 CmpIM 32 Beq pl2 CmpIM "#" Beq starpo CmpIM "0" Bcc starpilleg CmpIM "9"+1 Bcc starpo CmpIM "A" Bcc starpilleg CmpIM "F"+1 Bcc starpo CmpIM "a" Bcc starpilleg CmpIM "f"+1 Bcc starpo Jmp starpilleg starpo Inx StaAX ARGcon CpxIM 8 Bne pl2 badC bad1 starpilleg Jsr dobrk = &CC = "Bad parameter" = 0 pl3 LdaIM &85 Sta ARGcon CallOS LDAIM &7A LDXIM :LSB: ARGcon LDYIM :MSB: ARGcon Jsr osword anyrts SEC rts ; word LDXIM 4 ; *** Tim *** This routine has been changed a lot LDAIM 0 ; | to cope with tube addresses fooo ; | STAAX ARGcon ; | Clear answer to zero DEX ; | BNE fooo ; | LdaIY zp0 ; | CmpIM "." Beq skspcs CmpIM 32 Bne bad1 skspcs iny ; LdxIM 3 ; *** Tim *** X now set elsewhere LdaIY zp0 cmpIM 32 Beq skspcs LDXIM 0 ; *** Tim *** dgain ; | LDAIY zp0 ; | Read element of string sent CMPIM 13 ; | Search for end character BEQ endfnj ; | CMPIM 32 ; | BEQ badC ; | INX ; | INY ; | BNE dgain ; | (Always branch - we hope!) endfnj ; | CPXIM 3 ; | Only allow address greater than zero-page BCC badC ; | DEY ; | Point Y to last character in string LDXIM 0 ; | wizoz ; | INX ; | X is the offset of the number to be poked ; | into ARGcon CPXIM 6 ; | Only allow 8 numbers to be input BEQ badC ; | JSR vetget ; | Get value of next character BCS allfin ; | Branch if no more characters STAAX ARGcon ; | Save lower nibble in result JSR vetget ; | Get value of next character BCS allfin ; | ASLA ; | Shift to higher nibble ASLA ; | ASLA ; | ASLA ; | ORAAX ARGcon ; | Combine with lower nibble STAAX ARGcon ; | JMP wizoz ; | - and do it all again allfin ; | RTS ; | ; *** Tim *** byte ; BODGE JMP badC ; ; *** Tim *** Vetget is now different - copes with ; | errors and returns carry set if last ; | character reached. ; | vetget ; | LDAIY zp0 ; | Read next character CMPIM "." ; | Have we finished? BEQ sendst ; | CMPIM 32 ; | Space means we have finished as well BNE tendst ; | sendst ; | SEC ; | We have finished so exit with carry set RTS ; | tendst ; | DEY ; | Decrement Y for next time SEC ; | SBCIM "0" ; | Check for valid character BMI byte ; | CMPIM 10 ; | BCC rts99 ; | Exit SBCIM "A"-"0" ; | Adjust for hex BMI byte ; | CMPIM 6 ; | BCS zagain ; | ciai ; | ADCIM 10 ; | Add 10 for true hex meaning rts99 ; | CLC ; | Carry clear - not finished yet RTS ; | zagain ; | SBCIM 32 ; | Adjust for lower-case hex BMI byte ; | CMPIM 6 ; | BCS byte ; | BCC ciai ; *** Tim *** (Always branch) ; starca ;\\\\\\\\\\\\\\\\\\\\\\\\\\ * CAT JMP badCom startr JSR setFF ; High order addrs Jsr word LdaIM &8F Sta ARGcon JMP CallOS ; stardi Jsr word JSR stri02 = 22 = 7 = 0 dloop LDXIM :LSB: (ARGcon+1) ; *** Tim *** Changed for tube stuff LDYIM :MSB: (ARGcon+1) ; | LDAIM 0 ; | JSR poke ; | Read byte - tubed or otherwise CMPIM 0 ; *** Tim *** BNE notnul LDAIM " " notnul OraIM &80 Jsr oswrch LDAIM &86 JSR osbyte CpyIM 24 Beq nextrt Inc ARGcon+1 ; *** Tim *** Incrementing 4 byte address Bne dloop Inc ARGcon+2 ; *** Tim *** Bne dloop ; | INC ARGcon+3 ; | Bne dloop ; | INC ARGcon+4 ; | We've got a lot of RAM here ! JMP dloop ; *** Tim *** nextrt RTS ; ; ; ; ; ; ; ; ; ; ; ;Enters here to do a BRK instruction which must not happen ;in a sideways ROM. Uses page 1. dobrk PLA ; Lo byte of return addr STA zp0 PLA ; Hi byte STA zp1 LDAIM 0 TAY ; Offset-1 about to be INC'd (offset=1 because return addr-1 on stack) STA &100 ; Store a BRK dobrk1 INY LDAIY zp0 ; Get byte of message STAAY &100 ; Note that &100 has the BRK (Y=1 initially) BNE dobrk1 ; Terminates on zero JMP &100 ; Execute it ; ; ; ; dofscm ; OSFSCMD vector points here STA zp0 ;reason code PHA TXA PHA LDA zp0 CMPIM 8 ; Highest reasoncode we want, +1 BCC fscmd1 PLA TAX PLA RTS fscmd1 ASLA TAX LDAAX fscmdt STA zp0 LDAAX fscmdt+1 STA zp1 PLA TAX PLA JMI zp0 ; ; ; ; fshand ; return our range of handles LDXIM &0E ; lowest file handle LDYIM &0F ; highest RTS ; ; ; fseof CPXIM &0E BNE eof1 LDX eof0E RTS eof1 CPXIM &0F BNE eof2 LDX eof0F RTS eof2 JMP channe ; Cause CHANNEL error ; ; ; ; ; ; ; starcm ;Star command - set up & pass to our CLI PHA TXA PHA STA zp0 TYA PHA STA zp1 ; \\\\\\\\\\\\\\\\\\\\\ ARO-BUG??? LDXIM 0 ; All commands allowed in this context LDYIM 0 ; Original pointer needs no offset JSR cli BCS star1 badCom JSR dobrk = 254 ; This is correct error no. = "Bad command" BRK ; star1 JMP swexit ; ; ; starop CPXIM 0 BNE opt0 LdaIM 1 Sta CRCsig LdaIM 128 Jsr messag LdaIM 0 Jmp resetc opt0 CPXIM 1 BNE opt1 TYA Jsr messag ; Set RTF mess level Rts opt1 ; ******* OTHER *OPT's IN HERE ****** CPXIM 2 BNE opt2 TYA STA CRCsig Rts opt2 CPXIM 3 Bne opt3 TYA Jmp resetc opt3 JSR dobrk = &CB = "Bad option" BRK ; ; ; fsdie disab LDA oldctr ANDIM &F7 ; Share this code with other bit... STA ctrlre STA oldctr ;ALSO STOP DATA COMING IN (Bit 2) ANDIM 251 STA ctrlre ;********* SHOULD CLOSE >*SPOO * EXEC HERE ******** RTS enab Lda oldctr OraIM 8 Sta oldctr Sta ctrlre rts ; ; ; ; ; ; ; fscmdt & starop ; 0 - *OPT X,Y & fseof ; 1 - EOF#X from BASIC, via *FX & starru ; 2 - */ equivalent to *RUN & starcm ; 3 - * - decode command only, not *RUN ; since this is a slow, cassette-like filing system & starru ; 4 - *RUN & starca ; 5 - *CAT & fsdie ; 6 - file system vectors being removed & fshand ; 7 - return range of handles used by file system fscm00 ; ; ; ; ; ; ; ; ; Enters here to set the start address for subsequent ;data transfer. AddressAz passed in zp0p1 ****** Set up TUBE Here ****** ; initdm LDYIM 0 LDAIY zp0 STA dmazp0 INY LDAIY zp0 STA dmazp1 INY ; *** Tim *** Continue for 4 bytes LDAIY zp0 ; | STA dmazp2 ; | INY ; | LDAIY zp0 ; | STA dmazp3 ; *** Tim *** RTS ; ; ; ; ; sends a byte to the address, tubed or otherwise ; set up by initdm. ; Non tubed transfers use private z-page dmazp0, dmazp1 ; ; MustAX save A,Y ; prodby STA dmascr TYA PHA TXA ; *** Tim *** Save X as well PHA ; | LDXIM dmazp0 ; | Point X and Y to address LDYIM 0 ; | (Zero-page) LDA dmascr ; | Load A with byte to be poked STA TTEMP2 ; | LDAIM 1 ; | JSR poke ; *** Tim *** Poke byte - tubed or otherwise INC dmazp0 BNE prod00 ; If =0 then carry INC dmazp1 prod00 PLA ; *** TIM *** TAX ; *** TIM *** PLA TAY LDA dmascr RTS ; ; String print routine - terminates on a zero. No limit on ; message length. Message immediately follows JSR. ; stri02 PLA STA zp0 ; Return address -1 PLA STA zp1 LDYIM 1 ; Clears Z flag PHP DEY ; To 0 for use as offset string1 INC zp0 ; Point to next byte of string BNE stri00 ; If no carry INC zp1 stri00 PLP ; Z flag set if last char was null - cleared on entry BEQ stri01 LDAIY zp0 ; Get char (Y=0) PHP ; Save Z flag for testing after incrementing JSR oswrch JMP string1 ; stri01 JMI zp0 ; effective RTS ; ; LNK DEC9A