Skip to content

1984

1984: An Amstrad CPC Emulator That Recreates the W5100S of Cyboard and Net4CPC Down to the Register Level

scott

Published November 05, 2026

Original author: salvogendutOriginal source (new tab)

1984

Components

Hardware components

Project description

Summary

1984 is an Amstrad CPC emulator written in C. It recreates Net4CPC and Cyboard, real Ethernet boards for the CPC, along with the WIZnet W5100S inside them, down to the register level. CPC programs believe a real W5100S is present and drive its socket registers, while the emulator carries that activity over to the PC's network. As a result, network software written for the real boards (KCNet, SymbOS, FUZIX) runs on a PC without the hardware, and on Linux and BSD the CPC can even join a real LAN.

Overview

1984 is an Amstrad CPC emulator released by salvogendut in May 2026. It supports six machines, from the CPC 464, 664 and 6128 to the Plus range and the GX4000. The desktop edition uses SDL3, and the browser edition compiles the same core to WebAssembly. It is licensed under GPL-2.0.

The emulator recreates not only the CPC itself but also several expansion boards. This article focuses on its Net4CPC support. Net4CPC is a real board that adds Ethernet to the CPC with a W5100S, and the same circuit also appears on the all-in-one Cyboard. The structure of the real boards and how they connect the W5100S are covered in a separate article.

→ Cyboard article (WIZnet Makers): https://maker.wiznet.io/scott/projects/cyboard-for-cpc/
→ 1984 repository: https://github.com/salvogendut/1984

1984 does not use a W5100S. The chip lives on the real board, and 1984 imitates its behavior in software. That makes this article a case study in "what it takes to rebuild in software what the chip does in hardware."

Architecture

1984 architecture. CPC software (KCNet, SymbOS N4C daemon, FUZIX) reaches the virtual W5100S in net4cpc.c through I/O ports #FD20–#FD23. The virtual W5100S has a 64 KB register space, four sockets and 2 KB TX/RX buffers per socket. Below it, the path splits into two backends. The default backend uses host POSIX sockets, so the host OS handles TCP. The TAP backend uses the n4c_stack.c stack to handle ARP, ICMP, TCP, UDP, a DHCP server and a DNS proxy (Linux), then goes out through tap.c and a TAP device to the LAN

When a CPC program reads or writes I/O ports #FD20–#FD23, net4cpc.c updates register values and interprets socket commands just as a real W5100S would. There are two ways out to the real network.

  • Default backend: Maps each W5100S socket to one POSIX socket on the PC. The PC's operating system handles TCP. It works on every OS
  • TAP backend: The emulator's own TCP/IP stack (n4c_stack.c) builds and parses Ethernet frames itself and sends them to a TAP device on Linux or BSD. The CPC then appears as an independent device on the LAN

Technology Background

TAP Devices and L2 Bridging

TAP is a virtual Ethernet device provided by the Linux and BSD kernels. When a program writes an Ethernet frame to a TAP device, the kernel handles it as if it had arrived on a real network card, and the same works in the other direction. If you bridge a TAP device with a real network card, the virtual device the program created appears on the LAN as-is.

1984 uses this to turn the virtual W5100S into a real device on the LAN. The CPC gets its own MAC and IP, and other PCs on the LAN can ping it or connect to it. Using NAT instead of a bridge lets the CPC reach the Internet through the PC.

→ Net4CPC TAP setup guide: https://github.com/salvogendut/1984/blob/main/NET4CPC.md

Host Socket Mapping

The simplest way for an emulator to recreate a network chip is to pass the guest's socket requests straight to the host OS socket API. That is how 1984's default backend works. When OPEN reaches a W5100S socket, the PC opens a socket(), and when CONNECT arrives, it calls connect().

This is simple to implement and needs no administrator rights, but the limits are clear. Connections leave from the PC's IP, so the CPC is not an independent device on the LAN. Nothing outside can ping the CPC or connect to it, and ARP and DHCP do not work.

Register-Level Emulation

KCNet and the SymbOS daemon are Z80 code written for a real W5100S, so they depend on the behavior of individual registers. To run that code unchanged, the emulator must reproduce register addresses, initial values and read/write side effects exactly as the datasheet describes. If it only approximates behavior at the function level, a single value that differs from what the driver expects can stall it during startup.

1984's development history shows this well. The real bugs it ran into are collected in the "Where WIZnet Fits" section below.

Technical Highlights

