maxmod icon indicating copy to clipboard operation
maxmod copied to clipboard

Use calloc to get clear mix buffer to prevent mix noise

Open aronson opened this issue 1 year ago • 5 comments

If one calls malloc instead of calloc here, the memory may not be clear, so there will be mixing noise when e.g. booting in Quick Boot mode from an Everdrive. It works fine on fresh systems, but calloc is require for more esoteric setups.

aronson avatar May 10 '24 02:05 aronson

This code doesn't work as is, calloc has a different signature from malloc:

void* malloc(size_t size);
void* calloc(size_t nmemb, size_t size);

you'd need to set r1 to 1 at minimum

LunarLambda avatar May 10 '24 09:05 LunarLambda

It was allocating too much memory, good catch. I've changed the code in question, and replaced more malloc calls with the appropriate calloc calls.

aronson avatar May 10 '24 12:05 aronson

The changes made to DS-specific routines do not accomplish anything (the allocated buffers are initialized prior to first use).

fincs avatar May 10 '24 17:05 fincs

the calloc parameter order doesn't matter, we already talked about this on Discord. It's much simpler to do it the wrong way and accept it doesn't matter than to edit a bunch more instructions to use r1 instead of r0

LunarLambda avatar May 10 '24 17:05 LunarLambda

I had a feeling the DS specific changes weren't necessary. I've restored the files.

aronson avatar May 10 '24 17:05 aronson