News for hackers. Stuff that matters.
Re:Writing a Game Boy Emulator in OCaml by Gunax on Wednesday January 12, 2022 @09:27AM (#29906678)
I wrote (or tried writing) a gameboy emulator once.

My only qarning is that there are a lot of edge cases in the specification--and the proper specs are wrong.

I ended up spending most of the time searching through undocumented/missing CPU specifications. It became rather tedious.

For a learning project, this made it poorly suited. There are so many good emulators out there, the only reason to write one is for the learning experience. I just felt that I stopped oearning after a while and was just debugging obscure combinations of cpu states.

Re:Writing a Game Boy Emulator in OCaml by aquova on Wednesday January 12, 2022 @09:36AM (#29906783)
That was more or less my experience. I got the original Game Boy working well, and quite a few Game Boy Color games, but it eventually devolved into debugging CPU timing issues and edge cases with sprite bugs. At some point I realized that I had gained all of the knowledge I had wished to learn and since my own emulator was never really going to do anything that hundreds of others weren't already doing better I moved on. I will say it was a good learning experience however. Chip-8 is a good start, but there are lots of concepts that emulating a Game Boy will require that Chip-8 does not.
Re:Writing a Game Boy Emulator in OCaml by jmholla on Wednesday January 12, 2022 @10:17AM (#29907488)
I'd recommend maybe trying something simpler, like a Motorola 6811 or a MIPS processor. Their instruction sets are pretty simple and straightforward. But, I can see how that might not be as fulfilling.
Re:Writing a Game Boy Emulator in OCaml by tombert on Wednesday January 12, 2022 @09:31AM (#29906721)
That seems to be the consensus that I've read online.

Still, the reason I want to do it online is specifically because I want an excuse to really understand low-level hardware. I (and probably a majority of people on HN who do software) really only have "real" experience with "Java or Higher" with maybe hitting C if I have the rare occasion of having to worry about saving a few milliseconds. An emulator would force me understand low level hardware, or at least I think it would.

Re:Writing a Game Boy Emulator in OCaml by coldpie on Wednesday January 12, 2022 @10:39AM (#29907853)
Another fun option for learning low-level stuff is analyzing existing games. I did this to create a level map dumper for one of my favorite NES games[1]. You can see other ideas on the excellent Displaced Gamers YouTube channel, for example[2].

Also, read the book Code by Charles Petzold.

[1] https://tcrf.net/Proto:M.C._Kids#Level_Changes

[2] https://www.youtube.com/watch?v=zGdpst_6k9k

Re:Writing a Game Boy Emulator in OCaml by yoyohello13 on Wednesday January 12, 2022 @12:03PM (#29909503)
I think Nand 2 Tetris [1] is a really good way to get a good intro to this stuff at a basic level without too much friction with tools. You essentially start with a nand gate, and eventually build up a whole computer including a Java-like programming language.

[1]: https://www.nand2tetris.org/

Re:Writing a Game Boy Emulator in OCaml by rjhallsted on Wednesday January 12, 2022 @01:44PM (#29911120)
I've been meaning to get to Nand2Tetris, it looks really interesting.