Retro Challenge 2017/10 – Returning to Zork

After what felt like a lot of aimless bumbling around and poor progress on the first streamed game of Zork, I decided to take a peek at a walkthrough solution before playing this.

The last live stream finished off with me getting frustrated with not being able to undo a bolt at the Dam, despite having a wrench.  A peek at the walkthrough mentioned pushing a yellow button in the control room first.  Really?  Like, how was I supposed to know that?  Ok, I’ll admit that I hadn’t spotted any of the buttons in the control room (there was a lot of text bombarding me as I arrived in there), but if I had, I would have probably pushed all the buttons.  I don’t know if you must push only the yellow one, or if pushing them all would render the bolt still unturnable, but if this is the level of puzzle I’m supposed to solve, then it’s unlikely that I’m going to make too much progress after this part.

So, instead, I decided to print off the first couple of pages of the walkthrough, and planned to just follow along with it.

The live stream started at 7pm on Thursday evening, and the set up was the same as the previous one.  The only difference was that I’ve now upgraded from the free version of Wirecast to a licence one with no interruptions.  There was 5 viewers on YouTube and 4 on the text stream, although towards the end I spotted a tweet from a viewer that was unable to connect to the text stream (Sorry!), but I never found out if it was a problem at my end or his.

The first thing I wanted to do was test out the instructions on pushing the yellow button before undoing the bolt.  Sure enough, this worked!  However, there were a few other things that I’d missed out between the start and the dam.  I could have possibly caught up with those in a different order, but decided to quit this game and start afresh.

Progress went well, and within an hour I had completed around 50% of the game.  Some of the walkthrough was invaluable.  I can imagine I’d have ended up stuck in the maze for ever, and probably unable to map it too, but when the walkthrough tells you to just go northwest, south, west, up, west, southwest, and northeast, it is much more enjoyable.  Even following along on the map this was hard to work out.

I feel like I’ve successfully completed the Retro Challenge I set myself, and I’m happy that things went pretty well.  As I’ve mentioned before, I’m not much of a text adventurer, and I don’t think this experience has changed that.  Zork was actually better than I thought it would be, and at some point I’ll play through the 2nd half of the walkthrough.  The best part for me, however, was the technical side of things, and hooking up an ESP8266 as a wifi link for the RC2014.  There seems to be a few different bits of ESP8266 software that will add value to the RC2014, so I’ll be developing a proper ESP8266 Module soon.

A big thanks to those that have followed along with this blog, via Twitter, and, of course, via YouTube and the text stream.

Transcript of this adventure here;

If you need to watch the YouTube stream, it can be found here https://youtu.be/K-Kv5saIHyE

Retro Challenge 2017/10 Zork First Stream

At 7pm UK time on Sunday (yesterday), I did the first Zork live stream.  This post is going to look back at how this went, from a technical point of view, from my point of view as a new YouTube streamer, and from the point of view of a non-adventure gamer playing Zork for the first time.

There was two aspects to the hardware.  The RC2014 running Zork was almost completely stand-alone.  It had it’s own keyboard and monitor, and the only connection to the outside world was via the ESP8266 module.  The ESP connected to the internet over Wifi, and streamed everything that was sent to the monitor via web sockets.  The Tx line from the ESP also went to a laptop so that I could monitor how many connections were open.

The laptop was also running Wirecast, and streaming it’s webcam and microphone to a live (live-ish.  About a 10 second delay) YouTube feed.  I could then talk, mumble, gesture, or use the chat feature, as well as read the chat messages as they came in.

Overall, this worked reasonably well – however there were a few things that could have been better.  About 20 minutes in, there were a couple of people complaining that they couldn’t connect to the text stream from the ESP.  The 3 people still connected were ok and getting updates, but nobody else could connect.  After a reboot everyone could connect and I was streaming to an audience of 5.  There was a report of odd characters being sent, although I think this was only when I used the delete key, which couldn’t be displayed properly in the live feed.  Also, there was still the issue with some lines being truncated.  If anybody viewing has kept a transcript, it will be interesting to compare with my transcript to see if they are both truncating at the same point (indicating a dropout between the web socket server and the ESP), or if they are different (indicating a dropout between the web socket server and the viewer)

