1 2 /* 3 * REminiscence - Flashback interpreter 4 * Copyright (C) 2005-2019 Gregory Montoir (cyx@users.sourceforge.net) 5 */ 6 7 #ifndef SEQ_PLAYER_H__ 8 #define SEQ_PLAYER_H__ 9 10 #include "intern.h" 11 12 struct File; 13 struct SystemStub; 14 struct Mixer; 15 16 struct SeqDemuxer { 17 enum { 18 kFrameSize = 6144, 19 kAudioBufferSize = 882, 20 kBuffersCount = 30 21 }; 22 23 bool open(File *f); 24 void close(); 25 26 bool readHeader(); 27 bool readFrameData(); 28 void fillBuffer(int num, int offset, int size); 29 void clearBuffer(int num); 30 void readPalette(uint8_t *dst); 31 void readAudio(int16_t *dst); 32 33 int _frameOffset; 34 int _audioDataOffset; 35 int _paletteDataOffset; 36 int _videoData; 37 struct { 38 int size; 39 int avail; 40 uint8_t *data; 41 } _buffers[kBuffersCount]; 42 int _fileSize; 43 File *_f; 44 }; 45 46 struct SeqPlayer { 47 enum { 48 kVideoWidth = 256, 49 kVideoHeight = 128, 50 kSoundPreloadSize = 4 51 }; 52 53 static const char *_namesTable[]; 54 55 struct SoundBufferQueue { 56 int16_t *data; 57 int size; 58 int read; 59 SoundBufferQueue *next; 60 }; 61 62 SeqPlayer(SystemStub *stub, Mixer *mixer); 63 ~SeqPlayer(); 64 setBackBufferSeqPlayer65 void setBackBuffer(uint8_t *buf) { _buf = buf; } 66 void play(File *f); 67 bool mix(int16_t *buf, int len); 68 static bool mixCallback(void *param, int16_t *buf, int len); 69 70 SystemStub *_stub; 71 uint8_t *_buf; 72 Mixer *_mix; 73 SeqDemuxer _demux; 74 int _soundQueuePreloadSize; 75 SoundBufferQueue *_soundQueue, *_soundQueueTail; 76 }; 77 78 #endif // SEQ_PLAYER_H__ 79 80