close-circle
Close
0%
0%

WIFI Game Boy Cartridge

ESP32 emulating to be a cartridge

Similar projects worth following
close
Using the Game Boy as a remote control is a childhood dream of mine. Having it connected to the web was later on on the top of the list of things I wanted to have for this sweet machine. So that's what I'am aiming at: control stuff over the web with a Game Boy.

Or may be war driving with a Game Boy, controlling MQTT stuff and browsing http://retro.hackaday.com/ - depending how far I get.

The ESP32 parts in Arduino are licensed under http://www.apache.org/licenses/LICENSE-2.0, my work will be published under the MIT License (it's in the file section).


The goal

My plan is to achieve a working environment for the ESP32, to handle the requests of the game boy and work with wifi in parallel, so that you can actually use the Game Boy to surf or interact live with the web/wifi. There are many possibilities to take something useful out of it.


Choice of Hardware

Right now I only want to concentrate on one chip and focus on replicating results that are equal to the achievements of dhole [emulating with STM32] or Alex of insidegadgets.com [emulating on Arduino], where dhole managed to emulate not only ROM but also RAM and MBC (memory bank controller) on one chip. I was about to start with an additional Flash or EEPROM and an ATSAMD21 as an MBC, but that would mean programming two firmwares for two chips that I haven't worked with before - plus programming the actual code for the Game Boy side. The first idea was to use an ESP12 module as an MBC, but with only one core to handle WiFi and inputs at that level of speed would have been impossible (IMHO).


Cartridge vs. Link Port

I do like the approach of using the linkport to talk to an ESP12 and think it is feasible to go that route [like flying a drone]. But it would also require two components: an EEPROM cartridge AND an ESP dongle on a port that no one builds plugs for anymore. From a hardware aspect it is much easier to do an egde connector on a pcb and wire up the ESP, so that's another reason to go with a cartridge. You would also need to build and program your own cartridge, like I did on my other project: #Game Boy Cartridge plus Programmer - instead of using an USB ready ESP board in a cartridge form factor.


Choice of IDE

I'm currently using Arduino IDE, I've done a lot with it so far and am a creature of comfort. There are ways to implement features and functions to bypass "crappy" Arduino code. But it's written better then everything I could have come up with and I've heard of good changes that were made to the Arduino code recently. I hate the crappy editor, love sublime. Integration of Arduino into Sublime was always buggy for me. I love just pushing a button to upload code.


Speed of pin toggle

The current way that I use to toggle the pins and also read them is way too slow. As stated [here], the max speed with direct pin toggling through registers is about 4MHz, far from the cpu speed of 240MHz. In comparison the plain olde Arduino with 16MHz CPU has a toggle speed of round about 2.66MHz, when changed through port registers. You can find the ESP32 pin toggle function [here].


Using I2S as parallel input and output bus

