0001 ;;; 0002 ;;; Simple cassette data saver 0003 ;;; By: Daniel Tufvesson 2018 0004 ;;; 0005 0006 ;;; Monitor routines 0007 c000 mon_return: equ $c000 0008 c009 mon_pdata: equ $c009 0009 c01e mon_baddr: equ $c01e 0010 c021 mon_pcrlf: equ $c021 0011 7fe8 console_output: equ $7fe8 0012 7feb console_input: equ $7feB 0013 0002 page_register: equ $0002 0014 0015 ;;; Address of cassette interface 0016 8060 casport: equ $8060 0017 0018 ;;; Program begin here 0019 a100 org $a100 0020 a100 7e a1 3c jmp start 0021 a103 00 count: fcb 0 0022 a104 00 00 bega: fdb 0 0023 a106 00 00 enda: fdb 0 0024 a108 42 65 67 41 64 64 txt_ba: fcc "BegAddr: " 72 3a 20 0025 a111 04 fcb $04 0026 a112 45 6e 64 41 64 64 txt_ea: fcc "EndAddr: " 72 3a 20 0027 a11b 04 fcb $04 0028 a11c 53 74 61 72 74 20 txt_st: fcc "Start tape and press enter" 74 61 70 65 20 61 6e 64 20 70 72 65 73 73 20 65 6e 74 65 72 0029 a136 04 fcb $04 0030 a137 4f 4b txt_ok: fcc "OK" 0031 a139 0d 0a 04 fcb $0d,$0a,$04 0032 0033 a13c 86 f0 start: ldaa #$f0 0034 a13e 97 02 staa page_register 0035 ;; Ask for address 0036 a140 ce a1 08 ldx #txt_ba 0037 a143 bd c0 09 jsr mon_pdata 0038 a146 bd c0 1e jsr mon_baddr 0039 a149 ff a1 04 stx bega 0040 a14c bd c0 21 jsr mon_pcrlf 0041 ;; Ask for address 0042 a14f ce a1 12 ldx #txt_ea 0043 a152 bd c0 09 jsr mon_pdata 0044 a155 bd c0 1e jsr mon_baddr 0045 a158 ff a1 06 stx enda 0046 a15b bd c0 21 jsr mon_pcrlf 0047 ;; Start tape 0048 a15e ce a1 1c ldx #txt_st 0049 a161 bd c0 09 jsr mon_pdata 0050 a164 bd 7f eb jsr console_input 0051 a167 81 0d cmpa #$0d 0052 a169 26 20 bne exit 0053 a16b bd c0 21 jsr mon_pcrlf 0054 ;; Begin saving 0055 a16e bd a1 8e jsr sync 0056 a171 fe a1 04 ldx bega 0057 a174 a6 00 loop: ldaa ,x 0058 a176 bd a1 b5 jsr byte 0059 a179 08 inx 0060 a17a bc a1 06 cpx enda 0061 a17d 23 f5 bls loop 0062 a17f bd a1 8e jsr sync 0063 a182 7f 80 60 clr casport 0064 a185 ce a1 37 ldx #txt_ok 0065 a188 bd c0 09 jsr mon_pdata 0066 a18b 7e c0 00 exit: jmp mon_return 0067 0068 ;;; 0069 ;;; Send sync 0070 ;;; 2048 bits "1" 0071 ;;; 1 bit "0" 0072 ;;; 0073 a18e ce 08 00 sync: ldx #2048 0074 a191 c6 00 syncl: ldab #0 0075 a193 f7 80 60 stab casport 0076 a196 bd a1 f5 jsr dly0 0077 a199 c6 01 ldab #1 0078 a19b f7 80 60 stab casport 0079 a19e bd a1 fb jsr dly1 0080 a1a1 09 dex 0081 a1a2 26 ed bne syncl 0082 ;; Send end of sync bit 0083 a1a4 c6 00 ldab #0 0084 a1a6 f7 80 60 stab casport 0085 a1a9 bd a1 f5 jsr dly0 0086 a1ac c6 01 ldab #1 0087 a1ae f7 80 60 stab casport 0088 a1b1 bd a1 f5 jsr dly0 0089 a1b4 39 rts 0090 0091 ;;; 0092 ;;; Send one byte in A 0093 ;;; 0094 a1b5 c6 08 byte: ldab #8 0095 a1b7 f7 a1 03 stab count 0096 ;; Start bit - "0" 0097 a1ba c6 00 ldab #0 0098 a1bc f7 80 60 stab casport 0099 a1bf bd a1 f5 jsr dly0 0100 a1c2 c6 01 ldab #1 0101 a1c4 f7 80 60 stab casport 0102 a1c7 bd a1 f5 jsr dly0 0103 ;; Data bit 0104 a1ca 44 bloop: lsra 0105 a1cb 25 12 bcs byte1 0106 ;; Send zero 0107 a1cd c6 00 ldab #0 0108 a1cf f7 80 60 stab casport 0109 a1d2 bd a1 f5 jsr dly0 0110 a1d5 c6 01 ldab #1 0111 a1d7 f7 80 60 stab casport 0112 a1da bd a1 f5 jsr dly0 0113 a1dd 20 10 bra byte2 0114 ;; Send one 0115 a1df c6 00 byte1: ldab #0 0116 a1e1 f7 80 60 stab casport 0117 a1e4 bd a1 f5 jsr dly0 0118 a1e7 c6 01 ldab #1 0119 a1e9 f7 80 60 stab casport 0120 a1ec bd a1 fb jsr dly1 0121 ;; End of byte? 0122 a1ef 7a a1 03 byte2: dec count 0123 a1f2 26 d6 bne bloop 0124 a1f4 39 rts 0125 0126 ;;; 0127 ;;; Bit delays 0128 ;;; 0129 a1f5 c6 32 dly0: ldab #50 0130 a1f7 5a dly0l: decb 0131 a1f8 26 fd bne dly0l 0132 a1fa 39 rts 0133 a1fb c6 64 dly1: ldab #100 0134 a1fd 5a dly1l: decb 0135 a1fe 26 fd bne dly1l 0136 a200 39 rts Number of errors 0