CUzeBox - The new official Uzebox emulator

The Uzebox now have a fully functional emulator! Download and discuss it here.
User avatar
uze6666
Site Admin
Posts: 4449
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by uze6666 » Sat Oct 13, 2018 2:59 am

Thanks for the explanations. Pretty nifty and useful, specially those timing blue bars. Got used to them very fast and could not live without them now. 8-) Fixing timing with the avr simulator was such a chore in retrospect!

User avatar
nicksen782
Posts: 667
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by nicksen782 » Sat Dec 29, 2018 7:54 pm

Hey Jubation!

The new Uzebox Online Player has (working) support for both on-screen gamepads. I send the key event and for game pad two I also send the right alt key. This works for the on-screen controls. I also know that I can hold the right alt key and any keyboard input I give would go to player 2.

However, this doesn't work for some keys. Specifically for alt+space, and alt+s. These must be reserved key combos for the browser. I tried to override this behavior but I could not.

Could you add an additional modifier key for player two? I don't think it matters which key you use just so long as the browser isn't using it. What about the Alt-Gr key? That's the key between the alt and the ctrl on the right side of the keyboard (US keyboards at least.)

Also, here are the cuzebox.js modifications that I made and compiler flags that I set for the online version. Do you have any opinion on these?
I do a string replace in cuzebox.js to remove "cuzebox.html.mem" and I replace it with a base64 data url. Reading through the Emscripten code I found that it accepts either a filename to download or a base64 data url. So, now the emu_core.js is those files combined. I think Emscripten has an official method to combine but I'm doing this for now.

When compiling a new CUzeBox I do a git clone and then I modify Make_config.mk and Make_defines with sed via a bash script. These are the modifications.

Code: Select all

echo
echo '************************************************************************************'
echo Using 'sed' to edit the config files for CUzeBox.

quote=\'
dquote=\"
lbracket=\[
rbracket=\]
TEMPSPOT1=""
TEMPSPOT2=""

# Edit the CUzeBox config file.
# Make_config.mk
sed -i 's|Makefile - configuration.*|Makefile - configuration - Modified for the Uzebox Online Player # CHANGED|' Make_config.mk
sed -i 's|TSYS.*|TSYS=emscripten|'                                     Make_config.mk
sed -i 's|FLAG_NOCONSOLE=0|FLAG_NOCONSOLE=1 #CHANGED |'                Make_config.mk
sed -i 's|FLAG_NOGAMEFILE=0|FLAG_NOGAMEFILE=1 #CHANGED |'              Make_config.mk
sed -i 's|FLAG_DISPLAY_GAMEONLY=0|FLAG_DISPLAY_GAMEONLY=1 #CHANGED |'  Make_config.mk
sed -i 's|FLAG_SELFCONT=1|FLAG_SELFCONT=0 #CHANGED |'                  Make_config.mk

# Make_defines.mk
sed -i 's|CFLAGS+= -DTARGET_EMSCRIPTEN |\n#CHANGED\nCFLAGS+= -DTARGET_EMSCRIPTEN -s ENVIRONMENT=web -s WASM=0 -O3 -s MODULARIZE=1 --closure 0 -s FORCE_FILESYSTEM=1 -s LEGACY_VM_SUPPORT=1 TEMPSPOT1 TEMPSPOT2 |' Make_defines.mk
sed -i "s|TEMPSPOT1|-s "$quote"EXPORT_NAME="$dquote"UOP"$dquote""$quote" |"                                                                                    Make_defines.mk
sed -i "s|TEMPSPOT2|-s "$quote"EXTRA_EXPORTED_RUNTIME_METHODS=["$dquote"FS"$dquote"]"$quote" |"                                                                Make_defines.mk
echo '************************************************************************************'
I'm using the asm.js compile and not the wasm at this point. I do intend to test wasm though since it ends up smaller and could be faster. For this I would need two compile CUzeBox twice. Once for each version. Then, I would do a feature detect for wasm support and provide that otherwise provide the asm.js.

User avatar
Jubatian
Posts: 1355
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Sat Dec 29, 2018 8:35 pm

Nice solution for automating keeping up with the repo! Changes seem to be fine for me, really, stuff in Make_config should work just as documented, and for the arcane hackery you do with Make_defines is something I can not add much to. You know what compile options get the thing running proper in the online game changer!

I made a change: now both ALT keys would redirect controls to Player 2 (you mentioned that maybe I should add AltGr, but at least by my keyboard layout so far it accepted AltGr only for redirecting to P2).

User avatar
nicksen782
Posts: 667
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by nicksen782 » Mon Dec 31, 2018 4:29 pm

If you go to http://keycode.info/ you can see how the browser interprets keys.

The key that I've been referring to as AltGr is seen as ContextMenu here.

Code: Select all

event.key == ContextMenu
event.location == 0
event.which (deprecated) == 93
event.code == ContextMenu
(I do not know the SDL key. I thought it was the SDLK_LMETA or SDLK_RMETA but neither worked. )

event.key == Alt
event.location == 1
event.which (deprecated) == 18
event.code == AltLeft
SDLK_LALT

event.key == Alt
event.location == 2
event.which (deprecated) == 18
event.code == AltRight
SDLK_RALT

event.key == \
event.location == 0
event.which (deprecated) == 220
event.code == Backslash
SDLK_BACKSLASH
I see by the code changes that you allow now for both Alts to affect the player 2 game pad. But the problem still remains since ALT is used in many browser key combos.

I was hoping to use the context menu key and a blocker such as this:

Code: Select all

// Prevent the context menu from appearing on the emulator canvas. This will allow for it to be used as a combo key.
emu.vars.dom.view.emuCanvas.addEventListener("contextmenu", function(evt){evt.preventDefault(); return false;});
I'm not interested in trying to hide the context menu. I'm more interested in claiming it as a key that I can use however I want. It is right next to the Alt key anyway.

I experimented with adding keys to CUzeBox. I could not figure out the context menu but I was able to configure the backslash key to work. I have no problem with that key. It is only 3 line changes.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest