Lurker News
OFRAK Tetris is a project I started at work about two weeks ago. It's a web-based game that works on desktop and mobile. I made it for my company to bring to events like DEF CON, and to promote our binary analysis and patching framework called OFRAK.

In the game, 32-bit, little-endian ARM assembly instructions fall, and you can modify the operands before executing them on a CPU emulator. There are two segments mapped – one for instructions, and one for data (though both have read, write, and execute permissions). Your score is a four byte signed integer stored at the virtual address pointed to by the R12 register, and the goal is to use the instructions that fall to make the score value in memory as high as possible. When it's game over, you can download your game as an ELF to relive the glory in GDB on your favorite ARM device.
The CPU emulator is a version of Unicorn (https://www.unicorn-engine.org/) that has been cross-compiled to WebAssembly (https://alexaltea.github.io/unicorn.js/), so everything on the page runs in the browser without the need for any complicated infrastructure on the back end.
Since I've only been working on this for a short period of time leading up to its debut at DEF CON, there are still many more features I'd eventually like to implement. These include adding support for other ISAs besides ARM, adding an instruction reference manual, and lots of little cleanups, bug fixes, and adjustments.
My highest score is 509,644,979, but my average is about 131,378.
I look forward to feedback, bug reports, feature requests, and strategy discussions!

Comments (53) 23 threads

Show all comments

Showing thread 15 of 23

ithkuil1 reply#
wow, you can even remap the keys!
jstrieb2 replies#
It also works with USB gamepads!

At DEF CON where we will have this set up in-person tomorrow, we will have people playing on a USB Dance Dance Revolution floor pad.

murkle1 reply#
Cool! Does that use the Gamepad API or WebHID? I'd like to get one working in the browser for one of my projects
jstrieb1 reply#
Uses the Gamepad API. I found it very easy to work with, in large part thanks to the corresponding MDN docs.

The only weird part about the Gamepad API is that you have to poll it rather than handling events the way you normally would for other, similar stuff in JavaScript. In practice, this means that you have to do your own debouncing for handling things like key combos, but that doesn't really affect individual button presses too much.

Continue this thread — 1 reply

thisOtterBeGood#
What an amazing idea.

Another thing to make the entry easier: Create a "Memory" label for the memory area. You mention it in the intro text but color it in the R12 address color which was confusing for me.
Missed that memory space totally while playing the first two times.