Item Default backend TAP backend
Supported OS All platforms (including Windows and macOS) Linux, FreeBSD, NetBSD, OpenBSD
TCP handling Host OS kernel Emulator's own stack
Outbound TCP/UDP Yes Yes
Inbound connections (LISTEN) No Yes
Ping replies (ICMP) No Yes
ARP Not implemented Responder + cache, gateway resolution
DHCP Not implemented Built-in DHCP server, or the server on a bridged LAN
DNS proxy None (host handles it) Linux only
Privileges Plain sockets only CAP_NET_ADMIN or a pre-created TAP
  • Automatic setup on Linux: When TAP is enabled, a single pkexec prompt creates the TAP device, assigns an IP, adds it to the firewalld trusted zone, enables IPv4 forwarding and installs MASQUERADE and FORWARD rules. On BSD, doas or sudo only creates the TAP device, and NAT has to be set up by hand
  • Built-in DHCP server and DNS proxy: Hands out IPs from the configured range to the CPC, and on Linux forwards the CPC's DNS queries to the PC's resolver
  • Two tracing options: --trace-net4cpc logs every W5100S register read and write and every socket command, while --trace-tap logs ARP, TCP, UDP and ICMP frame events. With both enabled, you can follow bytes the CPC writes into the TX buffer all the way out as Ethernet frames
  • Cyboard toggle: Turning on Cyboard in the settings menu enables Net4CPC, the RTC, SYMBiFACE IDE and the mouse in one step. This matches the Ethernet, RTC, storage and mouse set found on a real Cyboard

FUZIX booted in 1984 and connected to a remote telnet server through the emulated Net4CPC. The remote server prints its command list and calendars, then the connection closes after logging out

FUZIX in 1984 connected over telnet to the Aardwolf MUD server, showing the welcome screen and the character name prompt

The first recording was made on the day the fix that connects FUZIX to the Internet through the Net4CPC TAP backend was merged. The repository does not say which path the second recording used.

Where WIZnet Fits: The W5100S Rebuilt in Software

What It Recreates

