A very long time ago I used telnet talkers. Around the time that ICQ was popular and before MSN Messenger. gerph, who was very well known in the RISC OS scene (and went on to work for RISC OS Ltd working on RISC OS 4), wrote a telnet talker in BASIC called TalkerD to demonstrate his excellent EasySocket library and I adapted TalkerD to be more NUTS-like. This became known as RISCtalk and Andrew Poole took it over when I lost interest.
Back in the day I remember having conversations with the late Paul Vigay about running RISCtalk on an Acorn machine within Argonet. The problem was twofold. Acorn machines were expensive and RISC OS is a desktop Operating System designed to have a single user sat in front of it. Trying to manage RISC OS remotely wasn’t easy, especially as RISC OS uses cooperative multitasking (CMT) so if an error box appeared on the desktop, nothing else would respond.
Today’s problem is that the EasySocket library only works with the older 26-bit generations of hardware and RISC OS. The solution has always been RPCEmu and recently version 0.9.4 was released that implemented port forwarding for NAT.
Now the world can connect to RISC OS. Which means RISCtalk can be resurrected. Mainly for nostalgia and comedy purposes. Using RPCEmu to host a RISC OS server solves all of those issues I mentioned previously. Here is how I’ve cobbled together a Linux host to run RPCEmu to run RISC OS to run RISCtalk.
The Linux host is Debian. It’s actually a VM running RPCEmu inside it. It runs Xorg to provide a display server and openbox to provide a Window Manager. VNC provides a way to remotely interact with RPCEmu and there’s a bash script that’s invoked using cron that checks if RISC OS running inside RPCEmu is alive or not and if not, takes a screenshot and restarts RPCEmu.
First install your Linux flavour of choice. Then install Xorg (or Wayland) along with openbox. Fluxbox, IceWM et al will also work. You don’t need a Display Manager such as lightdm or gdm. You’ll also need to install x11vnc, vncsnapshot and xrandr (on Debian/Ubuntu, xrandr is part of x11-xserver-utils). Create a normal user called (for example) rpcemu.
Log in as the rpcemu user and download and compile RPCEmu. I’m using the dynamic recompiler which seems to work well. Symlink the rpcemu directory, e.g:
$ ln -s rpcemu-0.9.4 rpcemu
Create an autostart file for openbox:
$ mkdir -p ~/.config/openbox $ cat > ~/.config/openbox/autostart <<EOF xrandr -s 1366x768 x11vnc -N -nevershared -forever -xkb -skip_keycodes 187,188 -bg while /bin/true; do sleep 1 && cd ~/rpcemu && ~/rpcemu/rpcemu-recompiler; done EOF
When openbox is started it will:
- Set the resolution to 1366×768.
- Start x11vnc – note, no password is required.
- Start RPCEmu and if it’s quit (intentionally or otherwise), start it again.
By default only root and users logged in to the console can start an X server. Change this by editing /etc/X11/Xwrapper.config and changing allowed_users to be anybody. If you’re using Debian or Ubuntu you can also run dpkg-reconfigure xserver-xorg-legacy and select Anybody.
$ xinit openbox-session -- :0
Now try connecting to the Linux host using VNC. You should see RPCEmu running and probably complaining there are no ROMs.
Configure the RISC OS side of things next. I’m using RISC OS 3.7 under RPCEmu. Once you have everything configured how you like it, run the !Alarm application and create a new alarm task that runs every minute and runs the command: Create Boot:Choices.alive
Save the Alarm in to Boot:Choices.Boot.Tasks so that the alarm runs when RISC OS boots. What this will do is create a file called alive in Boot:Choices. The modify timestamp on the Linux host will be updated every time this runs under RISC OS. Therefore it’s possible to check that RISC OS is alive from the Linux host and restart RPCEmu if things have gone wrong.
Create a bash script called check.sh within $HOME:
$ cat > ~/check.sh <<EOF #!/bin/bash pgrep rpcemu >/dev/null || exit 0 epoch_mtime=`stat -c %Y ~/rpcemu/hostfs/\!Boot/Choices/alive\,ffd` || exit 0 epoch_now=`date +%s` if [ $(($epoch_now - $epoch_mtime)) -ge 300 ] then echo "RISC OS has not responded for 5 minutes or more. Killing RPCEmu." vncsnapshot -quiet 127.0.01 ~/crash_`date +%s`.jpg >/dev/null 2>&1 pkill rpcemu fi EOF $ chmod +x ~/check.sh
This script will:
- Check if RPCEmu is running. If it’s not, it exits (RPCEmu probably isn’t running for a reason).
- Get the modified timestamp of the alive file inside HostFS.
- If the modified timestamp is >= 5 minutes, it assumes RISC OS running inside RPCEmu is non-responsive and:
- Using VNC, will take a screenshot (saved as $HOME/crash_unixtimestamp.jpg) so you can see what was on the RISC OS desktop.
- Kill RPCEmu (remember that the openbox autostart script will run RPCEmu again if it quits).
Then add two cron jobs. One to start X and run the openbox Window Manager (which in turn starts RPCEmu) and one to run the check script every 6 minutes:
@reboot xinit openbox-session -- :0 >/dev/null 2>&1 */6 * * * * ~/check.sh
It’s also pretty impressive that I have RISC OS running in an emulator, running on a Linux VM, running on a NAS that’s using an Intel x86 processor. Far more robust than any native hardware.
At some point I’ll make RISCtalk running on my RISC OS server available to the Internet. First I need to fix a few bugs which means needing to remember how BASIC works. Also the source code is, interesting. Lots of code reuse, variables that are just letters (a$, i%), hardly any indentation or whitespace and nearly no comments. But it works. Mostly.