diff --git a/src/ArmsItem.h b/src/ArmsItem.h index be9bc84b..c98bb2ae 100644 --- a/src/ArmsItem.h +++ b/src/ArmsItem.h @@ -2,16 +2,12 @@ #include "WindowsWrapper.h" -#ifdef __cplusplus -extern "C" { -#endif - // "Arms" is a synonym of "weapon" here // "Code" means "ID" here // "Num" often means "ammo" here /// Weapon struct -struct ARMS +typedef struct ARMS { /// ID of the weapon int code; @@ -27,13 +23,13 @@ struct ARMS /// Current ammunition int num; -}; +} ARMS; -struct ITEM +typedef struct ITEM { /// ID of the item int code; -}; +} ITEM; // Limits for the amount of weapons and items @@ -114,7 +110,3 @@ int RotationArmsRev(void); /// Change the current weapon to be the first one and play the usual rotation animation void ChangeToFirstArms(void); - -#ifdef __cplusplus -} -#endif diff --git a/src/Back.cpp b/src/Back.cpp index 4a45d3f6..b61076ab 100644 --- a/src/Back.cpp +++ b/src/Back.cpp @@ -10,9 +10,9 @@ #include "File.h" #include "Frame.h" #include "Game.h" +#include "Main.h" #include "Map.h" #include "Stage.h" -#include "Tags.h" BACK gBack; int gWaterY; diff --git a/src/Back.h b/src/Back.h index 184d4711..f10ccb0b 100644 --- a/src/Back.h +++ b/src/Back.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -struct BACK +typedef struct BACK { BOOL flag; // Basically unused int partsW; @@ -11,7 +11,7 @@ struct BACK int numY; int type; int fx; -}; +} BACK; extern BACK gBack; extern int gWaterY; diff --git a/src/Bullet.h b/src/Bullet.h index c10e7810..5604d8f3 100644 --- a/src/Bullet.h +++ b/src/Bullet.h @@ -2,10 +2,6 @@ #include "WindowsWrapper.h" -#ifdef __cplusplus -extern "C" { -#endif - typedef struct BULLET { int flag; @@ -73,7 +69,3 @@ void PutBullet(int fx, int fy); void SetBullet(int no, int x, int y, int dir); void ActBullet(void); BOOL IsActiveSomeBullet(void); - -#ifdef __cplusplus -} -#endif diff --git a/src/Config.cpp b/src/Config.cpp index 89a478f3..59d0db06 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -6,7 +6,7 @@ #include "Config.h" #include "File.h" -#include "Tags.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 diff --git a/src/Draw.cpp b/src/Draw.cpp index 687c89d1..33f01a58 100644 --- a/src/Draw.cpp +++ b/src/Draw.cpp @@ -17,7 +17,6 @@ #include "Main.h" #include "MapName.h" #include "Resource.h" -#include "Tags.h" #include "TextScr.h" typedef enum SurfaceType diff --git a/src/Draw.h b/src/Draw.h index ebd7296f..4ead4d1a 100644 --- a/src/Draw.h +++ b/src/Draw.h @@ -4,10 +4,6 @@ #include "WindowsWrapper.h" -#ifdef __cplusplus -extern "C" { -#endif - #ifndef RGB #define RGB(r,g,b) ((r) | ((g) << 8) | ((b) << 16)) #endif @@ -76,7 +72,3 @@ void InitTextObject(const char *font_name); void PutText(int x, int y, const char *text, unsigned long color); void PutText2(int x, int y, const char *text, unsigned long color, SurfaceID surf_no); void EndTextObject(void); - -#ifdef __cplusplus -} -#endif diff --git a/src/Ending.cpp b/src/Ending.cpp index 47f85563..89109a0e 100644 --- a/src/Ending.cpp +++ b/src/Ending.cpp @@ -16,7 +16,6 @@ #include "Organya.h" #include "Stage.h" #include "TextScr.h" -#include "Tags.h" CREDIT Credit; STRIP Strip[MAX_STRIP]; diff --git a/src/Frame.h b/src/Frame.h index 3f78684f..95b8e6b5 100644 --- a/src/Frame.h +++ b/src/Frame.h @@ -1,6 +1,6 @@ #pragma once -struct FRAME +typedef struct FRAME { int x; int y; @@ -9,7 +9,7 @@ struct FRAME int wait; int quake; int quake2; -}; +} FRAME; extern FRAME gFrame; diff --git a/src/Game.cpp b/src/Game.cpp index 47945c1b..c8b5e918 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -43,7 +43,6 @@ #include "Sound.h" #include "Stage.h" #include "Star.h" -#include "Tags.h" #include "TextScr.h" #include "ValueView.h" diff --git a/src/Game.h b/src/Game.h index 0e864bb4..75c48f9e 100644 --- a/src/Game.h +++ b/src/Game.h @@ -2,10 +2,6 @@ #include "WindowsWrapper.h" -#ifdef __cplusplus -extern "C" { -#endif - enum GameFlagsValues { // To be continued @@ -37,7 +33,3 @@ int Random(int min, int max); void PutNumber4(int x, int y, int value, BOOL bZero); BOOL Game(void); - -#ifdef __cplusplus -} -#endif diff --git a/src/Generic.cpp b/src/Generic.cpp index 7ae4d23d..255705ff 100644 --- a/src/Generic.cpp +++ b/src/Generic.cpp @@ -6,7 +6,7 @@ #include "WindowsWrapper.h" -#include "Tags.h" +#include "Main.h" void GetCompileDate(int *year, int *month, int *day) { diff --git a/src/Main.h b/src/Main.h index f2997706..0347fa09 100644 --- a/src/Main.h +++ b/src/Main.h @@ -2,6 +2,9 @@ #include "WindowsWrapper.h" +extern char gModulePath[MAX_PATH]; +extern char gDataPath[MAX_PATH]; + extern BOOL bFullscreen; void PutFramePerSecound(void); diff --git a/src/Map.cpp b/src/Map.cpp index 3c548f68..f3f0f7c4 100644 --- a/src/Map.cpp +++ b/src/Map.cpp @@ -10,8 +10,8 @@ #include "CommonDefines.h" #include "Draw.h" #include "File.h" +#include "Main.h" #include "NpChar.h" -#include "Tags.h" #define PXM_BUFFER_SIZE 0x4B000 diff --git a/src/MyChar.h b/src/MyChar.h index e9e01c8c..07a810eb 100644 --- a/src/MyChar.h +++ b/src/MyChar.h @@ -2,10 +2,6 @@ #include "WindowsWrapper.h" -#ifdef __cplusplus -extern "C" { -#endif - // TODO - When I add bitmask constants for gMC.flags... // 0x100 is a 'player is underwater' flag @@ -87,7 +83,3 @@ void SetNoise(int no, int freq); void CutNoise(void); void ResetNoise(void); void SleepNoise(void); - -#ifdef __cplusplus -} -#endif diff --git a/src/MycParam.cpp b/src/MycParam.cpp index 1729d8c8..b0dab941 100644 --- a/src/MycParam.cpp +++ b/src/MycParam.cpp @@ -12,10 +12,10 @@ #include "Draw.h" #include "File.h" #include "Game.h" +#include "Main.h" #include "MyChar.h" #include "NpChar.h" #include "Sound.h" -#include "Tags.h" #include "TextScr.h" #include "ValueView.h" diff --git a/src/MycParam.h b/src/MycParam.h index 5e625bef..82ab63b2 100644 --- a/src/MycParam.h +++ b/src/MycParam.h @@ -2,16 +2,16 @@ #include "WindowsWrapper.h" -struct ARMS_LEVEL +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]; diff --git a/src/NpChar.cpp b/src/NpChar.cpp index 91cb5f5f..68229eb0 100644 --- a/src/NpChar.cpp +++ b/src/NpChar.cpp @@ -12,10 +12,10 @@ #include "File.h" #include "Flags.h" #include "Game.h" +#include "Main.h" #include "MyChar.h" #include "NpcTbl.h" #include "Sound.h" -#include "Tags.h" #include "ValueView.h" NPCHAR gNPC[NPC_MAX]; diff --git a/src/NpChar.h b/src/NpChar.h index c5721561..a0781459 100644 --- a/src/NpChar.h +++ b/src/NpChar.h @@ -51,7 +51,7 @@ enum NPCNames // To be continued }; -struct NPCHAR +typedef struct NPCHAR { unsigned char cond; int flag; @@ -98,8 +98,8 @@ struct NPCHAR unsigned char shock; int damage_view; int damage; - NPCHAR *pNpc; -}; + struct NPCHAR *pNpc; +} NPCHAR; struct EVENT { diff --git a/src/Organya.h b/src/Organya.h index b76cc516..53adcfe7 100644 --- a/src/Organya.h +++ b/src/Organya.h @@ -1,4 +1,4 @@ - #pragma once +#pragma once #include "WindowsWrapper.h" diff --git a/src/PixTone.h b/src/PixTone.h index 99991309..45589105 100644 --- a/src/PixTone.h +++ b/src/PixTone.h @@ -2,15 +2,15 @@ #include "WindowsWrapper.h" -struct PIXTONEPARAMETER2 +typedef struct PIXTONEPARAMETER2 { int model; double num; int top; int offset; -}; +} PIXTONEPARAMETER2; -struct PIXTONEPARAMETER +typedef struct PIXTONEPARAMETER { int use; int size; @@ -24,7 +24,7 @@ struct PIXTONEPARAMETER int pointBy; int pointCx; int pointCy; -}; +} PIXTONEPARAMETER; void MakeWaveTables(void); BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData); diff --git a/src/Profile.cpp b/src/Profile.cpp index 700abc3f..eeddcb3f 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -13,13 +13,13 @@ #include "Flags.h" #include "Frame.h" #include "Game.h" +#include "Main.h" #include "MiniMap.h" #include "MyChar.h" #include "NpChar.h" #include "SelStage.h" #include "Stage.h" #include "Star.h" -#include "Tags.h" #include "ValueView.h" const char *gDefaultName = "Profile.dat"; diff --git a/src/Profile.h b/src/Profile.h index 158b12ce..9e99ebff 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -6,7 +6,7 @@ #include "SelStage.h" #include "Stage.h" -struct PROFILE +typedef struct PROFILE { char code[8]; int stage; @@ -29,7 +29,7 @@ struct PROFILE signed char permit_mapping[0x80]; char FLAG[4]; unsigned char flags[1000]; -}; +} PROFILE; BOOL IsProfile(void); BOOL SaveProfile(const char *name); diff --git a/src/SelStage.h b/src/SelStage.h index 419b94b7..7f1a49d4 100644 --- a/src/SelStage.h +++ b/src/SelStage.h @@ -2,11 +2,11 @@ #include "WindowsWrapper.h" -struct PERMIT_STAGE +typedef struct PERMIT_STAGE { int index; int event; -}; +} PERMIT_STAGE; extern PERMIT_STAGE gPermitStage[8]; diff --git a/src/Sound.cpp b/src/Sound.cpp index 63b04eba..41231ddf 100644 --- a/src/Sound.cpp +++ b/src/Sound.cpp @@ -20,9 +20,9 @@ equivalents. #include "WindowsWrapper.h" #include "Backends/Audio.h" +#include "Main.h" #include "Organya.h" #include "PixTone.h" -#include "Tags.h" BOOL audio_backend_initialised; AudioBackend_Sound *lpSECONDARYBUFFER[SE_MAX]; diff --git a/src/Stage.cpp b/src/Stage.cpp index 75d64a8d..85426658 100644 --- a/src/Stage.cpp +++ b/src/Stage.cpp @@ -246,9 +246,9 @@ const char *gMusicTable[42] = { "WHITE" }; +MusicID gMusicNo; unsigned int gOldPos; MusicID gOldNo; -MusicID gMusicNo; void ChangeMusic(MusicID no) { diff --git a/src/Stage.h b/src/Stage.h index de2432d9..be4f13fd 100644 --- a/src/Stage.h +++ b/src/Stage.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -enum MusicID +typedef enum MusicID { MUS_SILENCE = 0x0, MUS_MISCHIEVOUS_ROBOT = 0x1, @@ -46,9 +46,9 @@ enum MusicID MUS_SEAL_CHAMBER = 0x27, MUS_TOROKOS_THEME = 0x28, MUS_WHITE = 0x29 -}; +} MusicID; -struct STAGE_TABLE +typedef struct STAGE_TABLE { char parts[0x20]; char map[0x20]; @@ -58,7 +58,7 @@ struct STAGE_TABLE char boss[0x20]; signed char boss_no; char name[0x20]; -}; +} STAGE_TABLE; extern int gStageNo; extern MusicID gMusicNo; diff --git a/src/Star.h b/src/Star.h index 231242eb..672effb0 100644 --- a/src/Star.h +++ b/src/Star.h @@ -1,13 +1,5 @@ #pragma once -#ifdef __cplusplus -extern "C" { -#endif - void InitStar(void); void ActStar(void); void PutStar(int fx, int fy); - -#ifdef __cplusplus -} -#endif diff --git a/src/Tags.h b/src/Tags.h index d66bf478..09235ab7 100644 --- a/src/Tags.h +++ b/src/Tags.h @@ -1,6 +1,4 @@ #pragma once -#include "WindowsWrapper.h" - -extern char gModulePath[MAX_PATH]; -extern char gDataPath[MAX_PATH]; +// Apparently this used to contain a bunch of structs? +// For now, the structs are in header files matching their purpose. diff --git a/src/TextScr.cpp b/src/TextScr.cpp index 82f8be84..051c9a1f 100644 --- a/src/TextScr.cpp +++ b/src/TextScr.cpp @@ -32,7 +32,6 @@ #include "SelStage.h" #include "Sound.h" #include "Stage.h" -#include "Tags.h" #define TSC_BUFFER_SIZE 0x5000 @@ -42,7 +41,6 @@ TEXT_SCRIPT gTS; -int gNumberTextScript[4]; char text[4][0x40]; RECT gRect_line = {0, 0, 216, 16}; @@ -89,6 +87,7 @@ void EndTextScript(void) // Release buffers ReleaseSurface(SURFACE_ID_TEXT_BOX); + for (i = 0; i < 4; ++i) ReleaseSurface((SurfaceID)(SURFACE_ID_TEXT_LINE1 + i)); } @@ -96,12 +95,14 @@ void EndTextScript(void) // Decrypt .tsc void EncryptionBinaryData2(unsigned char *pData, long size) { - int val1; - int work; int i; + int work; + int half; + int val1; half = size / 2; + if (pData[half] == 0) val1 = -7; else @@ -120,8 +121,10 @@ void EncryptionBinaryData2(unsigned char *pData, long size) // Load generic .tsc BOOL LoadTextScript2(const char *name) { - // Get path + FILE *fp; char path[MAX_PATH]; + + // Get path sprintf(path, "%s/%s", gDataPath, name); gTS.size = GetFileSizeLong(path); @@ -129,7 +132,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 +153,19 @@ BOOL LoadTextScript2(const char *name) // Load stage .tsc BOOL LoadTextScript_Stage(const char *name) { - // Open Head.tsc + FILE *fp; char path[MAX_PATH]; + 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 == -1) return FALSE; - FILE *fp = fopen(path, "rb"); + fp = fopen(path, "rb"); if (fp == NULL) return FALSE; @@ -171,7 +178,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 == -1) return FALSE; @@ -295,6 +302,7 @@ BOOL JumpTextScript(int no) // Find where event starts gTS.p_read = 0; + while(1) { // Check if we are still in the proper range @@ -319,6 +327,7 @@ BOOL JumpTextScript(int no) // Advance until new-line while (gTS.data[gTS.p_read] != '\n') ++gTS.p_read; + ++gTS.p_read; return TRUE; @@ -346,15 +355,17 @@ void CheckNewLine(void) } } +int gNumberTextScript[4]; + // Type a number into the text buffer void SetNumberTextScript(int index) { + char str[5]; + BOOL bZero; int a; int b; - int i; - BOOL bZero; int offset; - char str[5]; + int i; // Get digit table int table[3]; @@ -424,15 +435,7 @@ void ClearTextLine(void) // Draw textbox and whatever else void PutTextScript(void) { - RECT rcFace; - RECT rcItemBox1; - RECT rcItemBox2; - RECT rcItemBox3; - RECT rcItemBox4; - RECT rcItemBox5; int i; - RECT rect_yesno; - RECT rect_cur; RECT rect; int text_offset; @@ -468,6 +471,7 @@ void PutTextScript(void) } // Draw face picture + RECT rcFace; rcFace.left = (gTS.face % 6) * 48; rcFace.top = (gTS.face / 6) * 48; rcFace.right = rcFace.left + 48; @@ -517,11 +521,11 @@ void PutTextScript(void) } // Draw GIT - SET_RECT(rcItemBox1, 0, 0, 72, 16) - SET_RECT(rcItemBox2, 0, 8, 72, 24) - SET_RECT(rcItemBox3, 240, 0, 244, 8) - SET_RECT(rcItemBox4, 240, 8, 244, 16) - SET_RECT(rcItemBox5, 240, 16, 244, 24) + RECT rcItemBox1 = {0, 0, 72, 16}; + RECT rcItemBox2 = {0, 8, 72, 24}; + RECT rcItemBox3 = {240, 0, 244, 8}; + RECT rcItemBox4 = {240, 8, 244, 16}; + RECT rcItemBox5 = {240, 16, 244, 24}; if (gTS.item != 0) { @@ -554,8 +558,8 @@ void PutTextScript(void) } // Draw Yes / No selection - SET_RECT(rect_yesno, 152, 48, 244, 80) - SET_RECT(rect_cur, 112, 88, 128, 104) + RECT rect_yesno = {152, 48, 244, 80}; + RECT rect_cur = {112, 88, 128, 104}; if (gTS.mode == 6) { @@ -573,11 +577,12 @@ void PutTextScript(void) // Parse TSC int TextScriptProc(void) { - BOOL bExit; - char c[3]; - int w, x, y, z; int i; + char c[3]; char str[72]; + int w, x, y, z; + + BOOL bExit; RECT rcSymbol = {64, 48, 72, 56}; diff --git a/src/TextScr.h b/src/TextScr.h index fc46a1d0..9cc49259 100644 --- a/src/TextScr.h +++ b/src/TextScr.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -struct TEXT_SCRIPT +typedef struct TEXT_SCRIPT { // Path (reload when exit teleporter menu/inventory) char path[MAX_PATH]; @@ -51,7 +51,7 @@ struct TEXT_SCRIPT // NOD cursor blink unsigned char wait_beam; -}; +} TEXT_SCRIPT; BOOL InitTextScript2(void); void EndTextScript(void); diff --git a/src/Types.h b/src/Types.h deleted file mode 100644 index 892ace5a..00000000 --- a/src/Types.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -//This was originally some sort of POSIX standard thing? leftover from the Linux port diff --git a/src/ValueView.cpp b/src/ValueView.cpp index ba9bcd3f..57b5601a 100644 --- a/src/ValueView.cpp +++ b/src/ValueView.cpp @@ -1,9 +1,10 @@ +#include "ValueView.h" + #include #include "WindowsWrapper.h" #include "Draw.h" -#include "ValueView.h" #define VALUEVIEW_MAX 0x10 @@ -26,6 +27,9 @@ void SetValueView(int *px, int *py, int value) int fig[4]; BOOL sw; int i; + RECT rect[20]; + RECT rcPlus; + RECT rcMinus; for (i = 0; i < VALUEVIEW_MAX; ++i) { @@ -91,28 +95,26 @@ void SetValueView(int *px, int *py, int value) gVV[index].rect.right = 40; gVV[index].rect.bottom = 8 * (index + 1); - RECT rect[20] = { - {0, 56, 8, 64}, - {8, 56, 16, 64}, - {16, 56, 24, 64}, - {24, 56, 32, 64}, - {32, 56, 40, 64}, - {40, 56, 48, 64}, - {48, 56, 56, 64}, - {56, 56, 64, 64}, - {64, 56, 72, 64}, - {72, 56, 80, 64}, - {0, 64, 8, 72}, - {8, 64, 16, 72}, - {16, 64, 24, 72}, - {24, 64, 32, 72}, - {32, 64, 40, 72}, - {40, 64, 48, 72}, - {48, 64, 56, 72}, - {56, 64, 64, 72}, - {64, 64, 72, 72}, - {72, 64, 80, 72}, - }; + SET_RECT(rect[0], 0, 56, 8, 64); + SET_RECT(rect[1], 8, 56, 16, 64); + SET_RECT(rect[2], 16, 56, 24, 64); + SET_RECT(rect[3], 24, 56, 32, 64); + SET_RECT(rect[4], 32, 56, 40, 64); + SET_RECT(rect[5], 40, 56, 48, 64); + SET_RECT(rect[6], 48, 56, 56, 64); + SET_RECT(rect[7], 56, 56, 64, 64); + SET_RECT(rect[8], 64, 56, 72, 64); + SET_RECT(rect[9], 72, 56, 80, 64); + SET_RECT(rect[10], 0, 64, 8, 72); + SET_RECT(rect[11], 8, 64, 16, 72); + SET_RECT(rect[12], 16, 64, 24, 72); + SET_RECT(rect[13], 24, 64, 32, 72); + SET_RECT(rect[14], 32, 64, 40, 72); + SET_RECT(rect[15], 40, 64, 48, 72); + SET_RECT(rect[16], 48, 64, 56, 72); + SET_RECT(rect[17], 56, 64, 64, 72); + SET_RECT(rect[18], 64, 64, 72, 72); + SET_RECT(rect[19], 72, 64, 80, 72); // Get digits dig[0] = 1; @@ -133,8 +135,8 @@ void SetValueView(int *px, int *py, int value) sw = FALSE; - RECT rcPlus = {32, 48, 40, 56}; - RECT rcMinus = {40, 48, 48, 56}; + SET_RECT(rcPlus, 32, 48, 40, 56); + SET_RECT(rcMinus, 40, 48, 48, 56); // Draw value CortBox2(&gVV[index].rect, 0x000000, SURFACE_ID_VALUE_VIEW); diff --git a/src/ValueView.h b/src/ValueView.h index c11a5b25..368e7039 100644 --- a/src/ValueView.h +++ b/src/ValueView.h @@ -2,7 +2,7 @@ #include "WindowsWrapper.h" -struct VALUEVIEW +typedef struct VALUEVIEW { BOOL flag; int *px; @@ -11,7 +11,7 @@ struct VALUEVIEW int value; int count; RECT rect; -}; +} VALUEVIEW; void ClearValueView(void); void SetValueView(int *px, int *py, int value);