- 
                Notifications
    You must be signed in to change notification settings 
- Fork 36
More compact storage of SFX channel status and other flags? #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Replace PSGChannel{0-3}SFX variables by a bitfield (PSGChannelSFX).
Bit values as as per SFX_CHANNEL0-3 defines.
    | 
 😲 😲 so you'll not be happy to see that I'm going to use even more RAM when this branch is merged https://github.com/sverx/devkitSMS/tree/PSGlib_test as it adds separate attenuation for each music channel, so that's 3 bytes more than what was previously used... Anyway if I might suggest - I suspect you could save one more byte by also removing the  | 
| 
 Oh no... I don't need this feature, so I think I'll stick with the current version, for that project at least. 
 Oh good idea! | 
| sorry for 'breaking' this - I have another change to push but then I'll work on a NO_ATTENUATION version that will make it possible to compile the library without the attenuation parts, and after that we might try this 'more compact storage' route. Hang on! 😃 | 
| @raphnet one question though: are you using attenuation or not at all? | 
| @sverx I use attenuation (global, not separate) to fade out when switching songs. For the project where I am low on memory, I have already copied the files of my fork to a subdirectory of the project, and this works fine for me. I mean, I'm not waiting for you to merge this or waiting for the new features you are working on, so no pressure. I don't think I'll ever update the forked code in my project unless there is a problem which I can't easily backport. What would be best is a way to compile a SINGLE_ATTENUATION version of the library, which would also take the approach of using a bit field instead of one byte per boolean, for a minimum memory footprint. But as stated above, I do not need this now, and for other projects I usually don't mind a few extra bytes of memory use... So I totally understand if you do not wish to take this route. The library can already be compiled in so many ways with so many options, adding more options only complicates maintenance. | 
| 
 This is true, and your suggestion is wise. Since you're using a forked version with reduced memory footprint in your current memory hungry project, I will consider if I really need to proceed with my plan... I might do it anyway, but we'll see. Thank you so much! 👋 | 
At the moment one byte per SFX is used to store the "in use" flag, but those can also be stored as bits
in a shared location.
I reused the bit definitions of SFX_CHANNELx, so PSGSFXPlay can even set the variable directly. This saves 3 bytes.
Next I will probably try to save 3 more bytes by also defining bits for the flags below,
but I was wondering what you thought of that, and if this is a change you would accept.
My project has become extremely tight on RAM, even shaving 6 bytes makes me happy... yes I'm in trouble.