[Scummvm-cvs-logs] SF.net SVN: scummvm: [21184] scummvm/trunk/engines/kyra/sound_adlib.cpp
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Thu Mar 9 10:43:03 CET 2006
Revision: 21184
Author: eriktorbjorn
Date: 2006-03-09 10:42:05 -0800 (Thu, 09 Mar 2006)
ViewCVS: http://svn.sourceforge.net/scummvm/?rev=21184&view=rev
Log Message:
-----------
As LordHoto pointed out to me, updateCallback41() was slightly different after
all: it adjusts the frequency even when state.unk16 is zero. Fixed that, and
added some comments to hopefully explain the differences between the cleaned up
code and the original disassembly.
Modified Paths:
--------------
scummvm/trunk/engines/kyra/sound_adlib.cpp
Modified: scummvm/trunk/engines/kyra/sound_adlib.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_adlib.cpp 2006-03-09 17:04:00 UTC (rev 21183)
+++ scummvm/trunk/engines/kyra/sound_adlib.cpp 2006-03-09 18:42:05 UTC (rev 21184)
@@ -156,7 +156,7 @@
uint16 getRandomNr();
void update1(uint8 unk1, OutputState &state);
- void updateAndOutput1(uint8 unk1, OutputState &state);
+ void updateAndOutput1(uint8 rawNote, OutputState &state, bool flag = false);
void updateAndOutput2(uint8 unk1, uint8 *dataptr, OutputState &state);
void updateAndOutput3(OutputState &state);
@@ -717,7 +717,7 @@
state.unk5 = unk1;
}
-void AdlibDriver::updateAndOutput1(uint8 rawNote, OutputState &state) {
+void AdlibDriver::updateAndOutput1(uint8 rawNote, OutputState &state, bool flag) {
debugC(9, kDebugLevelSound, "updateAndOutput1(%d, %d)", rawNote, &state - _outputTables);
state.rawNote = rawNote;
@@ -736,12 +736,25 @@
octave--;
}
+ // The calculation of frequency looks quite different from the original
+ // disassembly at a first glance, but when you consider that the
+ // largest possible value would be 0x0246 + 0xFF + 0x47 (and that's if
+ // baseFreq turns out to be unsigned after all), freq is still a 10-bit
+ // value, just as it should be to fit in the Ax and Bx registers.
+ //
+ // If it were larger than that, it could have overflowed into the
+ // octave bits, and that could possibly have been used in some sound.
+ // But as it is now, I can't see any way it would happen.
+
uint16 freq = _unkTable[note] + state.baseFreq;
- if (state.unk16) {
+ // When called from callback 41, the behaviour is slightly different:
+ // We adjust the frequency, even when state.unk16 is 0.
+
+ if (state.unk16 || flag) {
const uint8 *table;
- if (state.unk16 > 0) {
+ if (state.unk16 >= 0) {
table = _unkTables[(state.rawNote & 0x0F) + 2];
freq += table[state.unk16];
} else {
@@ -1279,7 +1292,7 @@
int AdlibDriver::updateCallback41(uint8 *&dataptr, OutputState &state, uint8 value) {
state.unk16 = value;
- updateAndOutput1(state.rawNote, state);
+ updateAndOutput1(state.rawNote, state, true);
return 0;
}
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