I felt a bit awkward on YouTube.  It was kind of odd, and I couldn’t quite decide if I should just be playing Zork on my own and ignoring everyone looking over my shoulder – or if I should be ‘performing’ for the audience and involving them more.  As someone that isn’t that comfortable in front of the camera, and not good at text adventure games, I am beginning to question my life choices that lead to me narrating my fumbling through a troll filled underworld live on YouTube :-/

Although I had loaded up Zork a few times in the past, I had never gone further than randomly typing in directions, or going in to the house.  So I really was treading new ground here.  One of the things that surprised me for a 40 year old game is just how large the place is, and how much is going on.  I didn’t realise that there would be other characters that moved around, stole things from you and dropped things in different rooms.

The first game didn’t last too long, after picking a fight with the thief left me injured and a troll finished me off.  So I restarted the game, and decided to take a different approach in attacking the thief – but was surprised to find he wasn’t where he was in the previous game.

I did find myself questioning my motives here though.  Basically, I broke in to somebodys house, took all of their possessions, and tried to kill the first person I met.  I should be asking myself who the bad guy is in this game!

I had downloaded a map from the internet to make things a little bit easier for me.  It saved me from trying to go in directions that didn’t exist, and meant that I didn’t have to map things out for myself as I went along.  However it didn’t mean that I could just get to where I thought I wanted to go.  For example, once I went downstairs from the house, I couldn’t get back up again.  Well, one way up was up an unclimbable slope, one was up through the trap door that was locked behind me (probably by the house owner after I stole his lunch), and the stairs to the kitchen could only be climbed if I dropped most of what I was carrying.

Eventually I ended up at the Dam, and there was a control panel with a bolt and a green bubble on it.  In the Maintenance Room I found a wrench.  Also a tube of magical gunk.  So, surely these things were all related, and something good would happen if I could remove the bolt.  But no matter what combination of words I used, it just wouldn’t do anything.

I’d been playing for an hour by this time, so decided to call it a day for now.  I’ll resume again soon, although I can’t promise that I won’t have looked up how to remove the bolt before I try again :)

A transcript of my adventure can is below

The YouTube stream can be found here https://youtu.be/Gdjq2Rb9y64 But, really, it’s probably not going to be one of those thing I expect anybody to sit through!

 

Retro Challenge 2017/10 – Live Zork Streaming Soon

Firstly, apologies that not much has happened recently.  I’ve been under the weather for the last few days, so only made minimal progress.  However, feeling a bit better, so Tonight I will try streaming Zork!

I am planning to go live at 7PM UK time tonight for around an hour (If you’re not in the UK, see this countdown timer).  If you missed it, I’m sorry – but I hope to have a transcript up soon, and will probably do it again shortly.

There will be a tweet beforehand with links to connect to, so if you don’t follow @ZXSpectROM on Twitter, click here to view

Essentially, there will be two aspects to the streaming.

  • Primarily, there will be a RC2014, running CP/M, with Zork on it.  This machine will have the ESP8266 Wifi bridge, and everything that is sent to the screen will also be sent to http://tzapu.github.io/WebSocketSerialMonitor/ via web sockets.  This machine will also be using one of the old parallel 80’s keyboards I investigated in the last Retro Challenge (It’s important to point this out so you’ll cut me some slack with all the inevitable typos that I know I’ll make with this keyboard layout).  This will be the live stream of Zork, which is essentially the goal of this Retro Challenge.
  • A live stream on YouTube will also take place.  Well, live-ish.  Apparently there’s a 10 second delay, so that might be a bit odd.  However, the main reason for this is to provide a feedback loop for those watching along at home via the YouTube Chat function.  I’ll have a laptop set up next to the RC2014 so I can see any comments as they come in.  So, if I forgot to pick up an object in a room, or you think I should go north instead of east, you can let me know.  It will be streaming video from a webcam too, but don’t expect that to be too exciting.  (Seriously, you’ll be watching a 40 year old ASCII based text adventure game being played by somebody that isn’t good at text adventure games, and the webcam footage will be LESS exciting!)

 

So, that’s the important stuff that you need to know to follow along tonight.

In other news, as I was happy enough with how the prototype PCB seems to be working, I’ve laid out a real board now.  The PCBs are currently being manufactured in China, although it isn’t looking likely that I’ll get them back before the end of this particular Retro Challenge.  But if I do, then expect an update here!  Here’s a sneaky peek at what they should look like though;

 

