# Web Based Gameboy Emulator



## nano351 (Jun 23, 2013)

Hello everyone!

I've been working on a web based gameboy emulator it runs using javascript/html5 and it uses google drive to store roms and saves. The idea is to create an emulator that works on web technologies and uses a cloud based storage sot hat it can be used from any computer with synchronized saves.

It supports gameboy, super gameboy, and gameboy color games along with fullscreen mode, gamepads, and preliminary sound support. It isn't fully optimized but enough to run at fullspeed on my acer C7 chromebook with sound off which uses a 1.1GHz intel cpu.

It also has emulation of the gameboy camera using your webcam! Contrast isn't working on that but it's basic functionality is there!

It has pretty high game compatibility, but is still very much in development and I'd love to get some feedback on it! Right now the next thing I plan on adding to it is offline support via web APIs. Right now the app can be loaded offline but it won't work because it still needs an internet connection to function correctly.

Link to the app: http://www.googulator.com/


----------



## macmanhigh (Jun 23, 2013)

Pretty Sweet Budd just tested it out with 2 games Loads n Runs Beatiful  Gonna jump on my Vita see if it works as smooth.....


----------



## Isaac (Jun 24, 2013)

Awesome, I'll try this out later when i get on my laptop. May I ask how you got it to access google drive?


----------



## FAST6191 (Jun 24, 2013)

Interesting, I reported on http://gbatemp.net/threads/js-vba-m.335675/ last year but always nice to see new goes at things like this.

When you say SGB any chance of the multiplayer stuff working? A web based multiplayer bomberman would be fatal to any chance I had to get stuff done at various points but that matters little.


----------



## nano351 (Jun 24, 2013)

macmanhigh said:


> Pretty Sweet Budd just tested it out with 2 games Loads n Runs Beatiful  Gonna jump on my Vita see if it works as smooth.....


 
Yikes let me know how it goes! The 3DS's javascript engine is pitiful and can't handle it at all



FAST6191 said:


> Interesting, I reported on http://gbatemp.net/threads/js-vba-m.335675/ last year but always nice to see new goes at things like this.
> 
> When you say SGB any chance of the multiplayer stuff working? A web based multiplayer bomberman would be fatal to any chance I had to get stuff done at various points but that matters little.


Yes it has multiplayer support! It's all local though so your friends have to come over and huddle arround your computer lol. You configure it on the settings tab


----------



## 2ndApex (Jun 24, 2013)

Kind of reminds me of this: http://www.virtualgbx.com/
But the cloud storing part of this makes it better already.


----------



## macmanhigh (Jun 24, 2013)

MMmmmmm Tested on Vita Loads the Page Fine but doesn't load upper right Login icon "Loading Google Credentials" loops Forever.......


----------



## nano351 (Jun 24, 2013)

2ndApex said:


> Kind of reminds me of this: http://www.virtualgbx.com/
> But the cloud storing part of this makes it better already.


 
There's also the issue that virtual GBX is illegal since they distribute copyright protected materials. They claim some legal jargon but it's false. There's no DRM to prevent me from easily just downloading the original ROM file!



macmanhigh said:


> MMmmmmm Tested on Vita Loads the Page Fine but doesn't load upper right Login icon "Loading Google Credentials" loops Forever.......


 
Strange. I don't have a vita so I can't do any testing and I doubt the vita has any debugging support! Also, I doubt the vita supports the gamepad api. It's a really new api that only really has support by chrome and firefox at the moment


----------



## macmanhigh (Jun 24, 2013)

nano351 said:


> Also, I doubt the vita supports the gamepad api. It's a really new api that only really has support by chrome and firefox at the moment


 


Yeah that was the second thought that Crept in my Mind...How to play it on Vita!!!!

Anyways Superb Program U got and GDrive makes it A Must


----------



## grantgalitz (Jun 24, 2013)

