Merge branch 'accurate' into portable

This commit is contained in:
Clownacy 2020-04-19 22:46:04 +01:00
commit b89207b586
7 changed files with 43 additions and 39 deletions

View file

@ -35,7 +35,7 @@ void InitBossChar(int code)
void PutBossChar(int fx, int fy)
{
char a = 0;
signed char a = 0;
int b;
int side;

View file

@ -8,8 +8,8 @@
#include "File.h"
#include "Main.h"
static const char* const config_filename = "Config.dat"; // Not the original name
static const char* const config_magic = "DOUKUTSU20041206"; // Not the original name
static const char* const gConfigName = "Config.dat";
static const char* const gProof = "DOUKUTSU20041206";
BOOL LoadConfigData(CONFIG *conf)
{
@ -18,7 +18,7 @@ BOOL LoadConfigData(CONFIG *conf)
// Get path
char path[MAX_PATH];
sprintf(path, "%s/%s", gModulePath, config_filename);
sprintf(path, "%s/%s", gModulePath, gConfigName);
// Open file
FILE *fp = fopen(path, "rb");
@ -46,7 +46,7 @@ BOOL LoadConfigData(CONFIG *conf)
fclose(fp);
// Check if version is not correct, and return if it failed
if (strcmp(conf->proof, config_magic))
if (strcmp(conf->proof, gProof))
{
memset(conf, 0, sizeof(CONFIG));
return FALSE;

View file

@ -50,6 +50,7 @@ static struct
BOOL Flip_SystemTask(void)
{
// TODO - Not the original variable names
static unsigned long timePrev;
static unsigned long timeNow;
@ -412,7 +413,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem
void BackupSurface(SurfaceID surf_no, const RECT *rect)
{
static RenderBackend_Rect scaled_rect;
static RenderBackend_Rect scaled_rect; // TODO - Not the original variable name
scaled_rect.left = rect->left * magnification;
scaled_rect.top = rect->top * magnification;
scaled_rect.right = rect->right * magnification;
@ -511,7 +512,7 @@ unsigned long GetCortBoxColor(unsigned long col)
void CortBox(const RECT *rect, unsigned long col)
{
static RenderBackend_Rect dst_rect;
static RenderBackend_Rect dst_rect; // TODO - Not the original variable name
dst_rect.left = rect->left * magnification;
dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * magnification;
@ -526,7 +527,7 @@ void CortBox(const RECT *rect, unsigned long col)
void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
{
static RenderBackend_Rect dst_rect;
static RenderBackend_Rect dst_rect; // TODO - Not the original variable name
dst_rect.left = rect->left * magnification;
dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * magnification;
@ -541,7 +542,9 @@ void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue);
}
BOOL DummiedOutLogFunction(int unknown)
// Dummied-out log function
// According to the Mac port, its name really is just "out".
static BOOL out(int unknown)
{
char unknown2[0x100];
int unknown3;
@ -557,7 +560,8 @@ BOOL DummiedOutLogFunction(int unknown)
return TRUE;
}
int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the Linux port
// TODO - Probably not the original variable name (this is an educated guess)
int RestoreSurfaces(void)
{
int s;
RECT rect;
@ -570,7 +574,7 @@ int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the L
{
++surfaces_regenerated;
RenderBackend_RestoreSurface(framebuffer);
DummiedOutLogFunction(0x62);
out(0x62);
}
for (s = 0; s < SURFACE_ID_MAX; ++s)
@ -581,7 +585,7 @@ int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the L
{
++surfaces_regenerated;
RenderBackend_RestoreSurface(surf[s]);
DummiedOutLogFunction(0x30 + s);
out(0x30 + s);
if (!surface_metadata[s].bSystem)
{

View file

@ -41,7 +41,7 @@ void MoveFrame3(void)
--gFrame.quake;
}
// This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6)
// This code exists in the Linux port (v1.0.0.4), but not the Windows version (v1.0.0.6) or the Mac port
/* if (gFrame.x / 0x200 < 0)
gFrame.x = 0;
if (gFrame.y / 0x200 < 0)

View file

@ -34,7 +34,7 @@ BOOL gbUseJoystick = FALSE;
int gJoystickButtonTable[8];
static BOOL bActive = TRUE;
static BOOL bFps = FALSE;
static BOOL bFPS = FALSE;
static int windowWidth;
static int windowHeight;
@ -48,38 +48,38 @@ static const char *lpWindowName = "Cave Story ~ Doukutsu Monogatari";
// Framerate stuff
void PutFramePerSecound(void)
{
if (bFps)
if (bFPS)
{
const unsigned long fps = GetFramePerSecound();
const unsigned long fps = CountFramePerSecound();
PutNumber4(WINDOW_WIDTH - 40, 8, fps, FALSE);
}
}
unsigned long GetFramePerSecound(void)
unsigned long CountFramePerSecound(void)
{
unsigned long current_tick;
static BOOL need_new_base_tick = TRUE;
static unsigned long frames_this_second;
static unsigned long current_frame;
static unsigned long base_tick;
unsigned long current_tick; // The original name for this variable is unknown
static BOOL first = TRUE;
static unsigned long max_count;
static unsigned long count;
static unsigned long wait;
if (need_new_base_tick)
if (first)
{
base_tick = Backend_GetTicks();
need_new_base_tick = FALSE;
wait = Backend_GetTicks();
first = FALSE;
}
current_tick = Backend_GetTicks();
++current_frame;
++count;
if (base_tick + 1000 <= current_tick)
if (wait + 1000 <= current_tick)
{
base_tick += 1000;
frames_this_second = current_frame;
current_frame = 0;
wait += 1000;
max_count = count;
count = 0;
}
return frames_this_second;
return max_count;
}
// TODO - Inaccurate stack frame
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
}
if (IsKeyFile("fps"))
bFps = TRUE;
bFPS = TRUE;
// Set rects
RECT rcLoading = {0, 0, 64, 8};

View file

@ -10,7 +10,7 @@ extern BOOL bFullscreen;
extern BOOL gbUseJoystick;
void PutFramePerSecound(void);
unsigned long GetFramePerSecound(void);
unsigned long CountFramePerSecound(void);
void InactiveWindow(void);
void ActiveWindow(void);

View file

@ -27,12 +27,7 @@ int gSuperYpos;
const char *gPassPixEve = "PXE";
void InitNpChar(void)
{
memset(gNPC, 0, sizeof(gNPC));
}
void SetUniqueParameter(NPCHAR *npc)
static void SetUniqueParameter(NPCHAR *npc)
{
int code = npc->code_char;
npc->surf = (SurfaceID)gNpcTable[code].surf;
@ -51,6 +46,11 @@ void SetUniqueParameter(NPCHAR *npc)
npc->view.bottom = gNpcTable[code].view.bottom * 0x200;
}
void InitNpChar(void)
{
memset(gNPC, 0, sizeof(gNPC));
}
BOOL LoadEvent(const char *path_event)
{
int i, n;