Retro Challenge 2017/10 Testing

The initial testing of the ESP8266 board with the RC2014 was pretty good, and fundamentally it worked.  However, it wasn’t quite right, and I suspected that the problem was to do with CR or LF.

The code I was using was found here; https://github.com/tzapu/WebSocketSerialMonitor (Thanks Tzapu!).  It uses web sockets, and allows an external web page to connect through to the ESP8266.  So, by going to http://tzapu.github.io/WebSocketSerialMonitor/ and connecting to ws://x.x.x.x:81/ws (where x.x.x.x is my external IP address and a firewall rule is set up to forward port 81 through to the internal address of the ESP) it will display everything the ESP receives on its Rx pin.  Well, almost everything, but not quie everything.

If, for example, I did a directory listing which was 2 full lines and a little bit more on the 3rd line, only the first 2 lines would show up.  If I’m playing Zork, sometimes it would show the whole chunk of text as it came in, other times it would miss the last line.

The code itself is fairly easy to read, although the complicated web sockets stuff is hidden away in libraries.  This is the part of the routine that reads the serial input until it detects a CR (the ‘\n’ part), where upon it then sends the line;

I figured that adding a check for a LF would do the job;

But, sadly, it didn’t.  If anything, it made it worse.  So, instead, I tried just reading a set amount of characters (10 initially) and sending them regardless of a CR or LF, but that didn’t work either.  When I got it to send every character without checking, it worked much much better, although if I sent a very large chunk of text it would miss random bits of it.

So, the problem seemed to be speed related.  The checking for CR was a nice idea by the original author, but it wasn’t something I needed, so time to strip out all the surplus code.  It went from this;

to this;

Much simpler, and it seemed to work perfectly!

All the testing up until this point was done either on my laptop or mobile.  Although they are on the same wifi network as the ESP, it’s connecting out to an external web page before coming back in, so it should be a reasonable test.  But there’s nothing like real people connecting in to really see if it works.  So, I put a shout out on Twitter, and on Saturday evening, 4 willing volunteers sat there watching me do random things on the RC2014.

Feedback was pretty good, and it all seemed to work as expected.  Thanks Thilo for this screenshot;

I messed about with simple programs in BASIC, directory listings, and the opening moves in Zork, with success.  In a moment of madness, I fired up Wordstar.  When the RC2014 is connected to a VT100 terminal, it works great by using escape codes to set where things are on the screen and what colours are used.  However, these escape codes don’t render at all well on the web sockets interface.  Thanks Dave for showing my just how bad it looked!

So, yes, I should have known that Wordstar would be pushing it a bit far.  But otherwise, I was very pleased with the performance.

The biggest problem I had, though, was that of feedback when interacting with the “audience”.  I could type short sentences in to Zork that the viewers would see and understand, even if the Zork engine couldn’t interpret it.  But, of course, there was no live feedback from the viewers.

I’m not sure what the solution to that will be, but it could be as simple as keeping Twitter open on my phone.  Alternatively, things like IRC or Slack could be used (although I don’t want viewers to have to jump through hoops to get connected to me).  Skype might be an option too, although, at the moment, I think it’s more likely I’ll set up a YouTube live stream and use the chat feature in that.

For those wondering about the set up that I’m using, it’s pretty much a stock RC2014 Pro with a Pi Serial Terminal and the ESP8266 prototype I built for this project.  The Pi Zero is connected via a HDMI > VGA adapter, and then to a 17″ monitor.  The keyboard is this Cherry keyboard from the last Retro Challenge.  Note that the key layout is sufficiently different from what I’m used to that typos aren’t too uncommon yet.

The laptop is there to program the ESP, and to monitor it’s output.

I am aiming to have a live run through on Friday, so that gives me a few days to look in to the feedback options.

Retro Challenge 2017/10 Getting Started

So, the idea of streaming the RC2014 to the internet had been rattling around in my head for a while, but I’d never quite worked out how the software side of things would work.  Although the hardware side should be kind of straightforward, with my software skills, I need to find something I can copy & paste.  A couple of days ago I just happened to put the right search terms in to Google and it gave a result that looked like it would do want I wanted.  So, with that, my plan for Retro Challenge took shape!