Looks like a nice ui and a great start.
Some nitpicks about the code though: I looked through the code, don't know why the hell you de-inlined a jump table into a switch and de-inlined register handling into outer functions. That's gonna eat up 3x more cpu than it should, I know because I spent a month reversing switches and if/else decoding back into a jump table in https://github.com/grantgalitz/gameboy-online

Also don't use JSBoy's APU emulation, it's shitty. Use VBA's or something similar to what I did, as there are tons of edge cases and audio comes out incorrectly if not sampled at sys clock.


----------



## nano351 (Jun 24, 2013)

grantgalitz said:


> Looks like a nice ui and a great start.
> Some nitpicks about the code though: I looked through the code, don't know why the hell you de-inlined a jump table into a switch and de-inlined register handling into outer functions. That's gonna eat up 3x more cpu than it should, I know because I spent a month reversing switches and if/else decoding back into a jump table in https://github.com/grantgalitz/gameboy-online
> 
> Also don't use JSBoy's APU emulation, it's shitty. Use VBA's or something similar to what I did, as there are tons of edge cases and audio comes out incorrectly if not sampled at sys clock.


 
Never thought I'd meet you! I didn't de-inline anything. I've written all the code slowly from scratch (except the APU code). I was actually planning on borrowing the APU emulation from your gameboy emulator lol. It's just I need to understand better how your code is working first. The main reason I threw JSBoy's APU emulation in there was because I was trying to do it using web audio oscillators (and getting very frustrated out how terrible the approach was turning out), so JSBoy's was the easiest to cut and paste for the time being.

Thanks for the info about the switch tables and register lookups. I originally wrote my code in Java a long time ago and ported it to javascript and fixed up a lot of things. I noticed that the switch tables weren't working as fast as they would in other languages (because the VM goes through it and checks all the cases until it finds a match). Although I guess I neglected to look into how bad it is for performance and kind of forgot about it.


----------



## grantgalitz (Jun 24, 2013)

The areas of my code that use an array of functions are dispatch tables so we don't spend most of the time going through branching to the right handler. Using "parentObj" to refer back to context is weird but it works. You have to emulate the APU directly, you can't use an api to do it for you. You need to construct your own pcm audio stream, even if there are apis available to "simulate" it.

Nice work though, just realize the optimizations go a long way even if it forces weird coding conventions. I know I can run gameboy-online on a 10 year old P3 computer fullspeed, so it *can* be done. Heck, I'm working on IodineGBA to hit the perf wall issues for creative coding again: http://i.imgur.com/6VArsmY.png


----------



## nano351 (Jun 24, 2013)

grantgalitz said:


> The areas of my code that use an array of functions are dispatch tables so we don't spend most of the time going through branching to the right handler. Using "parentObj" to refer back to context is weird but it works. You have to emulate the APU directly, you can't use an api to do it for you. You need to construct your own pcm audio stream, even if there are apis available to "simulate" it.
> 
> Nice work though, just realize the optimizations go a long way even if it forces weird coding conventions. I know I can run gameboy-online on a 10 year old P3 computer fullspeed, so it *can* be done. Heck, I'm working on IodineGBA to hit the perf wall issues for creative coding again: http://i.imgur.com/6VArsmY.png


 
Yeah that's the conclusion I reached about the audio emulation, I was trying to take an easy way out because I've never really done anything with audio except deal with high level APIs. And wow that's really impressive how optimized you've gotten gameboy-online to be and IodineGBA is looking really really good too!

I'm planning on making this project opensource. There's just stuff sitting around that I need to clean up and consolidate before I do so. I also plan on adding emulators for more systems to the project and despite how much fun it is to work from scratch, it's proven to be quite time consuming and tedious at times so I might look into either porting opensource emulators as a starting point for other emulators or looking into working in other opensource javascript emulators as a starting point


----------



## The_Cooker (Jun 26, 2013)

nice work, but you should make it so that you can run roms from your local harddive. also you should make it play gba and ds roms.


----------

