Imran Nazar
imrannazar.com · Personal blog · on HN since 2010
Imran Nazar writes about web development and retrocomputing, including a Game Boy emulator tutorial in JavaScript and Commodore 64 projects.
What HN saysCommenters recommend his Game Boy emulation series as an excellent writeup, and one is porting it to TypeScript to learn emulator writing.
41HN people shared it
21linked it in comments
36stories submitted
411story points
3 months agolast shared
2010people per year2026
Most-shared posts
- 1GameBoy Emulation in JavaScript: The CPU17 people · 14 points · first shared 2010 · discussion on HN
- 2Gameboy Emulation in Javascript and HTML510 people · 53 points · first shared 2010 · 7 comments on HN
- 3Pong Wars on the Commodore 643 people · 5 points · first shared 2026 · 1 comments on HN
- 4Extended Text Mode on the C642 people · 12 points · first shared 2018 · 1 comments on HN
- 5GameBoy Emulation in JS Part 8: Interrupts2 people · 4 points · first shared 2010 · discussion on HN
- 6Why was the Commodore 64 disk drive so slow?2 people · 1 points · first shared 2026 · discussion on HN
- 7De-Googling TOTP Authenticator Codes1 people · 105 points · first shared 2025 · 135 comments on HN
- 8Steganography with Brainfuck1 people · 75 points · first shared 2011 · 13 comments on HN
- 9Let's build a JPEG decoder: Huffman tables1 people · 69 points · first shared 2013 · 13 comments on HN
- 10Let's Build a JPEG Decoder, part one: Exploring the concepts of JPEG compression1 people · 21 points · first shared 2013 · discussion on HN
- 11GameBoy Emulation in JavaScript: Graphics1 people · 15 points · first shared 2010 · discussion on HN
- 12The Curious Case of Debian 12 and the SSH Failure1 people · 7 points · first shared 2024 · 3 comments on HN
- 13Let's build a JPEG Decoder1 people · 5 points · first shared 2013 · 1 comments on HN
- 14GameBoy Emulation in JavaScript: GPU Timings1 people · 5 points · first shared 2010 · discussion on HN
- 15How to write MS-DOS programs using only printable opcodes1 people · 3 points · first shared 2011 · 1 comments on HN
What HN people wrote when they linked it
Two9A · 2026-01-14
https://imrannazar.com - Sporadic blog posts on web development and retrocomputing
ngcc_hk · 2022-01-12
How it compares with the 12 years old javascript (my most beloved) simulator with detail explanation I wonder : https://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
mattlondon · 2020-04-05
Porting http://imrannazar.com/GameBoy-Emulation-in-JavaScript to Typescript as a way to learn about how to write an emulator, as well as taking advantage of newer JavaScript APIs (e.g. requestAnimationFrame, ArrayBuffer etc) that were not available when this series of articles was written in 2010.
We had a gameboy as a kid, but the ZX Spectrum (also Z80 CPU-based) meant more to me so hope to take what I learn from the great articles from imrannazar.com and apply to writing a ZX Speccy emulator (the gameboy had dedicated-hardware for sprites etc so not everything will be transferable).
Yes both gameboy & spectrum emulators in javascript have been done already, but this is just for personal learning/fun/itch-scratching. It has been quite instructive both from a remembering-fundamental-cs-classes/how-computers-really-work perspective, as well as modern javascript
elliottcarlson · 2012-01-10
It's also worth checking out Imran Nazar's excellent writeup on creating a Gameboy emulator in javascript: http://imrannazar.com/GameBoy-Emulation-in-JavaScript
Direct link to the first section, the CPU: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
JonnieCache · 2011-01-04
There used to be a demo floating around where someone had hacked this together with the firefox nightlies' support for the orientation sensor that allowed to your drive the kart by tilting your device. It worked for macbook as well as smartphones. Unfortunately the page is now down :( http://dougt.org/random/orientationdemo/index.xhtml
In lieu of that, I present to you something much more interesting: A complete step-by-step guide to writing your own fully functioning gameboy emulator in javascript+html5 (without sound.) It's really easy to follow even if you know nothing at all about emulators.
http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
timbit42 · 2026-01-08
It was not for no reason. When adding a screw hole in the motherboard so it could be mounted in the case, they accidentally removed the high speed wire, dooming the C64 to the same slow data speed of the VIC-20 with it's faulty VIA.
The C64 data speed actually ended up being even slower than the VIC-20. You can read the full detailed here: https://imrannazar.com/articles/commodore-1541
leeoniya · 2024-11-25
storing the tree as an MPTT/NestedSet would massively simplify this, without any subquery shenanigans.
https://en.m.wikipedia.org/wiki/Nested_set_model
https://imrannazar.com/articles/modified-preorder-tree-traversal
sprash · 2021-10-11
Personally I prefer the Novaterm font [1,2]. It is a bit larger (3x7 instead of 3x5) but supports full ASCII and is in my opinion much prettier.
1.: https://imrannazar.com/content/img/c64-80x25-font.png
2.: https://www.kludgesoft.com/c64/sc25.gif
geoah · 2021-09-20
I’ve always liked modified preorder tree travelsal for such usecases as they allow to deal with sub tree queries very easily at the expense of heavy writes. Probably not ideal for comments though as they change the tree way too often.
https://imrannazar.com/Modified-Preorder-Tree-Traversal
Macha · 2021-04-29
Depends on your area of interest. How to build a game boy emulator is pretty well trodden as it's usually used as the beginner's guide to emulation.
Here's a step by step guide in JS, for example: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
mburns · 2015-05-25
There was a detailed writeup of a different Gameyboy Emulator in Javascript:
http://imrannazar.com/GameBoy-Emulation-in-JavaScript
mattdotc · 2015-04-02
I believe you're thinking along the right lines. If you're really curious to learn more, check out this series which I have enjoyed reading:
http://imrannazar.com/GameBoy-Emulation-in-JavaScript
tnecniv · 2014-05-12
This was our bible: http://nocash.emubase.de/pandocs.htm
We would use this as a reference when we didn't know how to implement something since this was the first time either of us had done any sort of emulation: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
modarts · 2012-08-13
This makes for a good start: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
km3k · 2011-02-26
You might be thinking of Imran Nazarm, who documented the process of making a GameBoy emulator in Javascript: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
makmanalp · 2011-02-26
If you want to read on about how to go about building one of these, check out my friend Imran Nazar's very detailed jsgb article series:
http://imrannazar.com/GameBoy-Emulation-in-JavaScript
Also, the source code:
https://github.com/Two9A/jsGB
Jacquass12321 · 2011-01-19
Invariably been linked before, but http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU also addresses basics of emulator design.
Klonoar · 2011-01-10
This is some incredible work. There's a few ports out there I've tried, but this is by far the most performant yet. Definitely interested to see how further it's taken.
I'm also interested to see where the author learned about the inner workings of the Gameboy (i.e, if Nazar's work had any influence: http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU )
simias · 2019-04-15
If you're interested in making a GB emulator here are a few resources that helped me when I did just that a few years ago:
- An intro to making a GB emulator in JS (it doesn't matter if you don't plan on using JS, it still explains the basic concepts pretty well): http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU
- Opcode map (note that the GB CPU is not a stock Z80, it has different timings, different registers, different flags and different opcodes, do not use stock Z80 docs as a reference lest you end up with broken CPU emulation): http://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html
- The GameBoy programming manual: http://www.romhacking.net/documents/544/
- Accuracy test ROMs, very useful to make sure your timings are ok and you emulate various quirks of the hardware: http://tasvideos.org/EmulatorResources/GBAccuracyTests.html
Also note that even if you focus on making an original (DMG) GameBoy emulator you should be able to add GameBoy Color support later without too much difficulty, it's a fairly straightforward evolution of the original hardware.
drbawb · 2015-01-08
Sure!
This walkthrough[1] writing a Gameboy emulator in Javascript was very helpful in seeing how an emulator should be structured. -- Though the full source is available: the actual tutorial is more of a guideline that introduces you to the hardware and structure of the emulator. It often shows code-snippets instead of working code.
The Gameboy CPU Manual[2] and OP code chart[3] have been invaluable tools. In my experience: I spent most of my time flipping between the opcode chart and my CPU implementation.
As a tip: lots of the CPU instructions do the same thing w/ different register pairs. There is huge potential for code reuse here. In Rust I achieved it with macros, though.
Lastly: the "Pan Docs"[4] are more or less the same thing as the CPU Manual, but in a slightly more readable format.
Also there[5] are some test ROMs[6] that you can use for debugging.
I'm trying to find a good way to verify their results using Rust's unit testing.
`opus5.gb`[6] is a nice way to test the graphics subsystem; it's also a good "first ROM" to run because it has no additional ROM or RAM in the cartridge. In other-words: you don't need to implement the memory bank controllers to get it working.
---
And a little bit of friendly advice: _always_ keep debugging in the back of your mind. I usually resort to "printf debugging" but that really doesn't work inside a loop that's supposed to be ticking at 4.19MHz! :)
I accidentally filled up my disk once already; I forgot I had redirected…