Make variables more accurate

This commit changes which variables are static: the Mac (and
presumably the Linux) debug data tells you what variables are static,
by prefixing their names with double_underscores.

The variable names themselves also hint at this: global variables are
prefixed with 'g', and use upper-camelcase, while static variables
use whatever_you_call_this.
This commit is contained in:
Clownacy 2020-05-03 20:28:56 +01:00
parent 3dd904adf6
commit 03250d62a0
44 changed files with 246 additions and 188 deletions

View file

@ -20,10 +20,10 @@ ITEM gItemData[ITEM_MAX];
int gSelectedArms; int gSelectedArms;
int gSelectedItem; int gSelectedItem;
static int gCampTitleY; int gCampTitleY;
/// True if we're in the items section of the inventory (not in the weapons section) (only relevant when the inventory is open) /// True if we're in the items section of the inventory (not in the weapons section) (only relevant when the inventory is open)
static BOOL gCampActive; BOOL gCampActive;
int gArmsEnergyX = 16; int gArmsEnergyX = 16;

View file

@ -2,6 +2,10 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
// Limits for the amount of weapons and items
#define ARMS_MAX 8
#define ITEM_MAX 0x20
// "Arms" is a synonym of "weapon" here // "Arms" is a synonym of "weapon" here
// "Code" means "ID" here // "Code" means "ID" here
// "Num" often means "ammo" here // "Num" often means "ammo" here
@ -32,20 +36,6 @@ typedef struct ITEM
} ITEM; } ITEM;
// Limits for the amount of weapons and items
#define ARMS_MAX 8
#define ITEM_MAX 0x20
/// X coordinate for the weapons HUD section. Set it to 32 for the forward weapon rotation "animation", 0 for the reverse weapon rotation "animation" and 16 to immobilise it
extern int gArmsEnergyX;
/// Currently selected weapon
extern int gSelectedArms;
// Currently selected item
extern int gSelectedItem;
/// Contains data for all the weapons the character currently has /// Contains data for all the weapons the character currently has
extern ARMS gArmsData[ARMS_MAX]; extern ARMS gArmsData[ARMS_MAX];
@ -53,6 +43,21 @@ extern ARMS gArmsData[ARMS_MAX];
/// Contains data for all the items the character currently has /// Contains data for all the items the character currently has
extern ITEM gItemData[ITEM_MAX]; extern ITEM gItemData[ITEM_MAX];
/// Currently selected weapon
extern int gSelectedArms;
/// Currently selected item
extern int gSelectedItem;
extern int gCampTitleY;
/// True if we're in the items section of the inventory (not in the weapons section) (only relevant when the inventory is open)
extern BOOL gCampActive;
/// X coordinate for the weapons HUD section. Set it to 32 for the forward weapon rotation "animation", 0 for the reverse weapon rotation "animation" and 16 to immobilise it
extern int gArmsEnergyX;
/// Clear the weapons array, reverting it to the default state (no weapons) and adjust variables (initialize weapons basically) /// Clear the weapons array, reverting it to the default state (no weapons) and adjust variables (initialize weapons basically)
void ClearArmsData(void); void ClearArmsData(void);

View file

@ -3,6 +3,7 @@
#include "NpChar.h" #include "NpChar.h"
#define BOSS_MAX 20 #define BOSS_MAX 20
extern NPCHAR gBoss[BOSS_MAX]; extern NPCHAR gBoss[BOSS_MAX];
typedef void (*BOSSFUNCTION)(void); typedef void (*BOSSFUNCTION)(void);

View file

@ -7,14 +7,7 @@
#include "Draw.h" #include "Draw.h"
#include "NpChar.h" #include "NpChar.h"
static struct BOSSLIFE gBL;
{
BOOL flag;
int *pLife;
int max;
int br;
int count;
} gBL;
void InitBossLife(void) void InitBossLife(void)
{ {

View file

@ -2,6 +2,17 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
typedef struct BOSSLIFE // Not the original struct name
{
BOOL flag;
int *pLife;
int max;
int br;
int count;
} BOSSLIFE;
extern BOSSLIFE gBL;
void InitBossLife(void); void InitBossLife(void);
BOOL StartBossLife(int code_event); BOOL StartBossLife(int code_event);
BOOL StartBossLife2(void); BOOL StartBossLife2(void);

View file

@ -2,6 +2,8 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#define BULLET_MAX 0x40
typedef struct BULLET typedef struct BULLET
{ {
int flag; int flag;
@ -57,7 +59,6 @@ typedef struct BULLET_TABLE
} view; } view;
} BULLET_TABLE; } BULLET_TABLE;
#define BULLET_MAX 0x40
extern BULLET gBul[BULLET_MAX]; extern BULLET gBul[BULLET_MAX];
void InitBullet(void); void InitBullet(void);