Now I'm really leaving the sector of stuff that I'm used to do or comfortable with (I'm a PHP/JS guy in real life). I don't often surf around the latest CPP code written by CNLohr and SpriteTM, but when I do.. well I don't. But I want to work on that cartridge as long as I see there is an option to go on. In comes the code of CNLohr [github link] - and the previously unknown to me parallel I2S bus.

plain - 1.03 kB - 04/26/2017 at 18:25

download-circle
Download

  • 1 × ESP32 module
  • 3 × 74LVC8T245 Logic ICs / Receivers, Transceivers

  • Starting with esp-idf-v2.0

    davedarko06/16/2017 at 20:23 0 comments

    http://esp-idf.readthedocs.io/

    Finally found the time and inspiration to work on this project again. To get the I2S demo of CNLohr working, I also needed to be able to compile with the esp-idf.

  • celebrations are in order

    davedarko05/14/2017 at 21:37 3 comments

    http://hackaday.com/2017/05/14/hackaday-prize-entry-wifi-game-boy-cartridge/


    I feel some questions are coming my way, so I've updated the detail section :)

  • precognition in a game boy?

    davedarko05/13/2017 at 12:24 3 comments

    So I thought to myself, if the ESP is too slow, but the query itself is taking microseconds instead of nanoseconds: why not trick the ESP and spit out the next in array? here's what I got, admittedly one of the better results, but you can finally read something! I can live with it, if I can get it to work reliably.

  • i2s for parallel IN / OUT?

    davedarko05/12/2017 at 23:14 1 comment

    https://www.esp32.com/viewtopic.php?f=19&t=1746&p=8153&hilit=parallel#p8153

    Seems like I'm 3us late with reading and preparing my response. The posted scan looks like it takes 175us from address change to address change. Putting it in relation, an EEPROM takes 150ns to respond, that's 1/20 of the time I have now. With 240MHz the ESP32 should have a clock cycle time of 4.16ns. Whaaaat? My math is broken. Seems like the maximum speed for gpios on the ESP is "quite" limited, max toggle freq is around 4MHz. https://www.esp32.com/viewtopic.php?f=2&t=1595&p=7482&hilit=parallel#p7482

    Seems like there is a multipin IS2 interface that was also used on https://github.com/igrr/esp32-cam-demo/blob/master/components/camera/camera.c#L314

    https://www.esp32.com/viewtopic.php?f=12&t=951&p=4113&hilit=parallel#p4113

  • moar research.

    davedarko05/12/2017 at 18:48 0 comments

    So from far away it looks alright! I checked every byte and the data is correct. But...

    Look a bit closer and you see this:

    It might make sense to give the ESP the control over the OE of the data pins, since it's not fast enough to react to every change on the fly, it might needs better timing.

  • Needs moar research

    davedarko05/04/2017 at 22:05 1 comment

    I can't believe that I'm so close already... but I do need to check the timings and need to find out if I can advance the code more. This needs to be connected to an analyzer.

    1. Hardware setup

      davedarko05/01/2017 at 20:52 0 comments

      I'm still missing some cables, but so far it is looking quite interesting. I've recycled a donor board, replaced the missing switch with a wire, supply the game boy off of the 3V3 power of the esp board through a diode and soldered 32 cables to the missing cartridge port.

    2. what a week - no end in sight

      davedarko04/22/2017 at 19:37 3 comments

      The whole week was filled with work - taking support calls, fixing bugs, meetings and more support calls. In between all that we tried to develop the important stuff. Yesterday, after work, I prepared my room for some dry wall construction ,to close the window between my room and the kitchen. Today I was mainly helping my father to build up the dry wall. The next few days I will be painting, letting it dry, glue on wallpaper, letting it dry, putting paint on the wallpaper and letting it dry as well. To make the Wohngemeinschaft great again. My bed is right next to the wall, before the wall I was awake when my roommate was. I need to fix up the light switch as well - I see a Wemos D1 mini soon hanging there too :)


      Anyways. Back to the project - I received all the parts to get prototyping started and I'm excited to begin, as soon as I can possibly do, but not today - I'm tired. Funding looks great, e-begging works :D

    3. getting closer to a layout

      davedarko04/19/2017 at 20:54 0 comments

      I was able to drop a 74LVC8T245 level converter and connect the address pins. A15 on the Game Boy is basically the "chip select" for the ROM / cartridge, when pulled down, since the address space of the 32kb is 0x0000 to 0x7FFF. SO I use that for the output enable pin on the lvl converter.

      The Game Boy write pin will define the direction of the data pins lvl converter. The address lines will be pulled low, meaning the direction is always B->A. I use the pin that was previously the A15 pin to tell the ESP the direction of the communication.

      A0-A3 are connected to input only pins of the ESP. Not unlike the ESP12F there are some pins that are connected to the SPI flash on the module and shall not be connected otherwise.

      So far I only have the RX and TX pin free, but I consider to have the RST line on a transistor - maybe I need to hold the game boy in a reset state for a while, for the ESP32 to boot up and set all pins.

      Not on the picture is the current power supply. I'm a bit worried about the two AAA / LR03 batteries in my Game Boy pocket, they're not that powerful in general and with the LED backlight it's not better. Drawing from the 5V switch mode to convert to up to 250mA will be a challenge. I might need to add a LiPo and/or some tantalum capacitors to make it work.

    4. stuff ordered

      davedarko04/19/2017 at 07:44 0 comments

      so before I make a PCB and order it for a lot of money (that's almost true, I have a coupon), I thought I buy parts for a lot of money, but hey - there's more money to collect now [http://hackaday.com/2017/04/18/up-up-up-2k-more-seed-funding-for-projects-that-matter/].

      Some almost breadboard friendly 74LVC8T245 were ordered, although they have their pinheaders upside down. [http://www.ebay.de/itm/302193394421]

      I have an ESP32 basic adapter board (dual row headers, no power converting), but I'll wait on the breadboard adapter I've ordered, with all the bells and whistles. (full disclosure, I wrote balls the first time)

      With that the 20bugs on that project are almost spend :) but it's good to have it. There are also two #Hornbill in the making, but they arrive much later.

    View all 13 project logs

    Enjoy this project?

    Share

    Discussions

    Vije Miller wrote 05/15/2017 at 05:02 point

    Still mandatory...

      Are you sure? yes | no

    davedarko wrote 05/15/2017 at 07:05 point

    Actually not ;) I've integrated a backlight into my Game Boys. Well in 3 of them.

      Are you sure? yes | no

    Vije Miller wrote 05/15/2017 at 16:17 point

    I'm much older now, yes...yes it's mandatory :)

      Are you sure? yes | no

    el.seyf wrote 05/14/2017 at 21:33 point

    Looks promising, but isnt it more feasible to use the LINK Port instead of the Cartridge Port for the ESP and write some driver to put on a separate cartridge? For cartridge emulation, you might need some kind of parallel DMA that can output 8 Bit on the ESPs GPIO clocked by the Gameboy to make it work somehow, but I havent found any such feature (did a quicksearch, maybe the datasheet reveals something?)

      Are you sure? yes | no

    davedarko wrote 05/14/2017 at 21:56 point

    The closest thing I've came up with through extensive googling is parallel I2S, that's where my hopes are right now.

    There is also this: http://hackaday.com/2016/08/21/fly-with-a-game-boy-classic/ - where the game boy communicates over the serial port with the computer, thanks to a custom cartridge. I do like that approach and think it is feasible to go that route. But it would also require two parts, a cartridge AND an ESP dongle on a port that no one builds plugs for anymore. From a hardware aspect it is much easier to do an egde connector on a pcb and wire up the ESP. 

      Are you sure? yes | no

    davedarko wrote 05/14/2017 at 22:09 point

    I've added part of my response to the detail section, thank you very much for asking!

      Are you sure? yes | no

    haydn jones wrote 05/14/2017 at 21:07 point

    Can you do midi over bluetooth/usb with this. would go down with the chip-tunes crowd if it could just work with modern software without loads of mods.

      Are you sure? yes | no

    davedarko wrote 05/14/2017 at 22:01 point

    "not modding" is definitely a key benefit of having everything on the cartridge, so it would probably be possible. But I have no experience with BT nor MIDI over BT... 

    How does the Game Boy even Midi? Also over the serial port?

      Are you sure? yes | no

    Frank Buss wrote 05/15/2017 at 08:20 point

    It probably doesn't do MIDI. But the idea is to use the Gameboy as a synthesizer, which you can play with MIDI, e.g. controlled by Cubase from a PC, or even from a MIDI piano keyboard.

    Obviously you need a program for this on the Gameboy, maybe it already exists. For the C64 there is Cynthcart. Together with my Kerberos Cartridge it can be used to use the C64 as a MIDI instrument, as demonstrated by a beta-tester of my cartridge here:

      Are you sure? yes | no

    bamboori wrote 05/14/2017 at 20:59 point

    inb4 Gameboy online multiplayer!
    Also, have you considered using a Gameboy colour instead? Should be much better for light web browsing (especially when it comes to images).

      Are you sure? yes | no

    davedarko wrote 05/14/2017 at 22:04 point

    Totally honest: I'm not sure how to do that. I would have to steal the header from a game boy color cartridge and go from there, but for know I'm quite happy if I can get text to work ;)

      Are you sure? yes | no

    zakqwy wrote 04/24/2017 at 17:33 point

    Gameboy war driving sounds really awesome. Great project! I haven't played around with the esp32 nearly as much as many others on this site, but I agree with your assessment that power consumption may be a concern. Definitely a good application for a lipo retrofit, maybe there's an existing design out there for the GBP so you can focus on the cartridge?

      Are you sure? yes | no

    davedarko wrote 04/24/2017 at 17:47 point

    thank you for reading the logs and the kind words :) for now I will probably breadboard something together and work from USB power or an external power supply. Maybe a ton of caps can help, I've seen some designs that actually work with a coin cell, given some 1000uF tantals. But yes, the focus is full on the cartridge.

      Are you sure? yes | no

    coletonn wrote 04/24/2017 at 00:13 point

    Oh crap this is really cool. Ever thought of making a cloud rom storage? So connecting the cartridge to a site, then remotely transferring it to the cartridge. Connecting it the cloud and then pushing a button would save the state and upload it. 

      Are you sure? yes | no

    davedarko wrote 04/24/2017 at 07:46 point

    I'm still at the "oh crap, I have no idea what I'm doing" stage :)

    Right now I'm thinking war driving with a Game Boy, controlling MQTT stuff and browsing http://retro.hackaday.com/  - that kind of stuff. But I will probably start with faking to be the hackaday cartridge I've build in #Game Boy Cartridge plus Programmer project.

      Are you sure? yes | no

    Similar Projects

    Does this project spark your interest?

    Become a member to follow this project and never miss any updates