TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: NESFab – Programming language for making NES games

298 pointsby pubbyabout 2 years ago
This is a long-running personal project I&#x27;ve had to write an optimizing compiler from scratch. Everything was done by me, including the lexer&#x2F;parser, SSA-based IR, high-performance data structures, and code generator.<p>Originally I wasn&#x27;t targeting the NES. It started as a scripting language, then it morphed into a C++ replacement, and then finally I turned it into what it is today. The large scope of the project and colorful history means it&#x27;s still a little rough around the edges, but it&#x27;s now working well enough to post.

24 comments

bmitcabout 2 years ago
As someone trying to undertake some personal projects like this, I have a question. How do you keep motivated enough to work on this for so long and dedicatedly? As a solo developer, how did you manage things like getting stuck on technical issues that were either bugs out of your control or something you didn&#x27;t have the knowledge to know how to fix?
评论 #35059014 未加载
评论 #35058926 未加载
评论 #35064783 未加载
评论 #35058590 未加载
Taikonerdabout 2 years ago
This is a really interesting approach. One thing that surprised me from the code snippet:<p><pre><code> fn play_sound() {$4015}(%100) {$4008}($FF) </code></pre> Are these hard-coded memory addresses meaningful to NES devs? I&#x27;m surprised that they don&#x27;t have more readable aliases, like $SOUND_ROM_BASE_ADDR or whatever.
评论 #35057676 未加载
评论 #35057571 未加载
mungoman2about 2 years ago
I have long dreamed of a language for 8-bit computers&#x2F;consoles with a compiler that helps scheduling routines.<p>For example, let&#x27;s say I have a short snippet of code that needs to run every H blanking period. I should just declare something like<p>@every_hblank Blabla_code()<p>Or scheduling some code for X pixels into a line.<p>Actual scheduling can be done however the compiler wants to, using interrupts or inserting dummy instructions for delays.<p>I guess in the end it&#x27;s a constraint problem to solve where all these snippets fit in.<p>I imagine this makes it easier to write games&#x2F;special effects as you remove the tricky cycle counting. Easier, but maybe less fun...
评论 #35062598 未加载
russellsproutsabout 2 years ago
Just read through the documentation. There are so many great ideas for generating efficient code. `goto mode` in particular is an awesome idea. Generalizing the program to have multiple &quot;entry&quot; points and overlapping their global variables to save RAM, I&#x27;ve never heard of that technique before.<p>The inline assembly integration looks nice too -- accessing the arguments and return address as fields on the function makes a lot of sense.
leroy-is-hereabout 2 years ago
I didn’t take a deep dive, but I’m interested in how you keep the binary size small. Is it simply that LLVM, etc., all have too much function overhead and don’t take advantage of routines over subroutines (function calls)? Or is your back-end just specialized enough to take advantage of architecture-specific features the larger compiler suites don’t have the time to care about?<p>Anyway, this looks dope. Truthfully, we could use more hyper-specific languages like this in all sorts of areas.
评论 #35060805 未加载
pkayeabout 2 years ago
You should make a link to the examples directory prominent on the webpage so others get an quick idea of the language features.
lastdongabout 2 years ago
Congrats on the release! Website and code look super clean, and looks like super useful for anyone getting into NES game development.<p>- What languages did you use as inspiration?<p>- Is it possible to write a game to a physical cartridge and play it on a real snes?<p>Thanks for sharing your amazing work!
Timwiabout 2 years ago
Out of curiosity, why did you disallow tabs for indentation, and &#x2F;<i>...</i>&#x2F;-style comments in the middle of a line?
评论 #35067098 未加载
foldorabout 2 years ago
Really cool stuff! Is there an syntax highlighter available on any IDE&#x27;s like VSCode available? I&#x27;m having a hard time following the documentation without it as it&#x27;s hard for me to know what is a keyword and what is a variable for example. Single letter types can be hard for me to follow, but I can definitely appreciate their style.<p>Nice work.
terrycodyabout 2 years ago
Hey I think a lot of nostalgic people sometimes want to hack the game ROMs instead of making a new one. For example, they may want to add more characters, use enemy roles, add more skills and fun things, does your programming language can also provide such purposes?
hunta2097about 2 years ago
I got a Windows Defender alert when downloading the Windows binary:<p>Detected: Trojan:Script&#x2F;Wacatac.H!ml<p>Status: Removed<p>Details: This program is dangerous and executes commands from an attacker.
评论 #35060875 未加载
apple4everabout 2 years ago
This is awesome! I&#x27;m currently learning programming NES in assembler with FamicomParty[0], and this look like a great next step!!<p>0. <a href="https:&#x2F;&#x2F;famicom.party" rel="nofollow">https:&#x2F;&#x2F;famicom.party</a>
jonny_ehabout 2 years ago
&gt; Handling banks is normally a tedious affair for programmers, but NESFab handles it for you. The compiler smartly allocates code and data into banks, with the gritty details abstracted away.<p>Killer feature, but is there a cost to bank switching? Could abstracting it result in a lot of performance cost?
评论 #35062268 未加载
a_e_kabout 2 years ago
Nice work! Pubby, it looks like the markdown for the documentation goes off the rails in 12.3.
warpspinabout 2 years ago
Pretty cool project. While I never did NES games, I did assembler on the C64 for a while. The language alone minus the NES parts would already have been super useful back then at least for the high level parts of the programs I wrote.
agentultraabout 2 years ago
This is very cool. I had wanted to do a project like this once. Nice work!
nubinetworkabout 2 years ago
Its nice that people are still writing code for the NES, but I have to ask what makes this better than using ca65... assembly isn&#x27;t hard to learn.
评论 #35057902 未加载
AdmiralAsshatabout 2 years ago
Does this language have support for being able to save the game&#x27;s state into a simulated battery a la Legend of Zelda&#x2F;Metroid?
评论 #35059184 未加载
评论 #35062877 未加载
stehtisch123about 2 years ago
Awesome! Is it hard&#x2F;possible to put the finished game on a cartridge or do you play it with an emulator?
tibbonabout 2 years ago
Not to increase your scope, but have you considered making it work across other 6502 systems?
评论 #35057170 未加载
评论 #35059388 未加载
nunobritoabout 2 years ago
It is looking fantastic. Great work!
dom96about 2 years ago
Really cool but shouldn&#x27;t this actually be a library rather than a programming language?
评论 #35064194 未加载
评论 #35059453 未加载
algemabout 2 years ago
this is really cool, thanks for sharing.
benj111about 2 years ago
Why spaces and not tabs for indents?<p>I know this conversation has probably been had many times before. But if I prefer a 2 space tab, and you prefer a 4 space tab, we both get them how we want them with tabs.<p>With spaces, I have to put up with your stupidly wide indents, and try not to scratch my eyes out from the pain.
评论 #35057462 未加载
评论 #35057475 未加载
评论 #35057296 未加载
评论 #35057310 未加载
评论 #35062019 未加载
评论 #35057692 未加载