mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-09-09 01:25:35 -05:00
Replace text_data_table with FileContainerReader
text_data_table was very similar in concept to FileContainerReader. But FileContainerReader is generally more flexible, as it allows you to split up your table into several chunks. This takes away the worry of these files getting too big to compress. However, we now have a maintenance duty for the text_tables file, which maps a table index to the list of chunks. We also need to be careful about every use of FileContainerReader::getPointerToFileInDecompressionBuffer(). Using it is fine when you're dealing with a single chunk or if you're sure the file doesn't span multiple chunks. But the moment you seek to a different chunk, any pointer obtained from getPointerToFileInDecompressionBuffer() becomes stale as the decompression buffer gets overwritten. Still, this function is necessary for high memory pressure situations, such as mystery_gift_builder, because we can't maintain multiple lineBuffers there.
This commit is contained in:
@@ -9,14 +9,21 @@
|
||||
#include "box_menu.h"
|
||||
#include "text_engine.h"
|
||||
#include "translated_text.h"
|
||||
#include "text_data_table.h"
|
||||
#include "FileContainerReader.h"
|
||||
#include "text_tables.h"
|
||||
|
||||
Box_Menu::Box_Menu() {};
|
||||
|
||||
int Box_Menu::box_main(PokeBox* box)
|
||||
{
|
||||
u8 names_decompression_buffer[3072];
|
||||
text_data_table PKMN_NAMES(names_decompression_buffer);
|
||||
u8 names_decompression_buffer[2048];
|
||||
u8 single_name_buffer[16];
|
||||
const u8 **chunkList;
|
||||
u32 numChunks;
|
||||
u32 chunkSize;
|
||||
|
||||
get_text_table_chunks(PKMN_NAMES_INDEX, &chunkList, &numChunks, &chunkSize);
|
||||
FileContainerReader namesReader(chunkList, numChunks, chunkSize);
|
||||
|
||||
tte_erase_screen();
|
||||
load_flex_background(FLEXBG_BOX, 2);
|
||||
@@ -36,7 +43,7 @@ int Box_Menu::box_main(PokeBox* box)
|
||||
obj_unhide(box_select, 0);
|
||||
int index = 0;
|
||||
|
||||
PKMN_NAMES.decompress(get_compressed_text_table(PKMN_NAMES_INDEX));
|
||||
namesReader.init(names_decompression_buffer, sizeof(names_decompression_buffer));
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -133,6 +140,8 @@ int Box_Menu::box_main(PokeBox* box)
|
||||
if (index < box->getNumInBox() && curr_pkmn->isValid)
|
||||
{
|
||||
byte val[11];
|
||||
u32 nameEntryIndex = curr_pkmn->getSpeciesIndexNumber();
|
||||
|
||||
tte_set_pos(6, 88);
|
||||
curr_pkmn->externalConvertNickname(val);
|
||||
ptgb_write_simple(val, true);
|
||||
@@ -144,15 +153,14 @@ int Box_Menu::box_main(PokeBox* box)
|
||||
ptgb_write_simple(val, true);
|
||||
}
|
||||
tte_set_pos(14, 98);
|
||||
if (curr_pkmn->getSpeciesIndexNumber() == MISSINGNO)
|
||||
{
|
||||
ptgb_write_simple(PKMN_NAMES.get_text_entry(0), true);
|
||||
}
|
||||
|
||||
else
|
||||
if(nameEntryIndex == MISSINGNO)
|
||||
{
|
||||
ptgb_write_simple(PKMN_NAMES.get_text_entry(curr_pkmn->getSpeciesIndexNumber()), true);
|
||||
nameEntryIndex = 0;
|
||||
}
|
||||
namesReader.readFile(nameEntryIndex, single_name_buffer);
|
||||
ptgb_write_simple(single_name_buffer, true);
|
||||
|
||||
tte_set_pos(6, 108);
|
||||
val[0] = 0xC6; // L
|
||||
val[1] = 0xEA; // v
|
||||
|
||||
Reference in New Issue
Block a user