In-progress TextScriptProc fixes and accuracy improvements

Need to rework WindowsWrapper.h before I can progress.
This commit is contained in:
Clownacy 2019-06-20 19:13:59 +01:00
parent 6c96f243d1
commit 765beff57a

View file

@ -558,7 +558,6 @@ int TextScriptProc()
char c[3]; char c[3];
int w, x, y, z; int w, x, y, z;
int i; int i;
int length;
RECT rcSymbol = {64, 48, 72, 56}; RECT rcSymbol = {64, 48, 72, 56};
@ -694,13 +693,16 @@ int TextScriptProc()
y = GetTextScriptNo(gTS.p_read + 19); y = GetTextScriptNo(gTS.p_read + 19);
if (!TransferStage(z, w, x, y)) if (!TransferStage(z, w, x, y))
{ {
#ifdef NONPORTABLE
MessageBoxA(ghWnd, "ステージの読み込みに失敗", "エラー", 0);
#else
#ifdef JAPANESE #ifdef JAPANESE
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "ステージの読み込みに失敗", NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", "ステージの読み込みに失敗", NULL);
#else #else
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Failed to load stage", NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "Failed to load stage", NULL);
#endif #endif
#endif
//MessageBoxA(ghWnd, "ステージの読み込みに失敗", "エラー", 0);
return 0; return 0;
} }
} }
@ -942,7 +944,12 @@ int TextScriptProc()
} }
else if (IS_COMMAND('S','P','S')) else if (IS_COMMAND('S','P','S'))
{ {
#ifdef FIX_BUGS
SetNoise(2, 0);
#else
// x is not initialised. This bug isn't too bad, since that parameter's not used when the first one is set to 2, but still.
SetNoise(2, x); SetNoise(2, x);
#endif
gTS.p_read += 4; gTS.p_read += 4;
} }
else if (IS_COMMAND('C','P','S')) else if (IS_COMMAND('C','P','S'))
@ -1180,7 +1187,7 @@ int TextScriptProc()
} }
gTS.p_read += 8; gTS.p_read += 8;
} }
else if (IS_COMMAND('F','A','C')) else if (IS_COMMAND('F','A','C')) // Duplicate command
{ {
z = GetTextScriptNo(gTS.p_read + 4); z = GetTextScriptNo(gTS.p_read + 4);
if (gTS.face != (signed char)z) if (gTS.face != (signed char)z)
@ -1242,6 +1249,10 @@ int TextScriptProc()
else else
{ {
char str_0[0x40]; char str_0[0x40];
#ifdef NONPORTABLE
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
MessageBoxA(0, str_0, "エラー", 0);
#else
#ifdef JAPANESE #ifdef JAPANESE
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]); sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", str_0, NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "エラー", str_0, NULL);
@ -1249,8 +1260,7 @@ int TextScriptProc()
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]); sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", str_0, NULL); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", str_0, NULL);
#endif #endif
#endif
//MessageBoxA(0, str_0, "エラー", 0);
return 0; return 0;
} }
@ -1285,9 +1295,9 @@ int TextScriptProc()
} }
//Get text to copy //Get text to copy
length = x - gTS.p_read; y = x - gTS.p_read;
memcpy(str, &gTS.data[gTS.p_read], length); memcpy(str, &gTS.data[gTS.p_read], y);
str[length] = 0; str[y] = 0;
gTS.p_write = x; gTS.p_write = x;
@ -1296,7 +1306,7 @@ int TextScriptProc()
sprintf(&text[gTS.line % 4 * 0x40], str); sprintf(&text[gTS.line % 4 * 0x40], str);
//Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping) //Check if should move to next line (prevent a memory overflow, come on guys, this isn't a leftover of pixel trying to make text wrapping)
gTS.p_read += length; gTS.p_read += y;
if (gTS.p_write >= 35) if (gTS.p_write >= 35)
CheckNewLine(); CheckNewLine();