Skip to content

Commit 8cc844e

Browse files
author
Timur Gagiev
committed
Xbox One port (UWP)
1 parent e928908 commit 8cc844e

31 files changed

+1867
-82
lines changed

src/cache.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#define USE_SCREEN_TEX
1313
#endif
1414

15+
#if defined(_GAPI_D3D8) || defined(_GAPI_D3D9) || defined(_GAPI_D3D11)
16+
#define EARLY_CLEAR
17+
#endif
18+
1519
struct ShaderCache {
1620
enum Effect { FX_NONE = 0, FX_UNDERWATER = 1, FX_ALPHA_TEST = 2 };
1721

@@ -86,8 +90,8 @@ struct ShaderCache {
8690
void prepareSky(int fx) {
8791
compile(Core::passSky, Shader::DEFAULT, fx, rsBase);
8892
if (Core::support.tex3D) {
89-
compile(Core::passSky, Shader::SKY_CLOUDS, fx, rsBase);
90-
compile(Core::passSky, Shader::SKY_CLOUDS_AZURE, fx, rsBase);
93+
compile(Core::passSky, Shader::SKY_CLOUDS, fx, rsBase);
94+
compile(Core::passSky, Shader::SKY_AZURE, fx, rsBase);
9195
}
9296
}
9397

src/core.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@
1313

1414
#define USE_CUBEMAP_MIPS
1515

16-
#ifdef WIN32
16+
#ifdef __UWP__
17+
#define _OS_UWP 1
18+
#define _GAPI_D3D11 1
19+
20+
#ifdef __XB1__
21+
#define _OS_XB1
22+
#endif
23+
24+
#undef OS_PTHREAD_MT
25+
#elif WIN32
1726
#define _OS_WIN 1
1827
#define _GAPI_GL 1
1928
//#define _GAPI_D3D9 1
@@ -137,6 +146,12 @@
137146
#define NOMINMAX
138147
#include <xtl.h>
139148
#include <xgraphics.h>
149+
#elif _X360
150+
#define _OS_X360 1
151+
// TODO
152+
#elif _XB1
153+
#define _OS_XB1 1
154+
#define _GAPI_D3D11 1
140155
#endif
141156

142157
#ifndef _OS_PSP
@@ -1014,6 +1029,7 @@ namespace Core {
10141029
GAPI::deinit();
10151030
NAPI::deinit();
10161031
Sound::deinit();
1032+
Stream::deinit();
10171033
}
10181034

10191035
void setVSync(bool enable) {

src/gapi/d3d11.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@
3737

3838
extern ID3D11Device *device;
3939
extern ID3D11DeviceContext *deviceContext;
40+
#ifdef _OS_XB1
41+
extern IDXGISwapChain1 *swapChain;
42+
#else
4043
extern IDXGISwapChain *swapChain;
44+
#endif
4145

4246
namespace GAPI {
4347
using namespace Core;
@@ -134,7 +138,7 @@ namespace GAPI {
134138
#define SHADER_U(S,P) (underwater ? SHADER(S##_u,P) : SHADER(S,P))
135139
#define SHADER_AU(S,P) ((underwater && alphatest) ? SHADER(S##_au,P) : (alphatest ? SHADER(S##_a,P) : SHADER_U(S,P)))
136140

137-
const uint8 *vSrc, *fSrc;
141+
const uint8 *vSrc = NULL, *fSrc = NULL;
138142
switch (pass) {
139143
case passCompose :
140144
switch (type) {
@@ -161,7 +165,14 @@ namespace GAPI {
161165
default : ASSERT(false);
162166
}
163167
break;
164-
case passSky : SHADER ( gui, v ); SHADER ( gui, f ); break; // TODO
168+
case passSky :
169+
switch (type) {
170+
case 0 : SHADER ( sky, v ); SHADER ( sky, f ); break;
171+
case 1 : SHADER ( sky_clouds, v ); SHADER ( sky_clouds, f ); break;
172+
case 2 : SHADER ( sky_azure, v ); SHADER ( sky_azure, f ); break;
173+
default : ASSERT(false);
174+
}
175+
break;
165176
case passWater :
166177
switch (type) {
167178
case 0 : SHADER ( water_drop, v ); SHADER ( water_drop, f ); break;
@@ -179,7 +190,7 @@ namespace GAPI {
179190
case 1 : SHADER ( filter_downsample, v ); SHADER ( filter_downsample, f ); break;
180191
case 3 : SHADER ( filter_grayscale, v ); SHADER ( filter_grayscale, f ); break;
181192
case 4 : SHADER ( filter_blur, v ); SHADER ( filter_blur, f ); break;
182-
case 5 : SHADER ( filter_anaglyph, v ); SHADER ( filter_anaglyph, f ); break; // TODO anaglyph
193+
case 5 : SHADER ( filter_anaglyph, v ); SHADER ( filter_anaglyph, f ); break;
183194
default : ASSERT(false);
184195
}
185196
break;

src/inventory.h

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ struct OptionItem {
8282
int maxWidth = UI::getTextSize(STR[color + value]).x;
8383
maxWidth = maxWidth / 2 + 8;
8484
x += w * 0.5f;
85-
if (checkValue(value - 1)) UI::specOut(vec2(x - maxWidth - 16.0f, y), 108);
86-
if (checkValue(value + 1)) UI::specOut(vec2(x + maxWidth, y), 109);
85+
if (maxValue != 0xFF) {
86+
if (checkValue(value - 1)) UI::specOut(vec2(x - maxWidth - 16.0f, y), 108);
87+
if (checkValue(value + 1)) UI::specOut(vec2(x + maxWidth, y), 109);
88+
}
8789
}
8890
return y + LINE_HEIGHT;
8991
}
@@ -123,23 +125,51 @@ struct OptionItem {
123125
}
124126
};
125127

126-
#define SETTINGS(x) OFFSETOF(Core::Settings, x)
128+
#define SETTINGS(x) int32(OFFSETOF(Core::Settings, x))
129+
130+
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_CLOVER) || defined(_OS_PSC) || defined(_OS_XBOX) || defined(_OS_XB1)
131+
#define INV_GAMEPAD_ONLY
132+
#else
133+
#define INV_QUALITY
134+
#endif
135+
136+
#if !(defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_XBOX) || defined(_OS_XB1))
137+
#define INV_STEREO
138+
#endif
139+
140+
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_GCW0)
141+
#define INV_SINGLE_PLAYER
142+
#endif
143+
144+
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_CLOVER) || defined(_OS_XBOX)
145+
#define INV_GAMEPAD_NO_TRIGGER
146+
#endif
147+
148+
#ifdef INV_SINGLE_PLAYER
149+
#define INV_CTRL_START_OPTION 1
150+
#else
151+
#define INV_CTRL_START_OPTION 2
152+
#endif
153+
154+
#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_RPI) || defined(_OS_GCW0) || defined(_OS_XBOX) || defined(_OS_XB1)
155+
#define INV_VIBRATION
156+
#endif
127157

128158
static const OptionItem optDetail[] = {
129159
OptionItem( OptionItem::TYPE_TITLE, STR_SELECT_DETAIL ),
130160
OptionItem( ),
161+
#ifdef INV_QUALITY
131162
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_FILTER, SETTINGS( detail.filter ), STR_QUALITY_LOW, 0, 2 ),
132163
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_LIGHTING, SETTINGS( detail.lighting ), STR_QUALITY_LOW, 0, 2 ),
133164
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_SHADOWS, SETTINGS( detail.shadows ), STR_QUALITY_LOW, 0, 2 ),
134165
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_WATER, SETTINGS( detail.water ), STR_QUALITY_LOW, 0, 2 ),
166+
#endif
135167
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_SIMPLE_ITEMS, SETTINGS( detail.simple ), STR_OFF, 0, 1 ),
136-
#if !defined(_OS_3DS) && !defined(_OS_GCW0)
168+
#ifdef INV_QUALITY
137169
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_RESOLUTION, SETTINGS( detail.scale ), STR_SCALE_100, 0, 3 ),
138-
#endif
139-
#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_PSP) || defined(_OS_RPI) || defined(_OS_PSV)
140170
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_VSYNC, SETTINGS( detail.vsync ), STR_OFF, 0, 1 ),
141171
#endif
142-
#if !defined(_OS_PSP) && !defined(_OS_PSV) && !defined(_OS_3DS) && !defined(_OS_GCW0)
172+
#ifdef INV_STEREO
143173
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_DETAIL_STEREO, SETTINGS( detail.stereo ), STR_NO_STEREO, 0,
144174
#if defined(_OS_WIN) || defined(_OS_ANDROID)
145175
4 /* with VR option */
@@ -164,28 +194,6 @@ static const OptionItem optSound[] = {
164194
#endif
165195
};
166196

