diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/fs/wii/wii-fs.cpp scummvm_modTest/backends/fs/wii/wii-fs.cpp --- scummvm-master/backends/fs/wii/wii-fs.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/fs/wii/wii-fs.cpp 2019-04-29 15:27:43.965946000 +0200 @@ -152,45 +152,45 @@ bool WiiFilesystemNode::getChildren(Abst if (_path.empty()) return getDevopChildren(list, mode, hidden); - DIR* dp = opendir (_path.c_str()); - DIR* tmpdir; + DIR* dirp = opendir(_path.c_str()); + struct dirent *dp = NULL; - if (dp == NULL) + if (dirp == NULL) return false; - struct dirent *pent; - - while ((pent = readdir(dp)) != NULL) { - if (strcmp(pent->d_name, ".") == 0 || strcmp(pent->d_name, "..") == 0) + // loop over dir entries using readdir + while ((dp = readdir(dirp)) != NULL) { + // Skip 'invisible' files if necessary + if (dp->d_name[0] == '.' && !hidden) continue; - - Common::String newPath(_path); - if (newPath.lastChar() != '/') - newPath += '/'; - newPath += pent->d_name; - - bool isDir = false; - tmpdir = opendir(newPath.c_str()); - if(tmpdir) - { - isDir = true; - closedir(tmpdir); - } - - if ((mode == Common::FSNode::kListFilesOnly && isDir) || - (mode == Common::FSNode::kListDirectoriesOnly && !isDir)) + + // Skip '.' and '..' to avoid cycles + if ((dp->d_name[0] == '.' && dp->d_name[1] == 0) || (dp->d_name[0] == '.' && dp->d_name[1] == '.')) continue; - struct stat st; - st.st_mode = 0; - st.st_mode |= ( isDir ? S_IFDIR : 0 ); - st.st_mode |= S_IRUSR; - st.st_mode |= S_IWUSR; + WiiFilesystemNode entry(*this); + entry._displayName = dp->d_name; + if (_path.lastChar() != '/') + entry._path += '/'; + entry._path += entry._displayName; + + // Force validity for now... + entry._exists = 1; + + // Check if it's a directory + if(dp->d_type == DT_REG) + entry._isDirectory =false; + else if(dp->d_type == DT_DIR) + entry._isDirectory =true; + + // Honor the chosen mode + if ((mode == Common::FSNode::kListFilesOnly && entry._isDirectory) || + (mode == Common::FSNode::kListDirectoriesOnly && !entry._isDirectory)) + continue; - list.push_back(new WiiFilesystemNode(newPath, &st)); + list.push_back(new WiiFilesystemNode(entry)); } - - closedir(dp); + closedir(dirp); return true; } diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/main.cpp scummvm_modTest/backends/platform/wii/main.cpp --- scummvm-master/backends/platform/wii/main.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/main.cpp 2019-05-07 17:53:28.392210132 +0200 @@ -166,6 +166,9 @@ void wii_memstats(void) { int main(int argc, char *argv[]) { s32 res; + if(IOS_GetVersion() != 58) + IOS_ReloadIOS(58); + #if defined(USE_WII_DI) && !defined(GAMECUBE) DI_Init(); #endif @@ -179,6 +182,9 @@ int main(int argc, char *argv[]) { gfx_init(); gfx_con_init(NULL); + // Delay for usb hdd + sleep(1); + #ifdef DEBUG_WII_GDB DEBUG_Init(GDBSTUB_DEVICE_USB, 1); #endif @@ -213,6 +219,21 @@ int main(int argc, char *argv[]) { } } + // Loader's arguments, WiiFlow etc. + if ((argc > 1) && (argv[1] != NULL)) + { + // Force lower case for the target name because WiiFlow sends this argument as upper case. + // It fixes savegames not found in Mohawk engine when runModalWithCurrentTarget is called. + // Skip if it's a command line option or a path. + if(argv[1][0] != '-' && strchr(argv[1], '/') == NULL) + { + int len = strlen(argv[1]); + + for (int i = 0; i < len; ++i) + argv[1][i] = tolower(argv[1][i]); + } + } + g_system = new OSystem_Wii(); assert(g_system); diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/options.cpp scummvm_modTest/backends/platform/wii/options.cpp --- scummvm-master/backends/platform/wii/options.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/options.cpp 2019-05-07 19:11:32.257439513 +0200 @@ -32,6 +32,13 @@ #include "options.h" +static bool confGetBool(Common::String key, bool defaultVal) { + if (ConfMan.hasKey(key, Common::ConfigManager::kApplicationDomain)) + return ConfMan.getBool(key, Common::ConfigManager::kApplicationDomain); + return defaultVal; +} + + WiiOptionsDialog::WiiOptionsDialog(bool doubleStrike) : Dialog((640 - 400) / 2, (480 - 340) / 2, 400, 340), _doubleStrike(doubleStrike) { @@ -82,6 +89,9 @@ WiiOptionsDialog::WiiOptionsDialog(bool _sliderPadAcceleration->setMinValue(0); _sliderPadAcceleration->setMaxValue(8); + _MenuButtonToggle = new GUI::CheckboxWidget(_tab, 16, 72, 328, 20, "Y or + button for In-game menu(F5 key)", "When enabled it acts as F5 key. It's used for save/load menu or specific game's options. When disabled it's used as 'period' to skip dialogues.", 0, 'T'); + + _IndyFightToggle = new GUI::CheckboxWidget(_tab, 16, 100, 328, 20, "Indiana Jones Fight mode.", "When enabled, Classic controller and GC pad are used in fighting sequence. Hold L/R: Indy facing left/right mode.", 0, 'F'); #ifdef USE_WII_DI _tabDVD = _tab->addTab(_("DVD")); @@ -199,6 +209,10 @@ void WiiOptionsDialog::handleCommand(Com WiiFilesystemFactory &fsf = WiiFilesystemFactory::instance(); switch (cmd) { + case 'F': + case 'T': + break; + case 'x': case 'y': gfx_set_underscan(_sliderUnderscanX->getValue(), @@ -275,6 +289,9 @@ void WiiOptionsDialog::load() { Common::ConfigManager::kApplicationDomain); _sliderPadAcceleration->setValue(i); + _MenuButtonToggle->setState(confGetBool("wii_menu_button", true)); + + _IndyFightToggle->setState(confGetBool("wii_fight_mode", false)); #ifdef USE_WII_SMB _editSMBServer->setEditString(ConfMan.get("wii_smb_server", Common::ConfigManager::kApplicationDomain)); @@ -302,6 +319,13 @@ void WiiOptionsDialog::save() { _sliderPadAcceleration->getValue(), Common::ConfigManager::kApplicationDomain); + ConfMan.setBool("wii_menu_button", + _MenuButtonToggle->getState(), + Common::ConfigManager::kApplicationDomain); + + ConfMan.setBool("wii_fight_mode", + _IndyFightToggle->getState(), + Common::ConfigManager::kApplicationDomain); #ifdef USE_WII_SMB ConfMan.set("wii_smb_server", _editSMBServer->getEditString(), Common::ConfigManager::kApplicationDomain); diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/options.h scummvm_modTest/backends/platform/wii/options.h --- scummvm-master/backends/platform/wii/options.h 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/options.h 2019-05-02 17:18:37.624475276 +0200 @@ -56,6 +56,11 @@ private: SliderWidget *_sliderPadSensitivity; SliderWidget *_sliderPadAcceleration; + SliderWidget *_sliderMouseSensitivity; + SliderWidget *_sliderMouseAcceleration; + CheckboxWidget *_MenuButtonToggle; + CheckboxWidget *_IndyFightToggle; + #ifdef USE_WII_DI int _tabDVD; StaticTextWidget *_textDVDStatus; diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/osystem_events.cpp scummvm_modTest/backends/platform/wii/osystem_events.cpp --- scummvm-master/backends/platform/wii/osystem_events.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/osystem_events.cpp 2019-05-09 16:40:38.610625548 +0200 @@ -33,6 +33,7 @@ #endif #ifdef USE_WII_KBD #include +#include #endif #include "common/config-manager.h" @@ -43,11 +44,16 @@ #define PAD_CHECK_TIME 40 +#define USB_LEFTBUTTON 0x01 +#define USB_RIGHTBUTTON 0x02 +#define USB_MIDDLEBUTTON 0x04 + #ifndef GAMECUBE #define PADS_A (PAD_BUTTON_A | (WPAD_BUTTON_A << 16)) #define PADS_B (PAD_BUTTON_B | (WPAD_BUTTON_B << 16)) #define PADS_X (PAD_BUTTON_X | (WPAD_BUTTON_MINUS << 16)) #define PADS_Y (PAD_BUTTON_Y | (WPAD_BUTTON_PLUS << 16)) +#define PADS_L (PAD_TRIGGER_L) #define PADS_R (PAD_TRIGGER_R | (WPAD_BUTTON_1 << 16)) #define PADS_Z (PAD_TRIGGER_Z | (WPAD_BUTTON_2 << 16)) #define PADS_START (PAD_BUTTON_START | (WPAD_BUTTON_HOME << 16)) @@ -146,6 +152,39 @@ static u8 *timer_stack; static bool timer_thread_running = false; static bool timer_thread_quit = false; +static bool _menuButton; +static bool _fightMode; +static bool checkUsbMouse = false; + +bool getMenuButtonState() { + if (!ConfMan.hasKey("wii_menu_button", Common::ConfigManager::kApplicationDomain)) { + ConfMan.setBool("wii_menu_button", + true, + Common::ConfigManager::kApplicationDomain); + _menuButton = true; + } else { + _menuButton = ConfMan.getBool("wii_menu_button"); + + } + + return _menuButton; +} + +bool getFightModeState() { + if (!ConfMan.hasKey("wii_fight_mode", Common::ConfigManager::kApplicationDomain)) { + ConfMan.setBool("wii_fight_mode", + false, + Common::ConfigManager::kApplicationDomain); + _fightMode = false; + } else { + _fightMode = ConfMan.getBool("wii_fight_mode"); + + } + + return _fightMode; +} + + static void * timer_thread_func(void *arg) { while (!timer_thread_quit) { DefaultTimerManager *tm = @@ -188,8 +227,33 @@ void OSystem_Wii::initEvents() { _padSensitivity = 64 - ConfMan.getInt("wii_pad_sensitivity"); _padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration"); + if (!ConfMan.hasKey("wii_menu_button", Common::ConfigManager::kApplicationDomain)) + { + ConfMan.setBool("wii_menu_button", + true, + Common::ConfigManager::kApplicationDomain); + _menuButton = true; + } + else + { + _menuButton = ConfMan.getBool("wii_menu_button"); + + } + + if (!ConfMan.hasKey("wii_fight_mode", Common::ConfigManager::kApplicationDomain)) + { + ConfMan.setBool("wii_fight_mode", + false, + Common::ConfigManager::kApplicationDomain); + _fightMode = false; + } + else + { + _fightMode = ConfMan.getBool("wii_fight_mode"); + } #ifdef USE_WII_KBD _kbd_active = KEYBOARD_Init(NULL) >= 0; + MOUSE_Init(); #endif } @@ -280,8 +344,107 @@ bool OSystem_Wii::pollKeyboard(Common::E return true; } + +static int wpad_StickX(WPADData *data, u8 right) +{ + struct joystick_t* js = NULL; + + switch (data->exp.type) + { + case WPAD_EXP_NUNCHUK: + js = right ? NULL : &data->exp.nunchuk.js; + break; + + case WPAD_EXP_CLASSIC: + js = right ? &data->exp.classic.rjs : &data->exp.classic.ljs; + break; + + default: + break; + } + + if (js) + { + /* raw X position */ + int pos = js->pos.x; + + /* X range calibration */ + int min = js->min.x; + int max = js->max.x; + int center = js->center.x; + + /* value returned could be above calibration limits */ + if (pos > max) return 127; + if (pos < min) return -128; + + /* adjust against center position */ + pos -= center; + + /* return interpolated range [-128;127] */ + if (pos > 0) + { + return (int)(127.0 * ((float)pos / (float)(max - center))); + } + else + { + return (int)(128.0 * ((float)pos / (float)(center - min))); + } + } + + return 0; +} + +static int wpad_StickY(WPADData *data, u8 right) +{ + struct joystick_t* js = NULL; + + switch (data->exp.type) + { + case WPAD_EXP_NUNCHUK: + js = right ? NULL : &data->exp.nunchuk.js; + break; + + case WPAD_EXP_CLASSIC: + js = right ? &data->exp.classic.rjs : &data->exp.classic.ljs; + break; + + default: + break; + } + + if (js) + { + /* raw Y position */ + int pos = js->pos.y; + + /* Y range calibration */ + int min = js->min.y; + int max = js->max.y; + int center = js->center.y; + + /* value returned could be above calibration limits */ + if (pos > max) return 127; + if (pos < min) return -128; + + /* adjust against center position */ + pos -= center; + + /* return interpolated range [-128;127] */ + if (pos > 0) + { + return (int)(127.0 * ((float)pos / (float)(max - center))); + } + else + { + return (int)(128.0 * ((float)pos / (float)(center - min))); + } + } + + return 0; +} #endif + #define PAD_EVENT(pad_button, kbd_keycode, kbd_ascii, modifier) \ do { \ if ((bd | bu) & pad_button) { \ @@ -295,8 +458,169 @@ bool OSystem_Wii::pollKeyboard(Common::E return true; \ } \ } while (0) +bool OSystem_Wii::addIndyFightingKeys(Common::Event &event, u32 bd, u32 bh, u32 bu, u32 wpad) { + bool indyFightRight = false; + bool indyFightLeft = false; + bool emulate_mouse = true; + + if (wpad == WPAD_EXP_CLASSIC) { + + if (bh & WPAD_CLASSIC_BUTTON_FULL_L) + { + indyFightRight = true; + indyFightLeft = false; + emulate_mouse = false; + } + + + if (bh & WPAD_CLASSIC_BUTTON_FULL_R) + { + indyFightLeft = true; + indyFightRight = false; + emulate_mouse = false; + } + + PAD_EVENT(WPAD_CLASSIC_BUTTON_UP, Common::KEYCODE_8, '8', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_LEFT, Common::KEYCODE_4, '4', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_RIGHT, Common::KEYCODE_6, '6', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_DOWN, Common::KEYCODE_2, '2', 0); + + if (indyFightRight) { + PAD_EVENT(WPAD_CLASSIC_BUTTON_X, Common::KEYCODE_9, '9', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_A, Common::KEYCODE_6, '6', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_B, Common::KEYCODE_3, '3', 0); + } + else if (indyFightLeft) + { + PAD_EVENT(WPAD_CLASSIC_BUTTON_X, Common::KEYCODE_7, '7', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_A, Common::KEYCODE_4, '4', 0); + PAD_EVENT(WPAD_CLASSIC_BUTTON_B, Common::KEYCODE_1, '1', 0); + } + else + { + emulate_mouse = true; + } + + PAD_EVENT(WPAD_CLASSIC_BUTTON_Y, Common::KEYCODE_5, '5', 0); + /*else + { + PAD_EVENT(WPAD_CLASSIC_BUTTON_DOWN, Common::KEYCODE_F7, Common::ASCII_F7, Common::KBD_CTRL); + }*/ + + + if (emulate_mouse) + { + + if (!checkUsbMouse) { + if ((bd | bu) & (WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B)) { + if (bd & WPAD_CLASSIC_BUTTON_A) + event.type = Common::EVENT_LBUTTONDOWN; + else if (bu & WPAD_CLASSIC_BUTTON_A) + event.type = Common::EVENT_LBUTTONUP; + else if (bd & WPAD_CLASSIC_BUTTON_B) + event.type = Common::EVENT_RBUTTONDOWN; + else if (bu & WPAD_CLASSIC_BUTTON_B) + event.type = Common::EVENT_RBUTTONUP; + + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + return true; + } + } + + } + + if (bd & WPAD_CLASSIC_BUTTON_PLUS) { + showOptionsDialog(); + return false; + } + + PAD_EVENT(WPAD_CLASSIC_BUTTON_HOME, Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL); + } + else + { + if (bh & PADS_L) + { + indyFightRight = true; + indyFightLeft = false; + emulate_mouse = false; + } + + + if (bh & PADS_R) + { + indyFightLeft = true; + indyFightRight = false; + emulate_mouse = false; + + } + + PAD_EVENT(PADS_UP, Common::KEYCODE_8, '8', 0); + PAD_EVENT(PADS_LEFT, Common::KEYCODE_4, '4', 0); + PAD_EVENT(PADS_RIGHT, Common::KEYCODE_6, '6', 0); + PAD_EVENT(PADS_DOWN, Common::KEYCODE_2, '2', 0); + + if (indyFightRight) { + PAD_EVENT(PADS_X, Common::KEYCODE_9, '9', 0); + PAD_EVENT(PADS_A, Common::KEYCODE_6, '6', 0); + PAD_EVENT(PADS_B, Common::KEYCODE_3, '3', 0); + } + else if (indyFightLeft) + { + PAD_EVENT(PADS_X, Common::KEYCODE_7, '7', 0); + PAD_EVENT(PADS_A, Common::KEYCODE_4, '4', 0); + PAD_EVENT(PADS_B, Common::KEYCODE_1, '1', 0); + } + else + { + emulate_mouse = true; + } + + PAD_EVENT(PADS_Y, Common::KEYCODE_5, '5', 0); + + if (emulate_mouse) + { + + if (!checkUsbMouse) { + if ((bd | bu) & (PADS_A | PADS_B)) { + if (bd & PADS_A) + event.type = Common::EVENT_LBUTTONDOWN; + else if (bu & PADS_A) + event.type = Common::EVENT_LBUTTONUP; + else if (bd & PADS_B) + event.type = Common::EVENT_RBUTTONDOWN; + else if (bu & PADS_B) + event.type = Common::EVENT_RBUTTONUP; + + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + + return true; + } + } + + } + + + if (bd & PADS_Z) { + showOptionsDialog(); + return false; + } + + PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL); + } + + return false; +} bool OSystem_Wii::pollEvent(Common::Event &event) { + static int _mButtons = 0; + bool gcpad = false; + bool indyFight = false; + + indyFight = getFightModeState(); + _menuButton = getMenuButtonState(); + if ((reset_btn_pressed || power_btn_pressed) && !_event_quit) { _event_quit = true; event.type = Common::EVENT_QUIT; @@ -309,148 +633,387 @@ bool OSystem_Wii::pollEvent(Common::Even if (needsScreenUpdate()) updateScreen(); + u32 bd = 0, bh = 0, bu = 0; if (PAD_ScanPads() & 1) { + gcpad = true; bd = PAD_ButtonsDown(0); bh = PAD_ButtonsHeld(0); bu = PAD_ButtonsUp(0); } + #ifndef GAMECUBE WPAD_ScanPads(); + u32 wpad = 255; + s32 res = WPAD_Probe(0, &wpad); - s32 res = WPAD_Probe(0, NULL); + if (res == WPAD_ERR_NONE) { + switch (wpad) { + case WPAD_EXP_NONE: + bd |= WPAD_ButtonsDown(0) << 16; + bh |= WPAD_ButtonsHeld(0) << 16; + bu |= WPAD_ButtonsUp(0) << 16; + break; + case WPAD_EXP_NUNCHUK: + bd |= WPAD_ButtonsDown(0) << 16; + bh |= WPAD_ButtonsHeld(0) << 16; + bu |= WPAD_ButtonsUp(0) << 16; + break; + case WPAD_EXP_CLASSIC: + bd |= WPAD_ButtonsDown(0); + bh |= WPAD_ButtonsHeld(0); + bu |= WPAD_ButtonsUp(0); + break; + default: + break; + } + } - if (res == WPAD_ERR_NONE) { - bd |= WPAD_ButtonsDown(0) << 16; - bh |= WPAD_ButtonsHeld(0) << 16; - bu |= WPAD_ButtonsUp(0) << 16; - } -#endif - if (bd || bu) { - byte flags = 0; + if (checkUsbMouse) { + if (PAD_ButtonsDown(0) & PAD_BUTTON_START) { + event.type = Common::EVENT_MAINMENU; + return true; + } - if (bh & PADS_UP) { - PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, - Common::KBD_CTRL); - - if (bd & PADS_R) { - _consoleVisible = !_consoleVisible; - return false; - } + if (PAD_ButtonsDown(0) & PAD_TRIGGER_R) { + showOptionsDialog(); + return false; + } - flags = Common::KBD_SHIFT; - } + if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) { + event.type = Common::EVENT_MAINMENU; + return true; + } - if (bd & PADS_R) { - showOptionsDialog(); - return false; - } + if (WPAD_ButtonsDown(0) & WPAD_BUTTON_1) { + showOptionsDialog(); + return false; + } + } +#endif - if (bd & PADS_RIGHT) { - event.type = Common::EVENT_PREDICTIVE_DIALOG; - return true; - } - PAD_EVENT(PADS_Z, Common::KEYCODE_RETURN, Common::ASCII_RETURN, flags); - PAD_EVENT(PADS_X, Common::KEYCODE_ESCAPE, Common::ASCII_ESCAPE, flags); - PAD_EVENT(PADS_Y, Common::KEYCODE_PERIOD, '.', flags); - PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, flags); - PAD_EVENT(PADS_UP, Common::KEYCODE_LSHIFT, 0, flags); - PAD_EVENT(PADS_DOWN, Common::KEYCODE_F7, Common::ASCII_F7, Common::KBD_CTRL); - //PAD_EVENT(PADS_LEFT, Common::KEYCODE_F8, Common::ASCII_F8, Common::KBD_CTRL); - - if ((bd | bu) & (PADS_A | PADS_B)) { - if (bd & PADS_A) - event.type = Common::EVENT_LBUTTONDOWN; - else if (bu & PADS_A) - event.type = Common::EVENT_LBUTTONUP; - else if (bd & PADS_B) - event.type = Common::EVENT_RBUTTONDOWN; - else if (bu & PADS_B) - event.type = Common::EVENT_RBUTTONUP; + if ((bd || bu) && !checkUsbMouse) { + byte flags = 0; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; - return true; - } + /*if (checkUsbMouse) { + if(bd || bh) + MOUSE_FlushEvents(); + }*/ + + if(wpad == WPAD_EXP_CLASSIC) + { + if(indyFight) + { + if (addIndyFightingKeys(event, bd, bh, bu, wpad)) + return true; + } + else + { + if (bd & WPAD_CLASSIC_BUTTON_Y) { + showOptionsDialog(); + return false; + } + + if (_menuButton) + { + PAD_EVENT(WPAD_CLASSIC_BUTTON_PLUS, Common::KEYCODE_F5, Common::ASCII_F5, 0); + + } + else + { + PAD_EVENT(WPAD_CLASSIC_BUTTON_PLUS, Common::KEYCODE_PERIOD, '.', flags); + } + + + PAD_EVENT(WPAD_CLASSIC_BUTTON_HOME, Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL); + PAD_EVENT(WPAD_CLASSIC_BUTTON_UP, Common::KEYCODE_LSHIFT, 0, flags); + PAD_EVENT(WPAD_CLASSIC_BUTTON_DOWN, Common::KEYCODE_F7, Common::ASCII_F7, Common::KBD_CTRL); + + + if (!checkUsbMouse) { + if ((bd | bu) & (WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B)) { + if (bd & WPAD_CLASSIC_BUTTON_A) + event.type = Common::EVENT_LBUTTONDOWN; + else if (bu & WPAD_CLASSIC_BUTTON_A) + event.type = Common::EVENT_LBUTTONUP; + else if (bd & WPAD_CLASSIC_BUTTON_B) + event.type = Common::EVENT_RBUTTONDOWN; + else if (bu & WPAD_CLASSIC_BUTTON_B) + event.type = Common::EVENT_RBUTTONUP; + + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + return true; + } + } + } + } else { + if((gcpad || wpad == WPAD_EXP_NUNCHUK) && indyFight) + { + if (addIndyFightingKeys(event, bd, bh, bu, wpad)) + return true; + } + else + { + + if (bh & PADS_UP) { + //PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, + // Common::KBD_CTRL); + + if (bd & PADS_R) { + _consoleVisible = !_consoleVisible; + return false; + } + + flags = Common::KBD_SHIFT; + } + + + if (bd & PADS_R) { + showOptionsDialog(); + return false; + } + + if (bd & PADS_RIGHT) { + event.type = Common::EVENT_PREDICTIVE_DIALOG; + return true; + } + + PAD_EVENT(PADS_Z, Common::KEYCODE_RETURN, Common::ASCII_RETURN, flags); + PAD_EVENT(PADS_X, Common::KEYCODE_ESCAPE, Common::ASCII_ESCAPE, flags); + + if(_menuButton) + { + PAD_EVENT(PADS_Y, Common::KEYCODE_F5, Common::ASCII_F5, 0); + } + else + { + PAD_EVENT(PADS_Y, Common::KEYCODE_PERIOD, '.', flags); + } + + + PAD_EVENT(PADS_START, Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL); + PAD_EVENT(PADS_UP, Common::KEYCODE_LSHIFT, 0, flags); + PAD_EVENT(PADS_DOWN, Common::KEYCODE_F7, Common::ASCII_F7, Common::KBD_CTRL); + } + } + + if (!checkUsbMouse) { + if ((bd | bu) & (PADS_A | PADS_B)) { + if (bd & PADS_A) + event.type = Common::EVENT_LBUTTONDOWN; + else if (bu & PADS_A) + event.type = Common::EVENT_LBUTTONUP; + else if (bd & PADS_B) + event.type = Common::EVENT_RBUTTONDOWN; + else if (bu & PADS_B) + event.type = Common::EVENT_RBUTTONUP; + + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + + return true; + } + } } s32 mx = _mouseX; s32 my = _mouseY; + if (!checkUsbMouse) { #ifndef GAMECUBE - if (res == WPAD_ERR_NONE) { - struct ir_t ir; - - WPAD_IR(0, &ir); - - if (ir.valid) { - mx = s32(ir.x) - _currentWidth / 10; - my = s32(ir.y) - _currentHeight / 10; - - if (mx < 0) - mx = 0; - - if (mx >= _currentWidth) - mx = _currentWidth - 1; - - if (my < 0) - my = 0; + if (res == WPAD_ERR_NONE) { + struct ir_t ir; - if (my >= _currentHeight) - my = _currentHeight - 1; - - if ((mx != _mouseX) || (my != _mouseY)) { - event.type = Common::EVENT_MOUSEMOVE; - event.mouse.x = _mouseX = mx; - event.mouse.y = _mouseY = my; - - return true; - } - } - } -#endif - - uint32 time = getMillis(); - if (time - _lastPadCheck > PAD_CHECK_TIME) { - _lastPadCheck = time; - - if (abs (PAD_StickX(0)) > _padSensitivity) - mx += PAD_StickX(0) / - (_padAcceleration * _overlayWidth / _currentWidth); - if (abs (PAD_StickY(0)) > _padSensitivity) - my -= PAD_StickY(0) / - (_padAcceleration * _overlayHeight / _currentHeight); - - if (mx < 0) - mx = 0; - - if (mx >= _currentWidth) - mx = _currentWidth - 1; - - if (my < 0) - my = 0; - - if (my >= _currentHeight) - my = _currentHeight - 1; - - if ((mx != _mouseX) || (my != _mouseY)) { - event.type = Common::EVENT_MOUSEMOVE; - event.mouse.x = _mouseX = mx; - event.mouse.y = _mouseY = my; - - return true; - } - } + WPAD_IR(0, &ir); + if (ir.valid) { + mx = s32(ir.x) - _currentWidth / 10; + my = s32(ir.y) - _currentHeight / 10; + + if (mx < 0) + mx = 0; + + if (mx >= _currentWidth) + mx = _currentWidth - 1; + + if (my < 0) + my = 0; + + if (my >= _currentHeight) + my = _currentHeight - 1; + + if ((mx != _mouseX) || (my != _mouseY)) { + event.type = Common::EVENT_MOUSEMOVE; + event.mouse.x = _mouseX = mx; + event.mouse.y = _mouseY = my; + + return true; + } + } + } +#endif + + uint32 time = getMillis(); + if (time - _lastPadCheck > PAD_CHECK_TIME) { + _lastPadCheck = time; + + if (abs (PAD_StickX(0)) > _padSensitivity) + mx += PAD_StickX(0) / + (_padAcceleration * _overlayWidth / _currentWidth); + if (abs (PAD_StickY(0)) > _padSensitivity) + my -= PAD_StickY(0) / + (_padAcceleration * _overlayHeight / _currentHeight); + + + WPADData *data = WPAD_Data(0); + + // Only use stick when a known Wiimote expansion is detected + if(wpad > WPAD_EXP_NONE && wpad != 255) + { + if(wpad == WPAD_EXP_NUNCHUK && indyFight) + { + s8 x; + s8 y; + x = wpad_StickX(data, 0); + y = wpad_StickY(data, 0); + int key = 0; + int ascii = 0; + + if (x > (30)) { + bd |= PAD_BUTTON_RIGHT; + key = Common::KEYCODE_8; + ascii = '8'; + } else if (x < -(30)) { + bd |= PAD_BUTTON_LEFT; + key = Common::KEYCODE_4; + ascii = '4'; + } else if (y > (30)) { + bd |= PAD_BUTTON_UP; + key = Common::KEYCODE_6; + ascii = '6'; + } else if (y < -(30)) { + bd |= PAD_BUTTON_DOWN; + key = Common::KEYCODE_2; + ascii = '2'; + } + + event.type = Common::EVENT_KEYDOWN; + event.kbd.keycode = (Common::KeyCode)key; + event.kbd.ascii = ascii; + event.kbd.flags = 0; + return true; + } + else + { + if (abs (wpad_StickX(data,0)) > _padSensitivity) + mx += wpad_StickX(data,0) / + (_padAcceleration * _overlayWidth / _currentWidth); + if (abs (wpad_StickY(data,0)) > _padSensitivity) + my -= wpad_StickY(data,0) / + (_padAcceleration * _overlayHeight / _currentHeight); + + } + } + + if (mx < 0) + mx = 0; + + if (mx >= _currentWidth) + mx = _currentWidth - 1; + + if (my < 0) + my = 0; + + if (my >= _currentHeight) + my = _currentHeight - 1; + + if ((mx != _mouseX) || (my != _mouseY)) { + event.type = Common::EVENT_MOUSEMOVE; + event.mouse.x = _mouseX = mx; + event.mouse.y = _mouseY = my; + + return true; + } + } + } #ifdef USE_WII_KBD if (_kbd_active && pollKeyboard(event)) return true; #endif + // USB mouse + s32 mouse_active = false; + + if(MOUSE_IsConnected()) + { + checkUsbMouse = true; + mouse_event usbmouse; + mouse_active = MOUSE_GetEvent(&usbmouse); + + if(mouse_active) + { + //checkUsbMouse = true; + + if (usbmouse.button != _mButtons) { + uint16 change = _mButtons ^ usbmouse.button; + _mButtons = usbmouse.button; + if (change & (USB_LEFTBUTTON | USB_RIGHTBUTTON)) { + _mouseX += usbmouse.rx / (_overlayWidth / _currentWidth); + _mouseY += usbmouse.ry / (_overlayHeight / _currentHeight); + + if (change & USB_LEFTBUTTON) + event.type = (_mButtons & USB_LEFTBUTTON) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; + else + event.type = (_mButtons & USB_RIGHTBUTTON) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; + + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + return true; + } + } + // TODO : Middle click & Wheel scroll. + // Improve and add checks to avoid possible freeze. + + if (_mouseX < 0) + _mouseX = 0; + + if (_mouseX >= _currentWidth) + _mouseX = _currentWidth - 1; + + if (_mouseY < 0) + _mouseY = 0; + + if (_mouseY >= _currentHeight) + _mouseY = _currentHeight - 1; + + if ((_mouseX != usbmouse.rx) || (_mouseY != usbmouse.ry)) + { + _mouseX += usbmouse.rx / (_overlayWidth / _currentWidth); + _mouseY += usbmouse.ry / ( _overlayHeight / _currentHeight); + + event.type = Common::EVENT_MOUSEMOVE; + event.mouse.x = _mouseX; + event.mouse.y = _mouseY; + return true; + } + + } + /*else + { + checkUsbMouse = false; + }*/ + } + else + { + checkUsbMouse = false; + } + return false; } + diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/osystem_gfx.cpp scummvm_modTest/backends/platform/wii/osystem_gfx.cpp --- scummvm-master/backends/platform/wii/osystem_gfx.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/osystem_gfx.cpp 2019-05-09 11:34:02.552338174 +0200 @@ -69,6 +69,10 @@ void OSystem_Wii::initGfx() { _overlayWidth = gfx_video_get_width(); _overlayHeight = gfx_video_get_height(); + // FIXME : quick hack to setup the display/cursor when launched from WiiFlow. + showOverlay(); + hideOverlay(); + #ifndef GAMECUBE if (CONF_GetAspectRatio() && _fullscreen) _overlayHeight = 400; diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/backends/platform/wii/osystem.h scummvm_modTest/backends/platform/wii/osystem.h --- scummvm-master/backends/platform/wii/osystem.h 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/backends/platform/wii/osystem.h 2019-05-06 12:51:14.681824911 +0200 @@ -126,6 +126,8 @@ private: void updateEventScreenResolution(); bool pollKeyboard(Common::Event &event); + bool addIndyFightingKeys(Common::Event &event, u32 bd, u32 bh, u32 bu, u32 wpad); + void showOptionsDialog(); protected: Binary files scummvm-master/boot.dol and scummvm_modTest/boot.dol differ diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/config.h scummvm_modTest/config.h --- scummvm-master/config.h 1970-01-01 01:00:00.000000000 +0100 +++ scummvm_modTest/config.h 2019-05-07 19:06:57.322508959 +0200 @@ -0,0 +1,90 @@ +/* This file is automatically generated by configure */ +/* DO NOT EDIT MANUALLY */ + +#ifndef CONFIG_H +#define CONFIG_H + + +#undef SCUMM_LITTLE_ENDIAN +#define SCUMM_BIG_ENDIAN +#undef SCUMM_NEED_ALIGNMENT +#define AUDIO_REVERSE_STEREO +#define DEBUG_WII_USBGECKO +/* #define DEBUG_WII_MEMSTATS */ +/* #define DEBUG_WII_GDB */ +#define USE_WII_DI +#define USE_WII_SMB +#define USE_WII_KBD +#define USE_ELF_LOADER +#define DYNAMIC_MODULES +#define PLUGIN_PREFIX "" +#define PLUGIN_SUFFIX ".plg" +#define USE_MT32EMU +#undef DISABLE_NUKED_OPL +#define USE_RGB_COLOR +#define USE_HIGHRES +#define USE_SAVEGAME_TIMESTAMP +#undef USE_SCALERS +#undef USE_HQ_SCALERS +#undef USE_OGG +#undef USE_VORBIS +#define USE_TREMOR +#define USE_VORBIS +#undef ENABLE_OPL2LPT +#define USE_FLAC +#define USE_MAD +#undef USE_ALSA +#define USE_JPEG +#define USE_PNG +#undef USE_THEORADEC +#undef USE_FAAD +#undef USE_SEQ_MIDI +#undef USE_SNDIO +#undef USE_TIMIDITY +#define USE_ZLIB +#undef USE_MPEG2 +#undef USE_A52 +#undef USE_LIBCURL +#undef USE_CLOUD +#undef USE_FLUIDSYNTH +#undef USE_READLINE +#undef USE_TEXT_CONSOLE_FOR_DEBUGGER +#undef USE_UNITY +#define USE_FREETYPE2 +#undef USE_OPENGL +#undef USE_NASM +#undef USE_PANDOC +#define ENABLE_VKEYBD +#undef ENABLE_KEYMAPPER +#undef ENABLE_EVENTRECORDER +#define USE_TRANSLATION +#define USE_DETECTLANG +#undef USE_TASKBAR +#undef USE_SYSDIALOGS +#define USE_BINK +#undef USE_UPDATES +#define TAINTED_BUILD + +/* Data types */ +#ifndef SCUMMVM_DONT_DEFINE_TYPES +typedef unsigned char byte; +typedef unsigned int uint; +typedef unsigned char uint8; +typedef unsigned short uint16; +typedef unsigned int uint32; +typedef unsigned long long uint64; +typedef signed char int8; +typedef signed short int16; +typedef signed int int32; +typedef signed long long int64; +#endif + +typedef uint32 uintptr; + +#if defined(__APPLE__) && !defined(__ppc__) +#ifndef _UINT64 +#define _UINT64 +#endif +#endif + +#endif /* CONFIG_H */ diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/engine.cpp scummvm_modTest/engines/engine.cpp --- scummvm-master/engines/engine.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/engines/engine.cpp 2019-04-29 17:37:30.932605000 +0200 @@ -216,7 +216,7 @@ void initCommonGFX() { // Please leave the splash screen in working order for your releases, even if they're commercial. // This is a proper and good way to show your appreciation for our hard work over these years. -bool splash = false; +bool splash = true; #include "logo_data.h" diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/engines.mk scummvm_modTest/engines/engines.mk --- scummvm-master/engines/engines.mk 1970-01-01 01:00:00.000000000 +0100 +++ scummvm_modTest/engines/engines.mk 2019-05-07 19:06:57.962487848 +0200 @@ -0,0 +1,406 @@ +# This file is automatically generated by configure +# DO NOT EDIT MANUALLY +# This file is being included by "Makefile.common" + +ifdef ENABLE_SCUMM +DEFINES += -DENABLE_SCUMM=$(ENABLE_SCUMM) +MODULES += engines/scumm + +ifdef ENABLE_SCUMM_7_8 +DEFINES += -DENABLE_SCUMM_7_8 +endif + +ifdef ENABLE_HE +DEFINES += -DENABLE_HE +endif +endif + +ifdef ENABLE_ACCESS +DEFINES += -DENABLE_ACCESS=$(ENABLE_ACCESS) +MODULES += engines/access +endif + +ifdef ENABLE_ADL +DEFINES += -DENABLE_ADL=$(ENABLE_ADL) +MODULES += engines/adl +endif + +ifdef ENABLE_AGI +DEFINES += -DENABLE_AGI=$(ENABLE_AGI) +MODULES += engines/agi +endif + +ifdef ENABLE_AGOS +DEFINES += -DENABLE_AGOS=$(ENABLE_AGOS) +MODULES += engines/agos + +ifdef ENABLE_AGOS2 +DEFINES += -DENABLE_AGOS2 +endif +endif + +ifdef ENABLE_AVALANCHE +DEFINES += -DENABLE_AVALANCHE=$(ENABLE_AVALANCHE) +MODULES += engines/avalanche +endif + +ifdef ENABLE_BBVS +DEFINES += -DENABLE_BBVS=$(ENABLE_BBVS) +MODULES += engines/bbvs +endif + +ifdef ENABLE_BLADERUNNER +DEFINES += -DENABLE_BLADERUNNER=$(ENABLE_BLADERUNNER) +MODULES += engines/bladerunner +endif + +ifdef ENABLE_CGE +DEFINES += -DENABLE_CGE=$(ENABLE_CGE) +MODULES += engines/cge +endif + +ifdef ENABLE_CGE2 +DEFINES += -DENABLE_CGE2=$(ENABLE_CGE2) +MODULES += engines/cge2 +endif + +ifdef ENABLE_CHEWY +DEFINES += -DENABLE_CHEWY=$(ENABLE_CHEWY) +MODULES += engines/chewy +endif + +ifdef ENABLE_CINE +DEFINES += -DENABLE_CINE=$(ENABLE_CINE) +MODULES += engines/cine +endif + +ifdef ENABLE_COMPOSER +DEFINES += -DENABLE_COMPOSER=$(ENABLE_COMPOSER) +MODULES += engines/composer +endif + +ifdef ENABLE_CRUISE +DEFINES += -DENABLE_CRUISE=$(ENABLE_CRUISE) +MODULES += engines/cruise +endif + +ifdef ENABLE_CRYO +DEFINES += -DENABLE_CRYO=$(ENABLE_CRYO) +MODULES += engines/cryo +endif + +ifdef ENABLE_DIRECTOR +DEFINES += -DENABLE_DIRECTOR=$(ENABLE_DIRECTOR) +MODULES += engines/director +endif + +ifdef ENABLE_DM +DEFINES += -DENABLE_DM=$(ENABLE_DM) +MODULES += engines/dm +endif + +ifdef ENABLE_DRACI +DEFINES += -DENABLE_DRACI=$(ENABLE_DRACI) +MODULES += engines/draci +endif + +ifdef ENABLE_DRASCULA +DEFINES += -DENABLE_DRASCULA=$(ENABLE_DRASCULA) +MODULES += engines/drascula +endif + +ifdef ENABLE_DREAMWEB +DEFINES += -DENABLE_DREAMWEB=$(ENABLE_DREAMWEB) +MODULES += engines/dreamweb +endif + +ifdef ENABLE_FULLPIPE +DEFINES += -DENABLE_FULLPIPE=$(ENABLE_FULLPIPE) +MODULES += engines/fullpipe +endif + +ifdef ENABLE_GLK +DEFINES += -DENABLE_GLK=$(ENABLE_GLK) +MODULES += engines/glk +endif + +ifdef ENABLE_GNAP +DEFINES += -DENABLE_GNAP=$(ENABLE_GNAP) +MODULES += engines/gnap +endif + +ifdef ENABLE_GOB +DEFINES += -DENABLE_GOB=$(ENABLE_GOB) +MODULES += engines/gob +endif + +ifdef ENABLE_GROOVIE +DEFINES += -DENABLE_GROOVIE=$(ENABLE_GROOVIE) +MODULES += engines/groovie + +ifdef ENABLE_GROOVIE2 +DEFINES += -DENABLE_GROOVIE2 +endif +endif + +ifdef ENABLE_HOPKINS +DEFINES += -DENABLE_HOPKINS=$(ENABLE_HOPKINS) +MODULES += engines/hopkins +endif + +ifdef ENABLE_HUGO +DEFINES += -DENABLE_HUGO=$(ENABLE_HUGO) +MODULES += engines/hugo +endif + +ifdef ENABLE_ILLUSIONS +DEFINES += -DENABLE_ILLUSIONS=$(ENABLE_ILLUSIONS) +MODULES += engines/illusions +endif + +ifdef ENABLE_KYRA +DEFINES += -DENABLE_KYRA=$(ENABLE_KYRA) +MODULES += engines/kyra + +ifdef ENABLE_LOL +DEFINES += -DENABLE_LOL +endif + +ifdef ENABLE_EOB +DEFINES += -DENABLE_EOB +endif +endif + +ifdef ENABLE_LAB +DEFINES += -DENABLE_LAB=$(ENABLE_LAB) +MODULES += engines/lab +endif + +ifdef ENABLE_LASTEXPRESS +DEFINES += -DENABLE_LASTEXPRESS=$(ENABLE_LASTEXPRESS) +MODULES += engines/lastexpress +endif + +ifdef ENABLE_LILLIPUT +DEFINES += -DENABLE_LILLIPUT=$(ENABLE_LILLIPUT) +MODULES += engines/lilliput +endif + +ifdef ENABLE_LURE +DEFINES += -DENABLE_LURE=$(ENABLE_LURE) +MODULES += engines/lure +endif + +ifdef ENABLE_MACVENTURE +DEFINES += -DENABLE_MACVENTURE=$(ENABLE_MACVENTURE) +MODULES += engines/macventure +endif + +ifdef ENABLE_MADE +DEFINES += -DENABLE_MADE=$(ENABLE_MADE) +MODULES += engines/made +endif + +ifdef ENABLE_MADS +DEFINES += -DENABLE_MADS=$(ENABLE_MADS) +MODULES += engines/mads +endif + +ifdef ENABLE_MOHAWK +DEFINES += -DENABLE_MOHAWK=$(ENABLE_MOHAWK) +MODULES += engines/mohawk + +ifdef ENABLE_CSTIME +DEFINES += -DENABLE_CSTIME +endif + +ifdef ENABLE_MYST +DEFINES += -DENABLE_MYST +endif + +ifdef ENABLE_RIVEN +DEFINES += -DENABLE_RIVEN +endif +endif + +ifdef ENABLE_MORTEVIELLE +DEFINES += -DENABLE_MORTEVIELLE=$(ENABLE_MORTEVIELLE) +MODULES += engines/mortevielle +endif + +ifdef ENABLE_MUTATIONOFJB +DEFINES += -DENABLE_MUTATIONOFJB=$(ENABLE_MUTATIONOFJB) +MODULES += engines/mutationofjb +endif + +ifdef ENABLE_NEVERHOOD +DEFINES += -DENABLE_NEVERHOOD=$(ENABLE_NEVERHOOD) +MODULES += engines/neverhood +endif + +ifdef ENABLE_PARALLACTION +DEFINES += -DENABLE_PARALLACTION=$(ENABLE_PARALLACTION) +MODULES += engines/parallaction +endif + +ifdef ENABLE_PEGASUS +DEFINES += -DENABLE_PEGASUS=$(ENABLE_PEGASUS) +MODULES += engines/pegasus +endif + +ifdef ENABLE_PINK +DEFINES += -DENABLE_PINK=$(ENABLE_PINK) +MODULES += engines/pink +endif + +ifdef ENABLE_PLUMBERS +DEFINES += -DENABLE_PLUMBERS=$(ENABLE_PLUMBERS) +MODULES += engines/plumbers +endif + +ifdef ENABLE_PRINCE +DEFINES += -DENABLE_PRINCE=$(ENABLE_PRINCE) +MODULES += engines/prince +endif + +ifdef ENABLE_QUEEN +DEFINES += -DENABLE_QUEEN=$(ENABLE_QUEEN) +MODULES += engines/queen +endif + +ifdef ENABLE_SAGA +DEFINES += -DENABLE_SAGA=$(ENABLE_SAGA) +MODULES += engines/saga + +ifdef ENABLE_IHNM +DEFINES += -DENABLE_IHNM +endif + +ifdef ENABLE_SAGA2 +DEFINES += -DENABLE_SAGA2 +endif +endif + +ifdef ENABLE_SCI +DEFINES += -DENABLE_SCI=$(ENABLE_SCI) +MODULES += engines/sci + +ifdef ENABLE_SCI32 +DEFINES += -DENABLE_SCI32 +endif +endif + +ifdef ENABLE_SHERLOCK +DEFINES += -DENABLE_SHERLOCK=$(ENABLE_SHERLOCK) +MODULES += engines/sherlock +endif + +ifdef ENABLE_SKY +DEFINES += -DENABLE_SKY=$(ENABLE_SKY) +MODULES += engines/sky +endif + +ifdef ENABLE_SLUDGE +DEFINES += -DENABLE_SLUDGE=$(ENABLE_SLUDGE) +MODULES += engines/sludge +endif + +ifdef ENABLE_STARTREK +DEFINES += -DENABLE_STARTREK=$(ENABLE_STARTREK) +MODULES += engines/startrek +endif + +ifdef ENABLE_SUPERNOVA +DEFINES += -DENABLE_SUPERNOVA=$(ENABLE_SUPERNOVA) +MODULES += engines/supernova +endif + +ifdef ENABLE_SWORD1 +DEFINES += -DENABLE_SWORD1=$(ENABLE_SWORD1) +MODULES += engines/sword1 +endif + +ifdef ENABLE_SWORD2 +DEFINES += -DENABLE_SWORD2=$(ENABLE_SWORD2) +MODULES += engines/sword2 +endif + +ifdef ENABLE_SWORD25 +DEFINES += -DENABLE_SWORD25=$(ENABLE_SWORD25) +MODULES += engines/sword25 +endif + +ifdef ENABLE_TEENAGENT +DEFINES += -DENABLE_TEENAGENT=$(ENABLE_TEENAGENT) +MODULES += engines/teenagent +endif + +ifdef ENABLE_TESTBED +DEFINES += -DENABLE_TESTBED=$(ENABLE_TESTBED) +MODULES += engines/testbed +endif + +ifdef ENABLE_TINSEL +DEFINES += -DENABLE_TINSEL=$(ENABLE_TINSEL) +MODULES += engines/tinsel +endif + +ifdef ENABLE_TITANIC +DEFINES += -DENABLE_TITANIC=$(ENABLE_TITANIC) +MODULES += engines/titanic +endif + +ifdef ENABLE_TOLTECS +DEFINES += -DENABLE_TOLTECS=$(ENABLE_TOLTECS) +MODULES += engines/toltecs +endif + +ifdef ENABLE_TONY +DEFINES += -DENABLE_TONY=$(ENABLE_TONY) +MODULES += engines/tony +endif + +ifdef ENABLE_TOON +DEFINES += -DENABLE_TOON=$(ENABLE_TOON) +MODULES += engines/toon +endif + +ifdef ENABLE_TOUCHE +DEFINES += -DENABLE_TOUCHE=$(ENABLE_TOUCHE) +MODULES += engines/touche +endif + +ifdef ENABLE_TSAGE +DEFINES += -DENABLE_TSAGE=$(ENABLE_TSAGE) +MODULES += engines/tsage +endif + +ifdef ENABLE_TUCKER +DEFINES += -DENABLE_TUCKER=$(ENABLE_TUCKER) +MODULES += engines/tucker +endif + +ifdef ENABLE_VOYEUR +DEFINES += -DENABLE_VOYEUR=$(ENABLE_VOYEUR) +MODULES += engines/voyeur +endif + +ifdef ENABLE_WAGE +DEFINES += -DENABLE_WAGE=$(ENABLE_WAGE) +MODULES += engines/wage +endif + +ifdef ENABLE_WINTERMUTE +DEFINES += -DENABLE_WINTERMUTE=$(ENABLE_WINTERMUTE) +MODULES += engines/wintermute +endif + +ifdef ENABLE_XEEN +DEFINES += -DENABLE_XEEN=$(ENABLE_XEEN) +MODULES += engines/xeen +endif + +ifdef ENABLE_ZVISION +DEFINES += -DENABLE_ZVISION=$(ENABLE_ZVISION) +MODULES += engines/zvision +endif diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/plugins_table.h scummvm_modTest/engines/plugins_table.h --- scummvm-master/engines/plugins_table.h 1970-01-01 01:00:00.000000000 +0100 +++ scummvm_modTest/engines/plugins_table.h 2019-05-07 19:06:58.406473201 +0200 @@ -0,0 +1,216 @@ +/* This file is automatically generated by configure */ +/* DO NOT EDIT MANUALLY */ +// This file is being included by "base/plugins.cpp" +#if PLUGIN_ENABLED_STATIC(SCUMM) +LINK_PLUGIN(SCUMM) +#endif +#if PLUGIN_ENABLED_STATIC(ACCESS) +LINK_PLUGIN(ACCESS) +#endif +#if PLUGIN_ENABLED_STATIC(ADL) +LINK_PLUGIN(ADL) +#endif +#if PLUGIN_ENABLED_STATIC(AGI) +LINK_PLUGIN(AGI) +#endif +#if PLUGIN_ENABLED_STATIC(AGOS) +LINK_PLUGIN(AGOS) +#endif +#if PLUGIN_ENABLED_STATIC(AVALANCHE) +LINK_PLUGIN(AVALANCHE) +#endif +#if PLUGIN_ENABLED_STATIC(BBVS) +LINK_PLUGIN(BBVS) +#endif +#if PLUGIN_ENABLED_STATIC(BLADERUNNER) +LINK_PLUGIN(BLADERUNNER) +#endif +#if PLUGIN_ENABLED_STATIC(CGE) +LINK_PLUGIN(CGE) +#endif +#if PLUGIN_ENABLED_STATIC(CGE2) +LINK_PLUGIN(CGE2) +#endif +#if PLUGIN_ENABLED_STATIC(CHEWY) +LINK_PLUGIN(CHEWY) +#endif +#if PLUGIN_ENABLED_STATIC(CINE) +LINK_PLUGIN(CINE) +#endif +#if PLUGIN_ENABLED_STATIC(COMPOSER) +LINK_PLUGIN(COMPOSER) +#endif +#if PLUGIN_ENABLED_STATIC(CRUISE) +LINK_PLUGIN(CRUISE) +#endif +#if PLUGIN_ENABLED_STATIC(CRYO) +LINK_PLUGIN(CRYO) +#endif +#if PLUGIN_ENABLED_STATIC(DIRECTOR) +LINK_PLUGIN(DIRECTOR) +#endif +#if PLUGIN_ENABLED_STATIC(DM) +LINK_PLUGIN(DM) +#endif +#if PLUGIN_ENABLED_STATIC(DRACI) +LINK_PLUGIN(DRACI) +#endif +#if PLUGIN_ENABLED_STATIC(DRASCULA) +LINK_PLUGIN(DRASCULA) +#endif +#if PLUGIN_ENABLED_STATIC(DREAMWEB) +LINK_PLUGIN(DREAMWEB) +#endif +#if PLUGIN_ENABLED_STATIC(FULLPIPE) +LINK_PLUGIN(FULLPIPE) +#endif +#if PLUGIN_ENABLED_STATIC(GLK) +LINK_PLUGIN(GLK) +#endif +#if PLUGIN_ENABLED_STATIC(GNAP) +LINK_PLUGIN(GNAP) +#endif +#if PLUGIN_ENABLED_STATIC(GOB) +LINK_PLUGIN(GOB) +#endif +#if PLUGIN_ENABLED_STATIC(GROOVIE) +LINK_PLUGIN(GROOVIE) +#endif +#if PLUGIN_ENABLED_STATIC(HOPKINS) +LINK_PLUGIN(HOPKINS) +#endif +#if PLUGIN_ENABLED_STATIC(HUGO) +LINK_PLUGIN(HUGO) +#endif +#if PLUGIN_ENABLED_STATIC(ILLUSIONS) +LINK_PLUGIN(ILLUSIONS) +#endif +#if PLUGIN_ENABLED_STATIC(KYRA) +LINK_PLUGIN(KYRA) +#endif +#if PLUGIN_ENABLED_STATIC(LAB) +LINK_PLUGIN(LAB) +#endif +#if PLUGIN_ENABLED_STATIC(LASTEXPRESS) +LINK_PLUGIN(LASTEXPRESS) +#endif +#if PLUGIN_ENABLED_STATIC(LILLIPUT) +LINK_PLUGIN(LILLIPUT) +#endif +#if PLUGIN_ENABLED_STATIC(LURE) +LINK_PLUGIN(LURE) +#endif +#if PLUGIN_ENABLED_STATIC(MACVENTURE) +LINK_PLUGIN(MACVENTURE) +#endif +#if PLUGIN_ENABLED_STATIC(MADE) +LINK_PLUGIN(MADE) +#endif +#if PLUGIN_ENABLED_STATIC(MADS) +LINK_PLUGIN(MADS) +#endif +#if PLUGIN_ENABLED_STATIC(MOHAWK) +LINK_PLUGIN(MOHAWK) +#endif +#if PLUGIN_ENABLED_STATIC(MORTEVIELLE) +LINK_PLUGIN(MORTEVIELLE) +#endif +#if PLUGIN_ENABLED_STATIC(MUTATIONOFJB) +LINK_PLUGIN(MUTATIONOFJB) +#endif +#if PLUGIN_ENABLED_STATIC(NEVERHOOD) +LINK_PLUGIN(NEVERHOOD) +#endif +#if PLUGIN_ENABLED_STATIC(PARALLACTION) +LINK_PLUGIN(PARALLACTION) +#endif +#if PLUGIN_ENABLED_STATIC(PEGASUS) +LINK_PLUGIN(PEGASUS) +#endif +#if PLUGIN_ENABLED_STATIC(PINK) +LINK_PLUGIN(PINK) +#endif +#if PLUGIN_ENABLED_STATIC(PLUMBERS) +LINK_PLUGIN(PLUMBERS) +#endif +#if PLUGIN_ENABLED_STATIC(PRINCE) +LINK_PLUGIN(PRINCE) +#endif +#if PLUGIN_ENABLED_STATIC(QUEEN) +LINK_PLUGIN(QUEEN) +#endif +#if PLUGIN_ENABLED_STATIC(SAGA) +LINK_PLUGIN(SAGA) +#endif +#if PLUGIN_ENABLED_STATIC(SCI) +LINK_PLUGIN(SCI) +#endif +#if PLUGIN_ENABLED_STATIC(SHERLOCK) +LINK_PLUGIN(SHERLOCK) +#endif +#if PLUGIN_ENABLED_STATIC(SKY) +LINK_PLUGIN(SKY) +#endif +#if PLUGIN_ENABLED_STATIC(SLUDGE) +LINK_PLUGIN(SLUDGE) +#endif +#if PLUGIN_ENABLED_STATIC(STARTREK) +LINK_PLUGIN(STARTREK) +#endif +#if PLUGIN_ENABLED_STATIC(SUPERNOVA) +LINK_PLUGIN(SUPERNOVA) +#endif +#if PLUGIN_ENABLED_STATIC(SWORD1) +LINK_PLUGIN(SWORD1) +#endif +#if PLUGIN_ENABLED_STATIC(SWORD2) +LINK_PLUGIN(SWORD2) +#endif +#if PLUGIN_ENABLED_STATIC(SWORD25) +LINK_PLUGIN(SWORD25) +#endif +#if PLUGIN_ENABLED_STATIC(TEENAGENT) +LINK_PLUGIN(TEENAGENT) +#endif +#if PLUGIN_ENABLED_STATIC(TESTBED) +LINK_PLUGIN(TESTBED) +#endif +#if PLUGIN_ENABLED_STATIC(TINSEL) +LINK_PLUGIN(TINSEL) +#endif +#if PLUGIN_ENABLED_STATIC(TITANIC) +LINK_PLUGIN(TITANIC) +#endif +#if PLUGIN_ENABLED_STATIC(TOLTECS) +LINK_PLUGIN(TOLTECS) +#endif +#if PLUGIN_ENABLED_STATIC(TONY) +LINK_PLUGIN(TONY) +#endif +#if PLUGIN_ENABLED_STATIC(TOON) +LINK_PLUGIN(TOON) +#endif +#if PLUGIN_ENABLED_STATIC(TOUCHE) +LINK_PLUGIN(TOUCHE) +#endif +#if PLUGIN_ENABLED_STATIC(TSAGE) +LINK_PLUGIN(TSAGE) +#endif +#if PLUGIN_ENABLED_STATIC(TUCKER) +LINK_PLUGIN(TUCKER) +#endif +#if PLUGIN_ENABLED_STATIC(VOYEUR) +LINK_PLUGIN(VOYEUR) +#endif +#if PLUGIN_ENABLED_STATIC(WAGE) +LINK_PLUGIN(WAGE) +#endif +#if PLUGIN_ENABLED_STATIC(WINTERMUTE) +LINK_PLUGIN(WINTERMUTE) +#endif +#if PLUGIN_ENABLED_STATIC(XEEN) +LINK_PLUGIN(XEEN) +#endif +#if PLUGIN_ENABLED_STATIC(ZVISION) +LINK_PLUGIN(ZVISION) +#endif diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/sci/resource_audio.cpp scummvm_modTest/engines/sci/resource_audio.cpp --- scummvm-master/engines/sci/resource_audio.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/engines/sci/resource_audio.cpp 2019-04-29 15:51:36.366643000 +0200 @@ -297,10 +297,12 @@ int ResourceManager::readAudioMapSCI11(I uint32 offset = 0; const ResourceId mapResId(kResourceTypeMap, map->_mapNumber); + //Resource *mapRes = findResource(ResourceId(kResourceTypeMap, map->_mapNumber), false); Resource *mapRes = _resMap.getVal(mapResId, nullptr); if (!mapRes) { - warning("Failed to open %s", mapResId.toString().c_str()); + //warning("Failed to open %s", mapResId.toString().c_str()); +warning("Failed to open %i.MAP", map->_mapNumber); return SCI_ERROR_RESMAP_NOT_FOUND; } @@ -316,14 +318,15 @@ int ResourceManager::readAudioMapSCI11(I loadResource(mapRes); if (!mapRes->data()) { - warning("Failed to read data for %s", mapResId.toString().c_str()); + //warning("Failed to read data for %s", mapResId.toString().c_str()); return SCI_ERROR_RESMAP_NOT_FOUND; } ResourceSource *src = findVolume(map, map->_volumeNumber); - +//#if 0 if (!src) { - warning("Failed to find volume for %s", mapResId.toString().c_str()); + //warning("Failed to find volume for %s", mapResId.toString().c_str()); +warning("Failed to find volume for %i.MAP", map->_mapNumber); return SCI_ERROR_NO_RESOURCE_FILES_FOUND; } @@ -333,6 +336,13 @@ int ResourceManager::readAudioMapSCI11(I warning("Failed to open file stream for %s", src->getLocationName().c_str()); return SCI_ERROR_NO_RESOURCE_FILES_FOUND; } +//#endif +/* if (!src) { + warning("Failed to find volume for %i.MAP", map->_mapNumber); + return SCI_ERROR_NO_RESOURCE_FILES_FOUND; + }*/ + + //const uint32 srcSize = getVolumeFile(src)->size(); const uint32 srcSize = fileStream->size(); disposeVolumeFileStream(fileStream, src); @@ -369,8 +379,9 @@ int ResourceManager::readAudioMapSCI11(I offset += ptr.getUint24LE(); ptr += 3; } - - addResource(ResourceId(kResourceTypeAudio, n), src, offset, 0, map->getLocationName()); + //assert(offset < srcSize); + addResourcez(ResourceId(kResourceTypeAudio, n), src, offset); + //addResource(ResourceId(kResourceTypeAudio, n), src, offset, 0, map->getLocationName()); } } else if (map->_mapNumber == 0 && entrySize == 10 && ptr[3] == 0) { // QFG3 demo format @@ -387,7 +398,9 @@ int ResourceManager::readAudioMapSCI11(I uint32 size = ptr.getUint32LE(); ptr += 4; - addResource(ResourceId(kResourceTypeAudio, n), src, offset, size, map->getLocationName()); + //assert(offset + size <= srcSize); + addResourcez(ResourceId(kResourceTypeAudio, n), src, offset, size); + //addResource(ResourceId(kResourceTypeAudio, n), src, offset, size, map->getLocationName()); } } else if (map->_mapNumber == 0 && entrySize == 8 && (ptr + 2).getUint16LE() == 0xffff) { // LB2 Floppy/Mother Goose SCI1.1 format @@ -414,13 +427,16 @@ int ResourceManager::readAudioMapSCI11(I if (headerSize != 11 && headerSize != 12) { error("Unexpected header size in %s: should be 11 or 12, got %d", audioResId.toString().c_str(), headerSize); } + //assert(headerSize == 11 || headerSize == 12); stream->skip(7); size = stream->readUint32LE() + headerSize + 2; } else { size = 0; } - addResource(audioResId, src, offset, size, map->getLocationName()); + //addResource(audioResId, src, offset, size, map->getLocationName()); + //assert(offset + size <= srcSize); + addResourcez(ResourceId(kResourceTypeAudio, n), src, offset, size); } disposeVolumeFileStream(stream, src); @@ -448,34 +464,12 @@ int ResourceManager::readAudioMapSCI11(I // works if ((n & kEndOfMapFlag) == kEndOfMapFlag) { const uint32 bytesLeft = mapRes->cend() - ptr; - if (bytesLeft >= entrySize) { + /*if (bytesLeft >= entrySize) { warning("End of %s reached, but %u entries remain", mapResId.toString().c_str(), bytesLeft / entrySize); - } + }*/ break; } - // GK1CD has a message whose audio36 resource has the wrong tuple and never plays. - // The message tuple is 420 2 32 0 1 but the audio36 tuple is 420 2 32 3 1. bug #10819 - if (g_sci->getGameId() == GID_GK1 && g_sci->isCD() && - map->_mapNumber == 420 && n == 0x02200301) { - n = 0x02200001; - } - - // QFG4CD has a message whose audio36 resource has the wrong tuple and never plays. - // The message tuple is 510 23 1 0 1 but the audio36 tuple is 510 199 1 0 1. bug #10848 - if (g_sci->getGameId() == GID_QFG4 && g_sci->isCD() && - map->_mapNumber == 510 && n == 0xc7010001) { - n = 0x17010001; - } - - // QFG4CD has an orphaned audio36 resource that additionally has the wrong tuple. - // The audio36 tuple is 520 2 59 0 3. The message would be 520 2 59 0 2. bug #10849 - // We restore the missing message in message.cpp. - if (g_sci->getGameId() == GID_QFG4 && g_sci->isCD() && - map->_mapNumber == 520 && n == 0x023b0003) { - n = 0x023b0002; - } - if (isEarly) { offset = ptr.getUint32LE(); ptr += 4; @@ -491,15 +485,9 @@ int ResourceManager::readAudioMapSCI11(I // FIXME: The sync36 resource seems to be two bytes too big in KQ6CD // (bytes taken from the RAVE resource right after it) if (syncSize > 0) { - // TODO: Add a mechanism to handle cases with missing resources like the ones below - // - // LB2CD is missing the sync resource for message 1885 1 6 30 2 but it's a duplicate - // of 1885 1 6 16 2 which does have a sync resource so use that for both. bug #9956 - if (g_sci->getGameId() == GID_LAURABOW2 && map->_mapNumber == 1885 && n == 0x01061002) { - addResource(ResourceId(kResourceTypeSync36, map->_mapNumber, 0x01061e02), src, offset, syncSize, map->getLocationName()); - } - - addResource(ResourceId(kResourceTypeSync36, map->_mapNumber, n & 0xffffff3f), src, offset, syncSize, map->getLocationName()); + //addResource(ResourceId(kResourceTypeSync36, map->_mapNumber, n & 0xffffff3f), src, offset, syncSize, map->getLocationName()); + //assert(offset + syncSize <= srcSize); + addResourcez(ResourceId(kResourceTypeSync36, map->_mapNumber, n & 0xffffff3f), src, offset, syncSize); } } @@ -519,14 +507,18 @@ int ResourceManager::readAudioMapSCI11(I // validation will fail for compressed volumes (since the // relocation table in a compressed volume only contains // offsets that existed in the original audio map) - Resource *res = addResource(ResourceId(kResourceTypeRave, map->_mapNumber, n & 0xffffff3f), src, offset, syncSize + kq6HiresSyncSize, map->getLocationName()); + /*Resource *res = addResource(ResourceId(kResourceTypeRave, map->_mapNumber, n & 0xffffff3f), src, offset, syncSize + kq6HiresSyncSize, map->getLocationName()); res->_fileOffset += syncSize; res->_size -= syncSize; + syncSize += kq6HiresSyncSize;*/ + //assert(offset + syncSize + kq6HiresSyncSize <= srcSize); + addResourcez(ResourceId(kResourceTypeRave, map->_mapNumber, n & 0xffffff3f), src, offset + syncSize, kq6HiresSyncSize); syncSize += kq6HiresSyncSize; } } - const ResourceId id(kResourceTypeAudio36, map->_mapNumber, n & 0xffffff3f); + //const ResourceId id(kResourceTypeAudio36, map->_mapNumber, n & 0xffffff3f); + const ResourceId id = ResourceId(kResourceTypeAudio36, map->_mapNumber, n & 0xffffff3f); // Map 405 on CD 1 of the US release of PQ:SWAT 1.000 is broken // and points to garbage in the RESOURCE.AUD. The affected audio36 @@ -583,7 +575,9 @@ int ResourceManager::readAudioMapSCI11(I continue; } - addResource(id, src, offset + syncSize, 0, map->getLocationName()); + //addResource(id, src, offset + syncSize, 0, map->getLocationName()); + //assert(offset + syncSize < srcSize); + addResourcez(id, src, offset + syncSize); } } @@ -592,6 +586,7 @@ int ResourceManager::readAudioMapSCI11(I return 0; } + // AUDIOnnn.MAP contains 10-byte entries: // Early format: // w 5 bits resource type and 11 bits resource number @@ -643,7 +638,8 @@ int ResourceManager::readAudioMapSCI1(Re if (unload) removeAudioResource(resId); else - addResource(resId, src, offset, size, map->getLocationName()); + //addResource(resId, src, offset, size, map->getLocationName()); + addResourcez(resId, src, offset, size); } else { warning("Failed to find audio volume %i", volume_nr); return SCI_ERROR_NO_RESOURCE_FILES_FOUND; @@ -766,8 +762,6 @@ SoundResource::SoundResource(uint32 reso // Digital sample data included? -> Add an additional channel if (resource->getUint8At(0) == 2) _tracks->channelCount++; - // header information that can be passed to the SCI0 sound driver - _tracks->header = resource->subspan(0, _soundVersion == SCI_VERSION_0_EARLY ? 0x11 : 0x21); _tracks->channels = new Channel[_tracks->channelCount]; channel = &_tracks->channels[0]; channel->flags |= 2; // don't remap (SCI0 doesn't have remapping) diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/sci/resource.cpp scummvm_modTest/engines/sci/resource.cpp --- scummvm-master/engines/sci/resource.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/engines/sci/resource.cpp 2019-04-29 15:51:47.138287000 +0200 @@ -224,14 +224,10 @@ void Resource::unalloc() { } void Resource::writeToStream(Common::WriteStream *stream) const { - if (_headerSize == 0) { - // create patch file header - stream->writeByte(getType() | 0x80); // 0x80 is required by old Sierra SCI, otherwise it wont accept the patch file - stream->writeByte(_headerSize); - } else { - // use existing patch file header + stream->writeByte(getType() | 0x80); // 0x80 is required by old Sierra SCI, otherwise it wont accept the patch file + stream->writeByte(_headerSize); + if (_headerSize > 0) stream->write(_header, _headerSize); - } stream->write(_data, _size); } @@ -583,7 +579,7 @@ Common::SeekableReadStream *ResourceSour if (!fileStream) { warning("Failed to open %s", getLocationName().c_str()); - resMan->_hasBadResources = true; + //resMan->_hasBadResources = true; if (res) res->unalloc(); } @@ -804,7 +800,7 @@ void ResourceManager::addScriptChunkSour } extern void showScummVMDialog(const Common::String &message); - +#if 0 void ResourceManager::scanNewSources() { _hasBadResources = false; @@ -829,6 +825,17 @@ void ResourceManager::scanNewSources() { "game files are valid.")); } } +#endif +void ResourceManager::scanNewSources() { + for (Common::List::iterator it = _sources.begin(); it != _sources.end(); ++it) { + ResourceSource *source = *it; + + if (!source->_scanned) { + source->_scanned = true; + source->scanSource(this); + } + } +} void DirectoryResourceSource::scanSource(ResourceManager *resMan) { resMan->readResourcePatches(); @@ -839,7 +846,7 @@ void DirectoryResourceSource::scanSource resMan->readWaveAudioPatches(); } - +#if 0 void ExtMapResourceSource::scanSource(ResourceManager *resMan) { if (resMan->_mapVersion < kResVersionSci1Late) { if (resMan->readResourceMapSCI0(this) != SCI_ERROR_NONE) { @@ -851,12 +858,21 @@ void ExtMapResourceSource::scanSource(Re } } } +#endif +void ExtMapResourceSource::scanSource(ResourceManager *resMan) { + if (resMan->_mapVersion < kResVersionSci1Late) + resMan->readResourceMapSCI0(this); + else + resMan->readResourceMapSCI1(this); +} +#if 0 void ExtAudioMapResourceSource::scanSource(ResourceManager *resMan) { if (resMan->readAudioMapSCI1(this) != SCI_ERROR_NONE) { resMan->_hasBadResources = true; } } +#endif void IntMapResourceSource::scanSource(ResourceManager *resMan) { if (resMan->readAudioMapSCI11(this) != SCI_ERROR_NONE) { @@ -864,6 +880,10 @@ void IntMapResourceSource::scanSource(Re } } +void ExtAudioMapResourceSource::scanSource(ResourceManager *resMan) { + resMan->readAudioMapSCI1(this); +} + #ifdef ENABLE_SCI32 // Chunk resources are resources that hold other resources. They are normally called @@ -907,7 +927,8 @@ void ChunkResourceSource::scanSource(Res debugC(kDebugLevelResMan, 2, "Found %s in chunk %d", id.toString().c_str(), _number); - resMan->updateResource(id, this, entry.length, chunk->_source->getLocationName()); + //resMan->updateResource(id, this, entry.length, chunk->_source->getLocationName()); + resMan->updateResourcez(id, this, entry.length); // There's no end marker to the data table, but the first resource // begins directly after the entry table. So, when we hit the first @@ -928,9 +949,12 @@ void ChunkResourceSource::loadResource(R error("Trying to load non-existent resource %s from chunk %d", res->_id.toString().c_str(), _number); ResourceEntry entry = _resMap[res->_id]; - if (entry.offset + entry.length > chunk->size()) { +// + assert(entry.offset + entry.length <= chunk->_size); +// + /*if (entry.offset + entry.length > chunk->size()) { error("Resource %s is too large to exist within chunk %d (%u + %u > %u)", res->_id.toString().c_str(), _number, entry.offset, entry.length, chunk->size()); - } + }*/ byte *ptr = new byte[entry.length]; res->_data = ptr; res->_size = entry.length; @@ -1570,8 +1594,13 @@ void ResourceManager::processPatch(Resou } // Overwrite everything, because we're patching - newrsc = updateResource(resId, source, 0, fsize - patchDataOffset, source->getLocationName()); + /*newrsc = updateResource(resId, source, 0, fsize - patchDataOffset, source->getLocationName()); + newrsc->_headerSize = patchDataOffset;*/ + + newrsc = updateResourcez(resId, source, fsize - patchDataOffset); newrsc->_headerSize = patchDataOffset; + newrsc->_fileOffset = 0; + debugC(1, kDebugLevelResMan, "Patching %s - OK", source->getLocationName().c_str()); } @@ -1617,7 +1646,7 @@ void ResourceManager::readResourcePatche SearchMan.listMatchingMembers(files, "A???????.???"); SearchMan.listMatchingMembers(files, "B???????.???"); } else { - SearchMan.listMatchingMembers(files, "\\#???????.???"); + SearchMan.listMatchingMembers(files, "#???????.???"); #ifdef ENABLE_SCI32 SearchMan.listMatchingMembers(files, "S???????.???"); SearchMan.listMatchingMembers(files, "T???????.???"); @@ -1630,8 +1659,7 @@ void ResourceManager::readResourcePatche // The S/T prefixes often conflict with non-patch files and generate // spurious warnings about invalid patches - if (name.hasSuffix(".DLL") || name.hasSuffix(".EXE") || name.hasSuffix(".TXT") || name.hasSuffix(".OLD") || name.hasSuffix(".WIN") || name.hasSuffix(".DOS") || - name.hasSuffix(".HLP") || name.hasSuffix(".DRV")) { + if (name.hasSuffix(".DLL") || name.hasSuffix(".EXE") || name.hasSuffix(".TXT") || name.hasSuffix(".OLD") || name.hasSuffix(".WIN") || name.hasSuffix(".DOS")) { continue; } @@ -1739,6 +1767,17 @@ void ResourceManager::readResourcePatche } } +void ResourceManager::addResourcez(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size) { + // Adding new resource only if it does not exist + if (_resMap.contains(resId) == false) { + Resource *res = new Resource(this, resId); + _resMap.setVal(resId, res); + res->_source = src; + res->_fileOffset = offset; + res->_size = size; + } +} + int ResourceManager::readResourceMapSCI0(ResourceSource *map) { Common::SeekableReadStream *fileStream = 0; ResourceType type = kResourceTypeInvalid; // to silence a false positive in MSVC @@ -1810,7 +1849,8 @@ int ResourceManager::readResourceMapSCI0 } } - addResource(resId, source, offset & ((((byte)~bMask) << 24) | 0xFFFFFF), 0, map->getLocationName()); + //addResource(resId, source, offset & (((~bMask) << 24) | 0xFFFFFF), 0, map->getLocationName()); + addResource(resId, source, offset & (((~bMask) << 24) | 0xFFFFFF), 0); } } while (!fileStream->eos()); @@ -1899,7 +1939,8 @@ int ResourceManager::readResourceMapSCI1 Resource *resource = _resMap.getVal(resId, NULL); if (!resource) { - addResource(resId, source, fileOffset, 0, map->getLocationName()); + //addResource(resId, source, fileOffset, 0, map->getLocationName()); + addResourcez(resId, source, fileOffset, 0); } else { // If the resource is already present in a volume, change it to // the new content (but only in a volume, so as not to overwrite @@ -1910,7 +1951,15 @@ int ResourceManager::readResourceMapSCI1 // if we use the first entries in the resource file, half of the // game will be English and umlauts will also be missing :P if (resource->_source->getSourceType() == kSourceVolume) { - updateResource(resId, source, fileOffset, 0, map->getLocationName()); + //updateResource(resId, source, fileOffset, 0, map->getLocationName()); + //updateResourcez(resId, source, fileOffset); + if (resId.getType() == kResourceTypeMap) { + resource->_status = kResStatusNoMalloc; + } + resource->_source = source; + resource->_fileOffset = fileOffset; + resource->_size = 0; + } } @@ -1961,6 +2010,7 @@ int ResourceManager::readResourceMapSCI1 return 0; } + struct MacResTag { uint32 tag; ResourceType type; @@ -2047,7 +2097,8 @@ void MacResourceForkResourceSource::scan // Overwrite Resource instance. Resource forks may contain patches. // The size will be filled in later by decompressResource() - resMan->updateResource(resId, this, 0, getLocationName()); + //resMan->updateResource(resId, this, 0, getLocationName()); + resMan->updateResourcez(resId, this, 0); } } } @@ -2068,19 +2119,37 @@ bool ResourceManager::validateResource(c return true; } + + + Resource *ResourceManager::addResource(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size, const Common::String &sourceMapLocation) { // Adding new resource only if it does not exist - // Hoyle 4 contains each audio resource twice. The first file is in an unknown - // format and only static sounds are heard when it's played. The second file - // is a typical SOL audio file. We therefore skip the first audio file and add - // second one for this game. - if (_resMap.contains(resId) == false || (resId.getType() == kResourceTypeAudio && g_sci && g_sci->getGameId() == GID_HOYLE4)) { + if (_resMap.contains(resId) == false) { return updateResource(resId, src, offset, size, sourceMapLocation); } else { return _resMap.getVal(resId); } } +// +Resource *ResourceManager::updateResourcez(ResourceId resId, ResourceSource *src, uint32 size) { + // Update a patched resource, whether it exists or not + Resource *res = 0; + if (_resMap.contains(resId)) { + res = _resMap.getVal(resId); + } else { + res = new Resource(this, resId); + _resMap.setVal(resId, res); + } + + res->_status = kResStatusNoMalloc; + res->_source = src; + res->_headerSize = 0; + res->_size = size; + + return res; +} +// Resource *ResourceManager::updateResource(ResourceId resId, ResourceSource *src, uint32 size, const Common::String &sourceMapLocation) { uint32 offset = 0; if (_resMap.contains(resId)) { @@ -2107,12 +2176,7 @@ Resource *ResourceManager::updateResourc return res; } - // Resources from MacResourceForkResourceSource do not have a source size - // since the source "volume file" is the empty data fork, and they don't - // have an offset either since the MacResManager handles this, so trying to - // validate these resources using the normal validation would always fail - if (src->getSourceType() == kSourceMacResourceFork || - validateResource(resId, sourceMapLocation, src->getLocationName(), offset, size, volumeFile->size())) { + if (validateResource(resId, sourceMapLocation, src->getLocationName(), offset, size, volumeFile->size())) { if (res == nullptr) { res = new Resource(this, resId); _resMap.setVal(resId, res); @@ -2279,6 +2343,7 @@ int Resource::decompress(ResVersion volV } else { // At least Lighthouse puts sound effects in RESSCI.00n/RESSCI.PAT // instead of using a RESOURCE.SFX +#if 0 if (getType() == kResourceTypeAudio) { const uint8 headerSize = ptr[1]; if (headerSize < 11) { @@ -2292,6 +2357,15 @@ int Resource::decompress(ResVersion volV _size = MIN(_size - kResourceHeaderSize, headerSize + audioSize); } } +#endif + if (getType() == kResourceTypeAudio) { + const uint8 headerSize = ptr[1]; + assert(headerSize >= 11); + uint32 audioSize = READ_LE_UINT32(ptr + 9); + assert(audioSize + headerSize + kResourceHeaderSize == _size); + _size = headerSize + audioSize; + } + } delete dec; return errorNum; @@ -2932,9 +3006,6 @@ Common::String ResourceManager::findSier heap = findResource(ResourceId(kResourceTypeScript, 0), false); Resource *vocab = findResource(ResourceId(kResourceTypeVocab, VOCAB_RESOURCE_SELECTORS), false); - if (!vocab) - return ""; - const uint16 numSelectors = isBE ? vocab->getUint16BEAt(0) : vocab->getUint16LEAt(0); for (uint16 i = 0; i < numSelectors; ++i) { uint16 selectorOffset; diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/sci/resource.h scummvm_modTest/engines/sci/resource.h --- scummvm-master/engines/sci/resource.h 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/engines/sci/resource.h 2019-04-29 15:51:19.187211000 +0200 @@ -541,7 +541,11 @@ protected: void loadResource(Resource *res); void freeOldResources(); bool validateResource(const ResourceId &resourceId, const Common::String &sourceMapLocation, const Common::String &sourceName, const uint32 offset, const uint32 size, const uint32 sourceSize) const; + void addResourcez(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size = 0); Resource *addResource(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size = 0, const Common::String &sourceMapLocation = Common::String("(no map location)")); +// + Resource *updateResourcez(ResourceId resId, ResourceSource *src, uint32 size); +// Resource *updateResource(ResourceId resId, ResourceSource *src, uint32 size, const Common::String &sourceMapLocation = Common::String("(no map location)")); Resource *updateResource(ResourceId resId, ResourceSource *src, uint32 offset, uint32 size, const Common::String &sourceMapLocation = Common::String("(no map location)")); void removeAudioResource(ResourceId resId); @@ -654,7 +658,6 @@ public: struct Track { byte type; byte channelCount; - SciSpan header; Channel *channels; int16 digitalChannelNr; uint16 digitalSampleRate; diff -rupN '--exclude=*.o' '--exclude=*.d' '--exclude=config.mk' '--exclude=config.log' scummvm-master/engines/sci/sound/midiparser_sci.cpp scummvm_modTest/engines/sci/sound/midiparser_sci.cpp --- scummvm-master/engines/sci/sound/midiparser_sci.cpp 2019-04-29 10:48:20.000000000 +0200 +++ scummvm_modTest/engines/sci/sound/midiparser_sci.cpp 2019-04-29 17:31:01.037502000 +0200 @@ -395,8 +395,9 @@ void MidiParser_SCI::sendInitCommands() // Send header data to SCI0 sound drivers. The driver function which parses the header (opcode 3) // seems to be implemented at least in all SCI0_LATE drivers. The things that the individual drivers // do in that init function varies. - if (_track->header.byteSize()) - static_cast(_driver)->initTrack(_track->header); +// wiimpathy : quick hack, remove this. OK? + /*if (_track->header.byteSize()) + static_cast(_driver)->initTrack(_track->header);*/ } else { for (int i = 0; i < _track->channelCount; ++i) { byte voiceCount = _track->channels[i].poly;