Author Topic: An FPGA that you can play Zork on  (Read 8781 times)

0 Members and 1 Guest are viewing this topic.

Offline robertbaruch

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
An FPGA that you can play Zork on
« on: December 14, 2016, 05:32:10 pm »
Zork was the first commercial text adventure game. The game was originally implemented on a mainframe with a luxurious 1MB of memory! But it couldn't be played on the new home machines of the time, which usually had only 48k, so the programmers developed a virtual machine that executed bytecode called Z-code.

My project is to implement a CPU that can execute Z-code natively on an FPGA. You hook it up via USB to a terminal emulator, load the bytecode for the game, and play! It's my first FPGA project. It will use an Artix-7 on Digilent's Cmod A7 board, which conveniently has SRAM for the computer's RAM.

Why Artix-7 and not the more popular Spartan-6? Because I like SystemVerilog more than Verilog and the Altera Xilinx IDE that supports SystemVerilog only supports the 7-series chips. One possibility that I thought of was, Xilinx's other IDE that supports the 6-series can import netlists. If there were a program (a free one, not Mentor Graphics or Synoptix) that could convert SystemVerilog to netlists, you could use that. But really, the difference between, say, the Papilio and the Cmod A7 is not much anyway.

I've started a video blog about the project, since it's a learning experience for me, and I hope it can help others!
« Last Edit: December 14, 2016, 10:13:01 pm by robertbaruch »
 
The following users thanked this post: cerkit, asmi

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6777
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #1 on: December 14, 2016, 07:06:40 pm »
That sounds like a fun project.  Retrocomputing always is!

You might want to edit the name of the toolchain.  If you are using Artix, I don't think Altera plays with it.
 

Offline Pjotr

  • Frequent Contributor
  • **
  • Posts: 461
  • Country: nl
Re: An FPGA that you can play Zork on
« Reply #2 on: December 14, 2016, 09:08:34 pm »
Jeezzz..... Played Cave on a PDP10 (the university mainframe those days). I think it was the predecessor of Zork. I remember it locked the university computer and playing time was limited before nine in the morning and after five o'clock in the afternoon. The makers must be completely stoned when they programmed it  ;D We kept track of the cave on a large sheet of paper and kept adding new sheets over and over. Implementing a PDP10 on a FPGA must be fun!
« Last Edit: December 14, 2016, 09:11:12 pm by Pjotr »
 

Offline robertbaruch

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #3 on: December 14, 2016, 10:12:11 pm »
You might want to edit the name of the toolchain.  If you are using Artix, I don't think Altera plays with it.

Oooops, right you are!
 

Offline robertbaruch

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #4 on: December 14, 2016, 10:19:10 pm »
Jeezzz..... Played Cave on a PDP10 (the university mainframe those days). I think it was the predecessor of Zork.

Did you use a terminal that went "feep"?
 

Offline Macbeth

  • Super Contributor
  • ***
  • Posts: 2555
  • Country: gb
Re: An FPGA that you can play Zork on
« Reply #5 on: December 14, 2016, 10:29:22 pm »
Jeezzz..... Played Cave on a PDP10 (the university mainframe those days). I think it was the predecessor of Zork. I remember it locked the university computer and playing time was limited before nine in the morning and after five o'clock in the afternoon. The makers must be completely stoned when they programmed it  ;D We kept track of the cave on a large sheet of paper and kept adding new sheets over and over. Implementing a PDP10 on a FPGA must be fun!
There is always the original Essex MUD - utterly amazing at the time. Ran on a DEC-10 and written in BCPL.

Unfortunately there was a distinct advantage to the "internals" (Essex Uni students) with their 9600 baud terminals and the "externals" running at 1200 baud, or even 300 baud using a crappy telephone modem (acoustic coupler) via PDP-8 dial in "gateways" into the JANET network. There was also PSS from British Telecom.

Essex restricted MUD1 to the midnight hours IIRC.

ETA: Blimey it's still alive at http://www.british-legends.com/CMS/
« Last Edit: December 14, 2016, 10:34:40 pm by Macbeth »
 

Offline boffin

  • Supporter
  • ****
  • Posts: 917
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #6 on: December 14, 2016, 10:40:00 pm »
Jeezzz..... Played Cave on a PDP10 (the university mainframe those days). I think it was the predecessor of Zork.

Did you use a terminal that went "feep"?

VT52 w/ the relay BRRRAP;

I remember when the 1st VT100s arrived
 

Offline NivagSwerdna

  • Super Contributor
  • ***
  • Posts: 1831
  • Country: gb
