ScummVM API documentation
logic_he.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#if !defined(SCUMM_HE_LOGIC_HE_H) && defined(ENABLE_HE)
23#define SCUMM_HE_LOGIC_HE_H
24
25#include "scumm/resource.h"
26#include "scumm/scumm.h"
27#include "scumm/he/wiz_he.h"
28#include "scumm/he/basketball/basketball.h"
29#include "scumm/he/basketball/collision/bball_collision_support_obj.h"
30#include "scumm/he/basketball/obstacle_avoidance.h"
31
32namespace Scumm {
33
34class ScummEngine_v90he;
35class ScummEngine_v100he;
36class ResourceManager;
37
38class LogicHE {
39public:
40 static LogicHE *makeLogicHE(ScummEngine_v90he *vm);
41
42 virtual ~LogicHE();
43
44 virtual void beforeBootScript() {}
45 virtual void initOnce() {}
46 virtual int startOfFrame() { return 1; }
47 void endOfFrame() {}
48 void processKeyStroke(int keyPressed) {}
49
50 virtual int versionID();
51 virtual int32 dispatch(int op, int numArgs, int32 *args);
52 virtual bool userCodeProcessWizImageCmd(const WizImageCommand *icmdPtr) { return false; }
53 virtual bool overrideImageHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
54 virtual bool overrideImagePixelHitTest(int *outValue, int globNum, int state, int x, int y, int32 flags) { return false; }
55 virtual bool getSpriteProperty(int sprite, int property, int *outValue) { return false; }
56 virtual bool setSpriteProperty(int sprite, int property, int value) { return false; }
57 virtual bool getGroupProperty(int group, int property, int *outValue) { return false; }
58 virtual void spriteNewHook(int sprite) {}
59 virtual void groupNewHook(int group) {}
60
61
62protected:
63 // Only to be used from makeLogicHE()
64 LogicHE(ScummEngine_v90he *vm);
65
66 ScummEngine_v90he *_vm;
67
68 void writeScummVar(int var, int32 value);
69 int getFromArray(int arg0, int idx2, int idx1);
70 void putInArray(int arg0, int idx2, int idx1, int val);
71 int32 scummRound(double arg) { return (int32)(arg + 0.5); }
72
73 #define RAD2DEG (180 / M_PI)
74 #define DEG2RAD (M_PI / 180)
75};
76
77// Logic declarations
78LogicHE *makeLogicHErace(ScummEngine_v90he *vm);
79LogicHE *makeLogicHEfunshop(ScummEngine_v90he *vm);
80LogicHE *makeLogicHEfootball(ScummEngine_v90he *vm);
81LogicHE *makeLogicHEfootball2002(ScummEngine_v90he *vm);
82LogicHE *makeLogicHEsoccer(ScummEngine_v90he *vm);
83LogicHE *makeLogicHEbaseball2001(ScummEngine_v90he *vm);
84LogicHE *makeLogicHEbasketball(ScummEngine_v100he *vm);
85LogicHE *makeLogicHEmoonbase(ScummEngine_v100he *vm);
86
87
88// Declarations for Basketball logic live here
89// instead of in basketball_logic.cpp since
90// they are defined in multiple files...
91class LogicHEBasketball : public LogicHE {
92public:
93 LogicHEBasketball(ScummEngine_v100he *vm) : LogicHE(vm) { _vm1 = vm; }
94
95 int versionID() override;
96 int32 dispatch(int op, int numArgs, int32 *args) override;
97
98 float _courtAngle = 0.0F;
99 float _yTranslationA = 0.0F;
100 float _yTranslationB = 0.0F;
101 float _yTranslationC = 0.0F;
102 float _yRevTranslationA = 0.0F;
103 float _yRevTranslationB = 0.0F;
104 float _yRevTranslationC = 0.0F;
105 int _topScalingPointCutoff = 0;
106 int _bottomScalingPointCutoff = 0;
107
108protected:
109 int u32_userInitCourt(int courtID);
110 int u32_userInitBall(U32FltPoint3D &ballLocation, U32FltVector3D &bellVelocity, int radius, int ballID);
111 int u32_userInitVirtualBall(U32FltPoint3D &ballLocation, U32FltVector3D &bellVelocity, int radius, int ballID);
112 int u32_userInitPlayer(int playerID, U32FltPoint3D &playerLocation, int height, int radius, bool bPlayerIsInGame);
113 int u32_userPlayerOff(int playerID);
114 int u32_userPlayerOn(int playerID);
115 int u32_userDetectBallCollision(U32FltPoint3D &ballLocation, U32FltVector3D &ballVector, int recordCollision, int ballID);
116 int u32_userDetectPlayerCollision(int playerID, U32FltPoint3D &playerLocation, U32FltVector3D &playerVector, bool bPlayerHasBall);
117 int u32_userGetLastBallCollision(int ballID);
118 int u32_userGetLastPlayerCollision(int playerID);
119 int u32_userDeinitCourt();
120 int u32_userDeinitBall();
121 int u32_userDeinitVirtualBall();
122 int u32_userDeinitPlayer(int playerID);
123
124 int u32_userInitScreenTranslations(void);
125 int u32_userWorldToScreenTranslation(const U32FltPoint3D &worldPoint);
126 int u32_userScreenToWorldTranslation(const U32FltPoint2D &screenPoint);
127 int u32_userGetCourtDimensions();
128 int u32_userComputePointsForPixels(int pixels, int yPos);
129
130 int u32_userComputeTrajectoryToTarget(const U32FltPoint3D &sourcePoint, const U32FltPoint3D &targetPoint, int speed);
131 int u32_userComputeLaunchTrajectory(const U32FltPoint2D &sourcePoint, const U32FltPoint2D &targetPoint, int launchAngle, int iVelocity);
132 int u32_userComputeAngleBetweenVectors(const U32FltVector3D &vector1, const U32FltVector3D &vector2);
133
134 // Court shields
135 int u32_userRaiseShields(int shieldID);
136 int u32_userLowerShields(int shieldID);
137 int u32_userAreShieldsClear();
138
139 // Player shields
140 int u32_userShieldPlayer(int playerID, int shieldRadius);
141 int u32_userClearPlayerShield(int playerID);
142
143 int u32_userComputeAngleOfShot(int hDist, int vDist);
144 int u32_userComputeBankShotTarget(U32FltPoint3D basketLoc, int ballRadius);
145 int u32_userComputeSwooshTarget(const U32FltPoint3D &basketLoc, int ballRadius);
146 int u32_userComputeInitialShotVelocity(int theta, int hDist, int vDist, int gravity);
147 int u32_userDetectShotMade(const U32Sphere &basketball, const U32IntVector3D &ballVector, int gravity, int whichBasket);
148 int u32_userComputeAngleOfPass(int iVelocity, int hDist, int vDist, int gravity);
149 int u32_userComputeAngleOfBouncePass(int iVelocity, int hDist, int currentZ, int destZ, int gravity);
150 int u32_userHitMovingTarget(U32FltPoint2D sourcePlayer, U32FltPoint2D targetPlayer, U32FltVector2D targetVelocity, int passSpeed);
151 int u32_userGetPassTarget(int playerID, const U32FltVector3D &aimVector);
152 int u32_userDetectPassBlocker(int playerID, const U32FltPoint3D &targetPoint);
153 int u32_userGetBallIntercept(int playerID, int ballID, int playerSpeed, int gravity);
154 int u32_userGetAvoidancePath(int playerID, const U32FltPoint2D &targetLocation, EAvoidanceType type);
155
156 int u32_userGetPlayerClosestToBall(int teamIndex);
157 int u32_userGetPlayerClosestToBall();
158 int u32_userIsPlayerInBounds(int playerID);
159 int u32_userIsBallInBounds();
160 int u32_userGetOpenSpot(int whichPlayer, U32FltVector2D upperLeft, U32FltVector2D lowerRight, U32FltVector2D from, bool attract, U32FltVector2D attract_point);
161
162 int u32_userUpdateCursorPos(int xScrollVal, int yScrollVal);
163 int u32_userMakeCursorSticky(int lastCursorX, int lastCursorY);
164 int u32_userCursorTrackMovingObject(int xChange, int yChange);
165 int u32_userGetCursorPos();
166
167private:
168 ScummEngine_v100he *_vm1;
169};
170
171} // End of namespace Scumm
172
173#endif
Definition: actor.h:30