13#if !defined(SCUMM_INSANE_REBEL2_PSX_H) && defined(ENABLE_SCUMM_7_8) && defined(ENABLE_REBEL2_PSX)
14#define SCUMM_INSANE_REBEL2_PSX_H
16#include "common/array.h"
17#include "common/error.h"
18#include "common/hashmap.h"
19#include "common/path.h"
20#include "common/str.h"
21#include "common/types.h"
24#include "graphics/surface.h"
25#include "graphics/tinygl/tinygl.h"
29class SeekableReadStream;
33class RewindableAudioStream;
40class RA2PSXLevel2Scene;
41class RA2PSXMainMenuUI;
44class RA2PSXChapterSelectUI;
48bool loadRA2PSXDebrisModels(
const RA2PSXArchive &archive,
51enum RA2PSXMovieTextSequence {
53 kRA2PSXMovieTextOpening,
54 kRA2PSXMovieTextChapter1
70 bool findTopLevelEntry(
const Common::String &name, Entry &entry)
const;
74 static bool decompress(
const byte *source, uint32 sourceSize, uint32 expectedSize,
80class RA2PSXSoundBank {
84 uint16 adsrId = 0xffff)
const;
85 bool getSFX(uint16
id, uint16 ¯o,
byte &priority,
byte &maxVoices)
const;
86 bool getMacroCommand(uint16 macro, uint16 step,
byte *command)
const;
113 const Sample *findSample(uint16
id)
const;
114 const ADSR *findADSR(uint16
id)
const;
124class RA2PSXSoundPlayer {
126 typedef uint32 SoundId;
127 enum { kInvalidSoundId = 0 };
129 RA2PSXSoundPlayer(ScummEngine_v7 *vm,
const RA2PSXSoundBank &bank);
130 ~RA2PSXSoundPlayer();
133 enum { kNeutralBend = 0x2000 };
135 SoundId play(uint16 sfx,
int volume,
int pan,
int pitch = kNeutralBend);
137 void setPan(SoundId sound,
int pan);
138 void setVolume(SoundId sound,
int volume);
139 void setPitch(SoundId sound,
int pitch);
140 void stop(SoundId sound);
149struct RA2PSXSettings {
157 RA2PSXSettings() { reset(); }
162 void apply(ScummEngine_v7 *vm)
const;
163 byte videoVolume()
const;
165 int unlockedChapters()
const;
185 RA2PSXMatrix() { setIdentity(); }
188 void setScale(
int x,
int y,
int z);
189 void setRotationX(
int angle);
190 void setRotationY(
int angle);
191 void setRotationZ(
int angle);
192 void preRotateX(
int angle);
193 void preRotateY(
int angle);
194 void preRotateZ(
int angle);
195 void setTranslation(
int x,
int y,
int z);
197 float rotation[3][3];
198 float translation[3];
201struct RA2PSXTexture {
211uint32 decodeRA2PSXColor(uint16 value);
217struct RA2PSXPlayFrame {
218 RA2PSXPlayFrame() : x(0), y(0), width(0), height(0), boxLeft(0), boxTop(0),
219 boxRight(0), boxBottom(0), flags(0) {}
234 kRA2PSXPlayLastFrame = 0x0001,
235 kRA2PSXPlayCompressed = 0x0002,
236 kRA2PSXPlayTargetable = 0x0004,
237 kRA2PSXPlayHitsPlayer = 0x0008,
238 kRA2PSXPlaySound = 0x0010
248enum { kRA2PSXExplosionHeight = 56 };
256 kRA2PSXLevel2PartCount = 3,
257 kRA2PSXLevel2LayerCount = 5,
258 kRA2PSXLevel2SceneTop = 28,
261 kRA2PSXLevel2CoverFrames = 5,
263 kRA2PSXLevel2FrameCount = 33,
264 kRA2PSXLevel2RookieDelay = 3,
265 kRA2PSXLevel2AimColumns = 5,
266 kRA2PSXLevel2AimRows = 5,
269 kRA2PSXLevel2ScrollSteps = 20,
270 kRA2PSXLevel2ScrollHold = 14,
271 kRA2PSXLevel2ScrollDamping = 0xe000
275 kRA2PSXLevel2TrooperCount = 3,
277 kRA2PSXLevel2TickRate = 60,
278 kRA2PSXLevel2FrameTicks = 4,
280 kRA2PSXLevel2ClearTicks = 60,
282 kRA2PSXLevel2SlotNever = 0x7fffffff,
284 kRA2PSXLevel2FireRepeat = 12,
288 kRA2PSXLevel2ShotCount = 2,
289 kRA2PSXLevel2ShotStep = 300,
290 kRA2PSXLevel2ShotDraw = 4000,
291 kRA2PSXLevel2ShotEnd = 0x112f,
293 kRA2PSXLevel2ShotNearZ = 1000,
294 kRA2PSXLevel2ShotFarZ = 18000
299 kRA2PSXLevel2StateIdle = 0,
300 kRA2PSXLevel2StateAppear = 1,
301 kRA2PSXLevel2StateAimed = 2,
302 kRA2PSXLevel2StateWild = 3,
303 kRA2PSXLevel2StateDie = 4,
304 kRA2PSXLevel2StateShot = 5,
305 kRA2PSXLevel2StateCover = 0x80
309struct RA2PSXLevel2Shot {
310 RA2PSXLevel2Shot() : step(0), muzzleX(0), muzzleY(0), targetX(0), targetY(0) {}
322struct RA2PSXLevel2Actor {
323 RA2PSXLevel2Actor() : state(kRA2PSXLevel2StateIdle), animation(-1), frame(0), hold(0),
324 hit(false), slotTick(0), fireNext(0), fireEnd(0) {}
337struct RA2PSXLevel2FireWindow {
343struct RA2PSXLevel2Pose {
352struct RA2PSXLevel2Layer {
362struct RA2PSXLevel2PartInfo {
366 int16 coverScroll[2][2];
367 int16 openScroll[2][2];
370 RA2PSXLevel2Layer layers[kRA2PSXLevel2LayerCount];
374 int16 aimLeft, aimTop, aimRight, aimBottom;
375 int16 aimColumns[kRA2PSXLevel2AimColumns];
376 int16 aimRows[kRA2PSXLevel2AimRows];
379 RA2PSXLevel2Pose poses[kRA2PSXLevel2FrameCount];
383 const char *trooperPalettes[kRA2PSXLevel2TrooperCount];
384 const char *boltPalettes[kRA2PSXLevel2TrooperCount];
386 RA2PSXLevel2FireWindow fireWindows[kRA2PSXLevel2TrooperCount][3];
390extern const int16 kRA2PSXLevel2WaveTable[kRA2PSXLevel2PartCount][3][2];
393extern const int16 kRA2PSXLevel2SlotTable[kRA2PSXLevel2PartCount][3][5];
395extern const int16 kRA2PSXLevel2FireTable[2][3][2];
397extern const int16 kRA2PSXLevel2BoltTable[kRA2PSXLevel2PartCount][3][2];
398extern const int16 kRA2PSXLevel2KillScore[3];
400extern const RA2PSXLevel2PartInfo kRA2PSXLevel2Parts[kRA2PSXLevel2PartCount];
404struct RA2PSXBackgroundView {
405 RA2PSXBackgroundView() : panX(0), panY(0), tiltLeft(0), tiltRight(0),
406 sceneX(0), sceneY(0) {}
439 const RA2PSXTexture *texture(
int index)
const;
440 float radius()
const {
return _radius; }
453class RA2PSXTinyGLRenderer {
455 RA2PSXTinyGLRenderer();
456 ~RA2PSXTinyGLRenderer();
458 bool init(
int width,
int height);
460 void beginFrame(
const Graphics::Surface &background,
const RA2PSXBackgroundView &view);
462 void setViewOffset(
int x,
int y) { _viewOffsetX = x; _viewOffsetY = y; }
464 void renderSprite(
const RA2PSXTexture &texture,
float x,
float y,
float z,
465 float halfWidth,
float halfHeight,
int rotation,
int brightness = 0x80);
466 void renderModel(
const RA2PSXModel &model,
float x,
float y,
float size,
467 float pitch,
float yaw,
float roll,
bool depthTest =
true);
468 void renderPerspectiveModel(
const RA2PSXModel &model,
float x,
float y,
float z,
469 float directionX,
float directionY,
float directionZ,
float roll,
470 bool depthTest =
true,
int scale = 0x1000);
471 void renderTransformedModel(
const RA2PSXModel &model,
const RA2PSXMatrix &transform,
472 bool depthTest =
true);
476 struct TextureBinding {
477 const RA2PSXTexture *texture;
481 void setFaceState(
const RA2PSXModel &model,
const RA2PSXFace &face);
482 void setFaceColor(
const RA2PSXFace &face, uint vertexIndex,
483 float normalX,
float normalY,
float normalZ,
float depth);
484 TGLuint getTextureId(
const RA2PSXTexture &texture);
486 TinyGL::ContextHandle *_context;
488 const RA2PSXTexture *_activeTexture;
489 bool _textureEnabled;
500 explicit Rebel2PSX(ScummEngine_v7 *vm);
501 ~Rebel2PSX() =
default;
523 bool playVideo(
const Common::Path &path,
int discNumber,
bool version2,
524 const RA2PSXMovieText *movieText =
nullptr,
525 RA2PSXMovieTextSequence textSequence = kRA2PSXMovieTextNone);
526 bool playIntroSequence(
const RA2PSXMovieText &movieText);
527 MenuResult runMainMenu(
const RA2PSXMainMenuUI &ui,
const RA2PSXOptionsUI &options);
530 void runOptionsMenu(
const RA2PSXOptionsUI &ui, RA2PSXSoundPlayer &sound,
531 RA2PSXTinyGLRenderer &renderer);
534 int runChapterSelect(
const RA2PSXChapterSelectUI &ui);
535 bool loadGlobalAssets(RA2PSXMainMenuUI &menu);
536 bool loadMovieTextAssets(RA2PSXMovieText &movieText);
537 bool loadLevel1Assets(RA2PSXModel &enemy, RA2PSXModel &ship,
538 RA2PSXModel &crosshair, RA2PSXModel &laser, RA2PSXModel &tieLaser,
541 Level1Result playLevel1(
const RA2PSXModel &enemy,
const RA2PSXModel &ship,
542 const RA2PSXModel &crosshair,
const RA2PSXModel &laser,
544 const RA2PSXLevel1UI &ui,
int &lives,
int &score);
547 RA2PSXSoundBank _soundBank;
548 RA2PSXSettings _settings;
551 RA2PSXModel _logoModel;
552 RA2PSXModel _cloakModel;
553 RA2PSXModel _crestModel;
557 RA2PSXTexture _smokeTexture;
Definition: audiostream.h:109
Definition: algorithm.h:29