Live data from Hacker News

Statically Recompiling NES Games into Native Executables with LLVM and Go

andrewkelley.me

91–100 of 103 posts

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#91
post #51

Somewhat off-topic, but to defend gcc against clang, here is a modern version of gcc with the correct warning option: $ gcc-4.8 -std=gnu99 -Wall -o test test.c test.c: In function 'main': test.c:6:5: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses] if (foo & 0x80 == 0x80) { ^ gcc 4.9 will have colored diagnostics, too. Cool project, though.

This would be a great way, on a compiler or project that doesn't have this warning enabled, to conceal a deliberate bug and have it appear to be accidental.

Hey, check out the Underhanded C Contest.

http://underhanded.xcott.com

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#92

What is amazing here is not the techy stuff, but productivity and clear understanding of concepts. Of course, such shape (of mind) comes from years of daily practice. That's why I know I will never write anything good - I didn't spend enough time practicing. Practice leads to perfection (not reading HN). And look, the guy is not using any IDE or proprietary tools - just a terminal window and command line (what a horr…

It depends on what you are used to. I started programming in the 1980s and the first editor I used was pretty much like EDLIN (http://en.wikipedia.org/wiki/Edlin)---think of an unholy cross between the Unix commands cat and vi (line based and modal).

And, except for code completion, there isn't anything an IDE can do that can't be done via the command line (just not as conveniently). Then again, I don't program in Java.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#93
post #51

Somewhat off-topic, but to defend gcc against clang, here is a modern version of gcc with the correct warning option: $ gcc-4.8 -std=gnu99 -Wall -o test test.c test.c: In function 'main': test.c:6:5: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses] if (foo & 0x80 == 0x80) { ^ gcc 4.9 will have colored diagnostics, too. Cool project, though.

The rivalry between gcc and clang has been wonderful for everybody who use either of them.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#94
post #89

Earlier quoted context omitted.

I'm not quite sure what the point of this project is, as MESS is rather slow when built natively [1]. Perhaps some of the lower end systems can be emulated, albeit slowly. [1] http://www.mess.org/faq#it_works_but_it_is_way_too_slow

The point is historical preservation: Putting ancient games and systems on the Web as a way to enable people to experience them, as part of digital museums, online academic papers, and such, to provide some (imperfect) context for what would otherwise be dry technical history. It's in JS because it's the only language that doesn't require plugins, and so has a better-than-average chance of running on a variety of dif…

But why use a deliberately slow emulator as a base for all of this? Is accuracy really that important when compared to being able to run it on a wide variety of hardware? Why not just bundle some existing JS emulators together or take some fast native emulators and do the emscripten thing?

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#95
This is one of the best articles I've seen linked here in a long time. oP covers so much stuff but simplifies exactly where needed so everything stays understandable and there are no gaps (the "how to paint an owl" syndrome).

Thank you so much for writing and posting this. You made my day.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#96
Very interesting article indeed. Some time ago I made something similar for GameBoy games and ran into the same set of challenges (and ended up using similar techniques). The ROM is decompiled and translated into C code, which is then compiled and linked with runtime libraries. Jump tables and indirect jumps often need some manual fixing. I went up to the point where I can convert some simple games (without memory mappers) into binaries running on iOS and X. I did not have the time to document the tools but if anyone is interested to continue that work just let me know.

I guess one of the advantages of static recompilation is that you can port old games to new platforms if you hold the copyright of the game itself, but without running into issues with the manufacturer of the console (Nintendo)--but I might be wrong. You could also conceivably improve the game more easily during conversion (e.g., incorporate higher-resolution graphics). Finally, you could potentially have the resulting code distributed via app stores that do not allow general-purpose emulators.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#97
post #51

Somewhat off-topic, but to defend gcc against clang, here is a modern version of gcc with the correct warning option: $ gcc-4.8 -std=gnu99 -Wall -o test test.c test.c: In function 'main': test.c:6:5: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses] if (foo & 0x80 == 0x80) { ^ gcc 4.9 will have colored diagnostics, too. Cool project, though.

Some of these warnings start delving a bit too close to "Warning: Competent C programmer detected", ... too eager to flag "less common" usage like the dreaded 'original definition of the insertion operator' rather than specifically targeting things that are genuinely suspicious.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#98
post #92

What is amazing here is not the techy stuff, but productivity and clear understanding of concepts. Of course, such shape (of mind) comes from years of daily practice. That's why I know I will never write anything good - I didn't spend enough time practicing. Practice leads to perfection (not reading HN). And look, the guy is not using any IDE or proprietary tools - just a terminal window and command line (what a horr…

It depends on what you are used to. I started programming in the 1980s and the first editor I used was pretty much like EDLIN ( http://en.wikipedia.org/wiki/Edlin)---think of an unholy cross between the Unix commands cat and vi (line based and modal). And, except for code completion, there isn't anything an IDE can do that can't be done via the command line (just not as conveniently). Then again, I don't program in J…

vi is a small miracle of software engineering.

Re: Statically Recompiling NES Games into Native Executables with LLVM and Go

#100
post #54

Earlier quoted context omitted.

I've looked at this sort of stuff as utter voodoo for a long time. Then I ran into this book[1], and everything just kind of 'clicked' into place in my head. I can't recommend this book often enough. [1]: http://www.nand2tetris.org/book.php In short: It gives you a hands-on approach in designing and building your own computer and programming language, to end up writing and running your own games on the system. * It s…

Firefox indicates that nand2tetris.org has been reported as an attack page. Has the site been compromised? Anybody know how to contact the author? Edit: just noticed the original Edit mentioning that you contacted one of the authors.

Same with Chrome. Beware this link.
Post reply on HN