ref: b8de1cb5db536b68f3d64ba5cfa69f3539526717
parent: 61e708751d7cc6ed01cb1e56e58f4cea836f2fa4
parent: ca6538561f43dd0d96dc9412a7876e2465d2b38b
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Mar 31 10:06:15 EDT 2020
Merge branch 'accurate' into portable
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -259,7 +259,7 @@
if (!IsEnableBitmap(path))
{
- PrintBitmapError(path, 0);
+ ErrorLog(path, 0);
return FALSE;
}
@@ -269,13 +269,13 @@
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 @@
if (image_buffer == NULL)
{
- PrintBitmapError(path, 1);
+ ErrorLog(path, 1);
return FALSE;
}
@@ -350,7 +350,7 @@
if (!IsEnableBitmap(path))
{
- PrintBitmapError(path, 0);
+ ErrorLog(path, 0);
return FALSE;
}
@@ -360,7 +360,7 @@
if (surf_no > SURFACE_ID_MAX)
#endif
{
- PrintBitmapError("surface no", surf_no);
+ ErrorLog("surface no", surf_no);
return FALSE;
}
@@ -369,7 +369,7 @@
if (image_buffer == NULL)
{
- PrintBitmapError(path, 1);
+ ErrorLog(path, 1);
return FALSE;
}
@@ -431,78 +431,78 @@
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)
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -47,7 +47,7 @@
return TRUE;
}
-void DeleteDebugLog(void)
+void DeleteLog(void)
{
char path[MAX_PATH];
@@ -55,7 +55,7 @@
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 @@
return TRUE;
}
-BOOL CheckFileExists(const char *name)
+BOOL IsKeyFile(const char *name)
{
char path[MAX_PATH];
@@ -103,7 +103,7 @@
return len;
}
-BOOL PrintBitmapError(const char *string, int value)
+BOOL ErrorLog(const char *string, int value)
{
char path[MAX_PATH];
FILE *fp;
--- 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);
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -136,7 +136,7 @@
}
// 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 @@
SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0);
SDL_SetCursor(cursor);
- if (CheckFileExists("fps"))
+ if (IsKeyFile("fps"))
bFps = TRUE;
// Set rects
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -166,7 +166,7 @@
{
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
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -47,8 +47,9 @@
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
--- a/src/NpcAct060.cpp
+++ b/src/NpcAct060.cpp
@@ -202,36 +202,40 @@
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 @@
break;
- case 2:
+ case 2: // Blink
if (++npc->act_wait > 8)
{
npc->act_no = 1;
@@ -256,12 +260,12 @@
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 @@
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 @@
break;
- case 10:
+ case 10: // Running
npc->act_no = 11;
npc->ani_no = 4;
npc->ani_wait = 0;
@@ -324,13 +330,13 @@
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 @@
break;
- case 40:
+ case 40: // Dying
npc->act_no = 42;
npc->act_wait = 0;
npc->ani_no = 8;
@@ -371,7 +377,7 @@
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 @@
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 @@
npc->count2 = 1;
break;
- case 61:
+ case 61: // Leap - part 2
npc->ym += 0x40;
if (npc->flag & 8)
@@ -401,6 +407,7 @@
break;
}
+ // Apply gravity and speed-caps during most states
if (npc->act_no < 30 || npc->act_no >= 40)
{
npc->ym += 0x40;
--
⑨