diff options
author | Alyssa Milburn | 2011-08-17 09:28:51 +0200 |
---|---|---|
committer | Alyssa Milburn | 2011-08-17 09:28:51 +0200 |
commit | ae287ccee58ebf68ab6125e5bbb4d8a44874330e (patch) | |
tree | 2f4cee4b2940466b8a578962e0174c6f89077a40 /engines/scumm | |
parent | f5255288eabc0527c4c6b727a9db6b8d09a31206 (diff) | |
parent | e36832bbf84cba88fe6b17e1634fab0d550f13df (diff) | |
download | scummvm-rg350-ae287ccee58ebf68ab6125e5bbb4d8a44874330e.tar.gz scummvm-rg350-ae287ccee58ebf68ab6125e5bbb4d8a44874330e.tar.bz2 scummvm-rg350-ae287ccee58ebf68ab6125e5bbb4d8a44874330e.zip |
Merge remote-tracking branch 'origin/master' into soccer
Conflicts:
engines/scumm/he/logic_he.cpp
engines/scumm/he/logic_he.h
Diffstat (limited to 'engines/scumm')
-rw-r--r-- | engines/scumm/cursor.cpp | 77 | ||||
-rw-r--r-- | engines/scumm/he/intern_he.h | 2 | ||||
-rw-r--r-- | engines/scumm/he/logic/basketball.cpp | 105 | ||||
-rw-r--r-- | engines/scumm/player_v2cms.cpp | 39 | ||||
-rw-r--r-- | engines/scumm/player_v2cms.h | 10 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 4 |
6 files changed, 194 insertions, 43 deletions
diff --git a/engines/scumm/cursor.cpp b/engines/scumm/cursor.cpp index a8adb4d5c5..29b5eaedcb 100644 --- a/engines/scumm/cursor.cpp +++ b/engines/scumm/cursor.cpp @@ -22,6 +22,9 @@ #include "common/system.h" #include "common/util.h" #include "graphics/cursorman.h" +#ifdef ENABLE_HE +#include "graphics/wincursor.h" +#endif #include "scumm/bomp.h" #include "scumm/charset.h" #include "scumm/he/intern_he.h" @@ -177,12 +180,8 @@ void ScummEngine_v70he::setDefaultCursor() { 0xff, 0xff, 0xff, 0, 0, 0, }; - if (_bytesPerPixel == 2) { - for (i = 0; i < 1024; i++) - WRITE_UINT16(_grabbedCursor + i * 2, 5); - } else { - memset(_grabbedCursor, 5, sizeof(_grabbedCursor)); - } + + memset(_grabbedCursor, 5, sizeof(_grabbedCursor)); _cursor.hotspotX = _cursor.hotspotY = 2; src = default_he_cursor; @@ -195,16 +194,10 @@ void ScummEngine_v70he::setDefaultCursor() { for (j = 0; j < 32; j++) { switch ((p & (0x3 << 14)) >> 14) { case 1: - if (_bytesPerPixel == 2) - WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[4], palette[5], palette[6])); - else - _grabbedCursor[32 * i + j] = 0xfe; + _grabbedCursor[32 * i + j] = 0xfe; break; case 2: - if (_bytesPerPixel == 2) - WRITE_UINT16(_grabbedCursor + 64 * i + j * 2, get16BitColor(palette[0], palette[1], palette[2])); - else - _grabbedCursor[32 * i + j] = 0xfd; + _grabbedCursor[32 * i + j] = 0xfd; break; default: break; @@ -216,15 +209,61 @@ void ScummEngine_v70he::setDefaultCursor() { } } - if (_bytesPerPixel == 1) { - // Since white color position is not guaranteed - // we setup our own palette if supported by backend - CursorMan.disableCursorPalette(false); - CursorMan.replaceCursorPalette(palette, 0xfd, 3); + // Since white color position is not guaranteed + // we setup our own palette if supported by backend + CursorMan.disableCursorPalette(false); + CursorMan.replaceCursorPalette(palette, 0xfd, 3); + + updateCursor(); +} + +#ifdef ENABLE_HE +void ScummEngine_v80he::setDefaultCursor() { + // v80+ games use the default Windows cursor instead of the usual + // default HE cursor. + Graphics::Cursor *cursor = Graphics::makeDefaultWinCursor(); + + // Clear the cursor + if (_bytesPerPixel == 2) { + for (int i = 0; i < 1024; i++) + WRITE_UINT16(_grabbedCursor + i * 2, 5); + } else { + memset(_grabbedCursor, 5, sizeof(_grabbedCursor)); } + _cursor.width = cursor->getWidth(); + _cursor.height = cursor->getHeight(); + _cursor.hotspotX = cursor->getHotspotX(); + _cursor.hotspotY = cursor->getHotspotY(); + + const byte *surface = cursor->getSurface(); + const byte *palette = cursor->getPalette(); + + for (uint16 y = 0; y < _cursor.height; y++) { + for (uint16 x = 0; x < _cursor.width; x++) { + byte pixel = *surface++; + + if (pixel != cursor->getKeyColor()) { + pixel -= cursor->getPaletteStartIndex(); + + if (_bytesPerPixel == 2) + WRITE_UINT16(_grabbedCursor + (y * _cursor.width + x) * 2, get16BitColor(palette[pixel * 3], palette[pixel * 3 + 1], palette[pixel * 3 + 2])); + else + _grabbedCursor[y * _cursor.width + x] = (pixel == 0) ? 0xfd : 0xfe; + } + } + } + + delete cursor; + + // Since white color position is not guaranteed + // we setup our own palette if supported by backend + CursorMan.disableCursorPalette(false); + CursorMan.replaceCursorPalette(palette, 0xfd, cursor->getPaletteCount() * 3); + updateCursor(); } +#endif void ScummEngine_v6::setCursorFromImg(uint img, uint room, uint imgindex) { int w, h; diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index c49217b650..f4df6571fa 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -383,6 +383,8 @@ protected: void drawLine(int x1, int y1, int x, int unk1, int unk2, int type, int id); void drawPixel(int x, int y, int flags); + virtual void setDefaultCursor(); + /* HE version 80 script opcodes */ void o80_createSound(); void o80_getFileSize(); diff --git a/engines/scumm/he/logic/basketball.cpp b/engines/scumm/he/logic/basketball.cpp index 0a2f99aa90..8352aa4357 100644 --- a/engines/scumm/he/logic/basketball.cpp +++ b/engines/scumm/he/logic/basketball.cpp @@ -35,6 +35,28 @@ public: int versionID(); int32 dispatch(int op, int numArgs, int32 *args); + +private: + int op_1012(); + int op_1050(int32 *args); + int op_1053(); + + // op_1050 loads court object data + enum CourtObjectType { + kObjectTypeBackboard = 1, + kObjectTypeRim = 2, + kObjectTypeOther = 3, + kObjectTypeFloor = 4 + }; + + struct CourtObject { + Common::String name; + CourtObjectType type; + uint32 data[10]; + }; + + Common::Array<CourtObject> _courtObjects; + uint32 _backboardObjectLeft, _backboardObjectRight; }; int LogicHEbasketball::versionID() { @@ -55,12 +77,14 @@ int32 LogicHEbasketball::dispatch(int op, int numArgs, int32 *args) { break; case 1012: + res = op_1012(); break; case 1035: break; case 1050: + res = op_1050(args); break; case 1051: @@ -69,6 +93,10 @@ int32 LogicHEbasketball::dispatch(int op, int numArgs, int32 *args) { case 1052: break; + case 1053: + res = op_1053(); + break; + case 1056: break; @@ -118,6 +146,83 @@ int32 LogicHEbasketball::dispatch(int op, int numArgs, int32 *args) { return res; } +int LogicHEbasketball::op_1012() { + writeScummVar(108, 12000); + writeScummVar(109, 8000); + writeScummVar(110, 760); + writeScummVar(111, 4000); + writeScummVar(112, 1600); + return 1; +} + +int LogicHEbasketball::op_1050(int32 *args) { + // This function loads the court data + static const char *courtNames[] = { + "Dobbaguchi", "Jocindas", "SandyFlats", "Queens", + "Park", "Scheffler", "Polk", "McMillan", + "CrownHill", "Memorial", "TechState", "Garden", + "Moon", "Barn" + }; + + Common::String courtFileName = Common::String::format("data/courts/%s.cof", courtNames[args[0] - 1]); + + Common::File file; + if (!file.open(courtFileName)) + error("Could not open file '%s'", courtFileName.c_str()); + + debug(0, "Loading court data from '%s'", courtFileName.c_str()); + + // First, read in the header + file.readUint32LE(); // Header size (?) + + char version[6]; + file.read(version, 5); + version[5] = 0; + + if (strcmp(version, "01.05")) + error("Invalid court version field: %s", version); + + uint32 objectCount = file.readUint32LE(); + + for (uint32 i = 0; i < objectCount; i++) { + char nameBuf[100]; + memset(nameBuf, 0, sizeof(nameBuf)); + + uint32 nameLength = file.readUint32LE(); + assert(nameLength < sizeof(nameBuf) - 1); + file.read(nameBuf, nameLength); + + CourtObject object; + object.name = nameBuf; + object.type = (CourtObjectType)file.readUint32LE(); + for (uint32 j = 0; j < 10; j++) + object.data[j] = file.readUint32LE(); + + debug(1, "Found court object '%s' - Type %d", nameBuf, object.type); + + // Store backboard object indices for later + if (object.type == kObjectTypeBackboard) { + if (object.data[7] + object.data[4] / 2 >= 6000) + _backboardObjectRight = i; + else + _backboardObjectLeft = i; + } + + _courtObjects.push_back(object); + } + + // TODO: Some other variables are initialized with constants here + + return 1; +} + +int LogicHEbasketball::op_1053() { + _courtObjects.clear(); + // TODO: This also calls op_1065 with one argument (5) + + return 1; +} + LogicHE *makeLogicHEbasketball(ScummEngine_v90he *vm) { return new LogicHEbasketball(vm); } diff --git a/engines/scumm/player_v2cms.cpp b/engines/scumm/player_v2cms.cpp index d16f9d2be7..d4b21774ed 100644 --- a/engines/scumm/player_v2cms.cpp +++ b/engines/scumm/player_v2cms.cpp @@ -36,6 +36,10 @@ Player_V2CMS::Player_V2CMS(ScummEngine *scumm, Audio::Mixer *mixer) _outputTableReady(0), _midiChannel(), _midiChannelUse() { setMusicVolume(255); + memset(_sfxFreq, 0xFF, sizeof(_sfxFreq)); + memset(_sfxAmpl, 0x00, sizeof(_sfxAmpl)); + memset(_sfxOctave, 0x66, sizeof(_sfxOctave)); + _cmsVoices[0].amplitudeOutput = &_cmsChips[0].ampl[0]; _cmsVoices[0].freqOutput = &_cmsChips[0].freq[0]; _cmsVoices[0].octaveOutput = &_cmsChips[0].octave[0]; @@ -596,7 +600,6 @@ void Player_V2CMS::play() { _octaveMask = 0xF0; channel_data *chan = &_channels[0].d; - MusicChip &cms = _cmsChips[0]; byte noiseGen = 3; for (int i = 1; i <= 4; ++i) { @@ -608,8 +611,8 @@ void Player_V2CMS::play() { noiseGen = freq & 0xFF; } else { noiseGen = 3; - cms.freq[0] = cms.freq[3]; - cms.octave[0] = (cms.octave[0] & 0xF0) | ((cms.octave[1] & 0xF0) >> 4); + _sfxFreq[0] = _sfxFreq[3]; + _sfxOctave[0] = (_sfxOctave[0] & 0xF0) | ((_sfxOctave[1] & 0xF0) >> 4); } } else { if (freq == 0) { @@ -635,15 +638,15 @@ void Player_V2CMS::play() { oct |= cmsOct; oct &= _octaveMask; - oct |= (~_octaveMask) & cms.octave[(i & 3) >> 1]; - cms.octave[(i & 3) >> 1] = oct; + oct |= (~_octaveMask) & _sfxOctave[(i & 3) >> 1]; + _sfxOctave[(i & 3) >> 1] = oct; freq >>= -(cmsOct - 9); - cms.freq[i & 3] = (-(freq - 511)) & 0xFF; + _sfxFreq[i & 3] = (-(freq - 511)) & 0xFF; } - cms.ampl[i & 3] = _volumeTable[chan->volume >> 12]; + _sfxAmpl[i & 3] = _volumeTable[chan->volume >> 12]; } else { - cms.ampl[i & 3] = 0; + _sfxAmpl[i & 3] = 0; } chan = &_channels[i].d; @@ -654,25 +657,25 @@ void Player_V2CMS::play() { // the right channels amplitude is set // with the low value the left channels amplitude _cmsEmu->portWrite(0x221, 0); - _cmsEmu->portWrite(0x220, cms.ampl[0]); + _cmsEmu->portWrite(0x220, _sfxAmpl[0]); _cmsEmu->portWrite(0x221, 1); - _cmsEmu->portWrite(0x220, cms.ampl[1]); + _cmsEmu->portWrite(0x220, _sfxAmpl[1]); _cmsEmu->portWrite(0x221, 2); - _cmsEmu->portWrite(0x220, cms.ampl[2]); + _cmsEmu->portWrite(0x220, _sfxAmpl[2]); _cmsEmu->portWrite(0x221, 3); - _cmsEmu->portWrite(0x220, cms.ampl[3]); + _cmsEmu->portWrite(0x220, _sfxAmpl[3]); _cmsEmu->portWrite(0x221, 8); - _cmsEmu->portWrite(0x220, cms.freq[0]); + _cmsEmu->portWrite(0x220, _sfxFreq[0]); _cmsEmu->portWrite(0x221, 9); - _cmsEmu->portWrite(0x220, cms.freq[1]); + _cmsEmu->portWrite(0x220, _sfxFreq[1]); _cmsEmu->portWrite(0x221, 10); - _cmsEmu->portWrite(0x220, cms.freq[2]); + _cmsEmu->portWrite(0x220, _sfxFreq[2]); _cmsEmu->portWrite(0x221, 11); - _cmsEmu->portWrite(0x220, cms.freq[3]); + _cmsEmu->portWrite(0x220, _sfxFreq[3]); _cmsEmu->portWrite(0x221, 0x10); - _cmsEmu->portWrite(0x220, cms.octave[0]); + _cmsEmu->portWrite(0x220, _sfxOctave[0]); _cmsEmu->portWrite(0x221, 0x11); - _cmsEmu->portWrite(0x220, cms.octave[1]); + _cmsEmu->portWrite(0x220, _sfxOctave[1]); _cmsEmu->portWrite(0x221, 0x14); _cmsEmu->portWrite(0x220, 0x3E); _cmsEmu->portWrite(0x221, 0x15); diff --git a/engines/scumm/player_v2cms.h b/engines/scumm/player_v2cms.h index cbad46fe5d..905c7c141e 100644 --- a/engines/scumm/player_v2cms.h +++ b/engines/scumm/player_v2cms.h @@ -50,7 +50,6 @@ public: virtual bool isStereo() const { return true; } private: -#include "common/pack-start.h" // START STRUCT PACKING struct Voice { byte attack; byte decay; @@ -60,7 +59,7 @@ private: int16 vibrato; int16 vibrato2; int16 noise; - } PACKED_STRUCT; + }; struct Voice2 { byte *amplitudeOutput; @@ -105,14 +104,13 @@ private: Voice2 *nextVoice; byte chanNumber; - } PACKED_STRUCT; + }; struct MusicChip { byte ampl[4]; byte freq[4]; byte octave[2]; - } PACKED_STRUCT; -#include "common/pack-end.h" // END STRUCT PACKING + }; Voice _cmsVoicesBase[16]; Voice2 _cmsVoices[8]; @@ -130,6 +128,8 @@ private: int _loadedMidiSong; + byte _sfxFreq[4], _sfxAmpl[4], _sfxOctave[2]; + byte _lastMidiCommand; uint _outputTableReady; byte _voiceTimer; diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 50ae045052..5aded50600 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -1157,7 +1157,9 @@ int ScummEngine::readSoundResource(ResId idx) { // only contains a ROL resource for sound id 60. Formerly we tried // to play that via the AdLib or FM-Towns audio driver resulting // in strange noises. Now we behave like the original did. - if ((_sound->_musicType == MDT_ADLIB || _sound->_musicType == MDT_TOWNS) && pri != 10) + // We make an exception for priority 2 for the Mac output since + // we're doing GM -> AdLib conversion. + if ((_sound->_musicType == MDT_ADLIB || _sound->_musicType == MDT_TOWNS) && pri != 10 && pri != 2) pri = -1; debugC(DEBUG_RESOURCE, " tag: %s, total_size=%d, pri=%d", tag2str(tag), size, pri); |