ref: 826abb343fe579e9683ad2a67290b8e708b10149
parent: 5e49d734c92529b346240b9a7723a084e2e1ceb8
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Nov 15 15:12:41 EST 2019
Clean-up Frame.cpp
--- a/src/Frame.cpp
+++ b/src/Frame.cpp
@@ -9,7 +9,7 @@
FRAME gFrame;
-void MoveFrame3()
+void MoveFrame3(void)
{
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
@@ -18,8 +18,8 @@
if (g_GameFlags & 8)
{
// Use the original camera boundaries during the credits
- gFrame.x += (*gFrame.tgt_x - (320 * 0x100) - gFrame.x) / gFrame.wait;
- gFrame.y += (*gFrame.tgt_y - (240 * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (320 * 0x200 / 2) - gFrame.x) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (240 * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
@@ -26,10 +26,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -37,40 +37,40 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
- gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x100) - gFrame.x) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x200 / 2) - gFrame.x) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
- gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
// Vanilla behaviour
- gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x100) - gFrame.x) / gFrame.wait;
- gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x100) - gFrame.y) / gFrame.wait;
+ gFrame.x += (*gFrame.tgt_x - (WINDOW_WIDTH * 0x200 / 2) - gFrame.x) / gFrame.wait;
+ gFrame.y += (*gFrame.tgt_y - (WINDOW_HEIGHT * 0x200 / 2) - gFrame.y) / gFrame.wait;
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
@@ -77,10 +77,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
// Quake
@@ -97,7 +97,7 @@
--gFrame.quake;
}
- // This code exists in the Linux port, but not the Windows version
+ // This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6)
/* if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
if (gFrame.y / 0x200 < 0)
@@ -133,10 +133,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -144,9 +144,9 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -153,13 +153,13 @@
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -166,8 +166,8 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
@@ -177,14 +177,14 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200)
- gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200)
- gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
}
-void SetFrameMyChar()
+void SetFrameMyChar(void)
{
// Move frame position
int mc_x, mc_y;
@@ -193,8 +193,8 @@
short map_w, map_l;
GetMapData(0, &map_w, &map_l);
- gFrame.x = mc_x - (WINDOW_WIDTH << 8);
- gFrame.y = mc_y - (WINDOW_HEIGHT << 8);
+ gFrame.x = mc_x - ((WINDOW_WIDTH / 2) * 0x200);
+ gFrame.y = mc_y - ((WINDOW_HEIGHT / 2) * 0x200);
// Keep in bounds
#if WINDOW_WIDTH != 320 || WINDOW_HEIGHT != 240
@@ -206,10 +206,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - 320) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - 320) * 0x200;
- if (gFrame.y > ((map_l - 1) * 0x10 - 240) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - 240) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - 320) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - 320) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - 240) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - 240) * 0x200;
gFrame.x -= ((WINDOW_WIDTH - 320) / 2) * 0x200;
gFrame.y -= ((WINDOW_HEIGHT - 240) / 2) * 0x200;
@@ -217,9 +217,9 @@
else
{
// Widescreen/tallscreen-safe behaviour
- if (map_w * 0x10 < WINDOW_WIDTH)
+ if (map_w * 16 < WINDOW_WIDTH)
{
- gFrame.x = -(((WINDOW_WIDTH - (map_w - 1) * 0x10) * 0x200) / 2);
+ gFrame.x = -(((WINDOW_WIDTH - ((map_w - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -226,13 +226,13 @@
if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
- if (gFrame.x > ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200)
- gFrame.x = ((map_w - 1) * 0x10 - WINDOW_WIDTH) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
}
- if (map_l * 0x10 < WINDOW_HEIGHT)
+ if (map_l * 16 < WINDOW_HEIGHT)
{
- gFrame.y = -(((WINDOW_HEIGHT - (map_l - 1) * 0x10) * 0x200) / 2);
+ gFrame.y = -(((WINDOW_HEIGHT - ((map_l - 1) * 16)) * 0x200) / 2);
}
else
{
@@ -239,8 +239,8 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.y > ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200)
- gFrame.y = ((map_l - 1) * 0x10 - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
}
}
#else
@@ -250,10 +250,10 @@
if (gFrame.y / 0x200 < 0)
gFrame.y = 0;
- if (gFrame.x > (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200)
- gFrame.x = (((map_w - 1) * 0x10) - WINDOW_WIDTH) * 0x200;
- if (gFrame.y > (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200)
- gFrame.y = (((map_l - 1) * 0x10) - WINDOW_HEIGHT) * 0x200;
+ if (gFrame.x > (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200)
+ gFrame.x = (((map_w - 1) * 16) - WINDOW_WIDTH) * 0x200;
+ if (gFrame.y > (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200)
+ gFrame.y = (((map_l - 1) * 16) - WINDOW_HEIGHT) * 0x200;
#endif
}
@@ -267,7 +267,7 @@
void SetFrameTargetNpChar(int event, int wait)
{
int i;
- for (i = 0; i < NPC_MAX; i++)
+ for (i = 0; i < NPC_MAX; ++i)
if (gNPC[i].code_event == event)
break;
@@ -296,7 +296,7 @@
gFrame.quake2 = time;
}
-void ResetQuake()
+void ResetQuake(void)
{
gFrame.quake = 0;
gFrame.quake2 = 0;
--- a/src/Frame.h
+++ b/src/Frame.h
@@ -13,13 +13,13 @@
extern FRAME gFrame;
-void MoveFrame3();
+void MoveFrame3(void);
void GetFramePosition(int *fx, int *fy);
void SetFramePosition(int fx, int fy);
-void SetFrameMyChar();
+void SetFrameMyChar(void);
void SetFrameTargetMyChar(int wait);
void SetFrameTargetNpChar(int event, int wait);
void SetFrameTargetBoss(int no, int wait);
void SetQuake(int time);
void SetQuake2(int time);
-void ResetQuake();
+void ResetQuake(void);