1
0
Fork 0
mirror of https://github.com/dosbox-staging/dosbox-staging synced 2025-12-04 16:27:29 -05:00
Multiplayer & serial ports
Grounded0 edited this page 2025-08-25 10:40:16 +03:00
Table of index (click to expand)

Introduction

Since online multiplayer gaming with DOSBox Staging is heavily dependent on multiplexing serial connections over Enet transport layer we're focusing on both on this page. Enet is a transport layer implemented on top of UDP that is robust and can even be used over mobile networks like the LTE while ensuring best effort FIFO (first in, first out).

Networking code in DOS and Windows 3.x games is often based on principle of circuit switched networks like telephone networks that offered high connection quality compared to packet switched networks like the internet we use today. These considerations make Enet almost obligatory for an enjoyable gaming experience over the internet.

Multiplayer

Preconditions for multiplayer gaming:

  1. Realtime communication outside of the game lobby for connection to be established for example through Discord, IRC, SMS, voice or face to face.
  2. One player participating in the game must have port forwarding enabled for a single incoming UDP port to facilitate the game to be hosted if they're behind a firewall. The host must also know their external IP address visible to the internet. The easiest way to figure this out is to search Google for What's my IP.

serialmain

The main program for configuring serial ports on DOSBox Staging is SERIAL.COM.

Host

serialhost1

Lets do a simple null modem based setup. We're running SERIAL.COM with parameters 1 which means COM1 serial port is used, nullmodem means null modem interface is used, port:1250 means we're listening on port 1250 and sock:1 means we're using Enet which is a UDP based transport.

serialhost2

Successful initialisation of Enet and null modem interface can be verified from DOSBox Staging console.

atf1

We're using Jane's ATF: Advanced Tactical Fighters as an example. Games usually indicate null modem interface as Serial so we select that. DOS era game multiplayer interfaces have wild variations in user interface and operating principles so its a good idea to refer to game manual for information on how to set it up according to your needs.

atf2

In this final screen before connection is established and players enter the game lobby its usually enough to select the correct serial port in this case COM1 and leave the rest of the settings alone. This avoids potential issues like baud rate mismatch between the UARTs.

Select Answer, wait for connection to be established or view DOSBox Staging console to verify if other players have established Enet transport layer session to your system and are just setting up the game themselves to connect to your host:

serialhost3

Client

serialclient1

Lets do a simple null modem based setup. We're running SERIAL.COM with parameters 1 which means COM1 serial port is used, nullmodem means null modem interface is used, server:<IP address> means we're connecting to a host with designated IP address, port:1250 means we're connecting to the host on port 1250 and sock:1 means we're using Enet which is a UDP based transport.

serialclient2

Successful initialisation of Enet and null modem interface can be verified from DOSBox Staging console. We've also successfully established Enet transport layer session to the host.

atf1

We're using Jane's ATF: Advanced Tactical Fighters as an example. Games usually indicate null modem interface as Serial so we select that. DOS era game multiplayer interfaces have wild variations in user interface and operating principles so its a good idea to refer to game manual for information on how to set it up according to your needs.

atf2

In this final screen before connection is established and players enter the game lobby its usually enough to select the correct serial port in this case COM1 and leave the rest of the settings alone. This avoids potential issues like baud rate mismatch between the UARTs. Select Call and wait for connection to be established.

Game specific fixes for multiplayer

Tyrian 2000 - GOG Release

The GOG Release of Tyrian 2000 does not initially include online multiplayer capability. Fortunately, this issue can be fixed by doing the following:

  1. Open the game folder on your system for the GoG version of Tyrian 2000.

  2. Download T2kMulti.zip containing the missing multiplayer files from the shareware version.

  3. Extract ALL of the files from T2kMulti.zip into the Tyrian2000 game folder where tyrian.exe is located.

  4. Launch Dosbox-Staging.

  5. Type ipx = true and press Enter to enable IPX emulation.

  6. Connect to another Dosbox-Staging via the IPX emulation:

  • For the IPX Server: ipxnet startserver [UDP_Port] and press Enter.

  • OR

  • For the IPX Client: ipxnet connect <IP_Address_of_IPX_Server> [UDP_Port_of_IPX_Server] and press Enter.

  1. Navigate to your Tyrian 2000 game folder and launch multi.bat to open the Epic Mega Games Arena and challenge the other connected player.

  2. In Tyrian 2000 itself, select the Game Episode you both want to play, Game difficulty, then Start Level.

Wacky Wheels

Wacky Wheels needs the Interbyte delay set to 1 in the Setup in order to work.

Serial ports

Serial ports can be configured in the config file:

serialX = device [parameter:value]

Or on the DOS command line:

serial X device [parameter:value]

device can be: direct | modem | nullmodem | mouse |dummy

parameters:

  • for direct: irq, realport (required), rxdelay

  • for modem: irq, listenport, sock (all optional)

  • for nullmodem: irq, server rxdelay txdelay telnet usedtr transparent port inhsocket sock (all optional)

  • for mouse: irq, rate (NORMAL or SMOOTH), type (2BTN, 3BTN, WHEEL, MSM, 2BTN+MSM, 3BTN+MSM, or WHEEL+MSM)

  • for dummy: irq

Defaults

serial1=dummy
serial2=dummy
serial3=disabled
serial4=disabled

Default IRQs (COM1 to COM4): 4, 3, 4, 3

