diff --git a/src/Draw.cpp b/src/Draw.cpp index 03db0a19..b4e8e01f 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -259,7 +259,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no) if (!IsEnableBitmap(path)) { - PrintBitmapError(path, 0); + ErrorLog(path, 0); return FALSE; } @@ -269,13 +269,13 @@ 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; } @@ -284,7 +284,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no) if (image_buffer == NULL) { - PrintBitmapError(path, 1); + ErrorLog(path, 1); return FALSE; } @@ -350,7 +350,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no) if (!IsEnableBitmap(path)) { - PrintBitmapError(path, 0); + ErrorLog(path, 0); return FALSE; } @@ -360,7 +360,7 @@ 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; } @@ -369,7 +369,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no) if (image_buffer == NULL) { - PrintBitmapError(path, 1); + ErrorLog(path, 1); return FALSE; } @@ -431,78 +431,78 @@ 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; - 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; } - 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; - Backend_Blit(surf[surf_no], &src_rect, framebuffer, x * magnification, y * magnification, TRUE); + Backend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE); } void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency { - static RECT src_rect; + static RECT rcWork; - 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; } - 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; - Backend_Blit(surf[surf_no], &src_rect, framebuffer, x * magnification, y * magnification, FALSE); + Backend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE); } void Surface2Surface(int x, int y, const RECT *rect, int to, int from) { - static RECT src_rect; + static RECT rcWork; - 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; - Backend_Blit(surf[from], &src_rect, surf[to], x * magnification, y * magnification, TRUE); + Backend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE); } unsigned long GetCortBoxColor(unsigned long col) diff --git a/src/Generic.cpp b/src/Generic.cpp index b2a69fb5..c12bdc47 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -47,7 +47,7 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4) return TRUE; } -void DeleteDebugLog(void) +void DeleteLog(void) { char path[MAX_PATH]; @@ -55,7 +55,7 @@ void DeleteDebugLog(void) remove(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; @@ -71,7 +71,7 @@ BOOL PrintDebugLog(const char *string, int value1, int value2, int value3) return TRUE; } -BOOL CheckFileExists(const char *name) +BOOL IsKeyFile(const char *name) { char path[MAX_PATH]; @@ -103,7 +103,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; diff --git a/src/Generic.h b/src/Generic.h index d6ea38bb..aa66c752 100644 --- a/src/Generic.h +++ b/src/Generic.h @@ -4,10 +4,10 @@ void GetCompileDate(int *year, int *month, int *day); BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4); -void DeleteDebugLog(void); -BOOL PrintDebugLog(const char *string, int value1, int value2, int value3); -BOOL CheckFileExists(const char *name); +void DebugLog(void); +BOOL WriteLog(const char *string, int value1, int value2, int value3); +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 IsEnableBitmap(const char *path); diff --git a/src/Main.cpp b/src/Main.cpp index 5755e398..449eab6f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) } // Swap left and right weapon switch keys - if (CheckFileExists("s_reverse")) + if (IsKeyFile("s_reverse")) { gKeyArms = KEY_ARMSREV; gKeyArmsRev = KEY_ARMS; @@ -271,7 +271,7 @@ int main(int argc, char *argv[]) SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); SDL_SetCursor(cursor); - if (CheckFileExists("fps")) + if (IsKeyFile("fps")) bFps = TRUE; // Set rects diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 3aea159b..4333b735 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -166,7 +166,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;