; ; ********************************************************************* ; ; The Command Subroutines for a Redefinable Telesoftware Decoder ; ; ; (C) C.J. Oswald 1982 ; -- rtf6 -- ; ; ********************************************************************* ; ; ; The code hereafter is not as elegant as it might be - this is due to ; time and space. ; ; The command subroutine ; ; Destroys all registers & temporary zero page locations ; txt INC ordern ; default mode for BASIC programs ; ; The command subroutine ; ; ORDERED blocks for BCPL, PASCAL etc. txo ; ; Set all lone names to decode to themselves ; AND-ed with &7F (except the lone names of the escape operator) ; LDYIM 0 ; start at 0 ; txt1 LDAAY lonety ; get type of meaning of that name CMPIM 1 ; decode to one byte? BNE txt4 ; (no - leave entry alone) TYA ; put name in A ANDIM &7F ; and with &7F STAAY lonelo ; put back in name table ; txt4 INY BNE txt1 ; Set lone names &E0, &FE to , ; and escaped names &E0, &FE to decode to themselves :AND: 7F LDXIM &FE ; BBC GOT IT WRONG... LDYIM &E0 ; (X,Y SHOULD BE SWAPPED) LDAIM &12 ; set lone names STAAX lonety STAAY lonety LDAIM :LSB: ulb STAAX lonelo LDAIM :MSB: ulb STAAX lonehi LDAIM :LSB: urb STAAY lonelo LDAIM :MSB: urb STAAY lonehi LDAIM 1 ; set escaped names STAAX esctyp STAAY esctyp LDAIM &7E ; ANOTHER BBC MUDDLE STAAX esclo LDAIM &60 STAAY esclo ; ; Set all 1st pass commands with escaped names to be 2nd pass commands ; LDYIM 0 ; txt5 LDAAY esctyp CMPIM &11 BNE txt6 LDAIM &12 STAAY esctyp ; txt6 INY BNE txt5 ; ; Set decoder to 7-bit mode ; INC sevenb ; ; Set escaped name &C2 (|B) and &42 (|F) to mark start of a teletext block ; LDYIM &C2 LDAIM &10 STAAY esctyp LDYIM &46 STAAY esctyp LDAIM :LSB: txtsb STAAY esclo LDYIM &C2 STAAY esclo LDAIM :MSB: txtsb STAAY eschi LDYIM &46 STAAY eschi ; teletext blocks dont have CRC any more. LDYIM &E3 LDAIM :LSB: debtxt STAAY esclo LDAIM :MSB: debtxt ;\\\\\\\\\\\ CJO Balls-up - was DIV &FF!!!! STAAY eschi ; ; Now mark the start of a teletext block ; ; Destroys all registers & temporary zero page locations ; txtsb JSR dsb ; call subroutine LDA pass ; block wanted? BEQ txtsb1 ; (no - resets pass to zero if block not wanted) LDAIM 2 ; otherwise set decoder to 2nd pass state STA pass ; (there is only one pass of teletext blocks) ; txtsb1 CLC ; ensure carry is clear RTS ; ; *********************************************************************** ; ; The command subroutine ; ; Destroys all registers & temporary zero page locations ; dsb LDAIM 1 ; set decoder to 1st pass state STA pass LDAIM 0 ; clear CRC STA crc STA crc+1 JSR opinfo ; get number of operans in A CMPIM 1 PHP ; save result of test BMI dsb6 ; no operans ; ; Deal with first operan (block number) ; LDAIM :LSB: thisbl ; copy thisbl's address to zero page STA ztempa LDAIM :MSB: thisbl STA ztempa+1 JSR dlocat ; decode block number and store at thisbl CPXIM 0 ; was length of field zero? BEQ dsb6 ; (yes - ie unnumbered block) ; LDX ordern ; given that this block is numbered, does the order ; that the blocks are received in matter? ; (it is assumed unnumbered blocks can be got in any order) BNE dsb6 ; (order does not matter) ; ; Order that blocks are received in does matter ; dsb12 LDA thisbl LSRA ; divide the no. of this block by 8 LSRA LSRA ; A now holds offset in bytes from base of blockg ; of the bit in blockg corresponding to this block TAY ; put offset in X, Y TAX ; dsb8 CPYIM 0 BEQ dsb7 DEY LDAAY blockg ; check all blocks much earlier are got CMPIM &FF BEQ dsb8 ; ; Not all earlier blocks are got ; dsb9 PLA ; balance stack JMP dsb4 ; block is not wanted ; ; All the blocks much earlier in the sequence are got - check most ; recent blocks in sequence ; dsb7 TXA ; put offset back in Y TAY LDA thisbl ANDIM 7 ; get 3 lsb's TAX LDAIM 0 CPXIM 0 ; fill up A with X bits (r.h. justified) BEQ dsb10 ; dsb11 SEC ROLA DEX BNE dsb11 ; dsb10 STA ztempl ; save A ANDAY blockg ; and with byte that holds the bit corresponding ; to this block - if result is same as value in ztempl ; then all earlier blocks have been got ; CMP ztempl ; all earlier blocks got? BNE dsb9 ; (no) ; ; All earlier blocks have been got or else order does not matter ; dsb6 LDA blocks ; is the number of this block to large? SEC SBC thisbl BCC dsb9 ; (yes - reject this block) PLP ; was there a 2nd operan? BEQ dsb1 ; (no) BMI dsb1 ; (no) ; ; deal with 2nd operan (no. of blocks in total) ; LDA blocks ; save old value of blocks (total number of blocks) STA oldblo LDAIM :LSB: blocks ; copy block's address to zero page STA ztempa LDAIM :MSB: blocks STA ztempa+1 JSR dlocat ; decode block number & store at blocks ; ; No operans or else operans have now been dealt with ; See if this block is wanted (check flag to see if it is already got) ; dsb1 LDA thisbl ; get the number of this block LSRA ; divide by 8 LSRA LSRA TAY ; offset in bytes from base of blockg of the bit wanted LDA thisbl ; get the number of this block again ANDIM 7 ; get the 3 lsb's TAX LDAIM 1 ; put one set bit in A CPXIM 0 ; shift that bit X times BEQ dsb2 ; dsb3 ASLA DEX BNE dsb3 ; dsb2 ANDAY blockg ; and with byte that holds the bit corresponding to block BNE dsb4 ; block is already got, therefore not wanted again ; ; Block is wanted - carry on ; LDAIM 1 ; set pass to 1 STA pass LDAIM starto ; mark start of block ; dsb5 JSR buffer ; call buffer controlling routines CLC ; ensure carry is clear RTS ; ; Block is not wanted - ask for a new one ; dsb4 LDA oldblo ; restore old value of blocks STA blocks LDAIM 0 ; set pass to zero STA pass LDA ordern BEQ dsb13 ; order matters (blocks are in a chain) LDAIM nextpa ; order doesn't matter - code for next head of chain block JMP dsb5 ; dsb13 LDAIM next02 ; ordered file - code for next block in chain JMP dsb5 ; load next page into buffer and return from subroutine ; ; *********************************************************************** ; LNK RTF7