Ticket #5476: psp-pix2-source13.patch

File psp-pix2-source13.patch, 89.1 KB (added by digitall, 13 years ago)

Big patch linked from forum

  • backends/platform/psp/input.cpp

     
    3333
    3434#include "backends/platform/psp/psppixelformat.h"
    3535#include "backends/platform/psp/input.h"
     36#include "gui/message.h"
    3637
    3738// Defines for working with PSP buttons
    3839#define CHANGED(x)       (_buttonsChanged & (x))
     
    4546#define PSP_TRIGGERS (PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER)
    4647
    4748#define PAD_CHECK_TIME  53
     49#define CONTROL_MODE_CHANGE_TIME        2000
    4850
    4951void InputHandler::init() {
    5052        sceCtrlSetSamplingCycle(0);     // set sampling to vsync. n = n usecs
    5153        sceCtrlSetSamplingMode(1);  // analog
     54        _lastControlModeChangeTime=0;
    5255}
    5356
    5457bool InputHandler::getAllInputs(Common::Event &event) {
     
    106109
    107110        int newDpadX = 0, newDpadY = 0;
    108111        bool haveEvent = false;
    109 
    110         if (DOWN(PSP_CTRL_UP)) {
    111                 newDpadY++;
    112                 if (DOWN(PSP_CTRL_RTRIGGER))    // Shifting causes diagonals
     112       
     113        if(_lolControlMode) {
     114                //alternative controls for Lands Of Lore control mode
     115               
     116                //don't need diagonals......
     117                        if (DOWN(PSP_CTRL_UP)) {
     118                                newDpadY++;
     119                        }
     120                        if (DOWN(PSP_CTRL_RIGHT)) {
     121                                newDpadX++;
     122                        }
     123                        if (DOWN(PSP_CTRL_DOWN)) {
     124                                newDpadY--;
     125                        }
     126                        if (DOWN(PSP_CTRL_LEFT)) {
     127                                newDpadX--;
     128                        }       
     129       
     130                if(DOWN(PSP_CTRL_SQUARE)) { //if square pressed the d-pad maps to the four fight buttons
     131                        if (_dpadX == 0 && _dpadY == 0) {               // We were in the middle so we pressed dpad
     132                                event.type = Common::EVENT_KEYDOWN;
     133                                event.kbd.keycode = translateDpadLol(newDpadX, newDpadY, true);
     134                                event.kbd.ascii = event.kbd.keycode + 33;       // Get ascii
     135                                haveEvent = true;       
     136                                _dpadX = newDpadX;
     137                                _dpadY = newDpadY;
     138                        } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
     139                                event.type = Common::EVENT_KEYUP;
     140                                event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, true);
     141                                event.kbd.ascii = event.kbd.keycode + 33;       // Get ascii
     142                                haveEvent = true;
     143                                _dpadX = newDpadX;
     144                                _dpadY = newDpadY;
     145                        } else {        // we moved from one pressed dpad direction to another one
     146                                event.type = Common::EVENT_KEYUP;
     147                                event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, true);
     148                                event.kbd.ascii = event.kbd.keycode + 33;       // Get ascii
     149                                haveEvent = true;
     150                                _dpadX = 0;
     151                                _dpadY = 0;
     152                        }                       
     153                }  else { // If square not pressed then dpad maps to movement controls.
     154                        if (newDpadX != _dpadX || newDpadY != _dpadY) {
     155                                if (_dpadX == 0 && _dpadY == 0) {               // We were in the middle so we pressed dpad
     156                                        event.type = Common::EVENT_KEYDOWN;
     157                                        event.kbd.keycode = translateDpadLol(newDpadX, newDpadY, false);
     158                                        event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';        // Get ascii
     159                                        _dpadX = newDpadX;
     160                                        _dpadY = newDpadY;
     161                                } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
     162                                        event.type = Common::EVENT_KEYUP;
     163                                        event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, false);
     164                                        event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
     165                                        _dpadX = newDpadX;
     166                                        _dpadY = newDpadY;
     167                                } else {        // we moved from one pressed dpad direction to another one
     168                                        event.type = Common::EVENT_KEYUP;       // first release the last dpad direction
     169                                        event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, false);
     170                                        event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
     171                                        _dpadX = 0; // so that we'll pick up a new dpad movement the next round
     172                                        _dpadY = 0;
     173                                }               
     174                                PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY);
     175                                haveEvent = true;
     176                        }               
     177                }
     178        } else {
     179                if (DOWN(PSP_CTRL_UP)) {
     180                        newDpadY++;
     181                        if (DOWN(PSP_CTRL_RTRIGGER))    // Shifting causes diagonals
     182                                newDpadX++;
     183                }
     184                if (DOWN(PSP_CTRL_RIGHT)) {
    113185                        newDpadX++;
    114         }
    115         if (DOWN(PSP_CTRL_RIGHT)) {
    116                 newDpadX++;
    117                 if (DOWN(PSP_CTRL_RTRIGGER))
     186                        if (DOWN(PSP_CTRL_RTRIGGER))
     187                                newDpadY--;
     188                }
     189                if (DOWN(PSP_CTRL_DOWN)) {
    118190                        newDpadY--;
    119         }
    120         if (DOWN(PSP_CTRL_DOWN)) {
    121                 newDpadY--;
    122                 if (DOWN(PSP_CTRL_RTRIGGER))
     191                        if (DOWN(PSP_CTRL_RTRIGGER))
     192                                newDpadX--;
     193                }
     194                if (DOWN(PSP_CTRL_LEFT)) {
    123195                        newDpadX--;
    124         }
    125         if (DOWN(PSP_CTRL_LEFT)) {
    126                 newDpadX--;
    127                 if (DOWN(PSP_CTRL_RTRIGGER))
    128                         newDpadY++;
    129         }
    130 
    131         if (newDpadX != _dpadX || newDpadY != _dpadY) {
    132                 if (_dpadX == 0 && _dpadY == 0) {               // We were in the middle so we pressed dpad
    133                         event.type = Common::EVENT_KEYDOWN;
    134                         event.kbd.keycode = translateDpad(newDpadX, newDpadY);
    135                         event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';        // Get ascii
    136                         _dpadX = newDpadX;
    137                         _dpadY = newDpadY;
    138                 } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
    139                         event.type = Common::EVENT_KEYUP;
    140                         event.kbd.keycode = translateDpad(_dpadX, _dpadY);
    141                         event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
    142                         _dpadX = newDpadX;
    143                         _dpadY = newDpadY;
    144                 } else {        // we moved from one pressed dpad direction to another one
    145                         event.type = Common::EVENT_KEYUP;       // first release the last dpad direction
    146                         event.kbd.keycode = translateDpad(_dpadX, _dpadY);
    147                         event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
    148                         _dpadX = 0; // so that we'll pick up a new dpad movement the next round
    149                         _dpadY = 0;
     196                        if (DOWN(PSP_CTRL_RTRIGGER))
     197                                newDpadY++;
    150198                }
    151 
    152                 PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY);
    153                 haveEvent = true;
    154         }
    155 
     199       
     200                if (newDpadX != _dpadX || newDpadY != _dpadY) {
     201                        if (_dpadX == 0 && _dpadY == 0) {               // We were in the middle so we pressed dpad
     202                                event.type = Common::EVENT_KEYDOWN;
     203                                event.kbd.keycode = translateDpad(newDpadX, newDpadY);
     204                                event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';        // Get ascii
     205                                _dpadX = newDpadX;
     206                                _dpadY = newDpadY;
     207                        } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
     208                                event.type = Common::EVENT_KEYUP;
     209                                event.kbd.keycode = translateDpad(_dpadX, _dpadY);
     210                                event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
     211                                _dpadX = newDpadX;
     212                                _dpadY = newDpadY;
     213                        } else {        // we moved from one pressed dpad direction to another one
     214                                event.type = Common::EVENT_KEYUP;       // first release the last dpad direction
     215                                event.kbd.keycode = translateDpad(_dpadX, _dpadY);
     216                                event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
     217                                _dpadX = 0; // so that we'll pick up a new dpad movement the next round
     218                                _dpadY = 0;
     219                        }
     220       
     221                        PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY);
     222                        haveEvent = true;
     223                }
     224        }       
    156225        return haveEvent;
    157226}
    158 
     227       
    159228inline Common::KeyCode InputHandler::translateDpad(int x, int y) {
    160229        DEBUG_ENTER_FUNC();
    161230        Common::KeyCode key;
     
    184253        return key;
    185254}
    186255
     256inline Common::KeyCode InputHandler::translateDpadLol(int x, int y, bool fight) {
     257        DEBUG_ENTER_FUNC();
     258        Common::KeyCode key;
     259        if(fight) {
     260                if (x == -1) key = Common::KEYCODE_F1;
     261                else if (x == 1) key = Common::KEYCODE_F3;
     262                else if (y == 1) key = Common::KEYCODE_F2;
     263                else if (y == -1) key = Common::KEYCODE_F4;
     264        } else {
     265                if (x == -1) key = Common::KEYCODE_KP7;
     266                else if (x == 1) key = Common::KEYCODE_KP9;
     267                else if (y == 1) key = Common::KEYCODE_KP8;
     268                else if (y == -1) key = Common::KEYCODE_KP2;
     269        }
     270        return key;
     271}
    187272
     273
    188274bool InputHandler::getButtonEvent(Common::Event &event, SceCtrlData &pad) {
    189275        DEBUG_ENTER_FUNC();
    190276        bool haveEvent = false;
    191277
    192         if (PRESSED(PSP_CTRL_SELECT))
    193                 _keyboard->setVisible(true);
     278        //Change to LOL mode if square,triangle,X & O pressed simultaneouly.
     279        //Only change if no other buttons are pressed to avoid sticking keys.
    194280
    195         else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) {
    196                 if (CHANGED(PSP_CTRL_CROSS)) {
    197                         event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
    198                         event.mouse.x = _cursor->getX();        // Could this have to do with SCI enter problem?
    199                         event.mouse.y = _cursor->getY();
    200                         PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
    201                 } else if (CHANGED(PSP_CTRL_CIRCLE)) {
    202                         event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
    203                         event.mouse.x = _cursor->getX();
    204                         event.mouse.y = _cursor->getY();
     281        if(DOWN(PSP_CTRL_CROSS) && DOWN(PSP_CTRL_SQUARE) && DOWN(PSP_CTRL_CIRCLE) && DOWN(PSP_CTRL_TRIANGLE) && !DOWN(PSP_CTRL_LEFT)  && !DOWN(PSP_CTRL_DOWN) && !DOWN(PSP_CTRL_UP) && !DOWN(PSP_CTRL_RIGHT) && !DOWN(PSP_CTRL_LTRIGGER) && !DOWN(PSP_CTRL_START)) {
     282                uint32 time = g_system->getMillis();
     283                //Only change mode if enough time passed since last change
     284                if(time -_lastControlModeChangeTime > CONTROL_MODE_CHANGE_TIME) {
     285                        if(_lolControlMode) {
     286                                _lolControlMode=false;
     287                                _lastControlModeChangeTime=time;       
     288                                GUI::TimedMessageDialog dialog("Normal Button Mode", 1500);
     289                                dialog.runModal();
     290                        } else {
     291                                _lolControlMode=true;
     292                                _lastControlModeChangeTime=time;
     293                                //send keyup for . which is mapped to square in normal mode
     294                                event.type = Common::EVENT_KEYUP;
     295                                event.kbd.keycode = Common::KEYCODE_PERIOD;
     296                                event.kbd.ascii = '.';
     297                                haveEvent=true;
     298       
     299                                GUI::TimedMessageDialog dialog("1st Person Button Mode", 1500);
     300                                dialog.runModal();
     301                        }                       
     302                        return haveEvent;
     303                }
     304        }
     305        if(_lolControlMode) {
     306                        if (PRESSED(PSP_CTRL_SELECT))
     307                        _keyboard->setVisible(true);
     308       
     309                else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) {
     310                        if (CHANGED(PSP_CTRL_CROSS)) {
     311                                event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
     312                                event.mouse.x = _cursor->getX();        // Could this have to do with SCI enter problem?
     313                                event.mouse.y = _cursor->getY();
     314                                PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
     315                        } else if (CHANGED(PSP_CTRL_CIRCLE)) {
     316                                event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
     317                                event.mouse.x = _cursor->getX();
     318                                event.mouse.y = _cursor->getY();
    205319                        PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "RButtonDown" : "RButtonUp");
    206                 } else {
    207                         //any of the other buttons.
    208                         event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
    209                         event.kbd.ascii = 0;
    210                         event.kbd.flags = 0;
    211 
    212                         if (CHANGED(PSP_CTRL_LTRIGGER)) {
    213                                 event.kbd.keycode = Common::KEYCODE_ESCAPE;
    214                                 event.kbd.ascii = 27;
    215                         } else if (CHANGED(PSP_CTRL_START)) {
    216                                 event.kbd.keycode = Common::KEYCODE_F5;
    217                                 event.kbd.ascii = Common::ASCII_F5;
    218                                 if (DOWN(PSP_CTRL_RTRIGGER)) {
    219                                         event.kbd.flags |= Common::KBD_CTRL;    // Main menu to allow RTL
     320                        } else {
     321                                //any of the other buttons.
     322                                event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
     323                                event.kbd.ascii = 0;
     324                                event.kbd.flags = 0;
     325       
     326                                if (CHANGED(PSP_CTRL_LTRIGGER)) {
     327                                        event.kbd.keycode = Common::KEYCODE_KP4;
     328                                        event.kbd.ascii = Common::KEYCODE_KP4;
     329                                } else if (CHANGED(PSP_CTRL_SQUARE)) { //need to keyup movement/fighting keys to make certain they don't get stuck
     330                                        if(DOWN(PSP_CTRL_SQUARE)) {
     331                                                _dpadX = 0;
     332                                                _dpadY = 0;
     333                                                if(DOWN(PSP_CTRL_UP)) {
     334                                                        event.type = Common::EVENT_KEYUP;
     335                                                        event.kbd.keycode = Common::KEYCODE_KP8;
     336                                                        event.kbd.ascii = Common::KEYCODE_KP8;
     337                                                } else if(DOWN(PSP_CTRL_LEFT)) {
     338                                                        event.type = Common::EVENT_KEYUP;
     339                                                        event.kbd.keycode = Common::KEYCODE_KP4;
     340                                                        event.kbd.ascii = Common::KEYCODE_KP4;
     341                                                } else if(DOWN(PSP_CTRL_RIGHT)) {
     342                                                        event.type = Common::EVENT_KEYUP;
     343                                                        event.kbd.keycode = Common::KEYCODE_KP6;
     344                                                        event.kbd.ascii = Common::KEYCODE_KP6;
     345                                                } else if(DOWN(PSP_CTRL_DOWN)) {
     346                                                        event.type = Common::EVENT_KEYUP;
     347                                                        event.kbd.keycode = Common::KEYCODE_KP2;
     348                                                        event.kbd.ascii = Common::KEYCODE_KP2;
     349                                                } else return haveEvent;
     350                                        } else {
     351                                                _dpadX = 0;
     352                                                _dpadY = 0;
     353                                                if(DOWN(PSP_CTRL_UP)) {
     354                                                        event.type = Common::EVENT_KEYUP;
     355                                                        event.kbd.keycode = Common::KEYCODE_F2;
     356                                                        event.kbd.ascii = Common::ASCII_F2;
     357                                                } else if(DOWN(PSP_CTRL_LEFT)) {
     358                                                        event.type = Common::EVENT_KEYUP;
     359                                                        event.kbd.keycode = Common::KEYCODE_F1;
     360                                                        event.kbd.ascii = Common::ASCII_F1;
     361                                                } else if(DOWN(PSP_CTRL_RIGHT)) {
     362                                                        event.type = Common::EVENT_KEYUP;
     363                                                        event.kbd.keycode = Common::KEYCODE_F3;
     364                                                        event.kbd.ascii = Common::ASCII_F3;
     365                                                } else if(DOWN(PSP_CTRL_DOWN)) {
     366                                                        event.type = Common::EVENT_KEYUP;
     367                                                        event.kbd.keycode = Common::KEYCODE_F4;
     368                                                        event.kbd.ascii = Common::ASCII_F4;
     369                                                } else return haveEvent;
     370                                        }
    220371                                }
    221                         } else if (CHANGED(PSP_CTRL_SQUARE)) {
    222                                 event.kbd.keycode = Common::KEYCODE_PERIOD;
    223                                 event.kbd.ascii = '.';
    224                         } else if (CHANGED(PSP_CTRL_TRIANGLE)) {
    225                                 event.kbd.keycode = Common::KEYCODE_RETURN;
    226                                 event.kbd.ascii = '\r';
    227                         } else if (DOWN(PSP_CTRL_RTRIGGER)) {                   // An event
    228                                 event.kbd.flags |= Common::KBD_SHIFT;
     372                                else if (CHANGED(PSP_CTRL_RTRIGGER)) {                  // An event
     373                                        event.kbd.keycode = Common::KEYCODE_KP6;
     374                                        event.kbd.ascii = Common::KEYCODE_KP6;
     375                                } else if (CHANGED(PSP_CTRL_TRIANGLE)) {
     376                                        event.kbd.keycode = Common::KEYCODE_RETURN;
     377                                        event.kbd.ascii = '\r';
     378                                } else if (CHANGED(PSP_CTRL_START)) {
     379                                        event.kbd.keycode = Common::KEYCODE_ESCAPE;
     380                                        event.kbd.ascii = 27;
     381                                }
     382                                PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up");
    229383                        }
    230                         PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up");
     384               
     385                        haveEvent = true;
     386                }       
     387        }
     388        else
     389        {
     390                if (PRESSED(PSP_CTRL_SELECT))
     391                        _keyboard->setVisible(true);
     392       
     393                else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) {
     394                        if (CHANGED(PSP_CTRL_CROSS)) {
     395                                event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
     396                                event.mouse.x = _cursor->getX();        // Could this have to do with SCI enter problem?
     397                                event.mouse.y = _cursor->getY();
     398                                PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
     399                        } else if (CHANGED(PSP_CTRL_CIRCLE)) {
     400                                event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
     401                                event.mouse.x = _cursor->getX();
     402                                event.mouse.y = _cursor->getY();
     403                        PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "RButtonDown" : "RButtonUp");
     404                        } else {
     405                                //any of the other buttons.
     406                                event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
     407                                event.kbd.ascii = 0;
     408                                event.kbd.flags = 0;
     409       
     410                                if (CHANGED(PSP_CTRL_LTRIGGER)) {
     411                                        event.kbd.keycode = Common::KEYCODE_ESCAPE;
     412                                        event.kbd.ascii = 27;
     413                                } else if (CHANGED(PSP_CTRL_START)) {
     414                                        event.kbd.keycode = Common::KEYCODE_F5;
     415                                        event.kbd.ascii = Common::ASCII_F5;
     416                                        if (DOWN(PSP_CTRL_RTRIGGER)) {
     417                                                event.kbd.flags |= Common::KBD_CTRL;    // Main menu to allow RTL
     418                                        }
     419                                } else if (CHANGED(PSP_CTRL_SQUARE)) {
     420                                        event.kbd.keycode = Common::KEYCODE_PERIOD;
     421                                        event.kbd.ascii = '.';
     422                                } else if (CHANGED(PSP_CTRL_TRIANGLE)) {
     423                                                event.kbd.keycode = Common::KEYCODE_RETURN;
     424                                        event.kbd.ascii = '\r';
     425                                } else if (DOWN(PSP_CTRL_RTRIGGER)) {                   // An event
     426                                        event.kbd.flags |= Common::KBD_SHIFT;
     427                                }
     428                                PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up");
     429                        }
     430               
     431                        haveEvent = true;
    231432                }
    232 
    233                 haveEvent = true;
    234433        }
    235 
    236434        return haveEvent;
    237435}
    238436
     
    254452                PSP_DEBUG_PRINT("raw x[%d], y[%d]\n", analogStepX, analogStepY);
    255453
    256454                // If no movement then this has no effect
    257                 if (DOWN(PSP_CTRL_RTRIGGER)) {
     455                if ((!_lolControlMode && DOWN(PSP_CTRL_RTRIGGER)) || (_lolControlMode && DOWN(PSP_CTRL_SQUARE))) {
    258456                        // Fine control mode for analog
    259457                        if (analogStepX != 0) {
    260458                                if (analogStepX > 0)
  • backends/platform/psp/input.h

     
    5151        uint32 _buttonsChanged;
    5252        int32 _dpadX, _dpadY;
    5353        int32 _accelX, _accelY;
     54        uint32 _lastControlModeChangeTime;
     55        bool _lolControlMode;
    5456
     57
    5558        bool getEvent(Common::Event &event, SceCtrlData &pad);
    5659        bool getDpadEvent(Common::Event &event, SceCtrlData &pad);
    5760        bool getButtonEvent(Common::Event &event, SceCtrlData &pad);
    5861        bool getNubEvent(Common::Event &event, SceCtrlData &pad);
    5962        int32 modifyNubAxisMotion(int32 input);
    6063        Common::KeyCode translateDpad(int x, int y);
     64        Common::KeyCode translateDpadLol(int x, int y, bool fight);
    6165};
    6266
    6367#endif /* PSP_INPUT_H */
  • configure

     
    8787add_engine drascula "Drascula: The Vampire Strikes Back" yes
    8888add_engine gob "Gobli*ns" yes
    8989add_engine groovie "Groovie" yes "groovie2"
    90 add_engine groovie2 "Groovie 2 games" no
    91 add_engine hugo "Hugo Trilogy" no
     90add_engine groovie2 "Groovie 2 games" yes
     91add_engine hugo "Hugo Trilogy" yes
    9292add_engine kyra "Legend of Kyrandia" yes "lol"
    93 add_engine lol "Lands of Lore" no
     93add_engine lol "Lands of Lore" yes
    9494add_engine lure "Lure of the Temptress" yes
    95 add_engine m4 "M4/MADS" no
     95add_engine m4 "M4/MADS" yes
    9696add_engine made "MADE" yes
    97 add_engine mohawk "Mohawk" no
     97add_engine mohawk "Mohawk" yes
    9898add_engine parallaction "Parallaction" yes
    9999add_engine queen "Flight of the Amazon Queen" yes
    100100add_engine saga "SAGA" yes "ihnm saga2"
    101101add_engine ihnm "IHNM" yes
    102 add_engine saga2 "SAGA 2 games" no
     102add_engine saga2 "SAGA 2 games" yes
    103103add_engine sci "SCI" yes "sci32"
    104 add_engine sci32 "SCI32 games" no
     104add_engine sci32 "SCI32 games" yes
    105105add_engine sky "Beneath a Steel Sky" yes
    106106add_engine sword1 "Broken Sword" yes
    107107add_engine sword2 "Broken Sword II" yes
     
    166166_nasmpath="$PATH"
    167167NASMFLAGS=""
    168168NASM=""
    169 
    170 # Directories for installing ScummVM.
    171 # This list is closely based on what GNU autoconf does,
    172 # although the default value for datadir differs.
    173 # Like GNU autoconf, we distinguish datadir and datarootdir
    174 # to make it possible to change e.g. the location of the
    175 # man pages independently of that of the engine data files,
    176 # which are placed inside $datadir/scummvm
    177 exec_prefix=NONE
    178 prefix=NONE
    179 bindir='${exec_prefix}/bin'
    180 datarootdir='${prefix}/share'
    181 datadir='${datarootdir}/scummvm'
    182 docdir='${datarootdir}/doc/scummvm'
    183 libdir='${exec_prefix}/lib'
    184 #localedir='${datarootdir}/locale'
    185 mandir='${datarootdir}/man'
    186 
     169_prefix=/usr/pspdev/local
    187170# For cross compiling
    188171_host=""
    189172_host_cpu=""
  • engines/agos/midi.cpp

     
    2929#include "common/system.h"
    3030
    3131#include "agos/agos.h"
     32#include "sound/audiocd.h"
    3233
    3334namespace AGOS {
    3435
     
    9697}
    9798
    9899void MidiPlayer::send(uint32 b) {
     100
    99101        if (!_current)
    100102                return;
    101103
     
    208210        if (track == _currentTrack)
    209211                return;
    210212
     213        AudioCD.stop();
     214        AudioCD.play(_music.cdtracks[track], _loopTrack ? -1 : 1 , 0, 0);
     215
    211216        if (_music.num_songs > 0) {
    212217                if (track >= _music.num_songs)
    213218                        return;
     
    225230                parser->property (MidiParser::mpMalformedPitchBends, 1);
    226231                parser->setMidiDriver(this);
    227232                parser->setTimerRate(_driver->getBaseTempo());
     233                if(AudioCD.isPlaying()) parser->_dontplayme=true;
     234                else parser->_dontplayme=false;
    228235                if (!parser->loadMusic(_music.songs[track], _music.song_sizes[track])) {
    229236                        printf ("Error reading track!\n");
    230237                        delete parser;
     
    239246                        _mutex.unlock();
    240247                        return;
    241248                }
     249                if(AudioCD.isPlaying()) _music.parser->_dontplayme=true;
     250                else _music.parser->_dontplayme=false;
    242251                _currentTrack = (byte)track;
    243252                _current = &_music;
    244253                _music.parser->jumpToTick(0);
     
    250259
    251260void MidiPlayer::stop() {
    252261        Common::StackLock lock(_mutex);
     262        AudioCD.stop();
    253263
    254264        if (_music.parser) {
    255265                _current = &_music;
     
    288298
    289299        _musicVolume = musicVol;
    290300        _sfxVolume = sfxVol;
     301        g_system->getMixer()->setVolumeForSoundType(g_system->getMixer()->kMusicSoundType,musicVol);
    291302
    292303        // Now tell all the channels this.
    293304        Common::StackLock lock(_mutex);
     
    322333
    323334void MidiPlayer::queueTrack(int track, bool loop) {
    324335        _mutex.lock();
    325         if (_currentTrack == 255) {
     336        if (_currentTrack == 255 && !AudioCD.isPlaying()) {
    326337                _mutex.unlock();
    327338                setLoop(loop);
    328339                startTrack(track);
     
    523534        }
    524535}
    525536
    526 void MidiPlayer::loadXMIDI(Common::File *in, bool sfx) {
     537
     538void MidiPlayer::loadXMIDI(Common::File *in, bool sfx, uint8 cdtrack) {
    527539        Common::StackLock lock(_mutex);
    528540        MusicInfo *p = sfx ? &_sfx : &_music;
    529541        clearConstructs(*p);
    530542
     543        uint8 si2xmis[][16]={{0},{9,10,11},{4,5,6,7,8},{12},{13},{14},{15},{16},{17,9,10,11},{18,16},
     544                                                {19,20,21},{22},{23,24,25},{29},{1,2},{30},{29,31,32},{1,2},{29,31,32},{33,34},
     545                                                {35,36},{37,38},{39,40},{41,42},{43,44},{45,46,47,48},{26,27,28},{49,50,51,52,53},{54},{55,56,57,58},
     546                                                {59,60},{61},{62,63,64,65},{65,62,64,63},{65,62,64,63},{66},{67},{68},{69},{70},
     547                                                {71,72},{73,74},{75},{76,77},{78},{79},{80},{81},{82,83,84,85,86},{86,87,88},
     548                                                {114},{115,116},{116},{117},{118,119},{120},{121},{122},{123},{124},
     549                                                {89},{90,91},{92,93},{94,91,95},{96},{97},{98,99},{98,100},{98,101},{98,101},
     550                                                {98,101},{102},{98,101},{103},{104,105,106},{107},{108},{109},{110,111,112},{113},
     551                                                {125,126},{127},{128},{129,130,131},{132,133},{134,135},{136},{137},{138},{138,139},
     552                                                {3},{140,141},{142},{143},{144}
     553        };
     554
     555        if(cdtrack!=0) {
     556                for(int a=0;a<sizeof(p->cdtracks);a++) {
     557                        p->cdtracks[a]=si2xmis[cdtrack][a];
     558                }
     559        }
     560
    531561        char buf[4];
    532562        uint32 pos = in->pos();
    533563        uint32 size = 4;
  • engines/agos/midi.h

     
    4242        byte num_songs;           // For Type 1 SMF resources
    4343        byte *songs[16];          // For Type 1 SMF resources
    4444        uint32 song_sizes[16];    // For Type 1 SMF resources
     45        uint8 cdtracks[16];
    4546
    4647        MidiChannel *channel[16]; // Dynamic remapping of channels to resolve conflicts
    4748        byte volume[16];          // Current channel volume
    4849
     50
    4951        MusicInfo() { clear(); }
    5052        void clear() {
    5153                parser = 0; data = 0; num_songs = 0;
    5254                memset(songs, 0, sizeof(songs));
    5355                memset(song_sizes, 0, sizeof(song_sizes));
    5456                memset(channel, 0, sizeof(channel));
     57                memset(cdtracks, 0, sizeof(cdtracks));
    5558        }
    5659};
    5760
     
    9497
    9598        void loadSMF(Common::File *in, int song, bool sfx = false);
    9699        void loadMultipleSMF(Common::File *in, bool sfx = false);
    97         void loadXMIDI(Common::File *in, bool sfx = false);
     100        void loadXMIDI(Common::File *in, bool sfx = false, uint8 cdtrack = 0);
    98101        void loadS1D(Common::File *in, bool sfx = false);
    99102
    100103        void mapMT32toGM(bool map);
  • engines/agos/res_snd.cpp

     
    122122        char buf[4];
    123123
    124124        stopMusic();
    125 
    126125        _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
    127126        _gameFile->read(buf, 4);
    128127        if (!memcmp(buf, "FORM", 4)) {
    129128                _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
    130                 _midi.loadXMIDI(_gameFile);
     129                _midi.loadXMIDI(_gameFile,false,music);
    131130        } else {
    132131                _gameFile->seek(_gameOffsetsPtr[_musicIndexBase + music - 1], SEEK_SET);
    133132                _midi.loadMultipleSMF(_gameFile);
  • engines/cruise/sound.cpp

     
    3333#include "sound/audiostream.h"
    3434#include "sound/fmopl.h"
    3535#include "sound/mods/soundfx.h"
     36#include "sound/audiocd.h"
    3637
    3738namespace Cruise {
    3839
     
    652653void PCSoundFxPlayer::play() {
    653654        debug(9, "PCSoundFxPlayer::play()");
    654655        if (_sfxData) {
     656                //attempt to use cd audio first
     657                AudioCD.stop();
     658                Common::String mystring=_musicName;
     659
     660                if(mystring=="CORP9") AudioCD.play(9, -1, 0, 0);
     661                if(mystring=="CORP2") AudioCD.play(2, -1, 0, 0);
     662                if(mystring=="CORP6") AudioCD.play(6, -1, 0, 0);
     663                if(mystring=="CORP13") AudioCD.play(13, -1, 0, 0);
     664                if(mystring=="CORP1") AudioCD.play(1, -1, 0, 0);
     665                if(mystring=="CORP7") AudioCD.play(7, -1, 0, 0);
     666
     667                //not supported at this moment but here in case I get around to it
     668                if(mystring=="CORP3") AudioCD.play(3, -1, 0, 0);
     669                if(mystring=="CORP4") AudioCD.play(4, -1, 0, 0);
     670                if(mystring=="CORP5") AudioCD.play(5, -1, 0, 0);
     671                if(mystring=="CORP8") AudioCD.play(8, -1, 0, 0);
     672                if(mystring=="CORP10") AudioCD.play(10, -1, 0, 0);
     673                if(mystring=="CORP11") AudioCD.play(11, -1, 0, 0);
     674                if(mystring=="CORP12") AudioCD.play(12, -1, 0, 0);
     675                if(AudioCD.isPlaying()){
     676                        //_playing=true;
     677                        return;
     678                }
     679               
    655680                for (int i = 0; i < NUM_CHANNELS; ++i) {
    656681                        _instrumentsChannelTable[i] = -1;
    657682                }
     
    665690}
    666691
    667692void PCSoundFxPlayer::stop() {
     693        AudioCD.stop();
    668694        if (_playing || _fadeOutCounter != 0) {
    669695                _fadeOutCounter = 0;
    670696                _playing = false;
     
    677703}
    678704
    679705void PCSoundFxPlayer::fadeOut() {
     706        AudioCD.stop();
    680707        if (_playing) {
    681708                _fadeOutCounter = 1;
    682709                _playing = false;
  • engines/groovie/music.cpp

     
    4747
    4848void MusicPlayer::playSong(uint32 fileref) {
    4949        Common::StackLock lock(_mutex);
     50        AudioCD.stop();
     51        int doIloop=-1;
     52        //if(loop) doIloop=-1;
     53        int cdtrack=fileref-19455;
     54        if (cdtrack==1) cdtrack=100; //used to avoid confusion with real audio cd track
     55        /*switch(fileref) {
     56                case 0x4c39:
     57                        cdtrack=58;
     58                        break;
     59                case 0x4c3f:
     60                        cdtrack=64;
     61                        break;
     62        }       */
     63        if(cdtrack>0&&cdtrack<200)      AudioCD.play(cdtrack,doIloop,0,0);
     64        if(AudioCD.isPlaying())
     65        {
     66                _isPlaying=true;
     67                return;
     68        }
    5069
    5170        // Set the volumes
    5271        _fadingEndVolume = 100;
     
    338357void MusicPlayerMidi::endTrack() {
    339358        debugC(3, kGroovieDebugMIDI | kGroovieDebugAll, "Groovie::Music: endTrack()");
    340359        unload();
     360        AudioCD.stop();
    341361}
    342362
    343363void MusicPlayerMidi::onTimerInternal() {
  • engines/kyra/debugger.cpp

     
    5151        DCmd_Register("queryflag",                      WRAP_METHOD(Debugger, cmd_queryFlag));
    5252        DCmd_Register("timers",                         WRAP_METHOD(Debugger, cmd_listTimers));
    5353        DCmd_Register("settimercountdown",      WRAP_METHOD(Debugger, cmd_setTimerCountdown));
     54        DCmd_Register("play",   WRAP_METHOD(Debugger, cmd_play));
     55        DCmd_Register("loadsf", WRAP_METHOD(Debugger, cmd_loadsf));
    5456}
    5557
    5658bool Debugger::cmd_setScreenDebug(int argc, const char **argv) {
     
    6870        return true;
    6971}
    7072
     73bool Debugger::cmd_play(int argc, const char **argv) {
     74                int val = atoi(argv[1]);
     75                _vm->sound()->playTrack(val);
     76        return true;
     77}
     78
     79bool Debugger::cmd_loadsf(int argc, const char **argv) {
     80                //char* val = atoi(argv[1]);
     81                _vm->sound()->loadSoundFile(argv[1]);
     82        return true;
     83}
    7184bool Debugger::cmd_loadPalette(int argc, const char **argv) {
    7285        Palette palette(_vm->screen()->getPalette(0).getNumColors());
    7386
  • engines/kyra/debugger.h

     
    5151        bool cmd_toggleFlag(int argc, const char **argv);
    5252        bool cmd_queryFlag(int argc, const char **argv);
    5353        bool cmd_listTimers(int argc, const char **argv);
     54        bool cmd_play(int argc, const char **argv);
     55        bool cmd_loadsf(int argc, const char **argv);
    5456        bool cmd_setTimerCountdown(int argc, const char **argv);
    5557};
    5658
  • engines/kyra/sound_adlib.cpp

     
    4848#include "sound/mixer.h"
    4949#include "sound/fmopl.h"
    5050#include "sound/audiostream.h"
     51#include "sound/audiocd.h"
    5152
    5253// Basic AdLib Programming:
    5354// http://www.gamedev.net/reference/articles/article446.asp
     
    23012302void SoundAdLibPC::haltTrack() {
    23022303        unk1();
    23032304        unk2();
     2305        AudioCD.stop();
    23042306        //_vm->_system->delayMillis(3 * 60);
    23052307}
    23062308
     
    23092311}
    23102312
    23112313void SoundAdLibPC::playSoundEffect(uint8 track) {
     2314
    23122315        if (_sfxEnabled)
    2313                 play(track);
     2316        {
     2317                char filenamebuffer[25];
     2318                DigitalTrack dTrack=getDigitalEffectsTrack(track);
     2319                sprintf(filenamebuffer, "track%i", dTrack.track);
     2320
     2321                if(dTrack.track!=0) {
     2322                        _mixer->stopHandle(_fxHandle);
     2323                        voicePlay(filenamebuffer,&_fxHandle,255,true);
     2324                        _currentSoundEffect = filenamebuffer;
     2325                }
     2326                if(!_mixer->isSoundHandleActive(_fxHandle)) play(track,true);           
     2327        }
    23142328}
    23152329
    2316 void SoundAdLibPC::play(uint8 track) {
     2330void SoundAdLibPC::play(uint8 track, bool soundeffect) {
     2331       
     2332        if(soundeffect==false)
     2333        {
     2334                DigitalTrack dTrack = getDigitalMusicTrack(track);
     2335                bool loop = dTrack.loop;
     2336                uint8 tracktoplay = dTrack.track;
     2337                AudioCD.stop();
     2338       
     2339                if(tracktoplay != 0) {
     2340                        AudioCD.play(tracktoplay, loop ? -1 : 1, 0, 0);
     2341                }
     2342       
     2343                if(AudioCD.isPlaying()) return;
     2344        }
    23172345        uint16 soundId = 0;
    23182346
    23192347        if (_v2)
     
    23822410
    23832411void SoundAdLibPC::loadSoundFile(uint file) {
    23842412        internalLoadFile(fileListEntry(file));
     2413        Common::String filename = fileListEntry(file);
     2414        filename.toLowercase();
     2415        _currentTrack = filename;
     2416        haltTrack();
    23852417}
    23862418
    23872419void SoundAdLibPC::loadSoundFile(Common::String file) {
    23882420        internalLoadFile(file);
     2421        file.toLowercase();
     2422        _currentTrack = file;
     2423        haltTrack();
    23892424}
    23902425
    23912426void SoundAdLibPC::internalLoadFile(Common::String file) {
     
    24462481        playSoundEffect(0);
    24472482}
    24482483
    2449 } // End of namespace Kyra
     2484const SoundAdLibPC::DigitalTrack SoundAdLibPC::_introTracks[] = {
     2485        {0, false},  {0, false},  {1, false}, {2, false},  {3, true},   {4, true},
     2486        {0, false},  {0, false},  {0, false}, {0, false},  {0, false},  {0, false},
     2487        {0, false},  {0, false},  {0, false}, {0, false},  {0, false},  {0, false},
     2488        {0, false},  {0, false},  {0, false}, {0, false},  {50, false}, {51, false},
     2489        {52, false}, {53, false}, {0, false}, {54, false}, {55, false}, {0, false},
     2490        {56, false}, {57, false}, {0, false}, {58, false}, {59, false}, {60, false},
     2491        {61, false}, {62, false}, {63, false}
     2492};
    24502493
     2494const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra1aTracks[] = {
     2495        {0, false},   {0, false},   {5, true},    {6, true},    {7, true},    {0, false},
     2496        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2497        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2498        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2499        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2500        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2501        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2502        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2503        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2504        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2505        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2506        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2507        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2508        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2509        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2510        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2511        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2512        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2513        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2514        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2515};
     2516const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra1bTracks[] = {
     2517        {0, false},   {0, false},   {9, true},    {10, false},  {11, true},   {45, true},
     2518        {12, false},  {13, false},  {14, true},   {15, false},  {0, false},   {8, false},
     2519        {0, false},   {16, true},   {17, true},   {0, false},   {0, false},   {0, false},
     2520        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2521        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2522        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2523        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2524        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2525        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2526        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2527        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2528        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2529        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2530        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2531        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2532        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2533        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2534        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2535        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2536        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2537};
     2538const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra2aTracks[] = {
     2539        {0, false},   {0, false},   {18, true},   {19, true},   {20, false},  {21, true},
     2540        {22, false},  {23, true},   {0, false},   {0, false},   {0, false},   {0, false},
     2541        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2542        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2543        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2544        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2545        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2546        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2547        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2548        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2549        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2550        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2551        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2552        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2553        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2554        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2555        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2556        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2557        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2558        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2559};
     2560const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra3aTracks[] = {
     2561        {0, false},   {0, false},   {5, true},    {25, true},   {26, true},   {0, false},
     2562        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2563        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2564        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2565        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2566        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2567        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2568        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2569        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2570        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2571        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2572        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2573        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2574        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2575        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2576        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2577        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2578        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2579        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2580        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2581};
     2582const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra4aTracks[] = {
     2583        {0, false},   {0, false},   {27, true},   {28, true},   {47, false},  {48, false},
     2584        {49, false},  {29, false},  {30, true},   {64, false},  {0, false},   {0, false},
     2585        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2586        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2587        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2588        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2589        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2590        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2591        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2592        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2593        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2594        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2595        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2596        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2597        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2598        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2599        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2600        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2601        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2602        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2603};
     2604const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra4bTracks[] = {
     2605        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2606        {0, false},   {0, false},   {0, false},   {0, false},   {31, true},   {65, false},
     2607        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2608        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2609        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2610        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2611        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2612        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2613        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2614        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2615        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2616        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2617        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2618        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2619        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2620        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2621        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2622        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2623        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2624        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2625};
     2626const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra5aTracks[] = {
     2627        {0, false},   {0, false},   {33, true},   {34, true},   {0, true},    {7, true},
     2628        {66, false},  {67, false},  {68, false},  {69, false},  {0, false},   {70, false},
     2629        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2630        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2631        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2632        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2633        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2634        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2635        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2636        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2637        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2638        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2639        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2640        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2641        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2642        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2643        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2644        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2645        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2646        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2647};
     2648const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyra5bTracks[] = {
     2649        {0, false},   {0, false},   {35, false},  {36, false},  {0, false},   {37, false},
     2650        {38, false},  {39, false},  {40, false},  {41, false},  {0, false},   {0, false},
     2651        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2652        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2653        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2654        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2655        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2656        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2657        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2658        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2659        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2660        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2661        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2662        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2663        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2664        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2665        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2666        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2667        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2668        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2669};
     2670const SoundAdLibPC::DigitalTrack SoundAdLibPC::_kyramiscTracks[] = {
     2671        {0, false},   {0, false},   {42, true},   {43, true},   {36, false},  {0, false},
     2672        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2673        {0, false},   {0, false},   {0, false},   {0, false},   {0, false},   {0, false},
     2674        {0, false},   {0, false},   {71, false},  {72, false},  {73, false},  {74, false},
     2675        {75, false},  {76, false},  {77, false},  {78, false},  {79, false},  {80, false},
     2676        {81, false},  {82, false},  {83, false},  {84, false},  {85, false},  {86, false},
     2677        {87, false},  {88, false},  {89, false},  {90, false},  {0, false},   {0, false},
     2678        {0, false},   {94, false},  {95, false},  {0, false},   {97, false},  {98, false},
     2679        {99, false},  {100, false}, {101, false}, {102, false}, {103, false}, {104, false},
     2680        {105, false}, {106, false}, {107, false}, {108, false}, {109, false}, {110, false},
     2681        {111, false}, {112, false}, {113, false}, {114, false}, {115, false}, {0, false},
     2682        {0, false},   {118, false}, {119, false}, {120, false}, {121, false}, {122, false},
     2683        {123, false}, {124, false}, {125, true},  {0, false},   {127, false}, {128, false},
     2684        {129, false}, {130, false}, {131, false}, {132, false}, {133, false}, {134, false},
     2685        {135, false}, {136, false}, {137, false}, {138, false}, {139, false}, {140, false},
     2686        {141, false}, {142, false}, {143, true},  {144, false}, {145, false}, {146, false},
     2687        {147, false}, {148, false}, {149, false}, {150, false}, {151, false}, {152, false},
     2688        {153, false}, {154, false}, {155, false}, {156, false}, {157, false}, {158, false},
     2689        {159, false}, {160, false}, {0, false},   {162, false}, {163, false}, {164, false},
     2690        {165, false}, {0, false},   {167, false}, {168, false}, {169, false}, {170, false}
     2691};
     2692
     2693const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2introTracks[] = {
     2694        {0, false},   {0, false},   {1, false},   {2, false},   {3, false},   {4, true},
     2695        {5, true},    {6, false},   {7, false}
     2696};
     2697const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test1Tracks[] = {
     2698        {0, false},   {0, false},   {8, true},    {9, true}
     2699};
     2700const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test2Tracks[] = {
     2701        {0, false},   {0, false},   {18, true},   {19, true}
     2702};
     2703const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test3Tracks[] = {
     2704        {0, false},   {0, false},   {20, true},   {21, true}
     2705};
     2706const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test4Tracks[] = {
     2707        {0, false},   {0, false},   {22, true},   {23, true}
     2708};
     2709const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test5Tracks[] = {
     2710        {0, false},   {0, false},   {24, false},  {25, false},  {26, false},   {27, false},
     2711        {28, true},   {29, true}
     2712};
     2713const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test6Tracks[] = {
     2714        {0, false},   {0, false},   {0, false},   {30, true},   {31, true}
     2715};
     2716const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test7Tracks[] = {
     2717        {0, false},   {0, false},   {32, true},   {33, true},  {34, false},   {35, true},
     2718        {36, false},  {37, false},  {38, false},  {39, true}
     2719};
     2720const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test8Tracks[] = {
     2721        {0, false},   {0, false},   {40, true},   {41, false}, {42, false},   {43, true},
     2722        {44, false},  {45, true},   {46, false},  {47, true}
     2723};
     2724const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test9Tracks[] = {
     2725        {0, false},   {0, false},   {48, true},   {49, false}, {50, true},   {51, true},
     2726        {52, true},   {53, true},   {54, true},   {55, true}
     2727};
     2728const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test10Tracks[] = {
     2729        {0, false},   {0, false},   {10, false},  {11, false}, {12, true},   {13, true},
     2730        {14, false},  {15, false},  {16, false},  {17, true}
     2731};
     2732const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test11Tracks[] = {
     2733        {0, false},   {0, false},   {56, true},   {57, false}, {58, false},  {59, true},
     2734        {60, true},   {61, true}
     2735};
     2736const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test12Tracks[] = {
     2737        {0, false},   {0, false},   {62, true},   {63, true},  {63, true},   {64, true},
     2738        {65, false},  {66, true},   {67, true},   {68, true},  {69, true}
     2739};
     2740const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test13Tracks[] = {
     2741        {0, false},   {0, false},   {70, true},   {71, false}, {72, false},  {73, true},
     2742        {74, true},   {75, false},  {76, true},   {77, false}
     2743};
     2744const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test14Tracks[] = {
     2745        {0, false},   {0, false},   {78,true}
     2746};
     2747const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2test15Tracks[] = {
     2748        {0, false},   {0, false},   {79, true},   {80, false}, {81, true},   {82, false}
     2749};
     2750const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2finaleTracks[] = {
     2751        {0, false},   {0, false},   {0,false},    {83, true},   {84, false}
     2752};
     2753
     2754const SoundAdLibPC::DigitalTrack SoundAdLibPC::_k2effectTracks[] = {
     2755        {0, false},  {91, false},  {92, false},  {93, false},  {94, false},  {95, false},
     2756        {96, false},  {97, false},  {98, false},  {99, false},  {100, false}, {101, false},
     2757        {102, false}, {103, false}, {104, false}, {105, false}, {106, false}, {107, false},
     2758        {108, false}, {109, false}, {110, false}, {111, false}, {112, false}, {113, false},
     2759        {114, false}, {115, false}, {116, false}, {117, false}, {118, false}, {119, false},
     2760        {120, false}, {121, false}, {122, false}, {123, false}, {124, false}, {125, false},
     2761        {126, false}, {127, false}, {128, false}, {129, false}, {130, false}, {131, false},
     2762        {132, false}, {133, false}, {134, false}, {135, false}, {136, false}, {137, false},
     2763        {138, false}, {139, false}, {140, false}, {141, false}, {142, false}, {143, false},
     2764        {144, false}, {145, false}, {146, false}, {147, false}, {148, false}, {149, false},
     2765        {150, false}, {151, false}, {152, false}, {153, false}
     2766};
     2767
     2768const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lolintroTracks[] = {
     2769        {0, false},   {0, false},   {1,false}, {0, false},{0, false},{0, false},   {2, true},   {3, false}
     2770};
     2771
     2772const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore01aTracks[] = {
     2773        {0, false},   {0, false},   {4,true}, {5, true}, {6, true}, {7, true},   {8, false},
     2774        {9, true},   {10, false},   {11, false}
     2775};
     2776
     2777const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore01bTracks[] = {
     2778        {0, false},   {0, false},   {12,true}, {0, false}, {13, true}, {14, false},   {15, true},
     2779        {0, false},   {16, false},   {17, false}
     2780};
     2781
     2782const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore01cTracks[] = {
     2783        {0, false},   {0, false},   {18,false}, {19, true}, {20, true}, {21, true},   {22, true},
     2784        {23, true}
     2785};
     2786
     2787const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore01dTracks[] = {
     2788        {0, false},   {0, false},   {24,true}, {25, true}, {26, true}
     2789};
     2790
     2791const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore02aTracks[] = {
     2792        {0, false},   {0, false},   {27,true}, {28, true}, {29, true}, {30, true},   {31,false},
     2793        {32, false},   {33, false},   {34, true}
     2794};
     2795
     2796const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore03aTracks[] = {
     2797        {0, false},   {0, false},   {35,true}, {36, true}, {37, true}, {38, true},   {39,true}
     2798};
     2799
     2800const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore03bTracks[] = {
     2801        {0, false},   {0, false},   {40,false}, {41, false}, {42, false}, {43, false},   {44,false},
     2802        {45, false},   {46, false}
     2803};
     2804
     2805const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore04aTracks[] = {
     2806        {0, false},   {0, false},   {47, false}, {48, false}, {49, true}, {50, false},   {51,false},
     2807        {52, false},   {53, false}
     2808};
     2809const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore05aTracks[] = {
     2810        {0, false},   {0, false},   {54, false}, {55, true}, {56, true}, {57, false},   {58,true}
     2811};
     2812const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore05bTracks[] = {
     2813        {0, false},   {0, false},   {59, true}, {60, false}, {61, false}, {62, true},   {63,true}
     2814};
     2815const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore06aTracks[] = {
     2816        {0, false},   {0, false},   {64, true}, {65, false}, {66, true}, {67, true},   {68,false}
     2817};
     2818const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore06bTracks[] = {
     2819        {0, false},   {0, false},   {69, true}
     2820};
     2821const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore07aTracks[] = {
     2822        {0, false},   {0, false},   {70, false}, {71, false}
     2823};
     2824const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore08aTracks[] = {
     2825        {0, false},   {0, false},   {72, false}, {73, false}, {74, true}, {75, false},   {76,false},   {77,true}
     2826};
     2827const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lore08bTracks[] = {
     2828        {0, false},   {0, false},   {78, true}, {79, false}
     2829};
     2830const SoundAdLibPC::DigitalTrack SoundAdLibPC::_lorefinlTracks[] = {
     2831        {0, false},   {0, false},   {80, false}, {81, false}, {82, false}
     2832};
     2833
     2834SoundAdLibPC::DigitalTrack SoundAdLibPC::getDigitalMusicTrack(uint8 track) {
     2835          if (_vm->game() == GI_KYRA1) {
     2836                  if(_currentTrack == "kyra1a") return _kyra1aTracks[track];
     2837                  else if (_currentTrack == "kyra1b") return _kyra1bTracks[track];
     2838                  else if (_currentTrack == "kyra2a") return _kyra2aTracks[track];
     2839                  else if (_currentTrack == "kyra3a") return _kyra3aTracks[track];
     2840                  else if (_currentTrack == "kyra4a") return _kyra4aTracks[track];
     2841                  else if (_currentTrack == "kyra4b") return _kyra4bTracks[track];
     2842                  else if (_currentTrack == "kyra5a") return _kyra5aTracks[track];
     2843                  else if (_currentTrack == "kyra5b") return _kyra5bTracks[track];
     2844                  else if (_currentTrack == "kyramisc") return _kyramiscTracks[track];
     2845                  else if (_currentTrack == "intro") return _introTracks[track];
     2846           }
     2847          if (_vm->game() == GI_KYRA2) {
     2848                  if(_currentTrack == "k2intro") return _k2introTracks[track];
     2849                  else if (_currentTrack == "k2test1") return _k2test1Tracks[track];
     2850                  else if (_currentTrack == "k2test2") return _k2test2Tracks[track];
     2851                  else if (_currentTrack == "k2test3") return _k2test3Tracks[track];
     2852                  else if (_currentTrack == "k2test4") return _k2test4Tracks[track];
     2853                  else if (_currentTrack == "k2test5") return _k2test5Tracks[track];
     2854                  else if (_currentTrack == "k2test6") return _k2test6Tracks[track];
     2855                  else if (_currentTrack == "k2test7") return _k2test7Tracks[track];
     2856                  else if (_currentTrack == "k2test8") return _k2test8Tracks[track];
     2857                  else if (_currentTrack == "k2test9") return _k2test9Tracks[track];
     2858                  else if (_currentTrack == "k2test10") return _k2test10Tracks[track];
     2859                  else if (_currentTrack == "k2test11") return _k2test11Tracks[track];
     2860                  else if (_currentTrack == "k2test12") return _k2test12Tracks[track];
     2861                  else if (_currentTrack == "k2test13") return _k2test13Tracks[track];
     2862                  else if (_currentTrack == "k2test14") return _k2test14Tracks[track];
     2863                  else if (_currentTrack == "k2test15") return _k2test15Tracks[track];
     2864                  else if (_currentTrack == "k2finale") return _k2finaleTracks[track];
     2865           }
     2866           if (_vm->game() == GI_LOL) {
     2867                  if(_currentTrack == "loreintr") return _lolintroTracks[track];
     2868                  else if(_currentTrack == "lore01a") return _lore01aTracks[track];
     2869                  else if(_currentTrack == "lore01b") return _lore01bTracks[track];
     2870                  else if(_currentTrack == "lore01c") return _lore01cTracks[track];
     2871                  else if(_currentTrack == "lore01d") return _lore01dTracks[track];
     2872                  else if(_currentTrack == "lore02a") return _lore02aTracks[track];
     2873                  else if(_currentTrack == "lore03a") return _lore03aTracks[track];
     2874                  else if(_currentTrack == "lore03b") return _lore03bTracks[track];
     2875                  else if(_currentTrack == "lore04a") return _lore04aTracks[track];
     2876                  else if(_currentTrack == "lore05a") return _lore05aTracks[track];
     2877                  else if(_currentTrack == "lore05b") return _lore05bTracks[track];
     2878                  else if(_currentTrack == "lore06a") return _lore06aTracks[track];
     2879                  else if(_currentTrack == "lore06b") return _lore06bTracks[track];
     2880                  else if(_currentTrack == "lore07a") return _lore07aTracks[track];
     2881                  else if(_currentTrack == "lore08a") return _lore08aTracks[track];
     2882                  else if(_currentTrack == "lore08b") return _lore08bTracks[track];
     2883                  else if(_currentTrack == "lorefinl") return _lorefinlTracks[track];
     2884           }
     2885       return _introTracks[0]; //return empty track
     2886     
     2887 }
     2888
     2889SoundAdLibPC::DigitalTrack SoundAdLibPC::getDigitalEffectsTrack(uint8 track) {
     2890         if (_vm->game() == GI_KYRA1) {
     2891                return getDigitalMusicTrack(track);
     2892         }
     2893         if (_vm->game() == GI_KYRA2) {
     2894                return _introTracks[0];//hack for now since I can't be arsed to fix the fx
     2895         }
     2896         return _introTracks[0]; //return empty track
     2897}
     2898
     2899
     2900
     2901
     2902} // end of namespace Kyra
     2903
  • engines/kyra/sound_adlib.h

     
    8484private:
    8585        void internalLoadFile(Common::String file);
    8686
    87         void play(uint8 track);
     87        void play(uint8 track, bool soundeffect=false);
    8888
    8989        void unk1();
    9090        void unk2();
     
    9797        int _sfxPlayingSound;
    9898
    9999        Common::String _soundFileLoaded;
     100        Common::String _currentTrack;
     101        Common::String _currentSoundEffect;
    100102
    101103        uint8 _sfxPriority;
    102104        uint8 _sfxFourthByteOfSong;
     
    106108
    107109        static const int _kyra1NumSoundTriggers;
    108110        static const int _kyra1SoundTriggers[];
     111
     112        Audio::SoundHandle _fxHandle;
     113       
     114        struct DigitalTrack {
     115                const uint8 track;
     116                const bool loop;
     117        };
     118
     119        static const DigitalTrack _introTracks[];
     120        static const DigitalTrack _kyra1aTracks[];
     121        static const DigitalTrack _kyra1bTracks[];
     122        static const DigitalTrack _kyra2aTracks[];
     123        static const DigitalTrack _kyra3aTracks[];
     124        static const DigitalTrack _kyra4aTracks[];
     125        static const DigitalTrack _kyra4bTracks[];
     126        static const DigitalTrack _kyra5aTracks[];
     127        static const DigitalTrack _kyra5bTracks[];
     128        static const DigitalTrack _kyramiscTracks[];
     129        static const DigitalTrack _k2introTracks[];
     130        static const DigitalTrack _k2test1Tracks[];
     131        static const DigitalTrack _k2test2Tracks[];
     132        static const DigitalTrack _k2test3Tracks[];
     133        static const DigitalTrack _k2test4Tracks[];
     134        static const DigitalTrack _k2test5Tracks[];
     135        static const DigitalTrack _k2test6Tracks[];
     136        static const DigitalTrack _k2test7Tracks[];
     137        static const DigitalTrack _k2test8Tracks[];
     138        static const DigitalTrack _k2test9Tracks[];
     139        static const DigitalTrack _k2test10Tracks[];
     140        static const DigitalTrack _k2test11Tracks[];
     141        static const DigitalTrack _k2test12Tracks[];
     142        static const DigitalTrack _k2test13Tracks[];
     143        static const DigitalTrack _k2test14Tracks[];
     144        static const DigitalTrack _k2test15Tracks[];
     145        static const DigitalTrack _k2finaleTracks[];
     146        static const DigitalTrack _k2effectTracks[];
     147
     148        static const DigitalTrack _lolintroTracks[];
     149        static const DigitalTrack _lore01aTracks[];
     150        static const DigitalTrack _lore01bTracks[];             
     151        static const DigitalTrack _lore01cTracks[];             
     152        static const DigitalTrack _lore01dTracks[];
     153        static const DigitalTrack _lore02aTracks[];             
     154        static const DigitalTrack _lore03aTracks[];     
     155        static const DigitalTrack _lore03bTracks[];     
     156        static const DigitalTrack _lore04aTracks[];     
     157        static const DigitalTrack _lore05aTracks[];
     158        static const DigitalTrack _lore05bTracks[];     
     159        static const DigitalTrack _lore06aTracks[];     
     160        static const DigitalTrack _lore06bTracks[];     
     161        static const DigitalTrack _lore07aTracks[];     
     162        static const DigitalTrack _lore08aTracks[];     
     163        static const DigitalTrack _lore08bTracks[];     
     164        static const DigitalTrack _lorefinlTracks[];   
     165        DigitalTrack getDigitalMusicTrack(uint8 track);
     166        DigitalTrack getDigitalEffectsTrack(uint8 track);
    109167};
    110168
    111169} // End of namespace Kyra
  • engines/kyra/sound_lol.cpp

     
    3030#include "kyra/resource.h"
    3131
    3232#include "sound/audiostream.h"
     33#include "sound/audiocd.h"
    3334
    3435namespace Kyra {
    3536
  • engines/lure/debugger.cpp

     
    3535#include "lure/room.h"
    3636#include "lure/scripts.h"
    3737#include "lure/strings.h"
     38#include "lure/sound.h"
    3839
    3940namespace Lure {
    4041
     
    5354        DCmd_Register("strings",                        WRAP_METHOD(Debugger, cmd_saveStrings));
    5455        DCmd_Register("debug",                          WRAP_METHOD(Debugger, cmd_debug));
    5556        DCmd_Register("script",                         WRAP_METHOD(Debugger, cmd_script));
     57        DCmd_Register("playsound",                      WRAP_METHOD(Debugger, cmd_playSounds));
    5658}
    5759
    5860static int strToInt(const char *s) {
     
    115117        return true;
    116118}
    117119
     120bool Debugger::cmd_playSounds(int argc, const char **argv) {
     121        int a=strToInt(argv[1]);
     122        Sound.killSounds();
     123        Sound.musicInterface_Play(a,0);
     124        return true;
     125}
     126
    118127bool Debugger::cmd_listRooms(int argc, const char **argv) {
    119128        RoomDataList &rooms = Resources::getReference().roomData();
    120129        StringData &strings = StringData::getReference();
  • engines/lure/debugger.h

     
    4949        bool cmd_saveStrings(int argc, const char **argv);
    5050        bool cmd_debug(int argc, const char **argv);
    5151        bool cmd_script(int argc, const char **argv);
     52        bool cmd_playSounds(int argc, const char **argv);
    5253};
    5354
    5455extern const char *directionList[5];
  • engines/lure/sound.cpp

     
    3333#include "common/config-manager.h"
    3434#include "common/endian.h"
    3535#include "sound/midiparser.h"
     36#include "sound/audiocd.h"
     37#include "sound/mixer.h"
     38#include "sound/audiostream.h"
    3639
    3740DECLARE_SINGLETON(Lure::SoundManager)
    3841
     
    4144//#define SOUND_CROP_CHANNELS
    4245
    4346SoundManager::SoundManager() {
     47        currentSection=1;
    4448        Disk &disk = Disk::getReference();
    4549        _soundMutex = g_system->createMutex();
     50        _mixer = g_system->getMixer();
    4651
    4752        int index;
    4853        _descs = disk.getEntry(SOUND_DESC_RESOURCE_ID);
     
    8388SoundManager::~SoundManager() {
    8489        if (_driver)
    8590                _driver->setTimerCallback(this, NULL);
     91        _mixer->stopAll();
    8692
    8793        removeSounds();
    8894        _activeSounds.clear();
     
    134140
    135141
    136142void SoundManager::loadSection(uint16 sectionId) {
     143
    137144        debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::loadSection = %xh", sectionId);
    138145        killSounds();
     146        if( sectionId==ROLAND_MAIN_SOUND_RESOURCE_ID || sectionId==ADLIB_MAIN_SOUND_RESOURCE_ID)
     147        {
     148                currentSection=1;
     149        }
     150        else
     151        {
     152                currentSection=0;
     153        }
    139154
    140155        if (_soundData) {
    141156                delete _soundData;
     
    325340                        return rec;
    326341                }
    327342        }
     343        if(AudioCD.isPlaying())
     344                {
     345                        if(AudioCD.getStatus().track==soundNumber || AudioCD.getStatus().track+128==soundNumber)
     346                        {
     347                                SoundDescResource *rec=new SoundDescResource();
     348                                rec->soundNumber=soundNumber;
     349                                return rec;
     350                        }
     351                }
     352                for (int channel = 0; channel < ARRAYSIZE(_sounds); ++channel)
     353                {
     354                        if(_mixer->isSoundHandleActive(_sounds[channel].handle) && _sounds[channel].tracknumber==soundNumber)
     355                        {
     356                                SoundDescResource *rec=new SoundDescResource();
     357                                rec->soundNumber=soundNumber;
     358                                rec->channel=channel;
     359                                return rec;
     360                        }
     361                }
    328362
    329363        // Signal that sound wasn't found
    330364        debugC(ERROR_INTERMEDIATE, kLureDebugSounds, "SoundManager::findSound - sound not found");
     
    364398
    365399                ++i;
    366400        }
     401        _mixer->pauseAll(true);
     402
    367403}
    368404
    369405void SoundManager::restoreSounds() {
     
    382418
    383419                ++i;
    384420        }
     421        _mixer->pauseAll(false);
    385422}
    386423
    387424void SoundManager::fadeOut() {
    388425        debugC(ERROR_BASIC, kLureDebugSounds, "SoundManager::fadeOut");
    389426
    390427        // Fade out all the active sounds
    391         musicInterface_TidySounds();
    392428
    393429        bool inProgress = true;
    394430        while (inProgress)
     
    421457void SoundManager::musicInterface_Play(uint8 soundNumber, uint8 channelNumber, uint8 numChannels) {
    422458        debugC(ERROR_INTERMEDIATE, kLureDebugSounds, "musicInterface_Play soundNumber=%d, channel=%d",
    423459                soundNumber, channelNumber);
     460
     461        bool foundDigital=false;
     462
     463        uint8 sn=soundNumber;
     464        if(currentSection!=0) sn+=10;
     465        bool isMusic = (sn & 0x80)!= 0;
     466        while(sn>127)
     467        {
     468                sn-=128;
     469        }
     470        uint8 soundNum = soundNumber & 0x7f;
     471
     472
     473        debugC(ERROR_DETAILED, kLureDebugSounds, "MidiMusic::PlayMusic playing sound %d", soundNumber);
     474        /*if(isMusic)
     475        {
     476                //if its music I'm going to try to play it using the audiocd player
     477                AudioCD.stop();
     478                AudioCD.play(sn,1,0,0);
     479                if(AudioCD.isPlaying()) foundDigital=true;
     480        }
     481        else
     482        {*/
     483                //if it isn't then it must be sfx so I want to play it through digital audio instead.
     484                //I'm using 4 channels here which I'm assuming is overkill but I'm guessing
     485
     486                char trackName[16];
     487                sprintf(trackName, "track%d", sn);
     488
     489                _mixer->stopHandle(_sounds[channelNumber].handle);
     490                _sounds[channelNumber].tracknumber=-1;
     491
     492                _sounds[channelNumber].stream =0;
     493                bool loops=false;
     494                if(soundNumber==153) loops=true;
     495                _sounds[channelNumber].stream = Audio::SeekableAudioStream::openStreamFile(trackName);
     496                if (_sounds[channelNumber].stream != 0) {
     497                        //found a channel - play the fx
     498                        Audio::Timestamp start = Audio::Timestamp(0, 0, 75);
     499                        Audio::Timestamp end = 0 ? Audio::Timestamp(0, 0 + 0, 75) : _sounds[channelNumber].stream->getLength();
     500
     501                        _mixer->playStream(Audio::Mixer::kSFXSoundType, &_sounds[channelNumber].handle,
     502                                Audio::makeLoopingAudioStream(_sounds[channelNumber].stream,start ,end , (loops) ? 0 : 1));
     503                        _sounds[channelNumber].tracknumber=soundNumber;
     504                        foundDigital=true;
     505                }
     506//      }
     507        if(foundDigital) return;
     508
     509
     510
     511
    424512        Game &game = Game::getReference();
    425513
    426514        if (!_soundData)
    427515                error("Sound section has not been specified");
    428516
    429         uint8 soundNum = soundNumber & 0x7f;
    430517        if (soundNum > _soundsTotal)
    431518                error("Invalid sound index %d requested", soundNum);
    432519
     
    434521                // Only play sounds if a sound driver is active
    435522                return;
    436523
    437         bool isMusic = (soundNumber & 0x80) != 0;
    438 
    439524        if (!game.soundFlag())
    440525                // Don't play sounds if sound is turned off
    441526                return;
     
    466551        musicInterface_TidySounds();
    467552        uint8 soundNum = soundNumber & 0x7f;
    468553
     554        if(AudioCD.getStatus().track==soundNumber) AudioCD.stop();
     555        if(AudioCD.getStatus().track+128==soundNumber) AudioCD.stop();
     556
     557        for (int channel = 0; channel < ARRAYSIZE(_sounds); ++channel)
     558        {
     559                if (_sounds[channel].tracknumber==soundNumber)
     560                {
     561                        _mixer->stopHandle(_sounds[channel].handle);
     562                        _sounds[channel].tracknumber=-1;
     563                }
     564        }
     565
    469566        g_system->lockMutex(_soundMutex);
    470567        MusicListIterator i;
    471568        for (i = _playingSounds.begin(); i != _playingSounds.end(); ++i) {
     
    498595        }
    499596        g_system->unlockMutex(_soundMutex);
    500597
     598        if(AudioCD.isPlaying() && (AudioCD.getStatus().track==soundNumber||AudioCD.getStatus().track+128==soundNumber))
     599        {
     600                result=true;
     601        }
     602        for (int channel = 0; channel < ARRAYSIZE(_sounds); ++channel)
     603        {
     604                if(_sounds[channel].tracknumber==soundNumber && _mixer->isSoundHandleActive(_sounds[channel].handle) )
     605                {
     606                        result=true;
     607                }
     608        }
    501609        return result;
    502610}
    503611
     
    517625                        music->setVolume(volume);
    518626        }
    519627        g_system->unlockMutex(_soundMutex);
     628
     629        if(_mixer->isSoundHandleActive(_sounds[channelNum].handle) )
     630        {
     631                _mixer->setChannelVolume(_sounds[channelNum].handle, volume);
     632        }
     633
     634
    520635}
    521636
    522637// musicInterface_KillAll
     
    532647                MidiMusic *music = (*i).get();
    533648                music->stopMusic();
    534649        }
     650        AudioCD.stop();
    535651
     652        for (int channel = 0; channel < ARRAYSIZE(_sounds); ++channel)
     653        {
     654                _mixer->stopHandle(_sounds[channel].handle);
     655                _sounds[channel].tracknumber=-1;
     656        }
     657
    536658        _playingSounds.clear();
    537659        _activeSounds.clear();
    538660        g_system->unlockMutex(_soundMutex);
     
    680802}
    681803
    682804void MidiMusic::playMusic() {
    683         debugC(ERROR_DETAILED, kLureDebugSounds, "MidiMusic::PlayMusic playing sound %d", _soundNumber);
    684         _parser->loadMusic(_soundData, _soundSize);
    685         _parser->setTrack(0);
     805                _parser->loadMusic(_soundData, _soundSize);
     806                _parser->setTrack(0);
    686807        _isPlaying = true;
    687808}
    688809
  • engines/lure/sound.h

     
    6868
    6969        bool _passThrough;
    7070
     71
    7172public:
    7273        MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
    7374                 uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size);
     
    128129        Common::MutexRef _soundMutex;
    129130        bool _paused;
    130131
     132        Audio::Mixer *_mixer;
     133
     134        struct SoundFX {
     135                Audio::SoundHandle handle;
     136
     137                int tracknumber;
     138                Audio::SeekableAudioStream *stream;
     139        } _sounds[16];
     140
     141
    131142        uint _musicVolume;
    132143        uint _sfxVolume;
    133144
     
    175186        void musicInterface_KillAll();
    176187        void musicInterface_ContinuePlaying();
    177188        void musicInterface_TrashReverb();
     189        int currentSection;
    178190};
    179191
    180192} // End of namespace Lure
  • engines/m4/midi.cpp

     
    2929#include "m4/m4.h"
    3030#include "m4/midi.h"
    3131#include "common/stream.h"
     32#include "sound/audiocd.h"
    3233
    3334namespace M4 {
    3435
     
    145146
    146147void MidiPlayer::playMusic(const char *name, int32 vol, bool loop, int32 trigger, int32 scene) {
    147148        stopMusic();
     149        AudioCD.stop();
    148150
    149151        char fullname[144];
    150152        _vm->res()->changeExtension(fullname, name, "HMP");
     
    159161        _vm->res()->toss(fullname);
    160162        _vm->res()->purge();
    161163
    162         if (_midiData) {
     164        //support for CD Audio - not very efficient but just need to add a list of filenames for each game
     165        //should really use game check also in case of duplicate file names but won't be an issue
     166        //unless someone dumps a load of music into the game directory
     167
     168        char* nameArray[]={"name1","name2"};
     169        for(int a=0;a<sizeof(nameArray);a++)
     170        {
     171                if(nameArray[a]==name) AudioCD.play(a,loop?-1:1,0,0);
     172        }
     173
     174        if (_midiData && !AudioCD.isPlaying()) {
    163175                /*
    164176                FILE *out = fopen("music.mid", "wb");
    165177                fwrite(_midiData, smfSize, 1, out);
     
    176188
    177189void MidiPlayer::stopMusic() {
    178190        Common::StackLock lock(_mutex);
     191        AudioCD.stop();
    179192
    180193        _isPlaying = false;
    181194        if (_parser) {
  • engines/made/music.cpp

     
    1 /* ScummVM - Graphic Adventure Engine
     1 /* ScummVM - Graphic Adventure Engine
    22 *
    33 * ScummVM is the legal property of its developers, whose names
    44 * are too numerous to list here. Please refer to the COPYRIGHT
     
    3434#include "common/file.h"
    3535
    3636#include "made/music.h"
     37#include "sound/audiocd.h"
    3738
    3839namespace Made {
    3940
     
    202203}
    203204
    204205void MusicPlayer::stop() {
     206        AudioCD.stop();
    205207        Common::StackLock lock(_mutex);
    206208
    207209        _isPlaying = false;
     
    212214}
    213215
    214216void MusicPlayer::pause() {
     217        AudioCD.stop();
    215218        setVolume(-1);
    216219        _isPlaying = false;
    217220}
  • engines/made/scriptfuncs.cpp

     
    273273
    274274        if (_vm->getGameID() == GID_RTZ) {
    275275                if (musicNum > 0) {
     276
    276277                        _musicRes = _vm->_res->getXmidi(musicNum);
    277278                        if (_musicRes)
    278                                 _vm->_music->playXMIDI(_musicRes);
     279                        {
     280                                //AudioCD.stop();
     281                /*      int loops[50]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     282                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     283                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     284                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     285                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
     286                //              AudioCD.play(musicNum,loops[musicNum],0,0);
     287                                //if(!AudioCD.isPlaying()) */
     288                                        _vm->_music->playXMIDI(_musicRes);
     289                        }
     290
    279291                }
    280292        } else {
    281293                // HACK: music number 2 in LGOP2 is file MT32SET.TON, which
     
    287299                        return 0;
    288300                if (musicNum > 0) {
    289301                        _musicRes = _vm->_res->getMidi(musicNum);
    290                         if (_musicRes)
    291                                 _vm->_music->playSMF(_musicRes);
     302                        if (_musicRes) {
     303                                if(AudioCD.getStatus().track!=musicNum)
     304                                {
     305                                        AudioCD.stop();
     306                                        int loops[50]={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     307                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     308                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     309                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
     310                                                        -1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
     311                                        AudioCD.play(musicNum,loops[musicNum],0,0);
     312                                }
     313                                if(!AudioCD.isPlaying()) _vm->_music->playSMF(_musicRes);
     314                        }
    292315                }
    293316        }
    294317
  • engines/saga/music.cpp

     
    286286        } else {
    287287                realTrackNumber = resourceId + 1;
    288288        }
     289        if (_vm->getGameId() == GID_IHNM) {
     290                        flags = MUSIC_LOOP;
     291        }
    289292
    290293        // Try to open standalone digital track
    291294        char trackName[2][16];
  • engines/sci/sound/midiparser_sci.cpp

     
    563563        case 0x9:
    564564        case 0xA:
    565565        case 0xE:
     566                if(_pSnd->playSilent) info.event = info.channel() | 0x80;
    566567                info.basic.param1 = *(_position._play_pos++);
    567568                info.basic.param2 = *(_position._play_pos++);
    568569                if (info.command() == 0x9 && info.basic.param2 == 0)
  • engines/sci/sound/music.cpp

     
    3535#include "sci/engine/state.h"
    3636#include "sci/sound/midiparser_sci.h"
    3737#include "sci/sound/music.h"
     38#include "sound/audiocd.h"
    3839
    3940namespace Sci {
    4041
     
    256257                if (track->digitalChannelNr != -1) {
    257258                        byte *channelData = track->channels[track->digitalChannelNr].data;
    258259                        delete pSnd->pStreamAud;
     260                        delete pSnd->pStreamAud2;
    259261                        byte flags = Audio::FLAG_UNSIGNED;
    260262                        // Amiga SCI1 games had signed sound data
    261263                        if (_soundVersion >= SCI_VERSION_1_EARLY && g_sci->getPlatform() == Common::kPlatformAmiga)
     
    265267                                                                track->digitalSampleSize - track->digitalSampleStart - endPart,
    266268                                                                track->digitalSampleRate, flags, DisposeAfterUse::NO);
    267269                        delete pSnd->pLoopStream;
     270                        delete pSnd->pLoopStream2;
     271                        pSnd->pLoopStream2=0;
    268272                        pSnd->pLoopStream = 0;
    269273                        pSnd->soundType = Audio::Mixer::kSFXSoundType;
    270274                        pSnd->hCurrentAud = Audio::SoundHandle();
     
    329333}
    330334
    331335void SciMusic::soundPlay(MusicEntry *pSnd) {
     336
    332337        _mutex.lock();
    333338
    334339        uint playListCount = _playList.size();
     
    368373                }
    369374        }
    370375
     376               
     377        //Attempt to play using AudioCD sound
     378        //If the CD Audio isn't already going then play with audiocd
     379        pSnd->playSilent=false;
     380        /*if(!AudioCD.isPlaying())
     381        {
     382                AudioCD.play(pSnd->resourceId,pSnd->loop,0,0);
     383                if(AudioCD.isPlaying()) pSnd->playSilent=true;
     384        }
     385        else
     386        {*/
     387                //if its not priority 1 then try to play digitally as a sound effect
     388                //I'm going to piggyback the existing audio functions and make my ogg behave like a SCI digital resource thus avoiding me doing any work....
     389                char trackName[16];
     390                sprintf(trackName, "track%d", pSnd->resourceId);
     391                Audio::SeekableAudioStream *_cdSoundStream;
     392                if(pSnd->status==kSoundPaused)
     393                {
     394                        _pMixer->pauseHandle(pSnd->hCurrentAud2,false);
     395                        pSnd->playSilent=true;
     396                }
     397                if(!_pMixer->isSoundHandleActive(pSnd->hCurrentAud2))
     398                {
     399                        if(_cdSoundStream=Audio::SeekableAudioStream::openStreamFile(trackName))
     400                        {
     401       
     402                                pSnd->length=_cdSoundStream->getLength().msecs();
     403                                pSnd->pStreamAud2 = _cdSoundStream;
     404                                                if (pSnd->loop > 1) {
     405                                pSnd->pLoopStream2 = new Audio::LoopingAudioStream(pSnd->pStreamAud2,
     406                                                                                                                                pSnd->loop, DisposeAfterUse::NO
     407                                                                                                                                );
     408                                _pMixer->playStream(pSnd->soundType, &pSnd->hCurrentAud2,
     409                                                                                pSnd->pLoopStream2, -1, pSnd->volume*2, 0,
     410                                                                                DisposeAfterUse::NO);
     411                        } else {
     412                                _pMixer->playStream(pSnd->soundType, &pSnd->hCurrentAud2,
     413                                        pSnd->pStreamAud2, -1, pSnd->volume*2, 0,
     414                                                                                DisposeAfterUse::NO);
     415                        }
     416                                        //_pMidiDrv->setVolume(vol);
     417                        pSnd->playSilent=true;
     418                        }
     419                }
     420        //}
    371421        if (pSnd->pStreamAud) {
    372422                if (!_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) {
    373423                        // Sierra SCI ignores volume set when playing samples via kDoSound
     
    411461}
    412462
    413463void SciMusic::soundStop(MusicEntry *pSnd) {
     464
     465        if(pSnd&&pSnd->pStreamAud2)
     466        {
     467                int32 timeelapsed=_pMixer->getSoundElapsedTime(pSnd->hCurrentAud2);
     468
     469                if(pSnd->loop<=1&&pSnd->length-timeelapsed<4000&&_pMixer->isSoundHandleActive(pSnd->hCurrentAud2))
     470                {
     471                        return;
     472                }
     473                //checks to see if less than 4 seconds left in sample and carries on playing it if there are
     474        }
    414475        SoundStatus previousStatus = pSnd->status;
     476        if(pSnd->resourceId==AudioCD.getStatus().track) AudioCD.stop();
    415477        pSnd->status = kSoundStopped;
    416478        if (_soundVersion <= SCI_VERSION_0_LATE)
    417479                pSnd->isQueued = false;
    418480        if (pSnd->pStreamAud)
    419481                _pMixer->stopHandle(pSnd->hCurrentAud);
     482        //if(_pMixer->getSoundElapsedTime(pSnd->hCurrentAud2)<pSnd->pStreamAud2->);
     483        if (pSnd->pStreamAud2)
     484                _pMixer->stopHandle(pSnd->hCurrentAud2);
    420485
    421486        if (pSnd->pMidiParser) {
    422487                _mutex.lock();
     
    438503        if (pSnd->pStreamAud) {
    439504                // we simply ignore volume changes for samples, because sierra sci also
    440505                //  doesn't support volume for samples via kDoSound
    441         } else if (pSnd->pMidiParser) {
     506        }
     507        if (pSnd->pStreamAud2) {
     508                _pMixer->setChannelVolume(pSnd->hCurrentAud2, volume * 2); // Mixer is 0-255, SCI is 0-127
     509        }
     510        if (pSnd->pMidiParser) {
    442511                _mutex.lock();
    443512                pSnd->pMidiParser->mainThreadBegin();
    444513                pSnd->pMidiParser->setVolume(volume);
     
    481550                delete pSnd->pLoopStream;
    482551                pSnd->pLoopStream = 0;
    483552        }
     553        if (pSnd->pStreamAud2) {
     554                _pMixer->stopHandle(pSnd->hCurrentAud2);
     555                delete pSnd->pStreamAud2;
     556                pSnd->pStreamAud2 = NULL;
     557                delete pSnd->pLoopStream2;
     558                pSnd->pLoopStream2 = 0;
     559        }
    484560
    485561        _mutex.lock();
    486562        uint sz = _playList.size(), i;
     
    514590        pSnd->status = kSoundPaused;
    515591        if (pSnd->pStreamAud) {
    516592                _pMixer->pauseHandle(pSnd->hCurrentAud, true);
    517         } else {
    518                 if (pSnd->pMidiParser) {
     593        } else
     594        {
     595        if (pSnd->pStreamAud2) {
     596                _pMixer->pauseHandle(pSnd->hCurrentAud2, true);
     597        }
     598        if (pSnd->pMidiParser) {
    519599                        _mutex.lock();
    520600                        pSnd->pMidiParser->mainThreadBegin();
    521601                        pSnd->pMidiParser->pause();
     
    536616        if (pSnd->pStreamAud) {
    537617                _pMixer->pauseHandle(pSnd->hCurrentAud, false);
    538618                pSnd->status = kSoundPlaying;
    539         } else {
     619        } else
     620        {
     621        if (pSnd->pStreamAud2) {
     622                _pMixer->pauseHandle(pSnd->hCurrentAud2, false);
     623                pSnd->status = kSoundPlaying;
     624        }else {
    540625                soundPlay(pSnd);
    541         }
     626        }}
    542627}
    543628
    544629void SciMusic::soundToggle(MusicEntry *pSnd, bool pause) {
     
    665750        soundType = Audio::Mixer::kMusicSoundType;
    666751
    667752        pStreamAud = 0;
     753        pStreamAud2 = 0;
    668754        pLoopStream = 0;
     755        pLoopStream2 = 0;
    669756        pMidiParser = 0;
    670757}
    671758
     
    706793                        fadeStep = 0;
    707794                        fadeCompleted = true;
    708795                }
    709 
     796               
    710797                // Only process MIDI streams in this thread, not digital sound effects
    711798                if (pMidiParser) {
    712799                        pMidiParser->setVolume(volume);
  • engines/sci/sound/music.h

     
    8787        bool fadeSetVolume;
    8888        bool fadeCompleted;
    8989        bool stopAfterFading;
     90        bool playSilent;
     91        uint32 length;
    9092
    9193        SoundStatus status;
    9294
     
    105107        Audio::LoopingAudioStream *pLoopStream;
    106108        Audio::SoundHandle hCurrentAud;
    107109
     110
     111        Audio::RewindableAudioStream *pStreamAud2;
     112        Audio::LoopingAudioStream *pLoopStream2;
     113        Audio::SoundHandle hCurrentAud2;
     114
    108115public:
    109116        MusicEntry();
    110117        ~MusicEntry();
     
    164171        }
    165172
    166173        void updateAudioStreamTicker(MusicEntry *pSnd) {
    167                 assert(pSnd->pStreamAud != 0);
    168                 pSnd->ticker = (uint16)(_pMixer->getSoundElapsedTime(pSnd->hCurrentAud) * 0.06);
     174               
     175                if(pSnd->pStreamAud) pSnd->ticker = (uint16)(_pMixer->getSoundElapsedTime(pSnd->hCurrentAud) * 0.06);
     176                if(pSnd->pStreamAud2) pSnd->ticker = (uint16)(_pMixer->getSoundElapsedTime(pSnd->hCurrentAud2) * 0.06);
    169177        }
    170178
    171179        MusicEntry *getSlot(reg_t obj);
  • engines/sci/sound/soundcmd.cpp

     
    411411                        musicSlot->fadeSetVolume = false;
    412412                }
    413413        } else if (musicSlot->pMidiParser) {
     414
     415                if(     musicSlot->pStreamAud2&&musicSlot->fadeSetVolume)
     416                {
     417                        _music->soundSetVolume(musicSlot, musicSlot->volume);
     418                        musicSlot->fadeSetVolume = false;
     419                }               
    414420                // Update MIDI slots
    415421                if (musicSlot->signal == 0) {
    416422                        if (musicSlot->dataInc != readSelectorValue(_segMan, obj, SELECTOR(dataInc))) {
  • engines/scumm/imuse/imuse.cpp

     
    575575        // to bug #780918.
    576576
    577577        int i;
     578
     579        //HACK - I'm adding 99999 to the sound integer if its one I don't want to actually hear so I test for this here
     580        bool dontplayme=false;
     581        if(sound>99999)
     582        {
     583                sound-=99999;
     584                dontplayme=true;
     585        }
     586
    578587        ImTrigger *trigger = _snm_triggers;
    579588        for (i = ARRAYSIZE(_snm_triggers); i; --i, ++trigger) {
    580589                if (trigger->sound && trigger->id && trigger->command[0] == 8 && trigger->command[1] == sound && getSoundStatus_internal (trigger->sound,true))
     
    606615        if (!player)
    607616                return false;
    608617
     618
    609619        // WORKAROUND: This is to work around a problem at the Dino Bungie
    610620        // Memorial.
    611621        //
     
    636646
    637647        player->clear();
    638648        player->setOffsetNote(offset);
     649        if(dontplayme) sound+=99999;
    639650        return player->startSound(sound, driver, _direct_passthrough);
    640651}
    641652
  • engines/scumm/imuse/imuse_player.cpp

     
    9797        void *ptr;
    9898        int i;
    9999
     100
     101        //HACK - I'm adding 99999 to the sound integer if its one I don't want to actually hear so I test for this here
     102        bool dontplayme=false;
     103        if(sound>99999)
     104        {
     105                sound-=99999;
     106                dontplayme=true;
     107        }
     108
    100109        // Not sure what the old code was doing,
    101110        // but we'll go ahead and do a similar check.
    102111        ptr = _se->findStartOfSound(sound);
     
    122131        _passThrough = passThrough;
    123132
    124133        for (i = 0; i < ARRAYSIZE(_parameterFaders); ++i)
     134        {
    125135                _parameterFaders[i].init();
     136        }
    126137        hook_clear();
    127 
     138    if(dontplayme) sound+=99999;
    128139        if (start_seq_sound(sound) != 0) {
    129140                _active = false;
    130141                _midi = NULL;
     
    173184}
    174185
    175186int Player::start_seq_sound(int sound, bool reset_vars) {
     187       
     188        //HACK - I'm adding 99999 to the sound integer if its one I don't want to actually hear so I test for this here
     189        bool dontplayme=false;
     190        if(sound>99999)
     191        {
     192                sound-=99999;
     193                dontplayme=true;
     194        }
     195
    176196        byte *ptr;
    177 
    178197        if (reset_vars) {
    179198                _loop_to_beat = 1;
    180199                _loop_from_beat = 1;
     
    204223        _parser->property(MidiParser::mpSmartJump, 1);
    205224        _parser->loadMusic(ptr, 0);
    206225        _parser->setTrack(_track_index);
     226        if(dontplayme) _parser->_dontplayme=true;
     227
     228               
    207229        setSpeed(reset_vars ? 128 : _speed);
    208230
    209231        return 0;
  • engines/scumm/saveload.cpp

     
    471471                putState(819, 0);
    472472        }
    473473
     474
     475        //HACK to stop adlib sound playing if cd audio patch is working
     476        if (_game.id == GID_MONKEY_VGA && AudioCD.isPlaying()) {
     477                int track=AudioCD.getStatus().track;
     478                int numloops=AudioCD.getStatus().numLoops;
     479                int currentcdsound=_sound->getCurrentCDSound();
     480                _sound->stopAllSounds();
     481                _sound->pauseSounds(false);
     482                _sound->playCDTrack(track,numloops,0,0);
     483                _sound->pauseSounds(true);
     484                //_sound->_currentCDSound=currentcdsound;
     485        }
     486
     487        if(_game.platform == Common::kPlatformPC && _game.version == 0x03 && _game.id == GID_LOOM)
     488        {
     489                int numloops=AudioCD.getStatus().numLoops;
     490                int currentcdsound=_sound->getCurrentCDSound();
     491                _sound->stopAllSounds();
     492                _sound->pauseSounds(false);
     493                _sound->playCDTrack(currentcdsound-32,numloops,0,0);
     494                _sound->pauseSounds(true);
     495                //_sound->_currentCDSound=currentcdsound;
     496        }
     497
    474498        if (hdr.ver < VER(33) && _game.version >= 7) {
    475499                // For a long time, we didn't set these vars to default values.
    476500                VAR(VAR_DEFAULT_TALK_DELAY) = 60;
     
    574598
    575599        _sound->pauseSounds(false);
    576600
     601
    577602        // WORKAROUND: Original save/load script ran this script
    578603        // after game load, and o2_loadRoomWithEgo() does as well
    579604        // this script starts character-dependent music
  • engines/scumm/scumm.cpp

     
    17051705                break;
    17061706        }
    17071707
     1708        //HACK to get the adlib version of Loom PC EGA to use the MT32 midi's.
     1709
     1710        if(_game.version == 3 && _game.platform == Common::kPlatformPC && _game.id== GID_LOOM)
     1711                _musicType = MDT_MIDI;
     1712
     1713
     1714
    17081715        if ((_game.id == GID_MONKEY_EGA || (_game.id == GID_LOOM && _game.version == 3))
    17091716           &&  (_game.platform == Common::kPlatformPC) && _musicType == MDT_MIDI) {
    17101717                Common::String fileName;
  • engines/scumm/sound.cpp

     
    168168        Audio::AudioStream *stream;
    169169        int size = -1;
    170170        int rate;
     171        bool foundatrack=false;
    171172
    172173        if (_vm->_game.id == GID_LOOM && _vm->_game.platform == Common::kPlatformPCEngine) {
    173174                if (soundID >= 13 && soundID <= 32) {
     
    410411
    411412                if (_vm->_game.id == GID_MONKEY_VGA || _vm->_game.id == GID_MONKEY_EGA
    412413                        || (_vm->_game.id == GID_MONKEY && _vm->_game.platform == Common::kPlatformMacintosh)) {
     414                        if (_vm->_game.id == GID_MONKEY_VGA)
     415                        {
     416                                static const int tracks[20]={0x0000006e,0x0000006c,0x00000068,0x00000065,0x00000064,0x00000073,0x00000097,0x00000070,0x00000072,0x00000071,0x00000067,0x00000066,0x00000069,0x0000006a,0x0000006b,0x0000006d,0x0000006f,0x00000074,0x00000075,0x00000076};
     417                                static const int loop[20]={1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1};
     418                                for (int a=0;a<20;a++)
     419                                {
     420       
     421                                        if(soundID==tracks[a])
     422                                        {       
     423                                                playCDTrack(a+1,loop[a],0,0);
     424                                                stopCDTimer();
     425                                                foundatrack=true;
     426                                                _currentCDSound=soundID;
     427                                        }
     428                                }
     429                        }
     430
    413431                        // Works around the fact that in some places in MonkeyEGA/VGA,
    414432                        // the music is never explicitly stopped.
    415433                        // Rather it seems that starting a new music is supposed to
     
    419437                                        _vm->_imuse->stopAllSounds();
    420438                        }
    421439                }
     440                else if(_vm->_game.platform == Common::kPlatformPC && _vm->_game.version == 0x03 && _vm->_game.id == GID_LOOM)
     441                {
     442                        int loop=1;
     443                        if(soundID-32==11||soundID-32==31) loop=-1;
     444                        if(soundID<133)
     445                        {
     446                                playCDTrack(soundID-32,loop,0,0);
     447                                stopCDTimer();
     448                                foundatrack=true;
     449                                _currentCDSound=soundID;
     450                        }
     451                }
    422452
    423453                if (_vm->_musicEngine) {
     454                        if(foundatrack) soundID+=99999;
    424455                        _vm->_musicEngine->startSound(soundID);
     456
    425457                }
    426458
    427459                if (_vm->_townsPlayer)
  • engines/touche/resource.cpp

     
    3232#include "sound/decoders/vorbis.h"
    3333#include "sound/decoders/raw.h"
    3434#include "sound/audiostream.h"
     35#include "sound/audiocd.h"
    3536
    3637#include "touche/midi.h"
    3738#include "touche/touche.h"
     
    600601}
    601602
    602603void ToucheEngine::res_loadMusic(int num) {
     604        //dont loop 17,19,20,24
     605        int loops=-1;
     606        if(num==17 || num==19 || num==20 || num == 24) loops=1;
     607        AudioCD.stop();
     608        AudioCD.play(num,loops,0,0);
     609        if(AudioCD.isPlaying()) return;
     610
    603611        debugC(9, kDebugResource, "ToucheEngine::res_loadMusic() num=%d", num);
    604612        uint32 size;
    605613        const uint32 offs = res_getDataOffset(kResourceTypeMusic, num, &size);
  • sound/midiparser.cpp

     
    4848_abort_parse(0) {
    4949        memset(_active_notes, 0, sizeof(_active_notes));
    5050        _next_event.start = NULL;
     51_dontplayme=false;
    5152        _next_event.delta = 0;
    5253        _next_event.event = 0;
    5354        _next_event.length = 0;
     
    161162void MidiParser::onTimer() {
    162163        uint32 end_time;
    163164        uint32 event_time;
    164 
    165165        if (!_position._play_pos || !_driver)
    166166                return;
    167167
     
    228228                        }
    229229                        _driver->metaEvent(info.ext.type, info.ext.data, (uint16)info.length);
    230230                } else {
    231                         if (info.command() == 0x8) {
     231                        if (info.command() == 0x8 ) {
    232232                                activeNote(info.channel(), info.basic.param1, false);
    233233                        } else if (info.command() == 0x9) {
    234234                                if (info.length > 0)
    235235                                        hangingNote(info.channel(), info.basic.param1, info.length * _psec_per_tick - (end_time - event_time));
    236236                                else
    237237                                        activeNote(info.channel(), info.basic.param1, true);
     238                        }                       
     239                        if(!_dontplayme)
     240                        {
     241                                sendToDriver(info.event, info.basic.param1, info.basic.param2);
    238242                        }
    239                         sendToDriver(info.event, info.basic.param1, info.basic.param2);
    240243                }
    241244
    242245
     
    250253                _position._play_time = end_time;
    251254                _position._play_tick = (_position._play_time - _position._last_event_time) / _psec_per_tick + _position._last_event_tick;
    252255        }
     256
    253257}
    254258
    255259void MidiParser::allNotesOff() {
  • sound/midiparser.h

     
    363363                 */
    364364                mpCenterPitchWheelOnUnload = 4
    365365        };
     366        bool _dontplayme;
    366367
    367368public:
    368369        typedef void (*XMidiCallbackProc)(byte eventData, void *refCon);
  • sound/mixer.h

     
    6868
    6969                kMusicSoundType = 1,
    7070                kSFXSoundType = 2,
    71                 kSpeechSoundType = 3
     71                kSpeechSoundType = 3,
    7272        };
    7373
    7474        enum {