View file

@ -8,7 +8,6 @@
#include "Game.h" #include "Game.h"
#include "Triangle.h" #include "Triangle.h"
#define CARET_MAX 0x40
CARET gCrt[CARET_MAX]; CARET gCrt[CARET_MAX];
CARET_TABLE gCaretTable[18] = { CARET_TABLE gCaretTable[18] = {
@ -510,7 +509,7 @@ void ActCaret17(CARET *crt)
} }
typedef void (*CARETFUNCTION)(CARET*); typedef void (*CARETFUNCTION)(CARET*);
CARETFUNCTION gpCaretFuncTbl[] = CARETFUNCTION gpCaretFuncTbl[18] =
{ {
ActCaret00, ActCaret00,
ActCaret01, ActCaret01,

View file

@ -2,6 +2,8 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#define CARET_MAX 0x40
struct CARET_TABLE struct CARET_TABLE
{ {
int view_left; int view_left;
@ -26,6 +28,9 @@ struct CARET
RECT rect; RECT rect;
}; };
extern CARET gCrt[CARET_MAX];
extern CARET_TABLE gCaretTable[18];
void InitCaret(void); void InitCaret(void);
void ActCaret(void); void ActCaret(void);
void PutCaret(int fx, int fy); void PutCaret(int fx, int fy);

View file

@ -7,8 +7,8 @@
#include "Config.h" #include "Config.h"
#include "Main.h" #include "Main.h"
static const char* const gConfigName = "Config.dat"; const char* const gConfigName = "Config.dat";
static const char* const gProof = "DOUKUTSU20041206"; const char* const gProof = "DOUKUTSU20041206";
BOOL LoadConfigData(CONFIG *conf) BOOL LoadConfigData(CONFIG *conf)
{ {

View file

@ -14,5 +14,8 @@ struct CONFIG
long joystick_button[8]; long joystick_button[8];
}; };
extern const char* const gConfigName;
extern const char* const gProof;
BOOL LoadConfigData(CONFIG *conf); BOOL LoadConfigData(CONFIG *conf);
void DefaultConfigData(CONFIG *conf); void DefaultConfigData(CONFIG *conf);

View file

@ -10,7 +10,7 @@
// All of the original names for the functions/variables in this file are unknown // All of the original names for the functions/variables in this file are unknown
static const char *version_string = const char* const gVersionString =
"version.%d.%d.%d.%d\r\n" "version.%d.%d.%d.%d\r\n"
"2004/12/20 - %04d/%02d/%02d\r\n" "2004/12/20 - %04d/%02d/%02d\r\n"
"Studio Pixel" "Studio Pixel"
@ -37,7 +37,7 @@ DLGPROC_RET CALLBACK VersionDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lP
case WM_INITDIALOG: case WM_INITDIALOG:
GetCompileDate(&year, &month, &day); GetCompileDate(&year, &month, &day);
GetCompileVersion(&version1, &version2, &version3, &version4); GetCompileVersion(&version1, &version2, &version3, &version4);
sprintf(string_buffer, version_string, version1, version2, version3, version4, year, month, day); sprintf(string_buffer, gVersionString, version1, version2, version3, version4, year, month, day);
SetDlgItemTextA(hWnd, 1011, string_buffer); SetDlgItemTextA(hWnd, 1011, string_buffer);
CenteringWindowByParent(hWnd); CenteringWindowByParent(hWnd);

View file

@ -2,6 +2,8 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
extern const char* const gVersionString;
DLGPROC_RET CALLBACK VersionDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); DLGPROC_RET CALLBACK VersionDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
DLGPROC_RET CALLBACK DebugMuteDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); DLGPROC_RET CALLBACK DebugMuteDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
DLGPROC_RET CALLBACK DebugSaveDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); DLGPROC_RET CALLBACK DebugSaveDialog(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

View file

@ -26,23 +26,23 @@ typedef enum SurfaceType
RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
int magnification; static int mag;
BOOL fullscreen; static BOOL fullscreen; // TODO - Not the original variable name
static LPDIRECTDRAW lpDD; static LPDIRECTDRAW lpDD; // TODO - Not the original variable name
static LPDIRECTDRAWSURFACE frontbuffer; static LPDIRECTDRAWSURFACE frontbuffer; // TODO - Not the original variable name
static LPDIRECTDRAWSURFACE backbuffer; static LPDIRECTDRAWSURFACE backbuffer; // TODO - Not the original variable name
static LPDIRECTDRAWCLIPPER clipper; static LPDIRECTDRAWCLIPPER clipper; // TODO - Not the original variable name
static LPDIRECTDRAWSURFACE surf[SURFACE_ID_MAX]; static LPDIRECTDRAWSURFACE surf[SURFACE_ID_MAX];
static RECT backbuffer_rect; static RECT backbuffer_rect; // TODO - Not the original variable name
static int scaled_window_width; static int scaled_window_width; // TODO - Not the original variable name
static int scaled_window_height; static int scaled_window_height; // TODO - Not the original variable name
static HFONT font; static HFONT font; // TODO - Not the original variable name
// This doesn't exist in the Linux port, so none of these symbol names are accurate // This doesn't exist in the Linux port, so none of these symbol names are accurate
static struct static struct
@ -121,32 +121,32 @@ BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth)
switch (lMagnification) switch (lMagnification)
{ {
case 0: case 0:
magnification = 1; mag = 1;
fullscreen = FALSE; fullscreen = FALSE;
lpDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL); lpDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL);
break; break;
case 1: case 1:
magnification = 2; mag = 2;
fullscreen = FALSE; fullscreen = FALSE;
lpDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL); lpDD->SetCooperativeLevel(hWnd, DDSCL_NORMAL);
break; break;
case 2: case 2:
magnification = 2; mag = 2;
fullscreen = TRUE; fullscreen = TRUE;
lpDD->SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE); lpDD->SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE);
lpDD->SetDisplayMode(WINDOW_WIDTH * magnification, WINDOW_HEIGHT * magnification, lColourDepth); lpDD->SetDisplayMode(WINDOW_WIDTH * mag, WINDOW_HEIGHT * mag, lColourDepth);
break; break;
} }
backbuffer_rect.left = 0; backbuffer_rect.left = 0;
backbuffer_rect.top = 0; backbuffer_rect.top = 0;
backbuffer_rect.right = WINDOW_WIDTH * magnification; backbuffer_rect.right = WINDOW_WIDTH * mag;
backbuffer_rect.bottom = WINDOW_HEIGHT * magnification; backbuffer_rect.bottom = WINDOW_HEIGHT * mag;
scaled_window_width = WINDOW_WIDTH * magnification; scaled_window_width = WINDOW_WIDTH * mag;
scaled_window_height = WINDOW_HEIGHT * magnification; scaled_window_height = WINDOW_HEIGHT * mag;
memset(&ddsd, 0, sizeof(DDSURFACEDESC)); memset(&ddsd, 0, sizeof(DDSURFACEDESC));
ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwSize = sizeof(DDSURFACEDESC);
@ -161,8 +161,8 @@ BOOL StartDirectDraw(HWND hWnd, int lMagnification, int lColourDepth)
ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = WINDOW_WIDTH * magnification; ddsd.dwWidth = WINDOW_WIDTH * mag;
ddsd.dwHeight = WINDOW_HEIGHT * magnification; ddsd.dwHeight = WINDOW_HEIGHT * mag;
if (lpDD->CreateSurface(&ddsd, &backbuffer, NULL) != DD_OK) if (lpDD->CreateSurface(&ddsd, &backbuffer, NULL) != DD_OK)
return FALSE; return FALSE;
@ -240,8 +240,8 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bitmap.bmWidth * magnification; ddsd.dwWidth = bitmap.bmWidth * mag;
ddsd.dwHeight = bitmap.bmHeight * magnification; ddsd.dwHeight = bitmap.bmHeight * mag;
if (lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL) != DD_OK) if (lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL) != DD_OK)
return FALSE; return FALSE;
@ -253,8 +253,8 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
int dst_x = 0; int dst_x = 0;
int dst_y = 0; int dst_y = 0;
int dst_w = bitmap.bmWidth * magnification; int dst_w = bitmap.bmWidth * mag;
int dst_h = bitmap.bmHeight * magnification; int dst_h = bitmap.bmHeight * mag;
HDC hdc = CreateCompatibleDC(NULL); HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ hgdiobj = SelectObject(hdc, handle); HGDIOBJ hgdiobj = SelectObject(hdc, handle);
@ -330,8 +330,8 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
ddsd.dwSize = sizeof(DDSURFACEDESC); ddsd.dwSize = sizeof(DDSURFACEDESC);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bitmap.bmWidth * magnification; ddsd.dwWidth = bitmap.bmWidth * mag;
ddsd.dwHeight = bitmap.bmHeight * magnification; ddsd.dwHeight = bitmap.bmHeight * mag;
lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL); lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL);
@ -342,8 +342,8 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
int dst_x = 0; int dst_x = 0;
int dst_y = 0; int dst_y = 0;
int dst_w = bitmap.bmWidth * magnification; int dst_w = bitmap.bmWidth * mag;
int dst_h = bitmap.bmHeight * magnification; int dst_h = bitmap.bmHeight * mag;
HDC hdc = CreateCompatibleDC(NULL); HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ hgdiobj = SelectObject(hdc, handle); HGDIOBJ hgdiobj = SelectObject(hdc, handle);
@ -394,8 +394,8 @@ BOOL ReloadBitmap_Resource(const char *name, SurfaceID surf_no)
int dst_x = 0; int dst_x = 0;
int dst_y = 0; int dst_y = 0;
int dst_w = bitmap.bmWidth * magnification; int dst_w = bitmap.bmWidth * mag;
int dst_h = bitmap.bmHeight * magnification; int dst_h = bitmap.bmHeight * mag;
HDC hdc = CreateCompatibleDC(NULL); HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ hgdiobj = SelectObject(hdc, handle); HGDIOBJ hgdiobj = SelectObject(hdc, handle);
@ -464,8 +464,8 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
int dst_x = 0; int dst_x = 0;
int dst_y = 0; int dst_y = 0;
int dst_w = bitmap.bmWidth * magnification; int dst_w = bitmap.bmWidth * mag;
int dst_h = bitmap.bmHeight * magnification; int dst_h = bitmap.bmHeight * mag;
HDC hdc = CreateCompatibleDC(NULL); HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ hgdiobj = SelectObject(hdc, handle); HGDIOBJ hgdiobj = SelectObject(hdc, handle);
@ -511,8 +511,8 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem
else else
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bxsize * magnification; ddsd.dwWidth = bxsize * mag;
ddsd.dwHeight = bysize * magnification; ddsd.dwHeight = bysize * mag;
lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL); lpDD->CreateSurface(&ddsd, &surf[surf_no], NULL);
@ -523,8 +523,8 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem
surf[surf_no]->SetColorKey(DDCKEY_SRCBLT, &ddcolorkey); surf[surf_no]->SetColorKey(DDCKEY_SRCBLT, &ddcolorkey);
surface_metadata[surf_no].type = SURFACE_SOURCE_NONE; surface_metadata[surf_no].type = SURFACE_SOURCE_NONE;
surface_metadata[surf_no].width = ddsd.dwWidth / magnification; surface_metadata[surf_no].width = ddsd.dwWidth / mag;
surface_metadata[surf_no].height = ddsd.dwHeight / magnification; surface_metadata[surf_no].height = ddsd.dwHeight / mag;
if (bSystem) if (bSystem)
surface_metadata[surf_no].bSystem = TRUE; surface_metadata[surf_no].bSystem = TRUE;
@ -544,10 +544,10 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect)
ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwSize = sizeof(DDBLTFX);
static RECT scaled_rect; // TODO - Not the original variable name static RECT scaled_rect; // TODO - Not the original variable name
scaled_rect.left = rect->left * magnification; scaled_rect.left = rect->left * mag;
scaled_rect.top = rect->top * magnification; scaled_rect.top = rect->top * mag;
scaled_rect.right = rect->right * magnification; scaled_rect.right = rect->right * mag;
scaled_rect.bottom = rect->bottom * magnification; scaled_rect.bottom = rect->bottom * mag;
surf[surf_no]->Blt(&scaled_rect, backbuffer, &scaled_rect, DDBLT_WAIT, &ddbltfx); surf[surf_no]->Blt(&scaled_rect, backbuffer, &scaled_rect, DDBLT_WAIT, &ddbltfx);
} }
@ -582,15 +582,15 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
rcSet.right = x + rcWork.right - rcWork.left; rcSet.right = x + rcWork.right - rcWork.left;
rcSet.bottom = y + rcWork.bottom - rcWork.top; rcSet.bottom = y + rcWork.bottom - rcWork.top;
rcWork.left *= magnification; rcWork.left *= mag;
rcWork.top *= magnification; rcWork.top *= mag;
rcWork.right *= magnification; rcWork.right *= mag;
rcWork.bottom *= magnification; rcWork.bottom *= mag;
rcSet.left *= magnification; rcSet.left *= mag;
rcSet.top *= magnification; rcSet.top *= mag;
rcSet.right *= magnification; rcSet.right *= mag;
rcSet.bottom *= magnification; rcSet.bottom *= mag;
backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL); backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
} }
@ -625,15 +625,15 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
rcSet.right = x + rcWork.right - rcWork.left; rcSet.right = x + rcWork.right - rcWork.left;
rcSet.bottom = y + rcWork.bottom - rcWork.top; rcSet.bottom = y + rcWork.bottom - rcWork.top;
rcWork.left *= magnification; rcWork.left *= mag;
rcWork.top *= magnification; rcWork.top *= mag;
rcWork.right *= magnification; rcWork.right *= mag;
rcWork.bottom *= magnification; rcWork.bottom *= mag;
rcSet.left *= magnification; rcSet.left *= mag;
rcSet.top *= magnification; rcSet.top *= mag;
rcSet.right *= magnification; rcSet.right *= mag;
rcSet.bottom *= magnification; rcSet.bottom *= mag;
backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_WAIT, NULL); backbuffer->Blt(&rcSet, surf[surf_no], &rcWork, DDBLT_WAIT, NULL);
} }
@ -643,20 +643,20 @@ void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
static RECT rcWork; static RECT rcWork;
static RECT rcSet; static RECT rcSet;
rcWork.left = rect->left * magnification; rcWork.left = rect->left * mag;
rcWork.top = rect->top * magnification; rcWork.top = rect->top * mag;
rcWork.right = rect->right * magnification; rcWork.right = rect->right * mag;
rcWork.bottom = rect->bottom * magnification; rcWork.bottom = rect->bottom * mag;
rcSet.left = x; rcSet.left = x;
rcSet.top = y; rcSet.top = y;
rcSet.right = x + rect->right - rect->left; rcSet.right = x + rect->right - rect->left;
rcSet.bottom = y + rect->bottom - rect->top; rcSet.bottom = y + rect->bottom - rect->top;
rcSet.left *= magnification; rcSet.left *= mag;
rcSet.top *= magnification; rcSet.top *= mag;
rcSet.right *= magnification; rcSet.right *= mag;
rcSet.bottom *= magnification; rcSet.bottom *= mag;
surf[to]->Blt(&rcSet, surf[from], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL); surf[to]->Blt(&rcSet, surf[from], &rcWork, DDBLT_KEYSRC | DDBLT_WAIT, NULL);
} }
@ -704,13 +704,13 @@ void CortBox(const RECT *rect, unsigned long col)
ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwFillColor = col; ddbltfx.dwFillColor = col;
static RECT dst_rect; // TODO - Not the original variable name static RECT rcSet; // TODO - Not the original variable name
dst_rect.left = rect->left * magnification; rcSet.left = rect->left * mag;
dst_rect.top = rect->top * magnification; rcSet.top = rect->top * mag;
dst_rect.right = rect->right * magnification; rcSet.right = rect->right * mag;
dst_rect.bottom = rect->bottom * magnification; rcSet.bottom = rect->bottom * mag;
backbuffer->Blt(&dst_rect, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); backbuffer->Blt(&rcSet, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
} }
void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no) void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
@ -720,15 +720,15 @@ void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
ddbltfx.dwSize = sizeof(DDBLTFX); ddbltfx.dwSize = sizeof(DDBLTFX);
ddbltfx.dwFillColor = col; ddbltfx.dwFillColor = col;
static RECT dst_rect; // TODO - Not the original variable name static RECT rcSet; // TODO - Not the original variable name
dst_rect.left = rect->left * magnification; rcSet.left = rect->left * mag;
dst_rect.top = rect->top * magnification; rcSet.top = rect->top * mag;
dst_rect.right = rect->right * magnification; rcSet.right = rect->right * mag;
dst_rect.bottom = rect->bottom * magnification; rcSet.bottom = rect->bottom * mag;
surface_metadata[surf_no].type = SURFACE_SOURCE_NONE; surface_metadata[surf_no].type = SURFACE_SOURCE_NONE;
surf[surf_no]->Blt(&dst_rect, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx); surf[surf_no]->Blt(&rcSet, 0, 0, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx);
} }
// Dummied-out log function // Dummied-out log function
@ -820,7 +820,7 @@ void InitTextObject(const char *name)
// Get font size // Get font size
unsigned int width, height; unsigned int width, height;
switch (magnification) switch (mag)
{ {
case 1: case 1:
height = 12; height = 12;
@ -864,7 +864,7 @@ void PutText(int x, int y, const char *text, unsigned long color)
HGDIOBJ hgdiobj = SelectObject(hdc, font); HGDIOBJ hgdiobj = SelectObject(hdc, font);
SetBkMode(hdc, 1); SetBkMode(hdc, 1);
SetTextColor(hdc, color); SetTextColor(hdc, color);
TextOutA(hdc, x * magnification, y * magnification, text, (int)strlen(text)); TextOutA(hdc, x * mag, y * mag, text, (int)strlen(text));
SelectObject(hdc, hgdiobj); SelectObject(hdc, hgdiobj);
backbuffer->ReleaseDC(hdc); backbuffer->ReleaseDC(hdc);
} }
@ -876,7 +876,7 @@ void PutText2(int x, int y, const char *text, unsigned long color, SurfaceID sur
HGDIOBJ hgdiobj = SelectObject(hdc, font); HGDIOBJ hgdiobj = SelectObject(hdc, font);
SetBkMode(hdc, 1); SetBkMode(hdc, 1);
SetTextColor(hdc, color); SetTextColor(hdc, color);
TextOutA(hdc, x * magnification, y * magnification, text, (int)strlen(text)); TextOutA(hdc, x * mag, y * mag, text, (int)strlen(text));
SelectObject(hdc, hgdiobj); SelectObject(hdc, hgdiobj);
surf[surf_no]->ReleaseDC(hdc); surf[surf_no]->ReleaseDC(hdc);
} }

