Merge branch 'accurate' into portable

This commit is contained in:
Clownacy 2020-03-31 14:06:15 +01:00
commit b8de1cb5db
7 changed files with 90 additions and 82 deletions

View file

@ -259,7 +259,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
if (!IsEnableBitmap(path)) if (!IsEnableBitmap(path))
{ {
PrintBitmapError(path, 0); ErrorLog(path, 0);
return FALSE; return FALSE;
} }
@ -269,13 +269,13 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
if (surf_no > SURFACE_ID_MAX) if (surf_no > SURFACE_ID_MAX)
#endif #endif
{ {
PrintBitmapError("surface no", surf_no); ErrorLog("surface no", surf_no);
return FALSE; return FALSE;
} }
if (surf[surf_no] != NULL) if (surf[surf_no] != NULL)
{ {
PrintBitmapError("existing", surf_no); ErrorLog("existing", surf_no);
return FALSE; return FALSE;
} }
@ -284,7 +284,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
if (image_buffer == NULL) if (image_buffer == NULL)
{ {
PrintBitmapError(path, 1); ErrorLog(path, 1);
return FALSE; return FALSE;
} }
@ -350,7 +350,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
if (!IsEnableBitmap(path)) if (!IsEnableBitmap(path))
{ {
PrintBitmapError(path, 0); ErrorLog(path, 0);
return FALSE; return FALSE;
} }
@ -360,7 +360,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
if (surf_no > SURFACE_ID_MAX) if (surf_no > SURFACE_ID_MAX)
#endif #endif
{ {
PrintBitmapError("surface no", surf_no); ErrorLog("surface no", surf_no);
return FALSE; return FALSE;
} }
@ -369,7 +369,7 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
if (image_buffer == NULL) if (image_buffer == NULL)
{ {
PrintBitmapError(path, 1); ErrorLog(path, 1);
return FALSE; 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 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) 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) if (x < rcView->left)
{ {
src_rect.left += rcView->left - x; rcWork.left += rcView->left - x;
x = rcView->left; x = rcView->left;
} }
if (y + rect->bottom - rect->top > rcView->bottom) 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) if (y < rcView->top)
{ {
src_rect.top += rcView->top - y; rcWork.top += rcView->top - y;
y = rcView->top; y = rcView->top;
} }
src_rect.left *= magnification; rcWork.left *= magnification;
src_rect.top *= magnification; rcWork.top *= magnification;
src_rect.right *= magnification; rcWork.right *= magnification;
src_rect.bottom *= 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 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) 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) if (x < rcView->left)
{ {
src_rect.left += rcView->left - x; rcWork.left += rcView->left - x;
x = rcView->left; x = rcView->left;
} }
if (y + rect->bottom - rect->top > rcView->bottom) 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) if (y < rcView->top)
{ {
src_rect.top += rcView->top - y; rcWork.top += rcView->top - y;
y = rcView->top; y = rcView->top;
} }
src_rect.left *= magnification; rcWork.left *= magnification;
src_rect.top *= magnification; rcWork.top *= magnification;
src_rect.right *= magnification; rcWork.right *= magnification;
src_rect.bottom *= 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) 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; rcWork.left = rect->left * magnification;
src_rect.top = rect->top * magnification; rcWork.top = rect->top * magnification;
src_rect.right = rect->right * magnification; rcWork.right = rect->right * magnification;
src_rect.bottom = rect->bottom * 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) unsigned long GetCortBoxColor(unsigned long col)

View file

@ -47,7 +47,7 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
return TRUE; return TRUE;
} }
void DeleteDebugLog(void) void DeleteLog(void)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
@ -55,7 +55,7 @@ void DeleteDebugLog(void)
remove(path); 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]; char path[MAX_PATH];
FILE *fp; FILE *fp;
@ -71,7 +71,7 @@ BOOL PrintDebugLog(const char *string, int value1, int value2, int value3)
return TRUE; return TRUE;
} }
BOOL CheckFileExists(const char *name) BOOL IsKeyFile(const char *name)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
@ -103,7 +103,7 @@ long GetFileSizeLong(const char *path)
return len; return len;
} }
BOOL PrintBitmapError(const char *string, int value) BOOL ErrorLog(const char *string, int value)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
FILE *fp; FILE *fp;

