diff options
author | Bendegúz Nagy | 2016-08-16 19:15:35 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67 (patch) | |
tree | 9aff26bfd1a12daa4efa4148f088fe5989d2ce9c /engines/dm | |
parent | 7cc41a1929c1609cb952517a60bd222cc62d690d (diff) | |
download | scummvm-rg350-0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67.tar.gz scummvm-rg350-0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67.tar.bz2 scummvm-rg350-0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67.zip |
DM: Pull sound handling into a separate class
Diffstat (limited to 'engines/dm')
-rw-r--r-- | engines/dm/champion.cpp | 3 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 23 | ||||
-rw-r--r-- | engines/dm/dm.h | 40 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 5 | ||||
-rw-r--r-- | engines/dm/group.cpp | 19 | ||||
-rw-r--r-- | engines/dm/inventory.cpp | 3 | ||||
-rw-r--r-- | engines/dm/menus.cpp | 13 | ||||
-rw-r--r-- | engines/dm/movesens.cpp | 13 | ||||
-rw-r--r-- | engines/dm/projexpl.cpp | 9 | ||||
-rw-r--r-- | engines/dm/sounds.cpp | 116 | ||||
-rw-r--r-- | engines/dm/sounds.h | 80 | ||||
-rw-r--r-- | engines/dm/timeline.cpp | 13 |
12 files changed, 200 insertions, 137 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 9171d4f2d7..94d20465e6 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -36,6 +36,7 @@ #include "projexpl.h" #include "group.h" #include "movesens.h" +#include "sounds.h" namespace DM { @@ -172,7 +173,7 @@ bool ChampionMan::f328_isObjectThrown(uint16 champIndex, int16 slotIndex, int16 return false; } - _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); f325_decrementStamina(champIndex, f305_getThrowingStaminaCost(curThing)); f330_disableAction(champIndex, 4); int16 experience = 8; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 67e1185179..19003bb7f1 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -57,6 +57,7 @@ #include "dialog.h" #include <graphics/cursorman.h> #include <advancedDetector.h> +#include "sounds.h" namespace DM { void warning(bool repeat, const char* s, ...) { @@ -168,6 +169,7 @@ DMEngine::DMEngine(OSystem *syst, const ADGameDescription *desc) : Engine(syst), _timeline = nullptr; _projexpl = nullptr; _displayMan = nullptr; + _sound = nullptr; _engineShouldQuit = false; _g528_saveFormat = 0; @@ -220,9 +222,9 @@ DMEngine::~DMEngine() { delete _timeline; delete _projexpl; delete _dialog; + delete _sound; - for (uint16 i = 0; i < k34_D13_soundCount; ++i) - delete[] _gK24_soundData[i]._firstSample; + delete[] _savedScreenForOpenEntranceDoors; // clear debug channels @@ -254,7 +256,7 @@ void DMEngine::f463_initializeGame() { _displayMan->f94_loadFloorSet(k0_FloorSetStone); _displayMan->f95_loadWallSet(k0_WallSetStone); - f503_loadSounds(); // @ F0506_AMIGA_AllocateData + _sound->f503_loadSounds(); // @ F0506_AMIGA_AllocateData f437_STARTEND_drawTittle(); _textMan->f54_textInitialize(); @@ -359,6 +361,7 @@ Common::Error DMEngine::run() { _timeline = new Timeline(this); _projexpl = new ProjExpl(this); _dialog = new DialogMan(this); + _sound = new SoundMan(this); _displayMan->setUpScreens(320, 200); f463_initializeGame(); @@ -432,7 +435,7 @@ void DMEngine::f2_gameloop() { } } _eventMan->f363_highlightBoxDisable(); - f65_playPendingSound(); + _sound->f65_playPendingSound(); _championMan->f320_applyAndDrawPendingDamageAndWounds(); if (_championMan->_g303_partyDead) break; @@ -542,7 +545,7 @@ void DMEngine::f441_processEntrance() { } while (_g298_newGame == k202_CommandEntranceDrawCredits); //Strangerke: CHECKME: Earlier versions were using G0566_puc_Graphic534_Sound01Switch - f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40); + _sound->f060_SOUND_Play(k01_soundSWITCH, 112, 0x40, 0x40); f22_delay(20); _eventMan->f78_showMouse(); if (_g298_newGame) @@ -595,7 +598,7 @@ void DMEngine::f444_endGame(bool doNotDrawCreditsOnly) { _eventMan->_g443_primaryKeyboardInput = nullptr; _eventMan->_g444_secondaryKeyboardInput = nullptr; if (doNotDrawCreditsOnly && !_g302_gameWon) { - f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + _sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); f22_delay(240); } @@ -784,7 +787,7 @@ void DMEngine::f438_STARTEND_OpenEntranceDoors() { for (uint16 animStep = 1; animStep < 32; ++animStep) { if ((animStep % 3) == 1) { // Strangerke: CHECKME: Earlier versions of the game were using G0565_puc_Graphic535_Sound02DoorRattle instead of k02_soundDOOR_RATTLE 2 - f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40); + _sound->f060_SOUND_Play(k02_soundDOOR_RATTLE, 145, 0x40, 0x40); } _displayMan->f21_blitToScreen(_savedScreenForOpenEntranceDoors, &screenBox, 160, kM1_ColorNoTransparency, 200); @@ -889,7 +892,7 @@ T0446002: _projexpl->f213_explosionCreate(Thing::_explFireBall, AL1424_i_Attack, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k255_CreatureTypeSingleCenteredCreature); f445_STARTEND_fuseSequenceUpdate(); } - f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized); + _sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized); L1428_ps_Group->_type = k25_CreatureTypeLordOrder; f445_STARTEND_fuseSequenceUpdate(); for (AL1424_i_Attack = 55; AL1424_i_Attack <= 255; AL1424_i_Attack += 40) { @@ -898,7 +901,7 @@ T0446002: } for (AL1425_i_CycleCount = 4; --AL1425_i_CycleCount; ) { for (AL1424_i_CreatureTypeSwitchCount = 5; --AL1424_i_CreatureTypeSwitchCount; ) { - f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized); + _sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L1431_i_LordChaosMapX, L1432_i_LordChaosMapY, k1_soundModePlayIfPrioritized); L1428_ps_Group->_type = (AL1424_i_CreatureTypeSwitchCount & 0x0001) ? k25_CreatureTypeLordOrder : k23_CreatureTypeLordChaos; for (AL1426_i_FuseSequenceUpdateCount = AL1425_i_CycleCount; AL1426_i_FuseSequenceUpdateCount--; f445_STARTEND_fuseSequenceUpdate()); } @@ -957,7 +960,7 @@ T0446002: void DMEngine::f445_STARTEND_fuseSequenceUpdate() { _timeline->f261_processTimeline(); _displayMan->f128_drawDungeon(_dungeonMan->_g308_partyDir, _dungeonMan->_g306_partyMapX, _dungeonMan->_g307_partyMapY); - f65_playPendingSound(); + _sound->f65_playPendingSound(); _eventMan->f357_discardAllInput(); _displayMan->updateScreen(); f22_delay(2); diff --git a/engines/dm/dm.h b/engines/dm/dm.h index 85910eda82..9b39f6ee9a 100644 --- a/engines/dm/dm.h +++ b/engines/dm/dm.h @@ -54,6 +54,7 @@ class GroupMan; class Timeline; class ProjExpl; class DialogMan; +class SoundMan; void warning(bool repeat, const char *s, ...); @@ -202,36 +203,6 @@ struct SaveGameHeader { }; -#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT - -class SoundData { -public: - uint32 _byteCount; - byte* _firstSample; - uint32 _sampleCount; - SoundData(): _byteCount(0), _firstSample(nullptr), _sampleCount(0) {} -}; // @ SOUND_DATA - -class Sound { -public: - int16 _graphicIndex; - byte _period; - byte _priority; - byte _loudDistance; - byte _softDistance; - Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) : - _graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {} -}; // @ Sound - -class PendingSound { -public: - uint8 _leftVolume; - uint8 _rightVolume; - int16 _soundIndex; - PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex): - _leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {} -}; - class DMEngine : public Engine { void f462_startGame(); // @ F0462_START_StartGame_CPSF void f3_processNewPartyMap(uint16 mapIndex); // @ F0003_MAIN_ProcessNewPartyMap_CPSE @@ -243,7 +214,6 @@ class DMEngine : public Engine { void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName); bool readSaveGameHeader(Common::InSaveFile *file, SaveGameHeader *header); void f439_drawEntrance(); // @ F0439_STARTEND_DrawEntrance - void f503_loadSounds(); // @ F0503_SOUND_LoadAll public: explicit DMEngine(OSystem *syst, const ADGameDescription *gameDesc); ~DMEngine(); @@ -262,10 +232,6 @@ public: void f441_processEntrance(); // @ F0441_STARTEND_ProcessEntrance void f444_endGame(bool doNotDrawCreditsOnly); // @ F0444_STARTEND_Endgame - void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD - void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play - void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD - bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume void f438_STARTEND_OpenEntranceDoors(); // @ F0438_STARTEND_OpenEntranceDoors void f437_STARTEND_drawTittle() { warning(false, "STUB METHOD: f437_STARTEND_drawTittle"); }// @ F0437_STARTEND_DrawTitle void f442_SARTEND_processCommand202_entranceDrawCredits(); @@ -280,8 +246,7 @@ private: byte *_g562_entranceDoorAnimSteps[10]; // @ G0562_apuc_Bitmap_EntranceDoorAnimationSteps byte *_g564_interfaceCredits; // @ G0564_puc_Graphic5_InterfaceCredits Common::RandomSource *_rnd; - SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData - Common::Queue<PendingSound> _pendingSounds; + byte *_savedScreenForOpenEntranceDoors; // ad-hoc HACK const ADGameDescription *_gameVersion; public: @@ -299,6 +264,7 @@ public: Timeline *_timeline; ProjExpl *_projexpl; DialogMan *_dialog; + SoundMan *_sound; bool _engineShouldQuit; diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index e4eaa94418..0f7c120f17 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -39,6 +39,7 @@ #include "text.h" #include "group.h" #include "dialog.h" +#include "sounds.h" namespace DM { @@ -940,7 +941,7 @@ void EventManager::f366_commandMoveParty(CommandType cmdType) { damage |= _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(L1125_i_SecondDamagedChampionIndex, 1, k0x0008_ChampionWoundTorso | k0x0010_ChampionWoundLegs, k2_attackType_SELF); if (damage) - _vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, partyMapX, partyMapY, k0_soundModePlayImmediately); } else if (isMovementBlocked = (_vm->_groupMan->f175_groupGetThing(partyMapX, partyMapY) != Thing::_endOfList)) _vm->_groupMan->f209_processEvents29to41(partyMapX, partyMapY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0); } @@ -1075,7 +1076,7 @@ void EventManager::f377_commandProcessType80ClickInDungeonView(int16 posX, int16 Junk *junkPtr = (Junk*)_vm->_dungeonMan->f157_getSquareFirstThingData(L1155_i_MapX, L1156_i_MapY); if ((((Door*)junkPtr)->hasButton()) && _vm->_dungeonMan->_g291_dungeonViewClickableBoxes[k5_ViewCellDoorButtonOrWallOrn].isPointInside(posX, posY - 33)) { _vm->_g321_stopWaitingForPlayerInput = true; - _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); _vm->_moveSens->f268_addEvent(k10_TMEventTypeDoor, L1155_i_MapX, L1156_i_MapY, 0, k2_SensorEffToggle, _vm->_g313_gameTime + 1); return; } diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index e5c74fed74..17cd8d8ee2 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -33,6 +33,7 @@ #include "timeline.h" #include "objectman.h" #include "menus.h" +#include "sounds.h" namespace DM { @@ -147,7 +148,7 @@ void GroupMan::f188_dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThin _vm->_moveSens->f267_getMoveResult(L0365_T_CurrentThing, kM1_MapXNotOnASquare, 0, mapX, mapY); } while ((L0365_T_CurrentThing = L0366_T_NextThing) != Thing::_endOfList); if (mode >= k0_soundModePlayImmediately) { - _vm->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(L0371_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); } } } @@ -258,7 +259,7 @@ void GroupMan::f186_dropCreatureFixedPossessions(uint16 creatureType, int16 mapX L0358_T_Thing = M15_thingWithNewCell(L0358_T_Thing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); _vm->_moveSens->f267_getMoveResult(L0358_T_Thing, kM1_MapXNotOnASquare, 0, mapX, mapY); } - _vm->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(L0362_B_WeaponDropped ? k00_soundMETALLIC_THUD : k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, mapX, mapY, mode); } int16 GroupMan::f228_getDirsWhereDestIsVisibleFromSource(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY) { @@ -890,7 +891,7 @@ T0209089_DoubleSquareMove: AL0450_i_DestinationMapX = eventMapX; AL0451_i_DestinationMapY = eventMapY; AL0450_i_DestinationMapX += _vm->_dirIntoStepCountEast[AL0446_i_Direction] * 2, AL0451_i_DestinationMapY += _vm->_dirIntoStepCountNorth[AL0446_i_Direction] * 2; - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, AL0450_i_DestinationMapX, AL0451_i_DestinationMapY, k1_soundModePlayIfPrioritized); goto T0209061_MoveGroup; } } @@ -1271,7 +1272,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 if (getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) && (L0331_ui_CreatureType == k18_CreatureTypeAnimatedArmourDethKnight)) { if (_vm->getRandomNumber(2)) { toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); - _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); } } else { if (!getFlag(AL0326_ui_Aspect, k0x0080_MaskActiveGroupIsAttacking) || !getFlag(L0327_ui_CreatureGraphicInfo, k0x0400_CreatureInfoGraphicMaskFlipDuringAttack)) { @@ -1293,7 +1294,7 @@ int32 GroupMan::f179_getCreatureAspectUpdateTime(ActiveGroup *activeGroup, int16 toggleFlag(AL0326_ui_Aspect, k0x0040_MaskActiveGroupFlipBitmap); L1635_ui_SoundIndex = _vm->_moveSens->f514_getSound(k13_CreatureTypeCouatl); if (L1635_ui_SoundIndex <= k34_D13_soundCount) { - _vm->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(L1635_ui_SoundIndex, _g378_currentGroupMapX, _g379_currentGroupMapY, k1_soundModePlayIfPrioritized); } } } else { @@ -1487,7 +1488,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui AL0440_i_KineticEnergy = (L0441_ps_CreatureInfo->_attack >> 2) + 1; AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); AL0440_i_KineticEnergy += _vm->getRandomNumber(AL0440_i_KineticEnergy); - _vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, mapX, mapY, k0_soundModePlayImmediately); _vm->_projexpl->f212_projectileCreate(Thing(AL0437_T_Thing), mapX, mapY, AL0439_i_TargetCell, (Direction)_g382_currGroupPrimaryDirToParty, f26_getBoundedValue((int16)20, AL0440_i_KineticEnergy, (int16)255), L0441_ps_CreatureInfo->_dexterity, 8); } else { if (getFlag(L0441_ps_CreatureInfo->_attributes, k0x0010_MaskCreatureInfo_attackAnyChamp)) { @@ -1515,7 +1516,7 @@ bool GroupMan::f207_isCreatureAttacking(Group *group, int16 mapX, int16 mapY, ui } } if (AL0440_i_AttackSoundOrdinal = L0441_ps_CreatureInfo->_attackSoundOrdinal) { - _vm->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(G0244_auc_Graphic559_CreatureAttackSounds[--AL0440_i_AttackSoundOrdinal], mapX, mapY, k1_soundModePlayIfPrioritized); } return true; } @@ -1638,7 +1639,7 @@ int16 GroupMan::f230_getChampionDamage(Group *group, uint16 champIndex) { AL0558_i_Attack -= _vm->getRandomNumber((AL0558_i_Attack >> 1) + 1) - 1; } if (AL0558_i_Damage = _vm->_championMan->f321_addPendingDamageAndWounds_getDamage(champIndex, AL0558_i_Attack, AL0561_ui_AllowedWound, L0564_s_CreatureInfo._attackType)) { - _vm->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k09_soundCHAMPION_0_DAMAGED + champIndex, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); if ((AL0559_ui_PoisonAttack = L0564_s_CreatureInfo._poisonAttack) && _vm->getRandomNumber(2) && ((AL0559_ui_PoisonAttack = _vm->_championMan->f307_getStatisticAdjustedAttack(L0562_ps_Champion, k4_ChampionStatVitality, AL0559_ui_PoisonAttack)) >= 0)) { _vm->_championMan->f322_championPoison(champIndex, AL0559_ui_PoisonAttack); } @@ -1807,7 +1808,7 @@ Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplie if (_vm->_moveSens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ return Thing::_none; } - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, mapX, mapY, k1_soundModePlayIfPrioritized); return L0349_T_GroupThing; } diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp index bbc451daee..638fba2bf0 100644 --- a/engines/dm/inventory.cpp +++ b/engines/dm/inventory.cpp @@ -34,6 +34,7 @@ #include "objectman.h" #include "timeline.h" #include "projexpl.h" +#include "sounds.h" namespace DM { @@ -1038,7 +1039,7 @@ void InventoryMan::f349_processCommand70_clickOnMouth() { _vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._load += _vm->_dungeonMan->f140_getObjectWeight(L1078_T_Thing) - L1089_ui_Weight; setFlag(_vm->_championMan->_gK71_champions[_vm->_championMan->_g411_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad); } - _vm->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k08_soundSWALLOW, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics); if (_g424_panelContent == k0_PanelContentFoodWaterPoisoned) { setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel); diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 73a567a08a..53d504096e 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -37,6 +37,7 @@ #include "movesens.h" #include "group.h" #include "projexpl.h" +#include "sounds.h" namespace DM { @@ -1116,10 +1117,10 @@ T0407014: case k13_ChampionActionSwing: case k2_ChampionActionChop: if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) { - _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); L1249_ui_ActionDisabledTicks = 6; _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2); - _vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k2_soundModePlayOneTickLater); break; } case k24_ChampionActionDisrupt: @@ -1145,10 +1146,10 @@ T0407014: case k41_ChampionActionBrandish: case k4_ChampionActionBlowHorn: if (actionIndex == k8_ChampionActionWarCry) { - _vm->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); } if (actionIndex == k4_ChampionActionBlowHorn) { - _vm->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately); } AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY); break; @@ -1178,7 +1179,7 @@ T0407032: f406_setChampionDirectionToPartyDirection(L1247_ps_Champion); { // so gotos won't skip init Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand); - _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); _vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy); } break; @@ -1451,7 +1452,7 @@ bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int #define AL1237_ui_ActionHitProbability L1237_ui_Multiple int16 L1238_i_CreatureOrdinal; - _vm->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); if (_g517_actionTargetGroupThing == Thing::_endOfList) goto T0402010; if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) { diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index 1011b4240c..57bd51f6af 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -35,6 +35,7 @@ #include "group.h" #include "projexpl.h" #include "text.h" +#include "sounds.h" namespace DM { @@ -181,7 +182,7 @@ bool MovesensMan::f275_sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, ui if (!L0753_B_DoNotTriggerSensor) { L0759_B_AtLeastOneSensorWasTriggered = true; if (L0755_ps_Sensor->getAudibleA()) { - _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k1_soundModePlayIfPrioritized); } if (!_vm->_championMan->_g415_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) { L0754_ps_Generic = (Thing *)_vm->_dungeonMan->f156_getThingData(L0761_T_LeaderHandObject); @@ -299,7 +300,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 _vm->_dungeonMan->_g306_partyMapX = destMapX; _vm->_dungeonMan->_g307_partyMapY = destMapY; if (L0712_ps_Teleporter->isAudible()) { - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); } L0723_B_DrawDungeonViewWhileFalling = true; if (L0712_ps_Teleporter->getAbsoluteRotation()) { @@ -310,7 +311,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } else { if (L0710_i_ThingType == k4_GroupThingType) { if (L0712_ps_Teleporter->isAudible()) { - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized); } L0720_ui_MoveGroupResult = f262_getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource); } else { @@ -352,7 +353,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } } else { if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) { - _vm->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k06_soundSCREAM, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, k0_soundModePlayImmediately); } } } @@ -480,7 +481,7 @@ bool MovesensMan::f267_getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 } L1638_ui_MovementSoundIndex = f514_getSound(((Group *)_vm->_dungeonMan->_g284_thingData[k4_GroupThingType])[thing.getIndex()]._type); if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) { - _vm->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized); } if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_g309_partyMapIndex)) { /* If the group leaves the party map */ _vm->_groupMan->f184_removeActiveGroup(AL0708_i_ActiveGroupIndex); @@ -898,7 +899,7 @@ void MovesensMan::f276_sensorProcessThingAdditionOrRemoval(uint16 mapX, uint16 m goto T0276079; } if (L0769_ps_Sensor->getAudibleA()) { - _vm->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized); } f272_sensorTriggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around goto T0276079; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index 937e144e25..b65e03a3c6 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -32,6 +32,7 @@ #include "group.h" #include "objectman.h" #include "movesens.h" +#include "sounds.h" namespace DM { @@ -230,7 +231,7 @@ T0217004: AL0507_ui_SoundIndex = k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM; } } - _vm->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(AL0507_ui_SoundIndex, L0499_i_ProjectileMapX, L0500_i_ProjectileMapY, k1_soundModePlayIfPrioritized); } T0217044: if (L0509_B_RemovePotion) { @@ -321,10 +322,10 @@ void ProjExpl::f213_explosionCreate(Thing explThing, uint16 attack, uint16 mapXC L0470_ps_Explosion->setType(explThing.toUint16() - Thing::_firstExplosion.toUint16()); L0470_ps_Explosion->setAttack(attack); if (explThing.toUint16() < Thing::_explHarmNonMaterial.toUint16()) { - _vm->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD((attack > 80) ? k05_soundSTRONG_EXPLOSION : k20_soundWEAK_EXPLOSION, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); } else { if (explThing != Thing::_explSmoke) { - _vm->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k13_soundSPELL, AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY, k1_soundModePlayIfPrioritized); } } _vm->_dungeonMan->f163_linkThingToList(L0473_T_Thing, Thing(0), AP0443_ui_ProjectileMapX, AP0444_ui_ProjectileMapY); @@ -564,7 +565,7 @@ void ProjExpl::f220_explosionProcessEvent25_explosion(TimelineEvent* event) { break; case 0xFFE4: L0532_ps_Explosion->setType(L0532_ps_Explosion->getType() + 1); - _vm->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k05_soundSTRONG_EXPLOSION, L0528_ui_MapX, L0529_ui_MapY, k1_soundModePlayIfPrioritized); goto T0220026; case 0xFFA8: if (L0532_ps_Explosion->getAttack() > 55) { diff --git a/engines/dm/sounds.cpp b/engines/dm/sounds.cpp index b44e97b2bf..c90409da60 100644 --- a/engines/dm/sounds.cpp +++ b/engines/dm/sounds.cpp @@ -33,80 +33,86 @@ #include <audio/mixer.h> #include "timeline.h" #include "dungeonman.h" +#include "sounds.h" namespace DM { +SoundMan::SoundMan(DMEngine* vm) : _vm(vm) {} +SoundMan::~SoundMan() { + for (uint16 i = 0; i < k34_D13_soundCount; ++i) + delete[] _gK24_soundData[i]._firstSample; +} Sound g60_sounds[k34_D13_soundCount] = { - Sound(533, 112, 11, 3, 6), /* k00_soundMETALLIC_THUD 0 */ - Sound(534, 112, 15, 0, 3), /* k01_soundSWITCH 1 */ - Sound(535, 112, 72, 3, 6), /* k02_soundDOOR_RATTLE 2 */ - Sound(550, 112, 60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */ - Sound(536, 112, 10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */ - Sound(537, 112, 99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */ - Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */ - Sound(551, 112, 55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */ - Sound(540, 112, 2, 3, 6), /* k08_soundSWALLOW 8 */ - Sound(541, 112, 80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */ - Sound(542, 112, 82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */ - Sound(543, 112, 84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */ - Sound(544, 112, 86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */ - Sound(545, 112, 95, 3, 6), /* k13_soundSPELL 13 */ - Sound(552, 112, 57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */ - Sound(553, 112, 52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */ - Sound(546, 112, 40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */ - Sound(547, 112, 70, 1, 4), /* k17_soundBUZZ 17 */ - Sound(549, 138, 75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */ - Sound(554, 112, 50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */ - Sound(537, 112, 98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */ - Sound(555, 112, 96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */ - Sound(563, 138, 24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */ - Sound(564, 138, 21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */ - Sound(565, 138, 23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */ - Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */ - Sound(567, 138, 27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */ - Sound(568, 138, 28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */ - Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */ - Sound(570, 138, 56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */ - Sound(571, 138, 58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */ - Sound(572, 112, 53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */ - Sound(573, 138, 29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */ - Sound(574, 150, 22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */ - -void DMEngine::f503_loadSounds() { +Sound(533, 112, 11, 3, 6), /* k00_soundMETALLIC_THUD 0 */ +Sound(534, 112, 15, 0, 3), /* k01_soundSWITCH 1 */ +Sound(535, 112, 72, 3, 6), /* k02_soundDOOR_RATTLE 2 */ +Sound(550, 112, 60, 3, 5), /* k03_soundATTACK_PAIN_RAT_HELLHOUND_RED_DRAGON 3 */ +Sound(536, 112, 10, 3, 6), /* k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM 4 */ +Sound(537, 112, 99, 3, 7), /* k05_soundSTRONG_EXPLOSION 5 */ +Sound(539, 112, 110, 3, 6), /* k06_soundSCREAM 6 */ +Sound(551, 112, 55, 3, 5), /* k07_soundATTACK_MUMMY_GHOST_RIVE 7 */ +Sound(540, 112, 2, 3, 6), /* k08_soundSWALLOW 8 */ +Sound(541, 112, 80, 3, 6), /* k09_soundCHAMPION_0_DAMAGED 9 */ +Sound(542, 112, 82, 3, 6), /* k10_soundCHAMPION_1_DAMAGED 10 */ +Sound(543, 112, 84, 3, 6), /* k11_soundCHAMPION_2_DAMAGED 11 */ +Sound(544, 112, 86, 3, 6), /* k12_soundCHAMPION_3_DAMAGED 12 */ +Sound(545, 112, 95, 3, 6), /* k13_soundSPELL 13 */ +Sound(552, 112, 57, 3, 5), /* k14_soundATTACK_SCREAMER_OITU 14 */ +Sound(553, 112, 52, 3, 5), /* k15_soundATTACK_GIANT_SCORPION_SCORPION 15 */ +Sound(546, 112, 40, 2, 4), /* k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT 16 */ +Sound(547, 112, 70, 1, 4), /* k17_soundBUZZ 17 */ +Sound(549, 138, 75, 3, 6), /* k18_soundPARTY_DAMAGED 18 */ +Sound(554, 112, 50, 3, 5), /* k19_soundATTACK_MAGENTA_WORM_WORM 19 */ +Sound(537, 112, 98, 0, 4), /* k20_soundWEAK_EXPLOSION 20 */ +Sound(555, 112, 96, 2, 4), /* k21_soundATTACK_GIGGLER 21 */ +Sound(563, 138, 24, 0, 4), /* k22_soundMOVE_ANIMATED_ARMOUR_DETH_KNIGHT 22 Atari ST: not present */ +Sound(564, 138, 21, 0, 4), /* k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER 23 Atari ST: not present */ +Sound(565, 138, 23, 0, 4), /* k24_soundMOVE_MUMMY_TROLIN_ANTMAN_STONE_GOLEM_GIGGLER_VEXIRK_DEMON 24 Atari ST: not present */ +Sound(566, 138, 105, 0, 4), /* k25_soundBLOW_HORN 25 Atari ST: not present */ +Sound(567, 138, 27, 0, 4), /* k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU 26 Atari ST: not present */ +Sound(568, 138, 28, 0, 4), /* k27_soundMOVE_SWAMP_SLIME_SLIME_DEVIL_WATER_ELEMENTAL 27 Atari ST: not present */ +Sound(569, 138, 106, 0, 4), /* k28_soundWAR_CRY 28 Atari ST: not present */ +Sound(570, 138, 56, 0, 4), /* k29_soundATTACK_ROCK_ROCKPILE 29 Atari ST: not present */ +Sound(571, 138, 58, 0, 4), /* k30_soundATTACK_WATER_ELEMENTAL 30 Atari ST: not present */ +Sound(572, 112, 53, 0, 4), /* k31_soundATTACK_COUATL 31 Atari ST: not present */ +Sound(573, 138, 29, 0, 4), /* k32_soundMOVE_RED_DRAGON 32 Atari ST: not present */ +Sound(574, 150, 22, 0, 4)}; /* k33_soundMOVE_SKELETON 33 Atari ST: not present */ + +void SoundMan::f503_loadSounds() { for (uint16 soundIndex = 0; soundIndex < k34_D13_soundCount; ++soundIndex) { SoundData *soundData = _gK24_soundData + soundIndex; uint16 graphicIndex = g60_sounds[soundIndex]._graphicIndex; - soundData->_byteCount = _displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long + soundData->_byteCount = _vm->_displayMan->getCompressedDataSize(graphicIndex) - 2; // the header is 2 bytes long soundData->_firstSample = new byte[soundData->_byteCount]; - Common::MemoryReadStream stream = _displayMan->getCompressedData(graphicIndex); + Common::MemoryReadStream stream = _vm->_displayMan->getCompressedData(graphicIndex); soundData->_sampleCount = stream.readUint16BE(); stream.read(soundData->_firstSample, soundData->_byteCount); } } -void DMEngine::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) { +void SoundMan::f060_SOUND_Play(uint16 soundIndex, uint16 period, uint8 leftVolume, uint8 rightVolume) { SoundData *sound = &_gK24_soundData[soundIndex]; Audio::AudioStream *stream = Audio::makeRawStream(sound->_firstSample, sound->_byteCount, (72800 / period) * 8, 0, DisposeAfterUse::NO); signed char balance = ((int16)rightVolume - (int16)leftVolume) / 2; Audio::SoundHandle handle; - _mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance); + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, stream, -1, 127, balance); } -void DMEngine::f65_playPendingSound() { +void SoundMan::f65_playPendingSound() { while (!_pendingSounds.empty()) { PendingSound pendingSound = _pendingSounds.pop(); f060_SOUND_Play(pendingSound._soundIndex, g60_sounds[pendingSound._soundIndex]._period, pendingSound._leftVolume, pendingSound._rightVolume); } } -bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) { +bool SoundMan::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, uint8* rightVolume) { static byte K0030_aauc_DistanceToSoundVolume[25][25] = { {1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4}, {1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 5, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4}, @@ -139,22 +145,22 @@ bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui int16 L1680_i_LeftVolumeColumnIndex = 0; - switch (_dungeonMan->_g308_partyDir) { + switch (_vm->_dungeonMan->_g308_partyDir) { case kDirNorth: - L1678_i_RightVolumeColumnIndex = mapX - _dungeonMan->_g306_partyMapX; - L1679_i_LineIndex = mapY - _dungeonMan->_g307_partyMapY; + L1678_i_RightVolumeColumnIndex = mapX - _vm->_dungeonMan->_g306_partyMapX; + L1679_i_LineIndex = mapY - _vm->_dungeonMan->_g307_partyMapY; break; case kDirEast: - L1678_i_RightVolumeColumnIndex = mapY - _dungeonMan->_g307_partyMapY; - L1679_i_LineIndex = -(mapX - _dungeonMan->_g306_partyMapX); + L1678_i_RightVolumeColumnIndex = mapY - _vm->_dungeonMan->_g307_partyMapY; + L1679_i_LineIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX); break; case kDirSouth: - L1678_i_RightVolumeColumnIndex = -(mapX - _dungeonMan->_g306_partyMapX); - L1679_i_LineIndex = -(mapY - _dungeonMan->_g307_partyMapY); + L1678_i_RightVolumeColumnIndex = -(mapX - _vm->_dungeonMan->_g306_partyMapX); + L1679_i_LineIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY); break; case kDirWest: - L1678_i_RightVolumeColumnIndex = -(mapY - _dungeonMan->_g307_partyMapY); - L1679_i_LineIndex = mapX - _dungeonMan->_g306_partyMapX; + L1678_i_RightVolumeColumnIndex = -(mapY - _vm->_dungeonMan->_g307_partyMapY); + L1679_i_LineIndex = mapX - _vm->_dungeonMan->_g306_partyMapX; break; } if ((L1678_i_RightVolumeColumnIndex < -12) || (L1678_i_RightVolumeColumnIndex > 12)) { /* Sound is not audible if source is more than 12 squares away from the party */ @@ -171,23 +177,23 @@ bool DMEngine::f505_soundGetVolume(int16 mapX, int16 mapY, uint8* leftVolume, ui return true; } -void DMEngine::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) { +void SoundMan::f064_SOUND_RequestPlay_CPSD(uint16 soundIndex, int16 mapX, int16 mapY, uint16 mode) { Sound* sound; uint8 leftVolume, rightVolume; - if (mode && (_dungeonMan->_g272_currMapIndex != _dungeonMan->_g309_partyMapIndex)) + if (mode && (_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex)) return; sound = &g60_sounds[soundIndex]; if (mode > k1_soundModePlayIfPrioritized) { /* Add an event in the timeline to play the sound (mode - 1) ticks later */ TimelineEvent event; - M33_setMapAndTime(event._mapTime, _dungeonMan->_g272_currMapIndex, _g313_gameTime + mode - 1); + M33_setMapAndTime(event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + mode - 1); event._type = k20_TMEventTypePlaySound; event._priority = sound->_priority; event._C._soundIndex = soundIndex; event._B._location._mapX = mapX; event._B._location._mapY = mapY; - _timeline->f238_addEventGetEventIndex(&event); + _vm->_timeline->f238_addEventGetEventIndex(&event); return; } diff --git a/engines/dm/sounds.h b/engines/dm/sounds.h new file mode 100644 index 0000000000..b3add4a423 --- /dev/null +++ b/engines/dm/sounds.h @@ -0,0 +1,80 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +/* +* Based on the Reverse Engineering work of Christophe Fontanel, +* maintainer of the Dungeon Master Encyclopaedia (http://dmweb.free.fr/) +*/ + +#include "dm.h" + +namespace DM { + +#define k34_D13_soundCount 34 // @ D13_SOUND_COUNT + +class SoundData { +public: + uint32 _byteCount; + byte* _firstSample; + uint32 _sampleCount; + SoundData() : _byteCount(0), _firstSample(nullptr), _sampleCount(0) {} +}; // @ SOUND_DATA + +class Sound { +public: + int16 _graphicIndex; + byte _period; + byte _priority; + byte _loudDistance; + byte _softDistance; + Sound(int16 index, byte period, byte priority, byte loudDist, byte softDist) : + _graphicIndex(index), _period(period), _priority(priority), _loudDistance(loudDist), _softDistance(softDist) {} +}; // @ Sound + +class PendingSound { +public: + uint8 _leftVolume; + uint8 _rightVolume; + int16 _soundIndex; + PendingSound(uint8 leftVolume, uint8 rightVolume, int16 soundIndex) : + _leftVolume(leftVolume), _rightVolume(rightVolume), _soundIndex(soundIndex) {} +}; + + +class SoundMan { + DMEngine *_vm; + +public: + SoundMan(DMEngine* vm); + ~SoundMan(); + + SoundData _gK24_soundData[k34_D13_soundCount]; // @ K0024_as_SoundData + Common::Queue<PendingSound> _pendingSounds; + + void f503_loadSounds(); // @ F0503_SOUND_LoadAll + void f064_SOUND_RequestPlay_CPSD(uint16 P0088_ui_SoundIndex, int16 P0089_i_MapX, int16 P0090_i_MapY, uint16 P0091_ui_Mode); // @ F0064_SOUND_RequestPlay_CPSD + void f060_SOUND_Play(uint16 P0921_ui_SoundIndex, uint16 P0085_i_Period, uint8 leftVol, uint8 rightVol); // @ F0060_SOUND_Play + void f65_playPendingSound(); // @ F0065_SOUND_PlayPendingSound_CPSD + bool f505_soundGetVolume(int16 mapX, int16 mapY, uint8 *leftVolume, uint8 *rightVolume); // @ F0505_SOUND_GetVolume +}; + +}
\ No newline at end of file diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 6e5f4827da..3d88e43383 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -35,6 +35,7 @@ #include "text.h" #include "eventman.h" #include "objectman.h" +#include "sounds.h" namespace DM { @@ -318,7 +319,7 @@ void Timeline::f261_processTimeline() { f246_timelineProcesEvent65_enableGroupGenerator(L0681_ps_Event); break; case k20_TMEventTypePlaySound: - _vm->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(L0682_s_Event._C._soundIndex, L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, k1_soundModePlayIfPrioritized); break; case k24_TMEventTypeRemoveFluxcage: if (!_vm->_g302_gameWon) { @@ -420,7 +421,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { // Original bug fixed - A closing horizontal door wounds champions to the head instead of to the hands. Missing parenthesis in the condition cause all doors to wound the head in addition to the torso // See BUG0_78 if (_vm->_championMan->f324_damageAll_getDamagedChampionCount(5, k0x0008_ChampionWoundTorso | (AL0602_ui_VerticalDoor ? k0x0004_ChampionWoundHead : k0x0001_ChampionWoundReadHand | k0x0002_ChampionWoundActionHand), k2_attackType_SELF)) { - _vm->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k18_soundPARTY_DAMAGED, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); } } event->_mapTime++; @@ -434,7 +435,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { } L0596_i_DoorState = (L0596_i_DoorState == k0_doorState_OPEN) ? k0_doorState_OPEN : (L0596_i_DoorState - 1); L0597_puc_Square->setDoorState(L0596_i_DoorState); - _vm->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); event->_mapTime++; f238_addEventGetEventIndex(event); return; @@ -446,7 +447,7 @@ void Timeline::f241_timelineProcessEvent1_doorAnimation(TimelineEvent* event) { } L0596_i_DoorState += (L0595_i_Effect == k0_SensorEffSet) ? -1 : 1; L0597_puc_Square->setDoorState(L0596_i_DoorState); - _vm->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k02_soundDOOR_RATTLE, L0593_ui_MapX, L0594_ui_MapY, k1_soundModePlayIfPrioritized); if (L0595_i_Effect == k0_SensorEffSet) { if (L0596_i_DoorState == k0_doorState_OPEN) { @@ -838,7 +839,7 @@ void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { } _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (Direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); if (L0614_ps_Sensor->getAudibleA()) { - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0616_ui_MapX, L0617_ui_MapY, k1_soundModePlayIfPrioritized); } if (L0614_ps_Sensor->getOnlyOnce()) { L0614_ps_Sensor->setTypeDisabled(); @@ -878,7 +879,7 @@ void Timeline::f252_timelineProcessEvents60to61_moveGroup(TimelineEvent* event) T0252001: if (((_vm->_dungeonMan->_g272_currMapIndex != _vm->_dungeonMan->_g309_partyMapIndex) || (L0656_ui_MapX != _vm->_dungeonMan->_g306_partyMapX) || (L0657_ui_MapY != _vm->_dungeonMan->_g307_partyMapY)) && (_vm->_groupMan->f175_groupGetThing(L0656_ui_MapX, L0657_ui_MapY) == Thing::_endOfList)) { /* BUG0_24 Lord Chaos may teleport into one of the Black Flames and become invisible until the Black Flame is killed. In this case, _vm->_groupMan->f175_groupGetThing returns the Black Flame thing and the Lord Chaos thing is not moved into the dungeon until the Black Flame is killed */ if (event->_type == k61_TMEventTypeMoveGroupAudible) { - _vm->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized); + _vm->_sound->f064_SOUND_RequestPlay_CPSD(k17_soundBUZZ, L0656_ui_MapX, L0657_ui_MapY, k1_soundModePlayIfPrioritized); } _vm->_moveSens->f267_getMoveResult(Thing(event->_C._slot), kM1_MapXNotOnASquare, 0, L0656_ui_MapX, L0657_ui_MapY); } else { |