mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-03-21 17:34:42 -05:00
Add a binary table format and convert the text entries into this format in text_helper/main.py. It then gets compressed with zx0. The new text_data_table and streamed_data_table classes exist to read the various entries from this binary table. streamed_data_table specifically exists to use a decompression buffer that is smaller than the actual binary table. But it requires a decompression buffer that is still larger than ZX0_DEFAULT_WINDOW_SIZE (default: 2048 bytes) and will only be able to decompress in chunks of (<decompression_buffer_size> - <ZX0_DEFAULT_WINDOW_SIZE>) bytes Try to keep the binary text tables sufficiently small though, because since zx0 doesn't actually support random access, getting to the last entry is significantly more expensive than reading the first one. And unless you use streamed_data_table, it also requires <uncompressed_size> bytes of stack space, therefore IWRAM to decompress them. I also had to rework script_array because it can no longer reference the strings directly. Instead we now reference the DIA_* "enum" values. We also no longer store an array of script_obj instances, because these were getting stored in IWRAM since they're non-const global variables originally. Instead we now have const arrays of script_obj_params structs, which should end up in .rodata -> therefore EWRAM. Right now, script_obj only supports the PTGB text table (originally the dialogue array). But if the need arises to support other tables as well, I'd consider adding a separate enum to script_obj_params to indicate the specific table. The compilation process will also output .su files in the build folder from now on. These files indicate the stack frame size for every function in every compilation unit, so be sure to check them from time to time. Note that they will only show the stack consumption for that specific function. So to get the worst case stack consumption, you need to manually add all the functions in a certain stack flow.
40 lines
943 B
C++
40 lines
943 B
C++
#include "script_obj.h"
|
|
|
|
script_obj::script_obj()
|
|
: params_({0})
|
|
{
|
|
};
|
|
|
|
script_obj::script_obj(const script_obj_params ¶ms)
|
|
: params_(params)
|
|
{
|
|
}
|
|
|
|
bool script_obj::has_text() const
|
|
{
|
|
// So the thing is: when conditional_index is set, its value will always be higher than 0
|
|
// because the way these integer defines have been set up.
|
|
// So that means that if conditional_index IS 0, then we must have a text entry index defined instead!
|
|
// We can't base this check on the text_entry_index itself since unfortunately its value being zero can be legit.
|
|
return (params_.conditional_index == 0);
|
|
}
|
|
|
|
u8 script_obj::get_text_entry_index() const
|
|
{
|
|
return params_.text_entry_index;
|
|
}
|
|
|
|
u16 script_obj::get_true_index() const
|
|
{
|
|
return params_.next_if_true;
|
|
}
|
|
|
|
u16 script_obj::get_false_index() const
|
|
{
|
|
return params_.next_if_false;
|
|
}
|
|
|
|
u16 script_obj::get_cond_id() const
|
|
{
|
|
return params_.conditional_index;
|
|
} |