167-
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_CLOVER) || defined(_OS_PSC) || defined(_OS_XBOX)
168-
#define INV_GAMEPAD_ONLY
169-
#endif
170-
171-
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_GCW0)
172-
#define INV_SINGLE_PLAYER
173-
#endif
174-
175-
#if defined(_OS_PSP) || defined(_OS_PSV) || defined(_OS_3DS) || defined(_OS_CLOVER)
176-
#define INV_GAMEPAD_NO_TRIGGER
177-
#endif
178-
179-
#ifdef INV_SINGLE_PLAYER
180-
#define INV_CTRL_START_OPTION 1
181-
#else
182-
#define INV_CTRL_START_OPTION 2
183-
#endif
184-
185-
#if defined(_OS_WIN) || defined(_OS_LINUX) || defined(_OS_RPI) || defined(_OS_GCW0) || defined(_OS_XBOX)
186-
#define INV_VIBRATION
187-
#endif
188-
189197
static const OptionItem optControls[] = {
190198
OptionItem( OptionItem::TYPE_TITLE, STR_SET_CONTROLS ),
191199
OptionItem( ),
@@ -199,7 +207,7 @@ static const OptionItem optControls[] = {
199207
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_RETARGET , SETTINGS( controls[0].retarget ), STR_OFF, 0, 1 ),
200208
OptionItem( OptionItem::TYPE_PARAM, STR_OPT_CONTROLS_MULTIAIM , SETTINGS( controls[0].multiaim ), STR_OFF, 0, 1 ),
201209
#ifdef INV_GAMEPAD_ONLY
202-
OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( playerIndex ), STR_OPT_CONTROLS_GAMEPAD, 0, 0 ),
210+
OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( ctrlIndex ), STR_OPT_CONTROLS_KEYBOARD, 0, 0xFF ),
203211
#else
204212
OptionItem( OptionItem::TYPE_PARAM, STR_EMPTY , SETTINGS( ctrlIndex ), STR_OPT_CONTROLS_KEYBOARD, 0, 1 ),
205213
#endif
@@ -499,14 +507,14 @@ struct Inventory {
499507
case cUp : nextSlot(slot, -1); break;
500508
case cDown : nextSlot(slot, +1); break;
501509
case cLeft :
502-
if (opt->type == OptionItem::TYPE_PARAM && opt->checkValue(value - 1)) {
510+
if (opt->type == OptionItem::TYPE_PARAM && (opt->maxValue != 0xFF) && opt->checkValue(value - 1)) {
503511
value--;
504512
timer = 0.2f;
505513
return opt;
506514
}
507515
break;
508516
case cRight :
509-
if (opt->type == OptionItem::TYPE_PARAM && opt->checkValue(value + 1)) {
517+
if (opt->type == OptionItem::TYPE_PARAM && (opt->maxValue != 0xFF) && opt->checkValue(value + 1)) {
510518
value++;
511519
timer = 0.2f;
512520
return opt;
@@ -2090,7 +2098,7 @@ struct Inventory {
20902098
const char *bSelect = STR[STR_KEY_FIRST + ikEnter];
20912099
const char *bBack = STR[STR_KEY_FIRST + Core::settings.controls[playerIndex].keys[cInventory].key];
20922100

2093-
#if defined(_OS_SWITCH) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_XBOX)
2101+
#if defined(_OS_SWITCH) || defined(_OS_3DS) || defined(_OS_GCW0) || defined(_OS_XBOX) || defined(_OS_XB1)
20942102
bSelect = "A";
20952103
bBack = "B";
20962104
#endif

src/level.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ struct Level : IGame {
18081808
}
18091809

18101810
void renderSky() {
1811-
#ifndef _GAPI_GL
1811+
#if !defined(_GAPI_GL) && !defined(_GAPI_D3D11)
18121812
return;
18131813
#endif
18141814
ASSERT(mesh->transparent == 0);
@@ -1819,7 +1819,7 @@ struct Level : IGame {
18191819
if (level.version & TR::VER_TR1) {
18201820
if (Core::settings.detail.lighting < Core::Settings::HIGH || !Core::support.tex3D || !TR::getSkyParams(level.id, skyParams))
18211821
return;
1822-
type = Shader::SKY_CLOUDS_AZURE;
1822+
type = Shader::SKY_AZURE;
18231823
} else { // TR2, TR3
18241824
if (level.extra.sky == -1)
18251825
return;
@@ -1857,7 +1857,7 @@ struct Level : IGame {
18571857
time = (time - int(time)) * SKY_TIME_PERIOD;
18581858
}
18591859

1860-
Core::active.shader->setParam(uParam, vec4(skyParams.wind * time, 1.0));
1860+
Core::active.shader->setParam(uParam, vec4(skyParams.wind * time * 2.0f, 1.0));
18611861
Core::active.shader->setParam(uLightProj, *(mat4*)&skyParams);
18621862
Core::active.shader->setParam(uPosScale, skyParams.cloudDownColor, 2);
18631863

@@ -2608,7 +2608,18 @@ struct Level : IGame {
26082608
Texture *screen = NULL;
26092609
if (water) {
26102610
screen = (waterCache && waterCache->visible) ? waterCache->getScreenTex() : NULL;
2611-
Core::setTarget(screen, NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR | (screen ? RT_STORE_DEPTH : 0)); // render to screen texture (FUCK YOU iOS!) or back buffer
2611+
2612+
int clearFlags = RT_STORE_COLOR;
2613+
2614+
if (screen) {
2615+
clearFlags |= RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_DEPTH;
2616+
}
2617+
2618+
#ifndef EARLY_CLEAR
2619+
clearFlags |= RT_CLEAR_COLOR | RT_CLEAR_DEPTH;
2620+
#endif
2621+
2622+
Core::setTarget(screen, NULL, clearFlags); // render to screen texture or back buffer
26122623
Core::validateRenderState();
26132624
setupBinding();
26142625
}
@@ -2649,7 +2660,7 @@ struct Level : IGame {
26492660
Core::Pass pass = Core::pass;
26502661

26512662
if (water && waterCache && waterCache->visible && screen) {
2652-
Core::setTarget(NULL, NULL, RT_STORE_COLOR);
2663+
Core::setTarget(NULL, NULL, RT_CLEAR_DEPTH | RT_STORE_COLOR);
26532664
Core::validateRenderState();
26542665
waterCache->blitTexture(screen);
26552666
}
@@ -3201,6 +3212,13 @@ struct Level : IGame {
32013212
#endif
32023213
}
32033214
}
3215+
3216+
#ifdef EARLY_CLEAR
3217+
if (view == 0 && eye <= 0) {
3218+
Core::setTarget(NULL, NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR | RT_STORE_DEPTH);
3219+
Core::validateRenderState();
3220+
}
3221+
#endif
32043222
}
32053223

32063224
void renderEye(int eye, bool showUI, bool invBG) {

src/libs/tinf/tinflate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static int tinf_inflate_block_data(TINF_DATA *d, TINF_TREE *lt, TINF_TREE *dt)
303303
/* check for end of block */
304304
if (sym == 256)
305305
{
306-
*d->destLen += d->dest - start;
306+
*d->destLen += (unsigned int)(d->dest - start);
307307
return TINF_OK;
308308
}
309309

10.9 KB
Loading
2.24 KB
Loading
Loading
Loading
Loading
Loading
Loading
1.55 KB
Loading
Loading

src/platform/xb1/OpenLara.sln

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.1022
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenLara", "OpenLara.vcxproj", "{0DF8D188-E91B-49C5-A2C5-75C430648B5E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|ARM = Debug|ARM
11+
Debug|ARM64 = Debug|ARM64
12+
Debug|x64 = Debug|x64
13+
Debug|x86 = Debug|x86
14+
Release|ARM = Release|ARM
15+
Release|ARM64 = Release|ARM64
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.ActiveCfg = Debug|ARM
21+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.Build.0 = Debug|ARM
22+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM.Deploy.0 = Debug|ARM
23+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.ActiveCfg = Debug|ARM64
24+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.Build.0 = Debug|ARM64
25+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|ARM64.Deploy.0 = Debug|ARM64
26+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.ActiveCfg = Debug|x64
27+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.Build.0 = Debug|x64
28+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x64.Deploy.0 = Debug|x64
29+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.ActiveCfg = Debug|Win32
30+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.Build.0 = Debug|Win32
31+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Debug|x86.Deploy.0 = Debug|Win32
32+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.ActiveCfg = Release|ARM
33+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.Build.0 = Release|ARM
34+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM.Deploy.0 = Release|ARM
35+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.ActiveCfg = Release|ARM64
36+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.Build.0 = Release|ARM64
37+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|ARM64.Deploy.0 = Release|ARM64
38+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.ActiveCfg = Release|x64
39+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.Build.0 = Release|x64
40+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x64.Deploy.0 = Release|x64
41+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.ActiveCfg = Release|Win32
42+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.Build.0 = Release|Win32
43+
{0DF8D188-E91B-49C5-A2C5-75C430648B5E}.Release|x86.Deploy.0 = Release|Win32
44+
EndGlobalSection
45+
GlobalSection(SolutionProperties) = preSolution
46+
HideSolutionNode = FALSE
47+
EndGlobalSection
48+
GlobalSection(ExtensibilityGlobals) = postSolution
49+
SolutionGuid = {037CFBE7-50F7-492C-B712-18C42FD39BE3}
50+
EndGlobalSection
51+
EndGlobal

0 commit comments

Comments
 (0)