View file

@ -5,9 +5,6 @@
extern RECT grcGame; extern RECT grcGame;
extern RECT grcFull; extern RECT grcFull;
extern int magnification;
extern BOOL fullscreen;
typedef enum SurfaceID typedef enum SurfaceID
{ {
SURFACE_ID_TITLE = 0, SURFACE_ID_TITLE = 0,

View file

@ -17,9 +17,40 @@
#include "Stage.h" #include "Stage.h"
#include "TextScr.h" #include "TextScr.h"
CREDIT Credit; struct CREDIT
STRIP Strip[MAX_STRIP]; {
ILLUSTRATION Illust; long size;
char *pData;
int offset;
int wait;
int mode;
int start_x;
};
struct STRIP
{
int flag;
int x;
int y;
int cast;
char str[0x40];
};
struct ILLUSTRATION
{
int act_no;
int x;
};
struct ISLAND_SPRITE
{
int x;
int y;
};
static CREDIT Credit;
static STRIP Strip[MAX_STRIP];
static ILLUSTRATION Illust;
// Update casts // Update casts
void ActionStripper(void) void ActionStripper(void)

View file

@ -4,37 +4,6 @@
#include "CommonDefines.h" #include "CommonDefines.h"
struct CREDIT
{
long size;
char *pData;
int offset;
int wait;
int mode;
int start_x;
};
struct STRIP
{
int flag;
int x;
int y;
int cast;
char str[0x40];
};
struct ILLUSTRATION
{
int act_no;
int x;
};
struct ISLAND_SPRITE
{
int x;
int y;
};
#define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1) #define MAX_STRIP ((WINDOW_HEIGHT / 16) + 1)
void ActionStripper(void); void ActionStripper(void);

View file

@ -2,25 +2,12 @@
#include <string.h> #include <string.h>
#include "CommonDefines.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "Draw.h" #include "Draw.h"
#define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1) FADE gFade;
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1)
struct FADE
{
int mode;
BOOL bMask;
int count;
signed char ani_no[FADE_HEIGHT][FADE_WIDTH];
signed char flag[FADE_HEIGHT][FADE_WIDTH]; // Not a BOOLEAN (those are unsigned)
signed char dir;
};
static FADE gFade;
static unsigned long mask_color; static unsigned long mask_color;
void InitFade(void) void InitFade(void)

View file

@ -1,7 +1,23 @@
#pragma once #pragma once
#include "CommonDefines.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1)
#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1)
struct FADE
{
int mode;
BOOL bMask;
int count;
signed char ani_no[FADE_HEIGHT][FADE_WIDTH];
signed char flag[FADE_HEIGHT][FADE_WIDTH]; // Not a BOOLEAN (those are unsigned)
signed char dir;
};
extern FADE gFade;
void InitFade(void); void InitFade(void);
void SetFadeMask(void); void SetFadeMask(void);
void ClearFade(void); void ClearFade(void);

View file

@ -17,7 +17,7 @@ static struct
RECT rect2; RECT rect2;
} flash; } flash;
static unsigned long gFlashColor; unsigned long gFlashColor;
void InitFlash(void) void InitFlash(void)
{ {

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
extern unsigned long gFlashColor;
void InitFlash(void); void InitFlash(void);
void SetFlash(int x, int y, int mode); void SetFlash(int x, int y, int mode);
void ActFlash_Explosion(int flx, int fly); void ActFlash_Explosion(int flx, int fly);

View file

@ -46,7 +46,7 @@
int g_GameFlags; int g_GameFlags;
int gCounter; int gCounter;
BOOL bContinue; static BOOL bContinue;
int Random(int min, int max) int Random(int min, int max)
{ {

View file

@ -415,7 +415,7 @@ BOOL SaveWindowRect(HWND hWnd, const char *filename)
return TRUE; return TRUE;
} }
const char *extra_text = "(C)Pixel"; static const char* const extra_text = "(C)Pixel";
BOOL IsEnableBitmap(const char *path) BOOL IsEnableBitmap(const char *path)
{ {

View file

@ -10,7 +10,7 @@
#include "PixTone.h" #include "PixTone.h"
#include "Sound.h" #include "Sound.h"
static const PIXTONEPARAMETER gPtpTable[139] = const PIXTONEPARAMETER gPtpTable[139] =
{ {
{1, 5000, {5, 10.0, 32, 0}, {4, 4.0, 32, 0}, {0, 0.0, 63, 0}, 63, 6, 63, 45, 8, 119, 46}, {1, 5000, {5, 10.0, 32, 0}, {4, 4.0, 32, 0}, {0, 0.0, 63, 0}, 63, 6, 63, 45, 8, 119, 46},
{1, 1000, {0, 4.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 63}, {1, 1000, {0, 4.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 63},

View file

@ -2,4 +2,8 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#include "PixTone.h"
extern const PIXTONEPARAMETER gPtpTable[139];
BOOL LoadGenericData(void); BOOL LoadGenericData(void);

View file

@ -43,12 +43,12 @@ static HINSTANCE ghInstance;
static int windowWidth; static int windowWidth;
static int windowHeight; static int windowHeight;
static const char *mutex_name = "Doukutsu"; static const char* const mutex_name = "Doukutsu";
#ifdef JAPANESE #ifdef JAPANESE
static const char *lpWindowName = "\x93\xB4\x8C\x41\x95\xA8\x8C\xEA"; // '洞窟物語' (Cave Story) in Shift-JIS static const char* const lpWindowName = "\x93\xB4\x8C\x41\x95\xA8\x8C\xEA"; // '洞窟物語' (Cave Story) in Shift-JIS
#else #else
static const char *lpWindowName = "Cave Story ~ Doukutsu Monogatari"; static const char* const lpWindowName = "Cave Story ~ Doukutsu Monogatari";
#endif #endif
// The original name for this function is unknown // The original name for this function is unknown

View file

@ -7,6 +7,9 @@ extern char gDataPath[MAX_PATH];
extern HWND ghWnd; extern HWND ghWnd;
extern BOOL bFullscreen; extern BOOL bFullscreen;
extern BOOL gbUseJoystick;
extern int gJoystickButtonTable[8];
void PutFramePerSecound(void); void PutFramePerSecound(void);
unsigned long CountFramePerSecound(void); unsigned long CountFramePerSecound(void);

View file

@ -6,15 +6,9 @@
#include "Draw.h" #include "Draw.h"
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
typedef struct MAP_NAME
{
BOOL flag;
int wait;
char name[0x20];
} MAP_NAME;
MAP_NAME gMapName; MAP_NAME gMapName;
RECT rc = { 0, 0, 160, 12 };
static RECT rc = { 0, 0, 160, 12 };
void ReadyMapName(const char *str) void ReadyMapName(const char *str)
{ {

View file

@ -2,6 +2,15 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
typedef struct MAP_NAME
{
BOOL flag;
int wait;
char name[0x20];
} MAP_NAME;
extern MAP_NAME gMapName;
void ReadyMapName(const char *str); void ReadyMapName(const char *str);
void PutMapName(BOOL bMini); void PutMapName(BOOL bMini);
void StartMapName(void); void StartMapName(void);

View file

@ -986,8 +986,8 @@ void ResetCheck(void)
gMC.cond &= ~1; gMC.cond &= ~1;
} }
int noise_no; static int noise_no;
unsigned int noise_freq; static unsigned int noise_freq;
void SetNoise(int no, int freq) void SetNoise(int no, int freq)
{ {

View file

@ -387,7 +387,7 @@ void PutMyAir(int x, int y)
} }
} }
int time_count; static int time_count;
void PutTimeCounter(int x, int y) void PutTimeCounter(int x, int y)
{ {

View file

@ -24,7 +24,7 @@ int gCurlyShoot_y;
int gSuperXpos; int gSuperXpos;
int gSuperYpos; int gSuperYpos;
const char *gPassPixEve = "PXE"; const char* const gPassPixEve = "PXE";
static void SetUniqueParameter(NPCHAR *npc) static void SetUniqueParameter(NPCHAR *npc)
{ {

View file

@ -119,6 +119,8 @@ extern int gCurlyShoot_y;
extern int gSuperXpos; extern int gSuperXpos;
extern int gSuperYpos; extern int gSuperYpos;
extern const char* const gPassPixEve;
void InitNpChar(void); void InitNpChar(void);
BOOL LoadEvent(const char *path_event); BOOL LoadEvent(const char *path_event);
void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index); void SetNpChar(int code_char, int x, int y, int xm, int ym, int dir, NPCHAR *npc, int start_index);

View file

@ -26,5 +26,7 @@ typedef struct PIXTONEPARAMETER
int pointCy; int pointCy;
} PIXTONEPARAMETER; } PIXTONEPARAMETER;
extern signed char gWaveModelTable[6][0x100];
void MakeWaveTables(void); void MakeWaveTables(void);
BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData); BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData);

View file

@ -21,8 +21,8 @@
#include "Star.h" #include "Star.h"
#include "ValueView.h" #include "ValueView.h"
const char *gDefaultName = "Profile.dat"; const char* const gDefaultName = "Profile.dat";
const char *gProfileCode = "Do041220"; const char* const gProfileCode = "Do041220";
BOOL IsProfile(void) BOOL IsProfile(void)
{ {

View file

@ -31,6 +31,9 @@ typedef struct PROFILE
unsigned char flags[1000]; unsigned char flags[1000];
} PROFILE; } PROFILE;
extern const char* const gDefaultName;
extern const char* const gProfileCode;
BOOL IsProfile(void); BOOL IsProfile(void);
BOOL SaveProfile(const char *name); BOOL SaveProfile(const char *name);
BOOL LoadProfile(const char *name); BOOL LoadProfile(const char *name);

View file

@ -10,6 +10,9 @@ typedef struct PERMIT_STAGE
extern PERMIT_STAGE gPermitStage[8]; extern PERMIT_STAGE gPermitStage[8];
extern int gSelectedStage;
extern int gStageSelectTitleY;
void ClearPermitStage(void); void ClearPermitStage(void);
BOOL AddPermitStage(int index, int event); BOOL AddPermitStage(int index, int event);
BOOL SubPermitStage(int index); BOOL SubPermitStage(int index);

View file

@ -10,7 +10,7 @@
#include "MycParam.h" #include "MycParam.h"
#include "Sound.h" #include "Sound.h"
int empty; static int empty;
void ShootBullet_Frontia1(int level) void ShootBullet_Frontia1(int level)
{ {

View file

@ -206,7 +206,7 @@ BOOL TransferStage(int no, int w, int x, int y)
} }
// Music // Music
const char *gMusicTable[42] = { const char* const gMusicTable[42] = {
"XXXX", "XXXX",
"WANPAKU", "WANPAKU",
"ANZEN", "ANZEN",

View file

@ -62,6 +62,12 @@ typedef struct STAGE_TABLE
extern int gStageNo; extern int gStageNo;
extern MusicID gMusicNo; extern MusicID gMusicNo;
extern unsigned int gOldPos;
extern MusicID gOldNo;
extern const STAGE_TABLE gTMT[95];
extern const char* const gMusicTable[42];
BOOL TransferStage(int no, int w, int x, int y); BOOL TransferStage(int no, int w, int x, int y);
void ChangeMusic(MusicID no); void ChangeMusic(MusicID no);

View file

@ -42,9 +42,9 @@
TEXT_SCRIPT gTS; TEXT_SCRIPT gTS;
char text[4][0x40]; static char text[4][0x40];
RECT gRect_line = {0, 0, 216, 16}; const RECT gRect_line = {0, 0, 216, 16};
#ifdef FIX_BUGS #ifdef FIX_BUGS
static unsigned long nod_color; static unsigned long nod_color;

View file

@ -53,6 +53,10 @@ typedef struct TEXT_SCRIPT
unsigned char wait_beam; unsigned char wait_beam;
} TEXT_SCRIPT; } TEXT_SCRIPT;
extern TEXT_SCRIPT gTS;
extern const RECT gRect_line;
BOOL InitTextScript2(void); BOOL InitTextScript2(void);
void EndTextScript(void); void EndTextScript(void);
void EncryptionBinaryData2(unsigned char *pData, long size); void EncryptionBinaryData2(unsigned char *pData, long size);

View file

@ -1,5 +1,8 @@
#pragma once #pragma once
extern int gSin[0x100];
extern short gTan[0x21];
void InitTriangleTable(void); void InitTriangleTable(void);
int GetSin(unsigned char deg); int GetSin(unsigned char deg);
int GetCos(unsigned char deg); int GetCos(unsigned char deg);

View file

@ -6,8 +6,6 @@
#include "Draw.h" #include "Draw.h"
#define VALUEVIEW_MAX 0x10
VALUEVIEW gVV[VALUEVIEW_MAX]; VALUEVIEW gVV[VALUEVIEW_MAX];
int gVVIndex; int gVVIndex;

View file

@ -2,6 +2,8 @@
#include "WindowsWrapper.h" #include "WindowsWrapper.h"
#define VALUEVIEW_MAX 0x10
typedef struct VALUEVIEW typedef struct VALUEVIEW
{ {
BOOL flag; BOOL flag;
@ -13,6 +15,9 @@ typedef struct VALUEVIEW
RECT rect; RECT rect;
} VALUEVIEW; } VALUEVIEW;
extern VALUEVIEW gVV[VALUEVIEW_MAX];
extern int gVVIndex;
void ClearValueView(void); void ClearValueView(void);
void SetValueView(int *px, int *py, int value); void SetValueView(int *px, int *py, int value);
void ActValueView(void); void ActValueView(void);