22#if !defined(SCUMM_SMUSH_PLAYER_H) && defined(ENABLE_SCUMM_7_8)
23#define SCUMM_SMUSH_PLAYER_H
25#include "common/util.h"
26#include "common/list.h"
27#include "common/rect.h"
28#include "scumm/charset_v7.h"
29#include "scumm/smush/saud.h"
33class QueuingAudioStream;
38#define SMUSH_MAX_TRACKS 4
39#define SMUSH_FADE_SIZE 0xC00
42#define IS_BKG_MUSIC 0x40
49#define GRP_MASTER 0xFF01
51#define GRP_BKGMUS 0xFF03
52#define GRP_SPEECH 0xFF04
54#define TRK_STATE_INACTIVE 0
55#define TRK_STATE_PLAYING 1
56#define TRK_STATE_FADING 2
57#define TRK_STATE_ENDING 3
59#define TRK_TYPE_MASK 0xC0
61#define TRK_USERID_SPEECH 1
62#define TRK_USERID_MUSIC 2
63#define TRK_USERID_SFX 3
65#define SMUSH_CODEC_RLE 1
66#define SMUSH_CODEC_RA1_SCATTER 2
67#define SMUSH_CODEC_RLE_ALT 3
68#define SMUSH_CODEC_RA1_DELTA 4
69#define SMUSH_CODEC_RA1_BLOCK 5
70#define SMUSH_CODEC_UNCOMPRESSED 20
71#define SMUSH_CODEC_LINE_UPDATE 21
72#define SMUSH_CODEC_SKIP_RLE 23
73#define SMUSH_CODEC_DELTA_BLOCKS 37
74#define SMUSH_CODEC_LINE_UPDATE2 44
76#define SMUSH_CODEC_SEGACD_RLE 31
77#define SMUSH_CODEC_SEGACD_OPAQUE 32
78#define SMUSH_CODEC_SEGACD_BLOCK33 33
79#define SMUSH_CODEC_SEGACD_BLOCK34 34
80#define SMUSH_CODEC_RA2_BOMP 45
81#define SMUSH_CODEC_DELTA_GLYPHS 47
89 virtual ~StringResource() {}
90 virtual const char *get(
int id) = 0;
92class SmushDeltaBlocksDecoder;
93class SmushDeltaGlyphsDecoder;
97class SmushPlayerRebel1;
98class SmushPlayerRebel2;
102 friend class InsaneRebel1;
103 friend class InsaneRebel2;
104 friend class RebelAudio;
105 friend class SmushPlayerRebel1;
106 friend class SmushPlayerRebel2;
107 friend class SmushMultiFont;
109 struct SmushAudioDispatch {
113 int32 audioRemaining;
125 struct SmushAudioTrack {
139 int32 audioRemaining;
144 IMuseDigital *_imuseDigital;
147 int16 _deltaPal[0x300];
148 int32 _shiftedDeltaPal[0x300];
151 SmushMultiFont *_multiFont;
152 StringResource *_strings;
153 SmushDeltaBlocksDecoder *_deltaBlocksCodec;
154 SmushDeltaGlyphsDecoder *_deltaGlyphsCodec;
158 byte *_specialBuffer;
159 int _specialBufferSize;
162 byte *_storedFobjData;
163 int32 _storedFobjDataSize;
164 int _storedFobjCodec;
165 uint16 _storedFobjParm2;
168 int _storedFobjWidth;
169 int _storedFobjHeight;
174 int32 _lastFobjDataSize;
180 bool _hasFrameFobjForGost;
195 uint32 _fastForwardFromFrame;
196 uint32 _fastForwardToFrame;
197 bool _preserveVideoStateOnNextPlay;
198 bool _preserveGameVideoStateOnRelease;
204 bool _compressedFileMode;
205 byte _IACToutput[4096];
214 int _palDirtyMin, _palDirtyMax;
222 SmushAudioTrack _smushTracks[SMUSH_MAX_TRACKS];
223 SmushAudioDispatch _smushDispatch[SMUSH_MAX_TRACKS];
225 int _smushMaxFrames[SMUSH_MAX_TRACKS];
226 int _smushTrackIds[SMUSH_MAX_TRACKS];
227 int _smushTrackIdxs[SMUSH_MAX_TRACKS];
228 uint8 _smushAudioTable[256];
230 int _smushTrackFlags[SMUSH_MAX_TRACKS];
231 int _smushTrackVols[SMUSH_MAX_TRACKS];
233 int _smushAudioSampleRate;
234 int _gainReductionLowerBound;
235 int _gainReductionFactor;
236 int _gainReductionMultiplier;
238 bool _smushTracksNeedInit;
239 bool _smushAudioInitialized;
240 bool _smushAudioCallbackEnabled;
243 SmushPlayer(ScummEngine_v7 *scumm, IMuseDigital *_imuseDigital, Insane *insane);
244 virtual ~SmushPlayer();
247 virtual void unpause();
249 void play(
const char *filename, int32 speed, int32 offset = 0, int32 startFrame = 0);
251 void warpMouse(
int x,
int y,
int buttons);
252 int setChanFlag(
int id,
int flagVal);
253 void setGroupVolume(
int groupId,
int volValue);
254 void processDispatches(int16 feedSize);
255 bool isAudioCallbackEnabled();
256 byte *getVideoPalette();
257 void setCurVideoFlags(int16 flags);
258 SmushMultiFont *getMultiFont()
const {
return _multiFont; }
259 void ensureMultiFont();
260 bool isFastForwardingCurrentFrame()
const;
261 void setPreserveVideoStateOnNextPlay(
bool preserve) { _preserveVideoStateOnNextPlay = preserve; }
262 void setPreserveGameVideoStateOnRelease(
bool preserve) { _preserveGameVideoStateOnRelease = preserve; }
263 void setFastForwardFromFrame(uint32 frame) { _fastForwardFromFrame = frame; }
264 void setFastForwardToFrame(uint32 frame) { _fastForwardToFrame = frame; }
271 void clearMaskedRegions();
278 int _origPitch, _origNumStrips;
280 uint32 _pauseStartTime;
282 int16 _curVideoFlags = 0;
287 void setPalette(
const byte *palette);
288 void setPaletteValue(
int n,
byte r,
byte g,
byte b);
289 void setDirtyColors(
int min,
int max);
290 void setScrollOffset(
int x,
int y);
291 void seekSan(
const char *file, int32 pos, int32 contFrame);
292 const char *getString(
int id);
293 virtual void initGamePlayerFields() {}
294 virtual void destroyGamePlayerFields() {}
295 virtual void resetGameVideoState() {}
296 virtual void initGameVideoState() {}
297 virtual void releaseGameVideoState() {}
298 virtual bool shouldPreserveFrameBuffer()
const {
return false; }
301 virtual bool handleGameTextRendering(
const char *str,
int fontId,
int color,
int pos_x,
int pos_y,
int left,
int top,
int width,
int height, TextStyleFlags flg) {
return false; }
302 virtual bool shouldAlwaysShowSubtitles()
const {
return false; }
303 virtual SmushFont *getGameFont(
int font) {
return nullptr; }
304 virtual void adjustGamePalette() {}
305 virtual bool shouldLoadAnimHeaderPalette()
const {
return true; }
306 virtual bool handleGameAnimHeader(
byte *headerContent) {
return false; }
307 virtual bool handleGameSetupStrings() {
return false; }
308 virtual void handleGameParseNextFrame() {}
309 virtual bool shouldRouteAllIACTs()
const {
return false; }
310 virtual bool handleGameFrameBufferSelect(
int codec,
int width,
int height) {
return false; }
311 virtual bool handleGameDimensionOverride(
int codec,
int width,
int height) {
return false; }
312 virtual int handleGameFrameObjectPitch(
int pitch) {
return pitch; }
313 virtual bool handleGameAdjustCoords(
int codec,
int &left,
int &top,
int &width,
int &height,
int pitch,
int *srcSkipY) {
return false; }
314 virtual bool handleGameCodecDecode(
int codec,
const uint8 *src,
int left,
int top,
int width,
int height,
int pitch,
int dataSize, uint8 param = 0, uint16 parm2 = 0) {
return false; }
315 virtual bool handleGameStoreFrame() {
return false; }
316 virtual void handleGameFrameObjectPre(
int codec,
int left,
int top,
int width,
int height,
int dataSize) {}
317 virtual void handleGameFrameObjectPost(
int codec,
const byte *data, int32 dataSize,
int left,
int top,
int width,
int height) {}
318 virtual void handleGameFrameObjectDecoded(
int codec,
int left,
int top,
int width,
int height) {}
319 virtual void handleGameFrameStart() {}
322 virtual void handleGameProcessAudio(int16 feedSize) {}
323 virtual bool isInsaneGame()
const {
return false; }
327 virtual void handleGameUpdateScreen(
const byte *
328 src,
int srcPitch,
int width,
int height);
331 SmushFont *getFont(
int font);
332 void parseNextFrame();
333 void init(int32 spped);
334 void setupAnim(
const char *file);
336 void tryCmpFile(
const char *filename);
338 bool readString(
const char *file);
339 void decodeFrameObject(
int codec,
const uint8 *src,
int left,
int top,
int width,
int height,
int dataSize = 0, uint8 ra1Param = 0, uint16 ra1Parm2 = 0);
343 void handleSAUDChunk(uint8 *srcBuf, uint32 size,
int groupId,
int vol,
int pan, int16 flags,
int trkId,
int index,
int maxFrames);
352 void adjustFrameCoords(
int &left,
int &top,
int &width,
int &height,
int pitch,
int *srcSkipY =
nullptr);
353 void rememberLastFobj(
int codec,
const byte *data, int32 dataSize,
354 int left,
int top,
int width,
int height);
356 void initAudio(
int samplerate, int32 maxChunkSize);
357 void terminateAudio();
358 int isChanActive(
int flagId);
359 int addAudioTrack(int32 trackBlockSize, int32 maxBlockSize);
360 void resetAudioTracks();
361 void setGainReductionParams(int16 gainReductionLowerBound, int16 gainReductionMultiplier);
362 void fillAudioTrackInfo(uint8 *srcBuf, uint16 *flagsAccumulator, uint32 size,
int groupId,
int vol,
int pan, int16 flags,
int trkId,
int index,
int maxFrames);
363 bool processAudioCodes(
int idx, int32 &tmpFeedSize,
int &mixVolume);
364 void feedAudio(uint8 *srcBuf,
int groupId,
int volume,
int pan, int16 flags);
365 void sendAudioToDiMUSE(uint8 *mixBuf, int32 mixStartingPoint, int32 mixFeedSize, int32 mixInFrameCount,
int volume,
int pan);
367 void timerCallback();
Definition: audiostream.h:370