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;

void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == '\n') {
      stringComplete = true;
      return;
    } else {
      inputString += inChar;
    }
  }
}

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

if (inChar == '\n' || inChar == '\r') {

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;

void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == '\n') {
      stringComplete = true;
      return;
    } else {
      inputString += inChar;
    }
  }
}


void loop() {
  serialEvent();
  if (stringComplete) {
    
    String line = inputString;
       // clear the string:
    inputString = "";
    stringComplete = false;

    //line += '\n';
    webSocket.broadcastTXT(line);
    Serial.println(line);
  }
  webSocket.loop();
}

to this;

void serialEvent() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    inputString += inChar;
  }
}

void loop(){
  serialEvent();
  webSocket.broadcastTXT(inputString);
  inputString="";
  webSocket.loop();
}

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

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.

Retro Challenge 10/2016 – Still a work in progress

So, who remembers my entry for Retro Challenge in January?  It was quite devoid of effort and results I think you’ll agree.

Well, this time around, I’ve taken that theme and pushed it even further!  Even less effort and much less result.

Since January, I have had a few opportunities to carry on with the ZX81 Module.  Because I wanted this to be a Retro Challenge project, I deliberately avoided doing any work on it, so I could save it all for October.  Well, October started and I was overwhelmed with non-Retro Challenge stuff.  But after a couple of weeks, I had a spare afternoon, and decided to dedicate this to the ZX81 Module!

So, I dug out the PCBs I had manufactured in January and fired up the soldering iron;

retrochallenge10-2016_1

Time to wrack my brains and work out what my plans had been 9 months earlier.  I had failed to put any component values on the PCB, or even my Kicad schematics, so had to rifle through original ZX81 schematics to work out what these should be.

Now I knew what components I needed, it quickly dawned on me that I didn’t have very many of these at all.  This didn’t deter me though.  I fitted everything I had; IC socket, pin headers, some resistors and some transistors that may or may not be compatible;

retrochallenge10-2016_2

And that’s about it.  I have ordered the rest of the parts now, but not had an opportunity to fit them.  yet.

One thing I have learned from this experience though, is that if I get any opportunity or urge to work on this, then I will seize it.  Not wait until the next Retro Challenge.  If I’d done work on this months ago when I had the chance, then this would more likely be a trouble shooting / tweaking / developing challenge.

One other good thing that has come out of this though, is that when I started this in January, I had a few design changes or additions required for the RC2014 for it to work.  The Backplane 8 has the ability to add resistors between the CPU and the RAM.  The Universal Micro Keyboard has the right connections to work with a real ZX81 or this ZX81 Module (including diodes).  The CPU Module also now has BUSRQ, WAIT, NMI and WAIT pins broken out which is required for this.  These changes should all make things much easier.

Despite my poor efforts this time around, I have thoroughly enjoyed seeing what everybody else has achieved with their Retro Challenge.  Good work everybody else!

Retro Challenge 2016 – My Dog Ate My Homework

So, all the way back in deepest darkest December, I announced I would enter the Retro Challenge 2016 competition that ran throughout January.  Those of you that followed by blog or Twitter account when I did this in 2014 will know that I blogged and Tweeted relentlessly for the whole month, but, this time around, almost nothing.  Obviously, I’m keeping some secret about an amazing breakthrough or something, right?  Well, truth is, I’ve done almost nothing.

Things started well, and on 1st January, I designed a new backplane for the RC2014.  Although I hadn’t studied the circuit diagrams for the ZX81, Jupiter Ace or ZX Spectrum yet, I knew that there were resistiors between the Z80 CPU and other devices.  The stripboard backplane I’d been using had served me well, but it was time to progress to a better solution, and one that could be adapted better to my needs.  Knowing that PCB delivery times could be against me, I thought it best to crack on and get this  ordered.

Screenshot from 2016-01-31 16:01:00

The basic circuit is very very simple – however, I wanted to get this just right, not only for Retro Challenge 2016, but for other possible RC2014 uses.  Essentially, there are 8 40 way connectors that are linked straight through – however, the data lines and address lines for the leftmost 2 connectors and rightmost 2 connectors are separated by a pair of pads.  These can either be shorted together for up to 8 commoned connectors, or have resistors soldered across them.  I also added a power connector and the option of either running 5v directly in to the board, or regulating a higher voltage down via a LM7805.

