From a079eacaba773e9b117a2b8f118e8e2b3dbf3f33 Mon Sep 17 00:00:00 2001 From: XProger Date: Sun, 15 Jul 2018 03:33:33 +0300 Subject: [PATCH] fix FMV in VR mode; more buttons to skip FMV; remove gamepad selection for SNES (CLOVER) platform; do not play FMV for level restart and title screen; --- src/core.h | 7 ++++--- src/game.h | 12 +++++++++++- src/inventory.h | 20 +++++++++++--------- src/level.h | 7 ++----- src/utils.h | 1 + 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/core.h b/src/core.h index 7e103b8..1c58d39 100644 --- a/src/core.h +++ b/src/core.h @@ -949,9 +949,10 @@ namespace Core { void endFrame() { GAPI::endFrame(); - active.targetOp |= RT_STORE_COLOR; - GAPI::setTarget(NULL, RT_STORE_COLOR); - validateRenderState(); + if (active.target != defaultTarget) { + GAPI::setTarget(NULL, 0); + validateRenderState(); + } Core::stats.stop(); } diff --git a/src/game.h b/src/game.h index fa25c60..86a0676 100644 --- a/src/game.h +++ b/src/game.h @@ -14,10 +14,20 @@ namespace Game { Stream *nextLevel; void startLevel(Stream *lvl) { + TR::LevelID id = TR::LVL_MAX; + if (level) + id = level->level.id; + Input::stopJoyVibration(); delete level; level = new Level(*lvl); - level->init(); + + bool playVideo = id != level->level.id; + if (level->level.isTitle() && id != TR::LVL_MAX) + playVideo = false; + + level->init(playVideo); + UI::game = level; #if !defined(_OS_PSP) && !defined(_OS_CLOVER) UI::helpTipTime = 5.0f; diff --git a/src/inventory.h b/src/inventory.h index 9392c7e..469715a 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -153,8 +153,10 @@ static const OptionItem optControls[] = { OptionItem( OptionItem::TYPE_TITLE, STR_SET_CONTROLS ), OptionItem( ), OptionItem( OptionItem::TYPE_PARAM, STR_NOT_IMPLEMENTED , SETTINGS( playerIndex ), STR_PLAYER_1, 0, 1 ), +#ifndef _OS_CLOVER OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_GAMEPAD , SETTINGS( controls[0].joyIndex ), STR_GAMEPAD_1, 0, 3 ), -#ifdef _OS_WIN +#endif +#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_RPI) OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_VIBRATION , SETTINGS( controls[0].vibration ), STR_OFF, 0, 1 ), #endif OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_RETARGET , SETTINGS( controls[0].retarget ), STR_OFF, 0, 1 ), @@ -543,8 +545,8 @@ struct Inventory { delete background[i]; } - void init() { - new Stream(TR::getGameVideo(game->getLevel()->id), loadVideo, this); + void init(bool playVideo) { + new Stream(playVideo ? TR::getGameVideo(game->getLevel()->id) : NULL, loadVideo, this); } bool isActive() { @@ -926,7 +928,9 @@ struct Inventory { } void update() { - if (video && (Input::state[0][cInventory] || Input::state[1][cInventory])) + if (video && (Input::state[0][cInventory] || Input::state[0][cAction] || Input::state[0][cJump] || + Input::state[1][cInventory] || Input::state[1][cAction] || Input::state[1][cJump] || + Input::down[ikCtrl] || Input::down[ikEnter] || Input::down[ikAlt])) skipVideo(); if (video) { @@ -1438,11 +1442,9 @@ struct Inventory { vertices[10].texCoord = vertices[11].texCoord = short4(0, 0, 0, 0); - if (Core::settings.detail.stereo == Core::Settings::STEREO_VR || !background[0]) { - for (int i = 0; i < 4; i++) - vertices[i].light.x = vertices[i].light.y = vertices[i].light.z = 0; - Core::whiteTex->bind(sDiffuse); // black background - } else + if ((Core::settings.detail.stereo == Core::Settings::STEREO_VR && !video) || !background[0]) + Core::blackTex->bind(sDiffuse); // black background + else background[0]->bind(sDiffuse); game->setShader(Core::passFilter, Shader::FILTER_UPSCALE, false, false); diff --git a/src/level.h b/src/level.h index 34047d4..9ad3486 100644 --- a/src/level.h +++ b/src/level.h @@ -759,8 +759,8 @@ struct Level : IGame { Sound::stopAll(); } - void init() { - inventory->init(); + void init(bool playVideo) { + inventory->init(playVideo); } void addPlayer(int index) { @@ -2636,9 +2636,6 @@ struct Level : IGame { } void render() { - if (inventory->video) - return; - bool title = inventory->isActive() || level.isTitle(); bool copyBg = title && lastTitle != title; lastTitle = title; diff --git a/src/utils.h b/src/utils.h index 3fe3de1..f15d23d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -1454,6 +1454,7 @@ static const uint32 BIT_MASK[] = { 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF, }; +// TODO: refactor for LE, BE, byte and word reading struct BitStream { uint8 *data; uint8 *end;