A couple of years ago I played around with some EPS8266 Wifi Modules, but never really found a use for them.  However, for this, they would be ideal.  The code I had found was a Web Sockets Serial Monitor designed specifically to run on an ESP8266, so I decided to test it out just to check that it did what I expected it would.

Several hours later, it did!  Those hours, however, were spent trying to remember how to program these things.  My desktop machine didn’t have any of the ESP stuff in the Arduino IDE, but luckily, I still have my old laptop that I used a couple of years ago.  Despite getting all the right libraries, it just wouldn’t compile.  So, on to the new laptop, with a fresh Arduino IDE and all the ESP stuff and libraries, and it compiles.  Getting it to upload, however, was another challenge which actually involved burning myself on the USB to serial adapter at one point!  It turns out that of the two I tried, one of them was dead, and the other one spammed my Twitter account ever time it’s turned on (I didn’t know this until checking Twitter later… what!  86 new mentions!).  It also turns out they need more power than the adapter can supply.  And, in order to program them, the ESP needs to be pushed in to the adapter really really really hard!

The programming jig wasn’t really suitable for testing things out, so time to transfer this to a prototype board.  But first, lets work out a circuit!  The programming jig has the necessary support components and minimal connections, so that’s a good start.  The ESP works on 3v3, so I’m going to need a regulator to drop the 5v down.  And the Rx pin is only 3v3 tolerant, so a couple of resistors as a voltage divider will work fine as a level shift here.  The Tx pin won’t be connecting to the RC2014, although even if it was needed, 3v3 is sufficient enough to work.  GPIO0 is used to either put the ESP in to programming mode or run mode.  2 of the other GPIO pins (15 and 2) were tide to ground and 3v3 respectively on the programming jig.  I can’t remember why I did that, but that won’t be needed for this board.

Before hooking up the ESP to the power rails, I checked that the regulator I used (spare one I had lying around) did it’s job.  Yup, 3.299v, close enough!  On with adding the rest of the stuff.

So, from left to right, we’ve got a connector for 3v3 so it can be powered directly if needed (or use 3v3 elsewhere), and an FTDI header for my 3v3 adapter so the ESP can be reprogrammed.  Then there’s a reset button, the 3v3 regulator and caps, then the ESP itself.  There’s a 10k pull up resistor on the reset pin, and a program/run jumper below the ESP.  As yet, the resistor divider for the Rx pin aren’t fitted.  But it should power up and work just as it did in the jig, right?

Ummm… no.  Regardless if I used the power regulator, or fed 3v3 in directly, out of the serial header all I got was gibberish.  It was consistent gibberish, but not something I could make any sense of.  Maybe I damaged the ESP when soldering the wires on?  Hmmmm… maybe I should program another one just in case.  Well, long story short, it needs GPIO15 connected to ground to work!  I can’t see any logic why this would need to be the case, but, whatever, it works now.

I needed to add a rule on the firewall to allow port 81 through to the IP address of the ESP, and after that, I could connect from the outside world and see what my RC2014 was saying!

Things work pretty well, although there’s some kind of issue with carriage returns and/or linefeeds that’s causing some stuff to be dropped, but that’s enough success for one day.  We’ll sort that out tomorrow!

Retro Challenge 2017

Ok, with 5 days of October already gone, I know it’s cutting things a bit fine for putting my entry in for this seasons Retro Challenge – particularly as it started 5 days ago… but, better late than never, right?

So, what have I planned to do that is both retro and challenging? Simple, I’m going to play games! More specifically, I’m going to play Zork, on a CP/M enabled RC2014 that is connected to the internet so it can be streamed live to an audience of anybody that cares to watch me get eaten by a grue.

The first challenge is going to be hooking up the RC2014 to the internet, such that it can stream text. Kind of like Twitch, but in ASCII. Luckily, I’ve got a bunch of ESP8266 modules that have been sitting in a drawer, and I think these are likely to be ideal for converting serial data in to web pages.  I should be able to hook up something on breadboard, and find a bit of code that does the job – although it would be nice if I can get some real PCBs made up for the job.  With just over 3 weeks to go, though, that might be pushing it timewise.

