diff options
author | Eugene Sandulenko | 2005-04-07 21:13:01 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2005-04-07 21:13:01 +0000 |
commit | ba3077ed0e06f39dd27353f0e3a6c2c9ba05791d (patch) | |
tree | 359be431e5e03de71164719a47da1ac38fc6d305 | |
parent | bac8f7a90c8f9fc5a92623a877c25062edc81607 (diff) | |
download | scummvm-rg350-ba3077ed0e06f39dd27353f0e3a6c2c9ba05791d.tar.gz scummvm-rg350-ba3077ed0e06f39dd27353f0e3a6c2c9ba05791d.tar.bz2 scummvm-rg350-ba3077ed0e06f39dd27353f0e3a6c2c9ba05791d.zip |
Patch from Quietust:
1. properly handle costume colors in dark rooms (verified against disasm)
2. optimize NES audio generation a little bit - instead of calling a function ~80 times to get one audio sample, it calls it once and just loops ~80 times internally
3. NES audio now obeys the volume control
4. in MM NES, o2_setObjPreposition is a no-op
5. o2_lights uses new-style light values (i.e. bitfields) in MM NES
6. o2_delay, use ssPaused identifier rather than a literal '1'
7. in MM NES, o5_saveLoadGame only explicitly checks for type '1' (load), defaulting to save for any other value
svn-id: r17443
-rw-r--r-- | scumm/costume.cpp | 2 | ||||
-rw-r--r-- | scumm/player_nes.cpp | 50 | ||||
-rw-r--r-- | scumm/player_nes.h | 1 | ||||
-rw-r--r-- | scumm/script_v2.cpp | 12 | ||||
-rw-r--r-- | scumm/script_v5.cpp | 2 |
5 files changed, 31 insertions, 36 deletions
diff --git a/scumm/costume.cpp b/scumm/costume.cpp index 9e55779e14..1af14ea2cf 100644 --- a/scumm/costume.cpp +++ b/scumm/costume.cpp @@ -642,7 +642,7 @@ byte NESCostumeRenderer::drawLimb(const Actor *a, int limb) { if (cost.curpos[limb] == 0xFFFF) return 0; - if (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_actor_color) + if (_vm->VAR(_vm->VAR_CURRENT_LIGHTS) & LIGHTMODE_actor_base) palette = _vm->_NESPalette[1]; else palette = darkpalette; diff --git a/scumm/player_nes.cpp b/scumm/player_nes.cpp index 8dd8615259..278e763978 100644 --- a/scumm/player_nes.cpp +++ b/scumm/player_nes.cpp @@ -579,32 +579,27 @@ void APU_Reset (void) { Frame.Cycles = 1; } -int16 sample_pos = 0; -bool sample_ok = false; - -void APU_Run(void) { - static int sampcycles = 0, samppos = 0; - int NewBufPos = APU.SampleRate * ++APU.Cycles / 1789773; - - if (NewBufPos == APU.SampleRate) /* we've generated 1 second, so we can reset our counters now */ - APU.Cycles = NewBufPos = 0; +int16 APU_GetSample(void) { + int sampcycles = 0, samppos = 0; + int NewBufPos = APU.BufPos; + while (NewBufPos == APU.BufPos) { + NewBufPos = APU.SampleRate * ++APU.Cycles / 1789773; + if (APU.Cycles == 1789773) // we've generated 1 second, so we can reset our counters now + APU.Cycles = NewBufPos = 0; + + Frame_Run(); + Square0_Run(); + Square1_Run(); + Triangle_Run(); + Noise_Run(); + + samppos += Square0.Pos + Square1.Pos + Triangle.Pos + Noise.Pos; + sampcycles++; + } - Frame_Run(); - Square0_Run(); - Square1_Run(); - Triangle_Run(); - Noise_Run(); + APU.BufPos = NewBufPos; - samppos += Square0.Pos + Square1.Pos + Triangle.Pos + Noise.Pos; - sampcycles++; - - if (NewBufPos != APU.BufPos) { - APU.BufPos = NewBufPos; - samppos = (samppos << 6) / sampcycles; - sample_pos = samppos; - sample_ok = true; - samppos = sampcycles = 0; - } + return (samppos << 6) / sampcycles; } } @@ -652,15 +647,12 @@ Player_NES::~Player_NES() { } void Player_NES::setMusicVolume (int vol) { + _maxvol = vol; } int Player_NES::readBuffer(int16 *buffer, const int numSamples) { for (int n = 0; n < numSamples; n++) { - while (!APUe::sample_ok) - APUe::APU_Run(); - - APUe::sample_ok = false; - buffer[n] = APUe::sample_pos; + buffer[n] = APUe::APU_GetSample() * _maxvol / 255; _current_sample++; if (_current_sample == _samples_per_frame) { diff --git a/scumm/player_nes.h b/scumm/player_nes.h index c3132b6fdc..6674ff080a 100644 --- a/scumm/player_nes.h +++ b/scumm/player_nes.h @@ -73,6 +73,7 @@ private: int _sample_rate; int _samples_per_frame; int _current_sample; + int _maxvol; static const int MAXVOLUME = 0x7F; static const int NUMSLOTS = 3; diff --git a/scumm/script_v2.cpp b/scumm/script_v2.cpp index d8657854a7..8696a355be 100644 --- a/scumm/script_v2.cpp +++ b/scumm/script_v2.cpp @@ -519,6 +519,9 @@ void ScummEngine_v2::o2_assignVarByte() { void ScummEngine_v2::o2_setObjPreposition() { int obj = getVarOrDirectWord(PARAM_1); int unk = fetchScriptByte(); + + if (_features & GF_NES) + return; if (whereIsObject(obj) != WIO_NOT_FOUND) { // FIXME: this might not work properly the moment we save and restore the game. @@ -1280,16 +1283,15 @@ void ScummEngine_v2::o2_lights() { c = fetchScriptByte(); if (c == 0) { - if (_gameId == GID_MANIAC && _version == 1) { + if (_gameId == GID_MANIAC && _version == 1 && !(_features & GF_NES)) { // Convert older light mode values into // equivalent values.of later games // 0 Darkness // 1 Flashlight // 2 Lighted area - // 11 and 12 are used by NES version - if (a == 2 || a == 11) + if (a == 2) VAR(VAR_CURRENT_LIGHTS) = 11; - else if (a == 1 || a == 12) + else if (a == 1) VAR(VAR_CURRENT_LIGHTS) = 4; else VAR(VAR_CURRENT_LIGHTS) = 0; @@ -1353,7 +1355,7 @@ void ScummEngine_v2::o2_delay() { delay = 0xFFFFFF - delay; vm.slot[_currentScript].delay = delay; - vm.slot[_currentScript].status = 1; + vm.slot[_currentScript].status = ssPaused; o5_breakHere(); } diff --git a/scumm/script_v5.cpp b/scumm/script_v5.cpp index 57fc2bfefa..513f74c1a8 100644 --- a/scumm/script_v5.cpp +++ b/scumm/script_v5.cpp @@ -1136,7 +1136,7 @@ void ScummEngine_v5::o5_saveLoadGame() { slot = 1; if (a == 1) _opcode = 0x40; - else if (a == 2) + else if ((a == 2) || (_features & GF_NES)) _opcode = 0x80; } else { _opcode = a & 0xE0; |