All Uzebox Games Online! (Cuzebox and Emscripten)

The Uzebox now have a fully functional emulator! Download and discuss it here.
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by nicksen782 »

Great! The images that I have don't actually exactly fit. They are stretched to the size of their container. So, if the size of the container changes then so does the background image of that container. Although you'll want to use something with dimensions close to the container dimensions.

The top and bottom divs are 800x35. Press F12 and use the upper-left icon in the panel that appears, then hover over the element that you want to see the dimensions of.

Could you send me your Frogger images? I'd like to try them out.
User avatar
D3thAdd3r
Posts: 3222
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by D3thAdd3r »

I hadn't thought about how those dimensions would work with standard size marquee graphics, but it basically doesn't work well when it is squished that much vertically. I came up with this built from several different images around the web:
frogger_scaled.png
frogger_scaled.png (315.95 KiB) Viewed 8081 times
It cheats on the top part by using significantly higher vertical resolution than you specified. Past that I think it fits the specification; there is only so much you can do with so few pixels above the screen, where one would usually expect a design to show a title or so.

PS I can chop that up into sections if you need. The purplish color key should accurately frame out where the cuts should be. Probably if the top part cannot be higher resolution then marquees can't really be used(even that one has numerous modifications to squish well).
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by Jubatian »

Just skimmed through for now along with a quick check: Nice stuff!

For the EEPROM: The emulator will happily emulate it no matter if there is no file to back it, so as long as you play, it will work fine, then the contents will obviously go poof. For an okay solution I think you could use Emscripten's IDBFS interface, maybe it might need Emscripten-specific inserts in CUzeBox as well, this would store the file on the user's side (so not on a server, so you will only have your scores / saves etc, but no authorization / security problems).

It would be nice if somewhere it was printed out where you could find the SNES buttons on the keyboard (like I do on the minimalist Emscripten example in CUzeBox's repo), it is something rather critical for new players.
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by nicksen782 »

I have added a sort of modal that displays a copy/paste of your keyboard shortcuts. I also made an SNES controller graphic with the CUzeBox controls overlaid on top (since some of us are more visual.) Thank you for reminding me. You can access it in the Emulator Controls section.

The IDBFS API doc meantioned something about temporary storage:
This is provided to overcome the limitation that browsers do not offer synchronous APIs for persistent storage, and so (by default) all writes exist only temporarily in-memory.
This makes me think that it won't persist.

I was actually thinking of a sort of 'Save' function. I can add files to the Emscripten FS. I know that I can read them as well. What if a button click (or some other hopefully more automatic trigger) would download the EEPROM file into HTML5 Local Storage (Browser Storage)? Also, that file could be detected and loaded anytime a game is loaded. Perhaps EEPROM could be saved when the user clicks the "Stop Emulator" button? This seems very do-able.

I've been working on using this as a development tool lately. The Choose a Game: URL option allows you to input a .json file which indicates which files the system should download (from another server or the same.) Obviously, these files would need to be web-accessible and a .htaccess file would need to be created. I have provided an example config also. I've been using it for the past two days and this is all working really well!
Attachments
New controls
New controls
newcontrols.PNG (20.76 KiB) Viewed 8020 times
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by Jubatian »

nicksen782 wrote:This makes me think that it won't persist.
No, it just refers to that for syncing to work it is necessary to call FS.syncfs, which is asynchronous: the reason is most likely that while it could have been implemented so that on writes to files it attempts a sync, but that wouldn't exactly work like the C filesystem API (which is synchronous), notably it would break things if you, from C, opened a file, wrote it, closed it, then immediately assumed that it persisted (as it is the case when compiling C into a native program). Such as if you saved your stuff before exit (common), and in the Emscripten build, you wanted to redirect the page upon termination (which, unless you waited for the sync, would end up destroying the content you wanted to save).

In CUzeBox this seems to be a rather simple matter as it attempts to auto-sync the EEPROM file in every frame in which a write happened to it (so I think by simply placing an FS.syncfs(); call with inline JavaScript into the filesystem layer on writes it could work if you mounted the eeprom.bin file through the IDBFS API).
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by Jubatian »

Does anyone experience serious lag problems?

On some other forum where I posted about my game, one of the players experienced 1-3 seconds (!) lag in input response. As I queried, he uses Firefox under GenToo Linux on a very beefy AMD PC, and the emulator reports running at full speed. This is weird as for OS + browser I have a similar combo (just Debian) on a ten years old Core 2 Duo, and it works all fine here, I am clueless what could happen there.
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by nicksen782 »

I'm actually using it to develop with, not just play games. I'm not having a problem. At home I have a beefy Unix laptop and at another location I have a pretty standard fair dual core cpu with half as much RAM (AMD CPU, others were Intel). I use Chrome in both cases. I do notice that it runs half speed on a cell phone (from the way the music sounds.) Does this occur without the game changer? I only ask because it IS in an iframe.

What game(s) was this player using? It shouldn't matter how they loaded it (Server/Local/URL) because once loaded it is all the same. If the game is Bugz or FOAD then what happens if their specific Emscripten builds are used instead? I'm using the same compile method as you are using I belief. I do have the better quality on by default though. I'm not sure about the flicker (F7) setting.

I'm all for making this as efficient as possible.
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by Jubatian »

No, it is not the game changer, it is a general problem with the Emscripten build which this player experienced with FoaD on both yours and the specific build I provided for that game (using the last version of CUzeBox). The weird thing is that I asked and got a screenshot from him in debug mode which shows that the emulator is running at full speed ("CUzeBox 100%"), and an 1-3 sec (!) lag is present on inputs. This is such an atrocious lag which couldn't happen by misjudgement or anything alike, something very fishy is going on there.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by uze6666 »

Missed the last few weeks and just saw this thread. Awesome work, this is massive. We will have to discuss how to integrate with the existing main website. What's the backend requirements to run all this? I think we should probably aim to run the app centralized along all the rest on the uzebox.org server (Godaddy Linux host). We could then use some form of SSO for accessing the app in admin mode with the forums credentials. What do you think?
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: All Uzebox Games Online! (Cuzebox and Emscripten)

Post by nicksen782 »

Thanks Uze!

The code is available here: (I also adjusted the first post of this thread to include the Github link.)
https://github.com/nicksen782/OnlineUzeboxPlayer

The backend is PHP with SQLite drivers installed. The database is just a file in this case and is easy to work with. PHP handles reading/writing the database and getting the correct filenames. The front-end portion directly downloads the indicated game files from the server. The game files do NOT need to be modified. Each game gets its own folder and when a game is selected each file in that folder is brought into the Emscripten file system. You could store more than the game if you wanted (such as with Uzeamp I included an audio file and with Emuze I included a sample EEPROM file.) The database stores the filename of the game (it could be either the .hex or .uze). That's the system in a nutshell.

Right now I have the app configured to disable the database writing features (and the display of those features) when it is NOT hosted in my development environment. This means that currently my dev environment is the source of truth for the database since I overwrite whatever is on the live server each time I do a new rsync. Perhaps we could discuss the centralization and application access soon?

As for authentication for database edits I really like the idea of SSO and pre-approved accounts. It would also be interesting if I could just clone the authentication details from the Uzebox wiki or forum too. Each database write could create a backup if needed.
Post Reply