Re: An FPGA that you can play Zork on
« Reply #7 on: December 15, 2016, 11:03:50 pm »
Happy memories thread... I remember playing something involving a grate and a stream [think the house and letterbox might not be in that version] on the PDP something whatever at University of Exeter Chemistry department where the Exeter Homebrew computer club met... happy memories... and BCPL... the first language we were taught at University (maybe 2nd... I seem to remember some Waterloo Pascal)... wow now I feel old.

Looking forward to seeing how the z-machine comes along!
« Last Edit: December 15, 2016, 11:35:21 pm by NivagSwerdna »
 

Offline bson

  • Supporter
  • ****
  • Posts: 1592
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #8 on: December 15, 2016, 11:31:00 pm »
The original Dungeon was written in MDL and then ported to Fortran.  I played the Fortran-IV version on pdp-11's (found on the then popular DECUS tapes if memory serves) and spent quite a bit of time dissecting the source code.  It was a little slimmed down from the full version on pdp-10, if I remember correctly the latter had a bunch of "end game" stuff including a Rose Room with a big compass in it, that was missing from the pdp-11 version, presumably due to code size (I-space) limitations.  But it was mostly the same.  A friend and I spent many nights completely mapping it out and solving all the puzzles (prior to laying our hands on the F4 source code).  Later on it became commercialized as Zork I and reimplemented using the virtual Z-machine.

The hostname for my NAS is bankofzork and the volumes are exported as /Vault1, /Vault2, etc... :)
 

Offline BloodyCactus

  • Frequent Contributor
  • **
  • Posts: 477
  • Country: us
    • Kråketær
Re: An FPGA that you can play Zork on
« Reply #9 on: December 16, 2016, 04:39:23 pm »
Ive implemented ZMachine in C. what a nightmare. A very organic spec, if you want to play things from zmachine v0 up through v5 or even v6/v8..  Id probably target v3 + v5 only.

do you plan on implementing the virtual memory and everything? the zmachine spec is pretty deep. 
-- Aussie living in the USA --
 

Offline robertbaruch

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #10 on: December 18, 2016, 12:54:59 am »
I plan on implementing v3 first, then moving up one version at a time until v8.

Virtual memory is not implemented in the virtual machine, it's in the implementation on whatever CPU you're running. My CPU *is* the virtual machine, so there is no need for virtual memory.
 

Offline BloodyCactus

  • Frequent Contributor
  • **
  • Posts: 477
  • Country: us
    • Kråketær
Re: An FPGA that you can play Zork on
« Reply #11 on: December 18, 2016, 04:30:55 pm »
since zmachine 6/7/8 are graphical enhancements, sound and mouse support, I'd say its not worth implementing (very few games utilise the 6/7/8 modifications)

are you going to implement Quetzal and Blorb?

6/7/8 also go down the rabbit hole of PNG, JPEG, WAV, OGG, MP3, MOD.

fonts in beyond zork. ugh. realtime keyboard input for border zone..

version 3 still has sound effects too but I think only Lurking Horror had it and only on either atari st or amiga so most people never new/heard them.

are you going to (I assume) decouple the ui from the cpu? and have some pc side app interface with the fpga running the cpu? I cant imagine dealing with the streams and ui text/snd/gfx junk in the fpga.
-- Aussie living in the USA --
 

Offline robertbaruch

  • Regular Contributor
  • *
  • Posts: 119
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #12 on: December 20, 2016, 02:58:08 am »
I'm not sure about sound and so on. I definitely want to include text, even if at a basic VT100 terminal level. We'll see how far I get!
 

Offline Marty Geist

  • Newbie
  • Posts: 1
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #13 on: March 09, 2017, 02:31:47 pm »
Hi All;

Robert, I just stumbled on Your Project, Very good..

I am up to part 4, of Your project..

My Question is "Can I put Your project on a different Digilent Board, as I Don't have the money for the Boards that You are using ??"

I have a Digilent Spartan 3E Starter Board and a NEXYS 2 Board, which I got from a friend who I have done some work for in the Past..
And these would have Switches and Led's that I could use for Input and Output, with out getting an Arduino Board, something else that I don't have..

THANK YOU Marty 
 

Online james_s

  • Super Contributor
  • ***
  • Posts: 10247
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #14 on: March 10, 2017, 07:24:39 pm »
I have Zork running on a EP2C5T144 FPGA, the dev board cost me $13 and there is an external SRAM, PS/2 keyboard and micro SD card with a CP/M disk image. The entire system can be built for under $20, I found an old 9" green monochrome CRT monitor that gives it a very authentic look.

