; ; ************ DEC 6 AAAAAAAAAAA ************* ; Reclai ; Wipe all CBS except CB0. Must call appropriate ; OSWORD beforehand to copy CB holding data in ; private workspace into CB0. ; ; This will probably be called also in conjunction ; with OSWORD to swap contents of CB0 ith CBselect. ; In this case, it is entire page which must be copied too. LdyIM 0 LdxIM CBlen RecLoo Tya StaAX ctrlbl+inuse Txa Clc AdcIM CBlen Tax CpxIM (nopage*CBlen) Bne RecLoo LDA ctrlbl+specia AndIM TIM01 STA ctrlbl+specia ; Jmp swexit ; ; ; Jiggle ; Make CB0 point tp private workspace. ; DO NOT loose page contained within. Ldx &F4 LdaAX &DF0 AndIM 127 ; A = High addr of priv workspace Sta zp0 LdyIM 0 Lda ctrlbl+1 ; CB 0 Cmp zp0 beq gotosw Jig tya Clc AdcIM CBlen tay CpyIM (CBlen*nopage) beq gotosw LdaAY ctrlbl+1 Cmp zp0 Bne Jig ;\\\\\\\\\\\\ found CB0's slot. LdaAY ctrlbl PHA LdaAY ctrlbl+1 PHA Lda ctrlbl StaAY ctrlbl Lda ctrlbl+1 StaAY ctrlbl+1 PLA Sta ctrlbl+1 PLA Sta ctrlbl LDXIM 0 Jsr zapf00 ;Alternatively, don't zap - but copy page data ; across in its entirity. TYA TAX Jsr zapf00 gotosw Jmp swexit ; twl0 LdxIM 0 twl1 LsrAX ctrlbl+inuse txa Clc AdcIM CBlen tax CmpIM (nopage*CBlen) bne twl1 Jmp swexit ; trl0 LdxIM 0 trl1 AslAX ctrlbl+inuse txa Clc AdcIM CBlen tax CmpIM (nopage*CBlen) bne trl1 Jmp swexit ; ; ; ; ; ; ; If hammin error, or no TSDP present, useIM 00#### Tsdpin ; ; ; Lda TSbuff+1 ; Page 1s Tax Jsr hammin Bmi Hiccup Sta param+2 ; ; ; Lda TSbuff+2 ; Page 10s Tax Jsr hammin Bmi Hiccup Sta param+1 ; ; ; Lda TSbuff+3 ; Sub 1s Tax Jsr hammin Bmi Hiccup Sta param+6 ; ; ; ; Extract C4 Lda TSbuff+4 ; Sub 10s Tax Jsr hammin Bmi Hiccup Pha AndIM 7 Sta param+5 ; ; ; Pla LSRA LSRA LSRA Pha ; ; ; Lda TSbuff+5 ; Sub 100s Tax Jsr hammin Bmi Hicc00 Sta param+4 ; ; ; Lda TSbuff+6 ; Sub 1000s Tax Jsr hammin Bmi Hicc00 ; ExtractAC C65 Pha AndIM 3 Sta param+3 ; ; ; Pla LSRA AndIM 6 Sta zp0 ; Pla Ora zp0 AndIM 7 Sta param+0 ; JMP SelIIp Hicc00 PLA Hiccup LdaIM &FF Sta param+0 Sta param+3 Sta param+4 Sta param+5 Sta param+6 LdaIM 0 Sta param+1 Sta param+2 JMP SelIIp ; Swap00 ;########################### ;## ## ;## Swap CB 0 with ## ;## CB (CurCB) ## ;## ## ;########################### LdyIM 0 ; Mask 'in use' bit, ; while mucking about ; with control blocks. LdaAY ctrlbl+inuse Pha AndIM TIM01 StaAY ctrlbl+inuse ;DONT ALTERAY X LdaAY ctrlbl+incons RolA Bpl incon1 LdaAY ctrlbl+full AndIM TIM01 StaAY ctrlbl+full LdaAY ctrlbl+upda00 AndIM TIM01 StaAY ctrlbl+upda00 LdaAY ctrlbl+incons AndIM TIM01 StaAY ctrlbl+incons incon1 Ldx CurCB2 ; ; Ditto. ; LdaAX ctrlbl+inuse Pha AndIM TIM01 StaAX ctrlbl+inuse LdaAX ctrlbl+incons RolA Bpl incon2 LdaAX ctrlbl+full AndIM TIM01 StaAX ctrlbl+full LdaAX ctrlbl+upda00 AndIM TIM01 StaAX ctrlbl+upda00 LdaAX ctrlbl+incons AndIM TIM01 StaAX ctrlbl+incons incon2 SwapCB LdaAY ctrlbl Pha ; LdaAX ctrlbl StaAY ctrlbl ; Swap over ; entire CBs Pla StaAX ctrlbl Inx Iny ; Loop over ; all but last CpyIM inuse Bne SwapCB ; TXA PHA TYA PHA ; ASSUMES 'in use' byte is the last byte in the Control Block. LdyIM 0 SwPlug LdaAY ctrlbl+2 AndIM 127 StaAY ctrlbl+2 ; Clear old wild-cards LdaAY param Bpl SwNxt LdaIM &80 OraAY ctrlbl+2 StaAY ctrlbl+2 SwNxt Iny CpyIM 7 Bne SwPlug ; ; Swap done - so replace 'in use' ; bytes in each CB. ; if full and CRC ok then set upda00 bit ; (fix for selecting a page which matches ; but is TESTREADY tested...) Bit ctrlbl+full Bvc astiff Bit ctrlbl+crcok Bvc astiff Bit ctrlbl+crcpre Bvc astiff Lda ctrlbl+upda00 OraIM flagbi Sta ctrlbl+upda00 astiff ; PLA TAY PLA TAX Pla StaAY ctrlbl ; ; X and Y now point to 'in use'. ; Pla StaAX ctrlbl ; Plug in wild-card slots from 'param' ; ; Rts Fixpar ;################################ ;## ## ;## Vet the page number - ## ;## ascii to binary, ## ;## '#' to &FF ## ;## No errors returned? ## ;## ## ;################################ ; ; ; LdxIM 6 fix1 LdaAX param Bmi fixwil CmpIM "#" Beq fixwil ; <0, or '#' -> &FF CmpIM "A" ; This does the 'A' -> 10 conversion, ; with 'relaxed' checking to cope with ; lower case as well. Bcc fix2 SbcIM "A"-10 fix2 AndAX digitm ; Force page digit into correct range Bpl fix3 ; Always ; fixwil ; Wild cards LdaAX digitm ; Force page digit into correct range OraIM &80 fix3 ; & the rest (in A already) StaAX param Dex Bpl fix1 Rts ; ; ; ; DATA ; ; ; digitm = &7 = &F = &F = &3 = &F = &7 = &F ; pages in the range 7FF3F7F (8 mags, decimal page no's, ; and time-based subcode.) ; ; ; ; ; ; ;############################# ;## ## ;## Select page II ## ;## smart version to ## ;## find cached pages. ## ;## ## ;############################# ; ; ; initbg LdaIM pagehe+pageju+7 Sta curofs LdaIM 0 Sta currow STA select LdaIM 25 Sta eobrow LdaIM pagehe+pageju+40 Sta eobofs RTS ; copy parameter into local 'param'. zelect LdyIM 1 sel21 LdaIY &F0 StaAY param-1 Iny CpyIM 8 Bne sel21 ; SelIIp JSR initbg ; ; Now vet the parameter ; ; Jsr Fixpar ; ; LdxIM ((-CBlen) :AND: &FF) Stx CurCB2 ; ; FOR loop over all CB's ; sel2fo Lda CurCB2 Clc AdcIM 10 Sta CurCB2 CmpIM (CBlen*(nopage-1)) Bne sel2no ; ; All tested - set up CB 0. ***** IF Hermmaned, ; find a non-hermann page and swap into 0 ; If no non-hermann, set error code and return ; Error code to go in CB+0 - because other ; procedures call this routine locally Bit ctrlbl+specia Bvc nother LdyIM ((nopage-1)*CBlen) herm01 LdaAY ctrlbl+inuse ROLA Bpl hermes LdaAY ctrlbl+specia ROLA Bpl herm03 hermes Tya Sec SbcIM CBlen Tay Bne herm01 LdaIM 1 StaIY &F0 Jmp swexit herm03 Sty CurCB2 Jsr Swap00 nother LdxIM 0 Stx select ; ;PHP ;CLI ; ;Lda ctrlbl+hold ;OraIM flagbi ;Sta ctrlbl+hold ;.sel2delaylp ;Bit ctrlbl+incons ;Bvs sel2delaylp ;PLP ; Stx ctrlbl+inuse ; CB is invali while being written to sel2cr LdaAX param StaAX ctrlbl+2 Inx CpxIM 7 Bne sel2cr ; LdaIM flagbi Sta ctrlbl+inuse ; ; Now valid. Return. ; Jmp swexit ; ; sel2no ; try each CB in turn, comparing ; against 'param' to see if the page ; is already in store somewhere. ; If it is, swap the CB with CB 0. ; While 'holding' the target CB against ; update. LdyIM 0 Ldx CurCB2 LdaAX ctrlbl+inuse Sta zp0 Bit zp0 Bvc sel200 ; Only check active CBs sel2co LdaAY param Bmi sel2ok LdaAX ctrlbl+2 AndAY digitm ; Rub out control bits. CmpAY param Beq sel2ok sel200 Jmp sel2fo sel2ok Inx Iny CpyIM 7 Bne sel2co ; Jsr Swap00 Lda ctrlbl+hold AndIM TIM01 Sta ctrlbl+hold Jmp swexit ; ; ; ;################################### ;## ## ;## SELECT III ## ;## proper link selection ## ;## for terminal mode. ## ;## ## ;################################### Sele00 Jsr initbg Jsr Fixpar LdxIM 0 LDXIM ((-CBlen) :AND: &FF) ;\\\\\\\\\ TRY USING CB 0 FOR NOW Stx CurCB2 sel3fo Lda CurCB2 ; Don't look in CB0. Clc AdcIM CBlen Sta CurCB2 CmpIM ((nopage-1)*CBlen) ; Bne sel3no ; End of search - no page in buffers matches ; ; So find a non-hermann & in-use page - and set up new CB. ; also set 'select' to CB number. LdyIM ((nopage-1) * CBlen) herm02 LdaAY ctrlbl+inuse RolA Bpl herm00 ldaAY ctrlbl+specia RolA Bpl sel3ok herm00 Tya Sec SbcIM CBlen Tay CmpIM CBlen Bne herm02 LdyIM 0 LdaIM 1 StaIY &F0 jmp swexit ;\\\\\\\\\\\\\\ Error exit sel3ok Sty select LdaIM 0 StaAY ctrlbl+inuse LdxIM 0 sel3cr ldaAX param StaAY ctrlbl+2 Inx Iny CpxIM 7 Bne sel3cr LdaIM flagbi StaAY ctrlbl-7+inuse Jmp swexit ;\\\\\\ Exit when none match sel3no ; Look for matching LdyIM 0 Ldx CurCB2 LdaAX ctrlbl+inuse RolA Bpl sel300 sel3co LdaAY param Bmi sel301 LdaAX ctrlbl+2 AndAY digitm cmpAY param beq sel301 sel300 Jmp sel3fo sel301 Inx Iny CpyIM 7 Bne sel3co Lda CurCB2 Sta select ;\\\\\\\\ Exit when found in buffer TAX LDAAX ctrlbl+full ROLA BPL asti01 ;Bit ctrlbl+crcok ;Bvc asti01 LdaAX ctrlbl+upda00 OraIM flagbi StaAX ctrlbl+upda00 asti01 Jmp swexit ; LNK DEC6B