diff --git a/src/ArmsItem.cpp b/src/ArmsItem.cpp index 02c3af01..9c39d1f9 100644 --- a/src/ArmsItem.cpp +++ b/src/ArmsItem.cpp @@ -20,10 +20,10 @@ ITEM gItemData[ITEM_MAX]; int gSelectedArms; 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) -static BOOL gCampActive; +BOOL gCampActive; int gArmsEnergyX = 16; diff --git a/src/ArmsItem.h b/src/ArmsItem.h index c98bb2ae..9656a681 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -2,6 +2,10 @@ #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 // "Code" means "ID" here // "Num" often means "ammo" here @@ -32,20 +36,6 @@ typedef struct 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 extern ARMS gArmsData[ARMS_MAX]; @@ -53,6 +43,21 @@ extern ARMS gArmsData[ARMS_MAX]; /// Contains data for all the items the character currently has 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) void ClearArmsData(void); diff --git a/src/Boss.h b/src/Boss.h index ab3e6807..18d3ed90 100644 --- a/src/Boss.h +++ b/src/Boss.h @@ -3,6 +3,7 @@ #include "NpChar.h" #define BOSS_MAX 20 + extern NPCHAR gBoss[BOSS_MAX]; typedef void (*BOSSFUNCTION)(void); diff --git a/src/BossAlmo1.cpp b/src/BossAlmo1.cpp index 0204779a..4e3113a4 100644 --- a/src/BossAlmo1.cpp +++ b/src/BossAlmo1.cpp @@ -13,7 +13,7 @@ #include "Sound.h" #include "Triangle.h" -static void ActBossChar_Core_Face(NPCHAR *npc) +void ActBossChar_Core_Face(NPCHAR *npc) { RECT rect[4] = { {0, 0, 72, 112}, @@ -64,7 +64,7 @@ static void ActBossChar_Core_Face(NPCHAR *npc) npc->rect.bottom = npc->rect.top + npc->act_wait; } -static void ActBossChar_Core_Tail(NPCHAR *npc) +void ActBossChar_Core_Tail(NPCHAR *npc) { RECT rect[3] = { {72, 0, 160, 112}, @@ -114,7 +114,7 @@ static void ActBossChar_Core_Tail(NPCHAR *npc) npc->rect.bottom = npc->rect.top + npc->act_wait; } -static void ActBossChar_Core_Mini(NPCHAR *npc) +void ActBossChar_Core_Mini(NPCHAR *npc) { RECT rect[3] = { {256, 0, 320, 40}, @@ -228,7 +228,7 @@ static void ActBossChar_Core_Mini(NPCHAR *npc) npc->rect = rect[npc->ani_no]; } -static void ActBossChar_Core_Hit(NPCHAR *npc) +void ActBossChar_Core_Hit(NPCHAR *npc) { switch (npc->count1) { diff --git a/src/BossLife.cpp b/src/BossLife.cpp index 8546ffae..358ebade 100644 --- a/src/BossLife.cpp +++ b/src/BossLife.cpp @@ -7,14 +7,7 @@ #include "Draw.h" #include "NpChar.h" -static struct -{ - BOOL flag; - int *pLife; - int max; - int br; - int count; -} gBL; +BOSSLIFE gBL; void InitBossLife(void) { diff --git a/src/BossLife.h b/src/BossLife.h index 1d5ffc63..3276db84 100644 --- a/src/BossLife.h +++ b/src/BossLife.h @@ -2,6 +2,17 @@ #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); BOOL StartBossLife(int code_event); BOOL StartBossLife2(void); diff --git a/src/BulHit.cpp b/src/BulHit.cpp index b6bb9f56..065d8659 100644 --- a/src/BulHit.cpp +++ b/src/BulHit.cpp @@ -7,7 +7,7 @@ #include "NpChar.h" #include "Sound.h" -void Vanish(BULLET *bul) +static void Vanish(BULLET *bul) { if (bul->code_bullet != 37 && bul->code_bullet != 38 && bul->code_bullet != 39) PlaySoundObject(28, 1); diff --git a/src/Bullet.h b/src/Bullet.h index 5604d8f3..7db8afc8 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -2,6 +2,8 @@ #include "WindowsWrapper.h" +#define BULLET_MAX 0x40 + typedef struct BULLET { int flag; @@ -57,7 +59,6 @@ typedef struct BULLET_TABLE } view; } BULLET_TABLE; -#define BULLET_MAX 0x40 extern BULLET gBul[BULLET_MAX]; void InitBullet(void); diff --git a/src/Caret.cpp b/src/Caret.cpp index e436942d..5e4293f0 100644 --- a/src/Caret.cpp +++ b/src/Caret.cpp @@ -8,7 +8,6 @@ #include "Game.h" #include "Triangle.h" -#define CARET_MAX 0x40 CARET gCrt[CARET_MAX]; CARET_TABLE gCaretTable[18] = { @@ -520,7 +519,7 @@ void ActCaret17(CARET *crt) } typedef void (*CARETFUNCTION)(CARET*); -CARETFUNCTION gpCaretFuncTbl[] = +CARETFUNCTION gpCaretFuncTbl[18] = { ActCaret00, ActCaret01, diff --git a/src/Caret.h b/src/Caret.h index ab249e84..9aeca983 100644 --- a/src/Caret.h +++ b/src/Caret.h @@ -2,6 +2,8 @@ #include "WindowsWrapper.h" +#define CARET_MAX 0x40 + struct CARET_TABLE { int view_left; @@ -26,6 +28,9 @@ struct CARET RECT rect; }; +extern CARET gCrt[CARET_MAX]; +extern CARET_TABLE gCaretTable[18]; + void InitCaret(void); void ActCaret(void); void PutCaret(int fx, int fy); diff --git a/src/Config.cpp b/src/Config.cpp index 7b911516..e2afcb95 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -8,8 +8,8 @@ #include "File.h" #include "Main.h" -static const char* const gConfigName = "Config.dat"; -static const char* const gProof = "DOUKUTSU20041206"; +const char* const gConfigName = "Config.dat"; +const char* const gProof = "DOUKUTSU20041206"; BOOL LoadConfigData(CONFIG *conf) { diff --git a/src/Config.h b/src/Config.h index 9a01480a..a62d3559 100644 --- a/src/Config.h +++ b/src/Config.h @@ -14,5 +14,8 @@ struct CONFIG long joystick_button[8]; }; +extern const char* const gConfigName; +extern const char* const gProof; + BOOL LoadConfigData(CONFIG *conf); void DefaultConfigData(CONFIG *conf); diff --git a/src/Draw.cpp b/src/Draw.cpp index 149b220b..73daa462 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -29,14 +29,14 @@ typedef enum SurfaceType RECT grcGame = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; RECT grcFull = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT}; -int magnification; -BOOL fullscreen; +static int mag; +static BOOL fullscreen; // TODO - Not the original variable name -static RenderBackend_Surface *framebuffer; +static RenderBackend_Surface *framebuffer; // TODO - Not the original variable name static RenderBackend_Surface *surf[SURFACE_ID_MAX]; -static FontObject *font; +static FontObject *font; // TODO - Not the original variable name // This doesn't exist in the Linux port, so none of these symbol names are accurate static struct @@ -92,17 +92,17 @@ BOOL StartDirectDraw(const char *title, int width, int height, int lMagnificatio switch (lMagnification) { case 0: - magnification = 1; + mag = 1; fullscreen = FALSE; break; case 1: - magnification = 2; + mag = 2; fullscreen = FALSE; break; case 2: - magnification = 2; + mag = 2; fullscreen = TRUE; break; } @@ -152,12 +152,12 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width, { // IF YOU WANT TO ADD HD SPRITES, THIS IS THE CODE YOU SHOULD EDIT unsigned int pitch; - unsigned char *pixels = RenderBackend_LockSurface(surf[surf_no], &pitch, width * magnification, height * magnification); + unsigned char *pixels = RenderBackend_LockSurface(surf[surf_no], &pitch, width * mag, height * mag); if (pixels == NULL) return FALSE; - if (magnification == 1) + if (mag == 1) { // Just copy the pixels the way they are for (int y = 0; y < height; ++y) @@ -174,14 +174,14 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width, for (int y = 0; y < height; ++y) { const unsigned char *src_row = &image_buffer[y * width * 3]; - unsigned char *dst_row = &pixels[y * pitch * magnification]; + unsigned char *dst_row = &pixels[y * pitch * mag]; const unsigned char *src_ptr = src_row; unsigned char *dst_ptr = dst_row; for (int x = 0; x < width; ++x) { - for (int i = 0; i < magnification; ++i) + for (int i = 0; i < mag; ++i) { *dst_ptr++ = src_ptr[0]; *dst_ptr++ = src_ptr[1]; @@ -191,12 +191,12 @@ static BOOL ScaleAndUploadSurface(const unsigned char *image_buffer, int width, src_ptr += 3; } - for (int i = 1; i < magnification; ++i) - memcpy(dst_row + i * pitch, dst_row, width * magnification * 3); + for (int i = 1; i < mag; ++i) + memcpy(dst_row + i * pitch, dst_row, width * mag * 3); } } - RenderBackend_UnlockSurface(surf[surf_no], width * magnification, height * magnification); + RenderBackend_UnlockSurface(surf[surf_no], width * mag, height * mag); return TRUE; } @@ -222,7 +222,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no) if (image_buffer == NULL) return FALSE; - surf[surf_no] = RenderBackend_CreateSurface(width * magnification, height * magnification, false); + surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, false); if (surf[surf_no] == NULL) { @@ -284,7 +284,7 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no) return FALSE; } - surf[surf_no] = RenderBackend_CreateSurface(width * magnification, height * magnification, false); + surf[surf_no] = RenderBackend_CreateSurface(width * mag, height * mag, false); if (surf[surf_no] == NULL) { @@ -395,7 +395,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem if (surf[surf_no] != NULL) return FALSE; - surf[surf_no] = RenderBackend_CreateSurface(bxsize * magnification, bysize * magnification, true); + surf[surf_no] = RenderBackend_CreateSurface(bxsize * mag, bysize * mag, true); if (surf[surf_no] == NULL) return FALSE; @@ -417,10 +417,10 @@ 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; // TODO - Not the original variable name - scaled_rect.left = rect->left * magnification; - scaled_rect.top = rect->top * magnification; - scaled_rect.right = rect->right * magnification; - scaled_rect.bottom = rect->bottom * magnification; + scaled_rect.left = rect->left * mag; + scaled_rect.top = rect->top * mag; + scaled_rect.right = rect->right * mag; + scaled_rect.bottom = rect->bottom * mag; // Do not draw invalid RECTs if (scaled_rect.right <= scaled_rect.left || scaled_rect.bottom <= scaled_rect.top) @@ -456,16 +456,16 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su y = rcView->top; } - rcWork.left *= magnification; - rcWork.top *= magnification; - rcWork.right *= magnification; - rcWork.bottom *= magnification; + rcWork.left *= mag; + rcWork.top *= mag; + rcWork.right *= mag; + rcWork.bottom *= mag; // Do not draw invalid RECTs if (rcWork.right <= rcWork.left || rcWork.bottom <= rcWork.top) return; - RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, TRUE); + RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * mag, y * mag, TRUE); } void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency @@ -495,32 +495,32 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su y = rcView->top; } - rcWork.left *= magnification; - rcWork.top *= magnification; - rcWork.right *= magnification; - rcWork.bottom *= magnification; + rcWork.left *= mag; + rcWork.top *= mag; + rcWork.right *= mag; + rcWork.bottom *= mag; // Do not draw invalid RECTs if (rcWork.right <= rcWork.left || rcWork.bottom <= rcWork.top) return; - RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * magnification, y * magnification, FALSE); + RenderBackend_Blit(surf[surf_no], &rcWork, framebuffer, x * mag, y * mag, FALSE); } void Surface2Surface(int x, int y, const RECT *rect, int to, int from) { static RenderBackend_Rect rcWork; - rcWork.left = rect->left * magnification; - rcWork.top = rect->top * magnification; - rcWork.right = rect->right * magnification; - rcWork.bottom = rect->bottom * magnification; + rcWork.left = rect->left * mag; + rcWork.top = rect->top * mag; + rcWork.right = rect->right * mag; + rcWork.bottom = rect->bottom * mag; // Do not draw invalid RECTs if (rcWork.right <= rcWork.left || rcWork.bottom <= rcWork.top) return; - RenderBackend_Blit(surf[from], &rcWork, surf[to], x * magnification, y * magnification, TRUE); + RenderBackend_Blit(surf[from], &rcWork, surf[to], x * mag, y * mag, TRUE); } unsigned long GetCortBoxColor(unsigned long col) @@ -531,30 +531,30 @@ unsigned long GetCortBoxColor(unsigned long col) void CortBox(const RECT *rect, unsigned long col) { - 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; - dst_rect.bottom = rect->bottom * magnification; + static RenderBackend_Rect rcSet; // TODO - Not the original variable name + rcSet.left = rect->left * mag; + rcSet.top = rect->top * mag; + rcSet.right = rect->right * mag; + rcSet.bottom = rect->bottom * mag; const unsigned char red = col & 0xFF; const unsigned char green = (col >> 8) & 0xFF; const unsigned char blue = (col >> 16) & 0xFF; // Do not draw invalid RECTs - if (dst_rect.right <= dst_rect.left || dst_rect.bottom <= dst_rect.top) + if (rcSet.right <= rcSet.left || rcSet.bottom <= rcSet.top) return; - RenderBackend_ColourFill(framebuffer, &dst_rect, red, green, blue); + RenderBackend_ColourFill(framebuffer, &rcSet, red, green, blue); } void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no) { - 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; - dst_rect.bottom = rect->bottom * magnification; + static RenderBackend_Rect rcSet; // TODO - Not the original variable name + rcSet.left = rect->left * mag; + rcSet.top = rect->top * mag; + rcSet.right = rect->right * mag; + rcSet.bottom = rect->bottom * mag; surface_metadata[surf_no].type = SURFACE_SOURCE_NONE; @@ -563,10 +563,10 @@ void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no) const unsigned char blue = (col >> 16) & 0xFF; // Do not draw invalid RECTs - if (dst_rect.right <= dst_rect.left || dst_rect.bottom <= dst_rect.top) + if (rcSet.right <= rcSet.left || rcSet.bottom <= rcSet.top) return; - RenderBackend_ColourFill(surf[surf_no], &dst_rect, red, green, blue); + RenderBackend_ColourFill(surf[surf_no], &rcSet, red, green, blue); } // Dummied-out log function @@ -653,7 +653,7 @@ void InitTextObject(const char *name) // Get font size unsigned int width, height; - switch (magnification) + switch (mag) { case 1: height = 10; @@ -671,12 +671,12 @@ void InitTextObject(const char *name) void PutText(int x, int y, const char *text, unsigned long color) { - DrawText(font, framebuffer, x * magnification, y * magnification, color, text); + DrawText(font, framebuffer, x * mag, y * mag, color, text); } void PutText2(int x, int y, const char *text, unsigned long color, SurfaceID surf_no) { - DrawText(font, surf[surf_no], x * magnification, y * magnification, color, text); + DrawText(font, surf[surf_no], x * mag, y * mag, color, text); } void EndTextObject(void) diff --git a/src/Draw.h b/src/Draw.h index 592b17f3..c9aa3246 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -5,9 +5,6 @@ extern RECT grcGame; extern RECT grcFull; -extern int magnification; -extern BOOL fullscreen; - typedef enum SurfaceID { SURFACE_ID_TITLE = 0, diff --git a/src/Ending.cpp b/src/Ending.cpp index 65983135..1a4532ff 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -17,9 +17,40 @@ #include "Stage.h" #include "TextScr.h" -CREDIT Credit; -STRIP Strip[MAX_STRIP]; -ILLUSTRATION Illust; +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; +}; + +static CREDIT Credit; +static STRIP Strip[MAX_STRIP]; +static ILLUSTRATION Illust; // Update casts void ActionStripper(void) @@ -247,28 +278,17 @@ BOOL StartCreditScript(void) return TRUE; } -// Update credits -void ActionCredit(void) +// Get number from text (4 digit) +static int GetScriptNumber(const char *text) { - if (Credit.offset >= Credit.size) - return; - - // Update script, or if waiting, decrement the wait value - switch (Credit.mode) - { - case 1: - ActionCredit_Read(); - break; - - case 2: - if (--Credit.wait <= 0) - Credit.mode = 1; - break; - } + return (text[0] - '0') * 1000 + + (text[1] - '0') * 100 + + (text[2] - '0') * 10 + + text[3] - '0'; } // Parse credits -void ActionCredit_Read(void) +static void ActionCredit_Read(void) { int a, b, len; char text[40]; @@ -417,15 +437,25 @@ void ActionCredit_Read(void) } } -// Get number from text (4 digit) -int GetScriptNumber(const char *text) +// Update credits +void ActionCredit(void) { - return (text[0] - '0') * 1000 + - (text[1] - '0') * 100 + - (text[2] - '0') * 10 + - text[3] - '0'; -} + if (Credit.offset >= Credit.size) + return; + // Update script, or if waiting, decrement the wait value + switch (Credit.mode) + { + case 1: + ActionCredit_Read(); + break; + + case 2: + if (--Credit.wait <= 0) + Credit.mode = 1; + break; + } +} // Change illustration void SetCreditIllust(int a) diff --git a/src/Ending.h b/src/Ending.h index b143a05c..d9ece086 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -4,37 +4,6 @@ #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) void ActionStripper(void); @@ -48,8 +17,6 @@ void InitCreditScript(void); void ReleaseCreditScript(void); BOOL StartCreditScript(void); void ActionCredit(void); -void ActionCredit_Read(void); -int GetScriptNumber(const char *text); void SetCreditIllust(int a); void CutCreditIllust(void); int Scene_DownIsland(int mode); diff --git a/src/Fade.cpp b/src/Fade.cpp index cc8c48ba..df629e12 100644 --- a/src/Fade.cpp +++ b/src/Fade.cpp @@ -2,25 +2,12 @@ #include -#include "CommonDefines.h" #include "WindowsWrapper.h" #include "Draw.h" -#define FADE_WIDTH (((WINDOW_WIDTH - 1) / 16) + 1) -#define FADE_HEIGHT (((WINDOW_HEIGHT - 1) / 16) + 1) +FADE gFade; -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; void InitFade(void) diff --git a/src/Fade.h b/src/Fade.h index b1f17366..e39fb639 100644 --- a/src/Fade.h +++ b/src/Fade.h @@ -1,7 +1,23 @@ #pragma once +#include "CommonDefines.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 SetFadeMask(void); void ClearFade(void); diff --git a/src/Flash.cpp b/src/Flash.cpp index 3a606175..6fa82709 100644 --- a/src/Flash.cpp +++ b/src/Flash.cpp @@ -17,7 +17,7 @@ static struct RECT rect2; } flash; -static unsigned long gFlashColor; +unsigned long gFlashColor; void InitFlash(void) { diff --git a/src/Flash.h b/src/Flash.h index bbd99eaf..c31aa598 100644 --- a/src/Flash.h +++ b/src/Flash.h @@ -1,5 +1,7 @@ #pragma once +extern unsigned long gFlashColor; + void InitFlash(void); void SetFlash(int x, int y, int mode); void ActFlash_Explosion(int flx, int fly); diff --git a/src/Game.cpp b/src/Game.cpp index e2c9c6a1..51c51093 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -48,7 +48,7 @@ int g_GameFlags; int gCounter; -BOOL bContinue; +static BOOL bContinue; int Random(int min, int max) { @@ -109,7 +109,7 @@ void PutNumber4(int x, int y, int value, BOOL bZero) } } -int ModeOpening(void) +static int ModeOpening(void) { int frame_x; int frame_y; @@ -225,7 +225,7 @@ int ModeOpening(void) return 2; } -int ModeTitle(void) +static int ModeTitle(void) { // Set rects RECT rcTitle = {0, 0, 144, 40}; @@ -472,7 +472,7 @@ int ModeTitle(void) return 3; } -int ModeAction(void) +static int ModeAction(void) { int frame_x; int frame_y; diff --git a/src/Generic.cpp b/src/Generic.cpp index c12bdc47..5ef2a272 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -133,7 +133,7 @@ BOOL IsShiftJIS(unsigned char c) return FALSE; } -const char *extra_text = "(C)Pixel"; +static const char* const extra_text = "(C)Pixel"; BOOL IsEnableBitmap(const char *path) { diff --git a/src/GenericLoad.cpp b/src/GenericLoad.cpp index 9f0ba539..9f177091 100644 --- a/src/GenericLoad.cpp +++ b/src/GenericLoad.cpp @@ -10,7 +10,7 @@ #include "PixTone.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, 1000, {0, 4.0, 32, 0}, {3, 1.0, 63, 0}, {0, 0.0, 63, 0}, 63, 64, 63, 128, 63, 255, 63}, diff --git a/src/GenericLoad.h b/src/GenericLoad.h index 513b430e..187ad1b9 100644 --- a/src/GenericLoad.h +++ b/src/GenericLoad.h @@ -2,4 +2,8 @@ #include "WindowsWrapper.h" +#include "PixTone.h" + +extern const PIXTONEPARAMETER gPtpTable[139]; + BOOL LoadGenericData(void); diff --git a/src/Main.cpp b/src/Main.cpp index 5c8dd1a5..5925eab8 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -40,22 +40,12 @@ static int windowWidth; static int windowHeight; #ifdef JAPANESE -static const char *lpWindowName = "洞窟物語"; // "Cave Story" +static const char* const lpWindowName = "洞窟物語"; // "Cave Story" #else -static const char *lpWindowName = "Cave Story ~ Doukutsu Monogatari"; +static const char* const lpWindowName = "Cave Story ~ Doukutsu Monogatari"; #endif -// Framerate stuff -void PutFramePerSecound(void) -{ - if (bFPS) - { - const unsigned long fps = CountFramePerSecound(); - PutNumber4(WINDOW_WIDTH - 40, 8, fps, FALSE); - } -} - -unsigned long CountFramePerSecound(void) +static unsigned long CountFramePerSecound(void) { unsigned long current_tick; // The original name for this variable is unknown static BOOL first = TRUE; @@ -82,6 +72,16 @@ unsigned long CountFramePerSecound(void) return max_count; } +// Framerate stuff +void PutFramePerSecound(void) +{ + if (bFPS) + { + const unsigned long fps = CountFramePerSecound(); + PutNumber4(WINDOW_WIDTH - 40, 8, fps, FALSE); + } +} + // TODO - Inaccurate stack frame int main(int argc, char *argv[]) { diff --git a/src/Main.h b/src/Main.h index 5c136797..62d618bd 100644 --- a/src/Main.h +++ b/src/Main.h @@ -6,11 +6,13 @@ extern char gModulePath[MAX_PATH]; extern char gDataPath[MAX_PATH]; extern BOOL bFullscreen; +extern BOOL gbUseJoystick; + +extern int gJoystickButtonTable[8]; extern BOOL gbUseJoystick; void PutFramePerSecound(void); -unsigned long CountFramePerSecound(void); void InactiveWindow(void); void ActiveWindow(void); diff --git a/src/MapName.cpp b/src/MapName.cpp index f464d40b..12dd378b 100644 --- a/src/MapName.cpp +++ b/src/MapName.cpp @@ -6,15 +6,9 @@ #include "Draw.h" #include "WindowsWrapper.h" -typedef struct MAP_NAME -{ - BOOL flag; - int wait; - char name[0x20]; -} MAP_NAME; - MAP_NAME gMapName; -RECT rc = { 0, 0, 160, 12 }; + +static RECT rc = { 0, 0, 160, 12 }; void ReadyMapName(const char *str) { diff --git a/src/MapName.h b/src/MapName.h index c48312a8..d5e69b52 100644 --- a/src/MapName.h +++ b/src/MapName.h @@ -2,6 +2,15 @@ #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 PutMapName(BOOL bMini); void StartMapName(void); diff --git a/src/MiniMap.cpp b/src/MiniMap.cpp index af3b1c03..2de159f9 100644 --- a/src/MiniMap.cpp +++ b/src/MiniMap.cpp @@ -210,7 +210,7 @@ int MiniMapLoop(void) return enum_ESCRETURN_continue; } -char gMapping[0x80]; +signed char gMapping[0x80]; BOOL IsMapping(void) { diff --git a/src/MiniMap.h b/src/MiniMap.h index add3aee5..38639877 100644 --- a/src/MiniMap.h +++ b/src/MiniMap.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -extern char gMapping[0x80]; +extern signed char gMapping[0x80]; int MiniMapLoop(void); BOOL IsMapping(void); diff --git a/src/MyChar.cpp b/src/MyChar.cpp index 57b5dc20..22e6a708 100644 --- a/src/MyChar.cpp +++ b/src/MyChar.cpp @@ -986,8 +986,8 @@ void ResetCheck(void) gMC.cond &= ~1; } -int noise_no; -unsigned int noise_freq; +static int noise_no; +static unsigned int noise_freq; void SetNoise(int no, int freq) { diff --git a/src/MycHit.cpp b/src/MycHit.cpp index 77cfe04d..9246d9bf 100644 --- a/src/MycHit.cpp +++ b/src/MycHit.cpp @@ -19,7 +19,7 @@ void ResetMyCharFlag(void) gMC.flag = 0; } -void PutlittleStar(void) +static void PutlittleStar(void) { if (!(gMC.cond & 2) && gMC.ym < -0x200) { diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 76ea7283..430d2b68 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -390,7 +390,7 @@ void PutMyAir(int x, int y) } } -int time_count; +static int time_count; void PutTimeCounter(int x, int y) { diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 3254a494..d5d7b261 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -25,7 +25,7 @@ int gCurlyShoot_y; int gSuperXpos; int gSuperYpos; -const char *gPassPixEve = "PXE"; +const char* const gPassPixEve = "PXE"; static void SetUniqueParameter(NPCHAR *npc) { diff --git a/src/NpChar.h b/src/NpChar.h index 1a470c2f..0f2f9583 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -119,6 +119,8 @@ extern int gCurlyShoot_y; extern int gSuperXpos; extern int gSuperYpos; +extern const char* const gPassPixEve; + void InitNpChar(void); 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); diff --git a/src/PixTone.h b/src/PixTone.h index 45589105..289d47ff 100644 --- a/src/PixTone.h +++ b/src/PixTone.h @@ -26,5 +26,7 @@ typedef struct PIXTONEPARAMETER int pointCy; } PIXTONEPARAMETER; +extern signed char gWaveModelTable[6][0x100]; + void MakeWaveTables(void); BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData); diff --git a/src/Profile.cpp b/src/Profile.cpp index b9048bee..7d0c9cfa 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -23,8 +23,8 @@ #include "Star.h" #include "ValueView.h" -const char *gDefaultName = "Profile.dat"; -const char *gProfileCode = "Do041220"; +const char* const gDefaultName = "Profile.dat"; +const char* const gProfileCode = "Do041220"; BOOL IsProfile(void) { diff --git a/src/Profile.h b/src/Profile.h index 9e99ebff..c46607e8 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -31,6 +31,9 @@ typedef struct PROFILE unsigned char flags[1000]; } PROFILE; +extern const char* const gDefaultName; +extern const char* const gProfileCode; + BOOL IsProfile(void); BOOL SaveProfile(const char *name); BOOL LoadProfile(const char *name); diff --git a/src/SelStage.h b/src/SelStage.h index 7f1a49d4..f06dc427 100644 --- a/src/SelStage.h +++ b/src/SelStage.h @@ -10,6 +10,9 @@ typedef struct PERMIT_STAGE extern PERMIT_STAGE gPermitStage[8]; +extern int gSelectedStage; +extern int gStageSelectTitleY; + void ClearPermitStage(void); BOOL AddPermitStage(int index, int event); BOOL SubPermitStage(int index); diff --git a/src/Shoot.cpp b/src/Shoot.cpp index 64bf7788..8c05dfa8 100644 --- a/src/Shoot.cpp +++ b/src/Shoot.cpp @@ -10,7 +10,7 @@ #include "MycParam.h" #include "Sound.h" -int empty; +static int empty; void ShootBullet_Frontia1(int level) { diff --git a/src/Stage.cpp b/src/Stage.cpp index a28e89cd..21cafa53 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -204,7 +204,7 @@ BOOL TransferStage(int no, int w, int x, int y) } // Music -const char *gMusicTable[42] = { +const char* const gMusicTable[42] = { "XXXX", "WANPAKU", "ANZEN", diff --git a/src/Stage.h b/src/Stage.h index be4f13fd..c5831888 100644 --- a/src/Stage.h +++ b/src/Stage.h @@ -62,6 +62,12 @@ typedef struct STAGE_TABLE extern int gStageNo; 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); void ChangeMusic(MusicID no); diff --git a/src/TextScr.cpp b/src/TextScr.cpp index fd78f103..8c9bada9 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -43,9 +43,9 @@ 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 static unsigned long nod_color; diff --git a/src/TextScr.h b/src/TextScr.h index 9cc49259..eb87f61f 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -53,6 +53,10 @@ typedef struct TEXT_SCRIPT unsigned char wait_beam; } TEXT_SCRIPT; +extern TEXT_SCRIPT gTS; + +extern const RECT gRect_line; + BOOL InitTextScript2(void); void EndTextScript(void); void EncryptionBinaryData2(unsigned char *pData, long size); diff --git a/src/Triangle.h b/src/Triangle.h index 29a1a843..e9d8947e 100644 --- a/src/Triangle.h +++ b/src/Triangle.h @@ -1,5 +1,8 @@ #pragma once +extern int gSin[0x100]; +extern short gTan[0x21]; + void InitTriangleTable(void); int GetSin(unsigned char deg); int GetCos(unsigned char deg); diff --git a/src/ValueView.cpp b/src/ValueView.cpp index 0813bad9..3cbe4d97 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -6,8 +6,6 @@ #include "Draw.h" -#define VALUEVIEW_MAX 0x10 - VALUEVIEW gVV[VALUEVIEW_MAX]; int gVVIndex; diff --git a/src/ValueView.h b/src/ValueView.h index 368e7039..2c786d8f 100644 --- a/src/ValueView.h +++ b/src/ValueView.h @@ -2,6 +2,8 @@ #include "WindowsWrapper.h" +#define VALUEVIEW_MAX 0x10 + typedef struct VALUEVIEW { BOOL flag; @@ -13,6 +15,9 @@ typedef struct VALUEVIEW RECT rect; } VALUEVIEW; +extern VALUEVIEW gVV[VALUEVIEW_MAX]; +extern int gVVIndex; + void ClearValueView(void); void SetValueView(int *px, int *py, int value); void ActValueView(void);