Search Unity

unityGB - Emulator Game Boy for Unity [RELEASED]

Discussion in 'Assets and Asset Store' started by Takohi, May 14, 2014.

  1. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    $2842527909-cover.png

    unityGB allows you to run a Game Boy ROM in your Unity project. Globally, it's a Game Boy emulator written for Unity and it's totally free and open-source.
    It has been written in C# and is only using Mono allowing you to export the project to any platform supported by Unity. Also, unityGB has been released as Open Source software under the GNU General Public Licence. This means that you can download the source code, find out how it works, and contributing.

    unityGB is still in alpha version, many bugs and glitches can occur. Also, the code is far from being perfect and needs a lot of optimization. Any and all help welcome! Please feel free to contribute to this project.

    $2954418396-unitygb_demo_screenshot_2.png

    What is supported:
    • Game Boy games
    • Input
    • Sound
    • Save
    Game Boy Color games are not supported yet.

    With unityGB, you can easily script by yourself how to manage inputs (joypad) and outputs (audio, video).
    Demo: Try our demo to see some scenes with unityGB.
    Video: Watch on Youtube
    Repository: Help us by contributing to this project
    Wiki: Visit unityGB wiki for further information.


     
    Last edited: Aug 4, 2015
    NintendoMaster00 and EliasMasche like this.
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    OMG, this is awesome!
     
  3. SunnyChow

    SunnyChow

    Joined:
    Jun 6, 2013
    Posts:
    360
    i totally don't know what situation i need this. But IT'S AWESOME!!!!
     
  4. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    AWESOME! Takohi, you're a GOD! :D
     
    joaofaleiro20 likes this.
  5. FinsternIRL

    FinsternIRL

    Joined:
    Apr 17, 2014
    Posts:
    6
    Last edited: May 15, 2014
  6. sevensails

    sevensails

    Joined:
    Aug 22, 2013
    Posts:
    483
    Wow! Very Impressive! =)
    It would be viable to create a MSX emulator?
     
    Last edited: May 15, 2014
  7. oddgoo

    oddgoo

    Joined:
    Nov 22, 2011
    Posts:
    12
    Absolutely surprising, in the most positive kind of way!
     
  8. KonsomeJona

    KonsomeJona

    Joined:
    May 25, 2013
    Posts:
    10
    ignore this message please :)
     
    Last edited: May 15, 2014
  9. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Everybody, thank you a lot!

    I'm so glad you all like it, and FinsternIRL, thank you for your video, it's awesome.
    Can I share it on the wiki page of unityGB?

    I made this emulator just for fun, I was always curious about making an emulator and specially for Game Boy.
    When I got some first results, I was like "wow, it's awesome, but... what could we do with it?!", so I decided to share it with you, hoping you will get idea for me.
    Now I can see some people are interested with, I will definitively try to improve this emulator. I don't have so much time so don't expect updates so often. I work on it during my free time. So I also need you to help me and improve this emulator!

    FinsternIRL, and others, could you please make a list of problems you noticed during testing unityGB?
    I have spent a lot of time for fixing the audio but couldn't make it. I don't have to much experience in audio... I would be happy if someone can help me to fix this issue.

    Again, thank you everybody!
     
  10. FinsternIRL

    FinsternIRL

    Joined:
    Apr 17, 2014
    Posts:
    6
    Please, be my guest and post the video, I'm glad you like it =D. I did run into one error, but I'll post it on the bitbucket page. I'll try contribute what I can to the project as I love the idea for VR purposes!
     
  11. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Last edited: May 16, 2014
  12. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Hello JamesArndt,

    I'm sorry I can't run your webpage :(

    But of course it is possible, look at our demo, we are approximately doing the same.
    What you have to do is to map the texture generated in DefaultVideoOutput.cs to the material of your Game Boy screen model.
    You should also use a shader like this one to have a better effect.

    I also got an advice from reddit (david_is_neato):
    Share with us your results!
     
  13. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    Fixed the link.

    Here it is running in a webplayer.
    http://dl.dropboxusercontent.com/u/16956434/SuperMarioLand_Web/WebPlayer.html

    I am going to follow your advice on the point filtering so it will have that pixel perfect look. This should be really neat once it's set up. The cool thing is the model is physically accurate, so the actual screen is under the plastic cover glass, should look pretty convincing.
     
  14. atreu69

    atreu69

    Joined:
    May 6, 2014
    Posts:
    1
    Hi Takohi,

    So I took your awesome script, added the Super Mario Land gameboy rom , integrated it into a small room environment, and modded to run in android for the Durovis Dive headset.. end result , really cool :)

    The only problem that i'm having is the script causes my framerate to drop to at least 40-45fps at most times and sometimes slower (running on Galaxy S5 and HTC One) . Without the gameboy script running the room runs at 60fps always , but once enabled it slows considerably. I've tried a few other roms and it doesn't seem to make a difference.

    any mobile optimization tips?

    https://mega.co.nz/#!uphQXDwR!w9De6Jmy3zgd9JqgLNz5DFXOKrCYGGHdmMuX4PayWj0

    Thanks
    Mark
     
  15. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    First of all, that is absolutely amazing, nice work!

    Secondly, how would one go about improving it? Surely you didn't write that all from you head :). There must be some spec somewhere that says how that cpu "X80" works.
     
  16. TMPxyz

    TMPxyz

    Joined:
    Jul 20, 2012
    Posts:
    766
    Wow, I want to try pokemon on it!
     
  17. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Thank you a lot! Unfortunately, I don't have mobile optimization tips right now, I'm sorry.
    But in the future, I'm planning to review and optimize the code in order to make the emulator running much faster.
    In the meanwhile, don't hesitate to share with me all your tips!

    Hello, and thank you !
    I made a page on the unityGB wiki that includes all links that could help to make a Game Boy emulator.
    https://bitbucket.org/takohi/unitygb/wiki/Documentation

    There are also many open source Game Boy emulator already available in many languages (c, c++, java, javascript...).
    If you are interested to make your own emulator, here is a tutorial (it's in javascript): http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU


    Pokemon is working fine on it! Please try!
     
  18. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
  19. Mementos

    Mementos

    Joined:
    Sep 25, 2012
    Posts:
    79
    Are you still working on it?
     
  20. deiong

    deiong

    Joined:
    May 24, 2013
    Posts:
    79
    would love to see a nes one :)
     
  21. Pursche

    Pursche

    Joined:
    Dec 30, 2013
    Posts:
    3
    I just got my PSM Publisher license and decided to try this out on the PSVita, I didn't quite get it to work after loading a rom from the streamingassets folder, it seems like the PSV just isn't compatible. I would love to help you debug and try to fix this problem if you want unityGB to have support for PSV.
     
  22. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    I don't have so much time now but yeah, in the future, I will try to improve it.

    Me too, but you will have to be patient. ;)

    As I said to you on Facebook, I will of course help you to fix this problem.
    I'm waiting for your post here: https://bitbucket.org/takohi/unitygb/issues
     
  23. ChosenZeus

    ChosenZeus

    Joined:
    May 1, 2014
    Posts:
    18
    I get this on a few roms during it running through its demo and the rom freezes up. Anyone know maybe why and what to do?

    Also is there a way to call a restart of the script if the emu freezes up in game?

    Thanks!

    IndexOutOfRangeException: Array index is out of range.
    UnityGB.MBC1.ReadByte (Int32 address) (at Assets/unityGB/Scripts/unityGB/ROM.cs:351)
    UnityGB.X80.ReadByte (Int32 address) (at Assets/unityGB/Scripts/unityGB/CPU.cs:3298)
    UnityGB.X80.ReadByte (System.Int32& r, Int32 ah, Int32 al) (at Assets/unityGB/Scripts/unityGB/CPU.cs:2698)
    UnityGB.X80.Step () (at Assets/unityGB/Scripts/unityGB/CPU.cs:575)
    UnityGB.Emulator.ExecuteProcessor (Int32 maxTicks) (at Assets/unityGB/Scripts/unityGB/Emulator.cs:415)
    UnityGB.Emulator.UpdateModel (Boolean updateBitmap) (at Assets/unityGB/Scripts/unityGB/Emulator.cs:369)
    UnityGB.Emulator.RunNextStep () (at Assets/unityGB/Scripts/unityGB/Emulator.cs:62)
    DefaultEmulatorManager+<Run>c__Iterator4.MoveNext () (at Assets/unityGB/Scripts/DefaultEmulatorManager.cs:98)
     
  24. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Interesting. Could you tell me wich rom are you using?
    I think it's something about the rom that is maybe not supported yet.
     
  25. ChosenZeus

    ChosenZeus

    Joined:
    May 1, 2014
    Posts:
    18
    If you let the demo run to the third land on Super Mario Land,

    Also revenge of the gator has some issues, I can try that again and get you more detail.
     
  26. lloydsummers

    lloydsummers

    Joined:
    May 17, 2013
    Posts:
    359

    Attached Files:

  27. BlackHoleStorm

    BlackHoleStorm

    Joined:
    Jan 13, 2014
    Posts:
    5
    I'll get a Vita build of this over the next few days and upload a package file, thanks for the hard work you put into this
     
  28. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    We tried to push again unityGB on the Asset Store but it was declined because of "legalities issues".
    However, an emulator is perfectly legal ; downloading and having copyrighted ROMs is not.
    I don't know if the Unity team will see this post but in case, is it possible to get more information?
     
  29. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,355
    The emulator itself may not be illegal, but is made for playing illegal software, so my guess is that this is why it got rejected.

    Which is sad of course, since this would be a very cool asset :)
     
  30. the_motionblur

    the_motionblur

    Joined:
    Mar 4, 2008
    Posts:
    1,774
    Absolutely this!

    Aaaand this may very well be the most meta thing I've seen this month.

    I could just open the drawer a few feet behind me and pull out my real and actual gameboy from the 90s (working condition with fixed screen) but I also could buy and use a Rift :p

    Also: When will there be the "play GameBoy on the toilet VR simulator"? For all the people who did not grow up in the 80/90s :D
     
  31. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Yeah, that's very sad and there is nothing I can do I think.
    Anyway, the emulator is still available on the repository.


    Thank you! Great idea by the way, I will think about it (seriously! lol).
     
  32. blackwolf2012

    blackwolf2012

    Joined:
    Sep 17, 2014
    Posts:
    3
    First off thanks so much for this! This is really awesome!
    Im desperatly trying to figure out how to get a gamepad's dpad or analog sticks mapped to allow movment for the emulator. I have been able to remap the regular buttons but not the Up, Down, Left, Right as No KeyCode exists for the gamepad's Axis's that i can change in the keycode mappings. Any tips on how i might get a gamepad to work would be greatly appreciated! (an xbox 360 one connected to pc).
     
  33. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Sorry, I can't help you for that. :(
     
  34. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    Kurt-Dekker likes this.
  35. 128bit

    128bit

    Joined:
    Oct 8, 2014
    Posts:
    117
    Still trying to find out, why its slow on android. Il dont think its the cpu/gpu power. Since my actual mobile device is faster than my home pc. (got an very old pc).
    Could it may an issue on how android is limiting framerates in combination with UnityGB?
     
  36. lloydsummers

    lloydsummers

    Joined:
    May 17, 2013
    Posts:
    359
    Love it, I'll link it in my bitbucket

    Its been a while ... but if you take a look at the script: Assets / Scripts / Presses / pressButton.cs

    It looks like it enables the buttons using something like
    Code (CSharp):
    1. _buttonstmp [hitObj.name] = true;
    So, you could loop through a class to extend the controller to reach the button ...

    Under Edit > Project Settings > Input, under Axes you can see a list of Axis that you've customized. This needs the appropriate settings for the controller you are using - there are paid assets that make this easier. Or google around for the appropriate settings to use on this panel.

    Next, You can create an input class if some kind and have it check the Axis direction of the thumbstick... Something like below (I haven't tested this code)

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class InputManager
    4. {
    5.   public GameObject DragButtonObjectOnTopInEditor;
    6.   const float minPush = 0.1f;
    7.  
    8.   public void Update()
    9.   {
    10.   float hAxis = Input.GetAxis("Horizontal");
    11.   float vAxis = Input.GetAxis("Vertical");
    12.   var bl = false;
    13.  
    14.   DragButtonObjectOnTopInEditor._buttonstmp["RT"] = hAxis > minPush;
    15.   DragButtonObjectOnTopInEditor._buttonstmp["LT"]  = hAxis < -minPush;
    16.   DragButtonObjectOnTopInEditor._buttonstmp["UP"]  = vAxis > minPush;
    17.   DragButtonObjectOnTopInEditor._buttonstmp["DN"]  = vAxis < -minPush;
    18.   }
    19. }
    • Note #1: Make sure _buttonstmp is exposed as a public variable in the pressButton script. In which case, personally, I'd probably rename it to ButtonStmp.
    • Note #2: Now, assign that InputManager to anything. When it is enabled and on the screen, it will send those true/false flags when the button is held down. I've added a min value, so that if the joypad is "resting" but not quite "0" it won't give you a false reading.
    • Note #3: I personally don't use Update's much myself, I prefer to offload to a slower processed Coroutine. This reduces unnecessary CPU load - however it might be a bit much to go into here :)
    In Android builds, there is a checkbox to enable multi core processing. Make sure that's enabled. It runs buttery smooth on my BlackBerry devices, should be fine on Android. You also might want to add the following..

    Code (CSharp):
    1. Input.gyro.enabled = false;
    2. Application.targetFrameRate = 60;
     
  37. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    Takohi hi!

    You planned to create a SNES emulator?
     
  38. Takohi

    Takohi

    Joined:
    May 14, 2014
    Posts:
    58
    lloydsummers and Lesnikus like this.
  39. Pepe-Hoschi

    Pepe-Hoschi

    Joined:
    Feb 27, 2016
    Posts:
    8
    I worked on a Libretro Unity VR frontend last year:



    It features NES,SNES, GBA & Megadrive emulation. It's pretty basic and straigthforward, but works fine.
    I've not tried yet to implement a libretro android core.
    Would be fun to see if it works fast enough on a GearVR.
     
    carlos_cabral and Ostwind like this.
  40. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,476
    Hi, its great!

    So through this, can I make original NES, Gameboy game by unity engine and c#?
     
  41. mallmagician

    mallmagician

    Joined:
    Jul 15, 2015
    Posts:
    6
  42. Near0ne

    Near0ne

    Joined:
    Apr 18, 2017
    Posts:
    1
    Hi,
    thank you for your anwesome work !
    I would to know how people (@atreu69 and @128bit) clear to import this on android, because as far i know, android doesn't support move texture, and if i don't mistaken, it's a sort of it that you use in your emulator
    Someone can help me please ?
    Thank you
     
  43. GlitchInTheMatrix

    GlitchInTheMatrix

    Joined:
    Apr 12, 2010
    Posts:
    285
    Sorry for ask here but did anybody got LibRetro Arcade ( Mame ) Running?
     
  44. omarboss

    omarboss

    Joined:
    Dec 12, 2016
    Posts:
    3
    is it possible to use Unity gb to make ROM hacks to gameboy games?
    Also, can make one for the N64?
     
  45. omarboss

    omarboss

    Joined:
    Dec 12, 2016
    Posts:
    3
    How do you emulate retro game systems for Unity? I would like to know so I can make games for my retro consoles
     
  46. asdzhh

    asdzhh

    Joined:
    Jan 20, 2018
    Posts:
    9
    Hi,
    thank you for your anwesome work !!:)
    I find that "Emulator.UpdateModel()" call many times of "ExecuteProcessor()",and in this fuction "x80.Step()" execute more than 40000 times, it cost a lot of time every frame. Is there anyway to solve this problem?o_O