3 ms·
I've been on/off working on a homebrew NES game. Pretty much the go-to environment for that is assembly, which I'm sure I could write if I were motivated, but
by tombert 8mo ago
I've been on/off working on a homebrew NES game. Pretty much the go-to environment for that is assembly, which I'm sure I could write if I were motivated, but I find assembly considerably un-fun so I wanted to use a higher-level language.
I had been looking for an excuse to learn Forth, and its use in classic computing meant that it had a shot of being workable on the NES.
I was initially using IceForth but I had trouble getting that working, and so I got Codex to generate something that works, but then I also that building your own Forth is sort of a rite of passage for a software engineer, so I have been building my own Forth from scratch.
My custom hack-job isn't ready yet, but I was extremely impressed at the performance I was able to get on the NES with compiled Forth from the Codex thing on the NES. I'm getting roughly 80% of the speed for equivalent programs written in assembly, with much less code and this is without advanced optimizations. I do plan on finishing my custom one because I think I can build what I want a bit better than Codex, and I'm optimistic I can get the performance reasonable.
Forth is such a fascinating language, because it sort of enables you to work at any level of the program. You can write it super high level, almost like Lisp, but you can also poke around and create mappings to assembly, and you can do all this with decent performance no less! It has quickly become one of my more favorite scripting languages, though that might be because I have always had a soft spot for RPN.
- don-bright 8mo agothats so awesome. i wonder what a live forth interpreter would look like on NES.
- tombert 8mo agoA live interpreter turns out to be very slow! It's still useful but it's about 1/10th the speed of the compiled version. I've mostly just been using it to play with placement and test out my ppu logic. Honestly a lot of the work is being handled by BizHawk. The compiler is pretty neat though; my current system is doing a straightforward conversion of the threaded-code quasi-AST thing that Forth does and convert it all to JSR calls, where each name is a subroutine. I haven't done a ton of optimizations yet, so I'm actually surprised it's going as fast as it is. I am just going to say this is yet another "Forth is awesome" thing. Once I get it into a more stable state, I'll push it up to SourceHut.