From 9498fe13bedcca0417eee735173e59b94a236d02 Mon Sep 17 00:00:00 2001 From: Clownacy Date: Mon, 6 Jan 2020 21:15:42 +0000 Subject: [PATCH] Made TextScr.cpp valid C89 See #41 --- src/BossLife.h | 8 ++++++++ src/Ending.h | 8 ++++++++ src/Fade.h | 8 ++++++++ src/Flags.h | 8 ++++++++ src/KeyControl.h | 8 ++++++++ src/Main.cpp | 1 + src/Main.h | 8 ++++++++ src/MiniMap.h | 8 ++++++++ src/MycParam.h | 16 ++++++++++++---- src/PixTone.h | 16 ++++++++++++---- src/Sound.h | 8 ++++++++ src/Tags.h | 8 ++++++++ src/TextScr.cpp | 18 ++++++++++++------ src/TextScr.h | 4 ++-- vs2003/CSE2.vcproj | 6 ++++++ 15 files changed, 117 insertions(+), 16 deletions(-) diff --git a/src/BossLife.h b/src/BossLife.h index 1d5ffc63..28fa00f1 100644 --- a/src/BossLife.h +++ b/src/BossLife.h @@ -2,7 +2,15 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + void InitBossLife(void); BOOL StartBossLife(int code_event); BOOL StartBossLife2(void); void PutBossLife(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/Ending.h b/src/Ending.h index 54033793..9a749e36 100644 --- a/src/Ending.h +++ b/src/Ending.h @@ -4,6 +4,10 @@ #include "CommonDefines.h" +#ifdef __cplusplus +extern "C" { +#endif + struct CREDIT { long size; @@ -53,3 +57,7 @@ int GetScriptNumber(const char *text); void SetCreditIllust(int a); void CutCreditIllust(void); int Scene_DownIsland(HWND hWnd, int mode); + +#ifdef __cplusplus +} +#endif diff --git a/src/Fade.h b/src/Fade.h index b1f17366..4613be9d 100644 --- a/src/Fade.h +++ b/src/Fade.h @@ -2,6 +2,10 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + void InitFade(void); void SetFadeMask(void); void ClearFade(void); @@ -10,3 +14,7 @@ void StartFadeIn(signed char dir); void ProcFade(void); void PutFade(void); BOOL GetFadeActive(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/Flags.h b/src/Flags.h index 15a6ad2f..97aef8a4 100644 --- a/src/Flags.h +++ b/src/Flags.h @@ -2,6 +2,10 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + extern unsigned char gFlagNPC[1000]; extern unsigned char gSkipFlag[8]; @@ -13,3 +17,7 @@ BOOL GetNPCFlag(long a); void SetSkipFlag(long a); void CutSkipFlag(long a); BOOL GetSkipFlag(long a); + +#ifdef __cplusplus +} +#endif diff --git a/src/KeyControl.h b/src/KeyControl.h index 9063c82b..1a6da5c3 100644 --- a/src/KeyControl.h +++ b/src/KeyControl.h @@ -1,5 +1,9 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + enum KeyBind { //The movement keys go in the order of left, right, up and down @@ -53,3 +57,7 @@ extern long gKeyRight; extern long gKeyDown; void GetTrg(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/Main.cpp b/src/Main.cpp index 757575fb..98450750 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -20,6 +20,7 @@ #include "Organya.h" #include "Profile.h" #include "Sound.h" +#include "Tags.h" #include "Triangle.h" LRESULT __stdcall WindowProcedure(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); diff --git a/src/Main.h b/src/Main.h index 09b3e5aa..3acd86b8 100644 --- a/src/Main.h +++ b/src/Main.h @@ -2,6 +2,10 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + extern HWND ghWnd; extern BOOL bFullscreen; @@ -9,3 +13,7 @@ void PutFramePerSecound(void); unsigned long GetFramePerSecound(void); BOOL SystemTask(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/MiniMap.h b/src/MiniMap.h index add3aee5..a53fa872 100644 --- a/src/MiniMap.h +++ b/src/MiniMap.h @@ -2,9 +2,17 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + extern char gMapping[0x80]; int MiniMapLoop(void); BOOL IsMapping(void); void StartMapping(void); void SetMapping(int a); + +#ifdef __cplusplus +} +#endif diff --git a/src/MycParam.h b/src/MycParam.h index 5e625bef..d1256d67 100644 --- a/src/MycParam.h +++ b/src/MycParam.h @@ -2,16 +2,20 @@ #include "WindowsWrapper.h" -struct ARMS_LEVEL +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct ARMS_LEVEL { int exp[3]; -}; +} ARMS_LEVEL; -struct REC +typedef struct REC { long counter[4]; unsigned char random[4]; -}; +} REC; extern ARMS_LEVEL gArmsLevelTable[14]; @@ -30,3 +34,7 @@ void PutMyAir(int x, int y); void PutTimeCounter(int x, int y); BOOL SaveTimeCounter(void); int LoadTimeCounter(void); + +#ifdef __cplusplus +} +#endif diff --git a/src/PixTone.h b/src/PixTone.h index 99991309..e8e6c254 100644 --- a/src/PixTone.h +++ b/src/PixTone.h @@ -2,15 +2,19 @@ #include "WindowsWrapper.h" -struct PIXTONEPARAMETER2 +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PIXTONEPARAMETER2 { int model; double num; int top; int offset; -}; +} PIXTONEPARAMETER2; -struct PIXTONEPARAMETER +typedef struct PIXTONEPARAMETER { int use; int size; @@ -24,7 +28,11 @@ struct PIXTONEPARAMETER int pointBy; int pointCx; int pointCy; -}; +} PIXTONEPARAMETER; void MakeWaveTables(void); BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData); + +#ifdef __cplusplus +} +#endif diff --git a/src/Sound.h b/src/Sound.h index 46a0e032..ef60d65d 100644 --- a/src/Sound.h +++ b/src/Sound.h @@ -11,6 +11,10 @@ #include "PixTone.h" +#ifdef __cplusplus +extern "C" { +#endif + #define SE_MAX 160 // According to the Organya source code release, this is the real name for this constant enum SoundEffectNames @@ -42,3 +46,7 @@ void ChangeSoundFrequency(int no, DWORD rate); void ChangeSoundVolume(int no, long volume); void ChangeSoundPan(int no, long pan); int MakePixToneObject(const PIXTONEPARAMETER *ptp, int ptp_num, int no); + +#ifdef __cplusplus +} +#endif diff --git a/src/Tags.h b/src/Tags.h index d66bf478..0bc06aeb 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -2,5 +2,13 @@ #include "WindowsWrapper.h" +#ifdef __cplusplus +extern "C" { +#endif + extern char gModulePath[MAX_PATH]; extern char gDataPath[MAX_PATH]; + +#ifdef __cplusplus +} +#endif diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 65119232..a2fa078e 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -120,8 +120,10 @@ void EncryptionBinaryData2(unsigned char *pData, long size) // Load generic .tsc BOOL LoadTextScript2(const char *name) { - // Get path char path[MAX_PATH]; + FILE *fp; + + // Get path sprintf(path, "%s\\%s", gDataPath, name); gTS.size = GetFileSizeLong(path); @@ -129,7 +131,7 @@ BOOL LoadTextScript2(const char *name) return FALSE; // Open file - FILE *fp = fopen(path, "rb"); + fp = fopen(path, "rb"); if (fp == NULL) return FALSE; @@ -150,15 +152,19 @@ BOOL LoadTextScript2(const char *name) // Load stage .tsc BOOL LoadTextScript_Stage(const char *name) { - // Open Head.tsc char path[MAX_PATH]; + FILE *fp; + long head_size; + long body_size; + + // Open Head.tsc sprintf(path, "%s\\%s", gDataPath, "Head.tsc"); - long head_size = GetFileSizeLong(path); + head_size = GetFileSizeLong(path); if (head_size == INVALID_FILE_SIZE) return FALSE; - FILE *fp = fopen(path, "rb"); + fp = fopen(path, "rb"); if (fp == NULL) return FALSE; @@ -171,7 +177,7 @@ BOOL LoadTextScript_Stage(const char *name) // Open stage's .tsc sprintf(path, "%s\\%s", gDataPath, name); - long body_size = GetFileSizeLong(path); + body_size = GetFileSizeLong(path); if (body_size == INVALID_FILE_SIZE) return FALSE; diff --git a/src/TextScr.h b/src/TextScr.h index a073b731..ddfd49ea 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -6,7 +6,7 @@ extern "C" { #endif -struct TEXT_SCRIPT +typedef struct TEXT_SCRIPT { // Path (reload when exit teleporter menu/inventory) char path[MAX_PATH]; @@ -55,7 +55,7 @@ struct TEXT_SCRIPT // NOD cursor blink unsigned char wait_beam; -}; +} TEXT_SCRIPT; BOOL InitTextScript2(void); void EndTextScript(void); diff --git a/vs2003/CSE2.vcproj b/vs2003/CSE2.vcproj index 033252f3..73cc0ec7 100644 --- a/vs2003/CSE2.vcproj +++ b/vs2003/CSE2.vcproj @@ -345,6 +345,12 @@ + + +