File: logic_he.h

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (173 lines) | stat: -rw-r--r-- 7,376 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#if !defined(SCUMM_HE_LOGIC_HE_H) && defined(ENABLE_HE)
#define SCUMM_HE_LOGIC_HE_H

#include "scumm/resource.h"
#include "scumm/scumm.h"
#include "scumm/he/wiz_he.h"
#include "scumm/he/basketball/basketball.h"
#include "scumm/he/basketball/collision/bball_collision_support_obj.h"
#include "scumm/he/basketball/obstacle_avoidance.h"

namespace Scumm {

class ScummEngine_v90he;
class ScummEngine_v100he;
class ResourceManager;

class LogicHE {
public:
	static LogicHE *makeLogicHE(ScummEngine_v90he *vm);

	virtual ~LogicHE();

	virtual void beforeBootScript() {}
	virtual void initOnce() {}
	virtual int startOfFrame() { return 1; }
	void endOfFrame() {}
	void processKeyStroke(int keyPressed) {}

	virtual int versionID();
	virtual int32 dispatch(int op, int numArgs, int32 *args);
	virtual bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) { return false; }
	virtual bool overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
	virtual bool overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
	virtual bool getSpriteProperty(int sprite, int property, int *outValue) { return false; }
	virtual bool setSpriteProperty(int sprite, int property, int value) { return false; }
	virtual bool getGroupProperty(int group, int property, int *outValue) { return false; }
	virtual void spriteNewHook(int sprite) {}
	virtual void groupNewHook(int group) {}
	

protected:
	// Only to be used from makeLogicHE()
	LogicHE(ScummEngine_v90he *vm);

	ScummEngine_v90he *_vm;

	void writeScummVar(int var, int32 value);
	int getFromArray(int arg0, int idx2, int idx1);
	void putInArray(int arg0, int idx2, int idx1, int val);
	int32 scummRound(double arg) { return (int32)(arg + 0.5); }

	#define RAD2DEG (180 / M_PI)
	#define DEG2RAD (M_PI / 180)
};

// Logic declarations
LogicHE *makeLogicHErace(ScummEngine_v90he *vm);
LogicHE *makeLogicHEfunshop(ScummEngine_v90he *vm);
LogicHE *makeLogicHEfootball(ScummEngine_v90he *vm);
LogicHE *makeLogicHEfootball2002(ScummEngine_v90he *vm);
LogicHE *makeLogicHEsoccer(ScummEngine_v90he *vm);
LogicHE *makeLogicHEbaseball2001(ScummEngine_v90he *vm);
LogicHE *makeLogicHEbasketball(ScummEngine_v100he *vm);
LogicHE *makeLogicHEmoonbase(ScummEngine_v100he *vm);


// Declarations for Basketball logic live here
// instead of in basketball_logic.cpp since
// they are defined in multiple files...
class LogicHEBasketball : public LogicHE {
public:
	LogicHEBasketball(ScummEngine_v100he *vm) : LogicHE(vm) { _vm1 = vm; }

	int versionID() override;
	int32 dispatch(int op, int numArgs, int32 *args) override;

	float _courtAngle = 0.0F;
	float _yTranslationA = 0.0F;
	float _yTranslationB = 0.0F;
	float _yTranslationC = 0.0F;
	float _yRevTranslationA = 0.0F;
	float _yRevTranslationB = 0.0F;
	float _yRevTranslationC = 0.0F;
	int _topScalingPointCutoff = 0;
	int _bottomScalingPointCutoff = 0;

protected:
	int u32_userInitCourt(int courtID);
	int u32_userInitBall(U32FltPoint3D &ballLocation, U32FltVector3D &bellVelocity, int radius, int ballID);
	int u32_userInitVirtualBall(U32FltPoint3D &ballLocation, U32FltVector3D &bellVelocity, int radius, int ballID);
	int u32_userInitPlayer(int playerID, U32FltPoint3D &playerLocation, int height, int radius, bool bPlayerIsInGame);
	int u32_userPlayerOff(int playerID);
	int u32_userPlayerOn(int playerID);
	int u32_userDetectBallCollision(U32FltPoint3D &ballLocation, U32FltVector3D &ballVector, int recordCollision, int ballID);
	int u32_userDetectPlayerCollision(int playerID, U32FltPoint3D &playerLocation, U32FltVector3D &playerVector, bool bPlayerHasBall);
	int u32_userGetLastBallCollision(int ballID);
	int u32_userGetLastPlayerCollision(int playerID);
	int u32_userDeinitCourt();
	int u32_userDeinitBall();
	int u32_userDeinitVirtualBall();
	int u32_userDeinitPlayer(int playerID);

