dcdoffcount=&81 MC=&4000 timetaken=&80 : FOR C%=0 TO 3 STEP 3 P%=MC [ OPT C% : LDA #0 STA dcdoffcount STA timetaken : \ interrupts off SEI : \ set up; RS423, but motor off, so no charge yet LDA #&45 STA &FE10 JSR aciareset JSR delayby \ wait : \ start the motor; begin charging and wait a short while LDA #&C5 STA &FE10 JSR delayby : \ now switch to tape; continue charging LDA #&85 STA &FE10 JSR awaitdcdon \ see how long DCD takes : \ clean up LDA #&0 \ back to tape mode STA &FE10 LDA #3 \ reset ACIA STA &FE08 LDA #&56 STA &FE08 CLI RTS : .awaitdcdon \ poll for pulse to show up LDY #0 .awaitdcd2 JSR delay LDA &FE08 \ check ACIA bit 2 for DCD pulse AND #4 BEQ nodcd2 \ if still zero then continue \ got it STY timetaken \ record wait for DCD \ clear the dcd latch condition LDA &FE08 LDA &FE09 JSR awaitdcdoff \ now wait for DCD off (or failure) RTS .nodcd2 INY BNE awaitdcd2 RTS : .awaitdcdoff \ poll for pulse to end LDY #0 .Lawaitdcdoff JSR delay LDA &FE08 \ check ACIA bit 2 for DCD pulse AND #4 BNE nodcdoff \ if still high then go again \ got it INC dcdoffcount RTS .nodcdoff DEY BNE Lawaitdcdoff RTS : .delayby TXA PHA LDX #10 \ about 50 us .lpdelayby JSR delay DEX BNE lpdelayby PLA TAX RTS : .delay TXA PHA LDX #0 .lpdelay NOP:NOP:NOP:NOP:NOP:NOP:NOP:NOP NOP:NOP:NOP:NOP:NOP:NOP:NOP:NOP DEX BNE lpdelay PLA TAX RTS : .aciareset LDA #3 STA &FE08 LDA #&95 STA &FE08 RTS ] NEXT C% : CALL MC PROCresults("45, C5, 85") : END : DEF PROCresults(A$) P.'A$ P." DCDs: ";?dcdoffcount P." time taken: ";?timetaken ENDPROC