From eca92c4f7e4134ebeee13d66521f09ff19109b47 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Sat, 9 Apr 2022 11:34:26 -0700 Subject: [PATCH] Add compatibility hack for English Daibanchou Gpx2Plus.CopyStretchReduceAMap behaves differently in the English version. Fixes an issue with text being squashed horizontally on the regional phase menus. --- include/xsystem4.h | 1 + src/hacks.c | 24 +++++++++++++++++++++--- src/hll/Gpx2Plus.c | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/xsystem4.h b/include/xsystem4.h index db99bbe..394d9b8 100644 --- a/include/xsystem4.h +++ b/include/xsystem4.h @@ -63,6 +63,7 @@ void get_time(int *hour, int *min, int *sec, int *ms); #define XSYS4_DATA_DIR "/usr/local/share/xsystem4" #endif +extern bool game_daibanchou_en; extern bool game_rance02_mg; #endif /* XSYSTEM4_H */ diff --git a/src/hacks.c b/src/hacks.c index 8bc5218..e68162a 100644 --- a/src/hacks.c +++ b/src/hacks.c @@ -23,12 +23,14 @@ #include "system4/buffer.h" #include "system4/instructions.h" #include "system4/string.h" +#include "system4/utfsjis.h" #include "gfx/gfx.h" #include "xsystem4.h" #include "hll/hll.h" +bool game_daibanchou_en = false; bool game_rance02_mg = false; static void write_instruction0(struct buffer *out, enum opcode op) @@ -105,9 +107,25 @@ static void apply_rance02_hacks(struct ain *ain) game_rance02_mg = true; } -void apply_game_specific_hacks(struct ain *ain) +// Daibanchou (English fan translation) +// ------------------------------------ +// Gpx2Plus.CopyStretchReduceAMap behaves differently in order to work around +// text rendering issues caused by how the game calculates text width in +// StructRegionalSelect::DrawMenuItem. +static void apply_daibanchou_hacks(struct ain *ain) { - if (!strcmp(config.game_name, "Rance 02")) { - apply_rance02_hacks(ain); + if (ain->nr_strings > 2 && !strcmp(ain->strings[2]->text, "Seijou Academy")) { + game_daibanchou_en = true; } } + +void apply_game_specific_hacks(struct ain *ain) +{ + char *game_name = sjis2utf(config.game_name, 0); + if (!strcmp(game_name, "大番長")) { + apply_daibanchou_hacks(ain); + } else if (!strcmp(game_name, "Rance 02")) { + apply_rance02_hacks(ain); + } + free(game_name); +} diff --git a/src/hll/Gpx2Plus.c b/src/hll/Gpx2Plus.c index 10363ef..f08af5e 100644 --- a/src/hll/Gpx2Plus.c +++ b/src/hll/Gpx2Plus.c @@ -353,6 +353,8 @@ static void Gpx2Plus_CopyStretchReduce(int destSurface, int dx, int dy, int dWid static void Gpx2Plus_CopyStretchReduceAMap(int destSurface, int dx, int dy, int dWidth, int dHeight, int srcSurface, int sx, int sy, int sWidth, int sHeight) { + if (game_daibanchou_en) + sWidth /= 2; struct texture *dst = get_texture(destSurface); struct texture *src = get_texture(srcSurface); if (!dst || !src)