Good to know. I’ll try with the minimal game lib, see how much it improves.
Numbers being 32 bits is usable if I can set bits directly, but as I understand it uses floating points. I’ll try recoding it with a buffer. My current approach is to use one bit to encode color (black or white), then 15 bits (only up to 120*160 though) to encode number of times the color appears in a row.
One interesting thought is manual code generation, though I know its probably a poor idea. I just saw a binary.asm file and thought it would in theory be possible to compile from something like C++ or even C#.
Here are the links to my code. I split it into two projects since it’s easier to work on that way.
I found that less than 4096 unique color-length combos existed, so instead of using 16 bits to represent a line of pixels, I use 12 bits for the index in the map, where unique color-length combos are stored in a separate array. I know this doesn’t make a difference right now though since it’s 32 bits to store a number either way, I just wanted to set it up well for the future, where three bytes could hold the indices of two color-lengths.
The two possibilities were halving the resolution to quarter storage use, and using a more advanced compression algorithm, though that might make it take too long to generate a frame.
The midi data is stored in a number[][4]
, [startTime, pitch, length, instrument]
. From what you said about triple arrays being inefficient, I’d imagine it would be better to have a unique array for each property, and just have them each be the same size. A buffer could also significantly reduce the size since I can store start time in 11 bits, pitch in 6, channel in 3 bits, and length in 3 bits, so 3 bytes per note, 14kb total. May also create premade segments of music that are common and repeat, like the drum track. Should reduce storage dramatically.
One other question, about game.onUpdateInterval(period: number, a: () => void)
. Does this work off of in game time, or real time? I’m assuming real time, like game.runtime()
but I wanted to check just in case.
Hopefully those explain everything, but let me know if there’s anything I should clarify.