 .OPT NO LIST›;  SAVE #D1:CASSETTE.M65›;›;›;  LOAD #D1:PRINTER.M65›;› .PAGE "Cassette Handler"›;  *= $FCD8›  LIST  › .LOCAL ›; Most comments from 800 source›;›CIN› JMP CLICK   Cassette init›;›;›INITCAS› LDA #$CC    routine› STA CBAUDL  followed by› LDA #5      cassette i/o› STA CBAUDH  routines›;›SPECIAL.C› RTS ›;›;›OPEN.C› LDA ICAX2Z› STA FTYPE› LDA ICAX1Z› AND #$0C› CMP #4› BEQ DOCOPENI› CMP #8› BEQ DOCOPENO› RTS         If already open leave status at 132›;›DOCOPENI› LDA #0› STA WMODE   Set read mode› STA FEOF    No eof yet› LDA #1      Tone for press play› JSR ?BEEP› BMI ?OPNRTN If err during beep›;›MOTORON› LDA #$34    Turn motor on› STA PACTL› LDX PALNTS› LDY ?65171,X Set leader time› LDA ?65169,X› TAX › LDA #3› STA CDTMF3› JSR SETVBV  Set vblank timer›;›?WAITTM› LDA CDTMF3› BNE ?WAITTM Wait for motor to come up to speed› LDA #$80    Number bytes in buffer› STA BPTR› STA BLIM› JMP ?OPOK›;›?PBRK› LDY #$80    Break abort› DEC BRKKEY  Reset key›;›?OPNRTN› LDA #0      Clear write mode flag› STA WMODE› RTS ›;›DOCOPENO› LDA #$80› STA WMODE   set write mode› LDA #2      Record tone› JSR ?BEEP› BMI ?OPNRTN Error in beep› LDA #$CC    Set baud rate› STA AUDF3› LDA #5› STA AUDF4› LDA #$60› STA DDEVIC› JSR SENDEV  Tell pokey to write marks› LDA #$34    Write 5" blank tape› STA PACTL› LDX PALNTS› LDY ?65167,X Times for leader› LDA ?65165,X› TAX › LDA #3› JSR SETVBV› LDA #$FF› STA CDTMF3›;›?WDLR› LDA BRKKEY› BEQ ?PBRK   If break during leader› LDA CDTMF3› BNE ?WDLR› LDA #0      Init buffer pointer› STA BPTR›;›?OPOK› LDY #1› RTS ›;›GET.C› LDA FEOF    If eof› BMI ?ISEOF  return status› LDX BPTR    Buffer pointer› CPX BLIM    If end of buffer› BEQ CREADBLK read another block› LDA CASBUF+3,X Get next byte› INC BPTR    bump pointer› LDY #1      status ok›;›?GBX› RTS ›;›;›CREADBLK› LDA #'R› JSR ?SIOSB› TYA › BMI ?GBX    exit on err› LDA #0      Reset pointer› STA BPTR› LDX #$80    Default bytes› LDA CASBUF+2› CMP #$FE    If header› BEQ ?ATEOF  go read again› CMP #$FA    If last data record› BNE ?NLR› LDX CASBUF+130 Last record get # bytes›;›?NLR› STX BLIM› JMP GET.C   Get next byte›;›?ATEOF› DEC FEOF    Set flag›;›?ISEOF› LDY #136    End of file› RTS ›;›PUT.C› LDX BPTR    Pointer› STA CASBUF+3,X store character› INC BPTR    Bump index› LDY #1      Status ok› CPX #127    If buffer full› BEQ ?WRTBF  go write it› RTS ›?WRTBF   LDA #$FC    Record type=data› JSR ?WSIOSB› LDA #0      Reset pointer› STA BPTR› RTS ›;›STATUS.C› LDY #1› RTS ›;›CLOSE.C› LDA WMODE   If writing› BMI ?CLWRT  go close for write› LDY #1      Success›;›?FCAX› LDA #$3C    Stop motor in› STA PACTL   case short irg mode› RTS ›;›?CLWRT› LDX BPTR    If no data› BEQ ?WTLR   no dt1 rec› STX CASBUF+130 Write to› LDA #$FA    last record record type› JSR ?WSIOSB Write out buffer› BMI ?FCAX   go if error›;›?WTLR› LDX #127› LDA #0      Clear buffer›;›?ZTBUF› STA CASBUF+3,X› DEX › BPL ?ZTBUF› LDA #$FE    Write wot record› JSR ?WSIOSB› JMP ?FCAX   Flag closed and exit›;›?BEEP› STA FREQ›;›?BEEP1› LDA RTCLOK+2› CLC › LDX PALNTS› ADC ?65173,X› TAX ›;›?WFL› LDA #$FF› STA CONSOL  Beep on› LDA #0› LDY #$F0›;›?BWAIT› DEY › BNE ?BWAIT› STA CONSOL  Beep off› LDY #$F0›;›?BWAIT2› DEY › BNE ?BWAIT2› CPX RTCLOK+2 One " yet?› BNE ?WFL    no› DEC FREQ    Count beeps› BEQ ?WFAK   til done› TXA › CLC › LDX PALNTS› ADC ?65175,X› TAX ›;›?BWAIT3› CPX RTCLOK+2› BNE ?BWAIT3› BEQ ?BEEP1›;›?WFAK› JSR ?WFAK1› TYA         Wait for a key› RTS ›;›?WFAK1› LDA KEYBDV+5› PHA › LDA KEYBDV+4› PHA › RTS ›;›?SIOSB› STA DCOMND› LDA #0› STA DBYTHI› LDA #131› STA DBYTLO› LDA # >CASBUF› STA DBUFHI› LDA # <CASBUF› STA DBUFLO› LDA #$60› STA DDEVIC› LDA #0› STA DUNIT› LDA #35› STA DTIMLO› LDA DCOMND› LDY #$40› CMP #'R› BEQ ?SETSTA› LDY #$80›;›?SETSTA› STY DSTATS› LDA FTYPE› STA DAUX2   Indicate irg mode› JSR SIOV› RTS ›;›?WSIOSB› STA CASBUF+2 Store type› LDA #$55› STA CASBUF› STA CASBUF+1› LDA #'W› JSR ?SIOSB› RTS ›;›?65165› .BYTE 4,3   NTSC/PAL›;›?65167› .BYTE 128,192 Values›;›?65169› .BYTE 2,1   for beep›;›?65171› .BYTE 64,224 and›;›?65173› .BYTE 30,25 leader›;›?65175› .BYTE 10,8›