Fixing some graphics tearing

This commit is contained in:
The Gears of Progress 2025-04-08 14:28:30 -04:00
parent 7338828331
commit 08f6838c91
10 changed files with 278 additions and 230 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -4,12 +4,12 @@
#define VERSION "v1.2.0b"
#define PTGB_BUILD_LANGUAGE ENG_ID
#define DEBUG_MODE false
#define DEBUG_MODE true
#define PRINT_LINK_DATA (false && DEBUG_MODE) // This is currently broken... not sure why
#define INSTANT_TEXT_SPEED (false && DEBUG_MODE)
#define IGNORE_GAME_PAK (true && DEBUG_MODE)
#define IGNORE_LINK_CABLE (true && DEBUG_MODE)
#define IGNORE_LINK_CABLE (false && DEBUG_MODE)
#define IGNORE_MG_E4_FLAGS (true && DEBUG_MODE)
#define IGNORE_UNRECEIVED_PKMN (true && DEBUG_MODE)
#define FORCE_TUTORIAL (false && DEBUG_MODE)

Binary file not shown.

View File

@ -101,8 +101,7 @@ void load_graphics()
tte_erase_rect(0, 0, H_MAX, V_MAX);
// Load opening background first so it hides everything else
load_flex_background(BG_OPENING, 1);
load_background();
load_textbox_background();
load_background(); load_textbox_background();
load_eternal_sprites();
// Set up global yes no button
@ -223,6 +222,7 @@ int credits()
bool update = true;
global_next_frame();
while (true)
{
if (update)
@ -340,7 +340,7 @@ int main_menu_loop()
for (int i = 0; i < NUM_MENU_OPTIONS; i++)
{
int size = get_string_length(menu_options[i]);
int char_width = (curr_rom.language == JPN_ID ? 8 : 6);
int char_width = (PTGB_BUILD_LANGUAGE == JPN_ID ? 8 : 6);
int x = ((240 - (size * char_width)) / 2);
tte_set_pos(x, ((i * 17) + 80));
if (i == curr_selection)
@ -384,7 +384,6 @@ int main(void)
{
initalization_script();
//wow
// Set colors based on current ROM
set_background_pal(0, false, false);
@ -433,8 +432,8 @@ int main(void)
bool start_pressed = false;
REG_BLDCNT = BLD_BUILD(BLD_BG3, BLD_BG0, 1);
int char_width = (curr_rom.language == JPN_ID ? 8 : 6);
int size = get_string_length(press_start);
int char_width = (PTGB_BUILD_LANGUAGE == JPN_ID ? 8 : 6);
int x = ((240 - (size * char_width)) / 2);
tte_set_pos(x, 12 * 8);
@ -456,6 +455,7 @@ int main(void)
while (!curr_rom.load_rom())
{
obj_hide_multi(ptgb_logo_l, 2);
global_next_frame();
game_load_error();
// initalization_script();
}
@ -497,16 +497,20 @@ int main(void)
case (BTN_TRANSFER):
tte_set_ink(INK_DARK_GREY);
obj_hide_multi(ptgb_logo_l, 2);
load_flex_background(BG_FENNEL, 2);
load_flex_background(BG_FENNEL, 3);
text_loop(BTN_TRANSFER);
break;
case (BTN_POKEDEX):
load_flex_background(BG_DEX, 2);
set_background_pal(curr_rom.gamecode, true, false);
obj_hide_multi(ptgb_logo_l, 2);
pokedex_loop();
load_flex_background(BG_DEX, 3);
set_background_pal(curr_rom.gamecode, false, false);
if (get_tutorial_flag())
{
obj_hide_multi(ptgb_logo_l, 2);
global_next_frame();
load_flex_background(BG_DEX, 2);
set_background_pal(curr_rom.gamecode, true, false);
pokedex_loop();
load_flex_background(BG_DEX, 3);
set_background_pal(curr_rom.gamecode, false, false);
}
break;
case (BTN_CREDITS):
tte_set_ink(INK_DARK_GREY);

View File

@ -118,8 +118,13 @@ void set_background_pal(int curr_rom_id, bool dark, bool fade)
#include "dexBG.h"
#include "menu_bars.h"
#include "boxBG.h"
void load_flex_background(int background_id, int layer)
{
// This prevents screen tearing on this frame
global_next_frame();
REG_BG1CNT = (REG_BG1CNT && !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)
@ -129,6 +134,8 @@ void load_flex_background(int background_id, int layer)
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;
@ -138,6 +145,8 @@ void load_flex_background(int background_id, int layer)
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;
@ -147,6 +156,8 @@ void load_flex_background(int background_id, int layer)
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;
@ -156,6 +167,8 @@ void load_flex_background(int background_id, int layer)
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;
@ -165,6 +178,8 @@ void load_flex_background(int background_id, int layer)
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;
@ -243,7 +258,7 @@ static int TILE_SW_L_ARR[4] = {TILE_CLEAR, TILE_CLEAR, TILE_SW_4L, TILE_SW_6L};
void add_menu_box(int options, int startTileX, int startTileY)
{
add_menu_box(startTileX, startTileY, (MENU_WIDTH) * 8, options * 10);
add_menu_box(startTileX, startTileY, (MENU_WIDTH) * 8, (options * 10) + 16);
}
void add_menu_box(int startTileX, int startTileY, int full_width, int full_height)
@ -255,7 +270,7 @@ void add_menu_box(int startTileX, int startTileY, int full_width, int full_heigh
int SBB = 20;
int start = (32 * startTileY) + startTileX;
int tiles = (full_height / 8) - 2;
int tiles = (full_height / 8) - 2; // For the extra 2 tiles
int rem = full_height % 8;
full_width /= 8;

View File

@ -68,6 +68,7 @@ int text_loop(int script)
}
curr_text = curr_line.get_text();
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

File diff suppressed because one or more lines are too long

View File

@ -82,6 +82,24 @@ jpnCharArray = [
0x3A, 0xC4, 0xD6, 0xDC, 0xE4, 0xF6, 0xFC, 0x2A, 0x20, 0x20, 0x15E, 0x23C, 0x206, 0x1B2, 0x147, 0x19E,
]
jpnCharWidthArray = [
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8,
0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x28, 0x0, 0x0, ]
charConversionList = [
# replaces the first char in the list with the latter
["'", ""],
@ -124,12 +142,22 @@ def SplitSentenceIntoLines(sentence, offset, pixelsPerChar, pixelsInLine):
# Figure out the length of the word in pixels
for char in word:
if (pixelsPerChar == "Variable Latin Font"):
wordLength += engCharWidthArray[convertByte(ord(char), engCharArray)]
spaceLength = engCharWidthArray[convertByte(ord(' '), engCharArray)]
else:
wordLength += pixelsPerChar
spaceLength = pixelsPerChar
if (pixelsPerChar == "Variable"):
if(lang == Languages.Japanese):
wordLength += jpnCharWidthArray[convertByte(ord(char), engCharArray)]
spaceLength = jpnCharWidthArray[convertByte(ord(' '), engCharArray)]
else:
wordLength += engCharWidthArray[convertByte(ord(char), engCharArray)]
spaceLength = engCharWidthArray[convertByte(ord(' '), engCharArray)]
elif (pixelsPerChar == "Default"):
if (lang == Languages.Japanese):
wordLength += 8
spaceLength = 8
else:
wordLength += 6
spaceLength = 6
# See if the whole sentence is a newline
if (sentence == "Ň"):
@ -330,7 +358,7 @@ def convert_item(ogDict):
arr = engCharArray
for char in outStr[:-1]:
byteStr += hex(convertByte(ord(char), arr)) + ", "
if outStr[-1] != ' ': # Check if the last char is a space
if (len(outStr) > 0 and outStr[-1] != ' '): # Check if the last char is a space
byteStr += hex(convertByte(ord(outStr[-1]), arr)) + ", "
byteStr += "0xff"

File diff suppressed because one or more lines are too long

Binary file not shown.