!ID: Show ether station address and firmware version etc

%option "-low-nocheck-nodiag"
%include "inc:fs.imp"
%include "inc:util.imp"

%routine pdate(%integer d,m,y)
  phex2(d); printsymbol('/')
  phex2(m); printsymbol('/')
  phex2(y)
%end

%routine rwait
  %cycle; %repeatuntil eths&1#0
%end

%integerfn dc
  rwait %until eths&4#0
  %result = ethd
%end

%integerfn cc
%integer x
  %cycle
    rwait %until eths&2#0
    x = ethc
    %result = x %if x&\15=0
    %if x&\15#0 %start
      printstring("[^"); phex2(x); phex2(dc); printsymbol(']')
    %finish
  %repeat
%end

%integerfn cpu
  %integerfn f
    %option "-nocheck-nodiag"
    *move.l #68010,d0
    *=16_4e74;*=0 {rtd #0
  %end
  %on 0 %start
    %result = 68000
  %finish
  %result = f
%end

%routine kb(%integer b)
  write(b>>10,0); printstring(" kB")
%end

%begin
@16_0ff4 %byte dd,mm,yy
%integer i,z
%bytearray b(1:4)

  write(cpu,0)
  printstring(" firmware version ")
  pdate(dd,mm,yy); newline
  z = 0
  eths = z;              !Interrupts off
  twait; ethc = 8;       !Set Peek Address
  twait; ethd = 3;       !Low byte
  twait; ethd = z;       !High byte
  %for i = 1,1,4 %cycle
    twait; ethc = 13;    !Peek command
    z = cc %until z=14;  !Await Poke response
    b(i) = dc;           !Get the value
  %repeat
  eths = 6;              !Interrupts on again
  printstring("Ether firmware version ")
  pdate(b(2),b(3),b(4))
  newline
  printstring("Station address ")
  phex2(b(1)) %and printstring("? ") %unless b(1)=ldte
  phex2(ldte); newline
  printstring("Your port "); phex2(lsap)
  printstring(" is connected to port "); phex2(rsap)
  printstring(" of filestore "); phex2(rdte); newline
  printstring("Main store ")
  kb(memtop-membot); printstring(" from "); phex(membot); newline
  printstring("Free store ")
  kb(freetop-freebot); printstring(" from "); phex(freebot); newline
%endofprogram
