; ; ********************************************************************* ; ; The I/O section of a Redefinable Telesoftware Decoder ; ; ; (C) C.J. Oswald 1982 ; -- rtf5 -- ; ; ********************************************************************* ; ; ; ; The decode telesoftware channel (OSBGET with Y=thehan) ; ; On entry, ; Y=thehan (handle) ; ; On exit, ; C=0 indicates a successful acquisition of a decode byte ; of telesoftware (passed in A) ; C=1 indicates some sort of EOF condition ; with A containing the reason code ; A=&FE the whole file has now been loaded or else no file is open ; A=1 the end of a section of a disordered file has ; been reached; a new commen is available ; A=2 ditto; no commen is available ; A=&1B Escape pressed ; ; X,Y and temporary zero page locations are preserved ; gettel LDA title ; check file is open (!) BNE gtb7 ; (yes) LDA title+1 BEQ gtb8 ; (no) ; gtb7 LDA disord ; is the file disordered? BEQ gtb1 ; (no) LDA endofs ; has an end of section been reached? BEQ gtb1 ; (no) ; ; end of section of disordered file has been reached ; LDAIM 0 STA endofs ; clear end of section flag LDA bytepe ; collect pending byte (1st one in new section) PHA ; save byte JMP gtb3 ; ; file is ordered or in middle of section ; gtb1 ;LDAIM 0 ; (A already holds zero) STA commen ; clear old commen STA commen+1 ; fromge JSR decode ; get a decode byte of telesoftware BCS gtb2 ; end of file reached PHA ; save byte LDA disord ; if disordered file & end of section then take action BEQ gtb3 ; (not the case) LDA endofs BNE gtb4 ; ; Successful acquisition of decode byte ; gtb3 INC reloca ; increment relocatable location pointer BNE gtb6 INC reloca+1 BNE gtb6 INC reloca+2 BNE gtb6 INC reloca+3 ; gtb6 PLA ; restore byte CLC ; encure carry is clear RTS ; ; End of section of disordered file ; gtb4 PLA ; restore byte STA bytepe ; save it for time being (until next call of gettel) LDA commen ; new commen available? BNE gtb5 ; (yes) LDA commen+1 BNE gtb5 ; (yes) ; ; End of section due to load address being altered ; LDAIM 2 ; set A=2, C=1 SEC RTS ; ; End of section due to new commen ; gtb5 LDAIM 1 ; set A=1, C=1 SEC RTS ; ; End of file has been reached ; gtb2 JSR loadme LDAIM 0 STA title STA title+1 ; gtb8 LDAIM &FE ; set A=&FE, C=1 and close file SEC RTS loadme Lda commle Bpl loadrt JSR stri02 = 13 = 10 = 7 = "Loaded." = 13 = 10 = "Press RETURN to continue" = 0 LdaIM 0 Sta bufflo+1 Sta bufflo+2 LdaIM &92 Jsr buffer ; loadrt RTS ; ; File has not been opened! ; ; *********************************************************************** ; ; Two subroutines to set the level of messages decode and the choice ; over resetting the decoder between files respectively ; (*OPT1,xx and *OPT4,yy) ; messag STA commle RTS ; resetc STA norese RTS ; ; *********************************************************************** ; ; A subroutine to open an ordered file (OSFILE open00) ; ; On entry, ; A=open00 ; XY points to the name of the file to be opened (X=lsb, Y=msb) ; ; On exit, ; A=&thehan (handle) ; ; Destroys X,Y and temporary zero page locations ; openor CMPIM 0 BNE openok RTS ; openok JSR open1 ; reset decoder & load next page into buffer JSR open4 ; copy filename to top of heap LDAIM thehan ; handle LDYIM 0 ; OPENED OK!! RTS ; ; A subroutine to open a disordered telesoftware file (OSFILE 7) ; ; On entry, ; A=openfi ; XY points to a control block ; XY+0 to XY+1 points to the title of the file ; XY+2 to XY+5 is the forced load address (if there is one) ; XY+6=0 if there is a forced load address ; ; On exit, ; A=thehan (handle) ; ; Destroys X,Y and temporary zero page locations ; opendi JSR open1 ; reset decoder & load next page into buffer STX ztempa ; store XY at ztempa STY ztempa+1 LDYIM 6 LDAIY ztempa ; see if there is a forced load address BNE open7 ; (no) ; open8 DEY ; copy load address to memory LDAIY ztempa STAAY memory-2 CPYIM 2 BNE open8 INC igno00 ; set igno00 flag (ie ignore commands) ; open7 INC disord ; set disordered file flag INC ordern ; blocks can be received out of order (!) LDYIM 0 LDAIY ztempa ; get lsb of pointer to title of file TAX INY LDAIY ztempa ; get msb of pointer TAY JSR open4 ; copy filename to top of heap LDAIM thehan ; handle RTS ; ; Reset decoder & load next page into buffer ; open1 TYA ; save X,Y PHA TXA PHA LDA norese ; soft reset of decoder only? BNE open2 ; (yes) JSR inital ; full reset of decoder JMP open3 ; open2 JSR softin ; soft reset of decoder ; open3 LDAIM next01 ; code to load next page into buffer JSR buffer ; call input buffer control routines PLA ; restore X,Y TAX PLA TAY RTS ; ; Copy filename pointed to by XY to the top of the heap ; open4 STX ztempa ; store XY at ztempa STY ztempa+1 LDYIM 0 LDXIM 0 ; open5 LDAIY ztempa ; copy filename CMPIM """" BEQ open11 INX PHA ; temporarily store on stack (needed due to shortage ; of zero page locations) open11 INY CMPIM &0D ; end of filename? BNE open5 TXA ; A holds amount heapfr needs incrementing by TAY LDX heapfr ; get old value of heapfr STX ztempa STX title ; store pointer to title of file at title LDX heapfr+1 STX ztempa+1 STX title+1 CLC ADC heapfr ; increment heapfr STA heapfr BCC open9 INC heapfr+1 ; open9 DEY ; Y now is offset of last char in file title ; open10 PLA ; copy filename from stack to heap STAIY ztempa DEY BPL open10 RTS ; ; *********************************************************************** ; ; A subroutine to pass the details of the current file ; (title, load address, execution address) (OSFILE addres) ; ; Note that in the case of a disordered file, the load ; address is for the next section of telesoftware and ; that the title is that as requested when the file was opened ; ; On entry, ; A=addres ; XY points to a control block ("CB") ; ; On exit, ; CB+0 to CB+1 points to title of file (string ending in &0D) ; CB+2 to CB+5 load address ; CB+6 to CB+9 execution address (if available) ; CB+&A=0 if execution address is available ; ; Preserves temporary zero page locations ; getadd TYA PHA TXA PHA JSR saveal PLA STA ztempa PLA STA ztempa+1 LDA memory ; store contents of memory plus reloca at calc00 CLC ADC reloca STA calc00 LDA memory+1 ADC reloca+1 STA calc00+1 LDA memory+2 ADC reloca+2 STA calc00+2 LDA memory+3 ADC reloca+3 STA calc00+3 LDYIM &A ; copy control block ; ga1 LDAAY title STAIY ztempa DEY BPL ga1 ; Now CB+0=title, CB+2=calc00, CB+6=execut, CB+&A=noexec ; JSR restor RTS ; ; *********************************************************************** ; ; A subroutine to pass surrounding information about the telesoftware ; (title, version, commen, code for next block, code for same block) ; ; On entry, ; A holds request for information ; A=0 File title & version ; A=1 Comment ; A=2 Code to get next block ; A=3 Code to get same block again ; &F0 to &F1 points to a control block ("CB") ; ; On exit, ; CB+0 to CB+1 points to the data (1st byte of it is its length) ; CB+0=CB+1=0 if the data is not available ; ; Preserves temporary zero page locations ; getinf CMPIM 1 ; what is request for? BCS reqtit ; title and version BEQ reqcom ; commen CMPIM 3 BCS reqnex ; next block code BEQ reqsam ; same block again code ; ; Illegal request - set CB+0=CB+1=0 ; LDYIM 0 ; loadAY A with zero TYA STAIY &F0 ; set CB+0=CB+1=0 INY STAIY &F0 RTS ; ; Request for title & version ; reqtit LDX tandv LDA tandv+1 JMP gin1 ; ; Request for commen ; reqcom LDX commen LDA commen+1 JMP gin1 ; ; Request for code to get next block ; reqnex LDX blockr LDA blockr+1 JMP gin1 ; ; Request for code to get same block again ; reqsam LDX bloc00 LDA bloc00+1 ; gin1 LDYIM 1 ; offset of one STAIY &F0 ; msb of pointer (was in A) TXA DEY ; offset of zero STAIY &F0 ; lsb of pointer (was in X) RTS ; ; ; *********************************************************************** ; LNK RTF6