[WIP] Drawing fixed star select text

This commit is contained in:
KiritoDev 2021-04-22 00:33:13 -05:00
parent 01563890d9
commit b829ddb0f9
2 changed files with 5 additions and 123 deletions

View File

@ -33,6 +33,7 @@
#include "text/text-loader.h"
#include <math.h>
#include "pc/gfx/gfx_pc.h"
#include "moon/utils/moon-gfx.h"
u16 gDialogColorFadeTimer;
s8 gLastDialogLineNum;
@ -426,81 +427,9 @@ void print_hud_lut_string(s8 hudLUT, s16 x, s16 y, const u8 *str) {
}
}
#ifdef VERSION_EU
void print_menu_char_umlaut(s16 x, s16 y, u8 chr) {
void **fontLUT = segmented_to_virtual(menu_font_lut);
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[chr]);
gDPLoadSync(gDisplayListHead++);
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_8b_BYTES));
gSPTextureRectangle(gDisplayListHead++, x << 2, y << 2, (x + 8) << 2, (y + 8) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[DIALOG_CHAR_UMLAUT]);
gDPLoadSync(gDisplayListHead++);
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_8b_BYTES));
gSPTextureRectangle(gDisplayListHead++, x << 2, (y - 4) << 2, (x + 8) << 2, (y + 4) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
}
#endif
void print_menu_generic_string(s16 x, s16 y, const u8 *str) {
UNUSED s8 mark = DIALOG_MARK_NONE; // unused in EU
s32 strPos = 0;
s32 curX = x;
s32 curY = y;
void **fontLUT = segmented_to_virtual(menu_font_lut);
while (str[strPos] != DIALOG_CHAR_TERMINATOR) {
switch (str[strPos]) {
#ifdef VERSION_EU
case DIALOG_CHAR_UPPER_A_UMLAUT:
print_menu_char_umlaut(curX, curY, ASCII_TO_DIALOG('A'));
curX += gDialogCharWidths[str[strPos]];
break;
case DIALOG_CHAR_UPPER_U_UMLAUT:
print_menu_char_umlaut(curX, curY, ASCII_TO_DIALOG('U'));
curX += gDialogCharWidths[str[strPos]];
break;
case DIALOG_CHAR_UPPER_O_UMLAUT:
print_menu_char_umlaut(curX, curY, ASCII_TO_DIALOG('O'));
curX += gDialogCharWidths[str[strPos]];
break;
#else
case DIALOG_CHAR_DAKUTEN:
mark = DIALOG_MARK_DAKUTEN;
break;
case DIALOG_CHAR_PERIOD_OR_HANDAKUTEN:
mark = DIALOG_MARK_HANDAKUTEN;
break;
#endif
case DIALOG_CHAR_SPACE:
curX += 4;
break;
default:
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[str[strPos]]);
gDPLoadSync(gDisplayListHead++);
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_8b_BYTES));
gSPTextureRectangle(gDisplayListHead++, curX << 2, curY << 2, (curX + 8) << 2,
(curY + 8) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
#ifndef VERSION_EU
if (mark != DIALOG_MARK_NONE) {
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_8b, 1, fontLUT[mark + 0xEF]);
gDPLoadSync(gDisplayListHead++);
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_8b_BYTES));
gSPTextureRectangle(gDisplayListHead++, (curX + 6) << 2, (curY - 7) << 2,
(curX + 14) << 2, (curY + 1) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10);
mark = DIALOG_MARK_NONE;
}
#endif
#if defined(VERSION_JP) || defined(VERSION_SH)
curX += 9;
#else
curX += gDialogCharWidths[str[strPos]];
#endif
}
strPos++;
}
moon_draw_text(x, y, str, 0.8f);
}
void print_credits_string(s16 x, s16 y, const u8 *str) {

View File

@ -18,6 +18,7 @@
#include "star_select.h"
#include "prevent_bss_reordering.h"
#include "text/text-loader.h"
#include "moon/utils/moon-gfx.h"
/**
* @file star_select.c
@ -259,45 +260,16 @@ void print_act_selector_strings(void) {
unsigned char * starNumbers = get_key_string("TEXT_ZERO");
#ifdef VERSION_EU
u8 **levelNameTbl;
u8 *currLevelName;
u8 **actNameTbl;
#else
u8 **levelNameTbl = segmented_to_virtual(seg2_course_name_table);
u8 *currLevelName = segmented_to_virtual(levelNameTbl[gCurrCourseNum - 1]);
u8 **actNameTbl = segmented_to_virtual(seg2_act_name_table);
#endif
u8 *selectedActName;
#ifndef VERSION_EU
s16 lvlNameX;
s16 actNameX;
#endif
s8 i;
#ifdef VERSION_EU
s16 language = eu_get_language();
#endif
create_dl_ortho_matrix();
#ifdef VERSION_EU
switch (language) {
case LANGUAGE_ENGLISH:
actNameTbl = segmented_to_virtual(act_name_table_eu_en);
levelNameTbl = segmented_to_virtual(course_name_table_eu_en);
break;
case LANGUAGE_FRENCH:
actNameTbl = segmented_to_virtual(act_name_table_eu_fr);
levelNameTbl = segmented_to_virtual(course_name_table_eu_fr);
break;
case LANGUAGE_GERMAN:
actNameTbl = segmented_to_virtual(act_name_table_eu_de);
levelNameTbl = segmented_to_virtual(course_name_table_eu_de);
break;
}
currLevelName = segmented_to_virtual(levelNameTbl[gCurrCourseNum - 1]);
#endif
// Print the coin highscore.
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
@ -311,39 +283,20 @@ void print_act_selector_strings(void) {
print_generic_string(102, 118, get_key_string("TEXT_MY_SCORE"));
}
#ifdef VERSION_EU
print_generic_string(get_str_x_pos_from_center(160, currLevelName + 3, 10.0f), 33, currLevelName + 3);
#elif defined(VERSION_SH)
lvlNameX = get_str_x_pos_from_center_scale(160, currLevelName + 3, 10.0f);
print_generic_string(lvlNameX, 33, currLevelName + 3);
#else
lvlNameX = get_str_x_pos_from_center(160, currLevelName + 3, 10.0f);
print_generic_string(lvlNameX, 33, currLevelName + 3);
#endif
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
#ifdef VERSION_EU
print_course_number((u32)language);
#else
print_course_number();
#endif
gSPDisplayList(gDisplayListHead++, dl_menu_ia8_text_begin);
gDPSetEnvColor(gDisplayListHead++, 0, 0, 0, 255);
// Print the name of the selected act.
if (sVisibleStars != 0) {
selectedActName = segmented_to_virtual(actNameTbl[(gCurrCourseNum - 1) * 6 + sSelectedActIndex]);
#ifdef VERSION_EU
print_menu_generic_string(get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f), 81, selectedActName);
#elif defined(VERSION_SH)
actNameX = get_str_x_pos_from_center_scale(ACT_NAME_X, selectedActName, 8.0f);
print_menu_generic_string(actNameX, 81, selectedActName);
#else
actNameX = get_str_x_pos_from_center(ACT_NAME_X, selectedActName, 8.0f);
print_menu_generic_string(actNameX, 81, selectedActName);
#endif
actNameX = SCREEN_WIDTH / 2 - moon_get_text_width(selectedActName, 0.8f, 0) / 2;
print_menu_generic_string(actNameX, 151, selectedActName);
}
// Print the numbers above each star.