diff --git a/source/gameboy_colour.cpp b/source/gameboy_colour.cpp index 998d6ea..b73931e 100644 --- a/source/gameboy_colour.cpp +++ b/source/gameboy_colour.cpp @@ -130,7 +130,7 @@ void print(const char *format, ...) tte_erase_rect(0, 0, H_MAX, V_MAX); tte_set_pos(0, 0); ptgb_write_simple(reinterpret_cast("#{cx:0xE000}"), true); - ptgb_write_simple((byte*)(spi_text_out_array[j]), true); + ptgb_write_simple((byte *)(spi_text_out_array[j]), true); } } @@ -228,7 +228,8 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ text_data_table general_text(general_text_table_buffer); general_text.decompress(get_compressed_text_table(GENERAL_INDEX)); - ptgb_write_simple(general_text.get_text_entry(curr_gb_rom->version != YELLOW_ID ? GENERAL_link_success : GENERAL_link_success_yellow), true); + ptgb_write_textbox(general_text.get_text_entry(GENERAL_link_success), true, false, + GENERAL_INDEX, GENERAL_link_success, false); } link_animation_state(STATE_NO_ANIM); @@ -278,7 +279,8 @@ byte handleIncomingByte(byte in, byte *box_data_storage, byte *curr_payload, GB_ text_data_table general_text(general_text_table_buffer); general_text.decompress(get_compressed_text_table(GENERAL_INDEX)); - ptgb_write_simple(general_text.get_text_entry(GENERAL_transferring), true); + ptgb_write_textbox(general_text.get_text_entry(GENERAL_transferring), true, false, + GENERAL_INDEX, GENERAL_transferring, false); } link_animation_state(STATE_TRANSFER); @@ -609,7 +611,7 @@ byte exchange_boxes(byte curr_in, byte *box_data_storage, GB_ROM *curr_gb_rom, c n2hexstr(&outArr[currRow][14], init_packet, 2); outArr[currRow][16] = ' '; - //create_textbox(0, 0, 125, 110, false); + // create_textbox(0, 0, 125, 110, false); link_animation_state(0); ptgb_write_debug(debug_charset, *outArr, true); diff --git a/source/script_array.cpp b/source/script_array.cpp index 7ca00ad..2776b76 100644 --- a/source/script_array.cpp +++ b/source/script_array.cpp @@ -832,11 +832,11 @@ bool run_conditional(int index) return true; case CMD_SHOW_PROF: - load_flex_background(FLEXBG_FENNEL, 2); + //load_flex_background(FLEXBG_FENNEL, 3); return true; case CMD_HIDE_PROF: - load_flex_background(FLEXBG_FENNEL, 3); + //load_flex_background(FLEXBG_FENNEL, 3); return true; case CMD_SET_TUTOR_TRUE: diff --git a/source/sprite_data.cpp b/source/sprite_data.cpp index dc0deb1..01a847f 100644 --- a/source/sprite_data.cpp +++ b/source/sprite_data.cpp @@ -10,7 +10,7 @@ OBJ_ATTR obj_buffer[128]; OBJ_AFFINE *obj_aff_buffer = (OBJ_AFFINE *)obj_buffer; -int curr_flex_background; +int curr_flex_background = -1; int y_offset = 0; int y_offset_timer = 0; int y_offset_direction = 1; @@ -126,69 +126,73 @@ void set_background_pal(int curr_rom_id, bool dark, bool fade) void load_flex_background(int background_id, int layer) { - // This prevents screen tearing on this frame - global_next_frame(); - BG_FLEX = (BG_FLEX && !BG_PRIO_MASK) | BG_PRIO(3); - int CBB = 3; // CBB is the tiles that make up the sprite int SBB = 31; // SSB is the array of which tile goes where - switch (background_id) + + if (curr_flex_background != background_id) // Only load the background if it isn't already loaded { - case (FLEXBG_OPENING): - // Load palette - tonccpy(pal_bg_mem + 32, openingBGPal, openingBGPalLen); - // Load tiles into CBB 0 - LZ77UnCompVram(openingBGTiles, &tile_mem[CBB][0]); - // Give it a frame to uncompress the data + // This prevents screen tearing on this frame global_next_frame(); - // Load map into SBB 0 - LZ77UnCompVram(openingBGMap, &se_mem[SBB][0]); - REG_BG1VOFS = 96; - break; - case (FLEXBG_FENNEL): - // Load palette - tonccpy(pal_bg_mem + 32, fennelBGPal, fennelBGPalLen); - // Load tiles into CBB 0 - LZ77UnCompVram(fennelBGTiles, &tile_mem[CBB][0]); - // Give it a frame to uncompress the data - global_next_frame(); - // Load map into SBB 0 - LZ77UnCompVram(fennelBGMap, &se_mem[SBB][0]); - REG_BG1VOFS = FENNEL_SHIFT; - break; - case (FLEXBG_DEX): - // Load palette - tonccpy(pal_bg_mem + 32, dexBGPal, dexBGPalLen); - // Load tiles into CBB 0 - LZ77UnCompVram(dexBGTiles, &tile_mem[CBB][0]); - // Give it a frame to uncompress the data - global_next_frame(); - // Load map into SBB 0 - LZ77UnCompVram(dexBGMap, &se_mem[SBB][0]); - REG_BG1VOFS = 0; - break; - case (FLEXBG_MAIN_MENU): - // Load palette - tonccpy(pal_bg_mem + 32, pal_bg_mem, backgroundPalLen); - // Load tiles into CBB 0 - LZ77UnCompVram(menu_barsTiles, &tile_mem[CBB][0]); - // Give it a frame to uncompress the data - global_next_frame(); - // Load map into SBB 0 - LZ77UnCompVram(menu_barsMap, &se_mem[SBB][0]); - REG_BG1VOFS = 0; - break; - case (FLEXBG_BOX): - // Load palette - tonccpy(pal_bg_mem + 32, boxBGPal, boxBGPalLen); - // Load tiles into CBB 0 - LZ77UnCompVram(boxBGTiles, &tile_mem[CBB][0]); - // Give it a frame to uncompress the data - global_next_frame(); - // Load map into SBB 0 - LZ77UnCompVram(boxBGMap, &se_mem[SBB][0]); - REG_BG1VOFS = 0; - break; + BG_FLEX = (BG_FLEX && !BG_PRIO_MASK) | BG_PRIO(3); + + switch (background_id) + { + case (FLEXBG_OPENING): + // Load palette + tonccpy(pal_bg_mem + 32, openingBGPal, openingBGPalLen); + // Load tiles into CBB 0 + LZ77UnCompVram(openingBGTiles, &tile_mem[CBB][0]); + // Give it a frame to uncompress the data + global_next_frame(); + // Load map into SBB 0 + LZ77UnCompVram(openingBGMap, &se_mem[SBB][0]); + REG_BG1VOFS = 96; + break; + case (FLEXBG_FENNEL): + // Load palette + tonccpy(pal_bg_mem + 32, fennelBGPal, fennelBGPalLen); + // Load tiles into CBB 0 + LZ77UnCompVram(fennelBGTiles, &tile_mem[CBB][0]); + // Give it a frame to uncompress the data + global_next_frame(); + // Load map into SBB 0 + LZ77UnCompVram(fennelBGMap, &se_mem[SBB][0]); + REG_BG1VOFS = FENNEL_SHIFT; + break; + case (FLEXBG_DEX): + // Load palette + tonccpy(pal_bg_mem + 32, dexBGPal, dexBGPalLen); + // Load tiles into CBB 0 + LZ77UnCompVram(dexBGTiles, &tile_mem[CBB][0]); + // Give it a frame to uncompress the data + global_next_frame(); + // Load map into SBB 0 + LZ77UnCompVram(dexBGMap, &se_mem[SBB][0]); + REG_BG1VOFS = 0; + break; + case (FLEXBG_MAIN_MENU): + // Load palette + tonccpy(pal_bg_mem + 32, pal_bg_mem, backgroundPalLen); + // Load tiles into CBB 0 + LZ77UnCompVram(menu_barsTiles, &tile_mem[CBB][0]); + // Give it a frame to uncompress the data + global_next_frame(); + // Load map into SBB 0 + LZ77UnCompVram(menu_barsMap, &se_mem[SBB][0]); + REG_BG1VOFS = 0; + break; + case (FLEXBG_BOX): + // Load palette + tonccpy(pal_bg_mem + 32, boxBGPal, boxBGPalLen); + // Load tiles into CBB 0 + LZ77UnCompVram(boxBGTiles, &tile_mem[CBB][0]); + // Give it a frame to uncompress the data + global_next_frame(); + // Load map into SBB 0 + LZ77UnCompVram(boxBGMap, &se_mem[SBB][0]); + REG_BG1VOFS = 0; + break; + } } BG_FLEX = BG_CBB(CBB) | BG_SBB(SBB) | BG_4BPP | BG_REG_32x32 | BG_PRIO(layer); diff --git a/source/text_engine.cpp b/source/text_engine.cpp index be7c4c5..c43b344 100644 --- a/source/text_engine.cpp +++ b/source/text_engine.cpp @@ -121,8 +121,7 @@ int text_loop(int script) // tte_set_margins(LEFT, TOP, RIGHT, BOTTOM); if (script != SCRIPT_DEBUG) { - BG_FLEX = (BG_FLEX && !BG_PRIO_MASK) | BG_PRIO(2); // Show Fennel - while (true) // This loops through all the connected script objects + while (true) // This loops through all the connected script objects { if (curr_text != NULL && curr_text[char_index] != 0xFF && curr_text[char_index] != 0xFB) { @@ -273,6 +272,11 @@ int ptgb_write_textbox(const byte *text, bool instant, bool waitForUser, tte_erase_rect(0, 0, H_MAX, V_MAX); erase_textbox_tiles(); create_textbox(text_section, text_key, eraseMainBox); + // Set up Fennel if we are in a PTGB dialogue box + if (get_curr_flex_background() == FLEXBG_FENNEL && text_section == PTGB_INDEX) + { + load_flex_background(FLEXBG_FENNEL, 2); + } int out = ptgb_write(text, instant, 9999, text_box_type_tables[text_section][text_key]); // This is kinda silly but it'll work. if (waitForUser) { diff --git a/tools/text_helper/text.xlsx b/tools/text_helper/text.xlsx index 353d9b2..cb41809 100644 Binary files a/tools/text_helper/text.xlsx and b/tools/text_helper/text.xlsx differ