Working on building a utility library for the new llvm-mos compiler

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
Andrew900460
Posts: 2
Joined: Tue Dec 13, 2022 11:21 pm

Working on building a utility library for the new llvm-mos compiler

Post by Andrew900460 »

Of all places, I first discovered the existence of LLVM-MOS while playing around on Compiler Explorer https://godbolt.org/
Because I knew they had an option for CC65, but then I noticed they added a new one called "llvm-mos nes-nrom", and I was like "NO WAY, DOES IT INLINE?!". So I tested it, and it did way more than inlining. It's literally what I wanted with cc65. And then moment's later, I discovered that it also works with C++. And then my mind was blown even further! :shock:

I know I'm a few months late, but I was so envigorated by seeing this that I wanted to do somthing about it. Many months ago, I was actually trying to make some C code for doing 16bit fixed point operations with a fixed16 type. And it worked very well.
And I was able to make a 2 body gravity simulation and run it in a nes emulator, worked pretty well, but with a lot of concessions and unideal code styles, due to using a really old version of C.

But when I realised I could rewrite my code in C++, and possibly get additional performance gains from better optimizations, I was all in.
And I also want to share this, even if I'm not the first (but hopefully I am ┬┴┬┴┤_・) ├┬┴┬┴). I just finished rounding things off as well.

https://github.com/Andrew900460/llvm-mos-Game-Utilities

The intention is for this to just be a source of info people can grab from if they want.
I do plan on adding a Vector2 type as well (for fixed point, bytes, and shorts), and anything else that the llvm libraries doesn't provide that could be of use. Or other high-ish-level things.
Though, this is not my primary work right now, I have another big project I work on mostly, but this is a side thing I also like doing.

But I wanted to share this in case it ends up being very useful to a few people, and to celebrate llvm-mos's existence :P
Andrew900460
Posts: 2
Joined: Tue Dec 13, 2022 11:21 pm

Re: Working on building a utility library for the new llvm-mos compiler

Post by Andrew900460 »

I just added a basic struct for vector2 fixedpoint values.
And included some comments with benchmark scores for the math operations (idk if it's clock cycles or a time unit)

EDIT: Also, if there are any other people out there making their own similar libraries on github, please let me know.
I'm not sure if I'm the only one here making these kinds of things.
Post Reply