From 0eb61d0a7d1450ca79adfe8ef4bd3874de51ce67 Mon Sep 17 00:00:00 2001 From: Bendegúz Nagy Date: Tue, 16 Aug 2016 19:15:35 +0200 Subject: DM: Pull sound handling into a separate class --- engines/dm/champion.cpp | 3 +- engines/dm/dm.cpp | 23 ++++++---- engines/dm/dm.h | 40 ++-------------- engines/dm/eventman.cpp | 5 +- engines/dm/group.cpp | 19 ++++---- engines/dm/inventory.cpp | 3 +- engines/dm/menus.cpp | 13 +++--- engines/dm/movesens.cpp | 13 +++--- engines/dm/projexpl.cpp | 9 ++-- engines/dm/sounds.cpp | 116 +++++++++++++++++++++++++---------------------- engines/dm/sounds.h | 80 ++++++++++++++++++++++++++++++++ engines/dm/timeline.cpp | 13 +++--- 12 files changed, 200 insertions(+), 137 deletions(-) create mode 100644 engines/dm/sounds.h 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 #include +#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 _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