[Scummvm-cvs-logs] SF.net SVN: scummvm: [28624] scummvm/trunk/engines/agi
buddha_ at users.sourceforge.net
buddha_ at users.sourceforge.net
Wed Aug 15 17:55:39 CEST 2007
Revision: 28624
http://scummvm.svn.sourceforge.net/scummvm/?rev=28624&view=rev
Author: buddha_
Date: 2007-08-15 08:55:38 -0700 (Wed, 15 Aug 2007)
Log Message:
-----------
Made AGI's 4-channel PCjr sound not need structure packing pragmas anymore. Also added more use of little endian reading macros.
Modified Paths:
--------------
scummvm/trunk/engines/agi/sound.cpp
scummvm/trunk/engines/agi/sound.h
Modified: scummvm/trunk/engines/agi/sound.cpp
===================================================================
--- scummvm/trunk/engines/agi/sound.cpp 2007-08-14 19:57:20 UTC (rev 28623)
+++ scummvm/trunk/engines/agi/sound.cpp 2007-08-15 15:55:38 UTC (rev 28624)
@@ -420,7 +420,7 @@
}
chn[i].ins = waveform;
chn[i].size = WAVEFORM_SIZE;
- chn[i].ptr = (struct AgiNote *)(song + (song[i << 1] | (song[(i << 1) + 1] << 8)));
+ chn[i].ptr = song + READ_LE_UINT16(song + i * 2);
chn[i].timer = 0;
chn[i].vol = 0;
chn[i].end = 0;
@@ -586,7 +586,7 @@
}
chn[0].timer = *p++;
- chn[0].ptr = (struct AgiNote *)p;
+ chn[0].ptr = p;
if (*p >= 0xfc) {
debugC(3, kDebugLevelSound, "end of sequence");
@@ -603,24 +603,25 @@
#endif /* USE_IIGS_SOUND */
void SoundMgr::playAgiSound() {
- int i, freq;
+ int i;
+ AgiNote note;
for (playing = i = 0; i < (_vm->_soundemu == SOUND_EMU_PC ? 1 : 4); i++) {
playing |= !chn[i].end;
+ note.read(chn[i].ptr); // Read a single note (Doesn't advance the pointer)
if (chn[i].end)
continue;
if ((--chn[i].timer) <= 0) {
stopNote(i);
- freq = ((chn[i].ptr->frq0 & 0x3f) << 4) | (int)(chn[i].ptr->frq1 & 0x0f);
- if (freq) {
- uint8 v = chn[i].ptr->vol & 0x0f;
- playNote(i, freq * 10, v == 0xf ? 0 : 0xff - (v << 1));
+ if (note.freqDiv != 0) {
+ int volume = (note.attenuation == 0x0F) ? 0 : (0xFF - note.attenuation * 2);
+ playNote(i, note.freqDiv * 10, volume);
}
- chn[i].timer = ((int)chn[i].ptr->durHi << 8) | chn[i].ptr->durLo;
+ chn[i].timer = note.duration;
if (chn[i].timer == 0xffff) {
chn[i].end = 1;
@@ -634,7 +635,7 @@
}
#endif
}
- chn[i].ptr++;
+ chn[i].ptr += 5; // Advance the pointer to the next note data (5 bytes per note)
}
}
}
Modified: scummvm/trunk/engines/agi/sound.h
===================================================================
--- scummvm/trunk/engines/agi/sound.h 2007-08-14 19:57:20 UTC (rev 28623)
+++ scummvm/trunk/engines/agi/sound.h 2007-08-15 15:55:38 UTC (rev 28624)
@@ -177,21 +177,25 @@
bool finalize(Common::SeekableReadStream &uint8Wave);
};
-#include "common/pack-start.h"
-
/**
* AGI sound note structure.
*/
struct AgiNote {
- uint8 durLo; /**< LSB of note duration */
- uint8 durHi; /**< MSB of note duration */
- uint8 frq0; /**< LSB of note frequency */
- uint8 frq1; /**< MSB of note frequency */
- uint8 vol; /**< note volume */
+ uint16 duration; ///< Note duration
+ uint16 freqDiv; ///< Note frequency divisor (10-bit)
+ uint8 attenuation; ///< Note volume attenuation (4-bit)
+
+ /** Reads an AgiNote through the given pointer. */
+ void read(uint8 *ptr) {
+ duration = READ_LE_UINT16(ptr);
+ uint16 freqByte0 = *(ptr + 2); // Bits 4-9 of the frequency divisor
+ uint16 freqByte1 = *(ptr + 3); // Bits 0-3 of the frequency divisor
+ // Merge the frequency divisor's bits together into a single variable
+ freqDiv = ((freqByte0 & 0x3F) << 4) | (freqByte1 & 0x0F);
+ attenuation = *(ptr + 4) & 0x0F;
+ }
};
-#include "common/pack-end.h"
-
/**
* AGI engine sound channel structure.
*/
@@ -200,7 +204,7 @@
#define AGI_SOUND_MIDI 0x0002
#define AGI_SOUND_4CHN 0x0008
uint32 type;
- struct AgiNote *ptr;
+ uint8 *ptr; // Pointer to the AgiNote data
int16 *ins;
int32 size;
uint32 phase;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list