mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-03-21 17:34:42 -05:00
Adding text debug menu
This commit is contained in:
parent
2482bb486b
commit
2309f7c493
2
Makefile
2
Makefile
|
|
@ -1,5 +1,5 @@
|
|||
# Build configuration (set to either 'debug' or 'release')
|
||||
BUILD_TYPE := release
|
||||
BUILD_TYPE := debug
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
|
|
|
|||
2
PCCS
2
PCCS
|
|
@ -1 +1 @@
|
|||
Subproject commit 1c98a391c2261c8141c8917160b2040514a0c2ee
|
||||
Subproject commit db430d84c27bf196ab61e07d4b4588ddc093da08
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
#define BTN_EVENTS 3
|
||||
#define BTN_CREDITS 4
|
||||
#define BTN_OPENING 5
|
||||
#define BTN_TEXT_DEBUG 6
|
||||
|
||||
#define BUTTON_CANCEL UINT8_MAX
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
#define DEBUG_MODE_H
|
||||
|
||||
#define VERSION "v1.2.1"
|
||||
#define PTGB_BUILD_LANGUAGE 2
|
||||
#define PTGB_BUILD_LANGUAGE ENGLISH
|
||||
|
||||
#define DEBUG_MODE false
|
||||
#define DEBUG_MODE true
|
||||
|
||||
#define PRINT_LINK_DATA (false && DEBUG_MODE)
|
||||
#define INSTANT_TEXT_SPEED (false && DEBUG_MODE)
|
||||
|
|
@ -24,6 +24,7 @@
|
|||
#define PAYLOAD_EXPORT_TEST (false && DEBUG_MODE)
|
||||
#define DONT_TRANSFER_POKEMON_AT_INDEX_X (false && DEBUG_MODE)
|
||||
#define POKEMON_INDEX_TO_SKIP 5
|
||||
#define ENABLE_TEXT_DEBUG_SCREEN (true && DEBUG_MODE)
|
||||
|
||||
#define DEBUG_GAME EMERALD_ID
|
||||
#define DEBUG_VERS VERS_1_0
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@
|
|||
#define INK_ROM_COLOR 14
|
||||
#define INK_DARK_GREY 13
|
||||
|
||||
#define SCRIPT_DEBUG 0
|
||||
#define SCRIPT_TRANSFER 1
|
||||
#define SCRIPT_EVENT 2
|
||||
|
||||
void init_text_engine();
|
||||
int text_loop(int script);
|
||||
int text_next_obj_id(script_obj current_line);
|
||||
|
|
|
|||
|
|
@ -317,16 +317,22 @@ int credits()
|
|||
}
|
||||
};
|
||||
|
||||
#define NUM_MENU_OPTIONS 3
|
||||
|
||||
int main_menu_loop()
|
||||
{
|
||||
#if ENABLE_TEXT_DEBUG_SCREEN
|
||||
#define NUM_MENU_OPTIONS 4
|
||||
const uint8_t menu_options[NUM_MENU_OPTIONS] = {GENERAL_option_transfer, GENERAL_option_dreamdex, GENERAL_option_credits, GENERAL_option_text_debug};
|
||||
int return_values[NUM_MENU_OPTIONS] = {BTN_TRANSFER, BTN_POKEDEX, BTN_CREDITS, BTN_TEXT_DEBUG};
|
||||
#else
|
||||
#define NUM_MENU_OPTIONS 3
|
||||
const uint8_t menu_options[NUM_MENU_OPTIONS] = {GENERAL_option_transfer, GENERAL_option_dreamdex, GENERAL_option_credits};
|
||||
int return_values[NUM_MENU_OPTIONS] = {BTN_TRANSFER, BTN_POKEDEX, BTN_CREDITS};
|
||||
#endif
|
||||
|
||||
uint8_t general_text_table_buffer[2048];
|
||||
text_data_table general_text(general_text_table_buffer);
|
||||
bool update = true;
|
||||
const uint8_t menu_options[NUM_MENU_OPTIONS] = {GENERAL_option_transfer, GENERAL_option_dreamdex, GENERAL_option_credits};
|
||||
const uint8_t *text_entry;
|
||||
int return_values[NUM_MENU_OPTIONS] = {BTN_TRANSFER, BTN_POKEDEX, BTN_CREDITS};
|
||||
u16 test = 0;
|
||||
|
||||
general_text.decompress(get_compressed_text_table(GENERAL_INDEX));
|
||||
|
|
@ -380,8 +386,8 @@ int main_menu_loop()
|
|||
}
|
||||
}
|
||||
|
||||
// Legal mumbo jumbo
|
||||
static void show_legal_text(const u8* intro_text)
|
||||
// Legal stuff
|
||||
static void show_legal_text(const u8 *intro_text)
|
||||
{
|
||||
tte_set_margins(8, 8, H_MAX - 8, V_MAX - 8);
|
||||
tte_set_pos(8, 8);
|
||||
|
|
@ -535,7 +541,7 @@ int main(void)
|
|||
tte_set_ink(INK_DARK_GREY);
|
||||
obj_hide_multi(ptgb_logo_l, 2);
|
||||
load_flex_background(BG_FENNEL, 3);
|
||||
text_loop(BTN_TRANSFER);
|
||||
text_loop(SCRIPT_TRANSFER);
|
||||
break;
|
||||
case (BTN_POKEDEX):
|
||||
if (get_tutorial_flag())
|
||||
|
|
@ -560,7 +566,13 @@ int main(void)
|
|||
break;
|
||||
case (BTN_EVENTS):
|
||||
obj_hide_multi(ptgb_logo_l, 2);
|
||||
text_loop(BTN_EVENTS);
|
||||
text_loop(SCRIPT_EVENT);
|
||||
break;
|
||||
case (BTN_TEXT_DEBUG):
|
||||
tte_set_ink(INK_DARK_GREY);
|
||||
REG_BG1CNT = (REG_BG1CNT & ~BG_PRIO_MASK) | BG_PRIO(3);
|
||||
obj_hide_multi(ptgb_logo_l, 2);
|
||||
text_loop(SCRIPT_DEBUG);
|
||||
break;
|
||||
default:
|
||||
global_next_frame();
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "latin_short.h"
|
||||
#include "japanese_small.h"
|
||||
#include "text_data_table.h"
|
||||
#include "background_engine.h"
|
||||
|
||||
#define TEXT_CBB 0
|
||||
#define TEXT_SBB 10
|
||||
|
|
@ -28,7 +29,7 @@ bool text_exit;
|
|||
// Doing it this way does mean that we need to completely restart decompression whenever we switch from dialog entry.
|
||||
// but given that it requires user input to do so, I believe it's worth it and not time-critical.
|
||||
// attribute noinline was used to make sure the compiler doesn't inline this code back into text_loop()
|
||||
static __attribute__((noinline)) const u8* read_dialogue_text_entry(uint8_t index, u8 *output_buffer)
|
||||
static __attribute__((noinline)) const u8 *read_dialogue_text_entry(uint8_t index, u8 *output_buffer)
|
||||
{
|
||||
u8 text_decompression_buffer[6144];
|
||||
const u8 *text_entry;
|
||||
|
|
@ -43,6 +44,21 @@ static __attribute__((noinline)) const u8* read_dialogue_text_entry(uint8_t inde
|
|||
return output_buffer;
|
||||
}
|
||||
|
||||
static __attribute__((noinline)) const u8 *read_dialogue_text_entry(uint8_t index, uint8_t text_section, u8 *output_buffer)
|
||||
{
|
||||
u8 text_decompression_buffer[6144];
|
||||
const u8 *text_entry;
|
||||
|
||||
text_data_table dialogue_table(text_decompression_buffer);
|
||||
|
||||
dialogue_table.decompress(get_compressed_text_table(text_section));
|
||||
|
||||
text_entry = dialogue_table.get_text_entry(index);
|
||||
memcpy(output_buffer, text_entry, dialogue_table.get_text_entry_size(index));
|
||||
|
||||
return output_buffer;
|
||||
}
|
||||
|
||||
void init_text_engine()
|
||||
{
|
||||
// Load the TTE
|
||||
|
|
@ -82,51 +98,148 @@ int text_loop(int script)
|
|||
u8 diag_entry_text_buffer[1024];
|
||||
switch (script)
|
||||
{
|
||||
case BTN_TRANSFER:
|
||||
case SCRIPT_DEBUG:
|
||||
curr_line = transfer_script_params[0];
|
||||
break;
|
||||
|
||||
case SCRIPT_TRANSFER:
|
||||
curr_line = transfer_script_params[T_SCRIPT_START];
|
||||
break;
|
||||
|
||||
case BTN_EVENTS:
|
||||
case SCRIPT_EVENT:
|
||||
curr_line = event_script_params[E_SCRIPT_START];
|
||||
break;
|
||||
}
|
||||
|
||||
curr_text = (curr_line.has_text()) ? read_dialogue_text_entry(curr_line.get_text_entry_index(), diag_entry_text_buffer) : NULL;
|
||||
|
||||
REG_BG1CNT = (REG_BG1CNT && !BG_PRIO_MASK) | BG_PRIO(2); // Show Fennel
|
||||
show_text_box();
|
||||
// tte_set_margins(LEFT, TOP, RIGHT, BOTTOM);
|
||||
while (true) // This loops through all the connected script objects
|
||||
if (script != SCRIPT_DEBUG)
|
||||
{
|
||||
if (curr_text != NULL && curr_text[char_index] != 0xFF && curr_text[char_index] != 0xFB)
|
||||
REG_BG1CNT = (REG_BG1CNT && !BG_PRIO_MASK) | BG_PRIO(2); // Show Fennel
|
||||
show_text_box();
|
||||
while (true) // This loops through all the connected script objects
|
||||
{
|
||||
tte_set_pos(LEFT, TOP);
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
ptgb_write(curr_text, char_index);
|
||||
if (curr_text != NULL && curr_text[char_index] != 0xFF && curr_text[char_index] != 0xFB)
|
||||
{
|
||||
tte_set_pos(LEFT, TOP);
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
ptgb_write(curr_text, false);
|
||||
}
|
||||
|
||||
wait_for_user_to_continue(false);
|
||||
|
||||
line_char_index = 0;
|
||||
switch (script)
|
||||
{
|
||||
case BTN_TRANSFER:
|
||||
curr_line = transfer_script_params[text_next_obj_id(curr_line)];
|
||||
break;
|
||||
case BTN_EVENTS:
|
||||
curr_line = event_script_params[text_next_obj_id(curr_line)];
|
||||
break;
|
||||
}
|
||||
|
||||
curr_text = (curr_line.has_text()) ? read_dialogue_text_entry(curr_line.get_text_entry_index(), diag_entry_text_buffer) : NULL;
|
||||
char_index = 0;
|
||||
|
||||
if (text_exit)
|
||||
{
|
||||
hide_text_box();
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
text_exit = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Debug script loop
|
||||
{
|
||||
u16 debug_charset[256];
|
||||
load_localized_charset(debug_charset, 3, ENGLISH);
|
||||
|
||||
wait_for_user_to_continue(false);
|
||||
|
||||
line_char_index = 0;
|
||||
switch (script)
|
||||
int text_section = 0;
|
||||
int text_identifier = 0;
|
||||
while (true)
|
||||
{
|
||||
case BTN_TRANSFER:
|
||||
curr_line = transfer_script_params[text_next_obj_id(curr_line)];
|
||||
break;
|
||||
case BTN_EVENTS:
|
||||
curr_line = event_script_params[text_next_obj_id(curr_line)];
|
||||
break;
|
||||
}
|
||||
bool exit = false;
|
||||
bool update_text = true;
|
||||
key_poll();
|
||||
while (!exit)
|
||||
{
|
||||
if (key_hit(KEY_LEFT))
|
||||
{
|
||||
text_identifier = (text_identifier + (text_section_lengths[text_section] - 1)) % text_section_lengths[text_section];
|
||||
update_text = true;
|
||||
}
|
||||
else if (key_hit(KEY_RIGHT))
|
||||
{
|
||||
text_identifier = (text_identifier + 1) % text_section_lengths[text_section];
|
||||
update_text = true;
|
||||
}
|
||||
else if (key_hit(KEY_UP))
|
||||
{
|
||||
text_section = (text_section + 1) % NUM_TEXT_SECTIONS;
|
||||
update_text = true;
|
||||
}
|
||||
else if (key_hit(KEY_DOWN))
|
||||
{
|
||||
text_section = (text_section + (NUM_TEXT_SECTIONS - 1)) % NUM_TEXT_SECTIONS;
|
||||
update_text = true;
|
||||
}
|
||||
else if (key_hit(KEY_START))
|
||||
{
|
||||
exit = true;
|
||||
}
|
||||
if (update_text)
|
||||
{
|
||||
if (text_identifier > text_section_lengths[text_section])
|
||||
{
|
||||
text_identifier = text_section_lengths[text_section];
|
||||
}
|
||||
if (text_section > NUM_TEXT_SECTIONS)
|
||||
{
|
||||
text_section = NUM_TEXT_SECTIONS;
|
||||
}
|
||||
tte_set_pos(0, 0);
|
||||
tte_erase_rect(0, 0, 240, 160);
|
||||
ptgb_write_debug(debug_charset, "(", true);
|
||||
ptgb_write_debug(debug_charset, ptgb::to_string(text_section), true);
|
||||
ptgb_write_debug(debug_charset, ", ", true);
|
||||
ptgb_write_debug(debug_charset, ptgb::to_string(text_identifier), true);
|
||||
ptgb_write_debug(debug_charset, ")", true);
|
||||
update_text = false;
|
||||
}
|
||||
global_next_frame();
|
||||
}
|
||||
|
||||
curr_text = (curr_line.has_text()) ? read_dialogue_text_entry(curr_line.get_text_entry_index(), diag_entry_text_buffer) : NULL;
|
||||
char_index = 0;
|
||||
line_char_index = 0;
|
||||
curr_text = read_dialogue_text_entry(text_identifier, text_section, diag_entry_text_buffer);
|
||||
char_index = 0;
|
||||
|
||||
if (text_exit)
|
||||
{
|
||||
if (curr_text != NULL && curr_text[char_index] != 0xFF && curr_text[char_index] != 0xFB)
|
||||
{
|
||||
if (text_section == PTGB_INDEX)
|
||||
{
|
||||
reset_textbox();
|
||||
}
|
||||
else
|
||||
{
|
||||
create_textbox(4, 1, 160, 80, true);
|
||||
}
|
||||
show_text_box();
|
||||
tte_erase_rect(0, 0, 240, 160);
|
||||
ptgb_write(curr_text, true);
|
||||
}
|
||||
|
||||
wait_for_user_to_continue(false);
|
||||
update_text = true;
|
||||
hide_text_box();
|
||||
tte_erase_rect(LEFT, TOP, RIGHT, BOTTOM);
|
||||
text_exit = false;
|
||||
return 0;
|
||||
|
||||
if (text_exit)
|
||||
{
|
||||
text_exit = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -184,15 +297,15 @@ int ptgb_write(const byte *text, bool instant, int length)
|
|||
TFont *font;
|
||||
int num = 0;
|
||||
|
||||
/*
|
||||
if (curr_text[char_index] == 0xFB) // This will need to be moved
|
||||
{
|
||||
line_char_index += char_index;
|
||||
line_char_index++;
|
||||
// Low key kinda scuffed, but it works to split the string
|
||||
curr_text = &curr_line.get_text()[line_char_index];
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (curr_text[char_index] == 0xFB) // This will need to be moved
|
||||
{
|
||||
line_char_index += char_index;
|
||||
line_char_index++;
|
||||
// Low key kinda scuffed, but it works to split the string
|
||||
curr_text = &curr_line.get_text()[line_char_index];
|
||||
}
|
||||
*/
|
||||
while ((ch = *str) != 0xFF && num < length)
|
||||
{
|
||||
if (get_frame_count() % 2 == 0 || key_held(KEY_B) || key_held(KEY_A) || instant)
|
||||
|
|
@ -253,7 +366,7 @@ int ptgb_write(const byte *text, bool instant, int length)
|
|||
return 0; // str - text;
|
||||
}
|
||||
// This is mostly used for debug stuff, I shouldn't rely it on it much.
|
||||
int ptgb_write_debug(const u16* charset, const char *text, bool instant)
|
||||
int ptgb_write_debug(const u16 *charset, const char *text, bool instant)
|
||||
{
|
||||
byte temp_holding[256];
|
||||
int i;
|
||||
|
|
@ -296,6 +409,7 @@ void wait_for_user_to_continue(bool clear_text)
|
|||
fennel_speak(0);
|
||||
}
|
||||
}
|
||||
key_poll();
|
||||
while (!(key_hit(KEY_A) || key_hit(KEY_B) || curr_text == NULL))
|
||||
{
|
||||
global_next_frame();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user