shithub: cstory

Download patch

ref: 84626ea71009d5fb382526bbe1801462787f381f
parent: a0eb646a1f2f2f4356eb25a37e9d86153ff25aab
parent: dbe773f01a1221c483643e33bd50d0245d2aa077
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Jan 6 23:55:10 EST 2020

Merge branch 'accurate' into portable

--- 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 @@
 
 	/// 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 @@
 
 /// Change the current weapon to be the first one and play the usual rotation animation
 void ChangeToFirstArms(void);
-
-#ifdef __cplusplus
-}
-#endif
--- 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;
--- 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 @@
 	int numY;
 	int type;
 	int fx;
-};
+} BACK;
 
 extern BACK gBack;
 extern int gWaterY;
--- 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 SetBullet(int no, int x, int y, int dir);
 void ActBullet(void);
 BOOL IsActiveSomeBullet(void);
-
-#ifdef __cplusplus
-}
-#endif
--- 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
--- 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
--- 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 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
--- 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];
--- 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 @@
 	int wait;
 	int quake;
 	int quake2;
-};
+} FRAME;
 
 extern FRAME gFrame;
 
--- 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"
 
--- 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 @@
 void PutNumber4(int x, int y, int value, BOOL bZero);
 
 BOOL Game(void);
-
-#ifdef __cplusplus
-}
-#endif
--- 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)
 {
--- 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);
--- 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
 
--- 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 CutNoise(void);
 void ResetNoise(void);
 void SleepNoise(void);
-
-#ifdef __cplusplus
-}
-#endif
--- 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"
 
--- 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];
 
--- 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];
--- a/src/NpChar.h
+++ b/src/NpChar.h
@@ -51,7 +51,7 @@
 	// To be continued
 };
 
-struct NPCHAR
+typedef struct NPCHAR
 {
 	unsigned char cond;
 	int flag;
@@ -98,8 +98,8 @@
 	unsigned char shock;
 	int damage_view;
 	int damage;
-	NPCHAR *pNpc;
-};
+	struct NPCHAR *pNpc;
+} NPCHAR;
 
 struct EVENT
 {
--- a/src/Organya.h
+++ b/src/Organya.h
@@ -1,4 +1,4 @@
-	#pragma once
+#pragma once
 
 #include "WindowsWrapper.h"
 
--- 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 @@
 	int pointBy;
 	int pointCx;
 	int pointCy;
-};
+} PIXTONEPARAMETER;
 
 void MakeWaveTables(void);
 BOOL MakePixelWaveData(const PIXTONEPARAMETER *ptp, unsigned char *pData);
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -13,6 +13,7 @@
 #include "Flags.h"
 #include "Frame.h"
 #include "Game.h"
+#include "Main.h"
 #include "MiniMap.h"
 #include "MyChar.h"
 #include "NpChar.h"
@@ -19,7 +20,6 @@
 #include "SelStage.h"
 #include "Stage.h"
 #include "Star.h"
-#include "Tags.h"
 #include "ValueView.h"
 
 const char *gDefaultName = "Profile.dat";
--- 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 @@
 	signed char permit_mapping[0x80];
 	char FLAG[4];
 	unsigned char flags[1000];
-};
+} PROFILE;
 
 BOOL IsProfile(void);
 BOOL SaveProfile(const char *name);
--- 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];
 
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -20,9 +20,9 @@
 #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];
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -246,9 +246,9 @@
 	"WHITE"
 };
 
+MusicID gMusicNo;
 unsigned int gOldPos;
 MusicID gOldNo;
-MusicID gMusicNo;
 
 void ChangeMusic(MusicID no)
 {
--- 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 @@
 	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 @@
 	char boss[0x20];
 	signed char boss_no;
 	char name[0x20];
-};
+} STAGE_TABLE;
 
 extern int gStageNo;
 extern MusicID gMusicNo;
--- 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
--- 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.
--- 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 @@
 
 	// Release buffers
 	ReleaseSurface(SURFACE_ID_TEXT_BOX);
+
 	for (i = 0; i < 4; ++i)
 		ReleaseSurface((SurfaceID)(SURFACE_ID_TEXT_LINE1 + i));
 }
@@ -96,12 +95,14 @@
 // 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 @@
 // 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 @@
 		return FALSE;
 
 	// Open file
-	FILE *fp = fopen(path, "rb");
+	fp = fopen(path, "rb");
 	if (fp == NULL)
 		return FALSE;
 
@@ -150,15 +153,19 @@
 // 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 @@
 	// 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 @@
 
 	// Find where event starts
 	gTS.p_read = 0;
+
 	while(1)
 	{
 		// Check if we are still in the proper range
@@ -319,6 +327,7 @@
 	// Advance until new-line
 	while (gTS.data[gTS.p_read] != '\n')
 		++gTS.p_read;
+
 	++gTS.p_read;
 
 	return TRUE;
@@ -346,15 +355,17 @@
 	}
 }
 
+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 @@
 // 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 @@
 	}
 
 	// 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 @@
 	}
 
 	// 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 @@
 	}
 
 	// 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 @@
 // 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};
 
--- 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 @@
 
 	// NOD cursor blink
 	unsigned char wait_beam;
-};
+} TEXT_SCRIPT;
 
 BOOL InitTextScript2(void);
 void EndTextScript(void);
--- a/src/Types.h
+++ /dev/null
@@ -1,3 +1,0 @@
-#pragma once
-
-//This was originally some sort of POSIX standard thing? leftover from the Linux port
--- a/src/ValueView.cpp
+++ b/src/ValueView.cpp
@@ -1,9 +1,10 @@
+#include "ValueView.h"
+
 #include <string.h>
 
 #include "WindowsWrapper.h"
 
 #include "Draw.h"
-#include "ValueView.h"
 
 #define VALUEVIEW_MAX 0x10
 
@@ -26,6 +27,9 @@
 	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 @@
 	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 @@
 
 	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);
--- 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 @@
   int value;
   int count;
   RECT rect;
-};
+} VALUEVIEW;
 
 void ClearValueView(void);
 void SetValueView(int *px, int *py, int value);
--