Skip to content

Commit

Permalink
TITANIC: Implemented CMusicRoomhandler updateAudio
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 3, 2017
1 parent 13648c8 commit a5f71a3
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
12 changes: 6 additions & 6 deletions engines/titanic/sound/audio_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ void CAudioBuffer::reset() {
_fieldC = _field10 = _buffer.size() / 2;
}

const byte *CAudioBuffer::getDataPtr1() const {
byte *CAudioBuffer::getDataPtr1() {
return _flag ? &_buffer[_buffer.size() / 2] : &_buffer[0];
}

const byte *CAudioBuffer::getDataPtr2() const {
byte *CAudioBuffer::getDataPtr2() {
return _flag ? &_buffer[0] : &_buffer[_buffer.size() / 2];
}

const byte *CAudioBuffer::getPtr1() const {
const byte *ptr = getDataPtr1();
byte *CAudioBuffer::getPtr1() {
byte *ptr = getDataPtr1();
return ptr + (_buffer.size() / 2 - _fieldC);
}

const byte *CAudioBuffer::getPtr2() const {
const byte *ptr = getDataPtr2();
byte *CAudioBuffer::getPtr2() {
byte *ptr = getDataPtr2();
return ptr + (_buffer.size() / 2 - _field10);
}

Expand Down
8 changes: 4 additions & 4 deletions engines/titanic/sound/audio_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class CAudioBuffer {
~CAudioBuffer();

void reset();
const byte *getDataPtr1() const;
const byte *getDataPtr2() const;
const byte *getPtr1() const;
const byte *getPtr2() const;
byte *getDataPtr1();
byte *getDataPtr2();
byte *getPtr1();
byte *getPtr2();
int getC() const { return _fieldC; }
int get10() const { return _field10; }
void setC(int val);
Expand Down
34 changes: 33 additions & 1 deletion engines/titanic/sound/music_room_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,34 @@ bool CMusicRoomHandler::update() {
}

void CMusicRoomHandler::updateAudio() {
// TODO
_audioBuffer->enterCriticalSection();
int size = _audioBuffer->get10();
int count;
byte *ptr;

if (size > 0) {
byte *audioPtr = _audioBuffer->getPtr2();
Common::fill(audioPtr, audioPtr + size, 0);

for (int waveIdx = 0; waveIdx < 4; ++waveIdx) {
CMusicWave *musicWave = _musicWaves[waveIdx];

for (count = size, ptr = audioPtr; count > 0; ) {
int amount = musicWave->setData(ptr, count);
if (amount > 0) {
count -= amount;
ptr += amount;
} else if (!fn2()) {
--_field108;
break;
}
}
}

_audioBuffer->set10(size);
}

_audioBuffer->leaveCriticalSection();
}

void CMusicRoomHandler::fn1() {
Expand All @@ -221,4 +248,9 @@ void CMusicRoomHandler::fn1() {
}
}

bool CMusicRoomHandler::fn2() {
// TODO
return false;
}

} // End of namespace Titanic
1 change: 1 addition & 0 deletions engines/titanic/sound/music_room_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CMusicRoomHandler {

void updateAudio();
void fn1();
bool fn2();
public:
CMusicRoomHandler(CProjectItem *project, CSoundManager *soundManager);
~CMusicRoomHandler();
Expand Down
5 changes: 5 additions & 0 deletions engines/titanic/sound/music_wave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,9 @@ void CMusicWave::setState(int val) {
_field44 = 0;
}

int CMusicWave::setData(const byte *data, int count) {
// TODO: Implement
return 0;
}

} // End of namespace Titanic
2 changes: 2 additions & 0 deletions engines/titanic/sound/music_wave.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class CMusicWave {

void reset();
void setState(int val);

int setData(const byte *data, int count);
};

} // End of namespace Titanic
Expand Down

0 comments on commit a5f71a3

Please sign in to comment.