I just released my first #OoT-inspired data structure: oot_bitset. it's so simple its a single header file in C with a few defines. Yes you heard it right. A datastructure library inspired by an n64 game from the 1998, thanks to the oot decompilation project. Now its documented and available for anyone to use.

It's almost so obvious in retrospect, but I don't think I've ever seen an implementation like this before. Usually its some complex library that tries to do everything. What if you only need to store less than 4096 flags compactly in a small array? This is the library for you.

Back in this era brutal simplicity was the norm. Sometimes I wish we got back to that.

https://github.com/jb55/oot_bitset

Reply to this note

Please Login to reply.

Discussion

Too many years of video games I read that as Ocarina of Time

it is ocarina of time

its a data structure I found within the game and released it as a library

So cool!

first oot inspired library? lol.

Thanks.

If you like that, you should read Donald Knuth's "The Art of Computer Programming". It is full of very simple and powerful things that sometimes aren't obvious and will amaze you. It amazed me. I guess it's a textbook, but somehow I remember it more like a book of magic incantations.

yup I have a few of those. very intense books.

Starring that repo. Super cool, concise, easy to understand, can easily be added to any C/C++ project. Thanks for sharing!

neat eh? this is why I love C programming :D

I feel like really learning C programming pays dividends in how one thinks about code in just about every other language.

Very cool, how did you end discovering it? Were you just randomly exploring the repo?

in the decompilation project, there is tons of code like this:

if (GET_INFTABLE(INFTABLE_TOLD_EPONA_IS_SCARED)) {

}

which led to these macros:

#define INFTABLE_INDEX(flag) ((flag) >> 4)

#define INFTABLE_MASK(flag) (1 << ((flag) & 0xF))

#define GET_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] & INFTABLE_MASK(flag))

#define SET_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] |= INFTABLE_MASK(flag))

#define CLEAR_INFTABLE(flag) (gSaveContext.save.info.infTable[INFTABLE_INDEX(flag)] &= ~INFTABLE_MASK(flag))

// INFTABLE 0x0-0xF

#define INFTABLE_INDEX_0 0

#define INFTABLE_00 0x00

#define INFTABLE_01 0x01

#define INFTABLE_03 0x03

#define INFTABLE_05 0x05

...

I was curious what the INDEX and MASK thing were doing and then I realized it was a bitset/bitvector/bitmap

Sir, are we not going back to such things if you have to express complicated systems in Nostr events?