ZORK on esp32 - with VGA display and ps2 keyboard

Поделиться
HTML-код
  • Опубликовано: 17 сен 2024
  • How about a game of ZORK on esp32, using PS2 keyboard and a 14 inch VGA screen?
    For thus of you who never played Zork, it’s a text based quest, came out in the early 80’s.
    There is no graphics, and you type in your commands. It used Z-machine instructions as the game data, there for allowing any machine with Z-interpreter to play.
    For full tutorial
    www.hackster.i...
    This project actually started 9 years ago, when I came across this post on the Arduino forum
    forum.arduino.c...
    The user Louis Davis did an amazing work of taking an existing Z- interpreter and make it work on an Arduino mega with SD card.
    The thing was, that you had to connect it to a computer and play over the serial monitor.
    So I made several attempts to make a standalone unit.
    Adding a PS2 keyboard was easy, but finding a proper output, and get it all to work together was too complicated, and I just stopped trying at some point.
    Fast forward to a few weeks back, I came across another amazing work, which is the fabGL library for ESP32. Allowing you to basically turn the ESP32 into a small computer, with SD, PS2 mouse and keyboard, sound engine and the cherry on top - VGA output!
    Getting the space invaders example working on the VGA screen with sound was surprisingly simple and defiantly it was fun playing.
    Now all that retro, brought Zork back to my mind and then It clicked - I can finally get that project I was dreaming of to work.
    I forked the original project and spend 2 days in finding the right combination of libraries and settings to get the code to compile and work.
    If you want to try it out I will leave a link in the description
    github.com/tal...
    The next step, which forced me to make more adjustments, was to make it work on the ESP32.
    Now since I have made several attempts in the past, some of the code adjustments were ready for me, just had to copy them from old projects I kept (lucky me) .
    I was thrilled when I first got to play it on the new setup.
    Now let’s go over the setup.
    I took a VGA cable cut off one end and wired it up to a breadboard friendly connector.
    I used this schematics to figure out the pin out
    www.fabglib.org...
    I used the 8 color setup, with one pin for each color, connected via a 270Ohm resistor.
    I used PS2 with Arduino in the past, so I had a pair of female connectors with pin breakout ready.
    I use a logic level convertor, since the PS2 is 5V and the esp32 is 3.3V.
    And added 1K pull-ups on the 3.3V side.
    You can use the schematics on the site, to help you with the PS2 connector pin out.
    www.fabglib.org...
    The SD card is connected to the spi bus.
    And last and not least is the sound, which here I used a cut cable for.
    You can use this schematics to set it up
    www.fabglib.org...
    When it comes to the code, I took the original AZIP and added the fabgl on top of it, I do want to point out a few thigs
    The SD CONFIG
    #define SD_CONFIG SdSpiConfig(SS, SHARED_SPI, SD_SCK_MHZ(16))
    Without this I could not get the code running, but with other SD or breakout this might have to adjust this.
    I adjusted the VGA pinout to free the 2 SPI pins for the SD, that the original setup was using and this is my pinout
    displayController.begin(GPIO_NUM_21, GPIO_NUM_22, GPIO_NUM_4, GPIO_NUM_17, GPIO_NUM_15);
    The PS2 mouse and keyboard are left on their original pinout.
    The processreadfromsd takes care of the output.
    I added a limit of 71 craters per line, ignore a few craters that exists in the system replay like when you type something that system do not recognize.
    The processpromptline is responsible of the input from the keyboard.
    I had to add some logic, to process all the possible keys.
    for example I ignore scroll lock and tab as you can see here.
    All the special keys start with ESC, some have square bracket right after, like the arrow keys and some have other special keys like the F keys.
    I used the up arrow key to allow you to get the last line typed - make life easier when you play.
    And here you can see the implementation of backspace.
    The next big thing I did in the code was to allow to choose a file from a list.
    I changed the original GAME.DAT file to its proper name and downloaded 2 more zork games.
    The getFileName will return the name and length of the file, and true as its value if the file is not a folder and it’s not the memory game file.
    This was used in both the list of the files, and then to get the right selected file to open for the game.
    The code is available AT github.com/tal...
    and I would love to get a feedback from you guys.
    There are a few more things I would like to add, and I would probably make a proper board for it, so stay tune for updates.
    Hope you enjoyed this video, if you haven’t done it by now, please subscribe, give a thumbs up or leave a comment and see you next time.

Комментарии • 8

  • @MadsonOnTheWeb
    @MadsonOnTheWeb Год назад +1

    Thanks for the explanation! It seems a really good project to make your own version

    • @talofer99
      @talofer99  Год назад +1

      Thank you.
      It was a fun project, mainly since I love playing zork :)

  • @SusanAmberBruce
    @SusanAmberBruce 3 года назад +2

    This is awesome thanks, I can see you put in a lot of effort and details.

    • @talofer99
      @talofer99  3 года назад +2

      Thank you :)
      I did put a lot of effort into this one, but it was worth it seeing it all work well ... now need to find the time to playa full game ;)

  • @maangaritav
    @maangaritav 2 года назад +2

    I had problems with usb ps/adapter for a keyboard. Have to be a ps/2 keyboard?

    • @talofer99
      @talofer99  2 года назад +1

      Yes it is suppose to be ps2 keyboard, protocol wise.
      Someone did claim that you can use USB on it - I tired and failed - maybe old or specific type of USB kb will work. but again its a different protocol.

    • @maangaritav
      @maangaritav 2 года назад +1

      @@talofer99 thanks, I'll try to get a PS2 keyboard.

    • @talofer99
      @talofer99  2 года назад +1

      @@maangaritav try old computer parts stores.