8-Bit Software Online Conversion
Digital Analysis - Listing
5A=0
10 DIM C% 400
20 *KEY10"OLD|M "
30 *FX12,25
40
50 VDU23,240,&FF,0,0,0,0,0,0,0
60 VDU23,241,&FF,0,&FF,&FF,&FF,&FF,0,
0
70 VDU23,242,0,0,0,0,0,0,0,&FF
80 VDU23,243,0,0,&FF,&FF,&FF,&FF,0,&F
F
100 MODE 7
110 *FX4,0
120 VDU23,1,1;0;0;0;0
130
140 PRINT" DIGITAL ANALYSER"
150 PRINT''" 1....USER PORT"
160 PRINT" 2....SIMULATION"
170 REPEAT
180 A$=GET$
190 UNTIL INSTR("12",A$)
200 IF A$="2" THEN GOTO 370
210
220
230 REM" USER PORT
240 MODE0:PROCinit
250 A%=0:B%=0:PROCgetdata
260 A=0
270 CALL &900
280 F=INT(1/((A%+B%)*9.0E-6))
282 PRINTTAB(1,29)"BIT 7| FREQUENCY=";
F;" HZ "
290 PRINTTAB(33,29)"LOW COUNT=";B%;"
"
300 PRINTTAB(53,29)"HIGH COUNT=";A%;"
"
320 REPEAT
330 PROCkeys
340 UNTIL FALSE
350
360
370 REM" DATA SIMULATOR
390 MODE 0:PROCinit
392 PROCdata
400 PRINTTAB(30,29)"SIMULATION"
410
450 REPEAT
460 PROCkeys
470 UNTIL FALSE
480
490 DEFPROCkeys
500 REPEAT
510 IF A=136 THEN ?&7C=?&7C-1
520 IF A=137 THEN ?&7C=?&7C+1
532 IF INSTR("Pp",CHR$(A))THENCALLD%
540 IF ?&7C<1 THEN ?&7C=1
550 IF ?&7C>70 THEN ?&7C=70
560 CALLC%
570 PROCbits
580 A=GET
590 UNTIL A=13
600 ENDPROC
610
620
630 DEFPROCbits
640 W=?((!&80+71)-?&7C)
650 PRINTTAB(1,3);
660 FOR P=7 TO 0 STEP -1
670 IF W AND 2^P THEN PRINT"1"; ELSE P
RINT"0";
680 NEXT
690 PRINTTAB(15,VPOS)"&";STR$÷(W)" ";
700 PRINTTAB(25,VPOS)STR$(W)" ";
710 IF W>31 AND W<127 THEN C$=CHR$(W)
ELSE C$=" "
720 PRINTTAB(35,VPOS)C$;
730 ENDPROC
740
750 DEFPROCdata
760 REM" read USER PORT
770 B%=?&FE60
780 REM" BIT MASK
790 B%=B% AND &0F
800 FOR Q=!&80 TO !&80+70
810 ?&78=(Q-!&80) MOD 32
820 PROClogic
830 ?Q=?&78
840 NEXT
850 ENDPROC
860
870 DEFPROClogic
880 E%=?&78 MOD 2
890 ?&78=?&78 DIV 2
900 A%=?&78 AND &0F
910 IF A%>B% THEN ?&78=?&78 OR &10
920 IF A%=B% THEN ?&78=?&78 OR &20
930 IF A%<B% THEN ?&78=?&78 OR &40
940 IF E% THEN ?&78=?&78 OR &80
950 ENDPROC
960
970 DEFPROCinit
980 IF ?C%<>&A9 THEN OSCLI("LOAD"+CHR$
(34)+"Dump"+CHR$(34)+" "+STR$÷(C%))
990 *FX4,1
1000 VDU23,1,0;0;0;0;0
1010 REM" C%= plot routine
1020 D%=C%+&6E:REM" print routine
1030 !&80=&D10
1040 ?&7C=70:REM" cursor position
1050 PRINTTAB(30,1)"DIGITAL ANALYSER"
1060 FOR S=6 TO 27 STEP 3
1070 PRINT TAB(1,S)"BIT ";(S-6)/3;"|";
1080 NEXT
1090 PRINTTAB(1,2)"76543210"
1100 ENDPROC
1110
1120 DEFPROCgetdata
1130 FOR I%=0 TO 2 STEP 2
1140 P%=&900
1150 [OPTI%
1160 ½" disable interupts and
1170 ½" set the data counter
1180 SEI:LDY #70
1190 .synclow
1200 BIT &FE60:BPL synclow
1210 .synchigh
1220 BIT &FE60:BMI synchigh
1230 .get
1270 ½" read the USER PORT and
1280 ½" store as it goes negative
1282 .loop1
1290 LDA &FE60:BPL loop1
1300 STA (&80),Y
1310
1340 ½" read the USER PORT and
1350 ½" store as it goes posative
1352 .loop2
1360 LDA &FE60:BMI loop2
1370 DEY:STA (&80),Y
1380 ½" decrement data counter
1390 DEY:BNE get
1391 ½" resync and get period counts
1392 .sync
1394 BIT &FE60:BPL sync
1400 .loop3
1410 ½" increment signal low counter
1420 INC &404:BNE ok1
1430 INC &405:BNE ok1
1440 INC &406:BNE ok1:INC &407
1450 .ok1
1452 LDA &FE60:BMI loop3
1460 .loop4
1470 ½" increment signal high counter
1480 INC &408:BNE ok2
1490 INC &409:BNE ok2
1500 INC &40A:BNE ok2:INC &40B
1510 .ok2
1512 LDA &FE60:BPL loop4
1520 ½" enable interupts before return
1530 CLI:RTS
1540 ]NEXT
1550 ENDPROC