Skip to content

wwiv 5.4 qemu door example (experimental)

granitepenguin edited this page Jan 4, 2019 · 1 revision
  • So here is a basic setup that's gotten me close. It still doesn't quite work because either the display is funky (the ANSI characters are not cleanly being handled, especially for screen clears) or the user input is super slow in responding, or there's too much extra input streaming through (like when the sgabios device is used).

Hopefully someone else will have some better luck, and this may very well work for someone else's door; TW2002 may just be hosed.

install qemu-system-x86

	aptitude install qemu-system-x86

create disk image

	https://en.wikibooks.org/wiki/QEMU/FreeDOS
	qemu-img create -f raw freedos.img 100M

Download and Install FreeDOS

	wget http://www.freedos.org/download/download/FD12CD.iso
	qemu-system-i386 -localtime freedos.img -cdrom FD12CD.iso -boot d -curses
	Install to harddisk
	Language
	Yes - Continue with install
	Partition C:
		Large Disk support: NO (our OS disk is only 100MB)
		Create Primary DOS partition
	Reboot
	Install to harddisk
	Language
	Erase and Format
	Keyboard Layout
	Base packages only
	yes- Install (wait)
	return to DOS
	shutdown

install the sgabios display device sudo apt-get install sgabios

Set up fdconfig.sys and autoexec.bat

For editing the fdconfig.sys and autoexec.bat, I HIGHLY recommend mounting the image file locally. It's a LOT easier to use vim, nano, whatever than it is to try to use freeDOS' editor

to mount directly, as root:

 mount -t msdos -o loop,offset=32256 freedos.img  /media
 vim /media/fdconfig.sys
 vim /media/autoexec.bat
 umount /media

Contents of fdconfig.sys

SWITCHES=/F /N
SET DOSDIR=C:\FDOS

!COUNTRY=001,858,C:\FDOS\BIN\COUNTRY.SYS
!LASTDRIVE=Z
!BUFFERS=20
!FILES=40

DOS=HIGH
DOS=UMB
DOSDATA=UMB
DEVICE=C:\FDOS\BIN\JEMMEX.EXE NOEMS X=TEST I=TEST NOVME NOINVLPG
REM DEVICEHIGH=C:\FDOS\BIN\NANSI.SYS
SHELLHIGH=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\AUTOEXEC.BAT

contents of autoexec.bat

SET DOSDIR=C:\FDOS

!COUNTRY=001,858,C:\FDOS\BIN\COUNTRY.SYS
!LASTDRIVE=Z
!BUFFERS=20
!FILES=40

DOS=HIGH
DOS=UMB
DOSDATA=UMB
DEVICE=C:\FDOS\BIN\JEMMEX.EXE NOEMS X=TEST I=TEST NOVME NOINVLPG
REM DEVICEHIGH=C:\FDOS\BIN\NANSI.SYS
SHELLHIGH=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\AUTOEXEC.BAT
root@beaglebbs:~# cat /media/autoexec.bat
@ECHO OFF
SET DOSDIR=C:\FDOS
SET LANG=EN
SET TZ=UTC
SET PATH=%dosdir%\BIN
if exist %dosdir%\LINKS\NUL SET PATH=%path%;%dosdir%\LINKS
SET NLSPATH=%dosdir%\NLS
SET HELPPATH=%dosdir%\HELP
SET TEMP=%dosdir%\TEMP
SET TMP=%TEMP%
SET BLASTER=A220 I5 D1 H5 P330
SET DIRCMD=/P /OGN /Y
SET COPYCMD=/-Y

LH FDAPM APMDOS
LH SHARE

SET AUTOFILE=%0
SET CFGFILE=C:\FDCONFIG.SYS
alias reboot=fdapm warmboot
alias reset=fdisk /reboot
alias halt=fdapm poweroff
alias shutdown=fdapm poweroff
alias cfg=edit %cfgfile%
alias auto=edit %0

set OS_NAME=FreeDOS
set OS_VERSION=1.2

d:\rundoor.bat

Set up your Doors directory inside the qemu image Use the DPMI version of TW2002 We can either copy the file into the qemu image, or make it available using the fat:rw:/directory

to mount directly, as root:

mount -t msdos -o loop,offset=32256 freedos.img  /media
then copy in the 2002V309-DPMI.ZIP to /media
then umount /media

To put in a directory and mount inside of qemu as a fat volume make a /tmp/tw2002 directory, then boot your VM this will put /tmp/tw2002 as D: inside the VM

TERM=linux qemu-system-i386 -localtime freedos.img -hdb fat:ro:/tmp/tw2002 -parallel none -serial none -curses

Contents of tw2002.sh that will be the file we call in the chain

#!/bin/bash
#
# Tradewars 2002 chain
#

trap "echo" SIGHUP SIGINT SIGTERM

unset DISPLAY