Base memory addresses (COM1 to COM4): 0x3f8, 0x2f8, 0x3e8, 0x2e8

Examples

An example of how to configure an actual serial port for I/O use (Windows, for dosbox-staging.conf):

serial1=direct realport:com1

Listen on TCP:1250 as server

SERIAL 1 NULLMODEM PORT:1250 

Connect to TCP:1250 as client

SERIAL 2 NULLMODEM SERVER:10.0.0.6 PORT:1250 

Listen on UDP:5000 as server

SERIAL 3 MODEM LISTENPORT:5000 SOCK:1

Use a physical port on Linux

SERIAL 4 DIRECT REALPORT:ttyUSB0

Mouse Systems mouse:

SERIAL 1 MOUSE TYPE:MSM

Linux permissions

By default on Linux systems, if you are wanting to use a real serial port in DOSBox Staging, you need to give your user the permission to open the serial port device, as that will not be permitted by default. The best way to address this is to add your user to the appropriate serial group. On most (all?) Linux systems, this group is called "dialout".

To validate the serial port permissions, run the following command:

$ ls -l /dev/ttyS0
crw-rw----. 1 root dialout 4, 64 Jun  6 13:30 /dev/ttyS0

In the above example, we listed the onboard serial port. The device name will be different for a USB serial device (typically /dev/ttyUSB0). As you can see, the "dialout" group has read and write permissions to the device, which is what our user needs.

So let us add our user to the "dialout" group:

sudo usermod -a -G dialout $USER

You can validate the change with the id -Gn command. You may need to logout or reboot for the changes to take effect.

Common Linux errors

In case of problems with using real serial ports, please check the DOSBox Staging LOG, by launching from the terminal. On success the LOG should contain a single SERIAL message such as:

SERIAL: Port 1 opening ttyS0.

But it may be followed by an error message:

SERIAL: Port 1 could not open "ttyS0" due to: System error XX

A few common errors:

  • System error 2: the requested port does not exist
  • System error 5: IO error
  • System error 7: IO error
  • System error 13: permission denied

For error code 5 or 7, check the following:

  • Is the port not already in use by another process
  • Is the port actually present on the system (the Linux serial driver always creates a number of dummy ttyS* serial ports, if they actually exist or not)
  • Is the port enabled in the BIOS of the system

Nullmodem options

sock:1

  • Setting to 1 enables enet on the port, otherwise TCP.

usedtr:1

  • The nullmodem will
  1. when it is client connect to the server not immediately but as soon as a modem-aware application is started (DTR is switched on).
  2. only receive data when DTR is on.

transparent:1

  • don't add handshake control.

  • handshake control: if transparent is 0 or default (and not overridden by another mode), dosbox will include flow control pin changes (DTR and RTS) in the sent nullmodem stream and interpret similar received signals as DSR and CTS pin changes. Also it can include "Line Control Break" signals [todo: when are these used?]

telnet:1

  • interpret telnet commands.

rxdelay:

  • How many milliseconds to wait before causing an overflow when the application is unresponsive.
  • default: rxdelay:50
  • max value: rxdelay:10000

txdelay:

  • How many milliseconds to wait before sending data. This reduces network overhead quite a lot.
  • default: txdelay:12
  • max value: txdelay:500

port:

  • port is for both server and client
  • 1 to 65535
  • default: port:23

inhsocket:1

  • socket inheritance (client-alike)

Nullmodem escape characters

Information for developers.

DOSBox's nullmodem stream inserts the DTR/CTS pin changes into the stream with a two-byte escape sequence. It does this unless unless transparent:1, or other modes such as telnet are used.

The protocol is not formally described and may change in future, but for developers who wish to connect to the nullmodem stream directly as it is, the escape sequences appear as follows:

  • First byte: 0xFF
  • Second byte: 0xFF — for a literal 0xFF
  • or second byte: 0x00
    • +1 for RTS high (sent with CTS pin)
    • +2 for DTR high (sent with DSR pin)
    • +4 for Line Control Break [todo: when is this used?]

TCP/IP

  1. Open dosbox-staging.conf and verify that the setting ne2000 in the [ethernet] section is set to true.

  2. Download http://www.brutman.com/mTCP/download/mTCP_2023-03-31.zip and http://www.georgpotthast.de/sioux/pktdrv/ne2000.zip to your system.

  1. In your DOS game folder to be mounted as Dosbox-Staging's C drive, extract the contents of mTCP_2023-03-31.zip into a folder called mtcp.

  2. Also, extract only the file ne2000.com from ne2000.zip into the same mtcp folder.

  3. In dosbox-staging.conf in the [autoexec] section, add the following lines and save the file:

mount c c:\dosgames
c:
set path=c:\mtcp\
set mtcpcfg=c:\mtcp\samples\sample.cfg
ne2000.com 0x60 3 0x300
dhcp.exe
  • The lines above will mount your c:\dosgames folder as Dosbox-Staging's C drive, change the current working directory to the mounted C drive, add the mtcp folder to your PATH, specify DHCP settings for dhcp.exe to use to query the DHCP server, start the NE2000 packet driver (ne2000.com), and then run DHCP (dhcp.exe) to assign Dosbox-Staging an IP address.

  • Of course, if your DOS games folder is not c:\dosgames, replace it in the above mount command with the actual location on your system.

  1. Open Dosbox-Staging. If all went well, the NE2000 packet driver will start and then DHCP will display the IP address at the Dosbox-Staging command prompt.

See also