comparison AudioPlayer.cpp @ 379:5bea494a2365

AudioPlayer::UpdateSounds (004AAFCF) take 2
author Nomad
date Fri, 22 Feb 2013 22:26:51 +0200
parents 50875632e776
children d95a91011d57 7189d0bddf07
comparison
equal deleted inserted replaced
378:50875632e776 379:5bea494a2365
605 v6 = v2->pMixerChannels; 605 v6 = v2->pMixerChannels;
606 do 606 do
607 { 607 {
608 if ( v6->source_pid == a2 ) 608 if ( v6->source_pid == a2 )
609 { 609 {
610 if ( AIL_sample_status(v6->hSample) == 4 ) 610 if ( AIL_sample_status(v6->hSample) == AIL::Sample::Playing)
611 { 611 {
612 AIL_end_sample(v6->hSample); 612 AIL_end_sample(v6->hSample);
613 _4ABE55(v6); 613 _4ABE55(v6);
614 } 614 }
615 } 615 }
621 } 621 }
622 } 622 }
623 } 623 }
624 } 624 }
625 } 625 }
626 // 4D82F4: using guessed type int __stdcall AIL_3D_sample_status(int);
627 // 4D82F8: using guessed type int __stdcall AIL_sample_status(int);
628 // 4D82FC: using guessed type int __stdcall AIL_end_sample(int);
629 // 4D8300: using guessed type int __stdcall AIL_end_3D_sample(int);
630 626
631 //----- (004AA306) -------------------------------------------------------- 627 //----- (004AA306) --------------------------------------------------------
632 void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate) 628 void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate)
633 { 629 {
634 //AudioPlayer *pAudioPlayer1; // esi@1 630 //AudioPlayer *pAudioPlayer1; // esi@1
781 if ( pAudioPlayer->uMixerChannels > 0 ) 777 if ( pAudioPlayer->uMixerChannels > 0 )
782 { 778 {
783 pMixerChannel = pAudioPlayer->pMixerChannels; 779 pMixerChannel = pAudioPlayer->pMixerChannels;
784 do 780 do
785 { 781 {
786 if ( AIL_sample_status(pMixerChannel->hSample) == 4 && pMixerChannel->source_pid == a3 782 if ( AIL_sample_status(pMixerChannel->hSample) == AIL::Sample::Playing && pMixerChannel->source_pid == a3
787 && AIL_sample_status(pMixerChannel->hSample) == 4 ) 783 && AIL_sample_status(pMixerChannel->hSample) == AIL::Sample::Playing)
788 { 784 {
789 if ( pMixerChannel->uSourceTrackIdx == pNum ) 785 if ( pMixerChannel->uSourceTrackIdx == pNum )
790 return; 786 return;
791 AIL_end_sample(pMixerChannel->hSample); 787 AIL_end_sample(pMixerChannel->hSample);
792 _4ABE55(pMixerChannel); 788 _4ABE55(pMixerChannel);
802 v62 = varC; 798 v62 = varC;
803 //pAudioPlayer4 = pAudioPlayer; 799 //pAudioPlayer4 = pAudioPlayer;
804 if ( varC <= v96 ) 800 if ( varC <= v96 )
805 { 801 {
806 pMixerChannel2 = &pAudioPlayer->pMixerChannels[varC]; 802 pMixerChannel2 = &pAudioPlayer->pMixerChannels[varC];
807 while ( AIL_sample_status(pMixerChannel2->hSample) != 2 ) 803 while ( AIL_sample_status(pMixerChannel2->hSample) != AIL::Sample::Done)
808 { 804 {
809 ++v62; 805 ++v62;
810 ++pMixerChannel2; 806 ++pMixerChannel2;
811 if ( v62 > v96 ) 807 if ( v62 > v96 )
812 goto LABEL_140; 808 goto LABEL_140;
1384 //LayingItem *v37; // edi@53 1380 //LayingItem *v37; // edi@53
1385 int v38; // eax@53 1381 int v38; // eax@53
1386 //BLVDoor *v39; // edi@56 1382 //BLVDoor *v39; // edi@56
1387 //int v40; // eax@57 1383 //int v40; // eax@57
1388 //int v41; // eax@60 1384 //int v41; // eax@60
1389 MixerChannel *v42; // edi@65 1385 //MixerChannel *v42; // edi@65
1390 int v43; // ebx@68 1386 //int v43; // ebx@68
1391 LevelDecoration *v44; // esi@68 1387 //LevelDecoration *v44; // esi@68
1392 int v45; // ST1C_4@68 1388 //int v45; // ST1C_4@68
1393 int v46; // edi@68 1389 //int v46; // edi@68
1394 int v47; // eax@68 1390 //int v47; // eax@68
1395 DecorationDesc *v48; // edi@69 1391 //DecorationDesc *v48; // edi@69
1396 __int16 v49; // ax@69 1392 //__int16 v49; // ax@69
1397 __int16 v50; // ax@70 1393 //__int16 v50; // ax@70
1398 __int16 v51; // ax@71 1394 __int16 v51; // ax@71
1399 __int16 v52; // ax@73 1395 //__int16 v52; // ax@73
1400 signed int v53; // eax@88 1396 signed int v53; // eax@88
1401 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1 1397 RenderVertexSoft a1; // [sp+24h] [bp-48h]@1
1402 float v55; // [sp+54h] [bp-18h]@22 1398 float v55; // [sp+54h] [bp-18h]@22
1403 float v56; // [sp+58h] [bp-14h]@22 1399 float v56; // [sp+58h] [bp-14h]@22
1404 int uNumRepeats; // [sp+5Ch] [bp-10h]@15 1400 int uNumRepeats; // [sp+5Ch] [bp-10h]@15
1584 1580
1585 AIL_end_sample(channel->hSample); 1581 AIL_end_sample(channel->hSample);
1586 _4ABE55(channel); 1582 _4ABE55(channel);
1587 } 1583 }
1588 1584
1589 //v59 = 0;
1590 for (uint i = 0; i < uMixerChannels; ++i) 1585 for (uint i = 0; i < uMixerChannels; ++i)
1591 { 1586 {
1592 //v30 = pAudioPlayer->pMixerChannels;
1593 auto channel = pMixerChannels + i; 1587 auto channel = pMixerChannels + i;
1594 //while ( 1 )
1595 //{
1596 //v31 = v30->dword_000004;
1597 int source_type = channel->source_pid & 7, 1588 int source_type = channel->source_pid & 7,
1598 source_id = channel->source_pid >> 3; 1589 source_id = channel->source_pid >> 3;
1599 int source_x, 1590 int source_x,
1600 source_y, 1591 source_y,
1601 source_z; 1592 source_z;
1620 source_z = door->pZOffsets[0]; 1611 source_z = door->pZOffsets[0];
1621 } 1612 }
1622 break; 1613 break;
1623 1614
1624 case OBJECT_Item: 1615 case OBJECT_Item:
1625 case OBJECT_Decoration: 1616 {
1626 { 1617 assert(source_id < uNumLayingItems);
1627 LayingItem *object = nullptr; 1618 auto object = &pLayingItems[source_id];
1628 if (source_type == OBJECT_Item)
1629 {
1630 assert(source_id < uNumLayingItems);
1631 object = &pLayingItems[source_id];
1632 }
1633 else
1634 {
1635 assert(source_id < uNumLevelDecorations);
1636 object = (LayingItem *)&pLevelDecorations[source_id];
1637 }
1638 1619
1639 source_x = object->vPosition.x; 1620 source_x = object->vPosition.x;
1640 source_y = object->vPosition.y; 1621 source_y = object->vPosition.y;
1641 source_z = object->vPosition.z; 1622 source_z = object->vPosition.z;
1642 } 1623 }
1643 break; 1624 break;
1644 1625
1626 case OBJECT_Decoration:
1627 {
1628 assert(source_id < uNumLevelDecorations);
1629 auto object = (LayingItem *)&pLevelDecorations[source_id];
1630
1631 source_x = object->vPosition.x;
1632 source_y = object->vPosition.y;
1633 source_z = object->vPosition.z;
1634 }
1635 break;
1636
1645 case OBJECT_Actor: 1637 case OBJECT_Actor:
1646 { 1638 {
1647 assert(source_id < uNumActors); 1639 assert(source_id < uNumActors);
1648 auto actor = pActors + source_id; 1640 auto actor = pActors + source_id;
1649 1641
1669 _4ABE55(channel); 1661 _4ABE55(channel);
1670 } 1662 }
1671 } 1663 }
1672 1664
1673 1665
1666
1667 if (pCurrentScreen != SCREEN_GAME)
1668 {
1669 auto channel = &pMixerChannels[4];
1670 if (AIL_sample_status(channel->hSample) == AIL::Sample::Playing)
1671 AIL_end_sample(channel->hSample);
1672 return;
1673 }
1674 if (!_6807E0_num_decorations_with_sounds_6807B8)
1675 return;
1676
1674 v55 = 0; 1677 v55 = 0;
1675 if ( pCurrentScreen != SCREEN_GAME ) 1678 //v59 = 0;
1676 { 1679 for (uint i = 0; i < _6807E0_num_decorations_with_sounds_6807B8; ++i)
1677 v42 = &pAudioPlayer->pMixerChannels[4]; 1680 {
1678 if ( AIL_sample_status(v42->hSample) == 4 ) 1681 //while ( 1 )
1679 AIL_end_sample(v42->hSample); 1682 //{
1680 return;
1681 }
1682 v59 = v2;
1683 if ( _6807E0_num_decorations_with_sounds_6807B8 <= v2 )
1684 return;
1685 while ( 1 )
1686 {
1687 LODWORD(v56) = 1; 1683 LODWORD(v56) = 1;
1688 v43 = 4 * v59 + 6817720; 1684 //v43 = _6807B8_level_decorations_ids[v59];
1689 v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]]; 1685 //v44 = &pLevelDecorations[_6807B8_level_decorations_ids[v59]];
1690 v45 = abs(v44->vPosition.z - pParty->vPosition.z); 1686 //v45 = abs(v44->vPosition.z - pParty->vPosition.z);
1691 v46 = abs(v44->vPosition.y - pParty->vPosition.y); 1687 //v46 = abs(v44->vPosition.y - pParty->vPosition.y);
1692 v47 = abs(v44->vPosition.x - pParty->vPosition.x); 1688 //v47 = abs(v44->vPosition.x - pParty->vPosition.x);
1693 if ( int_get_vector_length(v47, v46, v45) <= 8192 ) 1689 auto decor = &pLevelDecorations[_6807B8_level_decorations_ids[i]];
1694 break; 1690 if (int_get_vector_length(decor->vPosition.x - pParty->vPosition.x,
1695 LABEL_89: 1691 decor->vPosition.y - pParty->vPosition.y,
1696 ++v59; 1692 decor->vPosition.z - pParty->vPosition.z) > 8192)
1697 if ( v59 >= _6807E0_num_decorations_with_sounds_6807B8 ) 1693 continue;
1698 return; 1694
1699 } 1695 auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID];
1700 v48 = &pDecorationList->pDecorations[v44->uDecorationDescID]; 1696 //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID];
1701 v49 = v48->uFlags; 1697 //v49 = v48->uFlags;
1702 uNumRepeats = (~(unsigned __int8)v48->uFlags & 0x40) >> 6; 1698 uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & 0x40) >> 6;
1703 if ( HIBYTE(v49) & 3 ) 1699
1704 { 1700 if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk())
1705 v50 = v44->field_1A; 1701 {
1702 //v50 = decor->field_1A;
1706 v55 = 0.0; 1703 v55 = 0.0;
1707 uNumRepeats = 2; 1704 uNumRepeats = 2;
1708 if ( v50 ) 1705 if (decor->field_1A)
1709 { 1706 {
1710 v51 = v50 - 32; 1707 v51 = decor->field_1A - 32;
1711 v44->field_1A = v51; 1708 decor->field_1A = v51;
1712 if ( v51 < 0 ) 1709 if ( v51 < 0 )
1713 v44->field_1A = 0; 1710 decor->field_1A = 0;
1714 } 1711 }
1715 } 1712 }
1716 v52 = v48->uFlags; 1713
1717 if ( !(HIBYTE(v52) & 1) ) 1714 //v52 = v48->uFlags;
1718 { 1715 if (!decor_desc->SoundOnDawn())
1719 if ( !(HIBYTE(v52) & 2) ) 1716 {
1720 goto LABEL_84; 1717 if (!decor_desc->SoundOnDusk())
1721 if ( v55 != 0.0 ) 1718 goto LABEL_84;
1722 goto LABEL_85; 1719 if ( v55 != 0.0 )
1723 } 1720 goto LABEL_85;
1724 v56 = 0.0; 1721 }
1725 if ( pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 1722 v56 = 0.0;
1726 || pParty->uCurrentHour >= 0x14 && pParty->uCurrentHour < 0x15 ) 1723
1727 { 1724 if (pParty->uCurrentHour >= 5 && pParty->uCurrentHour < 6 ||
1728 if ( !v44->field_1A && rand() % 100 < 100 ) 1725 pParty->uCurrentHour >= 20 && pParty->uCurrentHour < 21)
1726 {
1727 if ( !decor->field_1A && rand() % 100 < 100 )
1729 LODWORD(v56) = 1; 1728 LODWORD(v56) = 1;
1730 LODWORD(v55) = 1; 1729 LODWORD(v55) = 1;
1731 } 1730 }
1732 LABEL_84: 1731 LABEL_84:
1733 if ( v55 == 0.0 ) 1732 if ( v55 == 0.0 )
1734 { 1733 {
1735 LABEL_87: 1734 LABEL_87:
1736 if ( v56 != 0.0 ) 1735 if ( v56 != 0.0 )
1737 { 1736 {
1738 v53 = 8 * *(int *)v43; 1737 v53 = 8 * _6807B8_level_decorations_ids[i];
1739 LOBYTE(v53) = v53 | 5; 1738 LOBYTE(v53) = v53 | OBJECT_Decoration;
1740 PlaySound((SoundID)v48->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); 1739 PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0);
1741 } 1740 }
1742 goto LABEL_89; 1741 continue;
1743 } 1742 }
1744 LABEL_85: 1743 LABEL_85:
1745 if ( !v44->field_1A ) 1744 if ( !decor->field_1A )
1746 v44->field_1A = (rand() % 15 + 1) << 7; 1745 decor->field_1A = (rand() % 15 + 1) << 7;
1747 goto LABEL_87; 1746 goto LABEL_87;
1747 }
1748 } 1748 }
1749 1749
1750 1750
1751 1751
1752 //----- (004AB66C) -------------------------------------------------------- 1752 //----- (004AB66C) --------------------------------------------------------
2198 { 2198 {
2199 v8 = v16; 2199 v8 = v16;
2200 v9 = *(int *)v7; 2200 v9 = *(int *)v7;
2201 ++v16; 2201 ++v16;
2202 v14[v8] = v2; 2202 v14[v8] = v2;
2203 if ( AIL_sample_status((HSAMPLE)v9) == 4 ) 2203 if ( AIL_sample_status((HSAMPLE)v9) == AIL::Sample::Playing)
2204 ++v15; 2204 ++v15;
2205 } 2205 }
2206 ++v2; 2206 ++v2;
2207 v7 += 16; 2207 v7 += 16;
2208 } 2208 }
2228 } 2228 }
2229 } 2229 }
2230 } 2230 }
2231 } 2231 }
2232 } 2232 }
2233 // 4D82F8: using guessed type int __stdcall AIL_sample_status(int);
2234 // 4ABE55: using guessed type int var_48[16];
2235 2233
2236 2234
2237 2235
2238 //----- (004AAEA6) -------------------------------------------------------- 2236 //----- (004AAEA6) --------------------------------------------------------
2239 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) 2237 int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1)