declare -r NODE=$1
declare -r DROPFILE_PATH=$2
declare -r DROPFILE_NAME=$(basename ${DROPFILE_PATH})
declare -r BBS_TEMPDIR=$(dirname ${DROPFILE_PATH})
declare -r SOCKET_HANDLE=$3

SIZE_INFO=$(stty size) 
read -r ROWS COLS <<< "${SIZE_INFO}"

if [ ${ROWS} -lt 25 -o ${COLS} -lt 80 ]
then
    echo
    echo -e "\e[31;1mWARNING\e[0m"
    echo
    echo -e "Columns: \e[33;1m${COLS}\e[0m"
    echo -e "Lines  : \e[33;1m${ROWS}\e[0m"
    echo
    echo -e "Trade Wars 2002 requires a \e[32;1mminimum 80x25\e[0m display."
    echo "Please adjust your terminal to 80x25 and try again."
    echo
    echo "If you are using SyncTERM, make sure you have your"
    echo "Screen Mode explicitly set to 80x25, not \"Current\""
    echo
    echo "Thanks."
    echo 
    echo "-- "
    echo "The Management"
    sleep 2
else
    #
    # Create our batch file drop that has our info and runs after startup
    #
    echo "c:\doors\tw2002\tw2002.exe TWNODE=${NODE}" > ${BBS_TEMPDIR}/rundoor.bat
    echo "halt >NUL" >> ${BBS_TEMPDIR}/rundoor.bat
    unix2dos ${BBS_TEMPDIR}/rundoor.bat > /dev/null 2>&1

    # we need to convert the chain.txt file to DOS format.  TW doesn't like unix files
    unix2dos ${BBS_TEMPDIR}/chain.txt > /dev/null 2>&1

    #
    # combinations I've tested so far (all testing in SyncTERM)
    #
    # the export TERM is so qemu sees a term type at startup (it defaults to "dumb")

    # This one is a mess ( TERM type looks decent, but socat isn't really responding
    # and the ANSI painting isn't very good)
    #export TERM=ansi
    #socat -d -d FD:${SOCKET_HANDLE} EXEC:"qemu-system-i386 -localtime freedos.img -hdb fat\:ro\:${BBS_TEMPDIR} -parallel none -monitor none -serial none -curses",pty 

    # This one is a mess ( TERM type is ugly and socat isn't really responding)
    #export TERM=linux
    #socat -d -d FD:${SOCKET_HANDLE} EXEC:"qemu-system-i386 -localtime freedos.img -hdb fat\:ro\:${BBS_TEMPDIR} -parallel none -monitor none -serial none -curses",pty 

    # Looks the best, but the sgabios device sends a lot of extra characters that make it unplayable
    # plus input response is really slow (or nonexistent)
    #export TERM=ansi
    #socat -d -d FD:${SOCKET_HANDLE} EXEC:"qemu-system-i386 -localtime freedos.img -hdb fat\:ro\:${BBS_TEMPDIR} -parallel none -monitor none -nographic -device sga",pty 

    # Looks the best, but the sgabios device sends a lot of extra characters that make it unplayable
    # plus input response is really slow (or nonexistent, basically input gets lost or hard to see)
    #export TERM=linux
    #socat -d -d FD:${SOCKET_HANDLE} EXEC:"qemu-system-i386 -localtime freedos.img -hdb fat\:ro\:${BBS_TEMPDIR} -parallel none -monitor none -nographic -device sga",pty 

    # Actually works the best from a playability perspective, but the ANSI write out to curses 
    # isn't clearing properly so the display is usually garbled
    # This is the most straightforward and "works" and probably has the best chance of 
    # being "fixable"
    export TERM=ansi
    qemu-system-i386 -localtime freedos.img -hdb fat:ro:${BBS_TEMPDIR} -parallel none -monitor none -serial none -curses

    # Old dosemu version, kept around for historical reasons
    #dosemu -f ${WWIV_DIR}/.dosemurc_msdos -I "dosbanner 0" -E "tw2002.bat ${NODE}" 2>/dev/null 
fi

Chain setup

A) Description  : TW2002 v3.09
B) Filename     : tw2002.sh %N %C %H
C) SL           : 255
D) AR           : None.
E) ANSI         : Optional
F) DOS Interrupt: Used
G) Win32 FOSSIL : No
H) Native STDIO : Yes
I) Launch From  : BBS Root Directory
J) Local only   : No
K) Multi user   : Yes
L) Registered by: GRANITEPENGUIN
M) Usage        : 224
N) Age limit    : 0 - 255

I've fiddled with F and H so far. F doesn't seem to matter, and haven't tried Fossil at all

Edit setup

Node number: 1
<A> Path to Data files  : <Default Directory>
<B> Path to Drop file   : d:\
<C> BBS Drop file type  : WWIV
<D> Hardware Handshaking: Yes
<E> Active Node         : Yes
<F> Comport 1 to 16     : 1
<G> Override port Addr  : 03F8
<H> Override port IRQ   : 4
<I> I/O Type            : Standard