From 7cff8914528c0f0ba4360c2e9f32cb0a7dc0ff86 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 3 Sep 2020 21:31:49 +0100 Subject: [PATCH 1/4] Remove that FRAMERATE thing --- src/Draw.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index bd79cc60..bea72ee7 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -56,8 +56,6 @@ static struct static int client_x; static int client_y; -#define FRAMERATE 20 - void SetClientOffset(int width, int height) { client_x = width; @@ -78,7 +76,7 @@ BOOL Flip_SystemTask(HWND hWnd) // Framerate limiter timeNow = GetTickCount(); - if (timeNow >= timePrev + FRAMERATE) + if (timeNow >= timePrev + 20) break; Sleep(1); @@ -87,7 +85,7 @@ BOOL Flip_SystemTask(HWND hWnd) if (timeNow >= timePrev + 100) timePrev = timeNow; // If the timer is freakishly out of sync, panic and reset it, instead of spamming frames for who-knows how long else - timePrev += FRAMERATE; + timePrev += 20; static RECT dst_rect; // TODO - Not the original vaiable name GetWindowRect(hWnd, &dst_rect); From aa396092b517fbb40bfcbeb4e5e64801814f47b2 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 3 Sep 2020 21:39:36 +0100 Subject: [PATCH 2/4] Translate error messages with FIX_BUGS --- src/Game.cpp | 12 ++++++++++-- src/Profile.cpp | 6 +++++- src/TextScr.cpp | 11 ++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Game.cpp b/src/Game.cpp index 583310f4..2e95ab81 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -687,7 +687,11 @@ BOOL Game(HWND hWnd) if (!LoadGenericData()) { - MessageBoxA(hWnd, "\x94\xC4\x97\x70\x83\x74\x83\x40\x83\x43\x83\x8B\x82\xAA\x93\xC7\x82\xDF\x82\xC8\x82\xA2", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* '汎用ファイルが読めない' and 'エラー' ('Couldn't read general purpose files' and 'Error') in Shift-JIS */ + #if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this + MessageBoxA(hWnd, "Couldn't read general purpose files", "Error", MB_OK); + #else + MessageBoxA(hWnd, "\x94\xC4\x97\x70\x83\x74\x83\x40\x83\x43\x83\x8B\x82\xAA\x93\xC7\x82\xDF\x82\xC8\x82\xA2", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* '汎用ファイルが読めない' and 'エラー' in Shift-JIS */ + #endif return FALSE; } @@ -698,7 +702,11 @@ BOOL Game(HWND hWnd) if (!LoadNpcTable(path)) { - MessageBoxA(hWnd, "\x4E\x50\x43\x83\x65\x81\x5B\x83\x75\x83\x8B\x82\xAA\x93\xC7\x82\xDF\x82\xC8\x82\xA2", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'NPCテーブルが読めない' and 'エラー' ('Couldn't read the NPC table' and 'Error') in Shift-JIS */ + #if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this + MessageBoxA(hWnd, "Couldn't read the NPC table", "Error", MB_OK); + #else + MessageBoxA(hWnd, "\x4E\x50\x43\x83\x65\x81\x5B\x83\x75\x83\x8B\x82\xAA\x93\xC7\x82\xDF\x82\xC8\x82\xA2", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'NPCテーブルが読めない' and 'エラー' in Shift-JIS */ + #endif return FALSE; } diff --git a/src/Profile.cpp b/src/Profile.cpp index c12a3bfb..3111b912 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -180,7 +180,11 @@ BOOL InitializeGame(HWND hWnd) InitFlags(); if (!TransferStage(13, 200, 10, 8)) { - MessageBoxA(hWnd, "\x83\x58\x83\x65\x81\x5B\x83\x57\x82\xCC\x93\xC7\x82\xDD\x8D\x9E\x82\xDD\x82\xC9\x8E\xB8\x94\x73", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'ステージの読み込みに失敗' and 'エラー' ('Failed to load stage' and 'Error') in Shift-JIS */ + #if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this + MessageBoxA(hWnd, "Failed to load stage", "Error", MB_OK); + #else + MessageBoxA(hWnd, "\x83\x58\x83\x65\x81\x5B\x83\x57\x82\xCC\x93\xC7\x82\xDD\x8D\x9E\x82\xDD\x82\xC9\x8E\xB8\x94\x73", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'ステージの読み込みに失敗' and 'エラー' in Shift-JIS */ + #endif return FALSE; } diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 1ad813c4..7e5dad44 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -739,7 +739,11 @@ int TextScriptProc(void) if (!TransferStage(z, w, x, y)) { - MessageBoxA(ghWnd, "\x83\x58\x83\x65\x81\x5B\x83\x57\x82\xCC\x93\xC7\x82\xDD\x8D\x9E\x82\xDD\x82\xC9\x8E\xB8\x94\x73", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'ステージの読み込みに失敗' and 'エラー' ('Failed to load stage' and 'Error') in Shift-JIS */ + #if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this + MessageBoxA(ghWnd, "Failed to load stage", "Error", MB_OK); + #else + MessageBoxA(ghWnd, "\x83\x58\x83\x65\x81\x5B\x83\x57\x82\xCC\x93\xC7\x82\xDD\x8D\x9E\x82\xDD\x82\xC9\x8E\xB8\x94\x73", "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'ステージの読み込みに失敗' and 'エラー' in Shift-JIS */ + #endif return enum_ESCRETURN_exit; } } @@ -1316,8 +1320,13 @@ int TextScriptProc(void) else { char str_0[0x40]; + #if !defined(JAPANESE) && defined(FIX_BUGS) // The Aeon Genesis translation didn't translate this + 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]); + MessageBoxA(NULL, str_0, "Error", MB_OK); + #else sprintf(str_0, "\x95\x73\x96\xBE\x82\xCC\x83\x52\x81\x5B\x83\x68:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]); /* '不明のコード:<%c%c%c' (Unknown code:<%c%c%c) in Shift-JIS */ MessageBoxA(NULL, str_0, "\x83\x47\x83\x89\x81\x5B", MB_OK); /* 'エラー' (Error) in Shift-JIS */ + #endif return enum_ESCRETURN_exit; } } From 9c63e5994b33fa2ba9455bc9fd44a34dbdd3e3bf Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 3 Sep 2020 21:52:05 +0100 Subject: [PATCH 3/4] Document SelStage.cpp a little --- src/ArmsItem.h | 2 +- src/SelStage.cpp | 19 +++++++++++-------- src/SelStage.h | 4 +++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/ArmsItem.h b/src/ArmsItem.h index 9656a681..f21144e1 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -4,7 +4,7 @@ // Limits for the amount of weapons and items #define ARMS_MAX 8 -#define ITEM_MAX 0x20 +#define ITEM_MAX 32 // "Arms" is a synonym of "weapon" here // "Code" means "ID" here diff --git a/src/SelStage.cpp b/src/SelStage.cpp index b0c86c2c..c54b2d0c 100644 --- a/src/SelStage.cpp +++ b/src/SelStage.cpp @@ -12,7 +12,7 @@ #include "Sound.h" #include "TextScr.h" -PERMIT_STAGE gPermitStage[8]; +PERMIT_STAGE gPermitStage[STAGE_MAX]; int gSelectedStage; int gStageSelectTitleY; @@ -26,7 +26,7 @@ BOOL AddPermitStage(int index, int event) { int i = 0; - while (i < 8) + while (i < STAGE_MAX) { if (gPermitStage[i].index == index) break; @@ -37,7 +37,7 @@ BOOL AddPermitStage(int index, int event) ++i; } - if (i == 8) + if (i == STAGE_MAX) return FALSE; gPermitStage[i].index = index; @@ -50,18 +50,18 @@ BOOL SubPermitStage(int index) { int i; - for (i = 0; i < 8; ++i) + for (i = 0; i < STAGE_MAX; ++i) if (gPermitStage[i].index == index) break; #ifdef FIX_BUGS - if (i == 8) + if (i == STAGE_MAX) #else - if (i == 32) + if (i == 32) // Same value as 'ITEM_MAX' #endif return FALSE; - for (++i; i < 8; ++i) + for (++i; i < STAGE_MAX; ++i) gPermitStage[i - 1] = gPermitStage[i]; gPermitStage[i - 1].index = 0; @@ -139,11 +139,14 @@ void PutStageSelectObject(void) PutBitmap3(&rcView, stage_x + (gSelectedStage * 40), (WINDOW_HEIGHT / 2) - 56, &rcCur[flash / 2 % 2], SURFACE_ID_TEXT_BOX); - for (i = 0; i < 8; ++i) + for (i = 0; i < STAGE_MAX; ++i) { if (gPermitStage[i].index == 0) break; + // Interestingly, there's code for reading multiple rows of icons + // from the 'StageImage.pbm' file when there are more than 8 stages, + // despite only 6 icons ever being used. rcStage.left = (gPermitStage[i].index % 8) * 32; rcStage.right = rcStage.left + 32; rcStage.top = (gPermitStage[i].index / 8) * 16; diff --git a/src/SelStage.h b/src/SelStage.h index f06dc427..ee684438 100644 --- a/src/SelStage.h +++ b/src/SelStage.h @@ -2,13 +2,15 @@ #include "WindowsWrapper.h" +#define STAGE_MAX 8 // Note that Cave Story only has 5 stages + typedef struct PERMIT_STAGE { int index; int event; } PERMIT_STAGE; -extern PERMIT_STAGE gPermitStage[8]; +extern PERMIT_STAGE gPermitStage[STAGE_MAX]; extern int gSelectedStage; extern int gStageSelectTitleY; From dce5e215c804efc4cd58c2e98d87be7da9f610b4 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Thu, 3 Sep 2020 21:54:10 +0100 Subject: [PATCH 4/4] Explain the gamepad button limit --- src/Input.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Input.h b/src/Input.h index 6f733486..895c8950 100644 --- a/src/Input.h +++ b/src/Input.h @@ -8,7 +8,7 @@ struct DIRECTINPUTSTATUS BOOL bRight; BOOL bUp; BOOL bDown; - BOOL bButton[32]; + BOOL bButton[32]; // 32 is the number of buttons in DirectInput's `DIJOYSTATE` struct }; void ReleaseDirectInput(void);