10
20
30
40 :
50 MODE &83:top=HIMEM-&200:start=(TOP+&1000)AND&FFF00:HIMEM=start
60 PROCgo
70 END
80 DEFPROCassem
90 IFFNfx(0,1,0)<3 IntOff=&FE18:IntOn=&FE20:ADLC=&FEA0 ELSE IntOff=&FE38:IntOn=&FE3C:ADLC=&FEA0
100 IFINKEY-1:OSCLI"LOAD NetData "+STR$~start:ENDPROC
110 *FX143,12,255
120 X=?IntOff:?&D00=64
130 !&A6=start:!&A0=&1010
140 FOR P=0 TO 1
150 P%=&D00
160 [OPT P*2
170 BIT IntOff
180 PHA:TYA:PHA
190 LDY &A2
200 .lp1
210 LDA ADLC+1:STA (&A6),Y
220 INY
230 AND #&81:BNE L217C
240 LDA &A0:STA &A1
250 BNE L2187
260 .L217C
270 LDA ADLC+2
280 STA (&A6),Y
290 LDA &A1:BEQ L21AD
300 DEC &A1
310 .L2187
320 INY
330 BNE L2196
340 INC &A7
350 LDA &A7
360 CMP #top DIV 256
370 BNE L2196
380 LDA #start DIV 256
390 STA &A7
400 .L2196
410 STY &A2
420 .LD34
430 LDA #&65
440 STA ADLC+1
450 BIT ADLC+0
460 BMI lp1
470 LDA #0
480 STA (&A6),Y
490 PLA
500 TAY
510 PLA
520 BIT IntOn
530 RTI
540 .L21AD
550 DEY
560 JMP LD34
570 ]
580 NEXT
590 !start=0:ENDPROC
600 DEFFNfx(A%,X%,Y%):=((USR&FFF4)AND&FF00)DIV256
610 DEFFNh(A%,N%)=RIGHT$("0000000"+STR$~A%,N%)
620 DEFFNb:REPEATUNTIL?addr%<>0:st%=?addr%:by%=addr%?1:addr%=addr%+2:IF addr%>=top addr%=start
630 IF(st%AND4) f%=(f% AND 2)
640
650 =by%
660 DEFFNstn(A%,B%):=STRING$(3-LENSTR$A%," ")+STR$A%+"."+STR$B%+STRING$(3-LENSTR$B%," ")
670 DEFPROCgo
680 PRINT"Network Traffic Monitor and Decoder, (C)1990 J.G.Harston"'
690 PROCassem:DIM buf% 20
700 ON ERROR REPORT:IF INKEY-1 PRINT" at line ";ERL:END ELSE PRINT
710 X=?IntOff:addr%=start:!&A6=start:!&A0=&1010:f%=0:im%=3:X=?IntOn
720 IFINKEY-2:PROCraw:ENDPROC
730 REPEAT:REPEATb%=FNb:UNTIL(st%AND1):
740
750 buf%?0=b%:x%=1:REPEAT:b%=FNb:IF(st%AND&80):buf%?x%=b%:x%=x%+1
760 UNTILx%>18 OR (st%AND 126):IF(st%AND2):buf%?x%=FNb:x%=x%+1
770 IFx%=6 AND f%<2 PRINT
780 PRINTFNstn(buf%?3,buf%?2);" -> ";FNstn(buf%?1,buf%?0);" ";
790 IFx%=4 AND f%=1 PRINTSPC(24)"Scout ackn.":f%=2:UNTIL0
800 IFx%=4 AND f%=3 PRINTSPC(24)"Data ackn.":f%=0:UNTIL0
810 IFx%<6 PRINT"Abort":f%=0:UNTIL0
820 ctrl%=buf%?4:port%=buf%?5:IFctrl%<128:f%=2
830 IFf%=0 PRINT"Control: &";FNh(ctrl%,2);" Port: &";FNh(port%,2);" ";
840 IFbuf%?0=&FF AND buf%?1=&FF PROCbroad:f%=0:UNTIL0
850 IFx%=6 AND f%<2 PRINT"Scout":f%=1:UNTIL0
860 IFport%=0 AND f%=0:PROCimm:f%=0:im%=0:UNTIL0
870 PRINT"Data: ";:PROCpr(4):f%=im%:im%=3:UNTIL0
880 :
890 DEFPROCbroad
900 PRINT"Broadcast: ";:PROCpr(6):ENDPROC
910 DEFPROCpr(p%):p%=buf%+p%:REPEAT
920 IF ?p%<32 OR ?p%>126 PRINT"(";FNh(?p%,2);")"; ELSE VDU?p%
930 p%=p%+1:UNTILp%>=x%+buf% OR POS>75:PRINT:ENDPROC
940 DEFPROCimm
950
960 i%=ctrl%:
970 IF i%=&81 PRINT"PEEK";
980 IF i%=&82 PRINT"POKE";
990 IF i%=&83 PRINT"JSR ";
1000 IF i%=&84 PRINT"User procedure call";
1010 IF i%=&85 PRINT"OS Procedure call";
1020 IF i%=&86 PRINT"Halt":ENDPROC
1030 IF i%=&87 PRINT"Continue":ENDPROC
1040 IF i%=&88 PRINT"Machine type peek":ENDPROC
1050 IF i%=&89 PRINT"Read ARM registers":ENDPROC
1060 IF i%<&81 OR i%>&89 PRINT"Unknown";
1070 p%=buf%+6:REPEAT:PRINT" &"FNh(!p%,8);:p%=p%+4:UNTILp%>=x%:PRINT:ENDPROC
1080 DEFPROCraw:
1090 REPEATREPEATb%=FNb:UNTILst%AND1:
1100 REPEAT
1110 IF(st%AND&81):PRINTFNh(b%,2);
1120 IF(st%AND1):
1130 IF(st%AND2):PRINT"v";FNh(FNb,2);" ";:REPEATb%=FNb:UNTIL(st%AND13):IF(st%AND1):PRINTFNh(b%,2);
1140 IF(st%AND8):PRINT"b";:REPEATb%=FNb:UNTIL(st%AND4)
1150 IF(st%AND4):PRINT"i"
1160 IF(st%AND16):PRINT" e"
1170 IF(st%AND32):PRINT"d";
1180 IF(st%AND64):PRINT"o";
1190 IF(st%AND128):
1200 b%=FNb:UNTIL0
1210 UNTIL0