Vic 20 network interface by Lee Davison

Introduction

This is a developement of my SuprChip V network interface for the Vic 20. So now I can plug my Vic 20 into an ethernet port on my home network.

As far as I know this is the first ever ethernet equipped Vic 20 and the first Vic 20 web server. It may not be much use as such but shows that just because something is twenty years old, and not to well specified compared to today's PCs, doesn't mean it gets relegated to holding doors open.

I did this for the Vic 20 to see if I could and because I have a Vic 20 or two not doing much. I also thought the ISA card slot and ROM/RAM expansion may be usefull for something else someday.


Hardware

I decided straight off to use a 3Com 3C509B network interface card for two reasons. First I seem to have a shed load of the things, and second the code is easier because the 3Com card handles much of the housekeeping needed with an NE2000 type NIC.

If you do decide to use some other PC network card make sure that..

  • It works (try it in a PC first).
  • The I/O range and interrupt are configured.
  • The media type is configured.

  • Software

    The software is written entirely in assembler for a number of reasons. Vic BASIC doesn't directly support interrupts so I would need to use assembly code for that, the Vic BASIC POKE command doesn't quite work as expected, so that would also need to be patched, and it's easier for me to make a ROM than LOAD & SAVE from BASIC on the Vic.

    The software as it is supports ARP, ICMP echo requests (aka PING) and can serve one of three web pages, three image files and two HTTP error responses via TCP port 80. To support the web serving a simple ROM filesystem was designed and implemented.

    With the limited RAM available a single buffer is used for holding packets, this buffer is large enough to contain one maximum size packet. When a packet is received it is copied to the buffer and processed there, the outgoing packet is constructed in the same buffer and overwrites the received packet. This has not been a problem so far.

    A flag is used to indicate the arrival of a packet and to prevent the buffer being overwritten by new packets before the data has been processed. Packets received when the buffer is in use are queued by the network card. Most network cards have buffers that are large enough to hold four maximum sized ethernet packets. Once the packet processing is complete the flag is cleared and the buffer is free to receive the next packet.

    The program spends its idle time just waiting for a packet to arrive and keeping the display up to date. Once a received packet is flagged (this is done by the interrupt service routine) it is checked against known types and processed as needed. When this has been done the program clears the packet flag and returns to the idle loop to wait for the next packet to arrive.

    The TCP handler is not a full TCP stack, it can only handle one passively opened thread, and does not time wait on closing due to limited resources. It also ignores out of sequence, repeated or error packets where it should send a RST. The other shortfall is that it can only handle unfragmented data so is limited to less than 1500 data bytes for both receive and transmit.

    Source

    You can just download the latest source as zipped .asm file or view some highlights as html.

    Update

    A new version that supports multiple simultaneous TCP connections can be found here.


    Last page update: 28th April, 2004. e-mail me