From f6217bcc3df5f32a57e94516065e70b6f31dfadd Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Fri, 5 Jul 2019 23:03:41 -0700 Subject: [PATCH] Implement modified MP command from English patches Implement the patched version of the MP command, which appends a number of spaces to a string rather than truncating. This is only used in the English translations of Rance III and Rance IV. --- src/cmd2F.c | 9 ++++++++- src/cmdm.c | 37 ++++++++++++++++++++++++------------- src/gametitle.h | 2 ++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/cmd2F.c b/src/cmd2F.c index 192fa35..a1429be 100644 --- a/src/cmd2F.c +++ b/src/cmd2F.c @@ -39,6 +39,9 @@ #include "ald_manager.h" #include "LittleEndian.h" +/* defined by cmdm.c */ +extern boolean have_eng_mp_patch; + /* é�¸æŠž Window OPEN 時 callback */ static int cb_sel_init_page = 0; static int cb_sel_init_address = 0; @@ -446,7 +449,11 @@ void commands2F28() { strncpy(nact->game_title_name, title, 30); ags_setWindowTitle(title); - + + if (0 == strcmp(title, GT_RANCE3_ENG) || 0 == strcmp(title, GT_RANCE4_ENG)) { + have_eng_mp_patch = TRUE; + } + DEBUG_COMMAND("MT(new) %s:\n",title); } diff --git a/src/cmdm.c b/src/cmdm.c index ef42795..be9727d 100644 --- a/src/cmdm.c +++ b/src/cmdm.c @@ -43,6 +43,8 @@ extern boolean Y3waitCancel; /* MI 用パラメータ */ INPUTSTRING_PARAM mi_param; +boolean have_eng_mp_patch = FALSE; + void commandMS() { /* Xコマンドã�§è¡¨ç¤ºã�•れる文字列領域ã�«æ–‡å­—列を入れる */ int num = getCaliValue(); @@ -62,21 +64,30 @@ void commandMP() { int num2 = getCaliValue(); const char bstr[3] = "\x81\x40"; // full-width whitespace const char *src = v_str(num1 - 1); - char *str = malloc(num2 * 2 + 1); - - if (NULL == str) { - NOMEMERR(); - } - - memset(str, 0, num2 * 2 + 1); - int chars = num2; - const char *p = src; - while (*p && chars > 0) { - p += CHECKSJIS1BYTE(*p) ? 2 : 1; - chars--; + char *str; + + /* Patched English executable appends num2 spaces instead of truncating */ + if (have_eng_mp_patch) { + str = calloc(strlen(src) + num2 * 2 + 1, 1); + if (NULL == str) { + NOMEMERR(); + } + strcpy(str, src); + } + else { + str = calloc(num2 * 2 + 1, 1); + if (NULL == str) { + NOMEMERR(); + } + + const char *p = src; + while (*p && chars > 0) { + p += CHECKSJIS1BYTE(*p) ? 2 : 1; + chars--; + } + strncpy(str, src, p - src); } - strncpy(str, src, p - src); while (chars-- > 0) { strcat(str, bstr); } diff --git a/src/gametitle.h b/src/gametitle.h index 6c23aea..32c0e2a 100644 --- a/src/gametitle.h +++ b/src/gametitle.h @@ -2,3 +2,5 @@ #define GT_RANCE4 "‚q‚�‚Ž‚ƒ‚…‚S�@�|‹³’c‚̈âŽY�|�@‚e‚�‚’�@‚v‚‰‚Ž‚X‚T�@" #define GT_RANCE5D "ƒ‰ƒ“ƒX‚T‚c�@�iSR�j" #define GT_ESUKA "-BeatAngelEscalayer-" +#define GT_RANCE3_ENG "Rance3" +#define GT_RANCE4_ENG "Rance4 -Legacy of the Sect- For Win95 "