Then there is the challenge of Zork itself.  I often use it as a test game to show people what the RC2014 can do, however, I’ve never done more than a bit of random North, North, East, Look, Get Lamp etc.  I’ve never really played many text adventures either, so this will be a big learning experience for me.  I can’t promise that I won’t use the odd cheat/clue here and there, but if there are actually people watching along online, I’ll happily take suggestions over Twitter.  If things happen to go really well, and I complete it in good time, then I will add Adventure as a stretch goal.

Precision Laser Cut Resistors

Since the first days of selling RC2014 kits, I’ve been cutting resistors off of bandoleers.  Depending on the kit, they might be singular, or in groups of 3, 4, 5 or 8.  To cut off a single resistor with a pair of scissors is very quick and simple.  However, doing it time and time and time again, or having to count to cut them in to blocks of 5 can get time consuming and monotonous.  Of course, there are industrial machines to automate these, but they cost a lot of money and are designed for doing thousands per day.

Then there are more hobby level machines, like this one from Oomlout.  If I had a laser cutter, some servos, an Arduino and a few other bits, I could make one of these.  So, when I purchased a laser cutter recently, building one of these was on my to-do list.

At some point, the redundancy became obvious.  Why use a laser cutter to make a cutting machine – when the laser cutter is, itself, a cutter!  So, 5 minutes with InkScape and I had a basic template ready to test

The template consists of 2 parts.  The first, larger piece goes on the bed of the laser cutter.  A strip of resistors is decanted on to the firsts part so that the resistors themselves sit in the holes running down the middle

The second half of the template then clamps the resistors in place and is held down with magnets (Note that the following photo was taken after they were cut!).

The laser cutter then cuts the tape!  Depending on the template, this could be in groups of 1, 2, 3, 4, 5, 8 resistors.

 

And voila! Precision laser cut resistors!

The dxf file for this is available to download on Thingiverse so you can laser cut your own resistors.

This is the first iteration of this, and it works surprisingly well.  Set up time isn’t too long, but if you only need a few resistors cut off, you’re better off doing them the old fashioned way with scissors.  But for running off a batch of a couple of hundred or more, it’s certainly quicker and easier.

The lower part of the template will get repeatedly cut on the intersection of the resistor tape, and sooner or later this will need replacing.  When that happens, I’m going to replace it with a much longer version, so I can do a lot more in one go.  I’m also wondering about having a few tapes in parallel for even more speed – but this might be at the risk of mixing up different value resistors.

So, the next time you get a RC2014 kit, just take a moment to marvel at the precision at which your resistors have been trimmed off of the tape!

Backplane Motherboard Lacing

Having the ability to isolate some slots on the Backplane 8 can be very handy at times, and putting some protection in between modules can be very worthwhile.  However, if you want to connect the outer slots, then soldering little links can be fiddly and time consuming.

 

Thankfully, there’s a quick and easy way to do it.

The photos are probably self explanatory, but get a length of 300-400mm of stripped solid core wire and solder it through one hole to hold the end in place.  Then lace it all the way down, going horizontally on the top of the board and diagonally underneath.  Don’t worry if it’s not too neat underneath.  Solder each joint (I find it easiest from the top before all the sockets are in place, or from underneath if they are already fitted).  Then simply cut all the diagonal links off of the underside.  Job done!

 

Decoding ROM labels

Back in the earliest days of the RC2014, it came with a pre-programmed 64k ROM, with Microsoft BASIC on it in the first 8k, and it would work with 32k of RAM and a 68B50 ACIA.  One set up, one ROM, life was simple!

As time has gone on, and more options have become available, other ROM images, such as Microsoft BASIC for 56k RAM, or CP/M Monitor have been introduced.

Future possibilities, such as other UARTs, different CPUs or other variations will inevitably lead to more ROM images being needed.  So, in order to keep track of what is programmed where, ROMs are now being shipped out with a label on them.

Every ROM now has an 8 digit code on it.  Each digit, from left to right, refers to an 8k bank from 0x0000 to 0xD000.  This bank can be selected with the A13, A14, A15 jumpers;

Address A15 A14 A13 ROM Label
0000 0 0 0  Xooooooo
2000 0 0 1  oXoooooo
4000 0 1 0  ooXooooo
6000 0 1 1  oooXoooo
8000 1 0 0  ooooXooo
A000 1 0 1  oooooXoo
C000 1 1 0  ooooooXo
E000 1 1 1  oooooooX

 

The value of the digit represents the ROM image that sits in that particular 8k bank.  Currently, it will be one of the following;

