Ticket #8851: bs1-mac-en.diff

File bs1-mac-en.diff, 4.3 KB (added by criezy, 17 years ago)
Line 
1diff -cr scummvm-20080406/engines/sword1/sound.cpp scummvm-20080406-modified/engines/sword1/sound.cpp
2*** scummvm-20080406/engines/sword1/sound.cpp Tue Apr 1 01:11:54 2008
3--- scummvm-20080406-modified/engines/sword1/sound.cpp Sun Apr 6 17:43:20 2008
4***************
5*** 49,54 ****
6--- 49,55 ----
7 strcpy(_filePath, searchPath);
8 _mixer = mixer;
9 _resMan = pResMan;
10+ _bigEndianSpeech = false;
11 _cowHeader = NULL;
12 _endOfQueue = 0;
13 _currentCowFile = 0;
14***************
15*** 65,70 ****
16--- 66,75 ----
17 closeCowSystem();
18 }
19
20+ void Sound::setIsBigEndianSpeech(bool isBE) {
21+ _bigEndianSpeech = isBE;
22+ }
23+
24 int Sound::addToQueue(int32 fxNo) {
25 bool alreadyInQueue = false;
26 for (uint8 cnt = 0; (cnt < _endOfQueue) && (!alreadyInQueue); cnt++)
27***************
28*** 284,304 ****
29 int16 *dstData = (int16*)malloc(resSize * 2);
30 int32 samplesLeft = resSize;
31 while (srcPos < cSize && samplesLeft > 0) {
32! int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
33 srcPos++;
34 if (length < 0) {
35 length = -length;
36 if (length > samplesLeft)
37 length = samplesLeft;
38! for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
39! dstData[dstPos++] = srcData[srcPos];
40 srcPos++;
41 } else {
42 if (length > samplesLeft)
43 length = samplesLeft;
44! memcpy(dstData + dstPos, srcData + srcPos, length * 2);
45! dstPos += length;
46! srcPos += length;
47 }
48 samplesLeft -= length;
49 }
50--- 289,320 ----
51 int16 *dstData = (int16*)malloc(resSize * 2);
52 int32 samplesLeft = resSize;
53 while (srcPos < cSize && samplesLeft > 0) {
54! int16 length = (int16)(_bigEndianSpeech ? READ_BE_UINT16(srcData + srcPos) : READ_LE_UINT16(srcData + srcPos));
55 srcPos++;
56 if (length < 0) {
57 length = -length;
58 if (length > samplesLeft)
59 length = samplesLeft;
60! if (_bigEndianSpeech) {
61! int16 value = (int16)SWAP_BYTES_16(*((uint16*)(srcData + srcPos)));
62! for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
63! dstData[dstPos++] = value;
64! } else {
65! for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
66! dstData[dstPos++] = srcData[srcPos];
67! }
68 srcPos++;
69 } else {
70 if (length > samplesLeft)
71 length = samplesLeft;
72! if (_bigEndianSpeech) {
73! for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
74! dstData[dstPos++] = (int16)SWAP_BYTES_16(*((uint16*)(srcData + (srcPos++))));
75! } else {
76! memcpy(dstData + dstPos, srcData + srcPos, length * 2);
77! dstPos += length;
78! srcPos += length;
79! }
80 }
81 samplesLeft -= length;
82 }
83diff -cr scummvm-20080406/engines/sword1/sound.h scummvm-20080406-modified/engines/sword1/sound.h
84*** scummvm-20080406/engines/sword1/sound.h Tue Apr 1 01:11:54 2008
85--- scummvm-20080406-modified/engines/sword1/sound.h Sun Apr 6 17:38:36 2008
86***************
87*** 93,98 ****
88--- 93,100 ----
89 int addToQueue(int32 fxNo);
90
91 void engine(void);
92+
93+ void setIsBigEndianSpeech(bool);
94
95 private:
96 uint8 _sfxVolL, _sfxVolR, _speechVolL, _speechVolR;
97***************
98*** 115,120 ****
99--- 117,123 ----
100 uint8 _endOfQueue;
101 Audio::Mixer *_mixer;
102 ResMan *_resMan;
103+ bool _bigEndianSpeech;
104 char _filePath[100];
105 static const char _musicList[270];
106 static const uint16 _roomsFixedFx[TOTAL_ROOMS][TOTAL_FX_PER_ROOM];
107diff -cr scummvm-20080406/engines/sword1/sword1.cpp scummvm-20080406-modified/engines/sword1/sword1.cpp
108*** scummvm-20080406/engines/sword1/sword1.cpp Tue Apr 1 01:11:54 2008
109--- scummvm-20080406-modified/engines/sword1/sword1.cpp Sun Apr 6 17:52:04 2008
110***************
111*** 335,340 ****
112--- 335,351 ----
113
114 _systemVars.playSpeech = 1;
115 _mouseState = 0;
116+
117+ // Some Mac versions use big endian for the speech files but not all of them.
118+ // The speech files have always the clu extension (and not the clm for big endian)
119+ // and the only way I have found to try to guess if we should use big endian is by
120+ // testing the language.
121+ // Mac BS1 english full version: big endian.
122+ // PC BS1 (all language) & Mac BS1 french : little endian.
123+ // Mac BS1 all other language: not known. Currently set on little endian.
124+ // Mac BS1 demo: not known, set to the same than the full version (i.e. english uses big endian).
125+ if (_systemVars.isMac && _systemVars.language == BS1_ENGLISH)
126+ _sound->setIsBigEndianSpeech(true);
127
128 _logic->initialize();
129 _objectMan->initialize();