Classic Computer Magazine Archive PROGRAM LISTING: 85-11/CODEWRIT.M65


10 ;CODEWRITER III
20 ;BY STEVE STUNTZ
30 ;(c) 1985, ANTIC PUBLISHING
40 ;
50       *=  $8000
55 START
60 MEM   =   $B0
70 VTBASE =  $E400
80 SETVBV =  $E45C
90 PACTL =   $D302
0100 PORTA = $D300
0110 AUDC1 = $D201
0120 CH  =   $02FC
0130 CDTMA1 = $0226
0140 ROWCRS = $54
0150 COLCRS = $55
0160 VDSLST = $0200
0170 NMIEN = $D40E
0180 SDLSTL = $0230
0185 ATRACT = $4D
0190 MEMINT = $B4
0200 MEMRX = $B2
0210     JSR HEAD1
0220     LDA #$38
0230     STA PACTL
0240     LDA #$01
0250     STA PORTA
0260     LDA #$3C
0270     STA PACTL
0280     LDA #$01
0290     STA PORTA
0300     LDA SDLSTL
0310     STA MEMINT
0320     LDA SDLSTL+1
0330     STA MEMINT+1
0340     LDA #$82
0350     LDY #12
0360     STA (MEMINT),Y
0370     LDY #28
0380     STA (MEMINT),Y
0390     LDA #RXLOOP&255
0400     STA VDSLST
0410     LDA #RXLOOP/256
0420     STA VDSLST+1
0430     LDA #$FF
0440     STA POINTRI
0450     STA POINTRO
0460     LDA #$20
0470     STA CWSPC
0480     LDA #$40
0490     STA CWMAX
0500     LDA #$0F
0510     STA CWAVG
0520     LDA #$00
0530     STA I23X37
0540     STA HILO
0550     STA NBITS
0560     STA RXCW
0570     STA IAMREDI
0580     STA CTAVG
0590     STA CWTOT
0600     STA CWTOT+1
0610     LDA #2
0620     STA PREVHILO
0630     LDA MRX
0640     STA MEMRX
0650     LDA MRX+1
0660     STA MEMRX+1
0670     LDA #$C0
0680     STA NMIEN
0690 ;
0700 ;SEARCH FOR KEYBOARD CHARACTER
0710 LP1 JSR RXCH
0720     JMP LP1
0730 ;
0740 ; DEVICE HANDLER
0750 GOVEC CPX #6
0760     BNE GOV1
0770     LDY ROWCRS
0780     CPY #23
0790     BNE GOV1
0800     LDY COLCRS
0810     CPY #39
0820     BNE GOV1
0830     LDY #1
0840     STY I23X37
0850 GOV1 TAY 
0860     LDA VTBASE+1,X
0870     PHA 
0880     LDA VTBASE,X
0890     PHA 
0900     TYA 
0910     RTS 
0920 ;
0930 ; SCROLL
0940 SCROLL LDY I23X37
0950     CPY #1
0960     BNE SCROL1
0970     JSR HEAD3
0980     LDY #0
0990     STY I23X37
1000 SCROL1 RTS 
1010 ;
1020 ; RX WORD WRAP
1030 RXWRA LDY COLCRS
1040     CPY #34
1050     BCC RXWR9
1060     CPY #39
1070     BEQ RXWR9
1080 RXWR1 LDA #$A0
1090     JSR RXPNT
1100     LDY COLCRS
1110     CPY #39
1120     BNE RXWR1
1130 RXWR9 RTS 
1140 ;
1150 ;SET PIN1 AND SOUND
1160 ONOFF CMP #$02
1170     BNE OFF
1180     LDY #$00
1190     STY PORTA   SET PIN1 LOW
1200     LDY #$2F
1210     STY AUDC1   TURN SOUND ON
1220     JMP ONOF1
1230 OFF LDY #$01
1240     STY PORTA   SET PIN1 HIGH
1250     LDY #$00
1260     STY AUDC1   TURN SOUND OFF
1270 ONOF1 RTS 
1280 ;
1290 ;HEADING
1300 HEAD LDY #$00
1310     STY COPYI
1320 CR1 LDA COPYR,Y
1330     LDX #6
1340     JSR GOVEC
1350     INC COPYI
1360     LDY COPYI
1370     CPY #38
1380     BNE CR1
1390     RTS 
1400 ;
1410 ;SET CURSOR AT 0,0
1420 HEAD00 LDA ROWCRS
1430     STA ROW
1440     LDA COLCRS
1450     STA COL
1460     LDA #$00
1470     STA ROWCRS
1480     LDA #$02
1490     STA COLCRS
1500     RTS 
1510 ;
1520 ;SET CURSOR AT ORIGINAL POSITION
1530 HEADORG LDA ROW
1540     STA ROWCRS
1550     LDA COL
1560     STA COLCRS
1570     LDA #$1E
1580     LDX #6
1590     JSR GOVEC
1600     LDA #$1F
1610     LDX #6
1620     JSR GOVEC
1630     RTS 
1640 ;
1650 ;KEYBOARD HEADING
1660 HEAD1 JSR HEADCLR
1670     JSR HEAD
1680     RTS 
1690 ;
1700 ;CHANGE SPEED HEADING
1710 HEAD3 JSR HEAD00
1720     JSR HEAD
1730     JSR HEADORG
1740     RTS 
1750 ;
1760 ;
1770 HEADCLR LDA #$7D
1780     LDX #6
1790     JSR GOVEC
1800     RTS 
1810 ;
1820 ; RX INTERRUPT LOOP
1830 RXLOOP = *
1840     PHA 
1850     TYA 
1860     PHA 
1870     JSR CWCOUNT
1872     LDA #0
1874     STA ATRACT
1880     LDA PORTA
1890     AND #$02
1900     CMP PREVHILO
1910     BNE RI1
1920     JMP RI2
1930 RI1 JSR CHANGE
1940 RI2 PLA 
1950     TAY 
1960     PLA 
1970     RTI 
1980 ;
1990 ; RX CW COUNT BY 1
2000 CWCOUNT LDY POINTRI
2010     LDA (MEMRX),Y
2020     CMP CWMAX
2030     BEQ RC1
2040     CLC 
2050     ADC #$01
2060     STA (MEMRX),Y
2070 RC1 RTS 
2080 ;
2090 ; DETECT CW CHANGE
2100 CHANGE INC POINTRI
2110     LDA PREVHILO
2120     JSR ONOFF
2130     EOR #$02
2140     STA PREVHILO
2150     LDY POINTRI
2160     LDA #0
2170     STA (MEMRX),Y
2180     RTS 
2190 ;
2200 ;
2210 ; RX CHARACTER FROM PIN 2
2220 RXCH JSR READY
2230     LDA IAMREDI
2240     CMP #1
2250     BNE RX02
2260     INC POINTRO
2270     JSR COUNTAVG
2280     LDA #1
2290     EOR HILO
2300     STA HILO
2310     CMP #1
2320     BNE RX01
2330     JSR SHIFT
2340     JMP RX02
2350 RX01 JSR FINDCH
2360 RX02 RTS 
2370 ;
2380 ; SHIFT ROR BUILD NBITS
2390 SHIFT LDA NBITS
2400     CMP #7
2410     BEQ SHIFT9
2420     INC NBITS
2430     LDY POINTRO
2440     LDA (MEMRX),Y
2450     CMP CWAVG
2460     BCC SHIFT1
2470     SEC         ;DASH
2480     JMP SHIFT2
2490 SHIFT1 CLC      ;DOT
2500 SHIFT2 ROR RXCW
2510 SHIFT9 RTS 
2520 ;
2530 ; READY TO READ COUNT
2540 READY LDX POINTRO
2550     CPX POINTRI
2560     BEQ READY1
2570     INX 
2580     CPX POINTRI
2590     BNE READY2
2600     LDY POINTRI
2610     LDA (MEMRX),Y
2620     CMP CWMAX
2630     BEQ READY2
2640 READY1 LDA #0
2650     JMP READY3
2660 READY2 LDA #1
2670 READY3 STA IAMREDI
2680     RTS 
2690 ;
2700 ; FIND CW CHARACTER
2710 FINDCH LDY POINTRO
2720     LDA (MEMRX),Y
2730     CMP CWAVG
2740     BCC FIND09
2750     JSR FINISHCH
2760     JSR LOOKASCI
2770     LDY POINTRO
2780     LDA (MEMRX),Y
2790     CMP CWSPC
2800     BCC FIND09
2810     JSR RXWRA
2820     LDA #$A0
2830     JSR RXPNT
2840 FIND09 RTS 
2850 ;
2860 ; PRINT RECEIVED DATA
2870 RXPNT LDX #6
2880     JSR GOVEC
2890     JSR SCROLL
2900 RXPN1 RTS 
2910 ;
2920 ; FINISH RXC2 CHARACTER
2930 FINISHCH SEC 
2940     ROR RXCW
2950     INC NBITS
2960 FINISH1 LDA NBITS
2970     CMP #8
2980     BCS FINISH9
2990     CLC 
3000     ROR RXCW
3010     INC NBITS
3020     JMP FINISH1
3030 FINISH9 LDA #0
3040     STA NBITS
3050     RTS 
3060 ;
3070 ; LOOKUP AND PRINT CHARACTER
3080 LOOKASCI LDX #40
3090 LOOK1 LDA CWCHA,X
3100     CMP RXCW
3110     BEQ LOOK3
3120     INX 
3130     CPX #91
3140     BEQ LOOK2
3150     JMP LOOK1
3160 LOOK2 LDA #63
3170     JMP LOOK4
3180 LOOK3 TXA 
3190 LOOK4 EOR #$80
3200     JSR RXPNT
3210     RTS 
3220 ;
3230 ; COUNT FOR AVERAGE
3240 COUNTAVG LDX CTAVG
3250     INX 
3260     CPX #16
3270     BEQ COUNTA1
3280     INC CTAVG
3290     LDY POINTRO
3300     LDA (MEMRX),Y
3310     CLC 
3320     ADC CWTOT
3330     STA CWTOT
3340     LDA #0
3350     ADC CWTOT+1
3360     STA CWTOT+1
3370     JMP COUNTA2
3380 COUNTA1 JSR CALCAVG
3390 COUNTA2 RTS 
3400 ;
3410 ; CALCULATE AVERAGE
3420 CALCAVG CLC 
3430     ROR CWTOT+1
3440     ROR CWTOT
3450     CLC 
3460     ROR CWTOT+1
3470     ROR CWTOT
3480     LDA CWTOT
3490     STA CWMAX
3500     CLC 
3510     ROR CWTOT
3520     LDA CWTOT
3530     STA CWSPC
3540     CLC 
3550     ROR CWTOT
3560     LDA CWTOT
3570     STA CWAVG
3580     CLC 
3590     ROR CWTOT
3600     LDA CWTOT
3610     CLC 
3620     ADC CWSPC
3630     STA CWSPC
3640     LDA #0
3650     STA CWTOT
3660     STA CWTOT+1
3670     STA CTAVG
3680     RTS 
3690 ;
3700 ;ROM DATA
3710 COPYR
3720     .BYTE "  Codewriter III      BY STEVE STUNTZ "
3730 MRX .WORD MEMRX1
3740 CWCHA
3750     .BYTE 0,0,0,0,0,0,0,0
3760     .BYTE 0,0,0,0,0,0,0,0
3770     .BYTE 0,0,0,0,0,0,0,0
3780     .BYTE 0,0,0,0,0,0,0,0
3790     .BYTE $FE,$00
3800     .BYTE $00,$00,$00,$00,$00,$00
3810     .BYTE $6D,$6D,$22,$2A,$73,$68
3820     .BYTE $6A,$29,$3F,$3E,$3C,$38
3830     .BYTE $30,$20,$21,$23,$27,$2F
3840     .BYTE $47,$55,$FF,$31,$FF,$4C
3850     .BYTE $00,$06,$11,$15,$09,$02
3860     .BYTE $14,$0B,$10,$04,$1E,$0D
3870     .BYTE $12,$07,$05,$0F,$16,$1B
3880     .BYTE $0A,$08,$03,$0C,$18,$0E
3890     .BYTE $19,$1D,$13
3900     *=  CWCHA+$0100
3910 ;
3920 PND =   *       ; END OF BOOT FILE
3930 ;*=$1000
3940 COPYI *= *+1
3950 ROW *=  *+1
3960 COL *=  *+1
3970 MEMRX1 = *
3980     *=  *+$0100
3990 POINTRI *= *+1
4000 POINTRO *= *+1
4010 CWMAX *= *+1
4020 CWSPC *= *+1
4030 CWAVG *= *+1
4040 PREVHILO *= *+1
4050 HILO *= *+1
4060 NBITS *= *+1
4070 RXCW *= *+1
4080 IAMREDI *= *+1
4090 CTAVG *= *+1
4100 CWTOT *= *+2
4110 I23X37 *= *+1
4120 RXINDX *= *+1
4122     *=  $02E0
4124     .WORD START
4130     .END 

Back to previous page