HNHacker News
TopNewBestAskShowJobs

binji

433 karma · joined November 12, 2013

submissionscomments
binji··on The 29th International Obfuscated C Code Contest (IOCCC) 2025 Winners
Very cool! Clearly I had a long way to go with mine to get it under the IOCCC requirements :) Though my goal was specifically Pokémon... curious how much more you would need to be able to run that.
binji··on Writing a Game Boy Emulator in OCaml (2022)
rgbds-live is more-or-less this same idea, with an embedded version of RGBDS: https://gbdev.io/rgbds-live/
binji··on McDonald's just dropped a brand new Game Boy game
Glad they've helped! There are plenty of better emulators, but I'm pretty proud of binjgb for being small, pretty fast, and pretty accurate.
binji··on McDonald's just dropped a brand new Game Boy game
heh, good point! Most of the older ones are using GameBoy-Online[0] instead, since that was the GB Studio default for a while. But I think everything since GBStudio 3 should be binjgb.

[0] https://github.com/taisel/GameBoy-Online

binji··on McDonald's just dropped a brand new Game Boy game
nah, people can do whatever they want with it :)
binji··on McDonald's just dropped a brand new Game Boy game
This is using my gameboy emulator, binjgb[0], on the website! (well one of my gameboy emulators, heh [1][2]) It's been used as the emulator for GB Studio for a little while now, but I don't know how often people embed it in their websites, so it's really cool to see.

[0] https://github.com/binji/binjgb [1] https://github.com/binji/pokegb [2] https://binji.github.io/raw-wasm/badgb/

binji··on Smolnes: A NES emulator in less than 5000 significant bytes of C++
Thanks! I don't work much on WebAssembly anymore, but I'm super excited to see all the progress being made.
binji··on Smolnes: A NES emulator in less than 5000 significant bytes of C++
That's true, I should have mentioned that I use this extension. It is supported by clang as well, however.
binji··on Smolnes: A NES emulator in less than 5000 significant bytes of C++
This was brought up for the last one of these I made, but the code here is c++ so wouldn't be allowed. I don't use a lot of c++ features, but it might be hard to keep the code size small without them.
binji··on Smolnes: A NES emulator in less than 5000 significant bytes of C++
Hi all, author here! Happy to answer any questions y'all have
binji··on Smolnes: A NES emulator in less than 5000 significant bytes of C++
I didn't handle audio for this emulator. But you can see how I handle resampling in my more fully-featured NES emulator here: https://github.com/binji/binjnes/blob/ca6977469168069a165176...

I'm not sure it's the right technique, but it seems to work pretty well!

binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
I think so, when I was doing the write-up I noticed a few things I could have improved (and a few bugs!)
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
I kind of dreaded writing that one, to be honest! I didn't quite cover all the details but I hope it made a little more sense. :)
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Yes, you can find all the meeting notes here: https://github.com/webassembly/meetings

However there were a lot of discussions that were not in those meetings and were in smaller groups or held in GitHub issues or PRs. Most of these were in https://github.com/webassembly/design.

binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Yep, I made a mistake it's actually 68.
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Ha, I guess we'll see when I go for my next gig :-)
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
I'm probably the wrong person to ask, to be honest. I was around for a lot of the design of Wasm, but wasn't really involved at that level.

That said, in my opinion the ideal set of opcodes really depends on your goal. There were many goals For Wasm, but I think there was a focus on keeping it small and simple. Originally it was AST-based, but it was changed to a stack machine to reduce size. It was also designed to be AoT or JIT compiled, so the opcode layout is not particularly friendly to hardware decoding or interpreters (although people have made some very high quality Wasm interpreters).

And of course there were a lot of discussions and disagreements about the best way forward: AST vs. register VM vs. stack machine. Structured control flow vs. goto. How to handle unreachable code. How to store integer literals (LEB vs. prefix byte). What the text format should look like (sexprs vs. ...?) etc.

binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Not sure, I think it should! Would be really cool if someone tried it out. I'm a little worried I didn't implement some necessary instructions/hardware features so the game isn't actually winnable :-}
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Oops you're right, I should have mentioned that. Red works too, I just didn't want to write Blue/Red everwhere :)
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
JVM is a great choice! You might also want to check out WebAssembly too (full disclosure: I used to work on wasm). There aren't too many opcodes, and a lot of them are relatively simple math operations.

Once you get it working, you could run things like JSLinux! https://bellard.org/jslinux/vm.html?url=win2k.cfg&mem=192&gr...

binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
I got kinda dragged about this on reddit/twitter. Afterwards I posted on r/tinycode with the size in bytes:

https://www.reddit.com/r/tinycode/comments/nn5djb/pokegb_a_g...

binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
It really is one of the best things about emulation development. It's surprising how quickly you go from "nothing works" to "I'm playing Super Mario Bros!"
binji··on Pokegb: A gameboy emulator that only plays Pokémon Blue, in 68 lines of C++
Hi all, I'm the author of this post! Happy to answer any questions. :-)
binji··on Show HN: A WebAssembly game demo
Very nice write-up, thanks!

BTW, I also ran into issues with ScriptProcessorNode when generating audio, and ended up using `createBufferSource` with a scheduled playback time. I wrote a little about it here: https://binji.github.io/2017/02/28/binjgb-on-the-web-part-2....

binji··on An Abridged Cartoon Introduction To WebAssembly
You may want to take a look at the formal spec here as well: https://webassembly.github.io/spec/

There's still some work to be done, but it is quite far along already.

binji··on The Ultimate Game Boy Talk (33c3) [video]
As long as we're linking personal GB emulators... :-)

Here's mine, written as one file of less than 5000 lines of C: https://github.com/binji/binjgb. It's very accurate, based on few of the most commonly used GB emulator test suites (Blargg's and Gekkio's).

Interestingly, there are still many questions about the specific timings of the Gameboy PPU and APU. An interesting case pointed about by LIJI128 is that no accurate emulator can run Pinball Deluxe; they all crash in some way: https://www.reddit.com/r/EmuDev/comments/4n71ea/gb_pinball_d....

binji··on WebAssembly Browser Preview
There is a FAQ entry on this point: https://github.com/WebAssembly/design/blob/master/FAQ.md#is-...
binji··on WebAssembly Browser Preview
That appears to use https://github.com/WebAssembly/polyfill-prototype-1, which does not match the current binary format at all.

The current way to do the equivalent would be to use Binaryen's asm2wasm tool.

https://github.com/WebAssembly/binaryen

binji··on WebAssembly Browser Preview
Here's the emscripten-compiled wast2wasm (from wabt): https://cdn.rawgit.com/WebAssembly/wabt/2baa1ecb0b36bea6268c...

It uses the code from here: https://github.com/WebAssembly/wabt/tree/master/demo

binji··on WebAssembly Browser Preview
TeaVM[1] has an experimental WebAssembly backend that does something like this. Here's the recent Reddit thread[2].

[1] http://teavm.org/ [2] https://www.reddit.com/r/programming/comments/5899ln/teavm_j...

Page 1 of 2Next →