(more…)

Retro Challenge January 2016 – Preamble

So, you may well remember that I entered Retro Challenge 18 months ago, and what a fun crazy busy time that was!  Well, the January Retro Challenge competition is about to kick off in just over 2 weeks.

If you’re not familiar with Retro Challenge, shame on you!  But you can de-shame yourself by heading over to http://www.retrochallenge.org/ and seeing what it’s all about.  Essentially, it’s a month long bi-annual competition where the entrants set themselves a goal based around old school computing and blog, tweet and share their experiences.  The goals are pretty loose, as long as they are based on something from last centuary (modern emulators of old kit is fine).

The challenge I set myself was to take a breadboard based Z80 computer and bring it to life in modular PCB form in such a way that I could spell out my name on.  Have a look back through my blog to see how I did.  Spoiler —->

IMG_20140730_205950

(more…)

RC2014 Bootloader for SD Cards

So, the RC2014 is great.  I can run Microsoft BASIC and program it from there, and as long as I am using a terminal emulator, I can copy & paste to save and load programs.  Alternatively, I can write Z80 code using an online compiler then download it, copy it to USB stick, move it to my old Windows 2000 laptop (which has a parallel port) so I can burn it on to EPROM to see if it works, make adjustments and repeat with another EPROM.

I will be the first to admit, however, that this is probably not the most efficient workflow.  Not to mention the time and effort involved in wiping the limited stock of aged EPROMS.

So, I am in the process of designing an SD Card based bootloader.

i (2)

(more…)

RC2014 with ZX Printer interface

My original plan had never been to design and build my own computer.  I had, however, planned to build a clone of the Sinclair ZX80, which has been on my bucket list of things to own for year, and which I had found plans for online.  Whilst collecting the parts and reading up on simple Z80 computers I got kind of sidetracked and ended up with the RC2014.

The print out shown was what was left from the last time this was connected to a ZX Spectrum!

The heart of the RC2014 is a Zilog Z80 CPU, which is the same one that Sinclair used in the ZX80, ZX81, ZX Spectrum and Z88.  If the ZX81 and ZX Spectrum can run a ZX Printer, then surely it follows that the RC2014 will be able to too?

(more…)

Assembly Language Vs Lego

I guess this is kind of a follow up to my Retro Challenge posts, as it was thoughts that stemmed from teaching myself Assembly Language for my Z80 project.  Essentially it is a comparison between programming in the 70’s and today against building with Lego in the 70s and today.

lego_thesimpsons

But before I get stuck in, can you identify this famous TV family from a few crude Lego bricks? (more…)

Retro Challenge – Closing Thoughts

Wow! What an awesome month July has been.  The whole Retro Challenge thing has been great, and despite moments of stress or despair, I have thoroughly enjoyed taking part and seeing what everyone else has been up to.  Before I sum up my project, I should make a few honourable mentions.

Retro Challenge – A huge thanks to Mark and Wgoodf do a great job in hosting this twice a year.  Keeping everyone updated via Twitter has worked really well.  Cheers guys!

Grant Searle is responsible for the general Z80 design I used and also converted MS BASIC from the Nascom to run on this.  Really, this project is a test of my understanding of Grants work and seeing how far I can take things.

Nottingham Hackspace has an amazing “parts bin” that included the LEDs, Veroboard, case, some of the logic chips and the RAM I used.

OSHPark did a great job (for a very good price!) on the PCBs – even if the postal system did keep me on the edge of my seat for a bit!

Chris Gammell introductions to KiCad PCB design videos were critical in guiding me through the various stages of board design.

Rodney Zaks book Programming the Z80 has been like a bible for me.  Combined with a few dozen other resources of Z80 info on line I’ve been able to at least get the basics assembly language programming.

CLRHome is a great online Z80 IDE that can compile assembly language in a variety of output formats including for the ZX Spectrum.  I doubt I could have managed this in notepad!

All of the other Retro Challenge entrants deserve a mention too, but there’s a few that really caught my eye and taught me stuff about their particular approach to RC2014, such as Wgoodf – Turtles all the way down, Ians restoration of Northstar Horizon, Tezzas restoration and programming of Challenger 4P, John finishing work on Fahrfall

IMG_20140730_205950

(more…)