From f6606b7748c1b698e7b685c226de8d939a87af9a Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 22 Mar 2020 15:07:29 +0000 Subject: [PATCH 1/6] Add some missing function names These were retrieved from the Mac port (v0.0.7), which kept these functions. Unfortunately, this port is missing local variable names, so we can't use it to make InitBack accurate. --- src/Dialog.cpp | 8 ++++---- src/Draw.cpp | 16 ++++++++-------- src/Draw.h | 2 +- src/Generic.cpp | 14 +++++++------- src/Generic.h | 14 +++++++------- src/Input.cpp | 8 ++++---- src/Main.cpp | 12 ++++++------ 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Dialog.cpp b/src/Dialog.cpp index 999f8742..31ded851 100644 --- a/src/Dialog.cpp +++ b/src/Dialog.cpp @@ -40,7 +40,7 @@ DLGPROC_RET CALLBACK VersionDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP sprintf(string_buffer, version_string, version1, version2, version3, version4, year, month, day); SetDlgItemTextA(hWnd, 1011, string_buffer); - CenterWindow(hWnd); + CenteringWindowByParent(hWnd); return TRUE; @@ -65,7 +65,7 @@ DLGPROC_RET CALLBACK DebugMuteDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM switch (Msg) { case WM_INITDIALOG: - CenterWindow(hWnd); + CenteringWindowByParent(hWnd); CheckDlgButton(hWnd, 1010, g_mute[0] != 0); CheckDlgButton(hWnd, 1018, g_mute[1] != 0); CheckDlgButton(hWnd, 1019, g_mute[2] != 0); @@ -112,7 +112,7 @@ DLGPROC_RET CALLBACK DebugSaveDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM { case WM_INITDIALOG: SetDlgItemTextA(hWnd, 1008, "000.dat"); - CenterWindow(hWnd); + CenteringWindowByParent(hWnd); return TRUE; case WM_COMMAND: @@ -141,7 +141,7 @@ DLGPROC_RET CALLBACK QuitDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPara { case WM_INITDIALOG: SetDlgItemTextA(hWnd, 1009, (LPCSTR)lParam); - CenterWindow(hWnd); + CenteringWindowByParent(hWnd); return TRUE; case WM_COMMAND: diff --git a/src/Draw.cpp b/src/Draw.cpp index b48972c5..cfd1b349 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -61,7 +61,7 @@ static int y_offset; #define FRAMERATE 20 // The original name for this function is unknown -void SetWindowPadding(int width, int height) +void SetClientOffset(int width, int height) { x_offset = width; y_offset = height; @@ -296,7 +296,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no) if (!IsEnableBitmap(path)) { - PrintBitmapError(path, 0); + ErrorLog(path, 0); return FALSE; } @@ -306,20 +306,20 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no) if (surf_no > SURFACE_ID_MAX) #endif { - PrintBitmapError("surface no", surf_no); + ErrorLog("surface no", surf_no); return FALSE; } if (surf[surf_no] != NULL) { - PrintBitmapError("existing", surf_no); + ErrorLog("existing", surf_no); return FALSE; } HANDLE handle = LoadImageA(GetModuleHandleA(NULL), path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); if (handle == NULL) { - PrintBitmapError(path, 1); + ErrorLog(path, 1); return FALSE; } @@ -434,7 +434,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no) if (!IsEnableBitmap(path)) { - PrintBitmapError(path, 0); + ErrorLog(path, 0); return FALSE; } @@ -444,14 +444,14 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no) if (surf_no > SURFACE_ID_MAX) #endif { - PrintBitmapError("surface no", surf_no); + ErrorLog("surface no", surf_no); return FALSE; } HANDLE handle = LoadImageA(GetModuleHandleA(NULL), path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); if (handle == NULL) { - PrintBitmapError(path, 1); + ErrorLog(path, 1); return FALSE; } diff --git a/src/Draw.h b/src/Draw.h index b4c38db5..efa115be 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -44,7 +44,7 @@ typedef enum SurfaceID SURFACE_ID_MAX = 40 } SurfaceID; -void SetWindowPadding(int width, int height); +void SetClientOffset(int width, int height); BOOL Flip_SystemTask(HWND hWnd); BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth); void EndDirectDraw(HWND hWnd); diff --git a/src/Generic.cpp b/src/Generic.cpp index e6ad9194..ba875157 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -85,7 +85,7 @@ fail: // This seems to be broken in recent Windows (Sndvol32.exe was renamed 'SndVol.exe') // TODO - Inaccurate stack frame -BOOL OpenVolumeConfiguration(HWND hWnd) +BOOL OpenSoundVolume(HWND hWnd) { #ifdef FIX_BUGS char path[MAX_PATH]; @@ -152,7 +152,7 @@ BOOL OpenVolumeConfiguration(HWND hWnd) #endif } -void DeleteDebugLog(void) +void DeleteLog(void) { char path[MAX_PATH]; @@ -160,7 +160,7 @@ void DeleteDebugLog(void) DeleteFileA(path); } -BOOL PrintDebugLog(const char *string, int value1, int value2, int value3) +BOOL WriteLog(const char *string, int value1, int value2, int value3) { char path[MAX_PATH]; FILE *fp; @@ -184,7 +184,7 @@ uses this code. This is just speculation, but this *might* have been used in those prototypes Pixel released to testers, to prevent them from running after a certain date. */ -int CheckTime(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high) +int GetDateLimit(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high) { FILETIME FileTime1; FILETIME FileTime2; @@ -205,7 +205,7 @@ int CheckTime(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high) return 0; } -BOOL CheckFileExists(const char *name) +BOOL IsKeyFile(const char *name) { char path[MAX_PATH]; @@ -236,7 +236,7 @@ long GetFileSizeLong(const char *path) return len; } -BOOL PrintBitmapError(const char *string, int value) +BOOL ErrorLog(const char *string, int value) { char path[MAX_PATH]; FILE *fp; @@ -267,7 +267,7 @@ BOOL IsShiftJIS(unsigned char c) } // TODO - Inaccurate stack frame -BOOL CenterWindow(HWND hWnd) +BOOL CenteringWindowByParent(HWND hWnd) { RECT window_rect; HWND parent_hwnd; diff --git a/src/Generic.h b/src/Generic.h index 9259689e..41ab0f39 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -4,15 +4,15 @@ void GetCompileDate(int *year, int *month, int *day); BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4); -BOOL OpenVolumeConfiguration(HWND hWnd); -void DeleteDebugLog(void); -BOOL PrintDebugLog(const char *string, int value1, int value2, int value3); -int CheckTime(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high); -BOOL CheckFileExists(const char *name); +BOOL OpenSoundVolume(HWND hWnd); +void DebugLog(void); +BOOL WriteLog(const char *string, int value1, int value2, int value3); +int GetDateLimit(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high); +BOOL IsKeyFile(const char *name); long GetFileSizeLong(const char *path); -BOOL PrintBitmapError(const char *string, int value); +BOOL ErrorLog(const char *string, int value); BOOL IsShiftJIS(unsigned char c); -BOOL CenterWindow(HWND hWnd); +BOOL CenteringWindowByParent(HWND hWnd); BOOL LoadWindowRect(HWND hWnd, const char *filename, BOOL unknown); BOOL SaveWindowRect(HWND hWnd, const char *filename); BOOL IsEnableBitmap(const char *path); diff --git a/src/Input.cpp b/src/Input.cpp index 4eff1bff..2776b269 100644 --- a/src/Input.cpp +++ b/src/Input.cpp @@ -40,8 +40,8 @@ void ReleaseDirectInput(void) } } -// The original name for this function and its variables are unknown -BOOL SetDeviceAquire(BOOL aquire) +// The original name for this function's variables are unknown +BOOL ActivateDirectInput(BOOL aquire) { if (aquire == TRUE) { @@ -176,7 +176,7 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status) if (res != DI_OK) { if (res == DIERR_INPUTLOST) - SetDeviceAquire(FALSE); + ActivateDirectInput(FALSE); else return FALSE; } @@ -221,7 +221,7 @@ BOOL ResetJoystickStatus(void) if (res != DI_OK) { if (res == DIERR_INPUTLOST) - SetDeviceAquire(FALSE); + ActivateDirectInput(FALSE); else return FALSE; } diff --git a/src/Main.cpp b/src/Main.cpp index 1d5bcd89..2544b3a1 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -158,7 +158,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } // Swap left and right weapon switch keys - if (CheckFileExists("s_reverse")) + if (IsKeyFile("s_reverse")) { gKeyArms = KEY_ARMSREV; gKeyArmsRev = KEY_ARMS; @@ -262,7 +262,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine x = (GetSystemMetrics(SM_CXSCREEN) - nWidth) / 2; y = (GetSystemMetrics(SM_CYSCREEN) - nHeight) / 2; - SetWindowPadding(GetSystemMetrics(SM_CXFIXEDFRAME) + 1, GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU) + 1); + SetClientOffset(GetSystemMetrics(SM_CXFIXEDFRAME) + 1, GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU) + 1); hWnd = CreateWindowExA(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, lpWindowName, lpWindowName, WS_MINIMIZEBOX | WS_SYSMENU | WS_BORDER | WS_DLGFRAME | WS_VISIBLE, x, y, nWidth, nHeight, NULL, NULL, hInstance, NULL); ghWnd = hWnd; @@ -309,7 +309,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine windowWidth = WINDOW_WIDTH * 2; windowHeight = WINDOW_HEIGHT * 2; - SetWindowPadding(0, 0); + SetClientOffset(0, 0); hWnd = CreateWindowExA(WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, lpWindowName, lpWindowName, WS_SYSMENU | WS_VISIBLE | WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); ghWnd = hWnd; @@ -457,11 +457,11 @@ LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar DrawMenuBar(hWnd); hMenu = GetMenu(hWnd); - if (!CheckFileExists("mute")) + if (!IsKeyFile("mute")) DeleteMenu(hMenu, 40007, MF_BYCOMMAND); DrawMenuBar(hWnd); - if (CheckFileExists("fps")) + if (IsKeyFile("fps")) bFps = TRUE; if (!bFullscreen) @@ -685,7 +685,7 @@ LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lPar break; case 40004: - if (!OpenVolumeConfiguration(hWnd)) + if (!OpenSoundVolume(hWnd)) MessageBoxA(hWnd, "\x83\x7B\x83\x8A\x83\x85\x81\x5B\x83\x80\x90\xDD\x92\xE8\x82\xF0\x8B\x4E\x93\xAE\x82\xC5\x82\xAB\x82\xDC\x82\xB9\x82\xF1\x82\xC5\x82\xB5\x82\xBD", lpWindowName, 0); // 'ボリューム設定を起動できませんでした' (Could not launch volume configuration) in Shift-JIS break; From b374a8046c0ab998b97a0515098e1ac82ae5c94a Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 22 Mar 2020 15:29:20 +0000 Subject: [PATCH 2/6] Add some missing global/static variable names Also from the Mac port. --- src/Draw.cpp | 120 +++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index cfd1b349..6361a7df 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -55,16 +55,16 @@ static struct } surface_metadata[SURFACE_ID_MAX]; // The original names for these variables are unknown -static int x_offset; -static int y_offset; +static int client_x; +static int client_y; #define FRAMERATE 20 // The original name for this function is unknown void SetClientOffset(int width, int height) { - x_offset = width; - y_offset = height; + client_x = width; + client_y = height; } BOOL Flip_SystemTask(HWND hWnd) @@ -93,8 +93,8 @@ BOOL Flip_SystemTask(HWND hWnd) static RECT dst_rect; GetWindowRect(hWnd, &dst_rect); - dst_rect.left += x_offset; - dst_rect.top += y_offset; + dst_rect.left += client_x; + dst_rect.top += client_y; dst_rect.right = dst_rect.left + scaled_window_width; dst_rect.bottom = dst_rect.top + scaled_window_height; @@ -555,111 +555,111 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect) void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency { - static RECT src_rect; + static RECT rcWork; static RECT dst_rect; - src_rect = *rect; + rcWork = *rect; if (x + rect->right - rect->left > rcView->right) - src_rect.right -= (x + rect->right - rect->left) - rcView->right; + rcWork.right -= (x + rect->right - rect->left) - rcView->right; if (x < rcView->left) { - src_rect.left += rcView->left - x; + rcWork.left += rcView->left - x; x = rcView->left; } if (y + rect->bottom - rect->top > rcView->bottom) - src_rect.bottom -= (y + rect->bottom - rect->top) - rcView->bottom; + rcWork.bottom -= (y + rect->bottom - rect->top) - rcView->bottom; if (y < rcView->top) { - src_rect.top += rcView->top - y; + rcWork.top += rcView->top - y; y = rcView->top; } - dst_rect.left = x; - dst_rect.top = y; - dst_rect.right = x + src_rect.right - src_rect.left; - dst_rect.bottom = y + src_rect.bottom - src_rect.top; + rcSet.left = x; + rcSet.top = y; + rcSet.right = x + rcWork.right - rcWork.left; + rcSet.bottom = y + rcWork.bottom - rcWork.top; - src_rect.left *= magnification; - src_rect.top *= magnification; - src_rect.right *= magnification; - src_rect.bottom *= magnification; + rcWork.left *= magnification; + rcWork.top *= magnification; + rcWork.right *= magnification; + rcWork.bottom *= magnification; - dst_rect.left *= magnification; - dst_rect.top *= magnification; - dst_rect.right *= magnification; - dst_rect.bottom *= magnification; + rcSet.left *= magnification; + rcSet.top *= magnification; + rcSet.right *= magnification; + rcSet.bottom *= magnification; - backbuffer->Blt(&dst_rect, surf[surf_no], &src_rect, DDBLT_KEYSRC | DDBLT_WAIT, NULL); + backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL); } void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency { - static RECT src_rect; - static RECT dst_rect; + static RECT rcWork; + static RECT rcSet; - src_rect = *rect; + rcWork = *rect; if (x + rect->right - rect->left > rcView->right) - src_rect.right -= (x + rect->right - rect->left) - rcView->right; + rcWork.right -= (x + rect->right - rect->left) - rcView->right; if (x < rcView->left) { - src_rect.left += rcView->left - x; + rcWork.left += rcView->left - x; x = rcView->left; } if (y + rect->bottom - rect->top > rcView->bottom) - src_rect.bottom -= (y + rect->bottom - rect->top) - rcView->bottom; + rcWork.bottom -= (y + rect->bottom - rect->top) - rcView->bottom; if (y < rcView->top) { - src_rect.top += rcView->top - y; + rcWork.top += rcView->top - y; y = rcView->top; } - dst_rect.left = x; - dst_rect.top = y; - dst_rect.right = x + src_rect.right - src_rect.left; - dst_rect.bottom = y + src_rect.bottom - src_rect.top; + rcSet.left = x; + rcSet.top = y; + rcSet.right = x + rcWork.right - rcWork.left; + rcSet.bottom = y + rcWork.bottom - rcWork.top; - src_rect.left *= magnification; - src_rect.top *= magnification; - src_rect.right *= magnification; - src_rect.bottom *= magnification; + rcWork.left *= magnification; + rcWork.top *= magnification; + rcWork.right *= magnification; + rcWork.bottom *= magnification; - dst_rect.left *= magnification; - dst_rect.top *= magnification; - dst_rect.right *= magnification; - dst_rect.bottom *= magnification; + rcSet.left *= magnification; + rcSet.top *= magnification; + rcSet.right *= magnification; + rcSet.bottom *= magnification; - backbuffer->Blt(&dst_rect, surf[surf_no], &src_rect, DDBLT_WAIT, NULL); + backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_WAIT, NULL); } void Surface2Surface(int x, int y, const RECT *rect, int to, int from) { - static RECT src_rect; - static RECT dst_rect; + static RECT rcWork; + static RECT rcSet; - src_rect.left = rect->left * magnification; - src_rect.top = rect->top * magnification; - src_rect.right = rect->right * magnification; - src_rect.bottom = rect->bottom * magnification; + rcWork.left = rect->left * magnification; + rcWork.top = rect->top * magnification; + rcWork.right = rect->right * magnification; + rcWork.bottom = rect->bottom * magnification; - dst_rect.left = x; - dst_rect.top = y; - dst_rect.right = x + rect->right - rect->left; - dst_rect.bottom = y + rect->bottom - rect->top; + rcSet.left = x; + rcSet.top = y; + rcSet.right = x + rect->right - rect->left; + rcSet.bottom = y + rect->bottom - rect->top; - dst_rect.left *= magnification; - dst_rect.top *= magnification; - dst_rect.right *= magnification; - dst_rect.bottom *= magnification; + rcSet.left *= magnification; + rcSet.top *= magnification; + rcSet.right *= magnification; + rcSet.bottom *= magnification; - surf[to]->Blt(&dst_rect, surf[from], &src_rect, DDBLT_KEYSRC | DDBLT_WAIT, NULL); + surf[to]->Blt(&rcSet, surf[from], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL); } // This converts a colour to the 'native' format by writing it From c34a7fc3549c8d33439ee60396954d031b34f515 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 22 Mar 2020 15:35:59 +0000 Subject: [PATCH 3/6] Fix build error --- src/Draw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index 6361a7df..234678b8 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -556,7 +556,7 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect) void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency { static RECT rcWork; - static RECT dst_rect; + static RECT rcSet; rcWork = *rect; From 7820926bfd52b58f28479dfd90b2eef0a290b183 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 22 Mar 2020 15:37:00 +0000 Subject: [PATCH 4/6] Remove outdated comments --- src/Draw.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Draw.cpp b/src/Draw.cpp index 234678b8..d391a0ce 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -54,13 +54,11 @@ static struct BOOL bSystem; // Basically a 'do not regenerate' flag } surface_metadata[SURFACE_ID_MAX]; -// The original names for these variables are unknown static int client_x; static int client_y; #define FRAMERATE 20 -// The original name for this function is unknown void SetClientOffset(int width, int height) { client_x = width; From db1b1d80f8d2da5517a781425420d6a73a0ad216 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Sun, 22 Mar 2020 16:19:43 +0000 Subject: [PATCH 5/6] Disable Windows Travis builds for now Really not in the mood to deal with that damn mess. Maybe if the bloody thing could be arsed to print an error or two, I'd know what's wrong, but nope. Works fine on a regular MSYS2 installation, so sod it. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index eaa9960e..d09e848d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ compiler: os: - linux - - windows +# - windows addons: apt: From ca6538561f43dd0d96dc9412a7876e2465d2b38b Mon Sep 17 00:00:00 2001 From: Clownacy Date: Fri, 27 Mar 2020 17:48:08 +0000 Subject: [PATCH 6/6] Document ActNpc061 (King) --- src/NpChar.cpp | 2 +- src/NpChar.h | 3 +- src/NpcAct060.cpp | 77 ++++++++++++++++++++++++++--------------------- 3 files changed, 45 insertions(+), 37 deletions(-) diff --git a/src/NpChar.cpp b/src/NpChar.cpp index c0ee42d7..46c314da 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -160,7 +160,7 @@ void SetDestroyNpChar(int x, int y, int w, int num) { offset_x = Random(-w, w) * 0x200; offset_y = Random(-w, w) * 0x200; - SetNpChar(4, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100); + SetNpChar(NPC_SMOKE, x + offset_x, y + offset_y, 0, 0, 0, NULL, 0x100); } // Flash effect diff --git a/src/NpChar.h b/src/NpChar.h index a0781459..1a470c2f 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -47,8 +47,9 @@ enum NPCNames NPC_MALCO_UNDAMAGED = 107, NPC_PROJECTILE_BALFROG_SPITBALL = 108, NPC_MALCO_DAMAGED = 109, - NPC_ENEMY_PUCHI = 110 + NPC_ENEMY_PUCHI = 110, // To be continued + NPC_KINGS_SWORD = 145 }; typedef struct NPCHAR diff --git a/src/NpcAct060.cpp b/src/NpcAct060.cpp index df3569e2..0b7571a6 100644 --- a/src/NpcAct060.cpp +++ b/src/NpcAct060.cpp @@ -202,36 +202,40 @@ void ActNpc061(NPCHAR *npc) int i; RECT rcLeft[11] = { - {224, 32, 240, 48}, - {240, 32, 256, 48}, - {256, 32, 272, 48}, - {272, 32, 288, 48}, - {288, 32, 304, 48}, - {224, 32, 240, 48}, - {304, 32, 320, 48}, - {224, 32, 240, 48}, - {272, 32, 288, 48}, - {0, 0, 0, 0}, - {112, 32, 128, 48}, + // NpcRegu + {224, 32, 240, 48}, // 0 - Stood + {240, 32, 256, 48}, // 1 - Blinking + {256, 32, 272, 48}, // 2 - Injured - falling backwards + {272, 32, 288, 48}, // 3 - Lying down + {288, 32, 304, 48}, // 4 - Walking - frame 1 + {224, 32, 240, 48}, // 5 - Walking - frame 2 + {304, 32, 320, 48}, // 6 - Walking - frame 3 + {224, 32, 240, 48}, // 7 - Walking - frame 4 + {272, 32, 288, 48}, // 8 - Dying - frame 1 + {0, 0, 0, 0}, // 9 - Dying - frame 2 + // NpcSym + {112, 32, 128, 48}, // 10 - King's sword }; RECT rcRight[11] = { - {224, 48, 240, 64}, - {240, 48, 256, 64}, - {256, 48, 272, 64}, - {272, 48, 288, 64}, - {288, 48, 304, 64}, - {224, 48, 240, 64}, - {304, 48, 320, 64}, - {224, 48, 240, 64}, - {272, 48, 288, 64}, - {0, 0, 0, 0}, - {112, 32, 128, 48}, + // NpcRegu + {224, 48, 240, 64}, // 0 - Stood + {240, 48, 256, 64}, // 1 - Blinking + {256, 48, 272, 64}, // 2 - Injured - falling backwards + {272, 48, 288, 64}, // 3 - Lying down + {288, 48, 304, 64}, // 4 - Walking - frame 1 + {224, 48, 240, 64}, // 5 - Walking - frame 2 + {304, 48, 320, 64}, // 6 - Walking - frame 3 + {224, 48, 240, 64}, // 7 - Walking - frame 4 + {272, 48, 288, 64}, // 8 - Dying - frame 1 + {0, 0, 0, 0}, // 9 - Dying - frame 2 + // NpcSym + {112, 32, 128, 48}, // 10 - King's sword }; switch (npc->act_no) { - case 0: + case 0: // Stood npc->act_no = 1; npc->ani_no = 0; npc->ani_wait = 0; @@ -247,7 +251,7 @@ void ActNpc061(NPCHAR *npc) break; - case 2: + case 2: // Blink if (++npc->act_wait > 8) { npc->act_no = 1; @@ -256,12 +260,12 @@ void ActNpc061(NPCHAR *npc) break; - case 5: + case 5: // Lying down npc->ani_no = 3; npc->xm = 0; break; - case 6: + case 6: // Being knocked-back npc->act_no = 7; npc->act_wait = 0; npc->ani_wait = 0; @@ -275,12 +279,14 @@ void ActNpc061(NPCHAR *npc) else npc->xm = 0x200; + // If touching ground, enter 'lying down' state (the `act_wait` check is probably + // so he doesn't do it before he even leaves the ground in the first place) if (npc->act_wait++ != 0 && npc->flag & 8) npc->act_no = 5; break; - case 8: + case 8: // Walking npc->act_no = 9; npc->ani_no = 4; npc->ani_wait = 0; @@ -302,7 +308,7 @@ void ActNpc061(NPCHAR *npc) break; - case 10: + case 10: // Running npc->act_no = 11; npc->ani_no = 4; npc->ani_wait = 0; @@ -324,13 +330,13 @@ void ActNpc061(NPCHAR *npc) break; - case 20: - SetNpChar(145, 0, 0, 0, 0, 2, npc, 0x100); + case 20: // Spawn his sword, before entering his 'idle' state + SetNpChar(NPC_KINGS_SWORD, 0, 0, 0, 0, 2, npc, 0x100); npc->ani_no = 0; npc->act_no = 0; break; - case 30: + case 30: // Flying through air after being attacked by Misery npc->act_no = 31; npc->act_wait = 0; npc->ani_wait = 0; @@ -358,7 +364,7 @@ void ActNpc061(NPCHAR *npc) break; - case 40: + case 40: // Dying npc->act_no = 42; npc->act_wait = 0; npc->ani_no = 8; @@ -371,7 +377,7 @@ void ActNpc061(NPCHAR *npc) if (++npc->act_wait > 100) { for (i = 0; i < 4; ++i) - SetNpChar(4, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); + SetNpChar(NPC_SMOKE, npc->x + (Random(-12, 12) * 0x200), npc->y + (Random(-12, 12) * 0x200), Random(-341, 341), Random(-0x600, 0), 0, NULL, 0x100); npc->act_no = 50; npc->surf = SURFACE_ID_NPC_SYM; @@ -380,7 +386,7 @@ void ActNpc061(NPCHAR *npc) break; - case 60: + case 60: // Leap (used to attack Balrog in the Sand Zone storehouse) npc->ani_no = 6; npc->act_no = 61; npc->ym = -0x5FF; @@ -388,7 +394,7 @@ void ActNpc061(NPCHAR *npc) npc->count2 = 1; break; - case 61: + case 61: // Leap - part 2 npc->ym += 0x40; if (npc->flag & 8) @@ -401,6 +407,7 @@ void ActNpc061(NPCHAR *npc) break; } + // Apply gravity and speed-caps during most states if (npc->act_no < 30 || npc->act_no >= 40) { npc->ym += 0x40;