What 1984 recreates is the W5100S on the Net4CPC board. According to the source comments and development notes, it implements the following.

  • Four I/O ports: #FD20 (MR), #FD21 and #FD22 (IDM_AR upper and lower), #FD23 (IDM_DR). When MR's auto-increment bit is set, the address advances on every data-port access
  • 64 KB register and buffer space: Common registers (0x0000–0x002F), four sets of socket registers (0x0400–0x07FF), and 2 KB TX/RX ring buffers per socket (0x4000–0x7FFF)
  • Four sockets and socket commands: OPEN, CONNECT, LISTEN, SEND, RECV, DISCON, CLOSE
  • Socket modes: TCP, UDP (prepends the W5100S-style 8-byte header to received data), IPRAW (used by KCNet's PING.COM for ICMP)

One Command on Real Hardware Becomes 1,300 Lines of Code

Comparing a CPC program's TCP connection to a server on the real hardware and on 1984's TAP backend makes the difference clear.

Real Net4CPC (W5100S)

  1. The Z80 writes the destination IP and port to the socket registers and writes the CONNECT command
  2. The W5100S handles ARP, sending SYN, receiving SYN-ACK, sending ACK and retransmission entirely on-chip
  3. The Z80 only checks whether the socket status register has reached ESTABLISHED

1984 TAP backend

  1. net4cpc.c receives the CONNECT command, calls n4c_stack_tcp_connect() and sets the socket status to SYN_SENT
  2. n4c_stack.c looks up the peer's MAC in its ARP cache (16 entries, 60-second lifetime) and, if it is missing, builds and sends an ARP request itself
  3. It assembles the Ethernet, IP and TCP headers, computes the TCP checksum and writes the SYN frame to the TAP device
  4. On every emulated frame, it pulls incoming frames from the TAP, checks for the SYN-ACK, sends the ACK and sets the socket status to ESTABLISHED
  5. Sent data is kept in a 1,460-byte retransmit buffer per socket and resent if no ACK arrives within about one second (50 frames). If there is still no ACK after four retransmissions, it sets the socket to CLOSED and raises DISCON in the socket interrupt register
  6. On close, it goes through the FIN_WAIT, CLOSE_WAIT, LAST_ACK and TIME_WAIT states

1984 reimplements in n4c_stack.c what the chip does on the real hardware. Including the built-in DHCP server and DNS proxy, this file is 1,314 lines, not counting the register model net4cpc.c (971 lines) and the TAP I/O in tap.c (503 lines). Put the other way around, on the real board the W5100S takes on all of this, so the 4 MHz Z80 only has to handle a few registers.

Think of it this way: 1984's Net4CPC is a stand-in actor on a stage. The audience (the CPC program) only sees an actor following the script (the W5100S datasheet) and cannot tell whether it is the lead. The stand-in must match every line and move of the lead, and backstage, the work the lead did alone (ARP, handshakes, retransmission) is split among several crew members (the stack code).

→ Virtual W5100S source: https://github.com/salvogendut/1984/blob/main/src/net4cpc.c
→ Own TCP/IP stack source: https://github.com/salvogendut/1984/blob/main/src/n4c_stack.c

One Mismatch with the Datasheet Is Enough to Stall

1984's development notes, source comments and issues record W5100S behaviors that had to be fixed to get KCNet, SymbOS and FUZIX working.

Fixed behavior Symptom before the fix
Implemented Sn_IR bits as cleared by writing 1 (the datasheet's WC type) Bits that KCNet's NCFG had cleared stayed set, so after DHCP ACK it concluded the address was in use and sent DHCPDECLINE
Restored MR to 0x03 (indirect mode + auto-increment) after reset When the SymbOS daemon wrote multi-byte registers, only the last byte remained
Cleared Sn_IR on the OPEN command In FUZIX, the first telnet connection was refused and the second one succeeded

There are also cases where the first implementation disagreed with the datasheet and was fixed again.

  • Soft reset: At first, the common configuration block was preserved on MR.RST. After a report (issue #123) pointing out that section 3.1.1 of the datasheet says a soft reset initializes all registers, it was changed to wipe everything and restore the chip's default values
  • PHY status register (0x003C): At first it returned 0x07, based on the W5500's PHYCFGR. On the W5100S, however, this address is PHYSR0, and the speed and duplex bits mean something different. On the W5100S, 0x07 means 10 Mbps half duplex, and the SymbOS network daemon displayed exactly that. It was corrected to 0x01 (2026-06-13)

These notes are useful for anyone writing a W5100S driver. They show how much a driver relies on what the real chip does automatically (reporting link status, reset behavior, interrupt-bit handling), and that the same address can be defined differently on the W5500 and the W5100S.

→ Virtual W5100S source (reset and default-value comments): https://github.com/salvogendut/1984/blob/main/src/net4cpc.c
→ Development notes (Net4CPC section): https://github.com/salvogendut/1984/blob/main/Development.md

Similar Projects on WIZnet Makers

  • Cyboard: The original board behind the Net4CPC circuit that 1984 recreates. It attaches W5100S Ethernet to the CPC over an indirect parallel bus, alongside a CF card, mouse and RTC. Its relationship to 1984 is that of real hardware to emulator
    → Project link: https://maker.wiznet.io/scott/projects/cyboard-for-cpc/
  • xep128: An emulator for the Enterprise-128, a British 8-bit computer, focused on recreating expansion hardware, with limited W5300 emulation. It is the closest match to 1984 as a retro emulator that recreates a WIZnet chip, but its author describes it as an old, archived project
    → Project link: https://maker.wiznet.io/rena/projects/xep128/
  • PICSimLab: A simulator that makes development boards behave like real hardware. It offers Arduino Uno examples with W5500 Ethernet (web server, web client, NTP). It shares 1984's goal of developing firmware for a WIZnet chip without the hardware
    → Project link: https://maker.wiznet.io/WIZnet/projects/picsimlab-gui-tool-with-w5500/

All three show that the socket behavior of WIZnet chips serves as a "standard worth recreating." Because the chip wraps TCP/IP behind a handful of registers, reproducing those registers exactly is enough to run existing software without the hardware.

Item 1984 Cyboard xep128 PICSimLab
Type Emulator Real board Emulator Simulator
Target Amstrad CPC Amstrad CPC Enterprise-128 Arduino Uno and others
WIZnet chip W5100S (recreated) W5100S (real) W5300 (recreated, limited) W5500 (recreated)
Real LAN connection Host sockets / TAP Direct Unknown Unknown
Status Active (commits in 2026-10) No updates since 2023-05 Archived Unknown

What sets 1984 apart is that it can become an independent device on a real LAN. Through the TAP backend it recreates ARP, ICMP and even DHCP, so the CPC answers pings and accepts outside connections.

Use Cases

  • Network software development without the hardware: Build network programs for KCNet, SymbOS and FUZIX on a PC, debug them with register tracing, then move them to the real hardware. The N4C-NETTOOLS Z80 network library is also compatible with this emulator
  • Checking before buying the real board: Before building a Cyboard or Net4CPC, you can first see how the software you plan to use behaves
  • Learning how the W5100S works: --trace-net4cpc shows which registers are written, and in what order, for each socket command. It serves as a learning tool that shows how W5100S drivers are actually used
  • Putting a retro machine on the LAN: With a TAP bridge, the emulated CPC becomes a device on your home LAN and can talk to other devices

Limitations and Future Improvements

Current limitations:

  • The default backend is not an independent device: Ping replies, inbound connections, ARP and DHCP do not work. Windows and macOS can only use this backend
  • TAP setup effort: Linux sets up automatically but needs one administrator prompt, and BSD requires manual NAT setup
  • Subnet clashes: If the built-in DHCP server's default range, 10.0.0.0/24, overlaps your home LAN, nothing works. The documentation recommends another range such as 192.168.99.0/24
  • No browser support: In the browser edition (Javascript 1984), Net4CPC support is replaced by empty functions
  • Simplified TCP: It keeps only one unacknowledged segment per socket (1,460-byte buffer, MSS fixed at 536 bytes), the receive window is fixed at 2 KB, and TIME_WAIT moves straight to CLOSED. [Inferred] This is enough for retro software, but large file transfers may perform differently from the real hardware
  • Limited silicon-compatibility checks: The documented fixes mostly cover behavior used by KCNet, SymbOS and FUZIX. How closely other register behavior matches the real chip has not been verified

Directions for improvement:

  • Side-by-side testing with real hardware: [Inferred] Running the same program on a real Net4CPC and on 1984 and comparing the --trace-net4cpc logs would systematically reveal differences in register behavior
  • Networking in the browser edition: [Inferred] The browser edition already has a relay path for the M4 board (web/m4-bridge.js), so Net4CPC sockets could be moved to a WebSocket relay in the same way

FAQ

Q. Can I use Net4CPC on Windows? A. Yes. With the default backend, outbound TCP connections and unicast UDP from the CPC work. The TAP backend is Linux- and BSD-only, though, so on Windows the CPC cannot answer pings or accept outside connections.

Q. How much can I do without the real board? A. You can run the KCNet utilities, the SymbOS network daemon and FUZIX networking written for the real board, unchanged. 1984's feature documentation states that FUZIX reaches the Internet through Net4CPC. Features that need ARP or ICMP, such as KCNet's DHCP and PING, only work with the TAP backend.

Q. Does 1984 use a W5100S? A. No. The W5100S sits on the real Net4CPC and Cyboard boards, and 1984 recreates that chip's register and socket behavior in software. For the real boards, see the Cyboard article.

Q. I enabled TAP, but nothing gets through. A. First check for a subnet clash. If the built-in DHCP default range (10.0.0.0/24) overlaps your home LAN, change it to another range in the config file. Then use tcpdump -i <TAP device> -nn to see whether the emulator is sending frames, and --trace-net4cpc to check the CPC's register access.

Q. Does networking work in the browser edition? A. Not at the moment. The browser edition replaces Net4CPC support with empty functions.



요약

1984는 C로 작성된 Amstrad CPC 에뮬레이터로, CPC용 실물 Ethernet 보드인 Net4CPC·Cyboard와 그 안의 WIZnet W5100S를 레지스터 수준까지 재현합니다. CPC 프로그램은 진짜 W5100S가 있다고 믿고 소켓 레지스터를 조작하고, 에뮬레이터가 그 동작을 PC의 네트워크로 옮겨 줍니다. 덕분에 실물 보드용 네트워크 소프트웨어(KCNet, SymbOS, FUZIX)를 실기 없이 PC에서 돌리고, Linux·BSD에서는 CPC를 실제 LAN에 붙일 수도 있습니다.

개요

1984는 salvogendut이 2026년 5월에 공개한 Amstrad CPC 에뮬레이터입니다. CPC 464·664·6128과 Plus 계열, GX4000까지 6개 기종을 지원하며, 데스크톱판은 SDL3로, 브라우저판은 같은 코어를 WebAssembly로 빌드해 만듭니다. 라이선스는 GPL-2.0입니다.

이 에뮬레이터는 CPC 본체뿐 아니라 여러 확장 보드도 재현합니다. 이 글은 그중 Net4CPC 기능에 초점을 맞춥니다. Net4CPC는 W5100S로 CPC에 Ethernet을 더하는 실물 보드이고, 같은 회로가 통합 보드 Cyboard에도 들어 있습니다. 실물 보드의 구조와 W5100S 연결 방식은 별도 글에서 다뤘습니다.

→ Cyboard 글(WIZnet Makers): https://maker.wiznet.io/scott/projects/cyboard-for-cpc/
→ 1984 저장소: https://github.com/salvogendut/1984

1984는 W5100S를 쓰지 않습니다. 칩은 실물 보드에 있고, 1984는 그 칩의 동작을 소프트웨어로 흉내 냅니다. 그래서 이 글은 "칩이 하던 일을 소프트웨어로 다시 짜면 무엇이 필요한가"를 보여 주는 사례이기도 합니다.

아키텍처