0 – Empty bank, available for user to program

R – Microsoft BASIC, for 32k RAM, 68B50 ACIA, with origin 0x0000

K – Microsoft BASIC, for 56k RAM, 68B50 ACIA, with origin 0x0000

1 – CP/M Monitor, for pageable ROM, 64k RAM, 68B50 ACIA, CF Module at 0x10, with origin at 0x0000

2 – Microsoft BASIC, for 32k RAM, SIO/2, with origin 0x0000

4 – Microsoft BASIC, for 56k RAM, SIO/2, with origin 0x0000

5 – Microsoft BASIC, for CP/M installation,64k RAM, 68B50 ACIA, CF Module at 0x10, with origin at 0x2000

6 – CP/M Monitor, for pageable ROM, 64k RAM, SIO/2, CF Module at 0x10, with origin at 0x0000

 

As more ROM images are added, this list will be updated.

 

Standard factory ROM images can be downloaded from Github https://github.com/RC2014Z80/RC2014/tree/master/ROMs/Factory

The RC2014 currently uses a very simple, although inefficient method of addressing peripherals.  Most of the expansion modules feature a 74HCT138 used to provide up to 8 enable lines from 3 address signals.  For the purposes of this document, I will mainly refer to the Digital I/O Module, but the principals apply to all modules with a 74HCT138 (generally referred to simply as ‘138)

It is worth noting that the Z80 CPU can address up to 255 Input or 155 output addresses.  These are selected by the first 8 address lines (A0 – A7), IORQ going low and either WR or RD going low.

The ’138 has 3 enable pins, G1, G2B, G2A, all of which need to be true (G1 needs to be high, and both G2B and G2A need to be low) for the ‘138 to be enabled.  When it is enabled, the 3 address lines, A0, A1, A2 are read.  These 3 addresses have 8 possible combinations (000, 001, 010, 011, 100, 101, 110, 111), which will activate one of the 8 outputs Y0 to Y7.

In the Digital I/O Module, the ‘138 is activated when M1 is high, IORQ is low and A7 is low.  This corresponds to any port from 0 to 127 (IORQ being low indicates the address bus represents port, and A7 being low indicates the address bus is lower than 127).  [Side note – Serial I/O Module uses addresses 128 and 129, which are indicated by A7 being high].

The Z80 address pins A0 and A1, along with WR are connected to the address pins A0, A1, A2 on the ‘138.  This gives 4 addresses (00, 01, 10, 11) with the write bit high, and 4 with it low.

In normal use, the ports are addressed as 0 (In 0 or Out 0) on the Digital I/O Module.  (Or port 0, 1, 2 on the Digital Input module, for example).  However, any address that has A0, A1 and A7 low will work; 0—–00.  So echoes of this will appear on 4, 8, 12… 124.  So, whilst this works, and is fine for a small system without much I/O requirements, it quickly becomes inefficient as you need more ports.  In particular, it will clash with the Compact Flash Storage Module, which can have an impact on running CP/M.

In an ideal world, every peripheral should have a unique address, and with a lot of digital logic, this is certainly possible to do.  However, it will add both complexity and cost as well as needing more board space.

The easy solution, however, involves just 6 diodes and a resistor.  By connecting address lines A2 – A7 to the anode of each diode and the cathode of each diode to the G2A enable pin on the ‘138, any address above 00000011 will prevent the ‘138 from being enabled.  Effectively all the diodes are acting as a very simple OR gate.  A 10k resistor will bias the output low.

So with this set up, it will give just 4 unique addresses; 00000000, 00000001, 00000010, 00000011 (ie 0, 1, 2, 3) which for the Digital I/O Module, or the Digital Input or Digital Output is ideal.

Other addresses can be selected by changing which address pin the diodes are connected to.  So, for example, if A1 was connected to a diode instead of A3, and A3 went to the ‘138, the addresses would be 00000000, 00000001, 00001000, 00001001 (ie 0, 1, 8, 9).  Whilst it cuts down on the echoes at higher addresses, it’s still not perfect – but much better and still very cheap with minimal extra board space needed.

The Digital I/O Module has now been updated to reflect this change.  As PCB stocks run low on other modules, they too will have similar updates.  If you already have a non-diode selectable module, and wish to implement this, it is actually very simple to do as shown below.