; DEC 55555555555555555555555555555555555555555 ; bufman ; ; Test CRCpresent, CRCok, to see if page pending needs checked. ; Bit ctrlbl+inuse Bvc toendi Bit ctrlbl+full Bvc toendi Bit ctrlbl+crcok Bvs toendi Bit ctrlbl+crcpre Bvs toendi Bit ctrlbl+hold Bvc alabel toendi JMP endofi ; ; Check CRC for block 0 ; alabel LdaIM pagehe+pageju+7 Sta crcofs LdaIM 0 Sta crcrow ; Lda ctrlbl Sta intzp0 Lda ctrlbl+1 Sta intzp1 ; Check row 27 exists LdyIM 0 LdaIY intzp0 ; Max-rows (26 means no extra rows) CmpIM 27 Bcs toanot toenda Lda ctrlbl+crcok OraIM flagbi Sta ctrlbl+crcok Jmp endofi toanot ; ; maxbytes <= 26 means no room for extra rows with CRC data ; Iny LdaIY intzp0 Sec SbcIM (26+1) Pha ; A = nextfree - 26 - 1 ; ; ADDA1 2+26*48 to intzp0 ; Clc Lda intzp0 AdcIM :LSB: (pagehe+(40+pageju)*26) STA intzp0 LDA intzp1 ADCIM :MSB: (pagehe+(40+pageju)*26) Sta intzp1 Pla search ; A <0 when no lines left to examine CmpIM 0 Bmi toenda Pha LdyIM 0 LdaIY intzp0 CmpIM 27 Bne pullan LdyIM pageju LdaIY intzp0 Tay LdaAY hamtab Bmi pullan ; Hamming error AndIM &0F ; remove V flag Bne pullan ; DESIGNATION CODE 0 - CRC IN THIS PACKET LdyIM 39+pageju LdaIY intzp0 Sta correc Dey LdaIY intzp0 Sta correc+1 Pla Jmp crcwas pullan Pla Tay Dey Lda intzp0 Clc AdcIM (pageju+40) Sta intzp0 Lda intzp1 AdcIM 0 Sta intzp1 Tya Jmp search ; crcwas JSR linkgr Lda ctrlbl Sta intzp0 Lda ctrlbl+1 Sta intzp1 ; ;Init CRC counter to 0 Lda ctrlbl+crcpre OraIM flagbi Sta ctrlbl+crcpre LdaIM 0 Sta redcod Sta redcod+1 ; crccal Ldy crcofs Lda crcrow Bne crcn01 CpyIM pagehe+pageju+31 Bne crcnot LdyIM pagehe+pageju+39 Sty crcofs crcn01 crcnot Ldy crcofs Iny CpyIM pagehe+pageju+40 Bne crcn00 Clc AdcIM 1 Sta crcrow CmpIM 26 Beq crccom Lda intzp0 Clc AdcIM pageju+40 Sta intzp0 Lda intzp1 AdcIM 0 Sta intzp1 LdyIM pagehe+pageju+0 crcn00 Sty crcofs LdyIM pagehe ; Test missing rows LdaIY intzp0 CmpIM &FF Bne crcgra LdaIM 32 Jmp crcand crcgra Ldy crcofs LdaIY intzp0 ; CALCULATE CRC !!!!!!!!!!! crcand Jsr crcbit Jmp crccal crccom ; ; CRC calculated - set flags and return ; LdaIM 0 Ldy correc Cpy redcod Bne itfail Ldy correc+1 Cpy redcod+1 Bne itfail LdaIM flagbi itfail Ora ctrlbl+crcok Sta ctrlbl+crcok endofi STA status JSR enab JMP swexit ; DEC 55555555555555 ;****************************************************************** ; ; crcbit ; ; CRC routine ; ; On entry ; ; A contains data byte, ; redcod contains 16-bit ; cumulative value ; ; On exit ; ; A preserved ; X,Y lost ; ;.................................................................. ; crcbit Tay ; save data byte Lda redcod ; save CRC low byte Sta crclow ; Lda redcod+1 ; save high byte Sta crchig ; LdxIM 4 ; mult. redcod by 16 mult16 Asl redcod Rol redcod+1 Dex Bne mult16 ; Lda redcod+1 ; save high byte of result Sta redc01 ; LdxIM 3 ; mult. by 8 mult8 Asl redcod Rol redcod+1 Dex Bne mult8 ; Lda redcod+1 Sta redc00 ; LdxIM 2 ; mult. by 4 mult4 Asl redcod Rol redcod+1 Dex Bne mult4 ; gives redcod*512 ; Tya ; get original data byte Eor crchig Eor redc01 Eor redc00 Eor redcod+1 Sta crchig ; save intermediate result RolA ; get msb in carry LdaIM 0 RolA ; lsb = old msb Eor crchig Sta redcod ; final result to old low byte Lda crclow ; new high byte = old low byte Sta redcod+1 Tya ; restore original data byte ; Rts ; ; DEC 5555555555 ; LNK DEC5A