econet thoughts.
Rob O'Donnell. robert@irrelevant.com. 28/12/2004.

Econet has a network number x, and station number y.
where x < 128 for "real" econet, 128+ for ethernet.
Default Acorn AUN Econet over Ethernet uses IP 1.0.x.y
Apparently always uses UDP to port 32768.

In an emulation environmet this is less than ideal as we may wish
to run multiple emulated machines on one PC.

We will instead allow any station to exist on any IP/port combination.

use 'econet.cfg' file for the moment.

format is  
net stn ip port
eg.
0 254 192.168.0.93 32768
0 101 192.168.0.94 10101
0 102 127.0.0.1 10102



------------------------------------------------------------------------------------------
implementation in BeebEm

added EconetEnabled flag & menu item (buggy at time of writing - you sometimes need to save 
prefs & restart emulator after changing.)

added call to EconetReset at hardware reset stage.

add:  read from FE18 (not fe20 as per AUG) returns station number
note:  read/write from FE18 sets INTOFF line
note:  read from FE20 sets INTON
 --- and can trigger an NMI immediately if 68B54 was already holding line waiting to be noticed

added EconetNMIenabled flag, set as per reads above

add:  read/write from FEA0-FEA3 to ADLC.

added: econet polling routine to handle tcp transfers, setting of adlc registers etc.

added: command line variables to set station number and listening port.
(defaults to 2 and 32768 if not set)


------------------------------------------------------------------------------------------



ok. actually sending stuff on the network. umm.

we are intercepting data at the hardware level. 
the 68B54 does not know any address itself; it broadcasts what it's given and reports back anything it
receives.
a packet consists of:

Econet AUG says flag,dest,source,data,crc,flag.
MC6854 data sheet says:  flag,dest,control,data,crc,flag

thus we need to interpret this and issue udp transmits to the relevant ip address/port number.

it is up to the beeb cpu to send everyhting between the flags and crc. flags & crc are added automatically.

receiving beeb nfs would usually watch for 'our' station id and isue a discard for anything else. this is
less likely to be an issue for us as we will will generally only receive data directly for us.
note address-present flag (SR2b0)

in Econet, when data is coming across the lan, the adlc will send INTs.  These are masked by INTON/INTOFF to the
6502 NMI line.  So, when econet is off, they will be totally ignored.  
-- but can hit you as soon as you set INTON !
The 65B54 has a three byte fifo on rx & tx.  This means that if data is not fetched quickly enough,
you will get a receiver overrun error. (SR2b6)

For our application, we are using UDP packets.

we will have a poll routine runs every so often cycle that will:
copy data from the fifo into a tx buffer
 - if was last byte (CR2b4 set) then finish off and send the UDP packet.
 - clear CR2b4)
 - status flags?
is there a received udp packet in memory
  is discontinue bit set? (CR1b5) 
    if so, discard udp packet, set flags accordingly.
  check if space in receive fifo. 
    if there is, copy in next byte. set flags.
if no packet in mem
   try and fetch another udp packet
    


-------------------------------------------------------------------

REST STATE of a REAL BBC Micro (with or without nfs installed)
status 1 - 16	- CTS - cts comes from data lines, and will therefore be a collision detection.
(CTS is active low, this notavailable to send, normal as Tx is held in reset normally)
status 2 - 32   - DCD - dcd is derived directly from the clock signal.
(DCD is active low, thus this is flagging a DCD error)
- machine reports No Clock on boot.

REAL BBC micro with clock box only attached
status1 - 16 - CTS
status2 - 4 - RxIdle

-------------------------------------------------------------------
