Better HN
topnewbestaskshowjobs
Log inSign up

binji

433 karma · joined Nov 12, 2013 (13y ago) · 45 submissions

Submissions

comment 5mo ago · link · parent

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.

comment 1y ago · link · parent

rgbds-live is more-or-less this same idea, with an embedded version of RGBDS: https://gbdev.io/rgbds-live/

comment 3y ago · link · parent

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.

comment 3y ago · link · parent

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

comment 3y ago · link · parent

nah, people can do whatever they want with it :)

comment 3y ago · link · parent

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/

comment 4y ago · link · parent

Thanks! I don't work much on WebAssembly anymore, but I'm super excited to see all the progress being made.

comment 4y ago · link · parent

That's true, I should have mentioned that I use this extension. It is supported by clang as well, however.

comment 4y ago · link · parent

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.

comment 4y ago · link · parent

Hi all, author here! Happy to answer any questions y'all have

comment 4y ago · link · parent

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!

comment 5y ago · link · parent

I think so, when I was doing the write-up I noticed a few things I could have improved (and a few bugs!)

comment 5y ago · link · parent

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. :)

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

Yep, I made a mistake it's actually 68.

comment 5y ago · link · parent

Ha, I guess we'll see when I go for my next gig :-)

comment 5y ago · link · parent

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.

comment 5y ago · link · parent

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 :-}

comment 5y ago · link · parent

Oops you're right, I should have mentioned that. Red works too, I just didn't want to write Blue/Red everwhere :)

comment 5y ago · link · parent

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...

comment 5y ago · link · parent

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...

comment 5y ago · link · parent

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!"

comment 5y ago · link · parent

Hi all, I'm the author of this post! Happy to answer any questions. :-)

comment 9y ago · link · parent

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....

comment 9y ago · link · parent

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.

comment 9y ago · link · parent

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....

comment 10y ago · link · parent

There is a FAQ entry on this point: https://github.com/WebAssembly/design/blob/master/FAQ.md#is-...

comment 10y ago · link · parent

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

comment 10y ago · link · parent

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

comment 10y ago · link · parent

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...

12