View file

@ -4,10 +4,10 @@
void GetCompileDate(int *year, int *month, int *day); void GetCompileDate(int *year, int *month, int *day);
BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4); BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4);
void DeleteDebugLog(void); void DebugLog(void);
BOOL PrintDebugLog(const char *string, int value1, int value2, int value3); BOOL WriteLog(const char *string, int value1, int value2, int value3);
BOOL CheckFileExists(const char *name); BOOL IsKeyFile(const char *name);
long GetFileSizeLong(const char *path); 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 IsShiftJIS(unsigned char c);
BOOL IsEnableBitmap(const char *path); BOOL IsEnableBitmap(const char *path);

View file

@ -136,7 +136,7 @@ int main(int argc, char *argv[])
} }
// Swap left and right weapon switch keys // Swap left and right weapon switch keys
if (CheckFileExists("s_reverse")) if (IsKeyFile("s_reverse"))
{ {
gKeyArms = KEY_ARMSREV; gKeyArms = KEY_ARMSREV;
gKeyArmsRev = KEY_ARMS; gKeyArmsRev = KEY_ARMS;
@ -271,7 +271,7 @@ int main(int argc, char *argv[])
SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0);
SDL_SetCursor(cursor); SDL_SetCursor(cursor);
if (CheckFileExists("fps")) if (IsKeyFile("fps"))
bFps = TRUE; bFps = TRUE;
// Set rects // Set rects

View file

@ -166,7 +166,7 @@ void SetDestroyNpChar(int x, int y, int w, int num)
{ {
offset_x = Random(-w, w) * 0x200; offset_x = Random(-w, w) * 0x200;
offset_y = 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 // Flash effect

View file

@ -47,8 +47,9 @@ enum NPCNames
NPC_MALCO_UNDAMAGED = 107, NPC_MALCO_UNDAMAGED = 107,
NPC_PROJECTILE_BALFROG_SPITBALL = 108, NPC_PROJECTILE_BALFROG_SPITBALL = 108,
NPC_MALCO_DAMAGED = 109, NPC_MALCO_DAMAGED = 109,
NPC_ENEMY_PUCHI = 110 NPC_ENEMY_PUCHI = 110,
// To be continued // To be continued
NPC_KINGS_SWORD = 145
}; };
typedef struct NPCHAR typedef struct NPCHAR

View file

@ -202,36 +202,40 @@ void ActNpc061(NPCHAR *npc)
int i; int i;
RECT rcLeft[11] = { RECT rcLeft[11] = {
{224, 32, 240, 48}, // NpcRegu
{240, 32, 256, 48}, {224, 32, 240, 48}, // 0 - Stood
{256, 32, 272, 48}, {240, 32, 256, 48}, // 1 - Blinking
{272, 32, 288, 48}, {256, 32, 272, 48}, // 2 - Injured - falling backwards
{288, 32, 304, 48}, {272, 32, 288, 48}, // 3 - Lying down
{224, 32, 240, 48}, {288, 32, 304, 48}, // 4 - Walking - frame 1
{304, 32, 320, 48}, {224, 32, 240, 48}, // 5 - Walking - frame 2
{224, 32, 240, 48}, {304, 32, 320, 48}, // 6 - Walking - frame 3
{272, 32, 288, 48}, {224, 32, 240, 48}, // 7 - Walking - frame 4
{0, 0, 0, 0}, {272, 32, 288, 48}, // 8 - Dying - frame 1
{112, 32, 128, 48}, {0, 0, 0, 0}, // 9 - Dying - frame 2
// NpcSym
{112, 32, 128, 48}, // 10 - King's sword
}; };
RECT rcRight[11] = { RECT rcRight[11] = {
{224, 48, 240, 64}, // NpcRegu
{240, 48, 256, 64}, {224, 48, 240, 64}, // 0 - Stood
{256, 48, 272, 64}, {240, 48, 256, 64}, // 1 - Blinking
{272, 48, 288, 64}, {256, 48, 272, 64}, // 2 - Injured - falling backwards
{288, 48, 304, 64}, {272, 48, 288, 64}, // 3 - Lying down
{224, 48, 240, 64}, {288, 48, 304, 64}, // 4 - Walking - frame 1
{304, 48, 320, 64}, {224, 48, 240, 64}, // 5 - Walking - frame 2
{224, 48, 240, 64}, {304, 48, 320, 64}, // 6 - Walking - frame 3
{272, 48, 288, 64}, {224, 48, 240, 64}, // 7 - Walking - frame 4
{0, 0, 0, 0}, {272, 48, 288, 64}, // 8 - Dying - frame 1
{112, 32, 128, 48}, {0, 0, 0, 0}, // 9 - Dying - frame 2
// NpcSym
{112, 32, 128, 48}, // 10 - King's sword
}; };
switch (npc->act_no) switch (npc->act_no)
{ {
case 0: case 0: // Stood
npc->act_no = 1; npc->act_no = 1;
npc->ani_no = 0; npc->ani_no = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -247,7 +251,7 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 2: case 2: // Blink
if (++npc->act_wait > 8) if (++npc->act_wait > 8)
{ {
npc->act_no = 1; npc->act_no = 1;
@ -256,12 +260,12 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 5: case 5: // Lying down
npc->ani_no = 3; npc->ani_no = 3;
npc->xm = 0; npc->xm = 0;
break; break;
case 6: case 6: // Being knocked-back
npc->act_no = 7; npc->act_no = 7;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -275,12 +279,14 @@ void ActNpc061(NPCHAR *npc)
else else
npc->xm = 0x200; 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) if (npc->act_wait++ != 0 && npc->flag & 8)
npc->act_no = 5; npc->act_no = 5;
break; break;
case 8: case 8: // Walking
npc->act_no = 9; npc->act_no = 9;
npc->ani_no = 4; npc->ani_no = 4;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -302,7 +308,7 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 10: case 10: // Running
npc->act_no = 11; npc->act_no = 11;
npc->ani_no = 4; npc->ani_no = 4;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -324,13 +330,13 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 20: case 20: // Spawn his sword, before entering his 'idle' state
SetNpChar(145, 0, 0, 0, 0, 2, npc, 0x100); SetNpChar(NPC_KINGS_SWORD, 0, 0, 0, 0, 2, npc, 0x100);
npc->ani_no = 0; npc->ani_no = 0;
npc->act_no = 0; npc->act_no = 0;
break; break;
case 30: case 30: // Flying through air after being attacked by Misery
npc->act_no = 31; npc->act_no = 31;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_wait = 0; npc->ani_wait = 0;
@ -358,7 +364,7 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 40: case 40: // Dying
npc->act_no = 42; npc->act_no = 42;
npc->act_wait = 0; npc->act_wait = 0;
npc->ani_no = 8; npc->ani_no = 8;
@ -371,7 +377,7 @@ void ActNpc061(NPCHAR *npc)
if (++npc->act_wait > 100) if (++npc->act_wait > 100)
{ {
for (i = 0; i < 4; ++i) 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->act_no = 50;
npc->surf = SURFACE_ID_NPC_SYM; npc->surf = SURFACE_ID_NPC_SYM;
@ -380,7 +386,7 @@ void ActNpc061(NPCHAR *npc)
break; break;
case 60: case 60: // Leap (used to attack Balrog in the Sand Zone storehouse)
npc->ani_no = 6; npc->ani_no = 6;
npc->act_no = 61; npc->act_no = 61;
npc->ym = -0x5FF; npc->ym = -0x5FF;
@ -388,7 +394,7 @@ void ActNpc061(NPCHAR *npc)
npc->count2 = 1; npc->count2 = 1;
break; break;
case 61: case 61: // Leap - part 2
npc->ym += 0x40; npc->ym += 0x40;
if (npc->flag & 8) if (npc->flag & 8)
@ -401,6 +407,7 @@ void ActNpc061(NPCHAR *npc)
break; break;
} }
// Apply gravity and speed-caps during most states
if (npc->act_no < 30 || npc->act_no >= 40) if (npc->act_no < 30 || npc->act_no >= 40)
{ {
npc->ym += 0x40; npc->ym += 0x40;