	int u32_userInitScreenTranslations(void);
	int u32_userWorldToScreenTranslation(const U32FltPoint3D &worldPoint);
	int u32_userScreenToWorldTranslation(const U32FltPoint2D &screenPoint);
	int u32_userGetCourtDimensions();
	int u32_userComputePointsForPixels(int pixels, int yPos);

	int u32_userComputeTrajectoryToTarget(const U32FltPoint3D &sourcePoint, const U32FltPoint3D &targetPoint, int speed);
	int u32_userComputeLaunchTrajectory(const U32FltPoint2D &sourcePoint, const U32FltPoint2D &targetPoint, int launchAngle, int iVelocity);
	int u32_userComputeAngleBetweenVectors(const U32FltVector3D &vector1, const U32FltVector3D &vector2);

	// Court shields
	int u32_userRaiseShields(int shieldID);
	int u32_userLowerShields(int shieldID);
	int u32_userAreShieldsClear();

	// Player shields
	int u32_userShieldPlayer(int playerID, int shieldRadius);
	int u32_userClearPlayerShield(int playerID);

	int u32_userComputeAngleOfShot(int hDist, int vDist);
	int u32_userComputeBankShotTarget(U32FltPoint3D basketLoc, int ballRadius);
	int u32_userComputeSwooshTarget(const U32FltPoint3D &basketLoc, int ballRadius);
	int u32_userComputeInitialShotVelocity(int theta, int hDist, int vDist, int gravity);
	int u32_userDetectShotMade(const U32Sphere &basketball, const U32IntVector3D &ballVector, int gravity, int whichBasket);
	int u32_userComputeAngleOfPass(int iVelocity, int hDist, int vDist, int gravity);
	int u32_userComputeAngleOfBouncePass(int iVelocity, int hDist, int currentZ, int destZ, int gravity);
	int u32_userHitMovingTarget(U32FltPoint2D sourcePlayer, U32FltPoint2D targetPlayer, U32FltVector2D targetVelocity, int passSpeed);
	int u32_userGetPassTarget(int playerID, const U32FltVector3D &aimVector);
	int u32_userDetectPassBlocker(int playerID, const U32FltPoint3D &targetPoint);
	int u32_userGetBallIntercept(int playerID, int ballID, int playerSpeed, int gravity);
	int u32_userGetAvoidancePath(int playerID, const U32FltPoint2D &targetLocation, EAvoidanceType type);

	int u32_userGetPlayerClosestToBall(int teamIndex);
	int u32_userGetPlayerClosestToBall();
	int u32_userIsPlayerInBounds(int playerID);
	int u32_userIsBallInBounds();
	int u32_userGetOpenSpot(int whichPlayer, U32FltVector2D upperLeft, U32FltVector2D lowerRight, U32FltVector2D from, bool attract, U32FltVector2D attract_point);

	int u32_userUpdateCursorPos(int xScrollVal, int yScrollVal);
	int u32_userMakeCursorSticky(int lastCursorX, int lastCursorY);
	int u32_userCursorTrackMovingObject(int xChange, int yChange);
	int u32_userGetCursorPos();

private:
	ScummEngine_v100he *_vm1;
};

} // End of namespace Scumm

#endif