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.
70 lines
2.3 KiB
C
70 lines
2.3 KiB
C
#ifndef SCRIPT_ARRAY_H
|
|
#define SCRIPT_ARRAY_H
|
|
|
|
#include "script_obj.h"
|
|
#include "pokemon_party.h"
|
|
#include "rom_data.h"
|
|
#include "translated_text.h"
|
|
|
|
// Commands
|
|
#define T_SCRIPT_START DIA_END + 0
|
|
#define E_SCRIPT_START DIA_END + 1
|
|
#define CMD_START_LINK DIA_END + 2
|
|
#define CMD_IMPORT_POKEMON DIA_END + 3 // This one is special because it can be true or false
|
|
#define CMD_BACK_TO_MENU DIA_END + 4
|
|
#define CMD_SHOW_PROF DIA_END + 5
|
|
#define CMD_HIDE_PROF DIA_END + 6
|
|
#define CMD_SET_TUTOR_TRUE DIA_END + 7
|
|
#define CMD_END_SCRIPT DIA_END + 8
|
|
#define CMD_GAME_MENU DIA_END + 9
|
|
#define CMD_LANG_MENU DIA_END + 10
|
|
#define CMD_SLIDE_PROF_LEFT DIA_END + 11
|
|
#define CMD_SLIDE_PROF_RIGHT DIA_END + 12
|
|
#define CMD_CONTINUE_LINK DIA_END + 13
|
|
#define CMD_BOX_MENU DIA_END + 14
|
|
#define CMD_MYTHIC_MENU DIA_END + 15
|
|
#define CMD_LOAD_SIMP DIA_END + 16
|
|
#define CMD_CANCEL_LINK DIA_END + 17
|
|
#define CMD_END_MISSINGNO DIA_END + 18
|
|
|
|
#define CMD_SIZE 19
|
|
#define CMDS_END DIA_END + CMD_SIZE
|
|
|
|
// Conditionals
|
|
#define COND_ERROR_TIMEOUT_ONE CMDS_END + 0 // Didn't talk to the Cable Club attendant fast enough or cable not connected
|
|
#define COND_ERROR_DISCONNECT CMDS_END + 1 // If you unplug the cable after starting SPI
|
|
#define COND_ERROR_COM_ENDED CMDS_END + 2 // If you don't save the game
|
|
#define COND_ERROR_TIMEOUT_TWO CMDS_END + 3 // ???
|
|
#define COND_ERROR_COLOSSEUM CMDS_END + 4 // If the player selects the battle colosseum (shouldn't be possible)
|
|
#define COND_BEAT_E4 CMDS_END + 5
|
|
#define COND_MG_ENABLED CMDS_END + 6
|
|
#define COND_TUTORIAL_COMPLETE CMDS_END + 7
|
|
#define COND_NEW_POKEMON CMDS_END + 8
|
|
#define COND_IS_HOENN_RS CMDS_END + 9
|
|
#define COND_IS_FRLGE CMDS_END + 10
|
|
#define COND_MG_OTHER_EVENT CMDS_END + 11
|
|
#define COND_PKMN_TO_COLLECT CMDS_END + 12
|
|
#define COND_GB_ROM_EXISTS CMDS_END + 13
|
|
#define COND_CHECK_MYTHIC CMDS_END + 14
|
|
#define COND_CHECK_DEX CMDS_END + 15
|
|
#define COND_CHECK_KANTO CMDS_END + 16
|
|
#define COND_SOME_INVALID_PKMN CMDS_END + 17
|
|
#define COND_IS_HOENN_E CMDS_END + 18
|
|
#define COND_CHECK_MISSINGNO CMDS_END + 19
|
|
|
|
#define COND_SIZE 20
|
|
#define COND_END CMDS_END + COND_SIZE
|
|
|
|
// Ends
|
|
|
|
#define SCRIPT_SIZE COND_END
|
|
|
|
extern const script_obj_params transfer_script_params[];
|
|
extern const script_obj_params event_script_params[];
|
|
extern rom_data curr_rom;
|
|
|
|
void populate_lang_menu();
|
|
void populate_game_menu(int lang);
|
|
bool run_conditional(int index);
|
|
|
|
#endif |