Optimize the MOVESETS table for compression + eliminate 4 KB "handles" buffer from

libsysbase_libsysbase_a-handle_manager.o

So, I optimized the MOVESETS table to only store the "overriding" bits in the movesets of the evolutions
in relation to their base forms. That only improved compression slightly (about 300 bytes)

I also eliminated 4 KB of IWRAM usage by libsysbase_libsysbase_a-handle_manager.o because of the "handles"
buffer. We're not using it and we REALLY need our IWRAM. (and it also reduces the rom size with 4KB too!)
This commit is contained in:
Philippe Symons
2025-04-29 22:22:38 +02:00
parent 8e55a2bd52
commit 4c93ff869c
10 changed files with 600 additions and 68 deletions

View File

@@ -11,64 +11,6 @@
// unfortunately itoa is not standardized, so we'll have to make do with snprintf
static char conversion_buffer[33];
extern "C"
{
// HACK:
// Unfortunately, libtonc references siscanf, which in turn causes a "lot" of binary bloat from newlibc (in regards to locale support)
// to be pulled in by the linker.
// However, if you look at what it is actually used for (in libtonc's tte_iohook.c), is just to extract 1 or 2 integers from a string
// by specifying a custom -extremely simplified- version, we can avoid pulling in the version from libc (alongside all the symbols IT references)
// Obviously it doesn't support everything it should. Just enough to support libtonc's current iteration.
//
// Anyway, doing this optimizes away a lot of scanf related functions from newlib and locale support among which a 13KB "categories" symbol.
int siscanf(const char *str, const char *format, ...)
{
bool expectingFormatSpecifier = false;
va_list args;
int* resultVal;
int ret = 0;
va_start(args, format);
while(*format != '\0')
{
if(*str == '\0')
{
//EOF encountered.
return -1;
}
if(expectingFormatSpecifier)
{
if(*format == 'd')
{
resultVal = va_arg(args, int*);
(*resultVal) = 0;
while(isdigit(*str))
{
(*resultVal) *= 10;
(*resultVal) += (*str) - '0';
++str;
}
// go back to the last character of the int, because we'll forward by one again at the end of the outer loop
--str;
++ret;
}
expectingFormatSpecifier = false;
}
else if((*format) == '%')
{
expectingFormatSpecifier = true;
}
++format;
++str;
}
va_end(args);
return ret;
}
}
const char* ptgb::to_string(int intVal)
{
npf_snprintf(conversion_buffer, sizeof(conversion_buffer), "%d", intVal);