I got the basic design from here and made some improvements.

http://searle.hostei.com/grant/Multicomp/
 

Offline asmi

  • Frequent Contributor
  • **
  • Posts: 842
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #15 on: March 11, 2017, 01:22:52 am »
I have Zork running on a EP2C5T144 FPGA, the dev board cost me $13 and there is an external SRAM, PS/2 keyboard and micro SD card with a CP/M disk image. The entire system can be built for under $20, I found an old 9" green monochrome CRT monitor that gives it a very authentic look.
That chip is ancient (it's Cyclone 2 if my memory serves me). It's not even supported with current version of Quartus.
 

Offline asmi

  • Frequent Contributor
  • **
  • Posts: 842
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #16 on: March 11, 2017, 01:25:49 am »
I'm not sure about sound and so on. I definitely want to include text, even if at a basic VT100 terminal level. We'll see how far I get!
You can add I2S output pmod module (http://store.digilentinc.com/pmod-i2s-stereo-audio-output/ ) which would allow you to output sound.

P.S. Can't wait to see new episodes! :-+
 

Online amspire

  • Super Contributor
  • ***
  • Posts: 3786
  • Country: au
Re: An FPGA that you can play Zork on
« Reply #17 on: March 11, 2017, 01:48:21 am »
I have Zork running on a EP2C5T144 FPGA, the dev board cost me $13 and there is an external SRAM, PS/2 keyboard and micro SD card with a CP/M disk image. The entire system can be built for under $20, I found an old 9" green monochrome CRT monitor that gives it a very authentic look.
That chip is ancient (it's Cyclone 2 if my memory serves me). It's not even supported with current version of Quartus.
It is also a very capable chip and a really great price. Cheap enough to use directly in projects. I am pretty amazed it is powerful enough to run Zork under CP/M- I wouldn't have guessed that. I will definitely take a look at that project to see how it was done. The latest Quartus that can be used is 13.0Sp1.
 

Offline asmi

  • Frequent Contributor
  • **
  • Posts: 842
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #18 on: March 11, 2017, 03:21:24 am »
It is also a very capable chip and a really great price. Cheap enough to use directly in projects. I am pretty amazed it is powerful enough to run Zork under CP/M- I wouldn't have guessed that. I will definitely take a look at that project to see how it was done. The latest Quartus that can be used is 13.0Sp1.
I've just checked the price out of curiosity - and it turned out to be not that cheap at almost $15 at Digikey. For that money (or less) you can buy Spartan-6, Cyclone 4 or MAX10 chip (all in the same TQFP-144 package) which will run circles around Cyclone 2 (not to mention that fabric in any of these chips will be waaay faster).
Personally I like Lattice ICE40 Ultra FPGAs as they are cheap and very easy to use in your own boards, and it's available in easy to solder QFN-48 package. The only trouble is that they are kinda hard to find for sale, but I've bought ten 4K chips few months ago which will last for some time. Recently Lattice announced even more capable UltraPlus devices (which contain 1Mbit SRAM memory on-chip!), but I don't know when they will become available (as in "Digikey-Mouser kind of available").
For heavy lifting though Artix-7 (and Zynq SoC based on the same fabric) is simply the best balance of capabilities and price. The only problem is that they are only available in BGAs. I held a lot of hope when Xilinx announced that Spartan-7 will be shipped in TQFP package, but looks like they've quietly dropped this :(
 

Online amspire

  • Super Contributor
  • ***
  • Posts: 3786
  • Country: au
Re: An FPGA that you can play Zork on
« Reply #19 on: March 11, 2017, 03:32:32 am »
It is also a very capable chip and a really great price. Cheap enough to use directly in projects. I am pretty amazed it is powerful enough to run Zork under CP/M- I wouldn't have guessed that. I will definitely take a look at that project to see how it was done. The latest Quartus that can be used is 13.0Sp1.
I've just checked the price out of curiosity - and it turned out to be not that cheap at almost $15 at Digikey. For that money (or less) you can buy Spartan-6, Cyclone 4 or MAX10 chip (all in the same TQFP-144 package) which will run circles around Cyclone 2 (not to mention that fabric in any of these chips will be waaay faster).
The point is the development board is $13 including shipping. Instead of buying the chips, buy the board and use it in projects. You cannot get a development board for any of the chips you mentioned for double the price. I seem to remember there is a Cyclone 4 board for about 3 times the price. The EP2C5T144 board is perfect for starting in FPGAs but definitely, if you are designing a product, move to something better.

 

Offline asmi

  • Frequent Contributor
  • **
  • Posts: 842
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #20 on: March 11, 2017, 03:39:38 am »
The point is the development board is $13 including shipping. Instead of buying the chips, buy the board and use it in projects. You cannot get a development board for any of the chips you mentioned for double the price. I seem to remember there is a Cyclone 4 board for about 3 times the price. The EP2C5T144 board is perfect for starting in FPGAs but definitely, if you are designing a product, move to something better.
That board is waaay too big for my projects. Besides I like designing my own custom boards for every project - just like I 3D print all cases for them as well. I love making as much stuff myself as I can manage - I see no fun in cobbling together a ton of weird boards with tons of stuff that is useless of any specific project. I just can't imagine making a permanent device using devboard (Cmod boards, which are used in the topic at hand, might be exception here as it's small enough and there are almost no extra chips except of what's absolutely required to run the FPGA).
As for the price - well if my goal would be to be as cheapo as possible I wouldn't go into FPGAs at all. Most of projects I'm working on could be done much cheaper using MCUs instead of FPGAs. It's a hobby after all - so it going to be net loss no matter what.
As for development boards - just make your own with whatever nooks and crannies you want! It's not really that complicated, and you will definitely learn a lot designing it!
« Last Edit: March 11, 2017, 03:45:01 am by asmi »
 

Online james_s

  • Super Contributor
  • ***
  • Posts: 10247
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #21 on: March 11, 2017, 08:06:54 am »
Way too big? It's about the size of a credit card. It's actually a bit of a stretch to even call it a dev board, really it's more of a breakout board for the FPGA. I've got a whole pile of them, several are retro computers, another runs Asteroids and Asteroids Deluxe driving a vector monitor I made out of a 5" B&W TV. I've got Space Invaders, PacMan and Galaxian running on one with external ROM. On another one I've implemented a bunch of different sound boards used in 80s pinball machines and arcade games. For one-offs it's a real time saver, and the whole board costs less than the bare parts to get any other FPGA I'm aware of up and running.

Yeah it's an ancient chip, but who cares? It's way more than enough for what I'm doing with it. Asteroids for example consumes only 29%, the complete 64K 10MHz Z80 CP/M system with VGA, PS/2 keyboard, serial port and SD card interface fills 91% so even that has room to spare. What's wrong with using an older chip if the design fits and it works? Anything bigger would be wasted. I have a DE2-115 also but most of the time I end up using the little Cyclone II boards because they're tiny and cheap enough that if I ever manage to kill one it's no big deal, and I make daughterboards that plug right onto them to expand the capabilities. The Z80 system at 10MHz is way faster than the real Z80 computers that were around when CP/M was contemporary. It's actually the SRAM that is the bottleneck there, I've clocked the related 6502 computer at 25MHz on that same board using only the paltry internal RAM. 25MHz is ridiculously fast for an 8 bit retro computer.
« Last Edit: March 11, 2017, 08:13:19 am by james_s »
 
The following users thanked this post: albert22

Online james_s

  • Super Contributor
  • ***
  • Posts: 10247
  • Country: us
Re: An FPGA that you can play Zork on
« Reply #22 on: March 11, 2017, 08:22:53 am »
Here's my implementation of Grant's Multicomp on the left and Asteroids Deluxe on the right. For Asteroids I started with the code from fpgaarcade, ripped out the rasterizer and added a DAC and amps and DC-DC converter for the deflection signals. There's also an audio amplifier, and an I2C eeprom that I intend to use for high score save if I ever get around to coding that part. The board stack for either project is about the size of a deck of cards and operates on 5V. 
 

Online amspire

  • Super Contributor
  • ***
  • Posts: 3786
  • Country: au
Re: An FPGA that you can play Zork on
« Reply #23 on: March 11, 2017, 11:18:23 am »
Very neat James. I have a couple on order for an idea I want to experiment with, and I will need a plug in board.

Is there any 5V available on the headers? As far as I can see, it is only the 3.3V.
 

Offline asmi

  • Frequent Contributor
  • **
  • Posts: 842
  • Country: ca
Re: An FPGA that you can play Zork on
« Reply #24 on: March 11, 2017, 12:01:25 pm »
Yeah it's an ancient chip, but who cares?
I do :) For me the biggest problem is the fact that you gotta use very old version of Quartus to design anything for that. FPGA design software is buggy even in current version, so dealing with old unsupported software is too much of a hassle. Just look at ISE which doesn't work out of box in Win10. And in general new things are better because they are new and shiny :) Anyway, enough off-topic here.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf