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) void PutBossChar(int fx, int fy)
{ {
char a = 0; signed char a = 0;
int b; int b;
int side; int side;

View file

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

View file

@ -50,6 +50,7 @@ static struct
BOOL Flip_SystemTask(void) BOOL Flip_SystemTask(void)
{ {
// TODO - Not the original variable names
static unsigned long timePrev; static unsigned long timePrev;
static unsigned long timeNow; 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) 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.left = rect->left * magnification;
scaled_rect.top = rect->top * magnification; scaled_rect.top = rect->top * magnification;
scaled_rect.right = rect->right * 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) 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.left = rect->left * magnification;
dst_rect.top = rect->top * magnification; dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * 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) 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.left = rect->left * magnification;
dst_rect.top = rect->top * magnification; dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * 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); 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]; char unknown2[0x100];
int unknown3; int unknown3;
@ -557,7 +560,8 @@ BOOL DummiedOutLogFunction(int unknown)
return TRUE; 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; int s;
RECT rect; RECT rect;
@ -570,7 +574,7 @@ int RestoreSurfaces(void) // Guessed function name - this doesn't exist in the L
{ {
++surfaces_regenerated; ++surfaces_regenerated;
RenderBackend_RestoreSurface(framebuffer); RenderBackend_RestoreSurface(framebuffer);
DummiedOutLogFunction(0x62); out(0x62);
} }
for (s = 0; s < SURFACE_ID_MAX; ++s) 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; ++surfaces_regenerated;
RenderBackend_RestoreSurface(surf[s]); RenderBackend_RestoreSurface(surf[s]);
DummiedOutLogFunction(0x30 + s); out(0x30 + s);
if (!surface_metadata[s].bSystem) if (!surface_metadata[s].bSystem)
{ {

View file

@ -41,7 +41,7 @@ void MoveFrame3(void)
--gFrame.quake; --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) /* if (gFrame.x / 0x200 < 0)
gFrame.x = 0; gFrame.x = 0;
if (gFrame.y / 0x200 < 0) if (gFrame.y / 0x200 < 0)

View file

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

View file

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

View file

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