mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-06 04:05:11 +08:00
Compare commits
197 Commits
continuous
...
psp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8044646a2b | ||
|
|
7d8ea61ac2 | ||
|
|
40041e30eb | ||
|
|
a247e139bf | ||
|
|
00b2ca7f5a | ||
|
|
e58007aab3 | ||
|
|
dca862a838 | ||
|
|
7e71e20714 | ||
|
|
cee6862924 | ||
|
|
a8cc68f6b9 | ||
|
|
2af0adb629 | ||
|
|
628ac376ed | ||
|
|
251e6ac1dc | ||
|
|
9b6518376c | ||
|
|
6c3fee7f27 | ||
|
|
c111a59639 | ||
|
|
ba9bb70924 | ||
|
|
6acc97b0ef | ||
|
|
cd681d4303 | ||
|
|
46f30e215c | ||
|
|
2ae038c01c | ||
|
|
aaa9fbd50f | ||
|
|
51d4716bcb | ||
|
|
045caacfee | ||
|
|
95a5c670a2 | ||
|
|
30259e1573 | ||
|
|
8b884132b7 | ||
|
|
266f9a6bc6 | ||
|
|
58177d9251 | ||
|
|
69e801d6b8 | ||
|
|
388cc3061f | ||
|
|
c9d29b3955 | ||
|
|
371025dc8e | ||
|
|
cf7a79bff3 | ||
|
|
55dfa1bf44 | ||
|
|
519c8a032a | ||
|
|
c15822f375 | ||
|
|
0e91deec19 | ||
|
|
87b204c661 | ||
|
|
caefa0b7b9 | ||
|
|
a311923d4e | ||
|
|
ee4cb39f3e | ||
|
|
18436a70eb | ||
|
|
8298053e6a | ||
|
|
9304a0041d | ||
|
|
64f92003fa | ||
|
|
be0a241244 | ||
|
|
df6546d5b1 | ||
|
|
a0c31120d9 | ||
|
|
c0757bd84c | ||
|
|
9fa32a9cf4 | ||
|
|
15bc09b06b | ||
|
|
315aea1991 | ||
|
|
380422a6dc | ||
|
|
be26ecf1c9 | ||
|
|
d2bbe9dfd2 | ||
|
|
9c929c1405 | ||
|
|
9551240680 | ||
|
|
6605d0456c | ||
|
|
99e8f7b486 | ||
|
|
5ac8f63741 | ||
|
|
9d3949a948 | ||
|
|
5bd1dd34b3 | ||
|
|
6862b14e59 | ||
|
|
dc1d65f621 | ||
|
|
fba3a2b67f | ||
|
|
b946c8455d | ||
|
|
c56e876043 | ||
|
|
9773d11464 | ||
|
|
3c28b11754 | ||
|
|
f2584dcb9d | ||
|
|
ce73838f1b | ||
|
|
49f972a7c9 | ||
|
|
1ae01d89de | ||
|
|
8e54e18c8f | ||
|
|
18136e5320 | ||
|
|
a29f1899d3 | ||
|
|
0f804ffc30 | ||
|
|
620a4b4894 | ||
|
|
4cf87c2c23 | ||
|
|
f031c31b77 | ||
|
|
c2447d8634 | ||
|
|
ae9c1d9f18 | ||
|
|
0132eb6e44 | ||
|
|
f12df54226 | ||
|
|
d971055927 | ||
|
|
6059538d77 | ||
|
|
17deba0606 | ||
|
|
82a2d272ad | ||
|
|
707a9228e1 | ||
|
|
59ddfb787f | ||
|
|
acdf1da995 | ||
|
|
f1cdab91eb | ||
|
|
05d5abe4db | ||
|
|
44e017a410 | ||
|
|
64f3884f23 | ||
|
|
6386782674 | ||
|
|
8084687e50 | ||
|
|
6c16de55c0 | ||
|
|
537237ef62 | ||
|
|
4dfc3f34cb | ||
|
|
d22bbb4213 | ||
|
|
0e3b14e9a5 | ||
|
|
afb0540aa3 | ||
|
|
4d802d8901 | ||
|
|
6a4bf4965f | ||
|
|
a3c9538d12 | ||
|
|
632264809f | ||
|
|
bcfabbe802 | ||
|
|
c244cfc937 | ||
|
|
cae351f7b1 | ||
|
|
9812a9104b | ||
|
|
d419921ca3 | ||
|
|
3ccb156554 | ||
|
|
15ea61ea34 | ||
|
|
e6a9724d7c | ||
|
|
28723b01a9 | ||
|
|
0dc1c13b83 | ||
|
|
1704712650 | ||
|
|
066d87f546 | ||
|
|
0b500168a7 | ||
|
|
e3e5fe8e18 | ||
|
|
da161103b1 | ||
|
|
d6d8ee3e57 | ||
|
|
89ee68d5d0 | ||
|
|
f5ca0175a5 | ||
|
|
5559f728b7 | ||
|
|
238687affa | ||
|
|
5832d017c7 | ||
|
|
4e78898c6f | ||
|
|
c6520b83b2 | ||
|
|
a440d1ff7a | ||
|
|
3889ed8c52 | ||
|
|
53d44f4c0e | ||
|
|
bdc2009683 | ||
|
|
a375adb9ea | ||
|
|
122a11005b | ||
|
|
f70938d2b0 | ||
|
|
40dca1ea1f | ||
|
|
f8452b8490 | ||
|
|
3b50fded8b | ||
|
|
5ad4f43a7e | ||
|
|
ef117ffbb3 | ||
|
|
8850d2ae52 | ||
|
|
e66400ca39 | ||
|
|
01affdcbbd | ||
|
|
ed2ba1f226 | ||
|
|
1abec2620a | ||
|
|
f4ae5cf8e0 | ||
|
|
57ddff5457 | ||
|
|
d98330adca | ||
|
|
21ed285da7 | ||
|
|
b517019750 | ||
|
|
b567531cdb | ||
|
|
9c61941e52 | ||
|
|
3afc7134ab | ||
|
|
bcf838c42f | ||
|
|
91d6fdd190 | ||
|
|
b8ff41eac9 | ||
|
|
0277700977 | ||
|
|
da68591f03 | ||
|
|
da695b75c4 | ||
|
|
1b4bc7f5ec | ||
|
|
cbfb43f05b | ||
|
|
db9e82cdec | ||
|
|
12889494e0 | ||
|
|
f2d59eb7f8 | ||
|
|
3a3b8e2c4a | ||
|
|
1e132bf29e | ||
|
|
d35330cd55 | ||
|
|
c07c1357e5 | ||
|
|
8071355d68 | ||
|
|
6073e35bfc | ||
|
|
8e8a0e4908 | ||
|
|
1d7176751c | ||
|
|
07e29771a1 | ||
|
|
89ec7122fe | ||
|
|
fe8fea742d | ||
|
|
2ab8bce924 | ||
|
|
90faeb231f | ||
|
|
2885d44593 | ||
|
|
4dfdbdd6aa | ||
|
|
5eb19c1478 | ||
|
|
13a9c41b0c | ||
|
|
2eef2cec49 | ||
|
|
7be87a913d | ||
|
|
dc22f5cbaf | ||
|
|
5c244b4140 | ||
|
|
e7e10ac8b9 | ||
|
|
a308ce2f48 | ||
|
|
eea17a4e32 | ||
|
|
cab187618d | ||
|
|
32e175311b | ||
|
|
190279c117 | ||
|
|
f5aaa58ff9 | ||
|
|
cd37d866c2 | ||
|
|
64020b2902 |
21
.cirrus.yml
21
.cirrus.yml
@@ -1,14 +1,15 @@
|
|||||||
task:
|
task:
|
||||||
name: freebsd-12-amd64
|
# Seems packages for it were removed from the mirrors
|
||||||
freebsd_instance:
|
# name: freebsd-12-amd64
|
||||||
image_family: freebsd-12-4
|
# freebsd_instance:
|
||||||
setup_script:
|
# image_family: freebsd-12-4
|
||||||
- pkg update
|
# setup_script:
|
||||||
- pkg install -y pkgconf git sdl2 python fontconfig opus
|
# - pkg update
|
||||||
- git submodule update --init --recursive
|
# - pkg install -y pkgconf git sdl2 python fontconfig opus
|
||||||
test_script:
|
# - git submodule update --init --recursive
|
||||||
- ./scripts/cirrus/build_freebsd.sh dedicated
|
# test_script:
|
||||||
- ./scripts/cirrus/build_freebsd.sh full
|
# - ./scripts/cirrus/build_freebsd.sh dedicated
|
||||||
|
# - ./scripts/cirrus/build_freebsd.sh full
|
||||||
|
|
||||||
task:
|
task:
|
||||||
name: freebsd-13-amd64
|
name: freebsd-13-amd64
|
||||||
|
|||||||
4
.github/workflows/c-cpp.yml
vendored
4
.github/workflows/c-cpp.yml
vendored
@@ -45,11 +45,11 @@ jobs:
|
|||||||
- os: windows-latest
|
- os: windows-latest
|
||||||
targetos: win32
|
targetos: win32
|
||||||
targetarch: amd64
|
targetarch: amd64
|
||||||
- os: windows-latest
|
- os: windows-2019 # always use the oldest possible for 32-bit because of older compilers, and better support of certain legacy OSes
|
||||||
targetos: win32
|
targetos: win32
|
||||||
targetarch: i386
|
targetarch: i386
|
||||||
env:
|
env:
|
||||||
SDL_VERSION: 2.28.1
|
SDL_VERSION: 2.28.5
|
||||||
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
GH_CPU_ARCH: ${{ matrix.targetarch }}
|
||||||
ANDROID_SDK_TOOLS_VER: 4333796
|
ANDROID_SDK_TOOLS_VER: 4333796
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
Submodule 3rdparty/mainui updated: b4bb815420...7223589d60
@@ -240,6 +240,8 @@ CSO-like Xash3D-based mod, CSMoE - https://github.com/MoeMod/CSMoE
|
|||||||
## Crack-Life: Campaign Mode
|
## Crack-Life: Campaign Mode
|
||||||
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life
|
Recreation by lostgamer aka nillerusr - https://github.com/LostGamerHL/crack_life
|
||||||
|
|
||||||
|
Reverse-engineered code: branch **clcampaign** in hlsdk-portable - https://github.com/FWGS/hlsdk-portable/tree/clcampaign
|
||||||
|
|
||||||
## Escape from the Darkness
|
## Escape from the Darkness
|
||||||
malortie's recreation - https://github.com/malortie/hl-eftd
|
malortie's recreation - https://github.com/malortie/hl-eftd
|
||||||
|
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -73,6 +73,10 @@ This repository contains our fork of HLSDK and restored source code for some of
|
|||||||
* Clone this repostory:
|
* Clone this repostory:
|
||||||
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`
|
`$ git clone --recursive https://github.com/FWGS/xash3d-fwgs`
|
||||||
|
|
||||||
|
#### PSP
|
||||||
|
* Build pspsdk(GCC 9.3) from https://github.com/pspdev
|
||||||
|
* Clone this repository: `git clone --recursive https://github.com/Crow-bar/xash3d-fwgs`.
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
#### Windows (Visual Studio)
|
#### Windows (Visual Studio)
|
||||||
0) Open command line
|
0) Open command line
|
||||||
@@ -90,3 +94,20 @@ If compiling 32-bit on amd64, you may need to supply `export PKG_CONFIG_PATH=/us
|
|||||||
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor)
|
(You need to pass `-8` to compile 64-bit engine on 64-bit x86 processor)
|
||||||
2) Compile: `./waf build`
|
2) Compile: `./waf build`
|
||||||
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`
|
3) Install(optional): `./waf install --destdir=/path/to/any/output/directory`
|
||||||
|
|
||||||
|
#### PSP
|
||||||
|
0) Navigate to `xash3d-fwgs` directory.
|
||||||
|
1) Examine which build options are available: `./waf --help`
|
||||||
|
2) Configure build:
|
||||||
|
Normal: `./waf configure -T fast --psp=prx,660,HW --prefix=/path/to/any/output/directory`
|
||||||
|
Profiling: `./waf configure -T debug --psp=elf,660,HW --enable-profiling --prefix=/path/to/any/output/directory`
|
||||||
|
3) Compile: `./waf build`
|
||||||
|
4) Install(optional): `./waf install`
|
||||||
|
|
||||||
|
|
||||||
|
## Running
|
||||||
|
0) Copy libraries and main executable somewhere, if you're skipped installation stage.
|
||||||
|
1) Copy game files to same directory
|
||||||
|
2) Run `xash3d.exe`/`xash3d.sh`/`xash3d` depending on which platform you're using.
|
||||||
|
|
||||||
|
For additional info, run Xash3D with `-help` command line key.
|
||||||
|
|||||||
@@ -20,16 +20,19 @@ GNU General Public License for more details.
|
|||||||
#define VIDEO_SDL 1
|
#define VIDEO_SDL 1
|
||||||
#define VIDEO_FBDEV 3
|
#define VIDEO_FBDEV 3
|
||||||
#define VIDEO_DOS 4
|
#define VIDEO_DOS 4
|
||||||
|
#define VIDEO_PSP 5
|
||||||
|
|
||||||
// audio backends (XASH_SOUND)
|
// audio backends (XASH_SOUND)
|
||||||
#define SOUND_NULL 0
|
#define SOUND_NULL 0
|
||||||
#define SOUND_SDL 1
|
#define SOUND_SDL 1
|
||||||
#define SOUND_ALSA 3
|
#define SOUND_ALSA 3
|
||||||
|
#define SOUND_PSP 4
|
||||||
|
|
||||||
// input (XASH_INPUT)
|
// input (XASH_INPUT)
|
||||||
#define INPUT_NULL 0
|
#define INPUT_NULL 0
|
||||||
#define INPUT_SDL 1
|
#define INPUT_SDL 1
|
||||||
#define INPUT_EVDEV 3
|
#define INPUT_EVDEV 3
|
||||||
|
#define INPUT_PSP 4
|
||||||
|
|
||||||
// timer (XASH_TIMER)
|
// timer (XASH_TIMER)
|
||||||
#define TIMER_NULL 0 // not used
|
#define TIMER_NULL 0 // not used
|
||||||
@@ -37,17 +40,20 @@ GNU General Public License for more details.
|
|||||||
#define TIMER_POSIX 2
|
#define TIMER_POSIX 2
|
||||||
#define TIMER_WIN32 3
|
#define TIMER_WIN32 3
|
||||||
#define TIMER_DOS 4
|
#define TIMER_DOS 4
|
||||||
|
#define TIMER_PSP 5
|
||||||
|
|
||||||
// messageboxes (XASH_MESSAGEBOX)
|
// messageboxes (XASH_MESSAGEBOX)
|
||||||
#define MSGBOX_STDERR 0
|
#define MSGBOX_STDERR 0
|
||||||
#define MSGBOX_SDL 1
|
#define MSGBOX_SDL 1
|
||||||
#define MSGBOX_WIN32 3
|
#define MSGBOX_WIN32 3
|
||||||
#define MSGBOX_NSWITCH 4
|
#define MSGBOX_NSWITCH 4
|
||||||
|
#define MSGBOX_PSP 5
|
||||||
|
|
||||||
// library loading (XASH_LIB)
|
// library loading (XASH_LIB)
|
||||||
#define LIB_NULL 0
|
#define LIB_NULL 0
|
||||||
#define LIB_POSIX 1
|
#define LIB_POSIX 1
|
||||||
#define LIB_WIN32 2
|
#define LIB_WIN32 2
|
||||||
#define LIB_STATIC 3
|
#define LIB_STATIC 3
|
||||||
|
#define LIB_PSP 4
|
||||||
|
|
||||||
#endif /* BACKENDS_H */
|
#endif /* BACKENDS_H */
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ NOTE: number at end of pixelformat name it's a total bitscount e.g. PF_RGB_24 ==
|
|||||||
|| type == PF_BC7_UNORM \
|
|| type == PF_BC7_UNORM \
|
||||||
|| type == PF_BC7_SRGB \
|
|| type == PF_BC7_SRGB \
|
||||||
|| type == PF_KTX2_RAW )
|
|| type == PF_KTX2_RAW )
|
||||||
|
#define ImageIND( type ) (type == PF_INDEXED_32 || type == PF_INDEXED_24)
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -33,6 +34,10 @@ typedef enum
|
|||||||
PF_BGRA_32, // big endian RGBA (MacOS)
|
PF_BGRA_32, // big endian RGBA (MacOS)
|
||||||
PF_RGB_24, // uncompressed dds or another 24-bit image
|
PF_RGB_24, // uncompressed dds or another 24-bit image
|
||||||
PF_BGR_24, // big-endian RGB (MacOS)
|
PF_BGR_24, // big-endian RGB (MacOS)
|
||||||
|
PF_RGB_332, // 8-bit R3 G3 B2
|
||||||
|
PF_RGB_5650, // 16-bit R5 G6 B5
|
||||||
|
PF_RGBA_5551, // 16-bit R5 G5 B5 A1
|
||||||
|
PF_RGBA_4444, // 16-bit R4 G4 B4 A4
|
||||||
PF_LUMINANCE,
|
PF_LUMINANCE,
|
||||||
PF_DXT1, // s3tc DXT1/BC1 format
|
PF_DXT1, // s3tc DXT1/BC1 format
|
||||||
PF_DXT3, // s3tc DXT3/BC2 format
|
PF_DXT3, // s3tc DXT3/BC2 format
|
||||||
|
|||||||
@@ -127,6 +127,21 @@ typedef struct
|
|||||||
int flags; // sky or slime, no lightmap or 256 subdivision
|
int flags; // sky or slime, no lightmap or 256 subdivision
|
||||||
} mtexinfo_t;
|
} mtexinfo_t;
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
float uv[2];
|
||||||
|
float xyz[3];
|
||||||
|
}gu_vert_t;
|
||||||
|
typedef struct glpoly_s
|
||||||
|
{
|
||||||
|
struct glpoly_s *next;
|
||||||
|
struct glpoly_s *chain;
|
||||||
|
int numverts;
|
||||||
|
int flags; // for SURF_UNDERWATER
|
||||||
|
gu_vert_t verts[1]; // variable sized (xyz s1t1 + lm(xyz s2t2))
|
||||||
|
} glpoly_t;
|
||||||
|
#else
|
||||||
typedef struct glpoly_s
|
typedef struct glpoly_s
|
||||||
{
|
{
|
||||||
struct glpoly_s *next;
|
struct glpoly_s *next;
|
||||||
@@ -135,7 +150,7 @@ typedef struct glpoly_s
|
|||||||
int flags; // for SURF_UNDERWATER
|
int flags; // for SURF_UNDERWATER
|
||||||
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
|
||||||
} glpoly_t;
|
} glpoly_t;
|
||||||
|
#endif
|
||||||
typedef struct mnode_s
|
typedef struct mnode_s
|
||||||
{
|
{
|
||||||
// common with leaf
|
// common with leaf
|
||||||
|
|||||||
@@ -717,6 +717,7 @@ enum
|
|||||||
kRenderFxExplode, // Scale up really big!
|
kRenderFxExplode, // Scale up really big!
|
||||||
kRenderFxGlowShell, // Glowing Shell
|
kRenderFxGlowShell, // Glowing Shell
|
||||||
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
|
kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!)
|
||||||
|
kRenderFxLightMultiplier,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int func_t;
|
typedef int func_t;
|
||||||
|
|||||||
@@ -77,6 +77,30 @@ SETUP BACKENDS DEFINITIONS
|
|||||||
|
|
||||||
// usually only 10-20 fds availiable
|
// usually only 10-20 fds availiable
|
||||||
#define XASH_REDUCE_FD
|
#define XASH_REDUCE_FD
|
||||||
|
#elif XASH_PSP
|
||||||
|
#ifndef XASH_VIDEO
|
||||||
|
#define XASH_VIDEO VIDEO_PSP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XASH_TIMER
|
||||||
|
#define XASH_TIMER TIMER_PSP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XASH_INPUT
|
||||||
|
#define XASH_INPUT INPUT_PSP
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XASH_SOUND
|
||||||
|
#define XASH_SOUND SOUND_PSP
|
||||||
|
#endif // XASH_SOUND
|
||||||
|
|
||||||
|
#ifndef XASH_MESSAGEBOX
|
||||||
|
#define XASH_MESSAGEBOX MSGBOX_PSP
|
||||||
|
#endif // XASH_MESSAGEBOX
|
||||||
|
|
||||||
|
#define XASH_REDUCE_FD
|
||||||
|
#define XASH_NO_TOUCH
|
||||||
|
#define XASH_NO_ZIP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // XASH_DEDICATED
|
#endif // XASH_DEDICATED
|
||||||
@@ -105,7 +129,7 @@ SETUP BACKENDS DEFINITIONS
|
|||||||
#endif // !XASH_WIN32
|
#endif // !XASH_WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XASH_STATIC_LIBS
|
#if defined(XASH_STATIC_LIBS) && !XASH_PSP
|
||||||
#define XASH_LIB LIB_STATIC
|
#define XASH_LIB LIB_STATIC
|
||||||
#define XASH_INTERNAL_GAMELIBS
|
#define XASH_INTERNAL_GAMELIBS
|
||||||
#define XASH_ALLOW_SAVERESTORE_OFFSETS
|
#define XASH_ALLOW_SAVERESTORE_OFFSETS
|
||||||
@@ -113,6 +137,8 @@ SETUP BACKENDS DEFINITIONS
|
|||||||
#define XASH_LIB LIB_WIN32
|
#define XASH_LIB LIB_WIN32
|
||||||
#elif XASH_POSIX
|
#elif XASH_POSIX
|
||||||
#define XASH_LIB LIB_POSIX
|
#define XASH_LIB LIB_POSIX
|
||||||
|
#elif XASH_PSP
|
||||||
|
#define XASH_LIB LIB_PSP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -193,4 +219,20 @@ Default build-depended cvar and constant values
|
|||||||
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
|
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
|
||||||
#endif // DEFAULT_MAX_EDICTS
|
#endif // DEFAULT_MAX_EDICTS
|
||||||
|
|
||||||
|
#ifndef DEFAULT_ACCELERATED_RENDERER
|
||||||
|
#ifdef XASH_PSP
|
||||||
|
#define DEFAULT_ACCELERATED_RENDERER "gu"
|
||||||
|
#else
|
||||||
|
#if XASH_MOBILE_PLATFORM
|
||||||
|
#define DEFAULT_ACCELERATED_RENDERER "gles1"
|
||||||
|
#else // !XASH_MOBILE_PLATFORM
|
||||||
|
#define DEFAULT_ACCELERATED_RENDERER "gl"
|
||||||
|
#endif // !XASH_MOBILE_PLATFORM
|
||||||
|
#endif
|
||||||
|
#endif // DEFAULT_ACCELERATED_RENDERER
|
||||||
|
|
||||||
|
#ifndef DEFAULT_SOFTWARE_RENDERER
|
||||||
|
#define DEFAULT_SOFTWARE_RENDERER "soft" // mittorn's ref_soft
|
||||||
|
#endif // DEFAULT_SOFTWARE_RENDERER
|
||||||
|
|
||||||
#endif // DEFAULTS_H
|
#endif // DEFAULTS_H
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ GNU General Public License for more details.
|
|||||||
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
|
#define ENGINE_COMPUTE_STUDIO_LERP (1<<7) // enable MOVETYPE_STEP lerping back in engine
|
||||||
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
|
#define ENGINE_LINEAR_GAMMA_SPACE (1<<8) // disable influence of gamma/brightness cvars to textures/lightmaps, for mods with custom renderer
|
||||||
|
|
||||||
|
#define ENGINE_STEP_POSHISTORY_LERP (1U<<31) // enable MOVETYPE_STEP interpolation based on position history. Incompatible with ENGINE_COMPUTE_STUDIO_LERP!
|
||||||
|
|
||||||
// adjust the mask when features will be added or removed
|
// adjust the mask when features will be added or removed
|
||||||
#define ENGINE_FEATURES_MASK \
|
#define ENGINE_FEATURES_MASK \
|
||||||
( ENGINE_WRITE_LARGE_COORD \
|
( ENGINE_WRITE_LARGE_COORD \
|
||||||
@@ -37,6 +39,7 @@ GNU General Public License for more details.
|
|||||||
| ENGINE_COMPENSATE_QUAKE_BUG \
|
| ENGINE_COMPENSATE_QUAKE_BUG \
|
||||||
| ENGINE_IMPROVED_LINETRACE \
|
| ENGINE_IMPROVED_LINETRACE \
|
||||||
| ENGINE_COMPUTE_STUDIO_LERP \
|
| ENGINE_COMPUTE_STUDIO_LERP \
|
||||||
| ENGINE_LINEAR_GAMMA_SPACE )
|
| ENGINE_LINEAR_GAMMA_SPACE \
|
||||||
|
| ENGINE_STEP_POSHISTORY_LERP )
|
||||||
|
|
||||||
#endif//FEATURES_H
|
#endif//FEATURES_H
|
||||||
|
|||||||
@@ -1,18 +1,35 @@
|
|||||||
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
/*
|
||||||
//
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================
|
|
||||||
|
|
||||||
#if !defined( KBUTTONH )
|
This program is free software; you can redistribute it and/or
|
||||||
#define KBUTTONH
|
modify it under the terms of the GNU General Public License
|
||||||
#pragma once
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
typedef struct kbutton_s
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
#ifndef KBUTTON_H
|
||||||
|
#define KBUTTON_H
|
||||||
|
|
||||||
|
// a1ba: copied from WinQuake/client.h
|
||||||
|
//
|
||||||
|
// cl_input
|
||||||
|
//
|
||||||
|
typedef struct
|
||||||
{
|
{
|
||||||
int down[2]; // key nums holding it down
|
int down[2]; // key nums holding it down
|
||||||
int state; // low bit is down state
|
int state; // low bit is down state
|
||||||
} kbutton_t;
|
} kbutton_t;
|
||||||
|
|
||||||
#endif // !KBUTTONH
|
STATIC_ASSERT( sizeof( kbutton_t ) == 12, "kbutton_t isn't 12 bytes!" );
|
||||||
|
|
||||||
|
#endif // KBUTTON_H
|
||||||
|
|||||||
106
common/netadr.h
106
common/netadr.h
@@ -1,76 +1,74 @@
|
|||||||
/***
|
/*
|
||||||
*
|
Copyright (C) 1997-2001 Id Software, Inc.
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
#ifndef NETADR_H
|
This program is free software; you can redistribute it and/or
|
||||||
#define NETADR_H
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NET_ADR_H
|
||||||
|
#define NET_ADR_H
|
||||||
|
|
||||||
#include "build.h"
|
|
||||||
#include STDINT_H
|
#include STDINT_H
|
||||||
|
|
||||||
typedef enum
|
// net.h -- quake's interface to the networking layer
|
||||||
{
|
// a1ba: copied from Quake-2/qcommon/qcommon.h and modified to support IPv6
|
||||||
NA_UNUSED = 0,
|
|
||||||
NA_LOOPBACK,
|
|
||||||
NA_BROADCAST,
|
|
||||||
NA_IP,
|
|
||||||
NA_IPX,
|
|
||||||
NA_BROADCAST_IPX,
|
|
||||||
NA_IP6,
|
|
||||||
NA_MULTICAST_IP6, // all nodes multicast
|
|
||||||
} netadrtype_t;
|
|
||||||
|
|
||||||
// Original structure:
|
#define PORT_ANY -1
|
||||||
// typedef struct netadr_s
|
|
||||||
// {
|
typedef enum {NA_LOOPBACK = 1, NA_BROADCAST, NA_IP, NA_IPX, NA_BROADCAST_IPX, NA_IP6, NA_MULTICAST_IP6} netadrtype_t;
|
||||||
// netadrtype_t type;
|
|
||||||
// unsigned char ip[4];
|
/*
|
||||||
// unsigned char ipx[10];
|
Original Quake-2 structure:
|
||||||
// unsigned short port;
|
typedef struct
|
||||||
// } netadr_t;
|
{
|
||||||
|
netadrtype_t type;
|
||||||
|
|
||||||
|
byte ip[4];
|
||||||
|
byte ipx[10];
|
||||||
|
|
||||||
|
unsigned short port;
|
||||||
|
} netadr_t;
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma pack( push, 1 )
|
#pragma pack( push, 1 )
|
||||||
typedef struct netadr_s
|
typedef struct netadr_s
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
// IPv6 struct
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t type;
|
uint16_t type6;
|
||||||
|
uint8_t ip6[16];
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint32_t type; // must be netadrtype_t but will break with short enums
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint8_t ip[4];
|
uint8_t ip[4];
|
||||||
uint32_t ip4;
|
uint32_t ip4; // for easier conversions
|
||||||
};
|
};
|
||||||
uint8_t ipx[10];
|
uint8_t ipx[10];
|
||||||
};
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
#if XASH_LITTLE_ENDIAN
|
|
||||||
uint16_t type6;
|
|
||||||
uint8_t ip6[16];
|
|
||||||
#elif XASH_BIG_ENDIAN
|
|
||||||
uint8_t ip6_0[2];
|
|
||||||
uint16_t type6;
|
|
||||||
uint8_t ip6_2[14];
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
} netadr_t;
|
} netadr_t;
|
||||||
#pragma pack( pop )
|
#pragma pack( pop )
|
||||||
|
|
||||||
STATIC_ASSERT( sizeof( netadr_t ) == 20, "invalid netadr_t size" );
|
STATIC_ASSERT( sizeof( netadr_t ) == 20, "netadr_t isn't 20 bytes!" );
|
||||||
|
|
||||||
#endif//NETADR_H
|
#endif // NET_ADR_H
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ GNU General Public License for more details.
|
|||||||
#include <sys/syslimits.h>
|
#include <sys/syslimits.h>
|
||||||
#define OS_LIB_EXT "dylib"
|
#define OS_LIB_EXT "dylib"
|
||||||
#define OPEN_COMMAND "open"
|
#define OPEN_COMMAND "open"
|
||||||
#else
|
#elif XASH_PSP
|
||||||
|
#define OS_LIB_EXT "prx"
|
||||||
|
#else
|
||||||
#define OS_LIB_EXT "so"
|
#define OS_LIB_EXT "so"
|
||||||
#define OPEN_COMMAND "xdg-open"
|
#define OPEN_COMMAND "xdg-open"
|
||||||
#endif
|
#endif
|
||||||
@@ -55,6 +57,16 @@ GNU General Public License for more details.
|
|||||||
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pspiofilemgr.h>
|
||||||
|
|
||||||
|
#define O_BINARY 0
|
||||||
|
#define O_TEXT 0
|
||||||
|
|
||||||
|
#define _mkdir( x ) sceIoMkdir( x, FIO_S_IRWXU | FIO_S_IRWXG | FIO_S_IROTH | FIO_S_IXOTH )
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void* HANDLE;
|
typedef void* HANDLE;
|
||||||
typedef void* HINSTANCE;
|
typedef void* HINSTANCE;
|
||||||
|
|
||||||
|
|||||||
@@ -101,8 +101,13 @@ typedef enum
|
|||||||
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
|
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
|
||||||
TF_ATLAS_PAGE = (1<<21), // bit who indicate lightmap page or deluxemap page
|
TF_ATLAS_PAGE = (1<<21), // bit who indicate lightmap page or deluxemap page
|
||||||
TF_ALPHACONTRAST = (1<<22), // special texture mode for A2C
|
TF_ALPHACONTRAST = (1<<22), // special texture mode for A2C
|
||||||
|
#if XASH_PSP
|
||||||
|
TF_IMG_SWIZZLED = (1<<23),
|
||||||
|
TF_IMG_INVRAM = (1<<24),
|
||||||
|
#else
|
||||||
// reserved
|
// reserved
|
||||||
// reserved
|
// reserved
|
||||||
|
#endif
|
||||||
TF_IMG_UPLOADED = (1<<25), // this is set for first time when called glTexImage, otherwise it will be call glTexSubImage
|
TF_IMG_UPLOADED = (1<<25), // this is set for first time when called glTexImage, otherwise it will be call glTexSubImage
|
||||||
TF_ARB_FLOAT = (1<<26), // float textures
|
TF_ARB_FLOAT = (1<<26), // float textures
|
||||||
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
|
TF_NOCOMPARE = (1<<27), // disable comparing for depth textures
|
||||||
|
|||||||
@@ -21,12 +21,22 @@ typedef int sound_t;
|
|||||||
typedef float vec_t;
|
typedef float vec_t;
|
||||||
typedef vec_t vec2_t[2];
|
typedef vec_t vec2_t[2];
|
||||||
typedef vec_t vec3_t[3];
|
typedef vec_t vec3_t[3];
|
||||||
|
#if XASH_PSP
|
||||||
|
typedef vec_t vec4_t[4] __attribute__( ( aligned( 16 ) ) );
|
||||||
|
typedef vec_t quat_t[4] __attribute__( ( aligned( 16 ) ) );
|
||||||
|
#else
|
||||||
typedef vec_t vec4_t[4];
|
typedef vec_t vec4_t[4];
|
||||||
typedef vec_t quat_t[4];
|
typedef vec_t quat_t[4];
|
||||||
|
#endif
|
||||||
typedef byte rgba_t[4]; // unsigned byte colorpack
|
typedef byte rgba_t[4]; // unsigned byte colorpack
|
||||||
typedef byte rgb_t[3]; // unsigned byte colorpack
|
typedef byte rgb_t[3]; // unsigned byte colorpack
|
||||||
|
#if XASH_PSP
|
||||||
|
typedef vec_t matrix3x4[3][4] __attribute__( ( aligned( 16 ) ) );
|
||||||
|
typedef vec_t matrix4x4[4][4] __attribute__( ( aligned( 16 ) ) );
|
||||||
|
#else
|
||||||
typedef vec_t matrix3x4[3][4];
|
typedef vec_t matrix3x4[3][4];
|
||||||
typedef vec_t matrix4x4[4][4];
|
typedef vec_t matrix4x4[4][4];
|
||||||
|
#endif
|
||||||
|
|
||||||
#if XASH_64BIT
|
#if XASH_64BIT
|
||||||
typedef uint32_t poolhandle_t;
|
typedef uint32_t poolhandle_t;
|
||||||
@@ -58,9 +68,6 @@ typedef uint64_t longtime_t;
|
|||||||
|
|
||||||
#define BIT( n ) ( 1U << ( n ))
|
#define BIT( n ) ( 1U << ( n ))
|
||||||
#define BIT64( n ) ( 1ULL << ( n ))
|
#define BIT64( n ) ( 1ULL << ( n ))
|
||||||
#define GAMMA ( 2.2f ) // Valve Software gamma
|
|
||||||
#define INVGAMMA ( 1.0f / 2.2f ) // back to 1.0
|
|
||||||
#define TEXGAMMA ( 0.9f ) // compensate dim textures
|
|
||||||
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
|
#define SetBits( iBitVector, bits ) ((iBitVector) = (iBitVector) | (bits))
|
||||||
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
|
#define ClearBits( iBitVector, bits ) ((iBitVector) = (iBitVector) & ~(bits))
|
||||||
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
|
#define FBitSet( iBitVector, bit ) ((iBitVector) & (bit))
|
||||||
@@ -121,15 +128,18 @@ typedef uint64_t longtime_t;
|
|||||||
#define likely(x) (x)
|
#define likely(x) (x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __STDC_VERSION >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
|
#if __STDC_VERSION__ >= 202311L || __cplusplus >= 201103L // C23 or C++ static_assert is a keyword
|
||||||
#define STATIC_ASSERT_ static_assert
|
#define STATIC_ASSERT_( ignore, x, y ) static_assert( x, y )
|
||||||
#define STATIC_ASSERT static_assert
|
#define STATIC_ASSERT static_assert
|
||||||
#elif __STDC_VERSION >= 201112L // in C11 it's _Static_assert
|
#elif __STDC_VERSION__ >= 201112L // in C11 it's _Static_assert
|
||||||
#define STATIC_ASSERT_ _Static_assert
|
#define STATIC_ASSERT_( ignore, x, y ) _Static_assert( x, y )
|
||||||
#define STATIC_ASSERT _Static_assert
|
#define STATIC_ASSERT _Static_assert
|
||||||
#else
|
#else
|
||||||
#define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
|
#define STATIC_ASSERT_( id, x, y ) extern int id[( x ) ? 1 : -1]
|
||||||
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_( static_assert_##__LINE__, x, y )
|
// need these to correctly expand the line macro
|
||||||
|
#define STATIC_ASSERT_3( line, x, y ) STATIC_ASSERT_( static_assert_ ## line, x, y )
|
||||||
|
#define STATIC_ASSERT_2( line, x, y ) STATIC_ASSERT_3( line, x, y )
|
||||||
|
#define STATIC_ASSERT( x, y ) STATIC_ASSERT_2( __LINE__, x, y )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef XASH_BIG_ENDIAN
|
#ifdef XASH_BIG_ENDIAN
|
||||||
@@ -194,6 +204,9 @@ typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
|||||||
// config strings are a general means of communication from
|
// config strings are a general means of communication from
|
||||||
// the server to all connected clients.
|
// the server to all connected clients.
|
||||||
// each config string can be at most CS_SIZE characters.
|
// each config string can be at most CS_SIZE characters.
|
||||||
|
#if XASH_PSP
|
||||||
|
#define MAX_QPATH 48
|
||||||
|
#else
|
||||||
#if XASH_LOW_MEMORY == 0
|
#if XASH_LOW_MEMORY == 0
|
||||||
#define MAX_QPATH 64 // max length of a game pathname
|
#define MAX_QPATH 64 // max length of a game pathname
|
||||||
#elif XASH_LOW_MEMORY == 2
|
#elif XASH_LOW_MEMORY == 2
|
||||||
@@ -201,6 +214,7 @@ typedef void *(*pfnCreateInterface_t)( const char *, int * );
|
|||||||
#elif XASH_LOW_MEMORY == 1
|
#elif XASH_LOW_MEMORY == 1
|
||||||
#define MAX_QPATH 48
|
#define MAX_QPATH 48
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#define MAX_OSPATH 260 // max length of a filesystem pathname
|
#define MAX_OSPATH 260 // max length of a filesystem pathname
|
||||||
#define CS_SIZE 64 // size of one config string
|
#define CS_SIZE 64 // size of one config string
|
||||||
#define CS_TIME 16 // size of time string
|
#define CS_TIME 16 // size of time string
|
||||||
|
|||||||
356
engine/anorms.h
356
engine/anorms.h
@@ -1,177 +1,181 @@
|
|||||||
/***
|
/*
|
||||||
*
|
Copyright (C) 1996-1997 Id Software, Inc.
|
||||||
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
|
||||||
*
|
|
||||||
* This product contains software technology licensed from Id
|
|
||||||
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use, distribution, and modification of this source code and/or resulting
|
|
||||||
* object code is restricted to non-commercial enhancements to products from
|
|
||||||
* Valve LLC. All other use, distribution, or modification is prohibited
|
|
||||||
* without written permission from Valve LLC.
|
|
||||||
*
|
|
||||||
****/
|
|
||||||
|
|
||||||
{-0.525731, 0.000000, 0.850651},
|
This program is free software; you can redistribute it and/or
|
||||||
{-0.442863, 0.238856, 0.864188},
|
modify it under the terms of the GNU General Public License
|
||||||
{-0.295242, 0.000000, 0.955423},
|
as published by the Free Software Foundation; either version 2
|
||||||
{-0.309017, 0.500000, 0.809017},
|
of the License, or (at your option) any later version.
|
||||||
{-0.162460, 0.262866, 0.951056},
|
|
||||||
{0.000000, 0.000000, 1.000000},
|
This program is distributed in the hope that it will be useful,
|
||||||
{0.000000, 0.850651, 0.525731},
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
{-0.147621, 0.716567, 0.681718},
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
{0.147621, 0.716567, 0.681718},
|
|
||||||
{0.000000, 0.525731, 0.850651},
|
See the GNU General Public License for more details.
|
||||||
{0.309017, 0.500000, 0.809017},
|
|
||||||
{0.525731, 0.000000, 0.850651},
|
You should have received a copy of the GNU General Public License
|
||||||
{0.295242, 0.000000, 0.955423},
|
along with this program; if not, write to the Free Software
|
||||||
{0.442863, 0.238856, 0.864188},
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
{0.162460, 0.262866, 0.951056},
|
|
||||||
{-0.681718, 0.147621, 0.716567},
|
*/
|
||||||
{-0.809017, 0.309017, 0.500000},
|
{-0.525731, 0.000000, 0.850651},
|
||||||
{-0.587785, 0.425325, 0.688191},
|
{-0.442863, 0.238856, 0.864188},
|
||||||
{-0.850651, 0.525731, 0.000000},
|
{-0.295242, 0.000000, 0.955423},
|
||||||
{-0.864188, 0.442863, 0.238856},
|
{-0.309017, 0.500000, 0.809017},
|
||||||
{-0.716567, 0.681718, 0.147621},
|
{-0.162460, 0.262866, 0.951056},
|
||||||
{-0.688191, 0.587785, 0.425325},
|
{0.000000, 0.000000, 1.000000},
|
||||||
{-0.500000, 0.809017, 0.309017},
|
{0.000000, 0.850651, 0.525731},
|
||||||
{-0.238856, 0.864188, 0.442863},
|
{-0.147621, 0.716567, 0.681718},
|
||||||
{-0.425325, 0.688191, 0.587785},
|
{0.147621, 0.716567, 0.681718},
|
||||||
{-0.716567, 0.681718, -0.147621},
|
{0.000000, 0.525731, 0.850651},
|
||||||
{-0.500000, 0.809017, -0.309017},
|
{0.309017, 0.500000, 0.809017},
|
||||||
{-0.525731, 0.850651, 0.000000},
|
{0.525731, 0.000000, 0.850651},
|
||||||
{0.000000, 0.850651, -0.525731},
|
{0.295242, 0.000000, 0.955423},
|
||||||
{-0.238856, 0.864188, -0.442863},
|
{0.442863, 0.238856, 0.864188},
|
||||||
{0.000000, 0.955423, -0.295242},
|
{0.162460, 0.262866, 0.951056},
|
||||||
{-0.262866, 0.951056, -0.162460},
|
{-0.681718, 0.147621, 0.716567},
|
||||||
{0.000000, 1.000000, 0.000000},
|
{-0.809017, 0.309017, 0.500000},
|
||||||
{0.000000, 0.955423, 0.295242},
|
{-0.587785, 0.425325, 0.688191},
|
||||||
{-0.262866, 0.951056, 0.162460},
|
{-0.850651, 0.525731, 0.000000},
|
||||||
{0.238856, 0.864188, 0.442863},
|
{-0.864188, 0.442863, 0.238856},
|
||||||
{0.262866, 0.951056, 0.162460},
|
{-0.716567, 0.681718, 0.147621},
|
||||||
{0.500000, 0.809017, 0.309017},
|
{-0.688191, 0.587785, 0.425325},
|
||||||
{0.238856, 0.864188, -0.442863},
|
{-0.500000, 0.809017, 0.309017},
|
||||||
{0.262866, 0.951056, -0.162460},
|
{-0.238856, 0.864188, 0.442863},
|
||||||
{0.500000, 0.809017, -0.309017},
|
{-0.425325, 0.688191, 0.587785},
|
||||||
{0.850651, 0.525731, 0.000000},
|
{-0.716567, 0.681718, -0.147621},
|
||||||
{0.716567, 0.681718, 0.147621},
|
{-0.500000, 0.809017, -0.309017},
|
||||||
{0.716567, 0.681718, -0.147621},
|
{-0.525731, 0.850651, 0.000000},
|
||||||
{0.525731, 0.850651, 0.000000},
|
{0.000000, 0.850651, -0.525731},
|
||||||
{0.425325, 0.688191, 0.587785},
|
{-0.238856, 0.864188, -0.442863},
|
||||||
{0.864188, 0.442863, 0.238856},
|
{0.000000, 0.955423, -0.295242},
|
||||||
{0.688191, 0.587785, 0.425325},
|
{-0.262866, 0.951056, -0.162460},
|
||||||
{0.809017, 0.309017, 0.500000},
|
{0.000000, 1.000000, 0.000000},
|
||||||
{0.681718, 0.147621, 0.716567},
|
{0.000000, 0.955423, 0.295242},
|
||||||
{0.587785, 0.425325, 0.688191},
|
{-0.262866, 0.951056, 0.162460},
|
||||||
{0.955423, 0.295242, 0.000000},
|
{0.238856, 0.864188, 0.442863},
|
||||||
{1.000000, 0.000000, 0.000000},
|
{0.262866, 0.951056, 0.162460},
|
||||||
{0.951056, 0.162460, 0.262866},
|
{0.500000, 0.809017, 0.309017},
|
||||||
{0.850651, -0.525731, 0.000000},
|
{0.238856, 0.864188, -0.442863},
|
||||||
{0.955423, -0.295242, 0.000000},
|
{0.262866, 0.951056, -0.162460},
|
||||||
{0.864188, -0.442863, 0.238856},
|
{0.500000, 0.809017, -0.309017},
|
||||||
{0.951056, -0.162460, 0.262866},
|
{0.850651, 0.525731, 0.000000},
|
||||||
{0.809017, -0.309017, 0.500000},
|
{0.716567, 0.681718, 0.147621},
|
||||||
{0.681718, -0.147621, 0.716567},
|
{0.716567, 0.681718, -0.147621},
|
||||||
{0.850651, 0.000000, 0.525731},
|
{0.525731, 0.850651, 0.000000},
|
||||||
{0.864188, 0.442863, -0.238856},
|
{0.425325, 0.688191, 0.587785},
|
||||||
{0.809017, 0.309017, -0.500000},
|
{0.864188, 0.442863, 0.238856},
|
||||||
{0.951056, 0.162460, -0.262866},
|
{0.688191, 0.587785, 0.425325},
|
||||||
{0.525731, 0.000000, -0.850651},
|
{0.809017, 0.309017, 0.500000},
|
||||||
{0.681718, 0.147621, -0.716567},
|
{0.681718, 0.147621, 0.716567},
|
||||||
{0.681718, -0.147621, -0.716567},
|
{0.587785, 0.425325, 0.688191},
|
||||||
{0.850651, 0.000000, -0.525731},
|
{0.955423, 0.295242, 0.000000},
|
||||||
{0.809017, -0.309017, -0.500000},
|
{1.000000, 0.000000, 0.000000},
|
||||||
{0.864188, -0.442863, -0.238856},
|
{0.951056, 0.162460, 0.262866},
|
||||||
{0.951056, -0.162460, -0.262866},
|
{0.850651, -0.525731, 0.000000},
|
||||||
{0.147621, 0.716567, -0.681718},
|
{0.955423, -0.295242, 0.000000},
|
||||||
{0.309017, 0.500000, -0.809017},
|
{0.864188, -0.442863, 0.238856},
|
||||||
{0.425325, 0.688191, -0.587785},
|
{0.951056, -0.162460, 0.262866},
|
||||||
{0.442863, 0.238856, -0.864188},
|
{0.809017, -0.309017, 0.500000},
|
||||||
{0.587785, 0.425325, -0.688191},
|
{0.681718, -0.147621, 0.716567},
|
||||||
{0.688191, 0.587785, -0.425325},
|
{0.850651, 0.000000, 0.525731},
|
||||||
{-0.147621, 0.716567, -0.681718},
|
{0.864188, 0.442863, -0.238856},
|
||||||
{-0.309017, 0.500000, -0.809017},
|
{0.809017, 0.309017, -0.500000},
|
||||||
{0.000000, 0.525731, -0.850651},
|
{0.951056, 0.162460, -0.262866},
|
||||||
{-0.525731, 0.000000, -0.850651},
|
{0.525731, 0.000000, -0.850651},
|
||||||
{-0.442863, 0.238856, -0.864188},
|
{0.681718, 0.147621, -0.716567},
|
||||||
{-0.295242, 0.000000, -0.955423},
|
{0.681718, -0.147621, -0.716567},
|
||||||
{-0.162460, 0.262866, -0.951056},
|
{0.850651, 0.000000, -0.525731},
|
||||||
{0.000000, 0.000000, -1.000000},
|
{0.809017, -0.309017, -0.500000},
|
||||||
{0.295242, 0.000000, -0.955423},
|
{0.864188, -0.442863, -0.238856},
|
||||||
{0.162460, 0.262866, -0.951056},
|
{0.951056, -0.162460, -0.262866},
|
||||||
{-0.442863, -0.238856, -0.864188},
|
{0.147621, 0.716567, -0.681718},
|
||||||
{-0.309017, -0.500000, -0.809017},
|
{0.309017, 0.500000, -0.809017},
|
||||||
{-0.162460, -0.262866, -0.951056},
|
{0.425325, 0.688191, -0.587785},
|
||||||
{0.000000, -0.850651, -0.525731},
|
{0.442863, 0.238856, -0.864188},
|
||||||
{-0.147621, -0.716567, -0.681718},
|
{0.587785, 0.425325, -0.688191},
|
||||||
{0.147621, -0.716567, -0.681718},
|
{0.688191, 0.587785, -0.425325},
|
||||||
{0.000000, -0.525731, -0.850651},
|
{-0.147621, 0.716567, -0.681718},
|
||||||
{0.309017, -0.500000, -0.809017},
|
{-0.309017, 0.500000, -0.809017},
|
||||||
{0.442863, -0.238856, -0.864188},
|
{0.000000, 0.525731, -0.850651},
|
||||||
{0.162460, -0.262866, -0.951056},
|
{-0.525731, 0.000000, -0.850651},
|
||||||
{0.238856, -0.864188, -0.442863},
|
{-0.442863, 0.238856, -0.864188},
|
||||||
{0.500000, -0.809017, -0.309017},
|
{-0.295242, 0.000000, -0.955423},
|
||||||
{0.425325, -0.688191, -0.587785},
|
{-0.162460, 0.262866, -0.951056},
|
||||||
{0.716567, -0.681718, -0.147621},
|
{0.000000, 0.000000, -1.000000},
|
||||||
{0.688191, -0.587785, -0.425325},
|
{0.295242, 0.000000, -0.955423},
|
||||||
{0.587785, -0.425325, -0.688191},
|
{0.162460, 0.262866, -0.951056},
|
||||||
{0.000000, -0.955423, -0.295242},
|
{-0.442863, -0.238856, -0.864188},
|
||||||
{0.000000, -1.000000, 0.000000},
|
{-0.309017, -0.500000, -0.809017},
|
||||||
{0.262866, -0.951056, -0.162460},
|
{-0.162460, -0.262866, -0.951056},
|
||||||
{0.000000, -0.850651, 0.525731},
|
{0.000000, -0.850651, -0.525731},
|
||||||
{0.000000, -0.955423, 0.295242},
|
{-0.147621, -0.716567, -0.681718},
|
||||||
{0.238856, -0.864188, 0.442863},
|
{0.147621, -0.716567, -0.681718},
|
||||||
{0.262866, -0.951056, 0.162460},
|
{0.000000, -0.525731, -0.850651},
|
||||||
{0.500000, -0.809017, 0.309017},
|
{0.309017, -0.500000, -0.809017},
|
||||||
{0.716567, -0.681718, 0.147621},
|
{0.442863, -0.238856, -0.864188},
|
||||||
{0.525731, -0.850651, 0.000000},
|
{0.162460, -0.262866, -0.951056},
|
||||||
{-0.238856, -0.864188, -0.442863},
|
{0.238856, -0.864188, -0.442863},
|
||||||
{-0.500000, -0.809017, -0.309017},
|
{0.500000, -0.809017, -0.309017},
|
||||||
{-0.262866, -0.951056, -0.162460},
|
{0.425325, -0.688191, -0.587785},
|
||||||
{-0.850651, -0.525731, 0.000000},
|
{0.716567, -0.681718, -0.147621},
|
||||||
{-0.716567, -0.681718, -0.147621},
|
{0.688191, -0.587785, -0.425325},
|
||||||
{-0.716567, -0.681718, 0.147621},
|
{0.587785, -0.425325, -0.688191},
|
||||||
{-0.525731, -0.850651, 0.000000},
|
{0.000000, -0.955423, -0.295242},
|
||||||
{-0.500000, -0.809017, 0.309017},
|
{0.000000, -1.000000, 0.000000},
|
||||||
{-0.238856, -0.864188, 0.442863},
|
{0.262866, -0.951056, -0.162460},
|
||||||
{-0.262866, -0.951056, 0.162460},
|
{0.000000, -0.850651, 0.525731},
|
||||||
{-0.864188, -0.442863, 0.238856},
|
{0.000000, -0.955423, 0.295242},
|
||||||
{-0.809017, -0.309017, 0.500000},
|
{0.238856, -0.864188, 0.442863},
|
||||||
{-0.688191, -0.587785, 0.425325},
|
{0.262866, -0.951056, 0.162460},
|
||||||
{-0.681718, -0.147621, 0.716567},
|
{0.500000, -0.809017, 0.309017},
|
||||||
{-0.442863, -0.238856, 0.864188},
|
{0.716567, -0.681718, 0.147621},
|
||||||
{-0.587785, -0.425325, 0.688191},
|
{0.525731, -0.850651, 0.000000},
|
||||||
{-0.309017, -0.500000, 0.809017},
|
{-0.238856, -0.864188, -0.442863},
|
||||||
{-0.147621, -0.716567, 0.681718},
|
{-0.500000, -0.809017, -0.309017},
|
||||||
{-0.425325, -0.688191, 0.587785},
|
{-0.262866, -0.951056, -0.162460},
|
||||||
{-0.162460, -0.262866, 0.951056},
|
{-0.850651, -0.525731, 0.000000},
|
||||||
{0.442863, -0.238856, 0.864188},
|
{-0.716567, -0.681718, -0.147621},
|
||||||
{0.162460, -0.262866, 0.951056},
|
{-0.716567, -0.681718, 0.147621},
|
||||||
{0.309017, -0.500000, 0.809017},
|
{-0.525731, -0.850651, 0.000000},
|
||||||
{0.147621, -0.716567, 0.681718},
|
{-0.500000, -0.809017, 0.309017},
|
||||||
{0.000000, -0.525731, 0.850651},
|
{-0.238856, -0.864188, 0.442863},
|
||||||
{0.425325, -0.688191, 0.587785},
|
{-0.262866, -0.951056, 0.162460},
|
||||||
{0.587785, -0.425325, 0.688191},
|
{-0.864188, -0.442863, 0.238856},
|
||||||
{0.688191, -0.587785, 0.425325},
|
{-0.809017, -0.309017, 0.500000},
|
||||||
{-0.955423, 0.295242, 0.000000},
|
{-0.688191, -0.587785, 0.425325},
|
||||||
{-0.951056, 0.162460, 0.262866},
|
{-0.681718, -0.147621, 0.716567},
|
||||||
{-1.000000, 0.000000, 0.000000},
|
{-0.442863, -0.238856, 0.864188},
|
||||||
{-0.850651, 0.000000, 0.525731},
|
{-0.587785, -0.425325, 0.688191},
|
||||||
{-0.955423, -0.295242, 0.000000},
|
{-0.309017, -0.500000, 0.809017},
|
||||||
{-0.951056, -0.162460, 0.262866},
|
{-0.147621, -0.716567, 0.681718},
|
||||||
{-0.864188, 0.442863, -0.238856},
|
{-0.425325, -0.688191, 0.587785},
|
||||||
{-0.951056, 0.162460, -0.262866},
|
{-0.162460, -0.262866, 0.951056},
|
||||||
{-0.809017, 0.309017, -0.500000},
|
{0.442863, -0.238856, 0.864188},
|
||||||
{-0.864188, -0.442863, -0.238856},
|
{0.162460, -0.262866, 0.951056},
|
||||||
{-0.951056, -0.162460, -0.262866},
|
{0.309017, -0.500000, 0.809017},
|
||||||
{-0.809017, -0.309017, -0.500000},
|
{0.147621, -0.716567, 0.681718},
|
||||||
{-0.681718, 0.147621, -0.716567},
|
{0.000000, -0.525731, 0.850651},
|
||||||
{-0.681718, -0.147621, -0.716567},
|
{0.425325, -0.688191, 0.587785},
|
||||||
{-0.850651, 0.000000, -0.525731},
|
{0.587785, -0.425325, 0.688191},
|
||||||
{-0.688191, 0.587785, -0.425325},
|
{0.688191, -0.587785, 0.425325},
|
||||||
{-0.587785, 0.425325, -0.688191},
|
{-0.955423, 0.295242, 0.000000},
|
||||||
{-0.425325, 0.688191, -0.587785},
|
{-0.951056, 0.162460, 0.262866},
|
||||||
{-0.425325, -0.688191, -0.587785},
|
{-1.000000, 0.000000, 0.000000},
|
||||||
{-0.587785, -0.425325, -0.688191},
|
{-0.850651, 0.000000, 0.525731},
|
||||||
{-0.688191, -0.587785, -0.425325},
|
{-0.955423, -0.295242, 0.000000},
|
||||||
|
{-0.951056, -0.162460, 0.262866},
|
||||||
|
{-0.864188, 0.442863, -0.238856},
|
||||||
|
{-0.951056, 0.162460, -0.262866},
|
||||||
|
{-0.809017, 0.309017, -0.500000},
|
||||||
|
{-0.864188, -0.442863, -0.238856},
|
||||||
|
{-0.951056, -0.162460, -0.262866},
|
||||||
|
{-0.809017, -0.309017, -0.500000},
|
||||||
|
{-0.681718, 0.147621, -0.716567},
|
||||||
|
{-0.681718, -0.147621, -0.716567},
|
||||||
|
{-0.850651, 0.000000, -0.525731},
|
||||||
|
{-0.688191, 0.587785, -0.425325},
|
||||||
|
{-0.587785, 0.425325, -0.688191},
|
||||||
|
{-0.425325, 0.688191, -0.587785},
|
||||||
|
{-0.425325, -0.688191, -0.587785},
|
||||||
|
{-0.587785, -0.425325, -0.688191},
|
||||||
|
{-0.688191, -0.587785, -0.425325},
|
||||||
|
|||||||
@@ -570,6 +570,9 @@ void CL_ReadDemoUserCmd( qboolean discard )
|
|||||||
memset( &nullcmd, 0, sizeof( nullcmd ));
|
memset( &nullcmd, 0, sizeof( nullcmd ));
|
||||||
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
|
MSG_Init( &buf, "UserCmd", data, sizeof( data ));
|
||||||
|
|
||||||
|
// a1ba: I have no proper explanation why
|
||||||
|
cmdnumber++;
|
||||||
|
|
||||||
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
|
pcmd = &cl.commands[cmdnumber & CL_UPDATE_MASK];
|
||||||
pcmd->processedfuncs = false;
|
pcmd->processedfuncs = false;
|
||||||
pcmd->senttime = 0.0f;
|
pcmd->senttime = 0.0f;
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float )
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// never alloc particles when we not in game
|
// never alloc particles when we not in game
|
||||||
// if( tr.frametime == 0.0 ) return NULL;
|
if( cl_clientframetime() == 0.0 ) return NULL;
|
||||||
|
|
||||||
if( !cl_free_particles )
|
if( !cl_free_particles )
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,7 @@ particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life )
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// never alloc particles when we not in game
|
// never alloc particles when we not in game
|
||||||
//if( tr.frametime == 0.0 ) return NULL;
|
if( cl_clientframetime() == 0.0 ) return NULL;
|
||||||
|
|
||||||
if( !cl_free_particles )
|
if( !cl_free_particles )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,19 +24,7 @@ GNU General Public License for more details.
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
|
||||||
#define STUDIO_INTERPOLATION_FIX
|
// #define STUDIO_INTERPOLATION_FIX
|
||||||
|
|
||||||
/*
|
|
||||||
==================
|
|
||||||
CL_IsPlayerIndex
|
|
||||||
|
|
||||||
detect player entity
|
|
||||||
==================
|
|
||||||
*/
|
|
||||||
qboolean CL_IsPlayerIndex( int idx )
|
|
||||||
{
|
|
||||||
return ( idx >= 1 && idx <= cl.maxclients );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=========================================================================
|
=========================================================================
|
||||||
@@ -54,17 +42,28 @@ Store another position into interpolation circular buffer
|
|||||||
*/
|
*/
|
||||||
void CL_UpdatePositions( cl_entity_t *ent )
|
void CL_UpdatePositions( cl_entity_t *ent )
|
||||||
{
|
{
|
||||||
position_history_t *ph;
|
position_history_t *ph, *prev;
|
||||||
|
|
||||||
|
prev = &ent->ph[ent->current_position];
|
||||||
|
|
||||||
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
|
ent->current_position = (ent->current_position + 1) & HISTORY_MASK;
|
||||||
ph = &ent->ph[ent->current_position];
|
ph = &ent->ph[ent->current_position];
|
||||||
VectorCopy( ent->curstate.origin, ph->origin );
|
VectorCopy( ent->curstate.origin, ph->origin );
|
||||||
VectorCopy( ent->curstate.angles, ph->angles );
|
VectorCopy( ent->curstate.angles, ph->angles );
|
||||||
|
|
||||||
if( ent->model && ent->model->type == mod_brush )
|
ph->animtime = ent->curstate.animtime;
|
||||||
ph->animtime = ent->curstate.animtime;
|
|
||||||
else
|
// a1ba: for some reason, this sometimes still may happen
|
||||||
ph->animtime = cl.time;
|
// at this time, I'm not sure whether this bug happens in delta readwrite code
|
||||||
|
// or server just decides to go backwards and really sends these values
|
||||||
|
if( ph->animtime < prev->animtime )
|
||||||
|
{
|
||||||
|
// try to deduce real animtime by looking up the difference between
|
||||||
|
// server messages (cl.mtime is never modified ny the interpolation code)
|
||||||
|
float diff = Q_max( 0, ent->curstate.msg_time - ent->prevstate.msg_time );
|
||||||
|
|
||||||
|
ph->animtime = prev->animtime + diff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -159,6 +158,13 @@ qboolean CL_EntityCustomLerp( cl_entity_t *e )
|
|||||||
case MOVETYPE_FLY:
|
case MOVETYPE_FLY:
|
||||||
case MOVETYPE_COMPOUND:
|
case MOVETYPE_COMPOUND:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
|
||||||
|
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||||
|
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||||
|
case MOVETYPE_TOSS:
|
||||||
|
if( cls.legacymode && e->model && e->model->type == mod_studio )
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -171,7 +177,7 @@ CL_ParametricMove
|
|||||||
check for parametrical moved entities
|
check for parametrical moved entities
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
qboolean CL_ParametricMove( cl_entity_t *ent )
|
static qboolean CL_ParametricMove( cl_entity_t *ent )
|
||||||
{
|
{
|
||||||
float frac, dt, t;
|
float frac, dt, t;
|
||||||
vec3_t delta;
|
vec3_t delta;
|
||||||
@@ -349,11 +355,10 @@ CL_FindInterpolationUpdates
|
|||||||
find two timestamps
|
find two timestamps
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, position_history_t **ph0, position_history_t **ph1 )
|
static qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, double targettime, position_history_t **ph0, position_history_t **ph1 )
|
||||||
{
|
{
|
||||||
qboolean extrapolate = true;
|
qboolean extrapolate = true;
|
||||||
uint i, i0, i1, imod;
|
uint i, i0, i1, imod;
|
||||||
float at;
|
|
||||||
|
|
||||||
imod = ent->current_position;
|
imod = ent->current_position;
|
||||||
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
|
i0 = (imod - 0) & HISTORY_MASK; // curpos (lerp end)
|
||||||
@@ -361,8 +366,10 @@ qboolean CL_FindInterpolationUpdates( cl_entity_t *ent, float targettime, positi
|
|||||||
|
|
||||||
for( i = 1; i < HISTORY_MAX - 1; i++ )
|
for( i = 1; i < HISTORY_MAX - 1; i++ )
|
||||||
{
|
{
|
||||||
at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
|
double at = ent->ph[( imod - i ) & HISTORY_MASK].animtime;
|
||||||
if( at == 0.0f ) break;
|
|
||||||
|
if( at == 0.0f )
|
||||||
|
break;
|
||||||
|
|
||||||
if( targettime > at )
|
if( targettime > at )
|
||||||
{
|
{
|
||||||
@@ -387,15 +394,14 @@ CL_PureOrigin
|
|||||||
non-local players interpolation
|
non-local players interpolation
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangles )
|
static void CL_PureOrigin( cl_entity_t *ent, double t, vec3_t outorigin, vec3_t outangles )
|
||||||
{
|
{
|
||||||
qboolean extrapolate;
|
double t1, t0, frac;
|
||||||
float t1, t0, frac;
|
|
||||||
position_history_t *ph0, *ph1;
|
position_history_t *ph0, *ph1;
|
||||||
vec3_t delta;
|
vec3_t delta;
|
||||||
|
|
||||||
// NOTE: ph0 is next, ph1 is a prev
|
// NOTE: ph0 is next, ph1 is a prev
|
||||||
extrapolate = CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
|
CL_FindInterpolationUpdates( ent, t, &ph0, &ph1 );
|
||||||
|
|
||||||
if ( !ph0 || !ph1 )
|
if ( !ph0 || !ph1 )
|
||||||
return;
|
return;
|
||||||
@@ -403,7 +409,7 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
|
|||||||
t0 = ph0->animtime;
|
t0 = ph0->animtime;
|
||||||
t1 = ph1->animtime;
|
t1 = ph1->animtime;
|
||||||
|
|
||||||
if( t0 != 0.0f )
|
if( t0 != 0.0 )
|
||||||
{
|
{
|
||||||
vec4_t q, q1, q2;
|
vec4_t q, q1, q2;
|
||||||
|
|
||||||
@@ -411,9 +417,9 @@ void CL_PureOrigin( cl_entity_t *ent, float t, vec3_t outorigin, vec3_t outangle
|
|||||||
|
|
||||||
if( !Q_equal( t0, t1 ))
|
if( !Q_equal( t0, t1 ))
|
||||||
frac = ( t - t1 ) / ( t0 - t1 );
|
frac = ( t - t1 ) / ( t0 - t1 );
|
||||||
else frac = 1.0f;
|
else frac = 1.0;
|
||||||
|
|
||||||
frac = bound( 0.0f, frac, 1.2f );
|
frac = bound( 0.0, frac, 1.2 );
|
||||||
|
|
||||||
VectorMA( ph1->origin, frac, delta, outorigin );
|
VectorMA( ph1->origin, frac, delta, outorigin );
|
||||||
|
|
||||||
@@ -437,11 +443,11 @@ CL_InterpolateModel
|
|||||||
non-players interpolation
|
non-players interpolation
|
||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
int CL_InterpolateModel( cl_entity_t *e )
|
static int CL_InterpolateModel( cl_entity_t *e )
|
||||||
{
|
{
|
||||||
position_history_t *ph0 = NULL, *ph1 = NULL;
|
position_history_t *ph0 = NULL, *ph1 = NULL;
|
||||||
vec3_t origin, angles, delta;
|
vec3_t origin, angles, delta;
|
||||||
float t, t1, t2, frac;
|
double t, t1, t2, frac;
|
||||||
vec4_t q, q1, q2;
|
vec4_t q, q1, q2;
|
||||||
|
|
||||||
VectorCopy( e->curstate.origin, e->origin );
|
VectorCopy( e->curstate.origin, e->origin );
|
||||||
@@ -489,9 +495,7 @@ int CL_InterpolateModel( cl_entity_t *e )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACKHACK: workaround buggy position history animtime
|
if( Q_equal( t2, t1 ))
|
||||||
// going backward sometimes
|
|
||||||
if( Q_equal( t2, t1 ) || t2 < t1 )
|
|
||||||
{
|
{
|
||||||
VectorCopy( ph0->origin, e->origin );
|
VectorCopy( ph0->origin, e->origin );
|
||||||
VectorCopy( ph0->angles, e->angles );
|
VectorCopy( ph0->angles, e->angles );
|
||||||
@@ -529,7 +533,7 @@ interpolate non-local clients
|
|||||||
*/
|
*/
|
||||||
void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
void CL_ComputePlayerOrigin( cl_entity_t *ent )
|
||||||
{
|
{
|
||||||
float targettime;
|
double targettime;
|
||||||
vec4_t q, q1, q2;
|
vec4_t q, q1, q2;
|
||||||
vec3_t origin;
|
vec3_t origin;
|
||||||
vec3_t angles;
|
vec3_t angles;
|
||||||
@@ -1212,17 +1216,33 @@ void CL_LinkPacketEntities( frame_t *frame )
|
|||||||
#else
|
#else
|
||||||
if( ent->lastmove >= cl.time )
|
if( ent->lastmove >= cl.time )
|
||||||
{
|
{
|
||||||
|
float at = ent->curstate.animtime;
|
||||||
|
|
||||||
CL_ResetLatchedVars( ent, true );
|
CL_ResetLatchedVars( ent, true );
|
||||||
|
|
||||||
|
if( cl_fixmodelinterpolationartifacts.value )
|
||||||
|
ent->latched.prevanimtime = ent->curstate.animtime = at;
|
||||||
|
|
||||||
VectorCopy( ent->curstate.origin, ent->latched.prevorigin );
|
VectorCopy( ent->curstate.origin, ent->latched.prevorigin );
|
||||||
VectorCopy( ent->curstate.angles, ent->latched.prevangles );
|
VectorCopy( ent->curstate.angles, ent->latched.prevangles );
|
||||||
|
|
||||||
// disable step interpolation in client.dll
|
if( !FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
|
||||||
ent->curstate.movetype = MOVETYPE_NONE;
|
{
|
||||||
|
// disable step interpolation in client.dll
|
||||||
|
ent->curstate.movetype = MOVETYPE_NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// restore step interpolation in client.dll
|
if( FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
|
||||||
ent->curstate.movetype = MOVETYPE_STEP;
|
{
|
||||||
|
interpolate = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// restore step interpolation in client.dll
|
||||||
|
ent->curstate.movetype = MOVETYPE_STEP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1247,11 +1267,24 @@ void CL_LinkPacketEntities( frame_t *frame )
|
|||||||
if ( !CL_InterpolateModel( ent ))
|
if ( !CL_InterpolateModel( ent ))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if( ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
|
// a1ba: in GoldSrc this is done for cstrike and czero
|
||||||
|
// but let modders use this as an engine feature
|
||||||
|
else if( FBitSet( host.features, ENGINE_STEP_POSHISTORY_LERP ) &&
|
||||||
|
ent->curstate.movetype == MOVETYPE_STEP && !NET_IsLocalAddress( cls.netchan.remote_address ))
|
||||||
{
|
{
|
||||||
if( !CL_InterpolateModel( ent ))
|
if( !CL_InterpolateModel( ent ))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
// ABSOLUTELY STUPID HACK TO ALLOW MONSTERS
|
||||||
|
// INTERPOLATION IN GRAVGUNMOD COOP
|
||||||
|
// MUST BE REMOVED ONCE WE REMOVE 48 PROTO SUPPORT
|
||||||
|
else if( cls.legacymode && ent->model->type == mod_studio && ent->curstate.movetype == MOVETYPE_TOSS )
|
||||||
|
{
|
||||||
|
if( !CL_InterpolateModel( ent ))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// no interpolation right now
|
// no interpolation right now
|
||||||
|
|||||||
@@ -96,41 +96,6 @@ static dllfunc_t cdll_new_exports[] = // allowed only in SDK 2.3 and higher
|
|||||||
|
|
||||||
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
|
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc );
|
||||||
|
|
||||||
/*
|
|
||||||
====================
|
|
||||||
CL_GetEntityByIndex
|
|
||||||
|
|
||||||
Render callback for studio models
|
|
||||||
====================
|
|
||||||
*/
|
|
||||||
cl_entity_t *CL_GetEntityByIndex( int index )
|
|
||||||
{
|
|
||||||
if( !clgame.entities ) // not in game yet
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if( index < 0 || index >= clgame.maxEntities )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if( index == 0 )
|
|
||||||
return clgame.entities;
|
|
||||||
|
|
||||||
return CL_EDICT_NUM( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
CL_ModelHandle
|
|
||||||
|
|
||||||
get model handle by index
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
model_t *CL_ModelHandle( int modelindex )
|
|
||||||
{
|
|
||||||
if( modelindex < 0 || modelindex >= MAX_MODELS )
|
|
||||||
return NULL;
|
|
||||||
return cl.models[modelindex];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
====================
|
====================
|
||||||
CL_IsThirdPerson
|
CL_IsThirdPerson
|
||||||
@@ -939,7 +904,7 @@ void CL_DrawCrosshair( void )
|
|||||||
VectorAdd( refState.viewangles, cl.crosshairangle, angles );
|
VectorAdd( refState.viewangles, cl.crosshairangle, angles );
|
||||||
AngleVectors( angles, forward, NULL, NULL );
|
AngleVectors( angles, forward, NULL, NULL );
|
||||||
VectorAdd( refState.vieworg, forward, point );
|
VectorAdd( refState.vieworg, forward, point );
|
||||||
ref.dllFuncs.WorldToScreen( point, screen );
|
gTriApi.WorldToScreen( point, screen );
|
||||||
|
|
||||||
x += ( clgame.viewport[2] >> 1 ) * screen[0] + 0.5f;
|
x += ( clgame.viewport[2] >> 1 ) * screen[0] + 0.5f;
|
||||||
y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f;
|
y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f;
|
||||||
@@ -1084,7 +1049,6 @@ void CL_ClearWorld( void )
|
|||||||
|
|
||||||
world.max_recursion = 0;
|
world.max_recursion = 0;
|
||||||
|
|
||||||
clgame.ds.cullMode = TRI_FRONT;
|
|
||||||
clgame.numStatics = 0;
|
clgame.numStatics = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ CVAR_DEFINE_AUTO( cl_trace_events, "0", FCVAR_ARCHIVE|FCVAR_CHEAT, "enable event
|
|||||||
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
|
static CVAR_DEFINE_AUTO( cl_nat, "0", 0, "show servers running under NAT" );
|
||||||
CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
|
CVAR_DEFINE_AUTO( hud_utf8, "0", FCVAR_ARCHIVE, "Use utf-8 encoding for hud text" );
|
||||||
CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" );
|
CVAR_DEFINE_AUTO( ui_renderworld, "0", FCVAR_ARCHIVE, "render world when UI is visible" );
|
||||||
|
static CVAR_DEFINE_AUTO( cl_maxframetime, "0", 0, "set deadline timer for client rendering to catch freezes" );
|
||||||
|
CVAR_DEFINE_AUTO( cl_fixmodelinterpolationartifacts, "1", 0, "try to fix up models interpolation on a moving platforms (monsters on trains for example)" );
|
||||||
|
|
||||||
//
|
//
|
||||||
// userinfo
|
// userinfo
|
||||||
@@ -87,7 +89,6 @@ static CVAR_DEFINE_AUTO( model, "", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABL
|
|||||||
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" );
|
static CVAR_DEFINE_AUTO( topcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player top color" );
|
||||||
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" );
|
static CVAR_DEFINE_AUTO( bottomcolor, "0", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player bottom color" );
|
||||||
CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
CVAR_DEFINE_AUTO( rate, "3500", FCVAR_USERINFO|FCVAR_ARCHIVE|FCVAR_FILTERABLE, "player network rate" );
|
||||||
static CVAR_DEFINE_AUTO( cl_maxframetime, "0", 0, "set deadline timer for client rendering to catch freezes" );
|
|
||||||
|
|
||||||
client_t cl;
|
client_t cl;
|
||||||
client_static_t cls;
|
client_static_t cls;
|
||||||
@@ -606,10 +607,10 @@ void CL_CreateCmd( void )
|
|||||||
// message we are constructing.
|
// message we are constructing.
|
||||||
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
|
i = cls.netchan.outgoing_sequence & CL_UPDATE_MASK;
|
||||||
pcmd = &cl.commands[i];
|
pcmd = &cl.commands[i];
|
||||||
pcmd->processedfuncs = false;
|
|
||||||
|
|
||||||
if( !cls.demoplayback )
|
if( !cls.demoplayback )
|
||||||
{
|
{
|
||||||
|
pcmd->processedfuncs = false;
|
||||||
pcmd->senttime = host.realtime;
|
pcmd->senttime = host.realtime;
|
||||||
memset( &pcmd->cmd, 0, sizeof( pcmd->cmd ));
|
memset( &pcmd->cmd, 0, sizeof( pcmd->cmd ));
|
||||||
pcmd->receivedtime = -1.0;
|
pcmd->receivedtime = -1.0;
|
||||||
@@ -2190,9 +2191,20 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg )
|
|||||||
// serverlist got from masterserver
|
// serverlist got from masterserver
|
||||||
while( MSG_GetNumBitsLeft( msg ) > 8 )
|
while( MSG_GetNumBitsLeft( msg ) > 8 )
|
||||||
{
|
{
|
||||||
MSG_ReadBytes( msg, servadr.ip, sizeof( servadr.ip )); // 4 bytes for IP
|
uint8_t addr[16];
|
||||||
|
|
||||||
|
if( from.type6 == NA_IP6 ) // IPv6 master server only sends IPv6 addresses
|
||||||
|
{
|
||||||
|
MSG_ReadBytes( msg, addr, sizeof( addr ));
|
||||||
|
NET_IP6BytesToNetadr( &servadr, addr );
|
||||||
|
servadr.type6 = NA_IP6;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MSG_ReadBytes( msg, servadr.ip, sizeof( servadr.ip )); // 4 bytes for IP
|
||||||
|
servadr.type = NA_IP;
|
||||||
|
}
|
||||||
servadr.port = MSG_ReadShort( msg ); // 2 bytes for Port
|
servadr.port = MSG_ReadShort( msg ); // 2 bytes for Port
|
||||||
servadr.type = NA_IP;
|
|
||||||
|
|
||||||
// list is ends here
|
// list is ends here
|
||||||
if( !servadr.port )
|
if( !servadr.port )
|
||||||
@@ -2919,10 +2931,7 @@ void CL_InitLocal( void )
|
|||||||
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
|
Cvar_Get( "lastdemo", "", FCVAR_ARCHIVE, "last played demo" );
|
||||||
Cvar_RegisterVariable( &ui_renderworld );
|
Cvar_RegisterVariable( &ui_renderworld );
|
||||||
Cvar_RegisterVariable( &cl_maxframetime );
|
Cvar_RegisterVariable( &cl_maxframetime );
|
||||||
|
Cvar_RegisterVariable( &cl_fixmodelinterpolationartifacts );
|
||||||
// these two added to shut up CS 1.5 about 'unknown' commands
|
|
||||||
Cvar_Get( "lightgamma", "1", FCVAR_ARCHIVE, "ambient lighting level (legacy, unused)" );
|
|
||||||
Cvar_Get( "direct", "1", FCVAR_ARCHIVE, "direct lighting level (legacy, unused)" );
|
|
||||||
|
|
||||||
// server commands
|
// server commands
|
||||||
Cmd_AddCommand ("noclip", NULL, "enable or disable no clipping mode" );
|
Cmd_AddCommand ("noclip", NULL, "enable or disable no clipping mode" );
|
||||||
|
|||||||
@@ -81,12 +81,12 @@ NetGraph_FillRGBA shortcut
|
|||||||
*/
|
*/
|
||||||
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
|
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
|
||||||
{
|
{
|
||||||
ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
|
gTriApi.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
|
||||||
|
|
||||||
ref.dllFuncs.Vertex3f( rect->left, rect->top, 0 );
|
gTriApi.Vertex3f( rect->left, rect->top, 0 );
|
||||||
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top, 0 );
|
gTriApi.Vertex3f( rect->left + rect->right, rect->top, 0 );
|
||||||
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
|
gTriApi.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
|
||||||
ref.dllFuncs.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
|
gTriApi.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -691,7 +691,7 @@ void SCR_DrawNetGraph( void )
|
|||||||
|
|
||||||
ref.dllFuncs.End();
|
ref.dllFuncs.End();
|
||||||
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
|
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
|
||||||
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
|
ref.dllFuncs.RenderMode( kRenderNormal );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -903,11 +903,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
|
|||||||
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
|
Q_strncpy( clgame.maptitle, MSG_ReadString( msg ), sizeof( clgame.maptitle ));
|
||||||
background = MSG_ReadOneBit( msg );
|
background = MSG_ReadOneBit( msg );
|
||||||
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
|
Q_strncpy( gamefolder, MSG_ReadString( msg ), sizeof( gamefolder ));
|
||||||
host.features = (uint)MSG_ReadLong( msg );
|
Host_ValidateEngineFeatures( MSG_ReadDword( msg ));
|
||||||
host.features &= legacy ? ENGINE_LEGACY_FEATURES_MASK : ENGINE_FEATURES_MASK;
|
|
||||||
|
|
||||||
if( !Host_IsLocalGame( ))
|
|
||||||
Host_PrintEngineFeatures( host.features );
|
|
||||||
|
|
||||||
if( !legacy )
|
if( !legacy )
|
||||||
{
|
{
|
||||||
@@ -1642,9 +1638,6 @@ void CL_RegisterResources( sizebuf_t *msg )
|
|||||||
|
|
||||||
CL_ClearWorld ();
|
CL_ClearWorld ();
|
||||||
|
|
||||||
// update the ref state.
|
|
||||||
R_UpdateRefState ();
|
|
||||||
|
|
||||||
// tell rendering system we have a new set of models.
|
// tell rendering system we have a new set of models.
|
||||||
ref.dllFuncs.R_NewMap ();
|
ref.dllFuncs.R_NewMap ();
|
||||||
|
|
||||||
|
|||||||
@@ -660,9 +660,6 @@ void CL_LegacyPrecache_f( void )
|
|||||||
if( clgame.entities )
|
if( clgame.entities )
|
||||||
clgame.entities->model = cl.worldmodel;
|
clgame.entities->model = cl.worldmodel;
|
||||||
|
|
||||||
// update the ref state.
|
|
||||||
R_UpdateRefState ();
|
|
||||||
|
|
||||||
// tell rendering system we have a new set of models.
|
// tell rendering system we have a new set of models.
|
||||||
ref.dllFuncs.R_NewMap ();
|
ref.dllFuncs.R_NewMap ();
|
||||||
|
|
||||||
|
|||||||
@@ -824,6 +824,27 @@ static void CL_SetupPMove( playermove_t *pmove, const local_state_t *from, const
|
|||||||
cd = &from->client;
|
cd = &from->client;
|
||||||
|
|
||||||
pmove->player_index = ps->number - 1;
|
pmove->player_index = ps->number - 1;
|
||||||
|
|
||||||
|
// a1ba: workaround bug on old protocol where the server refuse to send
|
||||||
|
// our local player in delta. cl.playernum, in theory, must be equal
|
||||||
|
// to our local player index anyway
|
||||||
|
// this might not be a real solution, since everything else will be bogus
|
||||||
|
// but we need to properly run prediction and avoid potential memory
|
||||||
|
// corruption
|
||||||
|
// either debug this, or remove when old protocol will be dropped!!!
|
||||||
|
if( pmove->player_index < 0 )
|
||||||
|
{
|
||||||
|
if( cls.legacymode )
|
||||||
|
{
|
||||||
|
pmove->player_index = bound( 0, cl.playernum, cl.maxclients - 1 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if this happens, record a demo and send it to a1ba
|
||||||
|
Host_Error( "%s: ps->number == %d\n", __func__, ps->number );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pmove->multiplayer = (cl.maxclients > 1);
|
pmove->multiplayer = (cl.maxclients > 1);
|
||||||
pmove->runfuncs = runfuncs;
|
pmove->runfuncs = runfuncs;
|
||||||
pmove->time = time * 1000.0f;
|
pmove->time = time * 1000.0f;
|
||||||
|
|||||||
@@ -142,8 +142,6 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
|||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
case PARM_SKY_SPHERE:
|
|
||||||
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
|
|
||||||
case PARAM_GAMEPAUSED:
|
case PARAM_GAMEPAUSED:
|
||||||
return cl.paused;
|
return cl.paused;
|
||||||
case PARM_CLIENT_INGAME:
|
case PARM_CLIENT_INGAME:
|
||||||
@@ -187,28 +185,30 @@ intptr_t CL_RenderGetParm( const int parm, const int arg, const qboolean checkRe
|
|||||||
return CL_IsThirdPerson();
|
return CL_IsThirdPerson();
|
||||||
case PARM_QUAKE_COMPATIBLE:
|
case PARM_QUAKE_COMPATIBLE:
|
||||||
return Host_IsQuakeCompatible();
|
return Host_IsQuakeCompatible();
|
||||||
case PARM_PLAYER_INDEX:
|
|
||||||
return cl.playernum + 1;
|
|
||||||
case PARM_VIEWENT_INDEX:
|
|
||||||
return cl.viewentity;
|
|
||||||
case PARM_CONNSTATE:
|
case PARM_CONNSTATE:
|
||||||
return (int)cls.state;
|
return (int)cls.state;
|
||||||
case PARM_PLAYING_DEMO:
|
case PARM_PLAYING_DEMO:
|
||||||
return cls.demoplayback;
|
return cls.demoplayback;
|
||||||
case PARM_WATER_LEVEL:
|
case PARM_WATER_LEVEL:
|
||||||
return cl.local.waterlevel;
|
return cl.local.waterlevel;
|
||||||
case PARM_MAX_CLIENTS:
|
|
||||||
return cl.maxclients;
|
|
||||||
case PARM_LOCAL_HEALTH:
|
case PARM_LOCAL_HEALTH:
|
||||||
return cl.local.health;
|
return cl.local.health;
|
||||||
case PARM_LOCAL_GAME:
|
case PARM_LOCAL_GAME:
|
||||||
return Host_IsLocalGame();
|
return Host_IsLocalGame();
|
||||||
case PARM_NUMENTITIES:
|
case PARM_NUMENTITIES:
|
||||||
return pfnNumberOfEntities();
|
return pfnNumberOfEntities();
|
||||||
case PARM_NUMMODELS:
|
case PARM_GET_CLIENT_PTR:
|
||||||
return cl.nummodels;
|
return (intptr_t)&cl.time; // with the offset
|
||||||
case PARM_WORLD_VERSION:
|
case PARM_GET_HOST_PTR:
|
||||||
return world.version;
|
return (intptr_t)&host.realtime; // with the offset
|
||||||
|
case PARM_GET_WORLD_PTR:
|
||||||
|
return (intptr_t)&world;
|
||||||
|
case PARM_GET_MOVEVARS_PTR:
|
||||||
|
return (intptr_t)&clgame.movevars;
|
||||||
|
case PARM_GET_PALETTE_PTR:
|
||||||
|
return (intptr_t)&clgame.palette;
|
||||||
|
case PARM_GET_VIEWENT_PTR:
|
||||||
|
return (intptr_t)&clgame.viewent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -292,6 +292,8 @@ void SCR_MakeScreenShot( void )
|
|||||||
viewsize = cls.envshot_viewsize;
|
viewsize = cls.envshot_viewsize;
|
||||||
else viewsize = cl_envshot_size.value;
|
else viewsize = cl_envshot_size.value;
|
||||||
|
|
||||||
|
V_CheckGamma();
|
||||||
|
|
||||||
switch( cls.scrshot_action )
|
switch( cls.scrshot_action )
|
||||||
{
|
{
|
||||||
case scrshot_normal:
|
case scrshot_normal:
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ int CL_TempEntAddEntity( cl_entity_t *pEntity )
|
|||||||
VectorAdd( pEntity->origin, pEntity->model->maxs, maxs );
|
VectorAdd( pEntity->origin, pEntity->model->maxs, maxs );
|
||||||
|
|
||||||
// g-cont. just use PVS from previous frame
|
// g-cont. just use PVS from previous frame
|
||||||
if( TriBoxInPVS( mins, maxs ))
|
if( Mod_BoxVisible( mins, maxs, ref.dllFuncs.Mod_GetCurrentVis( )))
|
||||||
{
|
{
|
||||||
VectorCopy( pEntity->angles, pEntity->curstate.angles );
|
VectorCopy( pEntity->angles, pEntity->curstate.angles );
|
||||||
VectorCopy( pEntity->origin, pEntity->curstate.origin );
|
VectorCopy( pEntity->origin, pEntity->curstate.origin );
|
||||||
@@ -1023,8 +1023,12 @@ void GAME_EXPORT R_BreakModel( const vec3_t pos, const vec3_t size, const vec3_t
|
|||||||
count = (size[0] * size[1] + size[1] * size[2] + size[2] * size[0]) / (3 * SHARD_VOLUME * SHARD_VOLUME);
|
count = (size[0] * size[1] + size[1] * size[2] + size[2] * size[0]) / (3 * SHARD_VOLUME * SHARD_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
if( count > 15 ) count = 15;
|
||||||
|
#else
|
||||||
// limit to 100 pieces
|
// limit to 100 pieces
|
||||||
if( count > 100 ) count = 100;
|
if( count > 100 ) count = 100;
|
||||||
|
#endif
|
||||||
|
|
||||||
for( i = 0; i < count; i++ )
|
for( i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
@@ -2624,7 +2628,7 @@ CL_UpdateFlashlight
|
|||||||
update client flashlight
|
update client flashlight
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void CL_UpdateFlashlight( cl_entity_t *ent )
|
static void CL_UpdateFlashlight( cl_entity_t *ent )
|
||||||
{
|
{
|
||||||
vec3_t forward, view_ofs;
|
vec3_t forward, view_ofs;
|
||||||
vec3_t vecSrc, vecEnd;
|
vec3_t vecSrc, vecEnd;
|
||||||
@@ -2684,6 +2688,41 @@ void CL_UpdateFlashlight( cl_entity_t *ent )
|
|||||||
dl->radius = 80;
|
dl->radius = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void R_EntityDimlight( cl_entity_t *ent, int key )
|
||||||
|
{
|
||||||
|
dlight_t *dl = CL_AllocDlight( key );
|
||||||
|
|
||||||
|
VectorCopy( ent->origin, dl->origin );
|
||||||
|
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||||
|
dl->radius = COM_RandomFloat( 200.0f, 231.0f );
|
||||||
|
dl->die = cl.time + 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_EntityLight( cl_entity_t *ent, int key )
|
||||||
|
{
|
||||||
|
dlight_t *dl = CL_AllocDlight( key );
|
||||||
|
|
||||||
|
VectorCopy( ent->origin, dl->origin );
|
||||||
|
dl->color.r = dl->color.g = dl->color.b = 100;
|
||||||
|
dl->radius = 200;
|
||||||
|
dl->die = cl.time + 0.001;
|
||||||
|
|
||||||
|
R_RocketFlare( ent->origin );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_EntityBrightlight( cl_entity_t *ent, int key, int radius )
|
||||||
|
{
|
||||||
|
dlight_t *dl = CL_AllocDlight( key );
|
||||||
|
|
||||||
|
VectorCopy( ent->origin, dl->origin );
|
||||||
|
dl->origin[2] += 16.0f;
|
||||||
|
dl->color.r = dl->color.g = dl->color.b = 250;
|
||||||
|
if( !radius )
|
||||||
|
dl->radius = COM_RandomFloat( 400.0f, 431.0f );
|
||||||
|
else dl->radius = 400;
|
||||||
|
dl->die = cl.time + 0.001;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
CL_AddEntityEffects
|
CL_AddEntityEffects
|
||||||
@@ -2693,50 +2732,41 @@ apply various effects to entity origin or attachment
|
|||||||
*/
|
*/
|
||||||
void CL_AddEntityEffects( cl_entity_t *ent )
|
void CL_AddEntityEffects( cl_entity_t *ent )
|
||||||
{
|
{
|
||||||
// yellow flies effect 'monster stuck in the wall'
|
// players have special set of effects, from CL_LinkPlayers
|
||||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ) && !RP_LOCALCLIENT( ent ))
|
if( ent->player && ent->index != cl.viewentity )
|
||||||
R_EntityParticles( ent );
|
|
||||||
|
|
||||||
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
|
||||||
{
|
{
|
||||||
if( ent->player && !Host_IsQuakeCompatible( ))
|
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||||
{
|
R_EntityBrightlight( ent, ent->index /* 4 in GoldSrc */, 0 );
|
||||||
|
|
||||||
|
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||||
|
R_EntityDimlight( ent, ent->index /* 4 in GoldSrc */ );
|
||||||
|
}
|
||||||
|
else if( RP_LOCALCLIENT( ent ))
|
||||||
|
{
|
||||||
|
// from CL_PlayerFlashlight
|
||||||
|
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||||
|
R_EntityBrightlight( ent, ent->index /* 1 in GoldSrc */, 400 );
|
||||||
|
else if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||||
CL_UpdateFlashlight( ent );
|
CL_UpdateFlashlight( ent );
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
|
||||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
|
||||||
dl->radius = COM_RandomFloat( 200, 231 );
|
|
||||||
VectorCopy( ent->origin, dl->origin );
|
|
||||||
dl->die = cl.time + 0.001;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
|
||||||
{
|
{
|
||||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
// from CL_LinkPacketEntities
|
||||||
dl->color.r = dl->color.g = dl->color.b = 250;
|
if( FBitSet( ent->curstate.effects, EF_BRIGHTFIELD ))
|
||||||
if( ent->player ) dl->radius = 400; // don't flickering
|
R_EntityParticles( ent );
|
||||||
else dl->radius = COM_RandomFloat( 400, 431 );
|
|
||||||
VectorCopy( ent->origin, dl->origin );
|
|
||||||
dl->die = cl.time + 0.001;
|
|
||||||
dl->origin[2] += 16.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add light effect
|
if( FBitSet( ent->curstate.effects, EF_BRIGHTLIGHT ))
|
||||||
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
|
R_EntityBrightlight( ent, ent->index, 0 );
|
||||||
{
|
|
||||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
if( FBitSet( ent->curstate.effects, EF_DIMLIGHT ))
|
||||||
dl->color.r = dl->color.g = dl->color.b = 100;
|
R_EntityDimlight( ent, ent->index );
|
||||||
VectorCopy( ent->origin, dl->origin );
|
|
||||||
R_RocketFlare( ent->origin );
|
if( FBitSet( ent->curstate.effects, EF_LIGHT ))
|
||||||
dl->die = cl.time + 0.001;
|
R_EntityLight( ent, ent->curstate.number );
|
||||||
dl->radius = 200;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// studio models are handle muzzleflashes difference
|
// studio models are handle muzzleflashes difference
|
||||||
if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && Mod_AliasExtradata( ent->model ))
|
if( FBitSet( ent->curstate.effects, EF_MUZZLEFLASH ) && ent->model && ent->model->type == mod_alias )
|
||||||
{
|
{
|
||||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
dlight_t *dl = CL_AllocDlight( ent->index );
|
||||||
vec3_t fv;
|
vec3_t fv;
|
||||||
@@ -2765,15 +2795,11 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||||||
vec3_t neworigin;
|
vec3_t neworigin;
|
||||||
vec3_t oldorigin;
|
vec3_t oldorigin;
|
||||||
|
|
||||||
if( !ent->model ) return;
|
if( !ent->model || ent->player )
|
||||||
|
return;
|
||||||
|
|
||||||
switch( ent->model->type )
|
if( ent->model->type != mod_alias && ent->model->type != mod_studio )
|
||||||
{
|
return;
|
||||||
case mod_alias:
|
|
||||||
case mod_studio:
|
|
||||||
break;
|
|
||||||
default: return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( cls.demoplayback == DEMO_QUAKE1 )
|
if( cls.demoplayback == DEMO_QUAKE1 )
|
||||||
{
|
{
|
||||||
@@ -2793,19 +2819,15 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||||||
|
|
||||||
if( FBitSet( ent->model->flags, STUDIO_GIB ))
|
if( FBitSet( ent->model->flags, STUDIO_GIB ))
|
||||||
R_RocketTrail( oldorigin, neworigin, 2 );
|
R_RocketTrail( oldorigin, neworigin, 2 );
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_ZOMGIB ))
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 4 );
|
R_RocketTrail( oldorigin, neworigin, 4 );
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_TRACER ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_TRACER ))
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 3 );
|
R_RocketTrail( oldorigin, neworigin, 3 );
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_TRACER2 ))
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 5 );
|
R_RocketTrail( oldorigin, neworigin, 5 );
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_ROCKET ))
|
|
||||||
{
|
{
|
||||||
dlight_t *dl = CL_AllocDlight( ent->index );
|
dlight_t *dl = CL_AllocDlight( ent->curstate.number );
|
||||||
|
|
||||||
dl->color.r = dl->color.g = dl->color.b = 200;
|
dl->color.r = dl->color.g = dl->color.b = 200;
|
||||||
VectorCopy( ent->origin, dl->origin );
|
VectorCopy( ent->origin, dl->origin );
|
||||||
@@ -2819,11 +2841,9 @@ void CL_AddModelEffects( cl_entity_t *ent )
|
|||||||
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 0 );
|
R_RocketTrail( oldorigin, neworigin, 0 );
|
||||||
}
|
}
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_GRENADE ))
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 1 );
|
R_RocketTrail( oldorigin, neworigin, 1 );
|
||||||
|
else if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
|
||||||
if( FBitSet( ent->model->flags, STUDIO_TRACER3 ))
|
|
||||||
R_RocketTrail( oldorigin, neworigin, 6 );
|
R_RocketTrail( oldorigin, neworigin, 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ void R_DebugParticle( const vec3_t pos, byte r, byte g, byte b );
|
|||||||
void R_RicochetSound( const vec3_t pos );
|
void R_RicochetSound( const vec3_t pos );
|
||||||
struct dlight_s *CL_AllocDlight( int key );
|
struct dlight_s *CL_AllocDlight( int key );
|
||||||
struct dlight_s *CL_AllocElight( int key );
|
struct dlight_s *CL_AllocElight( int key );
|
||||||
void CL_UpdateFlashlight( cl_entity_t *pEnt );
|
|
||||||
void CL_AddEntityEffects( cl_entity_t *ent );
|
void CL_AddEntityEffects( cl_entity_t *ent );
|
||||||
void CL_AddModelEffects( cl_entity_t *ent );
|
void CL_AddModelEffects( cl_entity_t *ent );
|
||||||
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
|
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags );
|
||||||
@@ -102,19 +101,6 @@ struct beam_s *R_BeamRing( int startEnt, int endEnt, int modelIndex, float life,
|
|||||||
struct beam_s *R_BeamFollow( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
|
struct beam_s *R_BeamFollow( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
|
||||||
void R_BeamKill( int deadEntity );
|
void R_BeamKill( int deadEntity );
|
||||||
|
|
||||||
|
|
||||||
// TriAPI
|
|
||||||
void TriRenderMode( int mode );
|
|
||||||
void TriColor4f( float r, float g, float b, float a );
|
|
||||||
void TriColor4ub( byte r, byte g, byte b, byte a );
|
|
||||||
void TriBrightness( float brightness );
|
|
||||||
void TriCullFace( TRICULLSTYLE mode );
|
|
||||||
int TriWorldToScreen( const float *world, float *screen );
|
|
||||||
int TriBoxInPVS( float *mins, float *maxs );
|
|
||||||
void TriLightAtPoint( float *pos, float *value );
|
|
||||||
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode );
|
|
||||||
int TriSpriteTexture( model_t *pSpriteModel, int frame );
|
|
||||||
|
|
||||||
extern model_t *cl_sprite_dot;
|
extern model_t *cl_sprite_dot;
|
||||||
extern model_t *cl_sprite_shell;
|
extern model_t *cl_sprite_shell;
|
||||||
|
|
||||||
|
|||||||
@@ -347,6 +347,8 @@ qboolean V_PreRender( void )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
V_CheckGamma();
|
||||||
|
|
||||||
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
|
ref.dllFuncs.R_BeginFrame( !cl.paused && ( cls.state == ca_active ));
|
||||||
|
|
||||||
GL_UpdateSwapInterval( );
|
GL_UpdateSwapInterval( );
|
||||||
@@ -415,10 +417,10 @@ void R_DrawLeafNode( float x, float y, float scale )
|
|||||||
|
|
||||||
void R_DrawNodeConnection( float x, float y, float x2, float y2 )
|
void R_DrawNodeConnection( float x, float y, float x2, float y2 )
|
||||||
{
|
{
|
||||||
ref.dllFuncs.Begin( TRI_LINES );
|
gTriApi.Begin( TRI_LINES );
|
||||||
ref.dllFuncs.Vertex3f( x, y, 0 );
|
gTriApi.Vertex3f( x, y, 0 );
|
||||||
ref.dllFuncs.Vertex3f( x2, y2, 0 );
|
gTriApi.Vertex3f( x2, y2, 0 );
|
||||||
ref.dllFuncs.End( );
|
gTriApi.End( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
|
void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes, mleaf_t *viewleaf )
|
||||||
@@ -441,10 +443,10 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes,
|
|||||||
if( shownodes == 1 )
|
if( shownodes == 1 )
|
||||||
{
|
{
|
||||||
if( cl.worldmodel->leafs == leaf )
|
if( cl.worldmodel->leafs == leaf )
|
||||||
ref.dllFuncs.Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
gTriApi.Color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||||
else if( viewleaf && viewleaf == leaf )
|
else if( viewleaf && viewleaf == leaf )
|
||||||
ref.dllFuncs.Color4f( 1.0f, 0.0f, 0.0f, 1.0f );
|
gTriApi.Color4f( 1.0f, 0.0f, 0.0f, 1.0f );
|
||||||
else ref.dllFuncs.Color4f( 0.0f, 1.0f, 0.0f, 1.0f );
|
else gTriApi.Color4f( 0.0f, 1.0f, 0.0f, 1.0f );
|
||||||
R_DrawLeafNode( x, y, scale );
|
R_DrawLeafNode( x, y, scale );
|
||||||
}
|
}
|
||||||
world.recursion_level--;
|
world.recursion_level--;
|
||||||
@@ -453,7 +455,7 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes,
|
|||||||
|
|
||||||
if( shownodes == 1 )
|
if( shownodes == 1 )
|
||||||
{
|
{
|
||||||
ref.dllFuncs.Color4f( 0.0f, 0.0f, 1.0f, 1.0f );
|
gTriApi.Color4f( 0.0f, 0.0f, 1.0f, 1.0f );
|
||||||
R_DrawLeafNode( x, y, scale );
|
R_DrawLeafNode( x, y, scale );
|
||||||
}
|
}
|
||||||
else if( shownodes == 2 )
|
else if( shownodes == 2 )
|
||||||
@@ -485,7 +487,7 @@ void R_ShowTree( void )
|
|||||||
//pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
//pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||||
|
|
||||||
//pglLineWidth( 2.0f );
|
//pglLineWidth( 2.0f );
|
||||||
ref.dllFuncs.Color4f( 1, 0.7f, 0, 1.0f );
|
gTriApi.Color4f( 1, 0.7f, 0, 1.0f );
|
||||||
//pglDisable( GL_TEXTURE_2D );
|
//pglDisable( GL_TEXTURE_2D );
|
||||||
R_ShowTree_r( cl.worldmodel->nodes, x, y, world.max_recursion * 3.5f, 2, viewleaf );
|
R_ShowTree_r( cl.worldmodel->nodes, x, y, world.max_recursion * 3.5f, 2, viewleaf );
|
||||||
//pglEnable( GL_TEXTURE_2D );
|
//pglEnable( GL_TEXTURE_2D );
|
||||||
|
|||||||
@@ -174,6 +174,26 @@ typedef struct
|
|||||||
// at every server map change
|
// at every server map change
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
// ==== shared through RefAPI's ref_client_t ====
|
||||||
|
double time; // this is the time value that the client
|
||||||
|
// is rendering at. always <= cls.realtime
|
||||||
|
// a lerp point for other data
|
||||||
|
double oldtime; // previous cl.time, time-oldtime is used
|
||||||
|
// to decay light values and smooth step ups
|
||||||
|
int viewentity;
|
||||||
|
|
||||||
|
// server state information
|
||||||
|
int playernum;
|
||||||
|
int maxclients;
|
||||||
|
|
||||||
|
int nummodels;
|
||||||
|
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
|
||||||
|
|
||||||
|
qboolean paused;
|
||||||
|
|
||||||
|
vec3_t simorg; // predicted origin
|
||||||
|
// ==== shared through RefAPI's ref_client_t ===
|
||||||
|
|
||||||
int servercount; // server identification for prespawns
|
int servercount; // server identification for prespawns
|
||||||
int validsequence; // this is the sequence number of the last good
|
int validsequence; // this is the sequence number of the last good
|
||||||
// world snapshot/update we got. If this is 0, we can't
|
// world snapshot/update we got. If this is 0, we can't
|
||||||
@@ -183,7 +203,6 @@ typedef struct
|
|||||||
|
|
||||||
qboolean video_prepped; // false if on new level or new ref dll
|
qboolean video_prepped; // false if on new level or new ref dll
|
||||||
qboolean audio_prepped; // false if on new level or new snd dll
|
qboolean audio_prepped; // false if on new level or new snd dll
|
||||||
qboolean paused;
|
|
||||||
|
|
||||||
int delta_sequence; // acknowledged sequence number
|
int delta_sequence; // acknowledged sequence number
|
||||||
|
|
||||||
@@ -205,11 +224,6 @@ typedef struct
|
|||||||
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
|
runcmd_t commands[MULTIPLAYER_BACKUP]; // each mesage will send several old cmds
|
||||||
local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state
|
local_state_t predicted_frames[MULTIPLAYER_BACKUP]; // local client state
|
||||||
|
|
||||||
double time; // this is the time value that the client
|
|
||||||
// is rendering at. always <= cls.realtime
|
|
||||||
// a lerp point for other data
|
|
||||||
double oldtime; // previous cl.time, time-oldtime is used
|
|
||||||
// to decay light values and smooth step ups
|
|
||||||
double timedelta; // floating delta between two updates
|
double timedelta; // floating delta between two updates
|
||||||
|
|
||||||
char serverinfo[MAX_SERVERINFO_STRING];
|
char serverinfo[MAX_SERVERINFO_STRING];
|
||||||
@@ -223,7 +237,6 @@ typedef struct
|
|||||||
|
|
||||||
// player final info
|
// player final info
|
||||||
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
|
usercmd_t *cmd; // cl.commands[outgoing_sequence].cmd
|
||||||
int viewentity;
|
|
||||||
vec3_t viewangles;
|
vec3_t viewangles;
|
||||||
vec3_t viewheight;
|
vec3_t viewheight;
|
||||||
vec3_t punchangle;
|
vec3_t punchangle;
|
||||||
@@ -236,14 +249,9 @@ typedef struct
|
|||||||
float addangletotal;
|
float addangletotal;
|
||||||
float prevaddangletotal;
|
float prevaddangletotal;
|
||||||
|
|
||||||
// predicted origin and velocity
|
// predicted velocity
|
||||||
vec3_t simorg;
|
|
||||||
vec3_t simvel;
|
vec3_t simvel;
|
||||||
|
|
||||||
// server state information
|
|
||||||
int playernum;
|
|
||||||
int maxclients;
|
|
||||||
|
|
||||||
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
|
entity_state_t instanced_baseline[MAX_CUSTOM_BASELINES];
|
||||||
int instanced_baseline_count;
|
int instanced_baseline_count;
|
||||||
|
|
||||||
@@ -251,8 +259,6 @@ typedef struct
|
|||||||
char event_precache[MAX_EVENTS][MAX_QPATH];
|
char event_precache[MAX_EVENTS][MAX_QPATH];
|
||||||
char files_precache[MAX_CUSTOM][MAX_QPATH];
|
char files_precache[MAX_CUSTOM][MAX_QPATH];
|
||||||
lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
lightstyle_t lightstyles[MAX_LIGHTSTYLES];
|
||||||
model_t *models[MAX_MODELS+1]; // precached models (plus sentinel slot)
|
|
||||||
int nummodels;
|
|
||||||
int numfiles;
|
int numfiles;
|
||||||
|
|
||||||
consistency_t consistency_list[MAX_MODELS];
|
consistency_t consistency_list[MAX_MODELS];
|
||||||
@@ -364,7 +370,6 @@ typedef struct
|
|||||||
// holds text color
|
// holds text color
|
||||||
rgba_t textColor;
|
rgba_t textColor;
|
||||||
rgba_t spriteColor;
|
rgba_t spriteColor;
|
||||||
vec4_t triRGBA;
|
|
||||||
|
|
||||||
// crosshair members
|
// crosshair members
|
||||||
const model_t *pCrosshair;
|
const model_t *pCrosshair;
|
||||||
@@ -694,6 +699,7 @@ extern convar_t rate;
|
|||||||
extern convar_t m_ignore;
|
extern convar_t m_ignore;
|
||||||
extern convar_t r_showtree;
|
extern convar_t r_showtree;
|
||||||
extern convar_t ui_renderworld;
|
extern convar_t ui_renderworld;
|
||||||
|
extern convar_t cl_fixmodelinterpolationartifacts;
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
@@ -832,7 +838,6 @@ void CL_ClearSpriteTextures( void );
|
|||||||
void CL_CenterPrint( const char *text, float y );
|
void CL_CenterPrint( const char *text, float y );
|
||||||
void CL_TextMessageParse( byte *pMemFile, int fileSize );
|
void CL_TextMessageParse( byte *pMemFile, int fileSize );
|
||||||
client_textmessage_t *CL_TextMessageGet( const char *pName );
|
client_textmessage_t *CL_TextMessageGet( const char *pName );
|
||||||
model_t *CL_ModelHandle( int modelindex );
|
|
||||||
void NetAPI_CancelAllRequests( void );
|
void NetAPI_CancelAllRequests( void );
|
||||||
cl_entity_t *CL_GetLocalPlayer( void );
|
cl_entity_t *CL_GetLocalPlayer( void );
|
||||||
model_t *CL_LoadClientSprite( const char *filename );
|
model_t *CL_LoadClientSprite( const char *filename );
|
||||||
@@ -854,19 +859,45 @@ void CL_EnableScissor( scissor_state_t *scissor, int x, int y, int width, int he
|
|||||||
void CL_DisableScissor( scissor_state_t *scissor );
|
void CL_DisableScissor( scissor_state_t *scissor );
|
||||||
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
|
qboolean CL_Scissor( const scissor_state_t *scissor, float *x, float *y, float *width, float *height, float *u0, float *v0, float *u1, float *v1 );
|
||||||
|
|
||||||
_inline cl_entity_t *CL_EDICT_NUM( int n )
|
static inline cl_entity_t *CL_EDICT_NUM( int n )
|
||||||
{
|
{
|
||||||
if( !clgame.entities )
|
if( unlikely( !clgame.entities )) // not in game yet
|
||||||
{
|
{
|
||||||
Host_Error( "CL_EDICT_NUM: clgame.entities is NULL\n");
|
Host_Error( "CL_EDICT_NUM: clgame.entities is NULL\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(( n >= 0 ) && ( n < clgame.maxEntities ))
|
if( unlikely( n < 0 || n >= clgame.maxEntities ))
|
||||||
return clgame.entities + n;
|
{
|
||||||
|
Host_Error( "CL_EDICT_NUM: bad number %i\n", n );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Host_Error( "CL_EDICT_NUM: bad number %i\n", n );
|
return &clgame.entities[n];
|
||||||
return NULL;
|
}
|
||||||
|
|
||||||
|
static inline cl_entity_t *CL_GetEntityByIndex( int n )
|
||||||
|
{
|
||||||
|
if( unlikely( !clgame.entities )) // not in game yet
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if( unlikely( n < 0 || n >= clgame.maxEntities ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &clgame.entities[n];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline model_t *CL_ModelHandle( int modelindex )
|
||||||
|
{
|
||||||
|
if( unlikely( modelindex < 0 || modelindex >= MAX_MODELS ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return cl.models[modelindex];
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline qboolean CL_IsPlayerIndex( int idx )
|
||||||
|
{
|
||||||
|
return ( idx >= 1 && idx <= cl.maxclients );
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -988,7 +1019,6 @@ void CL_ProcessPlayerState( int playerindex, entity_state_t *state );
|
|||||||
void CL_ComputePlayerOrigin( cl_entity_t *clent );
|
void CL_ComputePlayerOrigin( cl_entity_t *clent );
|
||||||
void CL_ProcessPacket( frame_t *frame );
|
void CL_ProcessPacket( frame_t *frame );
|
||||||
void CL_MoveThirdpersonCamera( void );
|
void CL_MoveThirdpersonCamera( void );
|
||||||
qboolean CL_IsPlayerIndex( int idx );
|
|
||||||
void CL_SetIdealPitch( void );
|
void CL_SetIdealPitch( void );
|
||||||
void CL_EmitEntities( void );
|
void CL_EmitEntities( void );
|
||||||
|
|
||||||
@@ -1182,5 +1212,6 @@ int Key_ToUpper( int key );
|
|||||||
void OSK_Draw( void );
|
void OSK_Draw( void );
|
||||||
|
|
||||||
extern rgba_t g_color_table[8];
|
extern rgba_t g_color_table[8];
|
||||||
|
extern triangleapi_t gTriApi;
|
||||||
|
|
||||||
#endif//CLIENT_H
|
#endif//CLIENT_H
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ static CVAR_DEFINE_AUTO( con_charset, "cp1251", FCVAR_ARCHIVE, "console font cha
|
|||||||
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
static CVAR_DEFINE_AUTO( con_fontscale, "1.0", FCVAR_ARCHIVE, "scale font texture" );
|
||||||
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
static CVAR_DEFINE_AUTO( con_fontnum, "-1", FCVAR_ARCHIVE, "console font number (0, 1 or 2), -1 for autoselect" );
|
||||||
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
static CVAR_DEFINE_AUTO( con_color, "240 180 24", FCVAR_ARCHIVE, "set a custom console color" );
|
||||||
|
static CVAR_DEFINE_AUTO( scr_drawversion, "1", FCVAR_ARCHIVE, "draw version in menu or screenshots, doesn't affect console" );
|
||||||
|
static CVAR_DEFINE_AUTO( con_oldfont, "0", 0, "use legacy font from gfx.wad, might be missing or broken" );
|
||||||
|
|
||||||
static int g_codepage = 0;
|
static int g_codepage = 0;
|
||||||
static qboolean g_utf8 = false;
|
static qboolean g_utf8 = false;
|
||||||
@@ -543,8 +544,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
|
|||||||
if( font->valid )
|
if( font->valid )
|
||||||
return; // already loaded
|
return; // already loaded
|
||||||
|
|
||||||
// loading conchars
|
if( con_oldfont.value )
|
||||||
if( Sys_CheckParm( "-oldfont" ))
|
|
||||||
{
|
{
|
||||||
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
|
success = Con_LoadVariableWidthFont( "gfx/conchars.fnt", font, scale, kRenderTransTexture, TF_FONT|TF_NEAREST );
|
||||||
}
|
}
|
||||||
@@ -841,6 +841,8 @@ void Con_Init( void )
|
|||||||
Cvar_RegisterVariable( &con_fontscale );
|
Cvar_RegisterVariable( &con_fontscale );
|
||||||
Cvar_RegisterVariable( &con_fontnum );
|
Cvar_RegisterVariable( &con_fontnum );
|
||||||
Cvar_RegisterVariable( &con_color );
|
Cvar_RegisterVariable( &con_color );
|
||||||
|
Cvar_RegisterVariable( &scr_drawversion );
|
||||||
|
Cvar_RegisterVariable( &con_oldfont );
|
||||||
|
|
||||||
// init the console buffer
|
// init the console buffer
|
||||||
con.bufsize = CON_TEXTSIZE;
|
con.bufsize = CON_TEXTSIZE;
|
||||||
@@ -2047,26 +2049,30 @@ void Con_DrawVersion( void )
|
|||||||
byte *color = g_color_table[7];
|
byte *color = g_color_table[7];
|
||||||
int stringLen, charH = 0;
|
int stringLen, charH = 0;
|
||||||
int start, height = refState.height;
|
int start, height = refState.height;
|
||||||
qboolean draw_version = false;
|
|
||||||
string curbuild;
|
string curbuild;
|
||||||
|
|
||||||
switch( cls.scrshot_action )
|
if( !scr_drawversion.value || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
||||||
{
|
|
||||||
case scrshot_normal:
|
|
||||||
case scrshot_snapshot:
|
|
||||||
draw_version = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( host.force_draw_version_time > host.realtime )
|
|
||||||
draw_version = true;
|
|
||||||
|
|
||||||
if(( cls.key_dest != key_menu && !draw_version ) || CL_IsDevOverviewMode() == 2 || net_graph.value )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( draw_version )
|
if( cls.key_dest == key_menu )
|
||||||
Q_snprintf( curbuild, MAX_STRING, XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
{
|
||||||
else Q_snprintf( curbuild, MAX_STRING, "v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
Q_snprintf( curbuild, sizeof( curbuild ),
|
||||||
|
"v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qboolean draw_version;
|
||||||
|
|
||||||
|
draw_version = cls.scrshot_action == scrshot_normal
|
||||||
|
|| cls.scrshot_action == scrshot_snapshot
|
||||||
|
|| host.force_draw_version_time > host.realtime;
|
||||||
|
|
||||||
|
if( !draw_version )
|
||||||
|
return;
|
||||||
|
|
||||||
|
Q_snprintf( curbuild, sizeof( curbuild ),
|
||||||
|
XASH_ENGINE_NAME " v%i/" XASH_VERSION " (%s-%s build %i)", PROTOCOL_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
|
||||||
|
}
|
||||||
|
|
||||||
Con_DrawStringLen( curbuild, &stringLen, &charH );
|
Con_DrawStringLen( curbuild, &stringLen, &charH );
|
||||||
start = refState.width - stringLen * 1.05f;
|
start = refState.width - stringLen * 1.05f;
|
||||||
@@ -2112,10 +2118,7 @@ void Con_RunConsole( void )
|
|||||||
con.vislines = con.showlines;
|
con.vislines = con.showlines;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( con_charset.flags, FCVAR_CHANGED ) ||
|
if( FBitSet( con_charset.flags|con_fontscale.flags|con_fontnum.flags|cl_charset.flags|con_oldfont.flags, FCVAR_CHANGED ))
|
||||||
FBitSet( con_fontscale.flags, FCVAR_CHANGED ) ||
|
|
||||||
FBitSet( con_fontnum.flags, FCVAR_CHANGED ) ||
|
|
||||||
FBitSet( cl_charset.flags, FCVAR_CHANGED ))
|
|
||||||
{
|
{
|
||||||
// update codepage parameters
|
// update codepage parameters
|
||||||
if( !Q_stricmp( con_charset.string, "cp1251" ))
|
if( !Q_stricmp( con_charset.string, "cp1251" ))
|
||||||
@@ -2141,6 +2144,7 @@ void Con_RunConsole( void )
|
|||||||
ClearBits( con_fontnum.flags, FCVAR_CHANGED );
|
ClearBits( con_fontnum.flags, FCVAR_CHANGED );
|
||||||
ClearBits( con_fontscale.flags, FCVAR_CHANGED );
|
ClearBits( con_fontscale.flags, FCVAR_CHANGED );
|
||||||
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
ClearBits( cl_charset.flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( con_oldfont.flags, FCVAR_CHANGED );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2186,9 +2190,12 @@ void Con_VidInit( void )
|
|||||||
con.historyLoaded = true;
|
con.historyLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( Sys_CheckParm( "-oldfont" ))
|
||||||
|
Cvar_DirectSet( &con_oldfont, "1" );
|
||||||
|
|
||||||
Con_LoadConchars();
|
Con_LoadConchars();
|
||||||
Con_CheckResize();
|
Con_CheckResize();
|
||||||
#if XASH_LOW_MEMORY
|
#if XASH_LOW_MEMORY && !XASH_PSP
|
||||||
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE );
|
con.background = R_GetBuiltinTexture( REF_BLACK_TEXTURE );
|
||||||
#else
|
#else
|
||||||
// loading console image
|
// loading console image
|
||||||
|
|||||||
428
engine/client/gamma.c
Normal file
428
engine/client/gamma.c
Normal file
@@ -0,0 +1,428 @@
|
|||||||
|
/*
|
||||||
|
gamma.c - gamma routines
|
||||||
|
Copyright (C) 2011 Uncle Mike
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "xash3d_mathlib.h"
|
||||||
|
#include "enginefeatures.h"
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Gamma conversion support
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static byte texgammatable[256];
|
||||||
|
static uint lightgammatable[1024];
|
||||||
|
static uint lineargammatable[1024];
|
||||||
|
static uint screengammatable[1024];
|
||||||
|
static CVAR_DEFINE( v_direct, "direct", "0.9", 0, "direct studio lighting" );
|
||||||
|
static CVAR_DEFINE( v_texgamma, "texgamma", "2.0", 0, "texgamma amount" );
|
||||||
|
static CVAR_DEFINE( v_lightgamma, "lightgamma", "2.5", 0, "lightgamma amount" );
|
||||||
|
static CVAR_DEFINE( v_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
||||||
|
static CVAR_DEFINE( v_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
||||||
|
|
||||||
|
static void BuildGammaTable( const float gamma, const float brightness, const float texgamma, const float lightgamma )
|
||||||
|
{
|
||||||
|
float g1, g2, g3;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if( gamma != 0.0 )
|
||||||
|
g1 = 1.0 / gamma;
|
||||||
|
else g1 = 0.4;
|
||||||
|
|
||||||
|
g2 = g1 * texgamma;
|
||||||
|
|
||||||
|
if( brightness <= 0.0 )
|
||||||
|
g3 = 0.125;
|
||||||
|
else if( brightness <= 1.0 )
|
||||||
|
g3 = 0.125 - brightness * brightness * 0.075;
|
||||||
|
else
|
||||||
|
g3 = 0.05;
|
||||||
|
|
||||||
|
for( i = 0; i < 256; i++ )
|
||||||
|
{
|
||||||
|
double d = pow( i / 255.0, (double)g2 );
|
||||||
|
int inf = d * 255.0;
|
||||||
|
texgammatable[i] = bound( 0, inf, 255 );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( i = 0; i < 1024; i++ )
|
||||||
|
{
|
||||||
|
double d;
|
||||||
|
float f = pow( i / 1023.0, (double)lightgamma );
|
||||||
|
int inf;
|
||||||
|
|
||||||
|
if( brightness > 1.0 )
|
||||||
|
f *= brightness;
|
||||||
|
|
||||||
|
if( f <= g3 )
|
||||||
|
f = ( f / g3 ) * 0.125;
|
||||||
|
else
|
||||||
|
f = (( f - g3 ) / ( 1.0 - g3 )) * 0.875 + 0.125;
|
||||||
|
|
||||||
|
d = pow( (double)f, (double)g1 ); // do not remove the cast, or tests fail
|
||||||
|
inf = d * 1023.0;
|
||||||
|
lightgammatable[i] = bound( 0, inf, 1023 );
|
||||||
|
|
||||||
|
// do these calculations in the same loop...
|
||||||
|
lineargammatable[i] = pow( i / 1023.0, (double)gamma ) * 1023.0;
|
||||||
|
screengammatable[i] = pow( i / 1023.0, 1.0 / gamma ) * 1023.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void V_ValidateGammaCvars( void )
|
||||||
|
{
|
||||||
|
if( Host_IsLocalGame( ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( v_gamma.value < 1.8f )
|
||||||
|
Cvar_DirectSet( &v_gamma, "1.8" );
|
||||||
|
else if( v_gamma.value > 3.0f )
|
||||||
|
Cvar_DirectSet( &v_gamma, "3" );
|
||||||
|
|
||||||
|
if( v_texgamma.value < 1.8f )
|
||||||
|
Cvar_DirectSet( &v_texgamma, "1.8" );
|
||||||
|
else if( v_texgamma.value > 3.0f )
|
||||||
|
Cvar_DirectSet( &v_texgamma, "3" );
|
||||||
|
|
||||||
|
if( v_lightgamma.value < 1.8f )
|
||||||
|
Cvar_DirectSet( &v_lightgamma, "1.8" );
|
||||||
|
else if( v_lightgamma.value > 3.0f )
|
||||||
|
Cvar_DirectSet( &v_lightgamma, "3" );
|
||||||
|
|
||||||
|
if( v_brightness.value < 0.0f )
|
||||||
|
Cvar_DirectSet( &v_brightness, "0" );
|
||||||
|
else if( v_brightness.value > 2.0f )
|
||||||
|
Cvar_DirectSet( &v_brightness, "2" );
|
||||||
|
}
|
||||||
|
|
||||||
|
void V_CheckGamma( void )
|
||||||
|
{
|
||||||
|
static qboolean dirty = false;
|
||||||
|
qboolean notify_refdll = false;
|
||||||
|
|
||||||
|
// because these cvars were defined as archive
|
||||||
|
// but wasn't doing anything useful
|
||||||
|
// reset them into default values
|
||||||
|
// this might be removed after a while
|
||||||
|
if( v_direct.value == 1.0f || v_lightgamma.value == 1.0f )
|
||||||
|
{
|
||||||
|
Cvar_DirectSet( &v_direct, "0.9" );
|
||||||
|
Cvar_DirectSet( &v_lightgamma, "2.5" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( cls.scrshot_action == scrshot_envshot || cls.scrshot_action == scrshot_skyshot )
|
||||||
|
{
|
||||||
|
dirty = true; // force recalculate next normal frame
|
||||||
|
BuildGammaTable( 1.8f, 0.0f, 2.0f, 2.5f );
|
||||||
|
if( ref.initialized )
|
||||||
|
ref.dllFuncs.R_GammaChanged( true );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( dirty || FBitSet( v_texgamma.flags|v_lightgamma.flags|v_brightness.flags|v_gamma.flags, FCVAR_CHANGED ))
|
||||||
|
{
|
||||||
|
V_ValidateGammaCvars();
|
||||||
|
|
||||||
|
dirty = false;
|
||||||
|
BuildGammaTable( v_gamma.value, v_brightness.value, v_texgamma.value, v_lightgamma.value );
|
||||||
|
|
||||||
|
// force refdll to recalculate lightmaps
|
||||||
|
notify_refdll = true;
|
||||||
|
|
||||||
|
// unfortunately, recalculating textures isn't possible yet
|
||||||
|
ClearBits( v_texgamma.flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( v_lightgamma.flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( v_brightness.flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( v_gamma.flags, FCVAR_CHANGED );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( notify_refdll && ref.initialized )
|
||||||
|
ref.dllFuncs.R_GammaChanged( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
void V_Init( void )
|
||||||
|
{
|
||||||
|
Cvar_RegisterVariable( &v_texgamma );
|
||||||
|
Cvar_RegisterVariable( &v_lightgamma );
|
||||||
|
Cvar_RegisterVariable( &v_brightness );
|
||||||
|
Cvar_RegisterVariable( &v_gamma );
|
||||||
|
Cvar_RegisterVariable( &v_direct );
|
||||||
|
|
||||||
|
// force gamma init
|
||||||
|
SetBits( v_gamma.flags, FCVAR_CHANGED );
|
||||||
|
V_CheckGamma();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte TextureToGamma( byte b )
|
||||||
|
{
|
||||||
|
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
return texgammatable[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte LightToTexGamma( byte b )
|
||||||
|
{
|
||||||
|
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
// 255 << 2 is 1020, impossible to overflow
|
||||||
|
return lightgammatable[b << 2] >> 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint LightToTexGammaEx( uint b )
|
||||||
|
{
|
||||||
|
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
if( unlikely( b > ARRAYSIZE( lightgammatable )))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return lightgammatable[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint ScreenGammaTable( uint b )
|
||||||
|
{
|
||||||
|
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
if( unlikely( b > ARRAYSIZE( screengammatable )))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return screengammatable[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
uint LinearGammaTable( uint b )
|
||||||
|
{
|
||||||
|
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
||||||
|
return b;
|
||||||
|
|
||||||
|
if( unlikely( b > ARRAYSIZE( lineargammatable )))
|
||||||
|
return 0;
|
||||||
|
return lineargammatable[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
#if XASH_ENGINE_TESTS
|
||||||
|
#include "tests.h"
|
||||||
|
|
||||||
|
typedef struct precomputed_gamma_tables_s
|
||||||
|
{
|
||||||
|
float gamma;
|
||||||
|
float brightness;
|
||||||
|
float texgamma;
|
||||||
|
float lightgamma;
|
||||||
|
byte texgammatable[256];
|
||||||
|
int lightgammatable[1024];
|
||||||
|
int lineargammatable[1024];
|
||||||
|
int screengammatable[1024];
|
||||||
|
} precomputed_gamma_tables_t;
|
||||||
|
|
||||||
|
// put at the end of the file, to not confuse Qt Creator's parser
|
||||||
|
precomputed_gamma_tables_t *Test_GetGammaTables( int i );
|
||||||
|
|
||||||
|
static void Test_PrecomputedGammaTables( void )
|
||||||
|
{
|
||||||
|
precomputed_gamma_tables_t *data;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while(( data = Test_GetGammaTables( i )))
|
||||||
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
|
BuildGammaTable( data->gamma, data->brightness, data->texgamma, data->lightgamma );
|
||||||
|
|
||||||
|
for( j = 0; j < 1024; j++ )
|
||||||
|
{
|
||||||
|
if( j < 256 )
|
||||||
|
{
|
||||||
|
TASSERT_EQi( texgammatable[j], data->texgammatable[j] );
|
||||||
|
}
|
||||||
|
|
||||||
|
TASSERT_EQi( lightgammatable[j], data->lightgammatable[j] );
|
||||||
|
TASSERT_EQi( lineargammatable[j], data->lineargammatable[j] );
|
||||||
|
TASSERT_EQi( screengammatable[j], data->screengammatable[j] );
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test_RunGamma( void )
|
||||||
|
{
|
||||||
|
TRUN( Test_PrecomputedGammaTables() );
|
||||||
|
}
|
||||||
|
|
||||||
|
precomputed_gamma_tables_t *Test_GetGammaTables( int i )
|
||||||
|
{
|
||||||
|
static precomputed_gamma_tables_t precomputed_data[] = {
|
||||||
|
{
|
||||||
|
.gamma = 2.5,
|
||||||
|
.brightness = 0.0,
|
||||||
|
.texgamma = 2.0,
|
||||||
|
.lightgamma = 2.5,
|
||||||
|
.texgammatable = {
|
||||||
|
0, 3, 5, 7, 9, 10, 12, 14, 15, 17, 19, 20, 22, 23, 25, 26, 27, 29, 30, 31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49, 50, 52, 53, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 82, 83, 84,
|
||||||
|
85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 132, 133, 134, 135, 136, 137, 138,
|
||||||
|
139, 140, 141, 142, 143, 144, 145, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 165, 166, 167, 168, 169, 170, 171, 172, 172, 173, 174, 175, 176, 177, 178, 179, 180, 180, 181, 182, 183, 184, 185,
|
||||||
|
186, 186, 187, 188, 189, 190, 191, 192, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218, 219, 219, 220, 221, 222, 223, 224, 224, 225, 226, 227, 228, 229,
|
||||||
|
229, 230, 231, 232, 233, 233, 234, 235, 236, 237, 238, 238, 239, 240, 241, 242, 242, 243, 244, 245, 246, 246, 247, 248, 249, 250, 250, 251, 252, 253, 254, 255
|
||||||
|
},
|
||||||
|
.lightgammatable = {
|
||||||
|
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
|
||||||
|
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
|
||||||
|
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||||
|
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
|
||||||
|
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279,
|
||||||
|
280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331,
|
||||||
|
332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 343, 343, 344, 345, 346, 347, 348, 349, 350, 351, 353, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 376, 376, 377, 379, 379, 380, 381, 382, 383,
|
||||||
|
384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435,
|
||||||
|
436, 437, 438, 439, 440, 441, 442, 443, 444, 446, 446, 447, 449, 449, 450, 451, 452, 453, 455, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 468, 469, 470, 470, 472, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487,
|
||||||
|
488, 489, 490, 491, 493, 493, 494, 495, 496, 498, 498, 499, 500, 502, 502, 503, 504, 505, 507, 508, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 520, 521, 521, 522, 523, 524, 525, 526, 527, 528, 530, 530, 531, 532, 533, 534, 536, 536, 537, 538, 539,
|
||||||
|
540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 552, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 564, 564, 565, 566, 567, 568, 570, 571, 571, 572, 573, 574, 576, 576, 577, 578, 579, 580, 581, 583, 583, 584, 585, 586, 587, 588, 590, 591, 591,
|
||||||
|
593, 593, 594, 596, 596, 597, 598, 600, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 611, 611, 612, 613, 615, 615, 616, 618, 618, 620, 621, 621, 622, 624, 625, 626, 627, 627, 628, 629, 630, 632, 633, 633, 634, 635, 636, 638, 638, 639, 641, 642, 643, 643,
|
||||||
|
644, 645, 646, 648, 648, 650, 651, 651, 652, 654, 655, 656, 656, 658, 658, 660, 660, 662, 662, 664, 664, 665, 666, 668, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 682, 682, 683, 684, 685, 686, 687, 688, 690, 690, 691, 692, 693, 695, 696,
|
||||||
|
696, 697, 698, 699, 700, 701, 702, 703, 705, 706, 706, 707, 708, 709, 710, 711, 712, 713, 715, 716, 716, 717, 718, 719, 721, 721, 722, 724, 724, 725, 727, 727, 728, 729, 730, 731, 733, 733, 734, 735, 736, 737, 738, 740, 740, 741, 743, 744, 744, 745, 747, 747,
|
||||||
|
748, 749, 750, 752, 753, 753, 755, 755, 757, 757, 758, 759, 760, 761, 762, 764, 764, 766, 766, 767, 769, 770, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 782, 783, 784, 784, 785, 786, 788, 789, 790, 791, 792, 792, 794, 794, 796, 796, 797, 799, 800,
|
||||||
|
801, 801, 802, 803, 804, 805, 806, 807, 809, 810, 810, 811, 813, 813, 815, 815, 816, 817, 819, 819, 820, 822, 823, 823, 824, 825, 826, 827, 829, 829, 830, 832, 832, 833, 835, 835, 837, 837, 839, 840, 840, 841, 842, 843, 844, 845, 847, 847, 849, 849, 850, 851,
|
||||||
|
852, 854, 854, 856, 856, 857, 859, 859, 860, 861, 862, 864, 864, 865, 867, 867, 868, 870, 870, 872, 872, 874, 875, 875, 876, 877, 879, 880, 881, 881, 882, 883, 885, 885, 886, 887, 888, 890, 891, 891, 893, 893, 894, 895, 897, 898, 899, 900, 901, 902, 902, 903,
|
||||||
|
904, 905, 907, 907, 908, 910, 910, 911, 912, 914, 914, 915, 917, 918, 919, 920, 921, 922, 922, 923, 925, 925, 926, 927, 928, 930, 931, 932, 932, 933, 935, 936, 936, 937, 939, 940, 940, 942, 942, 944, 944, 946, 947, 948, 949, 949, 950, 952, 952, 953, 955, 956,
|
||||||
|
957, 958, 959, 959, 960, 962, 962, 964, 965, 965, 967, 967, 969, 970, 971, 972, 973, 973, 975, 975, 976, 977, 978, 979, 980, 982, 982, 984, 984, 986, 986, 988, 988, 990, 991, 992, 993, 993, 994, 995, 996, 998, 999, 999, 1000, 1002, 1002, 1004, 1005, 1005,
|
||||||
|
1006, 1007, 1008, 1010, 1011, 1011, 1013, 1014, 1015, 1016, 1017, 1018, 1018, 1019, 1020, 1021, 1023
|
||||||
|
},
|
||||||
|
.lineargammatable = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
|
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11,
|
||||||
|
11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23, 24, 24, 24, 25, 25,
|
||||||
|
25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 41, 42, 42, 43, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46,
|
||||||
|
47, 47, 48, 48, 48, 49, 49, 50, 50, 50, 51, 51, 52, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76,
|
||||||
|
77, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, 99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112,
|
||||||
|
113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 122, 122, 123, 124, 124, 125, 126, 126, 127, 128, 129, 129, 130, 131, 132, 132, 133, 134, 134, 135, 136, 137, 137, 138, 139, 140, 140, 141, 142, 143, 144, 144, 145, 146, 147, 147, 148, 149, 150,
|
||||||
|
151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 164, 164, 165, 166, 167, 168, 169, 169, 170, 171, 172, 173, 174, 175, 176, 176, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 193, 194,
|
||||||
|
195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
|
||||||
|
247, 248, 249, 250, 251, 252, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 265, 266, 267, 268, 269, 270, 271, 272, 274, 275, 276, 277, 278, 279, 280, 282, 283, 284, 285, 286, 287, 289, 290, 291, 292, 293, 294, 296, 297, 298, 299, 300, 302, 303, 304, 305,
|
||||||
|
306, 308, 309, 310, 311, 312, 314, 315, 316, 317, 319, 320, 321, 322, 324, 325, 326, 327, 329, 330, 331, 333, 334, 335, 336, 338, 339, 340, 342, 343, 344, 345, 347, 348, 349, 351, 352, 353, 355, 356, 357, 359, 360, 361, 363, 364, 365, 367, 368, 369, 371, 372,
|
||||||
|
373, 375, 376, 378, 379, 380, 382, 383, 384, 386, 387, 389, 390, 391, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 409, 410, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 437, 438, 440, 441, 443, 444, 446, 447,
|
||||||
|
449, 450, 452, 453, 455, 456, 458, 459, 461, 462, 464, 466, 467, 469, 470, 472, 473, 475, 477, 478, 480, 481, 483, 485, 486, 488, 489, 491, 493, 494, 496, 497, 499, 501, 502, 504, 506, 507, 509, 511, 512, 514, 515, 517, 519, 520, 522, 524, 525, 527, 529, 531,
|
||||||
|
532, 534, 536, 537, 539, 541, 542, 544, 546, 548, 549, 551, 553, 554, 556, 558, 560, 561, 563, 565, 567, 568, 570, 572, 574, 575, 577, 579, 581, 583, 584, 586, 588, 590, 592, 593, 595, 597, 599, 601, 602, 604, 606, 608, 610, 612, 613, 615, 617, 619, 621, 623,
|
||||||
|
625, 626, 628, 630, 632, 634, 636, 638, 639, 641, 643, 645, 647, 649, 651, 653, 655, 657, 659, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724,
|
||||||
|
726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 753, 755, 757, 759, 761, 763, 765, 767, 769, 771, 773, 776, 778, 780, 782, 784, 786, 788, 791, 793, 795, 797, 799, 801, 803, 806, 808, 810, 812, 814, 816, 819, 821, 823, 825, 827, 830, 832, 834,
|
||||||
|
836, 839, 841, 843, 845, 847, 850, 852, 854, 856, 859, 861, 863, 865, 868, 870, 872, 874, 877, 879, 881, 884, 886, 888, 890, 893, 895, 897, 900, 902, 904, 907, 909, 911, 914, 916, 918, 921, 923, 925, 928, 930, 932, 935, 937, 940, 942, 944, 947, 949, 952, 954,
|
||||||
|
956, 959, 961, 964, 966, 968, 971, 973, 976, 978, 981, 983, 985, 988, 990, 993, 995, 998, 1000, 1003, 1005, 1008, 1010, 1013, 1015, 1018, 1020, 1023
|
||||||
|
},
|
||||||
|
.screengammatable = {
|
||||||
|
0, 63, 84, 99, 111, 121, 130, 139, 146, 154, 160, 166, 172, 178, 183, 188, 193, 198, 203, 207, 212, 216, 220, 224, 228, 231, 235, 239, 242, 245, 249, 252, 255, 259, 262, 265, 268, 271, 274, 276, 279, 282, 285, 287, 290, 293, 295, 298, 300, 303, 305, 308,
|
||||||
|
310, 313, 315, 317, 320, 322, 324, 326, 328, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 357, 359, 361, 363, 365, 367, 369, 370, 372, 374, 376, 378, 379, 381, 383, 385, 386, 388, 390, 392, 393, 395, 397, 398, 400, 401, 403, 405, 406, 408,
|
||||||
|
409, 411, 413, 414, 416, 417, 419, 420, 422, 423, 425, 426, 428, 429, 431, 432, 434, 435, 436, 438, 439, 441, 442, 444, 445, 446, 448, 449, 450, 452, 453, 455, 456, 457, 459, 460, 461, 463, 464, 465, 466, 468, 469, 470, 472, 473, 474, 475, 477, 478, 479, 480,
|
||||||
|
482, 483, 484, 485, 487, 488, 489, 490, 491, 493, 494, 495, 496, 497, 499, 500, 501, 502, 503, 504, 505, 507, 508, 509, 510, 511, 512, 513, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539,
|
||||||
|
540, 541, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 585, 586, 587, 588, 589, 590,
|
||||||
|
591, 592, 593, 594, 595, 595, 596, 597, 598, 599, 600, 601, 602, 603, 603, 604, 605, 606, 607, 608, 609, 610, 610, 611, 612, 613, 614, 615, 616, 616, 617, 618, 619, 620, 621, 622, 622, 623, 624, 625, 626, 627, 627, 628, 629, 630, 631, 632, 632, 633, 634, 635,
|
||||||
|
636, 637, 637, 638, 639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675,
|
||||||
|
676, 677, 678, 678, 679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 699, 700, 701, 701, 702, 703, 704, 704, 705, 706, 706, 707, 708, 708, 709, 710, 711, 711, 712, 713,
|
||||||
|
713, 714, 715, 715, 716, 717, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 727, 728, 729, 729, 730, 731, 731, 732, 733, 733, 734, 735, 735, 736, 737, 737, 738, 739, 739, 740, 741, 741, 742, 743, 743, 744, 745, 745, 746, 746, 747,
|
||||||
|
748, 748, 749, 750, 750, 751, 752, 752, 753, 753, 754, 755, 755, 756, 757, 757, 758, 758, 759, 760, 760, 761, 762, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 768, 769, 770, 770, 771, 771, 772, 773, 773, 774, 774, 775, 776, 776, 777, 778, 778, 779, 779,
|
||||||
|
780, 781, 781, 782, 782, 783, 784, 784, 785, 785, 786, 786, 787, 788, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 796, 797, 798, 798, 799, 799, 800, 801, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 807, 808, 809, 809, 810,
|
||||||
|
810, 811, 811, 812, 813, 813, 814, 814, 815, 815, 816, 816, 817, 818, 818, 819, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 826, 827, 828, 828, 829, 829, 830, 830, 831, 831, 832, 832, 833, 834, 834, 835, 835, 836, 836, 837, 837, 838, 838,
|
||||||
|
839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 844, 845, 845, 846, 846, 847, 848, 848, 849, 849, 850, 850, 851, 851, 852, 852, 853, 853, 854, 854, 855, 855, 856, 856, 857, 857, 858, 859, 859, 860, 860, 861, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866,
|
||||||
|
866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 871, 872, 872, 873, 873, 874, 874, 875, 875, 876, 876, 877, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 890, 891, 891, 892,
|
||||||
|
892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903, 904, 904, 904, 905, 905, 906, 906, 907, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 915, 916, 916, 917,
|
||||||
|
917, 918, 918, 919, 919, 920, 920, 921, 921, 922, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 929, 930, 930, 931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 940, 941,
|
||||||
|
941, 942, 942, 943, 943, 944, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 953, 954, 954, 955, 955, 956, 956, 957, 957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 961, 962, 962, 963, 963, 964, 964,
|
||||||
|
964, 965, 965, 966, 966, 967, 967, 968, 968, 968, 969, 969, 970, 970, 971, 971, 971, 972, 972, 973, 973, 974, 974, 974, 975, 975, 976, 976, 977, 977, 977, 978, 978, 979, 979, 980, 980, 980, 981, 981, 982, 982, 983, 983, 983, 984, 984, 985, 985, 986, 986, 986,
|
||||||
|
987, 987, 988, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 993, 994, 994, 995, 995, 996, 996, 996, 997, 997, 998, 998, 998, 999, 999, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1003, 1003, 1003, 1004, 1004, 1005, 1005, 1005, 1006, 1006,
|
||||||
|
1007, 1007, 1008, 1008, 1008, 1009, 1009, 1010, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1014, 1015, 1015, 1016, 1016, 1016, 1017, 1017, 1018, 1018, 1018, 1019, 1019, 1020, 1020, 1020, 1021, 1021, 1022, 1022, 1023
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
.gamma = 2.2,
|
||||||
|
.brightness = 1.0,
|
||||||
|
.texgamma = 2.2,
|
||||||
|
.lightgamma = 2.4,
|
||||||
|
.texgammatable = {
|
||||||
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
|
||||||
|
66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123,
|
||||||
|
124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
|
||||||
|
176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
|
||||||
|
228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
|
||||||
|
},
|
||||||
|
.lightgammatable = {
|
||||||
|
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 45, 46, 47, 48, 50, 51, 52, 53, 55, 56, 57, 58, 60, 61, 62, 63, 65, 66, 67, 69, 70, 71, 72, 74, 75, 76,
|
||||||
|
78, 79, 80, 81, 83, 84, 85, 87, 88, 89, 91, 92, 93, 94, 96, 97, 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 112, 113, 114, 116, 117, 118, 120, 121, 122, 124, 125, 126, 128, 129, 130, 132, 133, 134, 136, 137, 138, 140, 141, 142, 144, 145, 147, 148, 149,
|
||||||
|
151, 152, 153, 155, 156, 157, 159, 160, 162, 163, 164, 166, 167, 168, 170, 171, 173, 174, 175, 177, 178, 179, 181, 182, 184, 185, 186, 188, 189, 191, 192, 193, 195, 196, 198, 199, 200, 202, 203, 204, 206, 207, 209, 210, 211, 213, 214, 216, 217, 219, 220, 221,
|
||||||
|
223, 224, 226, 227, 228, 230, 231, 233, 234, 235, 237, 238, 240, 241, 243, 244, 245, 247, 248, 250, 251, 252, 254, 255, 257, 258, 260, 261, 262, 264, 265, 267, 268, 270, 271, 272, 274, 275, 277, 278, 280, 281, 282, 284, 285, 287, 288, 290, 291, 293, 294, 295,
|
||||||
|
297, 298, 300, 301, 303, 304, 306, 307, 308, 310, 311, 313, 314, 316, 317, 319, 320, 321, 323, 324, 326, 327, 329, 330, 332, 333, 335, 336, 337, 339, 340, 342, 343, 345, 346, 348, 349, 351, 352, 354, 355, 356, 358, 359, 361, 362, 364, 365, 367, 368, 370, 371,
|
||||||
|
373, 374, 376, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 395, 396, 397, 398, 398, 399, 399, 400, 401, 401, 402, 402, 403, 403, 404, 404, 405, 406, 406, 407, 407, 408, 408, 409, 410, 410, 411, 411, 412, 413, 413, 414, 414, 415, 416, 416, 417,
|
||||||
|
417, 418, 419, 419, 420, 420, 421, 422, 422, 423, 423, 424, 425, 425, 426, 427, 427, 428, 428, 429, 430, 430, 431, 432, 432, 433, 433, 434, 435, 435, 436, 437, 437, 438, 439, 439, 440, 441, 441, 442, 443, 443, 444, 445, 445, 446, 447, 447, 448, 449, 449, 450,
|
||||||
|
451, 451, 452, 453, 453, 454, 455, 455, 456, 457, 457, 458, 459, 459, 460, 461, 461, 462, 463, 464, 464, 465, 466, 466, 467, 468, 468, 469, 470, 471, 471, 472, 473, 473, 474, 475, 476, 476, 477, 478, 478, 479, 480, 481, 481, 482, 483, 483, 484, 485, 486, 486,
|
||||||
|
487, 488, 489, 489, 490, 491, 492, 492, 493, 494, 495, 495, 496, 497, 498, 498, 499, 500, 501, 501, 502, 503, 504, 504, 505, 506, 507, 507, 508, 509, 510, 510, 511, 512, 513, 513, 514, 515, 516, 517, 517, 518, 519, 520, 520, 521, 522, 523, 524, 524, 525, 526,
|
||||||
|
527, 527, 528, 529, 530, 531, 531, 532, 533, 534, 535, 535, 536, 537, 538, 538, 539, 540, 541, 542, 542, 543, 544, 545, 546, 546, 547, 548, 549, 550, 550, 551, 552, 553, 554, 555, 555, 556, 557, 558, 559, 559, 560, 561, 562, 563, 564, 564, 565, 566, 567, 568,
|
||||||
|
568, 569, 570, 571, 572, 573, 573, 574, 575, 576, 577, 578, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 588, 589, 590, 591, 592, 593, 593, 594, 595, 596, 597, 598, 599, 599, 600, 601, 602, 603, 604, 605, 605, 606, 607, 608, 609, 610, 611, 611,
|
||||||
|
612, 613, 614, 615, 616, 617, 617, 618, 619, 620, 621, 622, 623, 623, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 634, 635, 636, 636, 637, 638, 639, 640, 641, 642, 643, 643, 644, 645, 646, 647, 648, 649, 650, 651, 651, 652, 653, 654, 655, 656, 657,
|
||||||
|
658, 658, 659, 660, 661, 662, 663, 664, 665, 666, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 703,
|
||||||
|
704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 749, 750, 751,
|
||||||
|
752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 795, 796, 797, 798, 799, 800,
|
||||||
|
801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850,
|
||||||
|
851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 900,
|
||||||
|
901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952,
|
||||||
|
953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002,
|
||||||
|
1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1023
|
||||||
|
},
|
||||||
|
.lineargammatable = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4,
|
||||||
|
4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||||
|
17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 24, 24, 24, 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36,
|
||||||
|
36, 36, 37, 37, 38, 38, 38, 39, 39, 39, 40, 40, 40, 41, 41, 42, 42, 42, 43, 43, 44, 44, 44, 45, 45, 46, 46, 46, 47, 47, 48, 48, 48, 49, 49, 50, 50, 51, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 61, 62, 62, 63,
|
||||||
|
63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 82, 82, 83, 83, 84, 84, 85, 86, 86, 87, 87, 88, 88, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 96, 96, 97, 97, 98, 99,
|
||||||
|
99, 100, 100, 101, 102, 102, 103, 104, 104, 105, 105, 106, 107, 107, 108, 109, 109, 110, 111, 111, 112, 113, 113, 114, 115, 115, 116, 117, 117, 118, 119, 119, 120, 121, 121, 122, 123, 123, 124, 125, 126, 126, 127, 128, 128, 129, 130, 131, 131, 132, 133, 133,
|
||||||
|
134, 135, 136, 136, 137, 138, 139, 139, 140, 141, 142, 142, 143, 144, 145, 145, 146, 147, 148, 148, 149, 150, 151, 151, 152, 153, 154, 155, 155, 156, 157, 158, 159, 159, 160, 161, 162, 163, 163, 164, 165, 166, 167, 167, 168, 169, 170, 171, 172, 172, 173, 174,
|
||||||
|
175, 176, 177, 177, 178, 179, 180, 181, 182, 183, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 193, 194, 195, 196, 197, 198, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221,
|
||||||
|
222, 223, 224, 225, 226, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273,
|
||||||
|
274, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 288, 289, 290, 291, 292, 293, 294, 295, 296, 298, 299, 300, 301, 302, 303, 304, 305, 307, 308, 309, 310, 311, 312, 313, 315, 316, 317, 318, 319, 320, 322, 323, 324, 325, 326, 328, 329, 330, 331, 332,
|
||||||
|
333, 335, 336, 337, 338, 339, 341, 342, 343, 344, 346, 347, 348, 349, 350, 352, 353, 354, 355, 357, 358, 359, 360, 362, 363, 364, 365, 367, 368, 369, 370, 372, 373, 374, 375, 377, 378, 379, 381, 382, 383, 384, 386, 387, 388, 390, 391, 392, 393, 395, 396, 397,
|
||||||
|
399, 400, 401, 403, 404, 405, 407, 408, 409, 411, 412, 413, 415, 416, 417, 419, 420, 421, 423, 424, 426, 427, 428, 430, 431, 432, 434, 435, 437, 438, 439, 441, 442, 443, 445, 446, 448, 449, 450, 452, 453, 455, 456, 458, 459, 460, 462, 463, 465, 466, 468, 469,
|
||||||
|
470, 472, 473, 475, 476, 478, 479, 481, 482, 483, 485, 486, 488, 489, 491, 492, 494, 495, 497, 498, 500, 501, 503, 504, 506, 507, 509, 510, 512, 513, 515, 516, 518, 519, 521, 522, 524, 525, 527, 528, 530, 532, 533, 535, 536, 538, 539, 541, 542, 544, 545, 547,
|
||||||
|
549, 550, 552, 553, 555, 556, 558, 560, 561, 563, 564, 566, 568, 569, 571, 572, 574, 576, 577, 579, 580, 582, 584, 585, 587, 589, 590, 592, 593, 595, 597, 598, 600, 602, 603, 605, 607, 608, 610, 612, 613, 615, 617, 618, 620, 622, 623, 625, 627, 628, 630, 632,
|
||||||
|
633, 635, 637, 639, 640, 642, 644, 645, 647, 649, 650, 652, 654, 656, 657, 659, 661, 663, 664, 666, 668, 670, 671, 673, 675, 677, 678, 680, 682, 684, 685, 687, 689, 691, 692, 694, 696, 698, 700, 701, 703, 705, 707, 709, 710, 712, 714, 716, 718, 719, 721, 723,
|
||||||
|
725, 727, 729, 730, 732, 734, 736, 738, 740, 741, 743, 745, 747, 749, 751, 753, 754, 756, 758, 760, 762, 764, 766, 767, 769, 771, 773, 775, 777, 779, 781, 783, 785, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 809, 811, 813, 815, 817, 819, 821,
|
||||||
|
823, 825, 827, 829, 831, 833, 835, 837, 839, 841, 843, 845, 847, 849, 851, 853, 855, 857, 859, 861, 863, 865, 867, 869, 871, 873, 875, 877, 879, 881, 883, 885, 887, 889, 891, 893, 895, 897, 899, 901, 903, 905, 907, 910, 912, 914, 916, 918, 920, 922, 924, 926,
|
||||||
|
928, 930, 932, 934, 937, 939, 941, 943, 945, 947, 949, 951, 953, 956, 958, 960, 962, 964, 966, 968, 970, 973, 975, 977, 979, 981, 983, 985, 988, 990, 992, 994, 996, 998, 1001, 1003, 1005, 1007, 1009, 1012, 1014, 1016, 1018, 1020, 1023
|
||||||
|
},
|
||||||
|
.screengammatable = {
|
||||||
|
0, 43, 60, 72, 82, 91, 98, 106, 112, 118, 124, 130, 135, 140, 145, 150, 154, 158, 163, 167, 171, 174, 178, 182, 185, 189, 192, 196, 199, 202, 205, 208, 211, 214, 217, 220, 223, 226, 228, 231, 234, 237, 239, 242, 244, 247, 249, 252, 254, 257, 259, 261,
|
||||||
|
264, 266, 268, 270, 273, 275, 277, 279, 281, 283, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 311, 313, 315, 317, 319, 321, 323, 324, 326, 328, 330, 331, 333, 335, 337, 338, 340, 342, 343, 345, 347, 348, 350, 352, 353, 355, 357, 358, 360,
|
||||||
|
361, 363, 365, 366, 368, 369, 371, 372, 374, 375, 377, 378, 380, 381, 383, 384, 386, 387, 389, 390, 392, 393, 394, 396, 397, 399, 400, 401, 403, 404, 406, 407, 408, 410, 411, 412, 414, 415, 416, 418, 419, 420, 422, 423, 424, 426, 427, 428, 430, 431, 432, 433,
|
||||||
|
435, 436, 437, 438, 440, 441, 442, 443, 445, 446, 447, 448, 450, 451, 452, 453, 454, 456, 457, 458, 459, 460, 462, 463, 464, 465, 466, 467, 469, 470, 471, 472, 473, 474, 475, 477, 478, 479, 480, 481, 482, 483, 484, 486, 487, 488, 489, 490, 491, 492, 493, 494,
|
||||||
|
495, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 545, 546, 547,
|
||||||
|
548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 583, 584, 585, 586, 587, 588, 589, 590, 591, 591, 592, 593, 594, 595,
|
||||||
|
596, 597, 598, 598, 599, 600, 601, 602, 603, 604, 604, 605, 606, 607, 608, 609, 609, 610, 611, 612, 613, 614, 615, 615, 616, 617, 618, 619, 620, 620, 621, 622, 623, 624, 624, 625, 626, 627, 628, 629, 629, 630, 631, 632, 633, 633, 634, 635, 636, 637, 637, 638,
|
||||||
|
639, 640, 641, 641, 642, 643, 644, 645, 645, 646, 647, 648, 649, 649, 650, 651, 652, 652, 653, 654, 655, 656, 656, 657, 658, 659, 659, 660, 661, 662, 663, 663, 664, 665, 666, 666, 667, 668, 669, 669, 670, 671, 672, 672, 673, 674, 675, 675, 676, 677, 678, 678,
|
||||||
|
679, 680, 681, 681, 682, 683, 684, 684, 685, 686, 686, 687, 688, 689, 689, 690, 691, 692, 692, 693, 694, 694, 695, 696, 697, 697, 698, 699, 700, 700, 701, 702, 702, 703, 704, 705, 705, 706, 707, 707, 708, 709, 709, 710, 711, 712, 712, 713, 714, 714, 715, 716,
|
||||||
|
716, 717, 718, 719, 719, 720, 721, 721, 722, 723, 723, 724, 725, 725, 726, 727, 728, 728, 729, 730, 730, 731, 732, 732, 733, 734, 734, 735, 736, 736, 737, 738, 738, 739, 740, 740, 741, 742, 742, 743, 744, 744, 745, 746, 746, 747, 748, 748, 749, 750, 750, 751,
|
||||||
|
752, 752, 753, 754, 754, 755, 756, 756, 757, 758, 758, 759, 759, 760, 761, 761, 762, 763, 763, 764, 765, 765, 766, 767, 767, 768, 769, 769, 770, 770, 771, 772, 772, 773, 774, 774, 775, 776, 776, 777, 777, 778, 779, 779, 780, 781, 781, 782, 782, 783, 784, 784,
|
||||||
|
785, 786, 786, 787, 787, 788, 789, 789, 790, 791, 791, 792, 792, 793, 794, 794, 795, 795, 796, 797, 797, 798, 799, 799, 800, 800, 801, 802, 802, 803, 803, 804, 805, 805, 806, 806, 807, 808, 808, 809, 809, 810, 811, 811, 812, 812, 813, 814, 814, 815, 815, 816,
|
||||||
|
817, 817, 818, 818, 819, 820, 820, 821, 821, 822, 823, 823, 824, 824, 825, 825, 826, 827, 827, 828, 828, 829, 830, 830, 831, 831, 832, 833, 833, 834, 834, 835, 835, 836, 837, 837, 838, 838, 839, 839, 840, 841, 841, 842, 842, 843, 843, 844, 845, 845, 846, 846,
|
||||||
|
847, 847, 848, 849, 849, 850, 850, 851, 851, 852, 853, 853, 854, 854, 855, 855, 856, 857, 857, 858, 858, 859, 859, 860, 860, 861, 862, 862, 863, 863, 864, 864, 865, 865, 866, 867, 867, 868, 868, 869, 869, 870, 870, 871, 872, 872, 873, 873, 874, 874, 875, 875,
|
||||||
|
876, 876, 877, 878, 878, 879, 879, 880, 880, 881, 881, 882, 882, 883, 884, 884, 885, 885, 886, 886, 887, 887, 888, 888, 889, 889, 890, 891, 891, 892, 892, 893, 893, 894, 894, 895, 895, 896, 896, 897, 898, 898, 899, 899, 900, 900, 901, 901, 902, 902, 903, 903,
|
||||||
|
904, 904, 905, 905, 906, 906, 907, 908, 908, 909, 909, 910, 910, 911, 911, 912, 912, 913, 913, 914, 914, 915, 915, 916, 916, 917, 917, 918, 918, 919, 920, 920, 921, 921, 922, 922, 923, 923, 924, 924, 925, 925, 926, 926, 927, 927, 928, 928, 929, 929, 930, 930,
|
||||||
|
931, 931, 932, 932, 933, 933, 934, 934, 935, 935, 936, 936, 937, 937, 938, 938, 939, 939, 940, 940, 941, 941, 942, 942, 943, 943, 944, 944, 945, 945, 946, 946, 947, 947, 948, 948, 949, 949, 950, 950, 951, 951, 952, 952, 953, 953, 954, 954, 955, 955, 956, 956,
|
||||||
|
957, 957, 958, 958, 959, 959, 960, 960, 961, 961, 962, 962, 963, 963, 964, 964, 965, 965, 966, 966, 967, 967, 968, 968, 969, 969, 969, 970, 970, 971, 971, 972, 972, 973, 973, 974, 974, 975, 975, 976, 976, 977, 977, 978, 978, 979, 979, 980, 980, 981, 981, 982,
|
||||||
|
982, 982, 983, 983, 984, 984, 985, 985, 986, 986, 987, 987, 988, 988, 989, 989, 990, 990, 991, 991, 991, 992, 992, 993, 993, 994, 994, 995, 995, 996, 996, 997, 997, 998, 998, 999, 999, 999, 1000, 1000, 1001, 1001, 1002, 1002, 1003, 1003, 1004, 1004, 1005,
|
||||||
|
1005, 1006, 1006, 1006, 1007, 1007, 1008, 1008, 1009, 1009, 1010, 1010, 1011, 1011, 1012, 1012, 1012, 1013, 1013, 1014, 1014, 1015, 1015, 1016, 1016, 1017, 1017, 1017, 1018, 1018, 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, 1023
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if( i < 0 || i >= ARRAYSIZE( precomputed_data ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &precomputed_data[i];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -19,6 +19,24 @@ GNU General Public License for more details.
|
|||||||
#include "vgui_draw.h"
|
#include "vgui_draw.h"
|
||||||
#include "mobility_int.h"
|
#include "mobility_int.h"
|
||||||
|
|
||||||
|
#ifdef XASH_NO_TOUCH
|
||||||
|
|
||||||
|
void Touch_WriteConfig( void ) {}
|
||||||
|
void Touch_SetClientOnly( qboolean state ) {}
|
||||||
|
void Touch_RemoveButton( const char *name ) {}
|
||||||
|
void Touch_HideButtons( const char *name, byte hide ) {}
|
||||||
|
void Touch_AddClientButton( const char *name, const char *texture, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags ) {}
|
||||||
|
void Touch_AddDefaultButton( const char *name, const char *texturefile, const char *command, float x1, float y1, float x2, float y2, byte *color, int round, float aspect, int flags ) {}
|
||||||
|
void Touch_ResetDefaultButtons( void ){}
|
||||||
|
void Touch_Init( void ) {}
|
||||||
|
void Touch_Draw( void ) {}
|
||||||
|
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy ) { return 0; }
|
||||||
|
void Touch_GetMove( float *forward, float *side, float *yaw, float *pitch ) {}
|
||||||
|
void Touch_KeyEvent( int key, int down ) {}
|
||||||
|
void Touch_Shutdown( void ) {}
|
||||||
|
|
||||||
|
#else /* XASH_NO_TOUCH */
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
touch_command, // just tap a button
|
touch_command, // just tap a button
|
||||||
@@ -1529,7 +1547,6 @@ void Touch_Draw( void )
|
|||||||
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x + touch.side * width - GRID_X * touch_move_indicator.value ),
|
ref.dllFuncs.R_DrawStretchPic( TO_SCRN_X( touch.move_start_x + touch.side * width - GRID_X * touch_move_indicator.value ),
|
||||||
TO_SCRN_Y( touch.move_start_y - touch.forward * height - GRID_Y * touch_move_indicator.value ),
|
TO_SCRN_Y( touch.move_start_y - touch.forward * height - GRID_Y * touch_move_indicator.value ),
|
||||||
TO_SCRN_X( GRID_X * 2 * touch_move_indicator.value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator.value ), 0, 0, 1, 1, touch.joytexture );
|
TO_SCRN_X( GRID_X * 2 * touch_move_indicator.value ), TO_SCRN_Y( GRID_Y * 2 * touch_move_indicator.value ), 0, 0, 1, 1, touch.joytexture );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2191,3 +2208,5 @@ void Touch_Shutdown( void )
|
|||||||
touch.initialized = false;
|
touch.initialized = false;
|
||||||
Mem_FreePool( &touch.mempool );
|
Mem_FreePool( &touch.mempool );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* XASH_NO_TOUCH */
|
||||||
|
|||||||
@@ -60,8 +60,10 @@ uint IN_CollectInputDevices( void )
|
|||||||
if( !m_ignore.value ) // no way to check is mouse connected, so use cvar only
|
if( !m_ignore.value ) // no way to check is mouse connected, so use cvar only
|
||||||
ret |= INPUT_DEVICE_MOUSE;
|
ret |= INPUT_DEVICE_MOUSE;
|
||||||
|
|
||||||
|
#ifndef XASH_NO_TOUCH
|
||||||
if( touch_enable.value )
|
if( touch_enable.value )
|
||||||
ret |= INPUT_DEVICE_TOUCH;
|
ret |= INPUT_DEVICE_TOUCH;
|
||||||
|
#endif
|
||||||
|
|
||||||
if( Joy_IsActive() ) // connected or enabled
|
if( Joy_IsActive() ) // connected or enabled
|
||||||
ret |= INPUT_DEVICE_JOYSTICK;
|
ret |= INPUT_DEVICE_JOYSTICK;
|
||||||
@@ -91,13 +93,17 @@ void IN_LockInputDevices( qboolean lock )
|
|||||||
{
|
{
|
||||||
SetBits( m_ignore.flags, FCVAR_READ_ONLY );
|
SetBits( m_ignore.flags, FCVAR_READ_ONLY );
|
||||||
SetBits( joy_enable.flags, FCVAR_READ_ONLY );
|
SetBits( joy_enable.flags, FCVAR_READ_ONLY );
|
||||||
|
#ifndef XASH_NO_TOUCH
|
||||||
SetBits( touch_enable.flags, FCVAR_READ_ONLY );
|
SetBits( touch_enable.flags, FCVAR_READ_ONLY );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ClearBits( m_ignore.flags, FCVAR_READ_ONLY );
|
ClearBits( m_ignore.flags, FCVAR_READ_ONLY );
|
||||||
ClearBits( joy_enable.flags, FCVAR_READ_ONLY );
|
ClearBits( joy_enable.flags, FCVAR_READ_ONLY );
|
||||||
|
#ifndef XASH_NO_TOUCH
|
||||||
ClearBits( touch_enable.flags, FCVAR_READ_ONLY );
|
ClearBits( touch_enable.flags, FCVAR_READ_ONLY );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,11 +357,14 @@ void IN_MouseEvent( int key, int down )
|
|||||||
else ClearBits( in_mstate, BIT( key ));
|
else ClearBits( in_mstate, BIT( key ));
|
||||||
|
|
||||||
// touch emulation overrides all input
|
// touch emulation overrides all input
|
||||||
|
#if XASH_NO_TOUCH
|
||||||
if( touch_emulate.value )
|
if( touch_emulate.value )
|
||||||
{
|
{
|
||||||
Touch_KeyEvent( K_MOUSE1 + key, down );
|
Touch_KeyEvent( K_MOUSE1 + key, down );
|
||||||
}
|
}
|
||||||
else if( cls.key_dest == key_game )
|
else
|
||||||
|
#endif
|
||||||
|
if( cls.key_dest == key_game )
|
||||||
{
|
{
|
||||||
// perform button actions
|
// perform button actions
|
||||||
VGui_MouseEvent( K_MOUSE1 + key, down );
|
VGui_MouseEvent( K_MOUSE1 + key, down );
|
||||||
@@ -364,8 +373,7 @@ void IN_MouseEvent( int key, int down )
|
|||||||
// client may override IN_MouseEvent
|
// client may override IN_MouseEvent
|
||||||
// but by default it calls back to Key_Event anyway
|
// but by default it calls back to Key_Event anyway
|
||||||
if( in_mouseactive )
|
if( in_mouseactive )
|
||||||
clgame.dllFuncs.IN_MouseEvent( in_mstate );
|
clgame.dllFuncs.IN_MouseEvent( in_mstate ); }
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// perform button actions
|
// perform button actions
|
||||||
|
|||||||
@@ -515,7 +515,6 @@ void Key_Init( void )
|
|||||||
|
|
||||||
Cvar_RegisterVariable( &osk_enable );
|
Cvar_RegisterVariable( &osk_enable );
|
||||||
Cvar_RegisterVariable( &key_rotate );
|
Cvar_RegisterVariable( &key_rotate );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -703,7 +702,11 @@ void GAME_EXPORT Key_Event( int key, int down )
|
|||||||
VGui_KeyEvent( key, down );
|
VGui_KeyEvent( key, down );
|
||||||
|
|
||||||
// console key is hardcoded, so the user can never unbind it
|
// console key is hardcoded, so the user can never unbind it
|
||||||
|
#if XASH_PSP
|
||||||
|
if( key == '`' || key == '~' || key == K_MODE_BUTTON )
|
||||||
|
#else
|
||||||
if( key == '`' || key == '~' )
|
if( key == '`' || key == '~' )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// we are in typing mode, so don't switch to console
|
// we are in typing mode, so don't switch to console
|
||||||
if( cls.key_dest == key_message || !down )
|
if( cls.key_dest == key_message || !down )
|
||||||
@@ -714,7 +717,11 @@ void GAME_EXPORT Key_Event( int key, int down )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// escape is always handled special
|
// escape is always handled special
|
||||||
|
#if XASH_PSP
|
||||||
|
if( ( key == K_ESCAPE || key == K_START_BUTTON ) && down )
|
||||||
|
#else
|
||||||
if( key == K_ESCAPE && down )
|
if( key == K_ESCAPE && down )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
switch( cls.key_dest )
|
switch( cls.key_dest )
|
||||||
{
|
{
|
||||||
@@ -881,7 +888,11 @@ Normal keyboard characters, already shifted / capslocked / etc
|
|||||||
void CL_CharEvent( int key )
|
void CL_CharEvent( int key )
|
||||||
{
|
{
|
||||||
// the console key should never be used as a char
|
// the console key should never be used as a char
|
||||||
|
#if XASH_PSP
|
||||||
|
if( key == '`' || key == '~' || key == K_MODE_BUTTON ) return;
|
||||||
|
#else
|
||||||
if( key == '`' || key == '~' ) return;
|
if( key == '`' || key == '~' ) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if( cls.key_dest == key_console && !Con_Visible( ))
|
if( cls.key_dest == key_console && !Con_Visible( ))
|
||||||
{
|
{
|
||||||
@@ -1006,7 +1017,11 @@ static qboolean OSK_KeyEvent( int key, int down )
|
|||||||
|
|
||||||
if( osk.curbutton.val == 0 )
|
if( osk.curbutton.val == 0 )
|
||||||
{
|
{
|
||||||
|
#if XASH_PSP
|
||||||
|
if( key == K_ENTER || key == K_A_BUTTON )
|
||||||
|
#else
|
||||||
if( key == K_ENTER )
|
if( key == K_ENTER )
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
|
osk.curbutton.val = osk_keylayout[osk.curlayout][osk.curbutton.y][osk.curbutton.x];
|
||||||
return true;
|
return true;
|
||||||
@@ -1017,6 +1032,9 @@ static qboolean OSK_KeyEvent( int key, int down )
|
|||||||
|
|
||||||
switch ( key )
|
switch ( key )
|
||||||
{
|
{
|
||||||
|
#if XASH_PSP
|
||||||
|
case K_A_BUTTON:
|
||||||
|
#endif
|
||||||
case K_ENTER:
|
case K_ENTER:
|
||||||
switch( osk.curbutton.val )
|
switch( osk.curbutton.val )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,6 +18,31 @@ CVAR_DEFINE_AUTO( r_showtree, "0", FCVAR_ARCHIVE, "build the graph of visible BS
|
|||||||
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
static CVAR_DEFINE_AUTO( r_refdll, "", FCVAR_RENDERINFO, "choose renderer implementation, if supported" );
|
||||||
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
|
static CVAR_DEFINE_AUTO( r_refdll_loaded, "", FCVAR_READ_ONLY, "currently loaded renderer" );
|
||||||
|
|
||||||
|
// there is no need to expose whole host and cl structs into the renderer
|
||||||
|
// but we still need to update timings accurately as possible
|
||||||
|
// this looks horrible but the only other option would be passing four
|
||||||
|
// time pointers and then it's looks even worse with dereferences everywhere
|
||||||
|
#define STATIC_OFFSET_CHECK( s1, s2, field, base, msg ) \
|
||||||
|
STATIC_ASSERT( offsetof( s1, field ) == offsetof( s2, field ) - offsetof( s2, base ), msg )
|
||||||
|
#define REF_CLIENT_CHECK( field ) \
|
||||||
|
STATIC_OFFSET_CHECK( ref_client_t, client_t, field, time, "broken ref_client_t offset" ); \
|
||||||
|
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_client_t *)0)->field ) == sizeof( cl.field ), "broken ref_client_t size" )
|
||||||
|
#define REF_HOST_CHECK( field ) \
|
||||||
|
STATIC_OFFSET_CHECK( ref_host_t, host_parm_t, field, realtime, "broken ref_client_t offset" ); \
|
||||||
|
STATIC_ASSERT_( szchk_##__LINE__, sizeof(((ref_host_t *)0)->field ) == sizeof( host.field ), "broken ref_client_t size" )
|
||||||
|
|
||||||
|
REF_CLIENT_CHECK( time );
|
||||||
|
REF_CLIENT_CHECK( oldtime );
|
||||||
|
REF_CLIENT_CHECK( viewentity );
|
||||||
|
REF_CLIENT_CHECK( playernum );
|
||||||
|
REF_CLIENT_CHECK( maxclients );
|
||||||
|
REF_CLIENT_CHECK( models );
|
||||||
|
REF_CLIENT_CHECK( paused );
|
||||||
|
REF_CLIENT_CHECK( simorg );
|
||||||
|
REF_HOST_CHECK( realtime );
|
||||||
|
REF_HOST_CHECK( frametime );
|
||||||
|
REF_HOST_CHECK( features );
|
||||||
|
|
||||||
void R_GetTextureParms( int *w, int *h, int texnum )
|
void R_GetTextureParms( int *w, int *h, int texnum )
|
||||||
{
|
{
|
||||||
if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
|
if( w ) *w = REF_GET_PARM( PARM_TEX_WIDTH, texnum );
|
||||||
@@ -42,18 +67,8 @@ void GAME_EXPORT GL_FreeImage( const char *name )
|
|||||||
ref.dllFuncs.GL_FreeTexture( texnum );
|
ref.dllFuncs.GL_FreeTexture( texnum );
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_UpdateRefState( void )
|
|
||||||
{
|
|
||||||
refState.time = cl.time;
|
|
||||||
refState.oldtime = cl.oldtime;
|
|
||||||
refState.realtime = host.realtime;
|
|
||||||
refState.frametime = host.frametime;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GL_RenderFrame( const ref_viewpass_t *rvp )
|
void GL_RenderFrame( const ref_viewpass_t *rvp )
|
||||||
{
|
{
|
||||||
R_UpdateRefState();
|
|
||||||
|
|
||||||
VectorCopy( rvp->vieworigin, refState.vieworg );
|
VectorCopy( rvp->vieworigin, refState.vieworg );
|
||||||
VectorCopy( rvp->viewangles, refState.viewangles );
|
VectorCopy( rvp->viewangles, refState.viewangles );
|
||||||
|
|
||||||
@@ -65,11 +80,6 @@ static intptr_t pfnEngineGetParm( int parm, int arg )
|
|||||||
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
return CL_RenderGetParm( parm, arg, false ); // prevent recursion
|
||||||
}
|
}
|
||||||
|
|
||||||
static world_static_t *pfnGetWorld( void )
|
|
||||||
{
|
|
||||||
return &world;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
|
static void pfnStudioEvent( const mstudioevent_t *event, const cl_entity_t *e )
|
||||||
{
|
{
|
||||||
clgame.dllFuncs.pfnStudioEvent( event, e );
|
clgame.dllFuncs.pfnStudioEvent( event, e );
|
||||||
@@ -99,16 +109,6 @@ static void *pfnMod_Extradata( int type, model_t *m )
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pfnGetPredictedOrigin( vec3_t v )
|
|
||||||
{
|
|
||||||
VectorCopy( cl.simorg, v );
|
|
||||||
}
|
|
||||||
|
|
||||||
static color24 *pfnCL_GetPaletteColor( void ) // clgame.palette[color]
|
|
||||||
{
|
|
||||||
return clgame.palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
static void pfnCL_GetScreenInfo( int *width, int *height ) // clgame.scrInfo, ptrs may be NULL
|
||||||
{
|
{
|
||||||
if( width ) *width = clgame.scrInfo.iWidth;
|
if( width ) *width = clgame.scrInfo.iWidth;
|
||||||
@@ -178,25 +178,6 @@ static screenfade_t *pfnRefGetScreenFade( void )
|
|||||||
return &clgame.fade;
|
return &clgame.fade;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
===============
|
|
||||||
R_DoResetGamma
|
|
||||||
gamma will be reset for
|
|
||||||
some type of screenshots
|
|
||||||
===============
|
|
||||||
*/
|
|
||||||
static qboolean R_DoResetGamma( void )
|
|
||||||
{
|
|
||||||
switch( cls.scrshot_action )
|
|
||||||
{
|
|
||||||
case scrshot_envshot:
|
|
||||||
case scrshot_skyshot:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static qboolean R_Init_Video_( const int type )
|
static qboolean R_Init_Video_( const int type )
|
||||||
{
|
{
|
||||||
host.apply_opengl_config = true;
|
host.apply_opengl_config = true;
|
||||||
@@ -207,11 +188,6 @@ static qboolean R_Init_Video_( const int type )
|
|||||||
return R_Init_Video( type );
|
return R_Init_Video( type );
|
||||||
}
|
}
|
||||||
|
|
||||||
static model_t **pfnGetModels( void )
|
|
||||||
{
|
|
||||||
return cl.models;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ref_api_t gEngfuncs =
|
static ref_api_t gEngfuncs =
|
||||||
{
|
{
|
||||||
pfnEngineGetParm,
|
pfnEngineGetParm,
|
||||||
@@ -246,14 +222,12 @@ static ref_api_t gEngfuncs =
|
|||||||
Con_DrawString,
|
Con_DrawString,
|
||||||
CL_DrawCenterPrint,
|
CL_DrawCenterPrint,
|
||||||
|
|
||||||
CL_GetViewModel,
|
|
||||||
R_BeamGetEntity,
|
R_BeamGetEntity,
|
||||||
CL_GetWaterEntity,
|
CL_GetWaterEntity,
|
||||||
CL_AddVisibleEntity,
|
CL_AddVisibleEntity,
|
||||||
|
|
||||||
Mod_SampleSizeForFace,
|
Mod_SampleSizeForFace,
|
||||||
Mod_BoxVisible,
|
Mod_BoxVisible,
|
||||||
pfnGetWorld,
|
|
||||||
Mod_PointInLeaf,
|
Mod_PointInLeaf,
|
||||||
Mod_CreatePolygonsForHull,
|
Mod_CreatePolygonsForHull,
|
||||||
|
|
||||||
@@ -270,7 +244,6 @@ static ref_api_t gEngfuncs =
|
|||||||
|
|
||||||
Mod_ForName,
|
Mod_ForName,
|
||||||
pfnMod_Extradata,
|
pfnMod_Extradata,
|
||||||
pfnGetModels,
|
|
||||||
|
|
||||||
CL_EntitySetRemapColors,
|
CL_EntitySetRemapColors,
|
||||||
CL_GetRemapInfoForEntity,
|
CL_GetRemapInfoForEntity,
|
||||||
@@ -281,8 +254,6 @@ static ref_api_t gEngfuncs =
|
|||||||
COM_RandomFloat,
|
COM_RandomFloat,
|
||||||
COM_RandomLong,
|
COM_RandomLong,
|
||||||
pfnRefGetScreenFade,
|
pfnRefGetScreenFade,
|
||||||
pfnGetPredictedOrigin,
|
|
||||||
pfnCL_GetPaletteColor,
|
|
||||||
pfnCL_GetScreenInfo,
|
pfnCL_GetScreenInfo,
|
||||||
pfnSetLocalLightLevel,
|
pfnSetLocalLightLevel,
|
||||||
Sys_CheckParm,
|
Sys_CheckParm,
|
||||||
@@ -316,9 +287,11 @@ static ref_api_t gEngfuncs =
|
|||||||
SW_LockBuffer,
|
SW_LockBuffer,
|
||||||
SW_UnlockBuffer,
|
SW_UnlockBuffer,
|
||||||
|
|
||||||
BuildGammaTable,
|
|
||||||
LightToTexGamma,
|
LightToTexGamma,
|
||||||
R_DoResetGamma,
|
LightToTexGammaEx,
|
||||||
|
TextureToGamma,
|
||||||
|
ScreenGammaTable,
|
||||||
|
LinearGammaTable,
|
||||||
|
|
||||||
CL_GetLightStyle,
|
CL_GetLightStyle,
|
||||||
CL_GetDynamicLight,
|
CL_GetDynamicLight,
|
||||||
@@ -332,7 +305,6 @@ static ref_api_t gEngfuncs =
|
|||||||
PM_CL_TraceLine,
|
PM_CL_TraceLine,
|
||||||
CL_VisTraceLine,
|
CL_VisTraceLine,
|
||||||
CL_TraceLine,
|
CL_TraceLine,
|
||||||
pfnGetMoveVars,
|
|
||||||
|
|
||||||
Image_AddCmdFlags,
|
Image_AddCmdFlags,
|
||||||
Image_SetForceFlags,
|
Image_SetForceFlags,
|
||||||
@@ -351,6 +323,10 @@ static ref_api_t gEngfuncs =
|
|||||||
&clgame.drawFuncs,
|
&clgame.drawFuncs,
|
||||||
|
|
||||||
&g_fsapi,
|
&g_fsapi,
|
||||||
|
#if XASH_PSP
|
||||||
|
P5Ram_Alloc,
|
||||||
|
P5Ram_Free,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static void R_UnloadProgs( void )
|
static void R_UnloadProgs( void )
|
||||||
@@ -372,33 +348,8 @@ static void R_UnloadProgs( void )
|
|||||||
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
|
memset( &ref.dllFuncs, 0, sizeof( ref.dllFuncs ));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
|
|
||||||
{
|
|
||||||
dst->version = TRI_API_VERSION;
|
|
||||||
dst->Begin = src->Begin;
|
|
||||||
dst->RenderMode = TriRenderMode;
|
|
||||||
dst->End = src->End;
|
|
||||||
dst->Color4f = TriColor4f;
|
|
||||||
dst->Color4ub = TriColor4ub;
|
|
||||||
dst->TexCoord2f = src->TexCoord2f;
|
|
||||||
dst->Vertex3f = src->Vertex3f;
|
|
||||||
dst->Vertex3fv = src->Vertex3fv;
|
|
||||||
dst->Brightness = TriBrightness;
|
|
||||||
dst->CullFace = TriCullFace;
|
|
||||||
dst->SpriteTexture = TriSpriteTexture;
|
|
||||||
dst->WorldToScreen = TriWorldToScreen;
|
|
||||||
dst->Fog = src->Fog;
|
|
||||||
dst->ScreenToWorld = src->ScreenToWorld;
|
|
||||||
dst->GetMatrix = src->GetMatrix;
|
|
||||||
dst->BoxInPVS = TriBoxInPVS;
|
|
||||||
dst->LightAtPoint = TriLightAtPoint;
|
|
||||||
dst->Color4fRendermode = TriColor4fRendermode;
|
|
||||||
dst->FogParams = src->FogParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
static qboolean R_LoadProgs( const char *name )
|
static qboolean R_LoadProgs( const char *name )
|
||||||
{
|
{
|
||||||
extern triangleapi_t gTriApi;
|
|
||||||
static ref_api_t gpEngfuncs;
|
static ref_api_t gpEngfuncs;
|
||||||
REFAPI GetRefAPI; // single export
|
REFAPI GetRefAPI; // single export
|
||||||
|
|
||||||
@@ -443,12 +394,18 @@ static qboolean R_LoadProgs( const char *name )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// initialize TriAPI callbacks
|
||||||
|
if( !ref.dllFuncs.getTriAPI( TRI_API_VERSION, &gTriApi ))
|
||||||
|
{
|
||||||
|
COM_FreeLibrary( ref.hInstance );
|
||||||
|
Con_Reportf( "R_LoadProgs: can't init TriAPI Interface: wrong version, %i must be %i\n", gTriApi.version, TRI_API_VERSION );
|
||||||
|
ref.hInstance = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
|
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
|
||||||
ref.initialized = true;
|
ref.initialized = true;
|
||||||
|
|
||||||
// initialize TriAPI callbacks
|
|
||||||
CL_FillTriAPIFromRef( &gTriApi, &ref.dllFuncs );
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ extern convar_t gl_clear;
|
|||||||
|
|
||||||
qboolean R_Init( void );
|
qboolean R_Init( void );
|
||||||
void R_Shutdown( void );
|
void R_Shutdown( void );
|
||||||
void R_UpdateRefState( void );
|
|
||||||
|
|
||||||
extern triangleapi_t gTriApi;
|
extern triangleapi_t gTriApi;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
s_dsp.c - digital signal processing algorithms for audio FX
|
s_dsp.c - digital signal processing algorithms for audio FX
|
||||||
Copyright (C) 2009 Uncle Mike
|
Copyright (C) 2009 Uncle Mike
|
||||||
|
Copyright (C) 2016-2024 Alibek Omarov
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@@ -333,7 +334,7 @@ DLY_MovePointer
|
|||||||
Checks overflow and moves pointer
|
Checks overflow and moves pointer
|
||||||
============
|
============
|
||||||
*/
|
*/
|
||||||
_inline void DLY_MovePointer( dly_t *dly )
|
static void DLY_MovePointer( dly_t *dly )
|
||||||
{
|
{
|
||||||
if( ++dly->idelayinput >= dly->cdelaysamplesmax )
|
if( ++dly->idelayinput >= dly->cdelaysamplesmax )
|
||||||
dly->idelayinput = 0;
|
dly->idelayinput = 0;
|
||||||
@@ -806,13 +807,9 @@ DSP_Process
|
|||||||
(xash dsp interface)
|
(xash dsp interface)
|
||||||
===========
|
===========
|
||||||
*/
|
*/
|
||||||
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount )
|
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount )
|
||||||
{
|
{
|
||||||
if( dsp_off.value )
|
if( dsp_off.value || !sampleCount )
|
||||||
return;
|
|
||||||
|
|
||||||
// don't process DSP while in menu
|
|
||||||
if( cls.key_dest == key_menu || !sampleCount )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// preset is already installed by CheckNewDspPresets
|
// preset is already installed by CheckNewDspPresets
|
||||||
@@ -833,7 +830,7 @@ DSP_ClearState
|
|||||||
*/
|
*/
|
||||||
void DSP_ClearState( void )
|
void DSP_ClearState( void )
|
||||||
{
|
{
|
||||||
Cvar_SetValue( "room_type", 0.0f );
|
Cvar_DirectSet( &room_type, "0" );
|
||||||
SX_ReloadRoomFX();
|
SX_ReloadRoomFX();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,15 +889,15 @@ void CheckNewDspPresets( void )
|
|||||||
|
|
||||||
cur = ptable + idsp_room;
|
cur = ptable + idsp_room;
|
||||||
|
|
||||||
Cvar_SetValue( "room_lp", cur->room_lp );
|
Cvar_DirectSetValue( &sxmod_lowpass, cur->room_lp );
|
||||||
Cvar_SetValue( "room_mod", cur->room_mod );
|
Cvar_DirectSetValue( &sxmod_mod, cur->room_mod );
|
||||||
Cvar_SetValue( "room_size", cur->room_size );
|
Cvar_DirectSetValue( &sxrvb_size, cur->room_size );
|
||||||
Cvar_SetValue( "room_refl", cur->room_refl );
|
Cvar_DirectSetValue( &sxrvb_feedback, cur->room_refl );
|
||||||
Cvar_SetValue( "room_rvblp", cur->room_rvblp );
|
Cvar_DirectSetValue( &sxrvb_lp, cur->room_rvblp );
|
||||||
Cvar_SetValue( "room_delay", cur->room_delay );
|
Cvar_DirectSetValue( &sxdly_delay, cur->room_delay );
|
||||||
Cvar_SetValue( "room_feedback", cur->room_feedback );
|
Cvar_DirectSetValue( &sxdly_feedback, cur->room_feedback );
|
||||||
Cvar_SetValue( "room_dlylp", cur->room_dlylp );
|
Cvar_DirectSetValue( &sxdly_lp, cur->room_dlylp );
|
||||||
Cvar_SetValue( "room_left", cur->room_left );
|
Cvar_DirectSetValue( &sxste_delay, cur->room_left );
|
||||||
}
|
}
|
||||||
|
|
||||||
room_typeprev = idsp_room;
|
room_typeprev = idsp_room;
|
||||||
@@ -929,7 +926,7 @@ static void SX_Profiling_f( void )
|
|||||||
|
|
||||||
if( Cmd_Argc() > 1 )
|
if( Cmd_Argc() > 1 )
|
||||||
{
|
{
|
||||||
Cvar_SetValue( "room_type", Q_atof( Cmd_Argv( 1 )));
|
Cvar_DirectSetValue( &room_type, Q_atof( Cmd_Argv( 1 )));
|
||||||
SX_ReloadRoomFX();
|
SX_ReloadRoomFX();
|
||||||
CheckNewDspPresets(); // we just need idsp_room immediately, for message below
|
CheckNewDspPresets(); // we just need idsp_room immediately, for message below
|
||||||
}
|
}
|
||||||
@@ -939,7 +936,7 @@ static void SX_Profiling_f( void )
|
|||||||
start = Sys_DoubleTime();
|
start = Sys_DoubleTime();
|
||||||
for( calls = 10000; calls; calls-- )
|
for( calls = 10000; calls; calls-- )
|
||||||
{
|
{
|
||||||
DSP_Process( idsp_room, testbuffer, 512 );
|
DSP_Process( testbuffer, 512 );
|
||||||
}
|
}
|
||||||
end = Sys_DoubleTime();
|
end = Sys_DoubleTime();
|
||||||
|
|
||||||
@@ -947,7 +944,7 @@ static void SX_Profiling_f( void )
|
|||||||
|
|
||||||
if( Cmd_Argc() > 1 )
|
if( Cmd_Argc() > 1 )
|
||||||
{
|
{
|
||||||
Cvar_SetValue( "room_type", oldroom );
|
Cvar_DirectSetValue( &room_type, oldroom );
|
||||||
SX_ReloadRoomFX();
|
SX_ReloadRoomFX();
|
||||||
CheckNewDspPresets();
|
CheckNewDspPresets();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ GNU General Public License for more details.
|
|||||||
// than could actually be referenced during gameplay,
|
// than could actually be referenced during gameplay,
|
||||||
// because we don't want to free anything until we are
|
// because we don't want to free anything until we are
|
||||||
// sure we won't need it.
|
// sure we won't need it.
|
||||||
|
#if XASH_PSP
|
||||||
|
#define MAX_SFX 2048
|
||||||
|
#else
|
||||||
#define MAX_SFX 8192
|
#define MAX_SFX 8192
|
||||||
|
#endif
|
||||||
#define MAX_SFX_HASH (MAX_SFX/4)
|
#define MAX_SFX_HASH (MAX_SFX/4)
|
||||||
|
|
||||||
static int s_numSfx = 0;
|
static int s_numSfx = 0;
|
||||||
|
|||||||
@@ -648,20 +648,6 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
|
|||||||
|
|
||||||
// Init client entity mouth movement vars
|
// Init client entity mouth movement vars
|
||||||
SND_InitMouth( ent, chan );
|
SND_InitMouth( ent, chan );
|
||||||
|
|
||||||
for( ch_idx = NUM_AMBIENTS, check = channels + NUM_AMBIENTS; ch_idx < MAX_DYNAMIC_CHANNELS; ch_idx++, check++)
|
|
||||||
{
|
|
||||||
if( check == target_chan ) continue;
|
|
||||||
|
|
||||||
if( check->sfx == sfx && !check->pMixer.sample )
|
|
||||||
{
|
|
||||||
// skip up to 0.1 seconds of audio
|
|
||||||
int skip = COM_RandomLong( 0, (long)( 0.1f * check->sfx->cache->rate ));
|
|
||||||
|
|
||||||
S_SetSampleStart( check, sfx->cache, skip );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -999,7 +999,8 @@ void MIX_PaintChannels( int endtime )
|
|||||||
MIX_UpsampleAllPaintbuffers( end, count );
|
MIX_UpsampleAllPaintbuffers( end, count );
|
||||||
|
|
||||||
// process all sounds with DSP
|
// process all sounds with DSP
|
||||||
DSP_Process( idsp_room, MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
|
if( cls.key_dest != key_menu )
|
||||||
|
DSP_Process( MIX_GetPFrontFromIPaint( IROOMBUFFER ), count );
|
||||||
|
|
||||||
// add music or soundtrack from movie (no dsp)
|
// add music or soundtrack from movie (no dsp)
|
||||||
MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() );
|
MIX_MixPaintbuffers( IPAINTBUFFER, IROOMBUFFER, IPAINTBUFFER, count, S_GetMasterVolume() );
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int
|
|||||||
|
|
||||||
// open stream
|
// open stream
|
||||||
s_bgTrack.stream = FS_OpenStream( introTrack );
|
s_bgTrack.stream = FS_OpenStream( introTrack );
|
||||||
|
|
||||||
Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current ));
|
Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current ));
|
||||||
memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade
|
memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade
|
||||||
s_bgTrack.source = cls.key_dest;
|
s_bgTrack.source = cls.key_dest;
|
||||||
|
|||||||
@@ -16,204 +16,6 @@ GNU General Public License for more details.
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
// hardcoded macros to test for zero crossing
|
|
||||||
#define ZERO_X_8( b ) (( b ) < 2 && ( b ) > -2 )
|
|
||||||
#define ZERO_X_16( b ) (( b ) < 512 && ( b ) > -512 )
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Search backward for a zero crossing starting at sample
|
|
||||||
// Input : sample - starting point
|
|
||||||
// Output : position of zero crossing
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample )
|
|
||||||
{
|
|
||||||
if( pWaveData == NULL )
|
|
||||||
return sample;
|
|
||||||
|
|
||||||
if( pWaveData->type == WF_PCMDATA )
|
|
||||||
{
|
|
||||||
int sampleSize;
|
|
||||||
|
|
||||||
sampleSize = pWaveData->width * pWaveData->channels;
|
|
||||||
|
|
||||||
// this can never be zero -- other functions divide by this.
|
|
||||||
// This should never happen, but avoid crashing
|
|
||||||
if( sampleSize <= 0 ) sampleSize = 1;
|
|
||||||
|
|
||||||
if( pWaveData->width == 1 )
|
|
||||||
{
|
|
||||||
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
|
|
||||||
qboolean zero = false;
|
|
||||||
|
|
||||||
if( pWaveData->channels == 1 )
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_8( *pData ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample--;
|
|
||||||
pData--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample--;
|
|
||||||
pData--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
|
||||||
qboolean zero = false;
|
|
||||||
|
|
||||||
if( pWaveData->channels == 1 )
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_16(*pData ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pData--;
|
|
||||||
sample--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample--;
|
|
||||||
pData--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Search forward for a zero crossing
|
|
||||||
// Input : sample - starting point
|
|
||||||
// Output : position of found zero crossing
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample )
|
|
||||||
{
|
|
||||||
if( pWaveData == NULL )
|
|
||||||
return sample;
|
|
||||||
|
|
||||||
if( pWaveData->type == WF_PCMDATA )
|
|
||||||
{
|
|
||||||
int sampleSize;
|
|
||||||
|
|
||||||
sampleSize = pWaveData->width * pWaveData->channels;
|
|
||||||
|
|
||||||
// this can never be zero -- other functions divide by this.
|
|
||||||
// This should never happen, but avoid crashing
|
|
||||||
if( sampleSize <= 0 ) sampleSize = 1;
|
|
||||||
|
|
||||||
if( pWaveData->width == 1 ) // 8-bit
|
|
||||||
{
|
|
||||||
signed char *pData = (signed char *)(pWaveData->buffer + sample * sampleSize);
|
|
||||||
qboolean zero = false;
|
|
||||||
|
|
||||||
if( pWaveData->channels == 1 )
|
|
||||||
{
|
|
||||||
while( sample < pWaveData->samples && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_8( *pData ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample++;
|
|
||||||
pData++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while( sample < pWaveData->samples && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_8( *pData ) && ZERO_X_8( pData[1] ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample++;
|
|
||||||
pData++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
short *pData = (short *)(pWaveData->buffer + sample * sampleSize);
|
|
||||||
qboolean zero = false;
|
|
||||||
|
|
||||||
if( pWaveData->channels == 1 )
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_16( *pData ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pData++;
|
|
||||||
sample++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while( sample > 0 && !zero )
|
|
||||||
{
|
|
||||||
if( ZERO_X_16( *pData ) && ZERO_X_16( pData[1] ))
|
|
||||||
{
|
|
||||||
zero = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sample++;
|
|
||||||
pData++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: wrap the position wrt looping
|
// Purpose: wrap the position wrt looping
|
||||||
// Input : samplePosition - absolute position
|
// Input : samplePosition - absolute position
|
||||||
@@ -279,28 +81,3 @@ int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int s
|
|||||||
|
|
||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the current position to newPosition
|
|
||||||
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition )
|
|
||||||
{
|
|
||||||
if( pSource )
|
|
||||||
newPosition = S_ZeroCrossingAfter( pSource, newPosition );
|
|
||||||
|
|
||||||
pChan->pMixer.sample = newPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
// end playback at newEndPosition
|
|
||||||
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition )
|
|
||||||
{
|
|
||||||
// forced end of zero means play the whole sample
|
|
||||||
if( !newEndPosition ) newEndPosition = 1;
|
|
||||||
|
|
||||||
if( pSource )
|
|
||||||
newEndPosition = S_ZeroCrossingBefore( pSource, newEndPosition );
|
|
||||||
|
|
||||||
// past current position? limit.
|
|
||||||
if( newEndPosition < pChan->pMixer.sample )
|
|
||||||
newEndPosition = pChan->pMixer.sample;
|
|
||||||
|
|
||||||
pChan->pMixer.forcedEndSample = newEndPosition;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,10 +18,126 @@ GNU General Public License for more details.
|
|||||||
#include "const.h"
|
#include "const.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#define TRIM_SCAN_MAX 255
|
||||||
|
#define TRIM_SAMPLES_BELOW_8 2
|
||||||
|
#define TRIM_SAMPLES_BELOW_16 512 // 65k * 2 / 256
|
||||||
|
|
||||||
|
#define CVOXFILESENTENCEMAX 4096
|
||||||
|
|
||||||
static int cszrawsentences = 0;
|
static int cszrawsentences = 0;
|
||||||
static char *rgpszrawsentence[CVOXFILESENTENCEMAX];
|
static char *rgpszrawsentence[CVOXFILESENTENCEMAX];
|
||||||
static const char *voxperiod = "_period", *voxcomma = "_comma";
|
static const char *voxperiod = "_period", *voxcomma = "_comma";
|
||||||
|
|
||||||
|
static qboolean S_ShouldTrimSample8( const int8_t *buf, int channels )
|
||||||
|
{
|
||||||
|
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_8 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_8 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static qboolean S_ShouldTrimSample16( const int16_t *buf, int channels )
|
||||||
|
{
|
||||||
|
if( abs( buf[0] ) > TRIM_SAMPLES_BELOW_16 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( channels >= 2 && abs( buf[1] ) > TRIM_SAMPLES_BELOW_16 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int S_TrimStart( const wavdata_t *wav, int start )
|
||||||
|
{
|
||||||
|
size_t channels = wav->channels, width = wav->width, i;
|
||||||
|
|
||||||
|
if( wav->type != WF_PCMDATA )
|
||||||
|
return start;
|
||||||
|
|
||||||
|
if( width == 1 )
|
||||||
|
{
|
||||||
|
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * start];
|
||||||
|
|
||||||
|
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||||
|
{
|
||||||
|
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||||
|
break;
|
||||||
|
|
||||||
|
start += channels;
|
||||||
|
data += channels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( width == 2 )
|
||||||
|
{
|
||||||
|
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * start];
|
||||||
|
|
||||||
|
for( i = 0; i < TRIM_SCAN_MAX && start < wav->samples; i++ )
|
||||||
|
{
|
||||||
|
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||||
|
break;
|
||||||
|
|
||||||
|
start += channels;
|
||||||
|
data += channels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int S_TrimEnd( const wavdata_t *wav, int end )
|
||||||
|
{
|
||||||
|
size_t channels = wav->channels, width = wav->width, i;
|
||||||
|
|
||||||
|
if( wav->type != WF_PCMDATA )
|
||||||
|
return end;
|
||||||
|
|
||||||
|
if( width == 1 )
|
||||||
|
{
|
||||||
|
const int8_t *data = (const int8_t *)&wav->buffer[channels * width * end];
|
||||||
|
|
||||||
|
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||||
|
{
|
||||||
|
if( !S_ShouldTrimSample8( data, wav->channels ))
|
||||||
|
break;
|
||||||
|
|
||||||
|
end -= channels;
|
||||||
|
data -= channels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( width == 2 )
|
||||||
|
{
|
||||||
|
const int16_t *data = (const int16_t *)&wav->buffer[channels * width * end];
|
||||||
|
|
||||||
|
for( i = 0; i < TRIM_SCAN_MAX && end > 0; i++ )
|
||||||
|
{
|
||||||
|
if( !S_ShouldTrimSample16( data, wav->channels ))
|
||||||
|
break;
|
||||||
|
|
||||||
|
end -= channels;
|
||||||
|
data -= channels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void S_TrimStartEndTimes( channel_t *ch, wavdata_t *wav, int start, int end )
|
||||||
|
{
|
||||||
|
ch->pMixer.sample = start = S_TrimStart( wav, start );
|
||||||
|
|
||||||
|
// don't overrun the buffer while trimming end
|
||||||
|
if( end == 0 )
|
||||||
|
end = wav->samples - wav->channels;
|
||||||
|
|
||||||
|
if( end < start )
|
||||||
|
end = start;
|
||||||
|
|
||||||
|
ch->pMixer.forcedEndSample = S_TrimEnd( wav, end );
|
||||||
|
}
|
||||||
|
|
||||||
// return number of samples mixed
|
// return number of samples mixed
|
||||||
int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset )
|
int VOX_MixDataToDevice( channel_t *pchan, int sampleCount, int outputRate, int outputOffset )
|
||||||
{
|
{
|
||||||
@@ -78,11 +194,7 @@ void VOX_LoadWord( channel_t *ch )
|
|||||||
|
|
||||||
if( end <= start ) end = 0;
|
if( end <= start ) end = 0;
|
||||||
|
|
||||||
if( start )
|
S_TrimStartEndTimes( ch, data, start * 0.01f * samples, end * 0.01f * samples );
|
||||||
S_SetSampleStart( ch, data, start * 0.01f * samples );
|
|
||||||
|
|
||||||
if( end )
|
|
||||||
S_SetSampleEnd( ch, data, end * 0.01f * samples );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VOX_FreeWord( channel_t *ch )
|
void VOX_FreeWord( channel_t *ch )
|
||||||
|
|||||||
@@ -201,9 +201,15 @@ typedef struct
|
|||||||
|
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
#define MAX_DYNAMIC_CHANNELS (20 + NUM_AMBIENTS)
|
||||||
|
#define MAX_CHANNELS (128 + MAX_DYNAMIC_CHANNELS)
|
||||||
|
#define MAX_RAW_CHANNELS 16
|
||||||
|
#else
|
||||||
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
|
#define MAX_DYNAMIC_CHANNELS (60 + NUM_AMBIENTS)
|
||||||
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
|
#define MAX_CHANNELS (256 + MAX_DYNAMIC_CHANNELS) // Scourge Of Armagon has too many static sounds on hip2m4.bsp
|
||||||
#define MAX_RAW_CHANNELS 48
|
#define MAX_RAW_CHANNELS 48
|
||||||
|
#endif
|
||||||
#define MAX_RAW_SAMPLES 8192
|
#define MAX_RAW_SAMPLES 8192
|
||||||
|
|
||||||
extern sound_t ambient_sfx[NUM_AMBIENTS];
|
extern sound_t ambient_sfx[NUM_AMBIENTS];
|
||||||
@@ -255,8 +261,7 @@ void S_InitSounds( void );
|
|||||||
void SX_Init( void );
|
void SX_Init( void );
|
||||||
void SX_Free( void );
|
void SX_Free( void );
|
||||||
void CheckNewDspPresets( void );
|
void CheckNewDspPresets( void );
|
||||||
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount );
|
void DSP_Process( portable_samplepair_t *pbfront, int sampleCount );
|
||||||
float DSP_GetGain( int idsp );
|
|
||||||
void DSP_ClearState( void );
|
void DSP_ClearState( void );
|
||||||
|
|
||||||
qboolean S_Init( void );
|
qboolean S_Init( void );
|
||||||
@@ -305,8 +310,6 @@ int S_ZeroCrossingAfter( wavdata_t *pWaveData, int sample );
|
|||||||
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample );
|
int S_ZeroCrossingBefore( wavdata_t *pWaveData, int sample );
|
||||||
int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop );
|
int S_ConvertLoopedPosition( wavdata_t *pSource, int samplePosition, qboolean use_loop );
|
||||||
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, qboolean use_loop );
|
int S_GetOutputData( wavdata_t *pSource, void **pData, int samplePosition, int sampleCount, qboolean use_loop );
|
||||||
void S_SetSampleStart( channel_t *pChan, wavdata_t *pSource, int newPosition );
|
|
||||||
void S_SetSampleEnd( channel_t *pChan, wavdata_t *pSource, int newEndPosition );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// s_vox.c
|
// s_vox.c
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
static CVAR_DEFINE( window_width, "width", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen width" );
|
||||||
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
static CVAR_DEFINE( window_height, "height", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen height" );
|
||||||
static CVAR_DEFINE( vid_brightness, "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
|
|
||||||
static CVAR_DEFINE( vid_gamma, "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
|
|
||||||
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
|
static CVAR_DEFINE_AUTO( vid_mode, "0", FCVAR_RENDERINFO, "current video mode index (used only for storage)" );
|
||||||
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
|
static CVAR_DEFINE_AUTO( vid_rotate, "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "screen rotation (0-3)" );
|
||||||
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
static CVAR_DEFINE_AUTO( vid_scale, "1.0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "pixel scale" );
|
||||||
@@ -36,19 +34,6 @@ CVAR_DEFINE( window_ypos, "_window_ypos", "-1", FCVAR_RENDERINFO, "window positi
|
|||||||
|
|
||||||
glwstate_t glw_state;
|
glwstate_t glw_state;
|
||||||
|
|
||||||
/*
|
|
||||||
=================
|
|
||||||
VID_StartupGamma
|
|
||||||
=================
|
|
||||||
*/
|
|
||||||
void VID_StartupGamma( void )
|
|
||||||
{
|
|
||||||
BuildGammaTable( vid_gamma.value, vid_brightness.value );
|
|
||||||
Con_Reportf( "VID_StartupGamma: gamma %g brightness %g\n", vid_gamma.value, vid_brightness.value );
|
|
||||||
ClearBits( vid_brightness.flags, FCVAR_CHANGED );
|
|
||||||
ClearBits( vid_gamma.flags, FCVAR_CHANGED );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
VID_InitDefaultResolution
|
VID_InitDefaultResolution
|
||||||
@@ -224,8 +209,6 @@ void VID_Init( void )
|
|||||||
Cvar_RegisterVariable( &vid_scale );
|
Cvar_RegisterVariable( &vid_scale );
|
||||||
Cvar_RegisterVariable( &vid_fullscreen );
|
Cvar_RegisterVariable( &vid_fullscreen );
|
||||||
Cvar_RegisterVariable( &vid_maximized );
|
Cvar_RegisterVariable( &vid_maximized );
|
||||||
Cvar_RegisterVariable( &vid_brightness );
|
|
||||||
Cvar_RegisterVariable( &vid_gamma );
|
|
||||||
Cvar_RegisterVariable( &window_xpos );
|
Cvar_RegisterVariable( &window_xpos );
|
||||||
Cvar_RegisterVariable( &window_ypos );
|
Cvar_RegisterVariable( &window_ypos );
|
||||||
|
|
||||||
@@ -233,5 +216,6 @@ void VID_Init( void )
|
|||||||
// but supported mode list is filled by backends, so numbers are not portable any more
|
// but supported mode list is filled by backends, so numbers are not portable any more
|
||||||
Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" );
|
Cmd_AddRestrictedCommand( "vid_setmode", VID_Mode_f, "display video mode" );
|
||||||
|
|
||||||
|
V_Init(); // init gamma
|
||||||
R_Init(); // init renderer
|
R_Init(); // init renderer
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,5 @@ void R_SaveVideoMode( int w, int h, int render_w, int render_h, qboolean maximiz
|
|||||||
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
void VID_SetDisplayTransform( int *render_w, int *render_h );
|
||||||
void VID_CheckChanges( void );
|
void VID_CheckChanges( void );
|
||||||
const char *VID_GetModeString( int vid_mode );
|
const char *VID_GetModeString( int vid_mode );
|
||||||
void VID_StartupGamma( void );
|
|
||||||
|
|
||||||
#endif // VID_COMMON
|
#endif // VID_COMMON
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ GNU General Public License for more details.
|
|||||||
#define VOX_H
|
#define VOX_H
|
||||||
|
|
||||||
#define CVOXWORDMAX 64
|
#define CVOXWORDMAX 64
|
||||||
#define CVOXFILESENTENCEMAX 4096
|
|
||||||
|
|
||||||
#define SENTENCE_INDEX -99999 // unique sentence index
|
#define SENTENCE_INDEX -99999 // unique sentence index
|
||||||
|
|
||||||
|
|||||||
175
engine/common/build.c
Normal file
175
engine/common/build.c
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/*
|
||||||
|
build.c - returns a engine build number
|
||||||
|
Copyright (C) 2010 Uncle Mike
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
static char *date = __DATE__ ;
|
||||||
|
static char *mon[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
|
static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||||
|
|
||||||
|
// returns days since Apr 1 2015
|
||||||
|
int Q_buildnum( void )
|
||||||
|
{
|
||||||
|
int m = 0, d = 0, y = 0;
|
||||||
|
static int b = 0;
|
||||||
|
|
||||||
|
if( b != 0 ) return b;
|
||||||
|
|
||||||
|
for( m = 0; m < 11; m++ )
|
||||||
|
{
|
||||||
|
if( !Q_strnicmp( &date[0], mon[m], 3 ))
|
||||||
|
break;
|
||||||
|
d += mond[m];
|
||||||
|
}
|
||||||
|
|
||||||
|
d += Q_atoi( &date[4] ) - 1;
|
||||||
|
y = Q_atoi( &date[7] ) - 1900;
|
||||||
|
b = d + (int)((y - 1) * 365.25f );
|
||||||
|
|
||||||
|
if((( y % 4 ) == 0 ) && m > 1 )
|
||||||
|
{
|
||||||
|
b += 1;
|
||||||
|
}
|
||||||
|
b -= 41728; // Apr 1 2015
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
Q_buildnum_compat
|
||||||
|
|
||||||
|
Returns a Xash3D build number. This is left for compability with original Xash3D.
|
||||||
|
IMPORTANT: this value must be changed ONLY after updating to newer Xash3D
|
||||||
|
IMPORTANT: this value must be acquired through "build" cvar.
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
int Q_buildnum_compat( void )
|
||||||
|
{
|
||||||
|
// do not touch this! Only author of Xash3D can increase buildnumbers!
|
||||||
|
return 4529;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
Q_buildos
|
||||||
|
|
||||||
|
Returns current name of operating system. Without any spaces.
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
const char *Q_buildos( void )
|
||||||
|
{
|
||||||
|
const char *osname;
|
||||||
|
|
||||||
|
#if XASH_MINGW
|
||||||
|
osname = "win32-mingw";
|
||||||
|
#elif XASH_WIN32
|
||||||
|
osname = "win32";
|
||||||
|
#elif XASH_ANDROID
|
||||||
|
osname = "android";
|
||||||
|
#elif XASH_LINUX
|
||||||
|
osname = "linux";
|
||||||
|
#elif XASH_APPLE
|
||||||
|
osname = "apple";
|
||||||
|
#elif XASH_FREEBSD
|
||||||
|
osname = "freebsd";
|
||||||
|
#elif XASH_NETBSD
|
||||||
|
osname = "netbsd";
|
||||||
|
#elif XASH_OPENBSD
|
||||||
|
osname = "openbsd";
|
||||||
|
#elif XASH_EMSCRIPTEN
|
||||||
|
osname = "emscripten";
|
||||||
|
#elif XASH_DOS4GW
|
||||||
|
osname = "DOS4GW";
|
||||||
|
#elif XASH_PSP
|
||||||
|
osname = "psp";
|
||||||
|
#else
|
||||||
|
#error "Place your operating system name here! If this is a mistake, try to fix conditions above and report a bug"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return osname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
Q_buildos
|
||||||
|
|
||||||
|
Returns current name of operating system. Without any spaces.
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
const char *Q_buildarch( void )
|
||||||
|
{
|
||||||
|
const char *archname;
|
||||||
|
|
||||||
|
#if XASH_AMD64
|
||||||
|
archname = "amd64";
|
||||||
|
#elif XASH_X86
|
||||||
|
archname = "i386";
|
||||||
|
#elif XASH_ARM && XASH_64BIT
|
||||||
|
archname = "arm64";
|
||||||
|
#elif XASH_ARM
|
||||||
|
archname = "armv"
|
||||||
|
#if XASH_ARM == 8
|
||||||
|
"8_32" // for those who (mis)using 32-bit OS on 64-bit CPU
|
||||||
|
#elif XASH_ARM == 7
|
||||||
|
"7"
|
||||||
|
#elif XASH_ARM == 6
|
||||||
|
"6"
|
||||||
|
#elif XASH_ARM == 5
|
||||||
|
"5"
|
||||||
|
#elif XASH_ARM == 4
|
||||||
|
"4"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if XASH_ARM_HARDFP
|
||||||
|
"hf";
|
||||||
|
#else
|
||||||
|
"l";
|
||||||
|
#endif
|
||||||
|
#elif XASH_MIPS && defined XASH_BIG_ENDIAN
|
||||||
|
archname = "mips";
|
||||||
|
#elif XASH_MIPS && defined XASH_LITTLE_ENDIAN
|
||||||
|
archname = "mipsel";
|
||||||
|
#elif XASH_JS
|
||||||
|
archname = "javascript";
|
||||||
|
#elif XASH_E2K
|
||||||
|
archname = "e2k";
|
||||||
|
#else
|
||||||
|
#error "Place your architecture name here! If this is a mistake, try to fix conditions above and report a bug"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return archname;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=============
|
||||||
|
Q_buildcommit
|
||||||
|
|
||||||
|
Returns a short hash of current commit in VCS as string.
|
||||||
|
XASH_BUILD_COMMIT must be passed in quotes
|
||||||
|
|
||||||
|
if XASH_BUILD_COMMIT is not defined,
|
||||||
|
Q_buildcommit will identify this build as "notset"
|
||||||
|
=============
|
||||||
|
*/
|
||||||
|
const char *Q_buildcommit( void )
|
||||||
|
{
|
||||||
|
#ifdef XASH_BUILD_COMMIT
|
||||||
|
return XASH_BUILD_COMMIT;
|
||||||
|
#else
|
||||||
|
return "notset";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@@ -141,6 +141,7 @@ typedef enum
|
|||||||
#define MAX_DECALS 256 // touching TE_DECAL messages, etc
|
#define MAX_DECALS 256 // touching TE_DECAL messages, etc
|
||||||
#define MAX_STATIC_ENTITIES 32 // static entities that moved on the client when level is spawn
|
#define MAX_STATIC_ENTITIES 32 // static entities that moved on the client when level is spawn
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GameState (&host.game)
|
#define GameState (&host.game)
|
||||||
|
|
||||||
@@ -302,8 +303,12 @@ typedef struct host_parm_s
|
|||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
|
||||||
|
// ==== shared through RefAPI's ref_host_t
|
||||||
double realtime; // host.curtime
|
double realtime; // host.curtime
|
||||||
double frametime; // time between engine frames
|
double frametime; // time between engine frames
|
||||||
|
uint features; // custom features that enables by mod-maker request
|
||||||
|
// ==== shared through RefAPI's ref_host_t
|
||||||
|
|
||||||
double realframetime; // for some system events, e.g. console animations
|
double realframetime; // for some system events, e.g. console animations
|
||||||
|
|
||||||
uint framecount; // global framecount
|
uint framecount; // global framecount
|
||||||
@@ -344,8 +349,6 @@ typedef struct host_parm_s
|
|||||||
poolhandle_t imagepool; // imagelib mempool
|
poolhandle_t imagepool; // imagelib mempool
|
||||||
poolhandle_t soundpool; // soundlib mempool
|
poolhandle_t soundpool; // soundlib mempool
|
||||||
|
|
||||||
uint features; // custom features that enables by mod-maker request
|
|
||||||
|
|
||||||
// for IN_MouseMove() easy access
|
// for IN_MouseMove() easy access
|
||||||
int window_center_x;
|
int window_center_x;
|
||||||
int window_center_y;
|
int window_center_y;
|
||||||
@@ -552,7 +555,7 @@ qboolean Host_IsLocalGame( void );
|
|||||||
qboolean Host_IsLocalClient( void );
|
qboolean Host_IsLocalClient( void );
|
||||||
void Host_ShutdownServer( void );
|
void Host_ShutdownServer( void );
|
||||||
void Host_Error( const char *error, ... ) _format( 1 );
|
void Host_Error( const char *error, ... ) _format( 1 );
|
||||||
void Host_PrintEngineFeatures( int features );
|
void Host_ValidateEngineFeatures( uint32_t features );
|
||||||
void Host_Frame( float time );
|
void Host_Frame( float time );
|
||||||
void Host_InitDecals( void );
|
void Host_InitDecals( void );
|
||||||
void Host_Credits( void );
|
void Host_Credits( void );
|
||||||
@@ -721,7 +724,6 @@ int R_CreateDecalList( struct decallist_s *pList );
|
|||||||
void R_ClearAllDecals( void );
|
void R_ClearAllDecals( void );
|
||||||
void CL_ClearStaticEntities( void );
|
void CL_ClearStaticEntities( void );
|
||||||
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
|
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
|
||||||
struct cl_entity_s *CL_GetEntityByIndex( int index );
|
|
||||||
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
|
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
|
||||||
void CL_HudMessage( const char *pMessage );
|
void CL_HudMessage( const char *pMessage );
|
||||||
const char *CL_MsgInfo( int cmd );
|
const char *CL_MsgInfo( int cmd );
|
||||||
@@ -810,8 +812,13 @@ void S_StopBackgroundTrack( void );
|
|||||||
void S_StopAllSounds( qboolean ambient );
|
void S_StopAllSounds( qboolean ambient );
|
||||||
|
|
||||||
// gamma routines
|
// gamma routines
|
||||||
void BuildGammaTable( float gamma, float brightness );
|
|
||||||
byte LightToTexGamma( byte b );
|
byte LightToTexGamma( byte b );
|
||||||
|
byte TextureToGamma( byte );
|
||||||
|
uint LightToTexGammaEx( uint );
|
||||||
|
uint ScreenGammaTable( uint );
|
||||||
|
uint LinearGammaTable( uint );
|
||||||
|
void V_Init( void );
|
||||||
|
void V_CheckGamma( void );
|
||||||
|
|
||||||
//
|
//
|
||||||
// identification.c
|
// identification.c
|
||||||
|
|||||||
@@ -563,6 +563,27 @@ void Cvar_RegisterVariable( convar_t *var )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static qboolean Cvar_CanSet( const convar_t *cv )
|
||||||
|
{
|
||||||
|
if( FBitSet( cv->flags, FCVAR_READ_ONLY ))
|
||||||
|
{
|
||||||
|
Con_Printf( "%s is read-only.\n", cv->name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FBitSet( cv->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
||||||
|
{
|
||||||
|
Con_Printf( "%s is cheat protected.\n", cv->name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// just tell user about deferred changes
|
||||||
|
if( FBitSet( cv->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
||||||
|
Con_Printf( "%s will be changed upon restarting.\n", cv->name );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_Set2
|
Cvar_Set2
|
||||||
@@ -632,22 +653,9 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
|||||||
force = true;
|
force = true;
|
||||||
|
|
||||||
if( !force )
|
if( !force )
|
||||||
{
|
{
|
||||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
if( !Cvar_CanSet( var ))
|
||||||
{
|
|
||||||
Con_Printf( "%s is read-only.\n", var->name );
|
|
||||||
return var;
|
return var;
|
||||||
}
|
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
|
||||||
{
|
|
||||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just tell user about deferred changes
|
|
||||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
|
||||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pszValue = Cvar_ValidateString( var, value );
|
pszValue = Cvar_ValidateString( var, value );
|
||||||
@@ -694,21 +702,8 @@ void Cvar_DirectSet( convar_t *var, const char *value )
|
|||||||
return; // how this possible?
|
return; // how this possible?
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
if( !Cvar_CanSet( var ))
|
||||||
{
|
|
||||||
Con_Printf( "%s is read-only.\n", var->name );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
|
||||||
{
|
|
||||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just tell user about deferred changes
|
|
||||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
|
||||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
|
||||||
|
|
||||||
// check value
|
// check value
|
||||||
if( !value )
|
if( !value )
|
||||||
@@ -741,6 +736,24 @@ void Cvar_DirectSet( convar_t *var, const char *value )
|
|||||||
Cvar_Changed( var );
|
Cvar_Changed( var );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
============
|
||||||
|
Cvar_DirectSetValue
|
||||||
|
|
||||||
|
functionally is the same as Cvar_SetValue but for direct cvar access
|
||||||
|
============
|
||||||
|
*/
|
||||||
|
void Cvar_DirectSetValue( convar_t *var, float value )
|
||||||
|
{
|
||||||
|
char val[32];
|
||||||
|
|
||||||
|
if( fabs( value - (int)value ) < 0.000001 )
|
||||||
|
Q_snprintf( val, sizeof( val ), "%d", (int)value );
|
||||||
|
else Q_snprintf( val, sizeof( val ), "%f", value );
|
||||||
|
|
||||||
|
Cvar_DirectSet( var, val );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_FullSet
|
Cvar_FullSet
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ convar_t *Cvar_Getf( const char *var_name, int flags, const char *description, c
|
|||||||
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
|
void Cvar_LookupVars( int checkbit, void *buffer, void *ptr, setpair_t callback );
|
||||||
void Cvar_FullSet( const char *var_name, const char *value, int flags );
|
void Cvar_FullSet( const char *var_name, const char *value, int flags );
|
||||||
void Cvar_DirectSet( convar_t *var, const char *value );
|
void Cvar_DirectSet( convar_t *var, const char *value );
|
||||||
|
void Cvar_DirectSetValue( convar_t *var, float value );
|
||||||
void Cvar_Set( const char *var_name, const char *value );
|
void Cvar_Set( const char *var_name, const char *value );
|
||||||
void Cvar_SetValue( const char *var_name, float value );
|
void Cvar_SetValue( const char *var_name, float value );
|
||||||
const char *Cvar_BuildAutoDescription( const char *szName, int flags );
|
const char *Cvar_BuildAutoDescription( const char *szName, int flags );
|
||||||
|
|||||||
@@ -247,4 +247,14 @@ void CL_HudMessage( const char *pMessage )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte TextureToGamma( byte b )
|
||||||
|
{
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte LightToTexGamma( byte b )
|
||||||
|
{
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // XASH_DEDICATED
|
#endif // XASH_DEDICATED
|
||||||
|
|||||||
4556
engine/common/filesystem.c
Normal file
4556
engine/common/filesystem.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
gamma.c - gamma routines
|
|
||||||
Copyright (C) 2011 Uncle Mike
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "xash3d_mathlib.h"
|
|
||||||
#include "enginefeatures.h"
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Gamma conversion support
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
static byte lightgammatable[256];
|
|
||||||
static int lineargammatable[1024];
|
|
||||||
static int screengammatable[1024];
|
|
||||||
|
|
||||||
void BuildGammaTable( float lightgamma, float brightness )
|
|
||||||
{
|
|
||||||
int i, inf;
|
|
||||||
float f, g, g1, g3;
|
|
||||||
|
|
||||||
lightgamma = bound( 1.8f, lightgamma, 3.0f );
|
|
||||||
brightness = bound( 0.0f, brightness, 10.0f );
|
|
||||||
|
|
||||||
if( brightness <= 0.0f )
|
|
||||||
g3 = 0.125f;
|
|
||||||
else if( brightness > 1.0f )
|
|
||||||
g3 = 0.05f;
|
|
||||||
else g3 = 0.125f - (brightness * brightness) * 0.075f;
|
|
||||||
|
|
||||||
g = 1.0f / lightgamma;
|
|
||||||
g1 = GAMMA * g;
|
|
||||||
|
|
||||||
for( i = 0; i < 256; i++ )
|
|
||||||
{
|
|
||||||
f = pow( i / 255.f, GAMMA );
|
|
||||||
|
|
||||||
// scale up
|
|
||||||
if( brightness > 1.0f )
|
|
||||||
f = f * brightness;
|
|
||||||
|
|
||||||
// shift up
|
|
||||||
if( f <= g3 ) f = (f / g3) * 0.125f;
|
|
||||||
else f = 0.125f + ((f - g3) / (1.0f - g3)) * 0.875f;
|
|
||||||
|
|
||||||
// convert linear space to desired gamma space
|
|
||||||
inf = (int)( 255.0f * pow( f, g ));
|
|
||||||
|
|
||||||
lightgammatable[i] = bound( 0, inf, 255 );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( i = 0; i < 1024; i++ )
|
|
||||||
{
|
|
||||||
// convert from screen gamma space to linear space
|
|
||||||
lineargammatable[i] = 1023 * pow( i / 1023.0f, g1 );
|
|
||||||
|
|
||||||
// convert from linear gamma space to screen space
|
|
||||||
screengammatable[i] = 1023 * pow( i / 1023.0f, 1.0f / g1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
byte LightToTexGamma( byte b )
|
|
||||||
{
|
|
||||||
if( FBitSet( host.features, ENGINE_LINEAR_GAMMA_SPACE ))
|
|
||||||
return b;
|
|
||||||
else
|
|
||||||
return lightgammatable[b];
|
|
||||||
}
|
|
||||||
@@ -190,29 +190,68 @@ void Host_ShutdownServer( void )
|
|||||||
Host_PrintEngineFeatures
|
Host_PrintEngineFeatures
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void Host_PrintEngineFeatures( int features )
|
static void Host_PrintEngineFeatures( int features )
|
||||||
{
|
{
|
||||||
const char *features_str[] =
|
struct
|
||||||
{
|
{
|
||||||
"Big World Support",
|
uint32_t mask;
|
||||||
"Quake Compatibility",
|
const char *msg;
|
||||||
"Deluxemap Support",
|
} features_str[] =
|
||||||
"Improved MOVETYPE_PUSH",
|
{
|
||||||
"Large Lightmaps",
|
{ ENGINE_WRITE_LARGE_COORD, "Big World Support" },
|
||||||
"Stupid Quake Bug Compensation",
|
{ ENGINE_QUAKE_COMPATIBLE, "Quake Compatibility" },
|
||||||
"Improved Trace Line",
|
{ ENGINE_LOAD_DELUXEDATA, "Deluxemap Support" },
|
||||||
"Studio MOVETYPE_STEP Lerping",
|
{ ENGINE_PHYSICS_PUSHER_EXT, "Improved MOVETYPE_PUSH" },
|
||||||
"Linear Gamma Space"
|
{ ENGINE_LARGE_LIGHTMAPS, "Large Lightmaps" },
|
||||||
|
{ ENGINE_COMPENSATE_QUAKE_BUG, "Stupid Quake Bug Compensation" },
|
||||||
|
{ ENGINE_IMPROVED_LINETRACE, "Improved Trace Line" },
|
||||||
|
{ ENGINE_COMPUTE_STUDIO_LERP, "Studio MOVETYPE_STEP Lerping" },
|
||||||
|
{ ENGINE_LINEAR_GAMMA_SPACE, "Linear Gamma Space" },
|
||||||
|
{ ENGINE_STEP_POSHISTORY_LERP, "MOVETYPE_STEP Position History Based Lerping" },
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < ARRAYSIZE( features_str ); i++ )
|
for( i = 0; i < ARRAYSIZE( features_str ); i++ )
|
||||||
{
|
{
|
||||||
if( FBitSet( features, BIT( i )))
|
if( FBitSet( features, features_str[i].mask ))
|
||||||
Con_Reportf( "^3EXT:^7 %s is enabled\n", features_str[i] );
|
Con_Reportf( "^3EXT:^7 %s is enabled\n", features_str[i].msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
Host_ValidateEngineFeatures
|
||||||
|
|
||||||
|
validate features bits and set host.features
|
||||||
|
==============
|
||||||
|
*/
|
||||||
|
void Host_ValidateEngineFeatures( uint32_t features )
|
||||||
|
{
|
||||||
|
uint32_t mask = ENGINE_FEATURES_MASK;
|
||||||
|
|
||||||
|
#if !HOST_DEDICATED
|
||||||
|
if( !Host_IsDedicated( ) && cls.legacymode )
|
||||||
|
mask = ENGINE_LEGACY_FEATURES_MASK;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// don't allow unsupported bits
|
||||||
|
features &= mask;
|
||||||
|
|
||||||
|
// force bits for some games
|
||||||
|
if( !Q_stricmp( GI->gamefolder, "cstrike" ) || !Q_stricmp( GI->gamefolder, "czero" ))
|
||||||
|
SetBits( features, ENGINE_STEP_POSHISTORY_LERP );
|
||||||
|
|
||||||
|
// print requested first
|
||||||
|
Host_PrintEngineFeatures( features );
|
||||||
|
|
||||||
|
// now warn about incompatible bits
|
||||||
|
if( FBitSet( features, ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ) == ( ENGINE_STEP_POSHISTORY_LERP|ENGINE_COMPUTE_STUDIO_LERP ))
|
||||||
|
Con_Printf( S_WARN "%s: incompatible ENGINE_STEP_POSHISTORY_LERP and ENGINE_COMPUTE_STUDIO_LERP are enabled!\n", __func__ );
|
||||||
|
|
||||||
|
// finally set global variable
|
||||||
|
host.features = features;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
Host_IsQuakeCompatible
|
Host_IsQuakeCompatible
|
||||||
@@ -915,7 +954,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
int developer = DEFAULT_DEV;
|
int developer = DEFAULT_DEV;
|
||||||
const char *baseDir;
|
const char *baseDir;
|
||||||
char ticrate[16];
|
char ticrate[16];
|
||||||
int len;
|
int len, i;
|
||||||
|
|
||||||
// some commands may turn engine into infinite loop,
|
// some commands may turn engine into infinite loop,
|
||||||
// e.g. xash.exe +game xash -game xash
|
// e.g. xash.exe +game xash -game xash
|
||||||
@@ -990,7 +1029,7 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
progname++;
|
progname++;
|
||||||
|
|
||||||
Q_strncpy( SI.exeName, progname, sizeof( SI.exeName ));
|
Q_strncpy( SI.exeName, progname, sizeof( SI.exeName ));
|
||||||
Q_strncpy( SI.basedirName, progname, sizeof( SI.exeName ));
|
Q_strncpy( SI.basedirName, progname, sizeof( SI.basedirName ));
|
||||||
|
|
||||||
if( Host_IsDedicated() )
|
if( Host_IsDedicated() )
|
||||||
{
|
{
|
||||||
@@ -1025,10 +1064,10 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
|
|
||||||
// init host state machine
|
// init host state machine
|
||||||
COM_InitHostState();
|
COM_InitHostState();
|
||||||
|
#ifdef XASH_HASHED_VARS
|
||||||
// init hashed commands
|
// init hashed commands
|
||||||
BaseCmd_Init();
|
BaseCmd_Init();
|
||||||
|
#endif
|
||||||
// startup cmds and cvars subsystem
|
// startup cmds and cvars subsystem
|
||||||
Cmd_Init();
|
Cmd_Init();
|
||||||
Cvar_Init();
|
Cvar_Init();
|
||||||
@@ -1071,6 +1110,8 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
Sys_Error( "couldn't find xash3d data directory" );
|
Sys_Error( "couldn't find xash3d data directory" );
|
||||||
host.rootdir[0] = 0;
|
host.rootdir[0] = 0;
|
||||||
}
|
}
|
||||||
|
#elif XASH_PSP
|
||||||
|
COM_ExtractFilePath( argv[0], host.rootdir );
|
||||||
#elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
|
#elif (XASH_SDL == 2) && !XASH_NSWITCH // GetBasePath not impl'd in switch-sdl2
|
||||||
char *szBasePath = SDL_GetBasePath();
|
char *szBasePath = SDL_GetBasePath();
|
||||||
if( szBasePath )
|
if( szBasePath )
|
||||||
@@ -1162,12 +1203,25 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha
|
|||||||
FS_LoadGameInfo( NULL );
|
FS_LoadGameInfo( NULL );
|
||||||
Cvar_PostFSInit();
|
Cvar_PostFSInit();
|
||||||
|
|
||||||
if( FS_FileExists( va( "%s.rc", SI.basedirName ), false ))
|
|
||||||
Q_strncpy( SI.rcName, SI.basedirName, sizeof( SI.rcName )); // e.g. valve.rc
|
|
||||||
else Q_strncpy( SI.rcName, SI.exeName, sizeof( SI.rcName )); // e.g. quake.rc
|
|
||||||
|
|
||||||
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
|
Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));
|
||||||
|
|
||||||
|
for( i = 0; i < 3; i++ )
|
||||||
|
{
|
||||||
|
const char *rcName;
|
||||||
|
switch( i )
|
||||||
|
{
|
||||||
|
case 0: rcName = SI.basedirName; break; // e.g. valve.rc
|
||||||
|
case 1: rcName = SI.exeName; break; // e.g. quake.rc
|
||||||
|
case 2: rcName = host.gamefolder; break; // e.g. game.rc (ran from default launcher)
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FS_FileExists( va( "%s.rc", rcName ), false ))
|
||||||
|
{
|
||||||
|
Q_strncpy( SI.rcName, rcName, sizeof( SI.rcName ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Image_CheckPaletteQ1 ();
|
Image_CheckPaletteQ1 ();
|
||||||
Host_InitDecals (); // reload decals
|
Host_InitDecals (); // reload decals
|
||||||
|
|
||||||
@@ -1342,6 +1396,8 @@ Host_Shutdown
|
|||||||
*/
|
*/
|
||||||
void EXPORT Host_Shutdown( void )
|
void EXPORT Host_Shutdown( void )
|
||||||
{
|
{
|
||||||
|
qboolean error = host.status == HOST_ERR_FATAL;
|
||||||
|
|
||||||
if( host.shutdown_issued ) return;
|
if( host.shutdown_issued ) return;
|
||||||
host.shutdown_issued = true;
|
host.shutdown_issued = true;
|
||||||
|
|
||||||
@@ -1349,7 +1405,7 @@ void EXPORT Host_Shutdown( void )
|
|||||||
if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
|
if( !host.change_game ) Q_strncpy( host.finalmsg, "Server shutdown", sizeof( host.finalmsg ));
|
||||||
|
|
||||||
#if !XASH_DEDICATED
|
#if !XASH_DEDICATED
|
||||||
if( host.type == HOST_NORMAL )
|
if( host.type == HOST_NORMAL && !error )
|
||||||
Host_WriteConfig();
|
Host_WriteConfig();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ void COM_NewGame( char const *pMapName )
|
|||||||
GameState->landmarkName[0] = 0;
|
GameState->landmarkName[0] = 0;
|
||||||
GameState->loadGame = false;
|
GameState->loadGame = false;
|
||||||
GameState->newGame = true;
|
GameState->newGame = true;
|
||||||
|
|
||||||
|
SV_ShutdownGame(); // exit from current game
|
||||||
}
|
}
|
||||||
|
|
||||||
void COM_LoadLevel( char const *pMapName, qboolean background )
|
void COM_LoadLevel( char const *pMapName, qboolean background )
|
||||||
@@ -74,6 +76,8 @@ void COM_LoadLevel( char const *pMapName, qboolean background )
|
|||||||
GameState->landmarkName[0] = 0;
|
GameState->landmarkName[0] = 0;
|
||||||
GameState->loadGame = false;
|
GameState->loadGame = false;
|
||||||
GameState->newGame = false;
|
GameState->newGame = false;
|
||||||
|
|
||||||
|
SV_ShutdownGame(); // exit from current game
|
||||||
}
|
}
|
||||||
|
|
||||||
void COM_LoadGame( char const *pMapName )
|
void COM_LoadGame( char const *pMapName )
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Image_LoadTGA
|
|||||||
*/
|
*/
|
||||||
qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesize )
|
qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||||
{
|
{
|
||||||
int i, columns, rows, row_inc, row, col;
|
int i, columns, rows, row_inc, row, col, bpp = 1;
|
||||||
byte *buf_p, *pixbuf, *targa_rgba;
|
byte *buf_p, *pixbuf, *targa_rgba;
|
||||||
rgba_t palette[256];
|
rgba_t palette[256];
|
||||||
byte red = 0, green = 0, blue = 0, alpha = 0;
|
byte red = 0, green = 0, blue = 0, alpha = 0;
|
||||||
@@ -32,6 +32,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
int reflectivity[3] = { 0, 0, 0 };
|
int reflectivity[3] = { 0, 0, 0 };
|
||||||
qboolean compressed;
|
qboolean compressed;
|
||||||
tga_t targa_header;
|
tga_t targa_header;
|
||||||
|
int palIndex = 0;
|
||||||
|
|
||||||
if( filesize < sizeof( tga_t ))
|
if( filesize < sizeof( tga_t ))
|
||||||
return false;
|
return false;
|
||||||
@@ -55,8 +56,6 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
// check for tga file
|
// check for tga file
|
||||||
if( !Image_ValidSize( name )) return false;
|
if( !Image_ValidSize( name )) return false;
|
||||||
|
|
||||||
image.type = PF_RGBA_32; // always exctracted to 32-bit buffer
|
|
||||||
|
|
||||||
if( targa_header.image_type == 1 || targa_header.image_type == 9 )
|
if( targa_header.image_type == 1 || targa_header.image_type == 9 )
|
||||||
{
|
{
|
||||||
// uncompressed colormapped image
|
// uncompressed colormapped image
|
||||||
@@ -119,11 +118,35 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "Image_LoadTGA: (%s) Type %i not supported\n", name, targa_header.image_type );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
columns = targa_header.width;
|
columns = targa_header.width;
|
||||||
rows = targa_header.height;
|
rows = targa_header.height;
|
||||||
|
|
||||||
image.size = image.width * image.height * 4;
|
if( Image_CheckFlag( IL_KEEP_8BIT ) && ( targa_header.image_type == 1 || targa_header.image_type == 9 ))
|
||||||
|
{
|
||||||
|
pixbuf = image.palette = Mem_Malloc( host.imagepool, 1024 );
|
||||||
|
for( i = 0; i < targa_header.colormap_length; i++ )
|
||||||
|
{
|
||||||
|
*pixbuf++ = palette[i][0];
|
||||||
|
*pixbuf++ = palette[i][1];
|
||||||
|
*pixbuf++ = palette[i][2];
|
||||||
|
*pixbuf++ = palette[i][3];
|
||||||
|
}
|
||||||
|
image.type = PF_INDEXED_32;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
image.palette = NULL;
|
||||||
|
image.type = PF_RGBA_32;
|
||||||
|
bpp = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
image.size = image.width * image.height * bpp;
|
||||||
targa_rgba = image.rgba = Mem_Malloc( host.imagepool, image.size );
|
targa_rgba = image.rgba = Mem_Malloc( host.imagepool, image.size );
|
||||||
|
|
||||||
// if bit 5 of attributes isn't set, the image has been stored from bottom to top
|
// if bit 5 of attributes isn't set, the image has been stored from bottom to top
|
||||||
@@ -134,8 +157,8 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pixbuf = targa_rgba + ( rows - 1 ) * columns * 4;
|
pixbuf = targa_rgba + ( rows - 1 ) * columns * bpp;
|
||||||
row_inc = -columns * 4 * 2;
|
row_inc = -columns * bpp * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
compressed = ( targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11 );
|
compressed = ( targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11 );
|
||||||
@@ -161,13 +184,13 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
case 1:
|
case 1:
|
||||||
case 9:
|
case 9:
|
||||||
// colormapped image
|
// colormapped image
|
||||||
blue = *buf_p++;
|
palIndex = *buf_p++;
|
||||||
if( blue < targa_header.colormap_length )
|
if( palIndex < targa_header.colormap_length )
|
||||||
{
|
{
|
||||||
red = palette[blue][0];
|
red = palette[palIndex][0];
|
||||||
green = palette[blue][1];
|
green = palette[palIndex][1];
|
||||||
alpha = palette[blue][3];
|
blue = palette[palIndex][2];
|
||||||
blue = palette[blue][2];
|
alpha = palette[palIndex][3];
|
||||||
if( alpha != 255 ) image.flags |= IMAGE_HAS_ALPHA;
|
if( alpha != 255 ) image.flags |= IMAGE_HAS_ALPHA;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -208,10 +231,18 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
reflectivity[1] += green;
|
reflectivity[1] += green;
|
||||||
reflectivity[2] += blue;
|
reflectivity[2] += blue;
|
||||||
|
|
||||||
*pixbuf++ = red;
|
if( image.type == PF_INDEXED_32 || image.type == PF_INDEXED_24 )
|
||||||
*pixbuf++ = green;
|
{
|
||||||
*pixbuf++ = blue;
|
*pixbuf++ = palIndex;
|
||||||
*pixbuf++ = alpha;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*pixbuf++ = red;
|
||||||
|
*pixbuf++ = green;
|
||||||
|
*pixbuf++ = blue;
|
||||||
|
*pixbuf++ = alpha;
|
||||||
|
}
|
||||||
|
|
||||||
if( ++col == columns )
|
if( ++col == columns )
|
||||||
{
|
{
|
||||||
// run spans across rows
|
// run spans across rows
|
||||||
@@ -223,6 +254,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
|
|||||||
}
|
}
|
||||||
|
|
||||||
VectorDivide( reflectivity, ( image.width * image.height ), image.fogParams );
|
VectorDivide( reflectivity, ( image.width * image.height ), image.fogParams );
|
||||||
|
if( image.palette ) Image_GetPaletteBMP( image.palette );
|
||||||
image.depth = 1;
|
image.depth = 1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -93,6 +93,23 @@ static const loadpixformat_t load_null[] =
|
|||||||
{ NULL, NULL, NULL, IL_HINT_NO }
|
{ NULL, NULL, NULL, IL_HINT_NO }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// a1ba: that's weird, better debug
|
||||||
|
#if XASH_PSP
|
||||||
|
static const loadpixformat_t load_game[] =
|
||||||
|
{
|
||||||
|
{ "%s%s.%s", "mip", Image_LoadMIP, IL_HINT_NO }, // hl textures from wad or buffer
|
||||||
|
{ "%s%s.%s", "mdl", Image_LoadMDL, IL_HINT_HL }, // hl studio model skins
|
||||||
|
{ "%s%s.%s", "spr", Image_LoadSPR, IL_HINT_HL }, // hl sprite frames
|
||||||
|
{ "%s%s.%s", "lmp", Image_LoadLMP, IL_HINT_NO }, // hl menu images (cached.wad etc)
|
||||||
|
{ "%s%s.%s", "fnt", Image_LoadFNT, IL_HINT_HL }, // hl console font (fonts.wad etc)
|
||||||
|
{ "%s%s.%s", "pal", Image_LoadPAL, IL_HINT_NO }, // install studio\sprite palette
|
||||||
|
{ "%s%s.%s", "dds", Image_LoadDDS, IL_HINT_NO }, // dds for world and studio models
|
||||||
|
{ "%s%s.%s", "tga", Image_LoadTGA, IL_HINT_NO }, // hl vgui menus
|
||||||
|
{ "%s%s.%s", "bmp", Image_LoadBMP, IL_HINT_NO }, // WON menu images
|
||||||
|
{ "%s%s.%s", "png", Image_LoadPNG, IL_HINT_NO }, // NightFire 007 menus
|
||||||
|
{ NULL, NULL, NULL, IL_HINT_NO }
|
||||||
|
};
|
||||||
|
#else
|
||||||
static const loadpixformat_t load_game[] =
|
static const loadpixformat_t load_game[] =
|
||||||
{
|
{
|
||||||
{ "%s%s.%s", "dds", Image_LoadDDS, IL_HINT_NO }, // dds for world and studio models
|
{ "%s%s.%s", "dds", Image_LoadDDS, IL_HINT_NO }, // dds for world and studio models
|
||||||
@@ -108,7 +125,7 @@ static const loadpixformat_t load_game[] =
|
|||||||
{ "%s%s.%s", "ktx2", Image_LoadKTX2, IL_HINT_NO }, // ktx2 for world and studio models
|
{ "%s%s.%s", "ktx2", Image_LoadKTX2, IL_HINT_NO }, // ktx2 for world and studio models
|
||||||
{ NULL, NULL, NULL, IL_HINT_NO }
|
{ NULL, NULL, NULL, IL_HINT_NO }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
=============================================================================
|
=============================================================================
|
||||||
|
|
||||||
@@ -287,16 +304,15 @@ void Image_SetPalette( const byte *pal, uint *d_table )
|
|||||||
uint uirgba; // TODO: palette looks byte-swapped on big-endian
|
uint uirgba; // TODO: palette looks byte-swapped on big-endian
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
|
||||||
// setup palette
|
// setup palette
|
||||||
switch( image.d_rendermode )
|
switch( image.d_rendermode )
|
||||||
{
|
{
|
||||||
case LUMP_NORMAL:
|
case LUMP_NORMAL:
|
||||||
for( i = 0; i < 256; i++ )
|
for( i = 0; i < 256; i++ )
|
||||||
{
|
{
|
||||||
rgba[0] = pal[i*3+0];
|
rgba[0] = TextureToGamma( pal[i*3+0] );
|
||||||
rgba[1] = pal[i*3+1];
|
rgba[1] = TextureToGamma( pal[i*3+1] );
|
||||||
rgba[2] = pal[i*3+2];
|
rgba[2] = TextureToGamma( pal[i*3+2] );
|
||||||
rgba[3] = 0xFF;
|
rgba[3] = 0xFF;
|
||||||
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
memcpy( &uirgba, rgba, sizeof( uirgba ));
|
||||||
d_table[i] = uirgba;
|
d_table[i] = uirgba;
|
||||||
|
|||||||
@@ -13,17 +13,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef SINGLE_BINARY
|
#if XASH_ENABLE_MAIN
|
||||||
|
#if XASH_SDLMAIN
|
||||||
#include "build.h"
|
#include <SDL.h>
|
||||||
#include "common.h"
|
|
||||||
#ifdef XASH_SDLMAIN
|
|
||||||
#include "SDL.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XASH_EMSCRIPTEN
|
#if XASH_EMSCRIPTEN
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include "build.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#define E_GAME "XASH3D_GAME" // default env dir to start from
|
#define E_GAME "XASH3D_GAME" // default env dir to start from
|
||||||
#ifndef XASH_GAMEDIR
|
#ifndef XASH_GAMEDIR
|
||||||
@@ -36,7 +34,13 @@ GNU General Public License for more details.
|
|||||||
|
|
||||||
static char szGameDir[128]; // safe place to keep gamedir
|
static char szGameDir[128]; // safe place to keep gamedir
|
||||||
static int szArgc;
|
static int szArgc;
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
#define MAX_NARGVS 50
|
||||||
|
static char *szArgv[MAX_NARGVS];
|
||||||
|
#else
|
||||||
static char **szArgv;
|
static char **szArgv;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void Sys_ChangeGame( const char *progname )
|
static void Sys_ChangeGame( const char *progname )
|
||||||
{
|
{
|
||||||
@@ -47,51 +51,49 @@ static void Sys_ChangeGame( const char *progname )
|
|||||||
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
|
exit( Host_Main( szArgc, szArgv, szGameDir, 1, &Sys_ChangeGame ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
_inline int Sys_Start( void )
|
static int Sys_Start( void )
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
const char *game = getenv( E_GAME );
|
const char *game = getenv( E_GAME );
|
||||||
|
|
||||||
if( !game )
|
if( !game )
|
||||||
game = XASH_GAMEDIR;
|
game = XASH_GAMEDIR;
|
||||||
|
|
||||||
Q_strncpy( szGameDir, game, sizeof( szGameDir ));
|
Q_strncpy( szGameDir, game, sizeof( szGameDir ));
|
||||||
|
|
||||||
#if XASH_EMSCRIPTEN
|
#if XASH_EMSCRIPTEN
|
||||||
#ifdef EMSCRIPTEN_LIB_FS
|
#ifdef EMSCRIPTEN_LIB_FS
|
||||||
// For some unknown reason emscripten refusing to load libraries later
|
// For some unknown reason emscripten refusing to load libraries later
|
||||||
COM_LoadLibrary("menu", 0 );
|
COM_LoadLibrary( "menu", 0 );
|
||||||
COM_LoadLibrary("server", 0 );
|
COM_LoadLibrary( "server", 0 );
|
||||||
COM_LoadLibrary("client", 0 );
|
COM_LoadLibrary( "client", 0 );
|
||||||
#endif
|
#endif
|
||||||
#if XASH_DEDICATED
|
#if XASH_DEDICATED
|
||||||
// NodeJS support for debug
|
// NodeJS support for debug
|
||||||
EM_ASM(try{
|
EM_ASM(try {
|
||||||
FS.mkdir('/xash');
|
FS.mkdir( '/xash' );
|
||||||
FS.mount(NODEFS, { root: '.'}, '/xash' );
|
FS.mount( NODEFS, { root: '.'}, '/xash' );
|
||||||
FS.chdir('/xash');
|
FS.chdir( '/xash' );
|
||||||
}catch(e){};);
|
} catch( e ) { };);
|
||||||
#endif
|
#endif
|
||||||
#elif XASH_IOS
|
#elif XASH_IOS
|
||||||
{
|
IOS_LaunchDialog();
|
||||||
void IOS_LaunchDialog( void );
|
#elif XASH_PSP
|
||||||
IOS_LaunchDialog();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame );
|
return Host_Main( szArgc, szArgv, game, 0, Sys_ChangeGame );
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
#if XASH_PSVITA
|
#if XASH_PSP
|
||||||
|
Platform_ReadCmd( "start.cmd", &szArgc, szArgv );
|
||||||
|
#elif XASH_PSVITA
|
||||||
// inject -dev -console into args if required
|
// inject -dev -console into args if required
|
||||||
szArgc = PSVita_GetArgv( argc, argv, &szArgv );
|
szArgc = PSVita_GetArgv( argc, argv, &szArgv );
|
||||||
#else
|
#else
|
||||||
szArgc = argc;
|
szArgc = argc;
|
||||||
szArgv = argv;
|
szArgv = argv;
|
||||||
#endif // XASH_PSVITA
|
#endif // XASH_PSVITA
|
||||||
|
|
||||||
return Sys_Start();
|
return Sys_Start();
|
||||||
}
|
}
|
||||||
#endif // SINGLE_BINARY
|
#endif // XASH_ENABLE_MAIN
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ void COM_PushLibraryError( const char *error )
|
|||||||
Q_strncat( s_szLastError, error, sizeof( s_szLastError ) );
|
Q_strncat( s_szLastError, error, sizeof( s_szLastError ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !XASH_PSP
|
||||||
void *COM_FunctionFromName_SR( void *hInstance, const char *pName )
|
void *COM_FunctionFromName_SR( void *hInstance, const char *pName )
|
||||||
{
|
{
|
||||||
char **funcs = NULL;
|
char **funcs = NULL;
|
||||||
@@ -85,6 +86,7 @@ const char *COM_OffsetNameForFunction( void *function )
|
|||||||
Con_Reportf( "COM_OffsetNameForFunction %s\n", sname );
|
Con_Reportf( "COM_OffsetNameForFunction %s\n", sname );
|
||||||
return sname;
|
return sname;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
||||||
{
|
{
|
||||||
@@ -128,7 +130,7 @@ dll_user_t *FS_FindLibrary( const char *dllname, qboolean directpath )
|
|||||||
|
|
||||||
static void COM_GenerateCommonLibraryName( const char *name, const char *ext, char *out, size_t size )
|
static void COM_GenerateCommonLibraryName( const char *name, const char *ext, char *out, size_t size )
|
||||||
{
|
{
|
||||||
#if ( XASH_WIN32 || XASH_LINUX || XASH_APPLE ) && XASH_X86
|
#if (( XASH_WIN32 || XASH_LINUX || XASH_APPLE ) && XASH_X86) || XASH_PSP
|
||||||
Q_snprintf( out, size, "%s.%s", name, ext );
|
Q_snprintf( out, size, "%s.%s", name, ext );
|
||||||
#elif ( XASH_WIN32 || XASH_LINUX || XASH_APPLE )
|
#elif ( XASH_WIN32 || XASH_LINUX || XASH_APPLE )
|
||||||
Q_snprintf( out, size, "%s_%s.%s", name, Q_buildarch(), ext );
|
Q_snprintf( out, size, "%s_%s.%s", name, Q_buildarch(), ext );
|
||||||
@@ -191,6 +193,8 @@ static void COM_GenerateServerLibraryPath( char *out, size_t size )
|
|||||||
Q_strncpy( out, GI->game_dll, size );
|
Q_strncpy( out, GI->game_dll, size );
|
||||||
#elif XASH_APPLE
|
#elif XASH_APPLE
|
||||||
Q_strncpy( out, GI->game_dll_osx, size );
|
Q_strncpy( out, GI->game_dll_osx, size );
|
||||||
|
#elif XASH_PSP
|
||||||
|
Q_strncpy( out, GI->game_dll_psp, size );
|
||||||
#else // XASH_LINUX
|
#else // XASH_LINUX
|
||||||
Q_strncpy( out, GI->game_dll_linux, size );
|
Q_strncpy( out, GI->game_dll_linux, size );
|
||||||
#endif
|
#endif
|
||||||
@@ -203,6 +207,8 @@ static void COM_GenerateServerLibraryPath( char *out, size_t size )
|
|||||||
Q_strncpy( dllpath, GI->game_dll, sizeof( dllpath ) );
|
Q_strncpy( dllpath, GI->game_dll, sizeof( dllpath ) );
|
||||||
#elif XASH_APPLE
|
#elif XASH_APPLE
|
||||||
Q_strncpy( dllpath, GI->game_dll_osx, sizeof( dllpath ) );
|
Q_strncpy( dllpath, GI->game_dll_osx, sizeof( dllpath ) );
|
||||||
|
#elif XASH_PSP
|
||||||
|
Q_strncpy( dllpath, GI->game_dll_psp, sizeof( dllpath ) );
|
||||||
#else // XASH_APPLE
|
#else // XASH_APPLE
|
||||||
Q_strncpy( dllpath, GI->game_dll_linux, sizeof( dllpath ) );
|
Q_strncpy( dllpath, GI->game_dll_linux, sizeof( dllpath ) );
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ static net_gai_state_t NET_GetMasterHostByName( master_t *m )
|
|||||||
if( res == NET_EAI_OK )
|
if( res == NET_EAI_OK )
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
m->adr.type = NA_UNUSED;
|
m->adr.type = 0;
|
||||||
if( res == NET_EAI_NONAME )
|
if( res == NET_EAI_NONAME )
|
||||||
Con_Reportf( "Can't resolve adr: %s\n", m->address );
|
Con_Reportf( "Can't resolve adr: %s\n", m->address );
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ static void NET_AddMaster( const char *addr, qboolean save )
|
|||||||
master->sent = false;
|
master->sent = false;
|
||||||
master->save = save;
|
master->save = save;
|
||||||
master->next = NULL;
|
master->next = NULL;
|
||||||
master->adr.type = NA_UNUSED;
|
master->adr.type = 0;
|
||||||
|
|
||||||
// link in
|
// link in
|
||||||
if( last )
|
if( last )
|
||||||
@@ -322,7 +322,7 @@ static void NET_ListMasters_f( void )
|
|||||||
for( i = 1, list = ml.list; list; i++, list = list->next )
|
for( i = 1, list = ml.list; list; i++, list = list->next )
|
||||||
{
|
{
|
||||||
Msg( "%d\t%s", i, list->address );
|
Msg( "%d\t%s", i, list->address );
|
||||||
if( list->adr.type != NA_UNUSED )
|
if( list->adr.type != 0 )
|
||||||
Msg( "\t%s\n", NET_AdrToString( list->adr ));
|
Msg( "\t%s\n", NET_AdrToString( list->adr ));
|
||||||
else Msg( "\n" );
|
else Msg( "\n" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1735,12 +1735,16 @@ static void Mod_LoadSubmodels( model_t *mod, dbspmodel_t *bmod )
|
|||||||
oldmaxfaces = Q_max( oldmaxfaces, out->numfaces );
|
oldmaxfaces = Q_max( oldmaxfaces, out->numfaces );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
refState.max_surfaces = 0; // sorting disabled
|
||||||
|
#else
|
||||||
// these array used to sort translucent faces in bmodels
|
// these array used to sort translucent faces in bmodels
|
||||||
if( oldmaxfaces > refState.max_surfaces )
|
if( oldmaxfaces > refState.max_surfaces )
|
||||||
{
|
{
|
||||||
refState.draw_surfaces = (sortedface_t *)Z_Realloc( refState.draw_surfaces, oldmaxfaces * sizeof( sortedface_t ));
|
refState.draw_surfaces = (sortedface_t *)Z_Realloc( refState.draw_surfaces, oldmaxfaces * sizeof( sortedface_t ));
|
||||||
refState.max_surfaces = oldmaxfaces;
|
refState.max_surfaces = oldmaxfaces;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -151,17 +151,6 @@ void MSG_Clear( sizebuf_t *sb )
|
|||||||
sb->bOverflow = false;
|
sb->bOverflow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static qboolean MSG_Overflow( sizebuf_t *sb, int nBits )
|
|
||||||
{
|
|
||||||
if( sb->iCurBit + nBits > sb->nDataBits )
|
|
||||||
sb->bOverflow = true;
|
|
||||||
return sb->bOverflow;
|
|
||||||
}
|
|
||||||
|
|
||||||
qboolean MSG_CheckOverflow( sizebuf_t *sb )
|
|
||||||
{
|
|
||||||
return MSG_Overflow( sb, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
int MSG_SeekToBit( sizebuf_t *sb, int bitPos, int whence )
|
int MSG_SeekToBit( sizebuf_t *sb, int bitPos, int whence )
|
||||||
{
|
{
|
||||||
@@ -193,17 +182,6 @@ void MSG_SeekToByte( sizebuf_t *sb, int bytePos )
|
|||||||
sb->iCurBit = bytePos << 3;
|
sb->iCurBit = bytePos << 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSG_WriteOneBit( sizebuf_t *sb, int nValue )
|
|
||||||
{
|
|
||||||
if( !MSG_Overflow( sb, 1 ))
|
|
||||||
{
|
|
||||||
if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 );
|
|
||||||
else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 );
|
|
||||||
|
|
||||||
sb->iCurBit++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits )
|
||||||
{
|
{
|
||||||
Assert( numbits >= 0 && numbits <= 32 );
|
Assert( numbits >= 0 && numbits <= 32 );
|
||||||
|
|||||||
@@ -64,6 +64,19 @@ _inline int MSG_TellBit( sizebuf_t *sb ) { return sb->iCurBit; }
|
|||||||
_inline const char *MSG_GetName( sizebuf_t *sb ) { return sb->pDebugName; }
|
_inline const char *MSG_GetName( sizebuf_t *sb ) { return sb->pDebugName; }
|
||||||
qboolean MSG_CheckOverflow( sizebuf_t *sb );
|
qboolean MSG_CheckOverflow( sizebuf_t *sb );
|
||||||
|
|
||||||
|
static inline qboolean MSG_Overflow( sizebuf_t *sb, int nBits )
|
||||||
|
{
|
||||||
|
if( sb->iCurBit + nBits > sb->nDataBits )
|
||||||
|
sb->bOverflow = true;
|
||||||
|
return sb->bOverflow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline MSG_CheckOverflow( sizebuf_t *sb )
|
||||||
|
{
|
||||||
|
return MSG_Overflow( sb, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if XASH_BIG_ENDIAN
|
#if XASH_BIG_ENDIAN
|
||||||
#define MSG_BigShort( x ) ( x )
|
#define MSG_BigShort( x ) ( x )
|
||||||
#else
|
#else
|
||||||
@@ -78,7 +91,16 @@ void MSG_StartWriting( sizebuf_t *sb, void *pData, int nBytes, int iStartBit, in
|
|||||||
void MSG_Clear( sizebuf_t *sb );
|
void MSG_Clear( sizebuf_t *sb );
|
||||||
|
|
||||||
// Bit-write functions
|
// Bit-write functions
|
||||||
void MSG_WriteOneBit( sizebuf_t *sb, int nValue );
|
static inline void MSG_WriteOneBit( sizebuf_t *sb, int nValue )
|
||||||
|
{
|
||||||
|
if( likely( !MSG_Overflow( sb, 1 )))
|
||||||
|
{
|
||||||
|
if( nValue ) sb->pData[sb->iCurBit>>3] |= BIT( sb->iCurBit & 7 );
|
||||||
|
else sb->pData[sb->iCurBit>>3] &= ~BIT( sb->iCurBit & 7 );
|
||||||
|
|
||||||
|
sb->iCurBit++;
|
||||||
|
}
|
||||||
|
}
|
||||||
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
|
void MSG_WriteUBitLong( sizebuf_t *sb, uint curData, int numbits );
|
||||||
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
|
void MSG_WriteSBitLong( sizebuf_t *sb, int data, int numbits );
|
||||||
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
|
void MSG_WriteBitLong( sizebuf_t *sb, uint data, int numbits, qboolean bSigned );
|
||||||
|
|||||||
@@ -1095,7 +1095,6 @@ int Delta_TestBaseline( entity_state_t *from, entity_state_t *to, qboolean playe
|
|||||||
if( from == NULL ) return 0;
|
if( from == NULL ) return 0;
|
||||||
return countBits;
|
return countBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
||||||
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
||||||
else if( player )
|
else if( player )
|
||||||
@@ -1793,7 +1792,6 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||||||
numChanges++;
|
numChanges++;
|
||||||
}
|
}
|
||||||
else MSG_WriteOneBit( msg, 0 );
|
else MSG_WriteOneBit( msg, 0 );
|
||||||
|
|
||||||
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
if( FBitSet( to->entityType, ENTITY_BEAM ))
|
||||||
{
|
{
|
||||||
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
dt = Delta_FindStructByIndex( DT_CUSTOM_ENTITY_STATE_T );
|
||||||
@@ -1806,7 +1804,6 @@ void MSG_WriteDeltaEntity( entity_state_t *from, entity_state_t *to, sizebuf_t *
|
|||||||
{
|
{
|
||||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert( dt && dt->bInitialized );
|
Assert( dt && dt->bInitialized );
|
||||||
|
|
||||||
pField = dt->pFields;
|
pField = dt->pFields;
|
||||||
@@ -1924,7 +1921,6 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
|
|||||||
{
|
{
|
||||||
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
dt = Delta_FindStructByIndex( DT_ENTITY_STATE_T );
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert( dt && dt->bInitialized );
|
Assert( dt && dt->bInitialized );
|
||||||
|
|
||||||
pField = dt->pFields;
|
pField = dt->pFields;
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ static const struct in6_addr in6addr_any;
|
|||||||
|
|
||||||
#define NET_USE_FRAGMENTS
|
#define NET_USE_FRAGMENTS
|
||||||
|
|
||||||
#define PORT_ANY -1
|
|
||||||
#define MAX_LOOPBACK 4
|
#define MAX_LOOPBACK 4
|
||||||
#define MASK_LOOPBACK (MAX_LOOPBACK - 1)
|
#define MASK_LOOPBACK (MAX_LOOPBACK - 1)
|
||||||
|
|
||||||
@@ -132,7 +131,7 @@ static CVAR_DEFINE_AUTO( net6_address, "0", FCVAR_PRIVILEGED|FCVAR_READ_ONLY, "c
|
|||||||
NET_ErrorString
|
NET_ErrorString
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
char *NET_ErrorString( void )
|
static char *NET_ErrorString( void )
|
||||||
{
|
{
|
||||||
#if XASH_WIN32
|
#if XASH_WIN32
|
||||||
int err = WSANOTINITIALISED;
|
int err = WSANOTINITIALISED;
|
||||||
@@ -226,34 +225,17 @@ _inline qboolean NET_IsSocketValid( int socket )
|
|||||||
|
|
||||||
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr )
|
void NET_NetadrToIP6Bytes( uint8_t *ip6, const netadr_t *adr )
|
||||||
{
|
{
|
||||||
#if XASH_LITTLE_ENDIAN
|
|
||||||
memcpy( ip6, adr->ip6, sizeof( adr->ip6 ));
|
memcpy( ip6, adr->ip6, sizeof( adr->ip6 ));
|
||||||
#elif XASH_BIG_ENDIAN
|
|
||||||
memcpy( ip6, adr->ip6_0, sizeof( adr->ip6_0 ));
|
|
||||||
memcpy( ip6 + sizeof( adr->ip6_0 ), adr->ip6_2, sizeof( adr->ip6_2 ));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 )
|
void NET_IP6BytesToNetadr( netadr_t *adr, const uint8_t *ip6 )
|
||||||
{
|
{
|
||||||
#if XASH_LITTLE_ENDIAN
|
|
||||||
memcpy( adr->ip6, ip6, sizeof( adr->ip6 ));
|
memcpy( adr->ip6, ip6, sizeof( adr->ip6 ));
|
||||||
#elif XASH_BIG_ENDIAN
|
|
||||||
memcpy( adr->ip6_0, ip6, sizeof( adr->ip6_0 ));
|
|
||||||
memcpy( adr->ip6_2, ip6 + sizeof( adr->ip6_0 ), sizeof( adr->ip6_2 ));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_inline int NET_NetadrIP6Compare( const netadr_t *a, const netadr_t *b )
|
static int NET_NetadrIP6Compare( const netadr_t *a, const netadr_t *b )
|
||||||
{
|
{
|
||||||
#if XASH_LITTLE_ENDIAN
|
|
||||||
return memcmp( a->ip6, b->ip6, sizeof( a->ip6 ));
|
return memcmp( a->ip6, b->ip6, sizeof( a->ip6 ));
|
||||||
#elif XASH_BIG_ENDIAN
|
|
||||||
int ret = memcmp( a->ip6_0, b->ip6_0, sizeof( a->ip6_0 ));
|
|
||||||
if( !ret )
|
|
||||||
return memcmp( a->ip6_2, b->ip6_2, sizeof( a->ip6_2 ));
|
|
||||||
return ret;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -374,7 +356,7 @@ qboolean NET_GetHostByName( const char *hostname, int family, struct sockaddr_st
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !XASH_EMSCRIPTEN && !XASH_DOS4GW && !defined XASH_NO_ASYNC_NS_RESOLVE
|
#if !XASH_EMSCRIPTEN && !XASH_DOS4GW && !XASH_PSP && !defined XASH_NO_ASYNC_NS_RESOLVE
|
||||||
#define CAN_ASYNC_NS_RESOLVE
|
#define CAN_ASYNC_NS_RESOLVE
|
||||||
#endif // !XASH_EMSCRIPTEN && !XASH_DOS4GW && !defined XASH_NO_ASYNC_NS_RESOLVE
|
#endif // !XASH_EMSCRIPTEN && !XASH_DOS4GW && !defined XASH_NO_ASYNC_NS_RESOLVE
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,18 @@ GNU General Public License for more details.
|
|||||||
#define NETSPLIT_BACKUP 8
|
#define NETSPLIT_BACKUP 8
|
||||||
#define NETSPLIT_BACKUP_MASK (NETSPLIT_BACKUP - 1)
|
#define NETSPLIT_BACKUP_MASK (NETSPLIT_BACKUP - 1)
|
||||||
#define NETSPLIT_HEADER_SIZE 18
|
#define NETSPLIT_HEADER_SIZE 18
|
||||||
|
#if XASH_PSP
|
||||||
|
#undef MULTIPLAYER_BACKUP
|
||||||
|
#undef SINGLEPLAYER_BACKUP
|
||||||
|
#undef NUM_PACKET_ENTITIES
|
||||||
|
#undef MAX_CUSTOM_BASELINES
|
||||||
|
#undef NET_MAX_FRAGMENT
|
||||||
|
#define MULTIPLAYER_BACKUP 16
|
||||||
|
#define SINGLEPLAYER_BACKUP 16
|
||||||
|
#define NUM_PACKET_ENTITIES 32
|
||||||
|
#define MAX_CUSTOM_BASELINES 8
|
||||||
|
#define NET_MAX_FRAGMENT 32768
|
||||||
|
#else
|
||||||
#if XASH_LOW_MEMORY == 2
|
#if XASH_LOW_MEMORY == 2
|
||||||
#undef MULTIPLAYER_BACKUP
|
#undef MULTIPLAYER_BACKUP
|
||||||
#undef SINGLEPLAYER_BACKUP
|
#undef SINGLEPLAYER_BACKUP
|
||||||
@@ -108,7 +119,7 @@ GNU General Public License for more details.
|
|||||||
#define MAX_CUSTOM_BASELINES 8
|
#define MAX_CUSTOM_BASELINES 8
|
||||||
#define NET_MAX_FRAGMENT 32768
|
#define NET_MAX_FRAGMENT 32768
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* XASH_PSP */
|
||||||
typedef struct netsplit_chain_packet_s
|
typedef struct netsplit_chain_packet_s
|
||||||
{
|
{
|
||||||
// bool vector
|
// bool vector
|
||||||
|
|||||||
@@ -177,6 +177,29 @@ GNU General Public License for more details.
|
|||||||
#define FRAGMENT_MAX_SIZE 64000 // maximal fragment size
|
#define FRAGMENT_MAX_SIZE 64000 // maximal fragment size
|
||||||
#define FRAGMENT_LOCAL_SIZE FRAGMENT_MAX_SIZE // local connection
|
#define FRAGMENT_LOCAL_SIZE FRAGMENT_MAX_SIZE // local connection
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
|
||||||
|
#undef MAX_VISIBLE_PACKET
|
||||||
|
#undef MAX_VISIBLE_PACKET_VIS_BYTES
|
||||||
|
#undef MAX_EVENTS
|
||||||
|
#undef MAX_SUPPORTED_MODELS
|
||||||
|
#undef MAX_MODELS
|
||||||
|
#undef MAX_SOUNDS
|
||||||
|
#undef MAX_CUSTOM
|
||||||
|
#undef MAX_RENDER_DECALS
|
||||||
|
#undef MAX_RESOURCES
|
||||||
|
|
||||||
|
#define MAX_VISIBLE_PACKET 256
|
||||||
|
#define MAX_VISIBLE_PACKET_VIS_BYTES ((MAX_VISIBLE_PACKET + 7) / 8)
|
||||||
|
#define MAX_EVENTS 256
|
||||||
|
#define MAX_SUPPORTED_MODELS 512
|
||||||
|
#define MAX_MODELS MAX_SUPPORTED_MODELS
|
||||||
|
#define MAX_SOUNDS 512
|
||||||
|
#define MAX_CUSTOM 32
|
||||||
|
#define MAX_RENDER_DECALS 256
|
||||||
|
#define MAX_RESOURCES (MAX_MODELS+MAX_SOUNDS+MAX_CUSTOM+MAX_EVENTS)
|
||||||
|
|
||||||
|
#else
|
||||||
#if XASH_LOW_MEMORY == 2
|
#if XASH_LOW_MEMORY == 2
|
||||||
#undef MAX_VISIBLE_PACKET
|
#undef MAX_VISIBLE_PACKET
|
||||||
#undef MAX_VISIBLE_PACKET_VIS_BYTES
|
#undef MAX_VISIBLE_PACKET_VIS_BYTES
|
||||||
@@ -215,7 +238,7 @@ GNU General Public License for more details.
|
|||||||
#define MAX_RENDER_DECALS 128
|
#define MAX_RENDER_DECALS 128
|
||||||
#define MAX_RESOURCES 1024
|
#define MAX_RESOURCES 1024
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* XASH_PSP */
|
||||||
// Quake1 Protocol
|
// Quake1 Protocol
|
||||||
#define PROTOCOL_VERSION_QUAKE 15
|
#define PROTOCOL_VERSION_QUAKE 15
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size )
|
|||||||
fs_offset_t filesize = 0;
|
fs_offset_t filesize = 0;
|
||||||
const loadwavfmt_t *format;
|
const loadwavfmt_t *format;
|
||||||
byte *f;
|
byte *f;
|
||||||
|
|
||||||
Sound_Reset(); // clear old sounddata
|
Sound_Reset(); // clear old sounddata
|
||||||
Q_strncpy( loadname, filename, sizeof( loadname ));
|
Q_strncpy( loadname, filename, sizeof( loadname ));
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ stream_t *FS_OpenStream( const char *filename )
|
|||||||
string path, loadname;
|
string path, loadname;
|
||||||
qboolean anyformat = true;
|
qboolean anyformat = true;
|
||||||
const streamfmt_t *format;
|
const streamfmt_t *format;
|
||||||
stream_t *stream;
|
stream_t *stream = NULL;
|
||||||
|
|
||||||
Sound_Reset(); // clear old streaminfo
|
Sound_Reset(); // clear old streaminfo
|
||||||
Q_strncpy( loadname, filename, sizeof( loadname ));
|
Q_strncpy( loadname, filename, sizeof( loadname ));
|
||||||
@@ -188,9 +188,18 @@ stream_t *FS_OpenStream( const char *filename )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Reportf( "FS_OpenStream: couldn't open \"%s\"\n", loadname );
|
// compatibility with original Xash3D, try media/ folder
|
||||||
|
if( Q_strncmp( filename, "media/", sizeof( "media/" ) - 1 ))
|
||||||
|
{
|
||||||
|
Q_snprintf( loadname, sizeof( loadname ), "media/%s", filename );
|
||||||
|
stream = FS_OpenStream( loadname );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_Reportf( "%s: couldn't open \"%s\" or \"%s\"\n", __func__, filename + 6, filename );
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "soundlib.h"
|
#include "soundlib.h"
|
||||||
|
#if !XASH_PSP
|
||||||
#include "libmpg/libmpg.h"
|
#include "libmpg/libmpg.h"
|
||||||
|
|
||||||
#pragma pack( push, 1 )
|
#pragma pack( push, 1 )
|
||||||
@@ -455,3 +455,485 @@ void Stream_FreeMPG( stream_t *stream )
|
|||||||
|
|
||||||
Mem_Free( stream );
|
Mem_Free( stream );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // XASH_PSP
|
||||||
|
#include "platform/psp/scemp3/pspmp3.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
PSP MPEG decoding
|
||||||
|
|
||||||
|
=================================================================
|
||||||
|
*/
|
||||||
|
#define MP3_ID3V1_ID "TAG"
|
||||||
|
#define MP3_ID3V1_ID_SZ 3
|
||||||
|
#define MP3_ID3V1_SZ 128
|
||||||
|
|
||||||
|
#define MP3_ID3V2_ID "ID3"
|
||||||
|
#define MP3_ID3V2_ID_SZ 3
|
||||||
|
#define MP3_ID3V2_SIZE_OFF 6
|
||||||
|
#define MP3_ID3V2_SIZE_SZ 4
|
||||||
|
#define MP3_ID3V2_HEADER_SZ 10
|
||||||
|
|
||||||
|
#define MP3_ERRORS_MAX 3
|
||||||
|
|
||||||
|
#define PCM_WIDTH 2 // always 16-bit PCM
|
||||||
|
#define PCM_CHANNELS 2 // always 2
|
||||||
|
|
||||||
|
#define MP3_BUFFER_SIZE ( 128 * 1024 )
|
||||||
|
#define PCM_BUFFER_SIZE (( 1152 * PCM_WIDTH * PCM_CHANNELS ) * 2 ) // framesample * width * channels * 2(double buffer)
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int handle;
|
||||||
|
int cachePos;
|
||||||
|
int frameCount;
|
||||||
|
byte *pcmTempPtr;
|
||||||
|
} mp3_decoder_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Sound_GetID3V2SizeMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
__inline int Sound_GetID3V2SizeMPG( const byte *tagSize )
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
byte *sizePtr = (byte*)&size;
|
||||||
|
|
||||||
|
// 7 bit per byte, invert endian
|
||||||
|
sizePtr[0] = (( tagSize[3] >> 0 ) & 0x7F ) | (( tagSize[2] & 0x01 ) << 7 );
|
||||||
|
sizePtr[1] = (( tagSize[2] >> 1 ) & 0x3F ) | (( tagSize[1] & 0x03 ) << 6 );
|
||||||
|
sizePtr[2] = (( tagSize[1] >> 2 ) & 0x1F ) | (( tagSize[0] & 0x07 ) << 5 );
|
||||||
|
sizePtr[3] = (( tagSize[0] >> 3 ) & 0x0F );
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Sound_FindHeadMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
fs_offset_t Sound_FindHeadMPG( const byte *buffer, fs_offset_t filesize )
|
||||||
|
{
|
||||||
|
fs_offset_t result;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
if( filesize >= MP3_ID3V2_HEADER_SZ )
|
||||||
|
{
|
||||||
|
if( !memcmp( buffer, MP3_ID3V2_ID, MP3_ID3V2_ID_SZ ))
|
||||||
|
result = Sound_GetID3V2SizeMPG( &buffer[MP3_ID3V2_SIZE_OFF] ) + MP3_ID3V2_HEADER_SZ;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Sound_FindTailMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
fs_offset_t Sound_FindTailMPG( const byte *buffer, fs_offset_t filesize )
|
||||||
|
{
|
||||||
|
fs_offset_t result;
|
||||||
|
|
||||||
|
result = filesize;
|
||||||
|
if( filesize >= MP3_ID3V1_SZ )
|
||||||
|
{
|
||||||
|
if( !memcmp( &buffer[filesize - MP3_ID3V1_SZ], MP3_ID3V1_ID, MP3_ID3V1_ID_SZ ))
|
||||||
|
result -= MP3_ID3V1_SZ;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
qboolean Sound_LoadMPG( const char *name, const byte *buffer, fs_offset_t filesize )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
int status;
|
||||||
|
int handle;
|
||||||
|
size_t bytesWrite = 0;
|
||||||
|
byte out[PCM_BUFFER_SIZE] __attribute__((aligned(64)));
|
||||||
|
fs_offset_t headOffset;
|
||||||
|
fs_offset_t tailOffset;
|
||||||
|
fs_offset_t contentSize;
|
||||||
|
int frameSample;
|
||||||
|
uint bps;
|
||||||
|
int frameLen;
|
||||||
|
int frameSize;
|
||||||
|
int frameCount;
|
||||||
|
|
||||||
|
headOffset = Sound_FindHeadMPG( buffer, filesize );
|
||||||
|
tailOffset = Sound_FindTailMPG( buffer, filesize );
|
||||||
|
contentSize = tailOffset - headOffset;
|
||||||
|
// TODO: read Xing header
|
||||||
|
|
||||||
|
handle = sceMp3ReserveMp3Handle( NULL );
|
||||||
|
if ( handle < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3ReserveMp3Handle returned 0x%08X\n", handle );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = sceMp3LowLevelInit( handle, &buffer[headOffset] );
|
||||||
|
if ( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3LowLevelInit returned 0x%08X\n", status );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
frameSample = sceMp3GetMaxOutputSample( handle );
|
||||||
|
frameSize = (( frameSample / 8 ) * sceMp3GetBitRate( handle ) * 1000 ) / sceMp3GetSamplingRate( handle );
|
||||||
|
frameCount = contentSize / frameSize;
|
||||||
|
|
||||||
|
sound.channels = sceMp3GetMp3ChannelNum( handle );
|
||||||
|
sound.rate = sceMp3GetSamplingRate( handle );
|
||||||
|
sound.width = PCM_WIDTH; // always 16-bit PCM
|
||||||
|
sound.loopstart = -1;
|
||||||
|
sound.size = (frameCount * frameSample) * sound.channels * sound.width; // invalid for VBR
|
||||||
|
/*
|
||||||
|
status = sceMp3LowLevelDecode(handle, &buffer[headOffset + mp3usedsize], &mp3usedsize, pcm, &pcmoutsize);
|
||||||
|
if(status < 0)
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3LowLevelDecode returned 0x%08X\n", status);
|
||||||
|
}
|
||||||
|
sceMp3ReleaseMp3Handle( handle );
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
Con_DPrintf( S_ERROR "Sound_LoadMPG unimplemented function!\n");
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_FindHeadMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
SceOff Stream_FindHeadMPG( file_t *file )
|
||||||
|
{
|
||||||
|
SceOff result;
|
||||||
|
byte tagId[MP3_ID3V2_ID_SZ];
|
||||||
|
byte tagSize[MP3_ID3V2_SIZE_SZ];
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
FS_Seek( file, 0, SEEK_SET );
|
||||||
|
|
||||||
|
if( FS_Read( file, tagId, MP3_ID3V2_ID_SZ) < MP3_ID3V2_ID_SZ )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "Sound_Mp3FindHead: ID3V2 ID read error\n");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !memcmp( tagId, MP3_ID3V2_ID, MP3_ID3V2_ID_SZ ))
|
||||||
|
{
|
||||||
|
FS_Seek( file, MP3_ID3V2_SIZE_OFF, SEEK_SET );
|
||||||
|
if( FS_Read( file, tagSize, MP3_ID3V2_SIZE_SZ ) < MP3_ID3V2_SIZE_SZ )
|
||||||
|
Con_DPrintf( S_ERROR "Sound_Mp3FindHead: ID3V2 SIZE read error\n");
|
||||||
|
else result = Sound_GetID3V2SizeMPG( tagSize ) + MP3_ID3V2_HEADER_SZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_FindTailMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
SceOff Stream_FindTailMPG( file_t *file )
|
||||||
|
{
|
||||||
|
SceOff result;
|
||||||
|
byte tagId[MP3_ID3V1_ID_SZ];
|
||||||
|
|
||||||
|
result = FS_FileLength( file );
|
||||||
|
|
||||||
|
FS_Seek( file, result - MP3_ID3V1_SZ, SEEK_SET );
|
||||||
|
|
||||||
|
if( FS_Read( file, tagId, MP3_ID3V1_ID_SZ ) < MP3_ID3V1_ID_SZ )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "Sound_Mp3FindTail: ID3V1 ID read error\n");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !memcmp( tagId, MP3_ID3V1_ID, MP3_ID3V1_ID_SZ ))
|
||||||
|
result -= MP3_ID3V1_SZ;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_FillBufferMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
int Stream_FillBufferMPG( file_t *file, mp3_decoder_t *desc )
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
byte *dstPtr;
|
||||||
|
int dstSize;
|
||||||
|
int dstPos;
|
||||||
|
fs_offset_t readSize;
|
||||||
|
|
||||||
|
if( sceMp3CheckStreamDataNeeded( desc->handle ) <= 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// get Info on the stream (where to fill to, how much to fill, where to fill from)
|
||||||
|
status = sceMp3GetInfoToAddStreamData( desc->handle, &dstPtr, &dstSize, &dstPos );
|
||||||
|
if( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3GetInfoToAddStreamData returned 0x%08X\n", status);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// seek file to position requested
|
||||||
|
if( desc->cachePos != dstPos )
|
||||||
|
{
|
||||||
|
FS_Seek( file, dstPos, SEEK_SET );
|
||||||
|
desc->cachePos = dstPos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// read the amount of data
|
||||||
|
readSize = FS_Read( file, dstPtr, dstSize );
|
||||||
|
desc->cachePos += ( int )readSize;
|
||||||
|
|
||||||
|
// notify mp3 library about how much we really wrote to the stream buffer
|
||||||
|
status = sceMp3NotifyAddStreamData( desc->handle, ( int )readSize );
|
||||||
|
if ( status < 0 )
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3NotifyAddStreamData returned 0x%08X\n", status);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_OpenMPG
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
stream_t *Stream_OpenMPG( const char *filename )
|
||||||
|
{
|
||||||
|
stream_t *stream;
|
||||||
|
mp3_decoder_t *desc;
|
||||||
|
file_t *file;
|
||||||
|
int status;
|
||||||
|
void *bufferBase;
|
||||||
|
|
||||||
|
file = FS_Open( filename, "rbh", false ); // hold mode
|
||||||
|
if( !file ) return NULL;
|
||||||
|
|
||||||
|
// at this point we have valid stream
|
||||||
|
stream = Mem_Calloc( host.soundpool, sizeof( stream_t ));
|
||||||
|
stream->file = file;
|
||||||
|
stream->pos = 0;
|
||||||
|
|
||||||
|
desc = Mem_Calloc( host.soundpool, sizeof( mp3_decoder_t ) + MP3_BUFFER_SIZE + PCM_BUFFER_SIZE + 63 );
|
||||||
|
bufferBase = (void *)(((( uintptr_t )desc + sizeof( mp3_decoder_t )) & (~( 64 - 1 ))) + 64 );
|
||||||
|
|
||||||
|
// reserve a mp3 handle
|
||||||
|
SceMp3InitArg mp3Init;
|
||||||
|
mp3Init.mp3StreamStart = Stream_FindHeadMPG( file );
|
||||||
|
mp3Init.mp3StreamEnd = Stream_FindTailMPG( file );
|
||||||
|
mp3Init.mp3Buf = bufferBase;
|
||||||
|
mp3Init.mp3BufSize = MP3_BUFFER_SIZE;
|
||||||
|
mp3Init.pcmBuf = (void *)(( uintptr_t )bufferBase + MP3_BUFFER_SIZE );
|
||||||
|
mp3Init.pcmBufSize = PCM_BUFFER_SIZE;
|
||||||
|
|
||||||
|
desc->cachePos = 0;
|
||||||
|
desc->pcmTempPtr = mp3Init.pcmBuf;
|
||||||
|
desc->handle = sceMp3ReserveMp3Handle( &mp3Init );
|
||||||
|
if ( desc->handle < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3ReserveMp3Handle returned 0x%08X\n", desc->handle );
|
||||||
|
Mem_Free( stream );
|
||||||
|
Mem_Free( desc );
|
||||||
|
FS_Close( file );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill the stream buffer with some data so that sceMp3Init has something to work with
|
||||||
|
if( Stream_FillBufferMPG( file, desc ) != 0 )
|
||||||
|
{
|
||||||
|
Mem_Free( stream );
|
||||||
|
Mem_Free( desc );
|
||||||
|
FS_Close( file );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = sceMp3Init( desc->handle );
|
||||||
|
if ( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3Init returned 0x%08X\n", status );
|
||||||
|
Mem_Free( stream );
|
||||||
|
Mem_Free( desc );
|
||||||
|
FS_Close( file );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
desc->frameCount = sceMp3GetFrameNum( desc->handle );
|
||||||
|
|
||||||
|
stream->buffsize = 0; // how many samples left from previous frame
|
||||||
|
stream->channels = PCM_CHANNELS; // always 2 PCM channels
|
||||||
|
stream->rate = sceMp3GetSamplingRate( desc->handle );
|
||||||
|
stream->width = PCM_WIDTH; // always 16 bit PCM
|
||||||
|
stream->ptr = (void *)desc;
|
||||||
|
stream->type = WF_MPGDATA;
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_ReadMPG
|
||||||
|
|
||||||
|
assume stream is valid
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
int Stream_ReadMPG( stream_t *stream, int needBytes, void *buffer )
|
||||||
|
{
|
||||||
|
// buffer handling
|
||||||
|
int bytesWritten = 0;
|
||||||
|
mp3_decoder_t *desc;
|
||||||
|
int errdec;
|
||||||
|
|
||||||
|
desc = ( mp3_decoder_t* )stream->ptr;
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
byte *data;
|
||||||
|
int outsize;
|
||||||
|
|
||||||
|
if( !stream->buffsize )
|
||||||
|
{
|
||||||
|
// Check if we need to fill our stream buffer
|
||||||
|
if( Stream_FillBufferMPG( stream->file, desc ) != 0 )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for( errdec = 0; errdec < MP3_ERRORS_MAX; errdec++ )
|
||||||
|
{
|
||||||
|
stream->pos = sceMp3Decode( desc->handle, (SceShort16**)&desc->pcmTempPtr );
|
||||||
|
if(( int )stream->pos >= 0 ) // decoding successful
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if( stream->pos == 0x80671402 ) // next frame header
|
||||||
|
{
|
||||||
|
if( Stream_FillBufferMPG( stream->file, desc ) != 0 )
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( int )stream->pos < 0 )
|
||||||
|
{
|
||||||
|
if( stream->pos != 0x80671402 )
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3Decode returned 0x%08X\n", stream->pos );
|
||||||
|
return 0; // ???
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// check remaining size
|
||||||
|
if( bytesWritten + stream->pos > needBytes )
|
||||||
|
outsize = ( needBytes - bytesWritten );
|
||||||
|
else outsize = stream->pos;
|
||||||
|
|
||||||
|
// copy raw sample to output buffer
|
||||||
|
data = (byte *)buffer + bytesWritten;
|
||||||
|
memcpy( data, &desc->pcmTempPtr[stream->buffsize], outsize );
|
||||||
|
bytesWritten += outsize;
|
||||||
|
stream->pos -= outsize;
|
||||||
|
stream->buffsize += outsize;
|
||||||
|
|
||||||
|
// continue from this sample on a next call
|
||||||
|
if( bytesWritten >= needBytes )
|
||||||
|
return bytesWritten;
|
||||||
|
|
||||||
|
stream->buffsize = 0; // no bytes remaining
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_SetPosMPG
|
||||||
|
|
||||||
|
assume stream is valid
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
int Stream_SetPosMPG( stream_t *stream, int newpos )
|
||||||
|
{
|
||||||
|
mp3_decoder_t *desc;
|
||||||
|
int frame;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
desc = ( mp3_decoder_t* )stream->ptr;
|
||||||
|
|
||||||
|
// get frame num
|
||||||
|
frame = newpos / sceMp3GetMaxOutputSample( desc->handle ); // VBR?
|
||||||
|
|
||||||
|
if( frame < 1 || frame >= desc->frameCount - 1 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
status = sceMp3ResetPlayPositionByFrame( desc->handle, frame );
|
||||||
|
if( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3ResetPlayPositionByFrame returned 0x%08X\n", status );
|
||||||
|
|
||||||
|
// failed to seek for some reasons
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// flush any previous data
|
||||||
|
stream->buffsize = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_GetPosMPG
|
||||||
|
|
||||||
|
assume stream is valid
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
int Stream_GetPosMPG( stream_t *stream )
|
||||||
|
{
|
||||||
|
mp3_decoder_t *desc;
|
||||||
|
|
||||||
|
desc = ( mp3_decoder_t * )stream->ptr;
|
||||||
|
|
||||||
|
return sceMp3GetSumDecodedSample( desc->handle );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
Stream_FreeMPG
|
||||||
|
|
||||||
|
assume stream is valid
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void Stream_FreeMPG( stream_t *stream )
|
||||||
|
{
|
||||||
|
mp3_decoder_t *desc;
|
||||||
|
|
||||||
|
desc = ( mp3_decoder_t * )stream->ptr;
|
||||||
|
if( desc )
|
||||||
|
{
|
||||||
|
sceMp3ReleaseMp3Handle( desc->handle );
|
||||||
|
Mem_Free( desc );
|
||||||
|
stream->ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( stream->file )
|
||||||
|
{
|
||||||
|
FS_Close( stream->file );
|
||||||
|
stream->file = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Mem_Free( stream );
|
||||||
|
}
|
||||||
|
#endif // XASH_PSP
|
||||||
|
|||||||
@@ -331,7 +331,8 @@ stream_t *Stream_OpenWAV( const char *filename )
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// open
|
// open
|
||||||
file = FS_Open( filename, "rb", false );
|
// h - hold mode
|
||||||
|
file = FS_Open( filename, "rbh", false );
|
||||||
if( !file ) return NULL;
|
if( !file ) return NULL;
|
||||||
|
|
||||||
// find "RIFF" chunk
|
// find "RIFF" chunk
|
||||||
|
|||||||
@@ -74,7 +74,9 @@ struct stream_s
|
|||||||
|
|
||||||
// current stream state
|
// current stream state
|
||||||
void *ptr; // internal decoder state
|
void *ptr; // internal decoder state
|
||||||
|
#if !XASH_PSP
|
||||||
char temp[OUTBUF_SIZE]; // mpeg decoder stuff
|
char temp[OUTBUF_SIZE]; // mpeg decoder stuff
|
||||||
|
#endif
|
||||||
size_t pos; // actual track position (or actual buffer remains)
|
size_t pos; // actual track position (or actual buffer remains)
|
||||||
int buffsize; // cached buffer size
|
int buffsize; // cached buffer size
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ GNU General Public License for more details.
|
|||||||
#include <vitasdk.h>
|
#include <vitasdk.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#include <psputility_sysparam.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "menu_int.h" // _UPDATE_PAGE macro
|
#include "menu_int.h" // _UPDATE_PAGE macro
|
||||||
|
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
@@ -144,6 +149,10 @@ const char *Sys_GetCurrentUser( void )
|
|||||||
|
|
||||||
if( pw )
|
if( pw )
|
||||||
return pw->pw_name;
|
return pw->pw_name;
|
||||||
|
#elif XASH_PSP
|
||||||
|
static string s_userName;
|
||||||
|
if( sceUtilityGetSystemParamString( PSP_SYSTEMPARAM_ID_STRING_NICKNAME, s_userName, sizeof( s_userName )) == 0 )
|
||||||
|
return s_userName;
|
||||||
#endif
|
#endif
|
||||||
return "Player";
|
return "Player";
|
||||||
}
|
}
|
||||||
@@ -485,7 +494,12 @@ Sys_Quit
|
|||||||
void Sys_Quit( void )
|
void Sys_Quit( void )
|
||||||
{
|
{
|
||||||
Host_Shutdown();
|
Host_Shutdown();
|
||||||
|
#if XASH_PSP
|
||||||
|
sceKernelDelayThread( 50 * 1000 );
|
||||||
|
sceKernelExitGame();
|
||||||
|
#else
|
||||||
exit( error_on_exit );
|
exit( error_on_exit );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ void Test_RunCvar( void );
|
|||||||
void Test_RunCon( void );
|
void Test_RunCon( void );
|
||||||
void Test_RunVOX( void );
|
void Test_RunVOX( void );
|
||||||
void Test_RunIPFilter( void );
|
void Test_RunIPFilter( void );
|
||||||
|
void Test_RunGamma( void );
|
||||||
|
|
||||||
#define TEST_LIST_0 \
|
#define TEST_LIST_0 \
|
||||||
Test_RunLibCommon(); \
|
Test_RunLibCommon(); \
|
||||||
@@ -47,7 +48,8 @@ void Test_RunIPFilter( void );
|
|||||||
Test_RunIPFilter();
|
Test_RunIPFilter();
|
||||||
|
|
||||||
#define TEST_LIST_0_CLIENT \
|
#define TEST_LIST_0_CLIENT \
|
||||||
Test_RunCon();
|
Test_RunCon(); \
|
||||||
|
Test_RunGamma();
|
||||||
|
|
||||||
#define TEST_LIST_1 \
|
#define TEST_LIST_1 \
|
||||||
Test_RunImagelib();
|
Test_RunImagelib();
|
||||||
|
|||||||
@@ -48,8 +48,6 @@ qboolean R_Init_Video( const int type )
|
|||||||
{
|
{
|
||||||
qboolean retval;
|
qboolean retval;
|
||||||
|
|
||||||
VID_StartupGamma();
|
|
||||||
|
|
||||||
if( type != REF_SOFTWARE )
|
if( type != REF_SOFTWARE )
|
||||||
return false; /// glide???
|
return false; /// glide???
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@@ -24,6 +27,19 @@ GNU General Public License for more details.
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#if defined(__GLIBC__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 30)
|
||||||
|
// Library support was added in glibc 2.30.
|
||||||
|
// Earlier glibc versions did not provide a wrapper for this system call,
|
||||||
|
// necessitating the use of syscall(2).
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
|
static pid_t gettid( void )
|
||||||
|
{
|
||||||
|
return syscall( SYS_gettid );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void *g_hsystemd;
|
static void *g_hsystemd;
|
||||||
static int (*g_pfn_sd_notify)( int unset_environment, const char *state );
|
static int (*g_pfn_sd_notify)( int unset_environment, const char *state );
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ qboolean R_Init_Video( const int type )
|
|||||||
string fbdev = DEFAULT_FBDEV;
|
string fbdev = DEFAULT_FBDEV;
|
||||||
fb.fd = -1;
|
fb.fd = -1;
|
||||||
|
|
||||||
VID_StartupGamma();
|
|
||||||
|
|
||||||
if( type != REF_SOFTWARE )
|
if( type != REF_SOFTWARE )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ void Platform_SetStatus( const char *status );
|
|||||||
// legacy iOS port functions
|
// legacy iOS port functions
|
||||||
#if TARGET_OS_IOS
|
#if TARGET_OS_IOS
|
||||||
const char *IOS_GetDocsDir( void );
|
const char *IOS_GetDocsDir( void );
|
||||||
|
void IOS_LaunchDialog( void );
|
||||||
#endif // TARGET_OS_IOS
|
#endif // TARGET_OS_IOS
|
||||||
|
|
||||||
#if XASH_WIN32 || XASH_LINUX
|
#if XASH_WIN32 || XASH_LINUX
|
||||||
@@ -57,6 +58,15 @@ void SDLash_Init( void );
|
|||||||
void SDLash_Shutdown( void );
|
void SDLash_Shutdown( void );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
void Platform_ReadCmd( const char *fname, int *argc, char **argv );
|
||||||
|
SceUID Platform_LoadModule( const char *filename, int mpid, SceSize argsize, void *argp );
|
||||||
|
int Platform_UnloadModule( SceUID modid, int *sce_code );
|
||||||
|
|
||||||
|
#include "psp/p5ram_psp.h"
|
||||||
|
#include "psp/fsh_psp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if XASH_ANDROID
|
#if XASH_ANDROID
|
||||||
const char *Android_GetAndroidID( void );
|
const char *Android_GetAndroidID( void );
|
||||||
const char *Android_LoadID( void );
|
const char *Android_LoadID( void );
|
||||||
|
|||||||
410
engine/platform/psp/fsh_psp.c
Normal file
410
engine/platform/psp/fsh_psp.c
Normal file
@@ -0,0 +1,410 @@
|
|||||||
|
/*
|
||||||
|
fsh_psp.c - PSP filesystem helper
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#include <pspiofilemgr.h>
|
||||||
|
#include "common.h"
|
||||||
|
#include "fsh_psp.h"
|
||||||
|
|
||||||
|
#define FSH_MAX_PATH 64
|
||||||
|
#define FSH_EMPTY_STRING "*empty*"
|
||||||
|
|
||||||
|
typedef struct fsh_path_s
|
||||||
|
{
|
||||||
|
char path[FSH_MAX_PATH];
|
||||||
|
int fsize;
|
||||||
|
uint hashvalue;
|
||||||
|
struct fsh_path_s *nexthash;
|
||||||
|
}fsh_path_t;
|
||||||
|
|
||||||
|
typedef struct fsh_handle_s
|
||||||
|
{
|
||||||
|
qboolean ready;
|
||||||
|
int count;
|
||||||
|
char folderpath[PATH_MAX];
|
||||||
|
int folderpath_size;
|
||||||
|
uint empty_hash;
|
||||||
|
int pathlist_size;
|
||||||
|
int hashlist_size;
|
||||||
|
fsh_path_t *pathlist;
|
||||||
|
fsh_path_t **hashlist;
|
||||||
|
struct fsh_handle_s *next;
|
||||||
|
}fsh_handle_t;
|
||||||
|
|
||||||
|
static fsh_handle_t *fsh_poolchain = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_AddHash
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
_inline void FSH_AddHash( fsh_path_t **hashlist, uint hash, fsh_path_t *fptr )
|
||||||
|
{
|
||||||
|
fptr->hashvalue = hash;
|
||||||
|
fptr->nexthash = hashlist[hash];
|
||||||
|
hashlist[hash] = fptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_RemoveHash
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
_inline void FSH_RemoveHash( fsh_path_t **hashlist, uint hash, fsh_path_t *fptr )
|
||||||
|
{
|
||||||
|
fsh_path_t **fptr_prev;
|
||||||
|
|
||||||
|
for( fptr_prev = &hashlist[hash]; *fptr_prev != NULL; fptr_prev = &( *fptr_prev )->nexthash )
|
||||||
|
{
|
||||||
|
if( *fptr_prev == fptr )
|
||||||
|
{
|
||||||
|
*fptr_prev = fptr->nexthash;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_AddFilePath
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
int FSH_AddFilePathWs( fsh_handle_t *handle, const char *path, int size )
|
||||||
|
{
|
||||||
|
uint hash;
|
||||||
|
fsh_path_t *fptr;
|
||||||
|
const char *strip_path;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if( Q_strnicmp( path, handle->folderpath, handle->folderpath_size ))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
strip_path = path + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
|
||||||
|
if( handle->ready && handle->count > 0 )
|
||||||
|
{
|
||||||
|
// see if already added
|
||||||
|
for( fptr = handle->hashlist[hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, strip_path ))
|
||||||
|
return fptr - handle->pathlist; // index
|
||||||
|
}
|
||||||
|
|
||||||
|
// find empty
|
||||||
|
for( fptr = handle->hashlist[handle->empty_hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, FSH_EMPTY_STRING ))
|
||||||
|
{
|
||||||
|
Q_strncpy( fptr->path, strip_path, FSH_MAX_PATH - 1 );
|
||||||
|
|
||||||
|
// file size
|
||||||
|
fptr->fsize = size;
|
||||||
|
|
||||||
|
// remove empty from hash table
|
||||||
|
FSH_RemoveHash( handle->hashlist, handle->empty_hash, fptr );
|
||||||
|
|
||||||
|
// add to hash table
|
||||||
|
FSH_AddHash( handle->hashlist, hash, fptr );
|
||||||
|
|
||||||
|
return fptr - handle->pathlist; // index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create new
|
||||||
|
if( handle->count + 1 >= handle->pathlist_size )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
fptr = &handle->pathlist[handle->count];
|
||||||
|
Q_strncpy( fptr->path, strip_path, FSH_MAX_PATH - 1 );
|
||||||
|
|
||||||
|
// file size
|
||||||
|
fptr->fsize = size;
|
||||||
|
|
||||||
|
// add to hash table
|
||||||
|
FSH_AddHash( handle->hashlist, hash, fptr );
|
||||||
|
|
||||||
|
handle->count++;
|
||||||
|
|
||||||
|
return fptr - handle->pathlist; // index
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_RemoveFilePath
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
int FSH_RemoveFilePath( fsh_handle_t *handle, const char *path )
|
||||||
|
{
|
||||||
|
uint hash;
|
||||||
|
fsh_path_t *fptr, **fptr_prev;
|
||||||
|
const char *strip_path;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if( Q_strnicmp( path, handle->folderpath, handle->folderpath_size ))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
strip_path = path + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
|
||||||
|
for( fptr = handle->hashlist[hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, strip_path ))
|
||||||
|
{
|
||||||
|
memset( fptr->path, 0, FSH_MAX_PATH );
|
||||||
|
Q_strncpy( fptr->path, FSH_EMPTY_STRING, FSH_MAX_PATH - 1 );
|
||||||
|
fptr->fsize = -3; // undefined
|
||||||
|
|
||||||
|
// remove from hash table
|
||||||
|
FSH_RemoveHash( handle->hashlist, hash, fptr );
|
||||||
|
|
||||||
|
// add empty to hash table
|
||||||
|
FSH_AddHash( handle->hashlist, handle->empty_hash, fptr );
|
||||||
|
|
||||||
|
return fptr - handle->pathlist; // index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_RenameFilePath
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
int FSH_RenameFilePath( fsh_handle_t *handle, const char *oldname, const char *newname )
|
||||||
|
{
|
||||||
|
uint hash;
|
||||||
|
fsh_path_t *fptr, **fptr_prev;
|
||||||
|
const char *strip_path;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if( Q_strnicmp( oldname, handle->folderpath, handle->folderpath_size ))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
strip_path = oldname + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
|
||||||
|
for( fptr = handle->hashlist[hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, strip_path ))
|
||||||
|
{
|
||||||
|
strip_path = newname + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
memset( fptr->path, 0, FSH_MAX_PATH );
|
||||||
|
Q_strncpy( fptr->path, strip_path, FSH_MAX_PATH - 1 );
|
||||||
|
|
||||||
|
// remove old from hash table
|
||||||
|
FSH_RemoveHash( handle->hashlist, hash, fptr );
|
||||||
|
|
||||||
|
// add new to hash table
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
FSH_AddHash( handle->hashlist, hash, fptr );
|
||||||
|
|
||||||
|
return fptr - handle->pathlist; // index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_FindSize
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
int FSH_FindSize( fsh_handle_t *handle, const char *path )
|
||||||
|
{
|
||||||
|
uint hash;
|
||||||
|
fsh_path_t *fptr;
|
||||||
|
const char *strip_path;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if( !handle->ready || !handle->count || Q_strnicmp( path, handle->folderpath, handle->folderpath_size ))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
strip_path = path + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
|
||||||
|
for( fptr = handle->hashlist[hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, strip_path ))
|
||||||
|
return fptr->fsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_Find
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
int FSH_Find( fsh_handle_t *handle, const char *path )
|
||||||
|
{
|
||||||
|
uint hash;
|
||||||
|
fsh_path_t *fptr;
|
||||||
|
const char *strip_path;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
if( !handle->ready || !handle->count || Q_strnicmp( path, handle->folderpath, handle->folderpath_size ))
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
strip_path = path + handle->folderpath_size + 1; // + '/'
|
||||||
|
|
||||||
|
hash = COM_HashKey( strip_path, handle->hashlist_size );
|
||||||
|
|
||||||
|
for( fptr = handle->hashlist[hash]; fptr != NULL; fptr = fptr->nexthash )
|
||||||
|
{
|
||||||
|
if( !Q_stricmp( fptr->path, strip_path ))
|
||||||
|
return fptr - handle->pathlist; // index
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_ScanDir
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
static int FSH_ScanDir( fsh_handle_t *handle, const char *path )
|
||||||
|
{
|
||||||
|
SceUID dir;
|
||||||
|
SceIoDirent entry;
|
||||||
|
char temp[FSH_MAX_PATH];
|
||||||
|
int result;
|
||||||
|
int fsize;
|
||||||
|
|
||||||
|
if(( dir = sceIoDopen( path )) < 0 )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
// iterate through the directory
|
||||||
|
while( 1 )
|
||||||
|
{
|
||||||
|
// zero the dirent, to avoid possible problems with sceIoDread
|
||||||
|
memset( &entry, 0, sizeof( SceIoDirent ));
|
||||||
|
if( !sceIoDread( dir, &entry ))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// ignore the virtual directories
|
||||||
|
if( !Q_stricmp( entry.d_name, "." ) || !Q_stricmp( entry.d_name, ".." ))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sprintf( temp, "%s/%s", path, entry.d_name );
|
||||||
|
|
||||||
|
if(FIO_S_ISDIR( entry.d_stat.st_mode ))
|
||||||
|
result = FSH_ScanDir( handle, temp );
|
||||||
|
else if(FIO_S_ISREG( entry.d_stat.st_mode ))
|
||||||
|
{
|
||||||
|
if( entry.d_stat.st_size <= __INT_MAX__ )
|
||||||
|
fsize = ( int )entry.d_stat.st_size;
|
||||||
|
else fsize = -3; // undefined
|
||||||
|
|
||||||
|
result = FSH_AddFilePathWs( handle, temp, fsize );
|
||||||
|
}
|
||||||
|
else continue;
|
||||||
|
if( result < 0 ) break;
|
||||||
|
}
|
||||||
|
sceIoDclose( dir );
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_Create
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
fsh_handle_t *FSH_Create( const char *path, int maxfiles )
|
||||||
|
{
|
||||||
|
fsh_handle_t *handle;
|
||||||
|
|
||||||
|
handle = P5Ram_Alloc( sizeof( fsh_handle_t ), 1 );
|
||||||
|
if( !handle )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
handle->pathlist_size = maxfiles;
|
||||||
|
handle->pathlist = P5Ram_Alloc( handle->pathlist_size * sizeof( fsh_path_t ), 1 );
|
||||||
|
if( !handle->pathlist )
|
||||||
|
{
|
||||||
|
P5Ram_Free( handle );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->hashlist_size = maxfiles >> 2;
|
||||||
|
handle->hashlist = P5Ram_Alloc( handle->hashlist_size * sizeof( fsh_path_t* ), 1 );
|
||||||
|
if( !handle->hashlist )
|
||||||
|
{
|
||||||
|
P5Ram_Free( handle );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->empty_hash = COM_HashKey( FSH_EMPTY_STRING, handle->hashlist_size );
|
||||||
|
|
||||||
|
if( !Q_strnicmp( path, "./", 2 ))
|
||||||
|
path += 2;
|
||||||
|
|
||||||
|
Q_strncpy( handle->folderpath, path, FSH_MAX_PATH - 1 );
|
||||||
|
handle->folderpath_size = Q_strlen( handle->folderpath );
|
||||||
|
|
||||||
|
if( FSH_ScanDir( handle, handle->folderpath ) < 0 )
|
||||||
|
{
|
||||||
|
P5Ram_Free( handle );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->next = fsh_poolchain;
|
||||||
|
fsh_poolchain = handle;
|
||||||
|
|
||||||
|
handle->ready = true;
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
FSH_Shutdown
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
void FSH_Free( fsh_handle_t *handle )
|
||||||
|
{
|
||||||
|
if( !handle )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( handle->pathlist )
|
||||||
|
P5Ram_Free( handle->pathlist );
|
||||||
|
|
||||||
|
if( handle->hashlist )
|
||||||
|
P5Ram_Free( handle->hashlist );
|
||||||
|
|
||||||
|
P5Ram_Free( handle );
|
||||||
|
}
|
||||||
37
engine/platform/psp/fsh_psp.h
Normal file
37
engine/platform/psp/fsh_psp.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
fsh_psp.h - PSP filesystem helper header
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#ifndef FSH_PSP_H
|
||||||
|
#define FSH_PSP_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
typedef struct fsh_handle_s fsh_handle_t;
|
||||||
|
|
||||||
|
int FSH_AddFilePathWs( fsh_handle_t *handle, const char *path, int size );
|
||||||
|
#define FSH_AddFilePath( handle, path ) FSH_AddFilePathWs(handle, path, -2 )
|
||||||
|
int FSH_RemoveFilePath( fsh_handle_t *handle, const char *path );
|
||||||
|
int FSH_RenameFilePath( fsh_handle_t *handle, const char *oldname, const char *newname );
|
||||||
|
int FSH_FindSize( fsh_handle_t *handle, const char *path );
|
||||||
|
int FSH_Find( fsh_handle_t *handle, const char *path );
|
||||||
|
fsh_handle_t *FSH_Create( const char *path, int maxfiles );
|
||||||
|
void FSH_Free( fsh_handle_t *handle );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // P5RAM_PSP_H
|
||||||
239
engine/platform/psp/in_psp.c
Normal file
239
engine/platform/psp/in_psp.c
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
/*
|
||||||
|
in_psp.c - PSP input component
|
||||||
|
Copyright (C) 2021 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#include "common.h"
|
||||||
|
#include "keydefs.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "client.h"
|
||||||
|
|
||||||
|
#if XASH_INPUT == INPUT_PSP
|
||||||
|
#include <pspctrl.h>
|
||||||
|
|
||||||
|
#define PSP_MAX_KEYS sizeof(psp_keymap) / sizeof(struct psp_keymap_s)
|
||||||
|
#define PSP_EXT_KEY PSP_CTRL_HOME
|
||||||
|
|
||||||
|
convar_t *psp_joy_dz_min;
|
||||||
|
convar_t *psp_joy_dz_max;
|
||||||
|
convar_t *psp_joy_cv_power;
|
||||||
|
convar_t *psp_joy_cv_expo;
|
||||||
|
|
||||||
|
static struct psp_keymap_s
|
||||||
|
{
|
||||||
|
int srckey;
|
||||||
|
int dstkey;
|
||||||
|
qboolean stdpressed;
|
||||||
|
qboolean extpressed;
|
||||||
|
}psp_keymap[] =
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
{ PSP_CTRL_SELECT, '~' , false, false },
|
||||||
|
{ PSP_CTRL_START, K_ESCAPE , false, false },
|
||||||
|
{ PSP_CTRL_UP, K_UPARROW , false, false },
|
||||||
|
{ PSP_CTRL_RIGHT, K_RIGHTARROW, false, false },
|
||||||
|
{ PSP_CTRL_DOWN, K_DOWNARROW , false, false },
|
||||||
|
{ PSP_CTRL_LEFT, K_LEFTARROW , false, false },
|
||||||
|
{ PSP_CTRL_LTRIGGER, K_JOY1 , false, false },
|
||||||
|
{ PSP_CTRL_RTRIGGER, K_JOY2 , false, false },
|
||||||
|
{ PSP_CTRL_TRIANGLE, K_SHIFT , false, false },
|
||||||
|
{ PSP_CTRL_CIRCLE, K_SPACE , false, false },
|
||||||
|
{ PSP_CTRL_CROSS, K_ENTER , false, false },
|
||||||
|
{ PSP_CTRL_SQUARE, K_BACKSPACE , false, false },
|
||||||
|
#else
|
||||||
|
{ PSP_CTRL_SELECT , K_MODE_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_START , K_START_BUTTON, false, false },
|
||||||
|
{ PSP_CTRL_UP , K_UPARROW , false, false },
|
||||||
|
{ PSP_CTRL_RIGHT , K_RIGHTARROW , false, false },
|
||||||
|
{ PSP_CTRL_DOWN , K_DOWNARROW , false, false },
|
||||||
|
{ PSP_CTRL_LEFT , K_LEFTARROW , false, false },
|
||||||
|
{ PSP_CTRL_LTRIGGER, K_L1_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_RTRIGGER, K_R1_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_TRIANGLE, K_Y_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_CIRCLE , K_B_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_CROSS , K_A_BUTTON , false, false },
|
||||||
|
{ PSP_CTRL_SQUARE , K_X_BUTTON , false, false },
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
|
PSP_CTRL_HOME,
|
||||||
|
PSP_CTRL_HOLD,
|
||||||
|
PSP_CTRL_NOTE,
|
||||||
|
PSP_CTRL_SCREEN,
|
||||||
|
PSP_CTRL_VOLUP,
|
||||||
|
PSP_CTRL_VOLDOWN,
|
||||||
|
PSP_CTRL_WLAN_UP,
|
||||||
|
PSP_CTRL_REMOTE,
|
||||||
|
PSP_CTRL_DISC,
|
||||||
|
PSP_CTRL_MS,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
static signed short psp_joymap[256]; /* -32768 <> 32767 */
|
||||||
|
|
||||||
|
static float Platform_JoyAxisCompute( float axis, float deadzone_min, float deadzone_max, float power, float expo )
|
||||||
|
{
|
||||||
|
float abs_axis, fabs_axis, fcurve;
|
||||||
|
float scale, r_deadzone_max;
|
||||||
|
qboolean flip_axis = 0;
|
||||||
|
|
||||||
|
expo = bound( 0.0f, expo, 1.0f );
|
||||||
|
power = bound( 0.0f, power, 10.0f );
|
||||||
|
deadzone_min = bound( 0.0f, deadzone_min, 127.0f );
|
||||||
|
deadzone_max = bound( 0.0f, deadzone_max, 127.0f );
|
||||||
|
|
||||||
|
// (-127) - (0) - (+127)
|
||||||
|
abs_axis = axis - 128.0f;
|
||||||
|
if( abs_axis < 0.0f )
|
||||||
|
{
|
||||||
|
abs_axis = -abs_axis - 1.0f;
|
||||||
|
flip_axis = 1;
|
||||||
|
}
|
||||||
|
if( abs_axis <= deadzone_min ) return 0.0f;
|
||||||
|
r_deadzone_max = 127.0f - deadzone_max;
|
||||||
|
if( abs_axis >= r_deadzone_max ) return ( flip_axis ? -127.0f : 127.0f );
|
||||||
|
|
||||||
|
scale = 127.0f / ( r_deadzone_max - deadzone_min );
|
||||||
|
abs_axis -= deadzone_min;
|
||||||
|
abs_axis *= scale;
|
||||||
|
|
||||||
|
if( expo )
|
||||||
|
{
|
||||||
|
// x * ( x^power * expo + x * ( 1.0 - expo ))
|
||||||
|
fabs_axis = abs_axis / 127.0f; // 0.0f - 1.0f
|
||||||
|
fcurve = powf(fabs_axis, power) * expo + fabs_axis * (1.0f - expo);
|
||||||
|
abs_axis = fabs_axis * fcurve * 127.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( flip_axis ? -abs_axis : abs_axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_RunEvents( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
SceCtrlData buf;
|
||||||
|
signed short curr_X, curr_Y;
|
||||||
|
static unsigned int last_buttons;
|
||||||
|
static signed short last_X, last_Y;
|
||||||
|
|
||||||
|
sceCtrlPeekBufferPositive( &buf, 1 );
|
||||||
|
|
||||||
|
for( i = 0; i < PSP_MAX_KEYS; i++ )
|
||||||
|
{
|
||||||
|
if( buf.Buttons & PSP_EXT_KEY )
|
||||||
|
{
|
||||||
|
if(( last_buttons ^ buf.Buttons ) & psp_keymap[i].srckey )
|
||||||
|
{
|
||||||
|
if( psp_keymap[i].stdpressed )
|
||||||
|
{
|
||||||
|
psp_keymap[i].stdpressed = false;
|
||||||
|
Key_Event( psp_keymap[i].dstkey, psp_keymap[i].stdpressed );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psp_keymap[i].extpressed = buf.Buttons & psp_keymap[i].srckey;
|
||||||
|
Key_Event( K_AUX16 + i, psp_keymap[i].extpressed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// release
|
||||||
|
if( psp_keymap[i].extpressed )
|
||||||
|
{
|
||||||
|
psp_keymap[i].extpressed = false;
|
||||||
|
Key_Event( K_AUX16 + i, psp_keymap[i].extpressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( last_buttons ^ buf.Buttons ) & psp_keymap[i].srckey )
|
||||||
|
{
|
||||||
|
psp_keymap[i].stdpressed = buf.Buttons & psp_keymap[i].srckey;
|
||||||
|
Key_Event( psp_keymap[i].dstkey, psp_keymap[i].stdpressed );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last_buttons = buf.Buttons;
|
||||||
|
|
||||||
|
if( FBitSet( psp_joy_dz_min->flags, FCVAR_CHANGED ) || FBitSet( psp_joy_dz_max->flags, FCVAR_CHANGED ) ||
|
||||||
|
FBitSet( psp_joy_cv_power->flags, FCVAR_CHANGED ) || FBitSet( psp_joy_cv_expo->flags, FCVAR_CHANGED ))
|
||||||
|
{
|
||||||
|
for ( i = 0; i < 256; i++ )
|
||||||
|
{
|
||||||
|
psp_joymap[i] = Platform_JoyAxisCompute( i, psp_joy_dz_min->value, psp_joy_dz_max->value, psp_joy_cv_power->value, psp_joy_cv_expo->value );
|
||||||
|
psp_joymap[i] *= 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearBits( psp_joy_dz_min->flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( psp_joy_dz_max->flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( psp_joy_cv_power->flags, FCVAR_CHANGED );
|
||||||
|
ClearBits( psp_joy_cv_expo->flags, FCVAR_CHANGED );
|
||||||
|
}
|
||||||
|
|
||||||
|
curr_X = psp_joymap[buf.Lx];
|
||||||
|
curr_Y = psp_joymap[buf.Ly];
|
||||||
|
|
||||||
|
if( last_X != curr_X )
|
||||||
|
Joy_AxisMotionEvent( 2, -curr_X );
|
||||||
|
|
||||||
|
if( last_Y != curr_Y )
|
||||||
|
Joy_AxisMotionEvent( 3, -curr_Y );
|
||||||
|
|
||||||
|
last_X = curr_X;
|
||||||
|
last_Y = curr_Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_GetMousePos( int *x, int *y )
|
||||||
|
{
|
||||||
|
*x = *y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_SetMousePos( int x, int y )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_EnableTextInput( qboolean enable )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_JoyInit( int numjoy )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// set up cvars
|
||||||
|
psp_joy_dz_min = Cvar_Get( "psp_joy_dz_min", "15", FCVAR_ARCHIVE, "joy deadzone min (0 - 127)" );
|
||||||
|
psp_joy_dz_max = Cvar_Get( "psp_joy_dz_max", "0", FCVAR_ARCHIVE, "joy deadzone max (0 - 127)" );
|
||||||
|
psp_joy_cv_power = Cvar_Get( "psp_joy_cv_power", "2", FCVAR_ARCHIVE, "joy curve power (0 - 10)" );
|
||||||
|
psp_joy_cv_expo = Cvar_Get( "psp_joy_cv_expo", "0.5", FCVAR_ARCHIVE, "joy curve expo (0 - 1.0)" );
|
||||||
|
|
||||||
|
// set up the controller.
|
||||||
|
sceCtrlSetSamplingCycle( 0 );
|
||||||
|
sceCtrlSetSamplingMode( PSP_CTRL_MODE_ANALOG );
|
||||||
|
|
||||||
|
// building a joystick map
|
||||||
|
for ( i = 0; i < 256; i++ )
|
||||||
|
{
|
||||||
|
psp_joymap[i] = Platform_JoyAxisCompute( i, psp_joy_dz_min->value, psp_joy_dz_max->value, psp_joy_cv_power->value, psp_joy_cv_expo->value );
|
||||||
|
psp_joymap[i] *= 256;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_MouseMove( float *x, float *y )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_PreCreateMove( void )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif /* XASH_INPUT */
|
||||||
8
engine/platform/psp/ka/KernelAccess.S
Normal file
8
engine/platform/psp/ka/KernelAccess.S
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.set noreorder
|
||||||
|
|
||||||
|
#include "pspstub.s"
|
||||||
|
|
||||||
|
STUB_START "KernelAccess",0x40090000,0x00020005
|
||||||
|
STUB_FUNC 0x8A5C745F,kaGeEdramSetSize
|
||||||
|
STUB_FUNC 0x71570ECF,kaGeEdramGetHwSize
|
||||||
|
STUB_END
|
||||||
30
engine/platform/psp/ka/ka.h
Normal file
30
engine/platform/psp/ka/ka.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
kamod.h - kernel access module header
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KAMOD_H
|
||||||
|
#define KAMOD_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
int kaGeEdramSetSize(int size);
|
||||||
|
int kaGeEdramGetHwSize(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // KAMOD_H
|
||||||
486
engine/platform/psp/lib_psp.c
Normal file
486
engine/platform/psp/lib_psp.c
Normal file
@@ -0,0 +1,486 @@
|
|||||||
|
/*
|
||||||
|
lib_psp.c - dynamic library code for Sony PSP system
|
||||||
|
Copyright (C) 2018 Flying With Gauss
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/sor modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#include "platform/platform.h"
|
||||||
|
|
||||||
|
#if XASH_LIB == LIB_PSP
|
||||||
|
#include <pspmodulemgr.h>
|
||||||
|
#include "common.h"
|
||||||
|
#include "library.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
#include "server.h"
|
||||||
|
|
||||||
|
#define MOD_MAXNAMELEN 256
|
||||||
|
|
||||||
|
typedef struct table_s
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
void *pointer;
|
||||||
|
} table_t;
|
||||||
|
#include "generated_library_tables.h"
|
||||||
|
|
||||||
|
typedef struct mod_func_s
|
||||||
|
{
|
||||||
|
const char *name;
|
||||||
|
void *addr;
|
||||||
|
} mod_func_t;
|
||||||
|
|
||||||
|
typedef struct mod_handle_s
|
||||||
|
{
|
||||||
|
SceUID uid;
|
||||||
|
char name[MOD_MAXNAMELEN];
|
||||||
|
uint segAddr;
|
||||||
|
uint segSize;
|
||||||
|
mod_func_t *func;
|
||||||
|
struct mod_handle_s *next;
|
||||||
|
} mod_handle_t;
|
||||||
|
|
||||||
|
static mod_handle_t *modList = NULL;
|
||||||
|
static char *modErrorPtr = NULL;
|
||||||
|
static char modErrorBuf[1024];
|
||||||
|
|
||||||
|
#define Module_Error( fmt, ... ) Module_SetError( "%s: " fmt "\n", __FUNCTION__, ##__VA_ARGS__ )
|
||||||
|
|
||||||
|
int Module_SetError( const char *fmt, ... )
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
va_start( args, fmt );
|
||||||
|
result = Q_vsnprintf( modErrorBuf, sizeof( modErrorBuf ), fmt, args );
|
||||||
|
va_end( args );
|
||||||
|
|
||||||
|
modErrorPtr = modErrorBuf;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *Module_GetError( void )
|
||||||
|
{
|
||||||
|
char *errPtr = modErrorPtr;
|
||||||
|
modErrorPtr = NULL;
|
||||||
|
return errPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mod_handle_t *Module_Find( const char *name )
|
||||||
|
{
|
||||||
|
mod_handle_t *modHandle;
|
||||||
|
|
||||||
|
if( !name )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( modHandle = modList; modHandle; modHandle = modHandle->next )
|
||||||
|
{
|
||||||
|
if( !Q_strcmp( modHandle->name, name ))
|
||||||
|
return modHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *Module_Name( void *handle )
|
||||||
|
{
|
||||||
|
mod_handle_t *modHandle;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( modHandle = modList; modHandle; modHandle = modHandle->next )
|
||||||
|
{
|
||||||
|
if( modHandle == handle )
|
||||||
|
return modHandle->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static mod_func_t *Module_LoadStatic( const char *name )
|
||||||
|
{
|
||||||
|
table_t *staticLib;
|
||||||
|
|
||||||
|
if( !name )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( staticLib = ( table_t* )libs; staticLib->pointer && staticLib->name; staticLib++ )
|
||||||
|
{
|
||||||
|
if( !Q_strcmp( staticLib->name, name ))
|
||||||
|
return staticLib->pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod_handle_t *Module_Load( const char *name )
|
||||||
|
{
|
||||||
|
mod_handle_t *modHandle;
|
||||||
|
mod_func_t *modFunc;
|
||||||
|
qboolean skipPrefix;
|
||||||
|
char modStaticName[32];
|
||||||
|
void *modArg[2];
|
||||||
|
SceUID modUid;
|
||||||
|
uint modSegAddr, modSegSize;
|
||||||
|
SceKernelModuleInfo info;
|
||||||
|
char engine_cwd[PATH_MAX];
|
||||||
|
|
||||||
|
if( !name )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
modHandle = Module_Find( name );
|
||||||
|
if( modHandle )
|
||||||
|
return modHandle;
|
||||||
|
|
||||||
|
skipPrefix = false;
|
||||||
|
modSegAddr = modSegSize = 0;
|
||||||
|
|
||||||
|
Q_sprintf( engine_cwd, "%s/", host.rootdir );
|
||||||
|
|
||||||
|
modArg[0] = &modFunc;
|
||||||
|
modArg[1] = engine_cwd;
|
||||||
|
modUid = Platform_LoadModule( name, 0, sizeof( modArg ), modArg );
|
||||||
|
if( modUid < 0 )
|
||||||
|
{
|
||||||
|
COM_FileBase( name, modStaticName );
|
||||||
|
|
||||||
|
if( !Q_strncmp( modStaticName, "lib", 3 ) )
|
||||||
|
skipPrefix = true;
|
||||||
|
|
||||||
|
modFunc = Module_LoadStatic( skipPrefix ? &modStaticName[3] : modStaticName );
|
||||||
|
if( !modFunc )
|
||||||
|
{
|
||||||
|
Module_Error( "module %s error ( %#010x )", name, modUid );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
modUid = -1;
|
||||||
|
|
||||||
|
Con_Reportf( "Module_Load( %s ): ( static ) success!\n", name );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info.size = sizeof( info );
|
||||||
|
if ( sceKernelQueryModuleInfo( modUid, &info ) >= 0 )
|
||||||
|
{
|
||||||
|
if( info.nsegment > 0 )
|
||||||
|
{
|
||||||
|
modSegAddr = info.segmentaddr[0];
|
||||||
|
modSegSize = info.segmentsize[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Con_Reportf( "Module_Load( %s ): ( dynamic ) success!\n", name );
|
||||||
|
}
|
||||||
|
|
||||||
|
modHandle = calloc( 1, sizeof( mod_handle_t ));
|
||||||
|
if( !modHandle )
|
||||||
|
{
|
||||||
|
Module_Error( "out of memory" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_strncpy( modHandle->name, name, MOD_MAXNAMELEN );
|
||||||
|
|
||||||
|
modHandle->uid = modUid;
|
||||||
|
modHandle->func = modFunc;
|
||||||
|
modHandle->segAddr = modSegAddr;
|
||||||
|
modHandle->segSize = modSegSize;
|
||||||
|
modHandle->next = modList;
|
||||||
|
|
||||||
|
modList = modHandle;
|
||||||
|
|
||||||
|
return modHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Module_GetAddrByName( mod_handle_t *handle, const char *name )
|
||||||
|
{
|
||||||
|
mod_func_t *modFunc;
|
||||||
|
|
||||||
|
if( !handle || !name )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Module_Name( handle ))
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown handle" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !handle->func )
|
||||||
|
{
|
||||||
|
Module_SetError( "call Module_Load() first" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( modFunc = handle->func; modFunc->addr && modFunc->name; modFunc++ )
|
||||||
|
{
|
||||||
|
if( !Q_strcmp( modFunc->name, name ))
|
||||||
|
return modFunc->addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Module_Error( "func %s not found in %s", name, handle->name );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *Module_GetNameByAddr( mod_handle_t *handle, const void *addr )
|
||||||
|
{
|
||||||
|
mod_func_t *modFunc;
|
||||||
|
|
||||||
|
if( !handle || !addr )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Module_Name( handle ))
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown handle" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !handle->func )
|
||||||
|
{
|
||||||
|
Module_SetError( "call Module_Load() first" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for( modFunc = handle->func; modFunc->addr && modFunc->name; modFunc++ )
|
||||||
|
{
|
||||||
|
if( modFunc->addr == addr )
|
||||||
|
return modFunc->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Module_Error( "addr %#010x not found in %s", addr, handle->name );
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint Module_GetOffsetByAddr( mod_handle_t *handle, const void *addr )
|
||||||
|
{
|
||||||
|
uint addrUInt;
|
||||||
|
|
||||||
|
if( !handle || !addr )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Module_Name( handle ))
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown handle" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !handle->segAddr )
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown segment" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
addrUInt = ( uint )addr;
|
||||||
|
if( addrUInt < handle->segAddr || addrUInt >= ( handle->segAddr + handle->segSize ))
|
||||||
|
{
|
||||||
|
Module_SetError( "addr %#010x is out of range", addrUInt );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addrUInt - handle->segAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *Module_GetAddrByOffset( mod_handle_t *handle, uint offset )
|
||||||
|
{
|
||||||
|
if( !handle || !offset )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Module_Name( handle ))
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown handle" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !handle->segAddr )
|
||||||
|
{
|
||||||
|
Module_SetError( "unknown segment" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( offset >= handle->segSize )
|
||||||
|
{
|
||||||
|
Module_SetError( "offset %#010x is out of range", offset );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( void* )( offset + handle->segAddr );
|
||||||
|
}
|
||||||
|
|
||||||
|
int Module_Unload( mod_handle_t *handle )
|
||||||
|
{
|
||||||
|
mod_handle_t *modHandle;
|
||||||
|
int result, sceCode;
|
||||||
|
|
||||||
|
if( !handle )
|
||||||
|
{
|
||||||
|
Module_Error( "input mismatch" );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !Module_Name( handle ))
|
||||||
|
{
|
||||||
|
Module_Error( "unknown handle" );
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( handle->uid != -1 )
|
||||||
|
{
|
||||||
|
result = Platform_UnloadModule( handle->uid, &sceCode );
|
||||||
|
if( result < 0 )
|
||||||
|
{
|
||||||
|
if( result == -1 )
|
||||||
|
Module_Error( "module %s doesn't want to stop", handle->name );
|
||||||
|
else
|
||||||
|
Module_Error( "module %s error ( %#010x )", handle->name, sceCode );
|
||||||
|
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( handle != modList )
|
||||||
|
{
|
||||||
|
for( modHandle = modList; modHandle; modHandle = modHandle->next )
|
||||||
|
{
|
||||||
|
if( modHandle->next == handle )
|
||||||
|
{
|
||||||
|
modHandle->next = handle->next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else modList = handle->next;
|
||||||
|
|
||||||
|
free( handle );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qboolean COM_CheckLibraryDirectDependency( const char *name, const char *depname, qboolean directpath )
|
||||||
|
{
|
||||||
|
// TODO: implement
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *COM_LoadLibrary( const char *dllname, int build_ordinals_table, qboolean directpath )
|
||||||
|
{
|
||||||
|
dll_user_t *hInst = NULL;
|
||||||
|
void *pHandle = NULL;
|
||||||
|
|
||||||
|
COM_ResetLibraryError();
|
||||||
|
|
||||||
|
// platforms where gameinfo mechanism is working goes here
|
||||||
|
// and use FS_FindLibrary
|
||||||
|
hInst = FS_FindLibrary( dllname, directpath );
|
||||||
|
if( !hInst )
|
||||||
|
{
|
||||||
|
// try to find by linker(LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LD_32_LIBRARY_PATH and so on...)
|
||||||
|
if( !pHandle )
|
||||||
|
{
|
||||||
|
pHandle = Module_Load( dllname );
|
||||||
|
if( pHandle )
|
||||||
|
return pHandle;
|
||||||
|
|
||||||
|
COM_PushLibraryError( va( "Failed to find library %s", dllname ));
|
||||||
|
COM_PushLibraryError( Module_GetError() );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hInst->custom_loader )
|
||||||
|
{
|
||||||
|
COM_PushLibraryError( va( "Custom library loader is not available. Extract library %s and fix gameinfo.txt!", hInst->fullPath ));
|
||||||
|
Mem_Free( hInst );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !( hInst->hInstance = Module_Load( hInst->fullPath )))
|
||||||
|
{
|
||||||
|
COM_PushLibraryError( Module_GetError() );
|
||||||
|
Mem_Free( hInst );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pHandle = hInst->hInstance;
|
||||||
|
|
||||||
|
Mem_Free( hInst );
|
||||||
|
|
||||||
|
return pHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void COM_FreeLibrary( void *hInstance )
|
||||||
|
{
|
||||||
|
Module_Unload( hInstance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void *COM_GetProcAddress( void *hInstance, const char *name )
|
||||||
|
{
|
||||||
|
return Module_GetAddrByName( hInstance, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
void *COM_FunctionFromName_SR( void *hInstance, const char *pName )
|
||||||
|
{
|
||||||
|
void *funcAddr;
|
||||||
|
|
||||||
|
if( !memcmp( pName, "ofs:", 4 ))
|
||||||
|
funcAddr = Module_GetAddrByOffset( hInstance, Q_atoi( &pName[4] ));
|
||||||
|
else
|
||||||
|
funcAddr = Module_GetAddrByName( hInstance, pName );
|
||||||
|
|
||||||
|
if( !funcAddr )
|
||||||
|
Con_Reportf( S_ERROR "FunctionFromName: Can't get symbol %s: %s\n", pName, Module_GetError() );
|
||||||
|
|
||||||
|
return funcAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *COM_NameForFunction( void *hInstance, void *function )
|
||||||
|
{
|
||||||
|
static char offsetName[16];
|
||||||
|
const char *funcName;
|
||||||
|
uint addrOffset;
|
||||||
|
|
||||||
|
funcName = Module_GetNameByAddr( hInstance, function );
|
||||||
|
if( funcName )
|
||||||
|
return funcName;
|
||||||
|
|
||||||
|
addrOffset = Module_GetOffsetByAddr( hInstance, function );
|
||||||
|
if( !addrOffset )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Q_snprintf( offsetName, sizeof( offsetName ), "ofs:%u", addrOffset );
|
||||||
|
Con_Reportf( "COM_NameForFunction: %s\n", offsetName );
|
||||||
|
|
||||||
|
return offsetName;
|
||||||
|
}
|
||||||
|
#endif // XASH_LIB == LIB_PSP
|
||||||
165
engine/platform/psp/p5ram_psp.c
Normal file
165
engine/platform/psp/p5ram_psp.c
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
/*
|
||||||
|
p5ram_psp.c - PSP P5 memory allocator
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#include <psppower.h>
|
||||||
|
#include <pspsuspend.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "p5ram_psp.h"
|
||||||
|
|
||||||
|
#define P5RAM_ALIGN( x, a ) ((( x ) + (( typeof( x ))( a ) - 1 )) & ~( typeof( x )( a ) - 1 ))
|
||||||
|
|
||||||
|
#define P5RAM_CHECK( addr ) ((( unsigned int )addr >= ( unsigned int )p5ram_addr) && (( unsigned int )addr < ( unsigned int )p5ram_addr + p5ram_size))
|
||||||
|
|
||||||
|
#define P5RAM_FLAG_INIT 0x01
|
||||||
|
#define P5RAM_FLAG_SUSPENDED 0x02
|
||||||
|
|
||||||
|
typedef struct __attribute__(( aligned( 64 ))) p5ram_info_s
|
||||||
|
{
|
||||||
|
SceUID uid;
|
||||||
|
size_t size;
|
||||||
|
struct p5ram_info_s *next;
|
||||||
|
}p5ram_info_t;
|
||||||
|
|
||||||
|
static unsigned char p5ram_flags = 0x00;
|
||||||
|
static p5ram_info_t *p5ram_poolchain = NULL;
|
||||||
|
static void *p5ram_addr;
|
||||||
|
static unsigned int p5ram_size;
|
||||||
|
|
||||||
|
int P5Ram_Init( void )
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if( p5ram_flags & P5RAM_FLAG_INIT )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
result = sceKernelVolatileMemLock( 0, &p5ram_addr, &p5ram_size );
|
||||||
|
if( result == 0 )
|
||||||
|
p5ram_flags |= P5RAM_FLAG_INIT;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *P5Ram_Alloc( size_t size, int clear )
|
||||||
|
{
|
||||||
|
SceUID uid;
|
||||||
|
void *ptr;
|
||||||
|
|
||||||
|
if(!( p5ram_flags & P5RAM_FLAG_INIT ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
uid = sceKernelAllocPartitionMemory( 5, "USER P5", PSP_SMEM_Low, size + sizeof( p5ram_info_t ), NULL );
|
||||||
|
if( uid < 0 ) return NULL;
|
||||||
|
|
||||||
|
ptr = sceKernelGetBlockHeadAddr( uid );
|
||||||
|
(( p5ram_info_t* )ptr )->uid = uid;
|
||||||
|
(( p5ram_info_t* )ptr )->size = size;
|
||||||
|
(( p5ram_info_t* )ptr )->next = p5ram_poolchain;
|
||||||
|
if( clear ) memset(( unsigned char* )ptr + sizeof( p5ram_info_t ), 0, size );
|
||||||
|
|
||||||
|
p5ram_poolchain = ptr;
|
||||||
|
|
||||||
|
return ( void* )(( unsigned char* )ptr + sizeof( p5ram_info_t ));
|
||||||
|
}
|
||||||
|
|
||||||
|
void P5Ram_Free( void *ptr )
|
||||||
|
{
|
||||||
|
p5ram_info_t *info, *next_ptr;
|
||||||
|
|
||||||
|
if( !( p5ram_flags & P5RAM_FLAG_INIT ) || ptr == NULL ) return;
|
||||||
|
|
||||||
|
info = ( p5ram_info_t* )((unsigned char*)ptr - sizeof( p5ram_info_t ));
|
||||||
|
|
||||||
|
if( info == p5ram_poolchain )
|
||||||
|
{
|
||||||
|
p5ram_poolchain = p5ram_poolchain->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
next_ptr = p5ram_poolchain;
|
||||||
|
while( next_ptr )
|
||||||
|
{
|
||||||
|
if( next_ptr->next == info )
|
||||||
|
{
|
||||||
|
next_ptr->next = info->next;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
next_ptr = next_ptr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sceKernelFreePartitionMemory( info->uid );
|
||||||
|
}
|
||||||
|
|
||||||
|
void P5Ram_FreeAll( void )
|
||||||
|
{
|
||||||
|
p5ram_info_t *next_ptr;
|
||||||
|
|
||||||
|
while( p5ram_poolchain )
|
||||||
|
{
|
||||||
|
next_ptr = p5ram_poolchain->next;
|
||||||
|
sceKernelFreePartitionMemory( p5ram_poolchain->uid );
|
||||||
|
p5ram_poolchain = next_ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void P5Ram_Shutdown( void )
|
||||||
|
{
|
||||||
|
if( !( p5ram_flags & P5RAM_FLAG_INIT ))
|
||||||
|
return;
|
||||||
|
|
||||||
|
P5Ram_FreeAll();
|
||||||
|
sceKernelVolatileMemUnlock( 0 );
|
||||||
|
|
||||||
|
p5ram_flags &= ~P5RAM_FLAG_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
void P5Ram_PowerCallback( int count, int arg, void *common )
|
||||||
|
{
|
||||||
|
if( !( p5ram_flags & ( P5RAM_FLAG_INIT | P5RAM_FLAG_SUSPENDED )))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( arg & PSP_POWER_CB_POWER_SWITCH || arg & PSP_POWER_CB_SUSPENDING )
|
||||||
|
{
|
||||||
|
P5Ram_Shutdown();
|
||||||
|
p5ram_flags |= P5RAM_FLAG_SUSPENDED;
|
||||||
|
}
|
||||||
|
else if ( arg & PSP_POWER_CB_RESUMING )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if ( arg & PSP_POWER_CB_RESUME_COMPLETE )
|
||||||
|
{
|
||||||
|
P5Ram_Init();
|
||||||
|
p5ram_flags &= ~P5RAM_FLAG_SUSPENDED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef P5RAM_DEBUG
|
||||||
|
void P5Ram_Print( void )
|
||||||
|
{
|
||||||
|
p5ram_info_t *next_ptr;
|
||||||
|
|
||||||
|
printf("+++++++++++++++++++++++++++++\n");
|
||||||
|
next_ptr = p5ram_poolchain;
|
||||||
|
while( next_ptr )
|
||||||
|
{
|
||||||
|
printf("P5 ALLOC [ 0x%08X 0x%08X 0x%08X 0x%08X ]\n", next_ptr, next_ptr->uid, next_ptr->size, next_ptr->next );
|
||||||
|
next_ptr = next_ptr->next;
|
||||||
|
}
|
||||||
|
printf("+++++++++++++++++++++++++++++\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
38
engine/platform/psp/p5ram_psp.h
Normal file
38
engine/platform/psp/p5ram_psp.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
p5ram_psp.h - PSP P5 memory allocator header
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#ifndef P5RAM_PSP_H
|
||||||
|
#define P5RAM_PSP_H
|
||||||
|
|
||||||
|
//#define P5RAM_DEBUG
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif // __cplusplus
|
||||||
|
|
||||||
|
int P5Ram_Init( void );
|
||||||
|
void *P5Ram_Alloc( size_t size, int clear );
|
||||||
|
void P5Ram_Free( void *ptr );
|
||||||
|
void P5Ram_FreeAll( void );
|
||||||
|
void P5Ram_Shutdown( void );
|
||||||
|
void P5Ram_PowerCallback( int count, int arg, void *common );
|
||||||
|
#ifdef P5RAM_DEBUG
|
||||||
|
void P5Ram_Print( void );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // P5RAM_PSP_H
|
||||||
248
engine/platform/psp/scemp3/pspmp3.h
Normal file
248
engine/platform/psp/scemp3/pspmp3.h
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
/*
|
||||||
|
* PSP Software Development Kit - https://github.com/pspdev
|
||||||
|
* -----------------------------------------------------------------------
|
||||||
|
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||||
|
*
|
||||||
|
* pspmp3.h - Prototypes for the sceMp3 library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008 David Perry <tias_dp@hotmail.com>
|
||||||
|
* Copyright (c) 2008 Alexander Berl <raphael@fx-world.org>
|
||||||
|
* Copyright (c) 2022 Sergey Galushko
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __SCELIBMP3_H__
|
||||||
|
#define __SCELIBMP3_H__
|
||||||
|
|
||||||
|
#include <psptypes.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct SceMp3InitArg {
|
||||||
|
/** Stream start position */
|
||||||
|
SceOff mp3StreamStart;
|
||||||
|
/** Stream end position */
|
||||||
|
SceOff mp3StreamEnd;
|
||||||
|
/** Pointer to a buffer to contain raw mp3 stream data (+1472 bytes workspace) */
|
||||||
|
SceUChar8* mp3Buf;
|
||||||
|
/** Size of mp3Buf buffer (must be >= 8192) */
|
||||||
|
SceInt32 mp3BufSize;
|
||||||
|
/** Pointer to decoded pcm samples buffer */
|
||||||
|
SceUChar8* pcmBuf;
|
||||||
|
/** Size of pcmBuf buffer (must be >= 9216) */
|
||||||
|
SceInt32 pcmBufSize;
|
||||||
|
} SceMp3InitArg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3ReserveMp3Handle
|
||||||
|
*
|
||||||
|
* @param args - Pointer to SceMp3InitArg structure
|
||||||
|
*
|
||||||
|
* @return sceMp3 handle on success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3ReserveMp3Handle(SceMp3InitArg* args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3ReleaseMp3Handle
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3ReleaseMp3Handle(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3InitResource
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3InitResource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3TermResource
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3TermResource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3Init
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3Init(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3Decode
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param dst - Pointer to destination pcm samples buffer
|
||||||
|
*
|
||||||
|
* @return number of bytes in decoded pcm buffer, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3Decode(SceInt32 handle, SceShort16** dst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetInfoToAddStreamData
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param dst - Pointer to stream data buffer
|
||||||
|
* @param towrite - Space remaining in stream data buffer
|
||||||
|
* @param srcpos - Position in source stream to start reading from
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetInfoToAddStreamData(SceInt32 handle, SceUChar8** dst, SceInt32* towrite, SceInt32* srcpos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3NotifyAddStreamData
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param size - number of bytes added to the stream data buffer
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3NotifyAddStreamData(SceInt32 handle, SceInt32 size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3CheckStreamDataNeeded
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return 1 if more stream data is needed, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3CheckStreamDataNeeded(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3SetLoopNum
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param loop - Number of loops
|
||||||
|
*
|
||||||
|
* @return 0 if success, < 0 on error.
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3SetLoopNum(SceInt32 handle, SceInt32 loop);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetLoopNum
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Number of loops
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetLoopNum(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetSumDecodedSample
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Number of decoded samples
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetSumDecodedSample(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetMaxOutputSample
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Number of max samples to output
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetMaxOutputSample(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetSamplingRate
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Sampling rate of the mp3
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetSamplingRate(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetBitRate
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Bitrate of the mp3
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetBitRate(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetMp3ChannelNum
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return Number of channels of the mp3
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetMp3ChannelNum(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3ResetPlayPosition
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3ResetPlayPosition(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetFrameNum
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetFrameNum(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3ResetPlayPositionByFrame
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param frame - frame
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3ResetPlayPositionByFrame(SceInt32 handle, SceUInt32 frame);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3GetMPEGVersion
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3GetMPEGVersion(SceInt32 handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3LowLevelInit
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param src - Pointer to a buffer to contain raw mp3 stream data
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3LowLevelInit(SceInt32 handle, SceUChar8* src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sceMp3LowLevelDecode
|
||||||
|
*
|
||||||
|
* @param handle - sceMp3 handle
|
||||||
|
* @param mp3src -
|
||||||
|
* @param mp3srcused -
|
||||||
|
* @param pcmdst -
|
||||||
|
* @param pcmdstoutsz -
|
||||||
|
*
|
||||||
|
* @return < 0 on error
|
||||||
|
*/
|
||||||
|
SceInt32 sceMp3LowLevelDecode(SceInt32 handle, SceUChar8* mp3src, SceUInt32* mp3srcused, SceShort16* pcmdst, SceUInt32* pcmdstoutsz);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
29
engine/platform/psp/scemp3/sceMp3.S
Normal file
29
engine/platform/psp/scemp3/sceMp3.S
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
.set noreorder
|
||||||
|
|
||||||
|
#include "pspimport.s"
|
||||||
|
|
||||||
|
IMPORT_START "sceMp3",0x00090011
|
||||||
|
IMPORT_FUNC "sceMp3",0x07EC321A,sceMp3ReserveMp3Handle
|
||||||
|
IMPORT_FUNC "sceMp3",0x0DB149F4,sceMp3NotifyAddStreamData
|
||||||
|
IMPORT_FUNC "sceMp3",0x2A368661,sceMp3ResetPlayPosition
|
||||||
|
IMPORT_FUNC "sceMp3",0x354D27EA,sceMp3GetSumDecodedSample
|
||||||
|
IMPORT_FUNC "sceMp3",0x35750070,sceMp3InitResource
|
||||||
|
IMPORT_FUNC "sceMp3",0x3C2FA058,sceMp3TermResource
|
||||||
|
IMPORT_FUNC "sceMp3",0x3CEF484F,sceMp3SetLoopNum
|
||||||
|
IMPORT_FUNC "sceMp3",0x44E07129,sceMp3Init
|
||||||
|
IMPORT_FUNC "sceMp3",0x732B042A,sceMp3EndEntry
|
||||||
|
IMPORT_FUNC "sceMp3",0x7F696782,sceMp3GetMp3ChannelNum
|
||||||
|
IMPORT_FUNC "sceMp3",0x87677E40,sceMp3GetBitRate
|
||||||
|
IMPORT_FUNC "sceMp3",0x87C263D1,sceMp3GetMaxOutputSample
|
||||||
|
IMPORT_FUNC "sceMp3",0x8AB81558,sceMp3StartEntry
|
||||||
|
IMPORT_FUNC "sceMp3",0x8F450998,sceMp3GetSamplingRate
|
||||||
|
IMPORT_FUNC "sceMp3",0xA703FE0F,sceMp3GetInfoToAddStreamData
|
||||||
|
IMPORT_FUNC "sceMp3",0xD021C0FB,sceMp3Decode
|
||||||
|
IMPORT_FUNC "sceMp3",0xD0A56296,sceMp3CheckStreamDataNeeded
|
||||||
|
IMPORT_FUNC "sceMp3",0xD8F54A51,sceMp3GetLoopNum
|
||||||
|
IMPORT_FUNC "sceMp3",0xF5478233,sceMp3ReleaseMp3Handle
|
||||||
|
IMPORT_FUNC "sceMp3",0xAE6D2027,sceMp3GetMPEGVersion
|
||||||
|
IMPORT_FUNC "sceMp3",0x3548AEC8,sceMp3GetFrameNum
|
||||||
|
IMPORT_FUNC "sceMp3",0x0840E808,sceMp3ResetPlayPositionByFrame
|
||||||
|
IMPORT_FUNC "sceMp3",0x1B839B83,sceMp3LowLevelInit
|
||||||
|
IMPORT_FUNC "sceMp3",0xE3EE2C81,sceMp3LowLevelDecode
|
||||||
275
engine/platform/psp/snd_psp.c
Normal file
275
engine/platform/psp/snd_psp.c
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
snd_psp.c - psp sound hardware output
|
||||||
|
Copyright (C) 2022 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform/platform.h"
|
||||||
|
#if XASH_SOUND == SOUND_PSP
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include <pspaudio.h>
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#include <pspdmac.h>
|
||||||
|
|
||||||
|
#include "sound.h"
|
||||||
|
|
||||||
|
#define PSP_NUM_AUDIO_SAMPLES 1024 // must be multiple of 64
|
||||||
|
#define PSP_OUTPUT_CHANNELS 2
|
||||||
|
#define PSP_OUTPUT_BUFFER_SIZE (( PSP_NUM_AUDIO_SAMPLES ) * ( PSP_OUTPUT_CHANNELS ))
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
SceUID threadUID;
|
||||||
|
SceUID semaUID;
|
||||||
|
int channel;
|
||||||
|
volatile int volL;
|
||||||
|
volatile int volR;
|
||||||
|
volatile int running;
|
||||||
|
} snd_psp = { -1, -1, -1, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, 1 };
|
||||||
|
|
||||||
|
static short snd_psp_buff[2][PSP_OUTPUT_BUFFER_SIZE] __attribute__(( aligned( 64 )));
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
SNDDMA_MainThread
|
||||||
|
|
||||||
|
Copy samples
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
static int SNDDMA_MainThread( SceSize args, void *argp )
|
||||||
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
|
while( snd_psp.running )
|
||||||
|
{
|
||||||
|
sceKernelWaitSema( snd_psp.semaUID, 1, NULL );
|
||||||
|
|
||||||
|
int len = PSP_OUTPUT_BUFFER_SIZE;
|
||||||
|
int size = dma.samples;
|
||||||
|
int pos = dma.samplepos;
|
||||||
|
int wrapped = pos + len - size;
|
||||||
|
|
||||||
|
if( wrapped < 0 )
|
||||||
|
{
|
||||||
|
sceDmacMemcpy( snd_psp_buff[index], dma.buffer + ( pos * 2 ), len * 2 );
|
||||||
|
dma.samplepos += len;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int remaining = size - pos;
|
||||||
|
sceDmacMemcpy( snd_psp_buff[index], dma.buffer + ( pos * 2 ), remaining * 2 );
|
||||||
|
if( wrapped > 0 )
|
||||||
|
sceDmacMemcpy( snd_psp_buff[index] + ( remaining * 2 ), dma.buffer, wrapped * 2 );
|
||||||
|
dma.samplepos = wrapped;
|
||||||
|
}
|
||||||
|
|
||||||
|
sceKernelSignalSema( snd_psp.semaUID, 1 );
|
||||||
|
|
||||||
|
sceAudioOutputPannedBlocking( snd_psp.channel, snd_psp.volL, snd_psp.volR, snd_psp_buff[index] );
|
||||||
|
index = !index;
|
||||||
|
}
|
||||||
|
|
||||||
|
sceKernelExitThread( 0 );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
SNDDMA_Init
|
||||||
|
|
||||||
|
Try to find a sound device to mix for.
|
||||||
|
Returns false if nothing is found.
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
qboolean SNDDMA_Init( void )
|
||||||
|
{
|
||||||
|
int samplecount;
|
||||||
|
|
||||||
|
dma.format.speed = SOUND_DMA_SPEED;
|
||||||
|
dma.format.channels = PSP_OUTPUT_CHANNELS;
|
||||||
|
dma.format.width = 2;
|
||||||
|
|
||||||
|
// must be multiple of 64
|
||||||
|
samplecount = s_samplecount->value;
|
||||||
|
if( !samplecount )
|
||||||
|
samplecount = 0x4000;
|
||||||
|
|
||||||
|
dma.samples = samplecount * PSP_OUTPUT_CHANNELS;
|
||||||
|
dma.samplepos = 0;
|
||||||
|
dma.buffer = memalign( 64, dma.samples * 2 ); // 16 bit
|
||||||
|
if( !dma.buffer )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// clearing buffers
|
||||||
|
memset( dma.buffer, 0, dma.samples * 2 );
|
||||||
|
memset( snd_psp_buff, 0, sizeof( snd_psp_buff ));
|
||||||
|
|
||||||
|
// allocate and initialize a hardware output channel
|
||||||
|
snd_psp.channel = sceAudioChReserve( PSP_AUDIO_NEXT_CHANNEL,
|
||||||
|
PSP_NUM_AUDIO_SAMPLES, PSP_AUDIO_FORMAT_STEREO );
|
||||||
|
if( snd_psp.channel < 0 )
|
||||||
|
{
|
||||||
|
SNDDMA_Shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create semaphore
|
||||||
|
snd_psp.semaUID = sceKernelCreateSema( "sound_sema", 0, 1, 255, NULL );
|
||||||
|
if( snd_psp.semaUID <= 0 )
|
||||||
|
{
|
||||||
|
SNDDMA_Shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// create audio thread
|
||||||
|
snd_psp.threadUID = sceKernelCreateThread( "sound_thread", SNDDMA_MainThread, 0x12, 0x8000, 0, 0 );
|
||||||
|
if( snd_psp.threadUID < 0 )
|
||||||
|
{
|
||||||
|
SNDDMA_Shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// start audio thread
|
||||||
|
if( sceKernelStartThread( snd_psp.threadUID, 0, 0 ) < 0 )
|
||||||
|
{
|
||||||
|
SNDDMA_Shutdown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Con_Printf( "Using PSP audio driver: %d Hz\n", dma.format.speed );
|
||||||
|
|
||||||
|
dma.initialized = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
SNDDMA_GetDMAPos
|
||||||
|
|
||||||
|
return the current sample position (in mono samples read)
|
||||||
|
inside the recirculating dma buffer, so the mixing code will know
|
||||||
|
how many sample are required to fill it up.
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
int SNDDMA_GetDMAPos( void )
|
||||||
|
{
|
||||||
|
return dma.samplepos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
SNDDMA_GetSoundtime
|
||||||
|
|
||||||
|
update global soundtime
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
int SNDDMA_GetSoundtime( void )
|
||||||
|
{
|
||||||
|
static int buffers, oldsamplepos;
|
||||||
|
int samplepos, fullsamples;
|
||||||
|
|
||||||
|
fullsamples = dma.samples / 2;
|
||||||
|
|
||||||
|
// it is possible to miscount buffers
|
||||||
|
// if it has wrapped twice between
|
||||||
|
// calls to S_Update. Oh well.
|
||||||
|
samplepos = SNDDMA_GetDMAPos();
|
||||||
|
|
||||||
|
if( samplepos < oldsamplepos )
|
||||||
|
{
|
||||||
|
buffers++; // buffer wrapped
|
||||||
|
|
||||||
|
if( paintedtime > 0x40000000 )
|
||||||
|
{
|
||||||
|
// time to chop things off to avoid 32 bit limits
|
||||||
|
buffers = 0;
|
||||||
|
paintedtime = fullsamples;
|
||||||
|
S_StopAllSounds( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oldsamplepos = samplepos;
|
||||||
|
|
||||||
|
return ( buffers * fullsamples + samplepos / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
SNDDMA_BeginPainting
|
||||||
|
|
||||||
|
Makes sure dma.buffer is valid
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
void SNDDMA_BeginPainting( void )
|
||||||
|
{
|
||||||
|
if( snd_psp.semaUID > 0 )
|
||||||
|
sceKernelWaitSema( snd_psp.semaUID, 1, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
SNDDMA_Submit
|
||||||
|
|
||||||
|
Send sound to device if buffer isn't really the dma buffer
|
||||||
|
Also unlocks the dsound buffer
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
void SNDDMA_Submit( void )
|
||||||
|
{
|
||||||
|
if( snd_psp.semaUID > 0 )
|
||||||
|
sceKernelSignalSema( snd_psp.semaUID, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==============
|
||||||
|
SNDDMA_Shutdown
|
||||||
|
|
||||||
|
Reset the sound device for exiting
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
void SNDDMA_Shutdown( void )
|
||||||
|
{
|
||||||
|
Con_Printf("Shutting down audio.\n");
|
||||||
|
|
||||||
|
snd_psp.running = 0;
|
||||||
|
|
||||||
|
if( snd_psp.threadUID >= 0 )
|
||||||
|
{
|
||||||
|
sceKernelWaitThreadEnd( snd_psp.threadUID, NULL );
|
||||||
|
sceKernelDeleteThread( snd_psp.threadUID );
|
||||||
|
snd_psp.threadUID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( snd_psp.semaUID > 0 )
|
||||||
|
{
|
||||||
|
sceKernelDeleteSema( snd_psp.semaUID );
|
||||||
|
snd_psp.semaUID = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( snd_psp.channel >= 0 )
|
||||||
|
{
|
||||||
|
sceAudioChRelease( snd_psp.channel );
|
||||||
|
snd_psp.channel = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( dma.buffer )
|
||||||
|
{
|
||||||
|
free( dma.buffer );
|
||||||
|
dma.buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dma.initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // XASH_SOUND == SOUND_PSP
|
||||||
353
engine/platform/psp/sys_psp.c
Normal file
353
engine/platform/psp/sys_psp.c
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
/*
|
||||||
|
sys_psp.c - PSP System utils
|
||||||
|
Copyright (C) 2021 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "platform/platform.h"
|
||||||
|
#include "platform/psp/ka/ka.h"
|
||||||
|
#include "platform/psp/scemp3/pspmp3.h"
|
||||||
|
#include <pspsdk.h>
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#include <psppower.h>
|
||||||
|
#include <psprtc.h>
|
||||||
|
#include <pspprof.h>
|
||||||
|
#include <pspctrl.h>
|
||||||
|
#include <psputility.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
|
PSP_MODULE_INFO( "Xash3D", PSP_MODULE_USER, 1, 0 );
|
||||||
|
PSP_MAIN_THREAD_ATTR( PSP_THREAD_ATTR_USER | PSP_THREAD_ATTR_VFPU );
|
||||||
|
PSP_MAIN_THREAD_STACK_SIZE_KB( 512 );
|
||||||
|
PSP_HEAP_SIZE_KB( -3 * 1024 ); /* 3 MB for prx modules */
|
||||||
|
|
||||||
|
static qboolean psp_audiolib_init = false;
|
||||||
|
|
||||||
|
static int Platform_ExitCallback( int count, int arg, void *common )
|
||||||
|
{
|
||||||
|
host.crashed = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Platform_PowerCallback( int count, int arg, void *common )
|
||||||
|
{
|
||||||
|
P5Ram_PowerCallback( count, arg, common );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int Platform_CallbackThread( SceSize args, void *argp )
|
||||||
|
{
|
||||||
|
int cbid;
|
||||||
|
|
||||||
|
//cbid = sceKernelCreateCallback( "Exit Callback", Platform_ExitCallback, NULL );
|
||||||
|
//sceKernelRegisterExitCallback( cbid );
|
||||||
|
|
||||||
|
cbid = sceKernelCreateCallback( "Power Callback", Platform_PowerCallback, NULL );
|
||||||
|
scePowerRegisterCallback( 0, cbid );
|
||||||
|
|
||||||
|
sceKernelSleepThreadCB();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sets up the callback thread and returns its thread id */
|
||||||
|
static int Platform_SetupCallbacks( void )
|
||||||
|
{
|
||||||
|
int thid = 0;
|
||||||
|
|
||||||
|
thid = sceKernelCreateThread("update_thread", Platform_CallbackThread, 0x11, 0xFA0, 0, 0);
|
||||||
|
if(thid >= 0)
|
||||||
|
{
|
||||||
|
sceKernelStartThread(thid, 0, 0);
|
||||||
|
}
|
||||||
|
return thid;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if XASH_TIMER == TIMER_PSP
|
||||||
|
double Platform_DoubleTime( void )
|
||||||
|
{
|
||||||
|
return ( double )sceKernelGetSystemTimeWide() * 0.000001; // microseconds to seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_Sleep( int msec )
|
||||||
|
{
|
||||||
|
sceKernelDelayThread( msec * 1000 );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void *Platform_GetNativeObject( const char *name )
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_Vibrate( float life, char flags )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_GetClipboardText( char *buffer, size_t size )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_SetClipboardText( const char *buffer, size_t size )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_ShellExecute( const char *path, const char *parms )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if XASH_MESSAGEBOX == MSGBOX_PSP
|
||||||
|
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow )
|
||||||
|
{
|
||||||
|
static qboolean g_dbgscreen = false;
|
||||||
|
|
||||||
|
// Clear the sound buffer.
|
||||||
|
S_StopAllSounds( true );
|
||||||
|
|
||||||
|
// Print message to the debug screen.
|
||||||
|
if ( !g_dbgscreen )
|
||||||
|
{
|
||||||
|
pspDebugScreenInit();
|
||||||
|
g_dbgscreen = true;
|
||||||
|
}
|
||||||
|
pspDebugScreenSetTextColor( 0x0080ff );
|
||||||
|
pspDebugScreenPrintf( "\n\n\n\n%s:\n", title );
|
||||||
|
pspDebugScreenSetTextColor( 0x0000ff );
|
||||||
|
pspDebugScreenPrintData( message, Q_strlen( message ) );
|
||||||
|
pspDebugScreenSetTextColor( 0xffffff );
|
||||||
|
pspDebugScreenPrintf( "\n\nPress X to continue.\n" );
|
||||||
|
|
||||||
|
// Wait for a X button press.
|
||||||
|
SceCtrlData pad;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
sceCtrlReadBufferPositive( &pad, 1 );
|
||||||
|
}
|
||||||
|
while( !( pad.Buttons & PSP_CTRL_CROSS ) );
|
||||||
|
pspDebugScreenClear();
|
||||||
|
}
|
||||||
|
#endif // XASH_MESSAGEBOX == MSGBOX_PSP
|
||||||
|
|
||||||
|
void Platform_ReadCmd( const char *fname, int *argc, char **argv )
|
||||||
|
{
|
||||||
|
int cmd_fd;
|
||||||
|
size_t cmd_fsize;
|
||||||
|
byte *cmd_buff;
|
||||||
|
int i, j = 0;
|
||||||
|
|
||||||
|
cmd_fd = sceIoOpen( fname, PSP_O_RDONLY, 0777 );
|
||||||
|
if( cmd_fd > 0 )
|
||||||
|
{
|
||||||
|
cmd_fsize = sceIoLseek( cmd_fd, 0, PSP_SEEK_END );
|
||||||
|
sceIoLseek( cmd_fd, 0, PSP_SEEK_SET );
|
||||||
|
|
||||||
|
printf( "CMD FILE(%s) Size: %i\n", fname, cmd_fsize );
|
||||||
|
|
||||||
|
if( cmd_fsize == 0 ) return;
|
||||||
|
|
||||||
|
cmd_buff = malloc( cmd_fsize );
|
||||||
|
if( !cmd_buff )
|
||||||
|
{
|
||||||
|
printf( "CMD FILE(%s) Memory allocation error!\n", fname );
|
||||||
|
sceIoClose(cmd_fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( sceIoRead(cmd_fd, cmd_buff, cmd_fsize) >= 0 )
|
||||||
|
{
|
||||||
|
for( i = 0; i < cmd_fsize; i++ )
|
||||||
|
{
|
||||||
|
if( isspace( cmd_buff[i] ) != 0 )
|
||||||
|
{
|
||||||
|
if( j == 0 ) continue;
|
||||||
|
|
||||||
|
argv[*argc] = malloc( j + 1 );
|
||||||
|
if( !argv[*argc] )
|
||||||
|
{
|
||||||
|
printf( "CMD FILE(%s) Memory allocation error!\n", fname );
|
||||||
|
free( cmd_buff );
|
||||||
|
sceIoClose( cmd_fd );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy( argv[*argc], &cmd_buff[i - j], j );
|
||||||
|
argv[*argc][j] = 0x00;
|
||||||
|
( int )( *argc )++;
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
else j++;
|
||||||
|
|
||||||
|
}
|
||||||
|
if( j != 0 )
|
||||||
|
{
|
||||||
|
argv[*argc] = malloc( j + 1 );
|
||||||
|
if( !argv[*argc] )
|
||||||
|
{
|
||||||
|
printf( "CMD FILE(%s) Memory allocation error!\n", fname );
|
||||||
|
free( cmd_buff );
|
||||||
|
sceIoClose( cmd_fd );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memcpy( argv[*argc], &cmd_buff[i - j], j );
|
||||||
|
argv[*argc][j] = 0x00;
|
||||||
|
( int )( *argc )++;
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else printf( "CMD FILE(%s) Read error!\n", fname );
|
||||||
|
|
||||||
|
free( cmd_buff );
|
||||||
|
sceIoClose( cmd_fd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SceUID Platform_LoadModule( const char *filename, int mpid, SceSize argsize, void *argp )
|
||||||
|
{
|
||||||
|
SceKernelLMOption option;
|
||||||
|
SceUID modid = 0;
|
||||||
|
int retVal = 0, mresult;
|
||||||
|
|
||||||
|
memset( &option, 0, sizeof( option ) );
|
||||||
|
option.size = sizeof( option );
|
||||||
|
option.mpidtext = mpid;
|
||||||
|
option.mpiddata = mpid;
|
||||||
|
option.position = 0;
|
||||||
|
option.access = 1;
|
||||||
|
|
||||||
|
retVal = sceKernelLoadModule( filename, 0, &option );
|
||||||
|
if(retVal < 0)
|
||||||
|
return retVal;
|
||||||
|
|
||||||
|
modid = retVal;
|
||||||
|
|
||||||
|
retVal = sceKernelStartModule( modid, argsize, argp, &mresult, NULL );
|
||||||
|
if( retVal < 0 )
|
||||||
|
return retVal;
|
||||||
|
|
||||||
|
return modid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_UnloadModule( SceUID modid, int *sce_code )
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
*sce_code = sceKernelStopModule( modid, 0, NULL, &status, NULL);
|
||||||
|
|
||||||
|
if( ( *sce_code ) < 0 )
|
||||||
|
return -2;
|
||||||
|
else if( status == SCE_KERNEL_ERROR_NOT_STOPPED )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
*sce_code = sceKernelUnloadModule( modid );
|
||||||
|
return ( ( ( *sce_code ) < 0 ) ? -2 : 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_InitAudioLibs( void )
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if( psp_audiolib_init )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
status = sceUtilityLoadModule( PSP_MODULE_AV_AVCODEC );
|
||||||
|
if ( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceUtilityLoadModule(PSP_MODULE_AV_AVCODEC) returned 0x%08X\n", status );
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = sceUtilityLoadModule( PSP_MODULE_AV_MP3 );
|
||||||
|
if ( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceUtilityLoadModule(PSP_MODULE_AV_MP3) returned 0x%08X\n", status );
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
// init mp3 resources
|
||||||
|
status = sceMp3InitResource();
|
||||||
|
if ( status < 0 )
|
||||||
|
{
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3InitResource returned 0x%08X\n", status );
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
psp_audiolib_init = true;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Platform_ShutdownAudioLibs( void )
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
if( !psp_audiolib_init )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
status = sceMp3TermResource();
|
||||||
|
if ( status < 0 )
|
||||||
|
Con_DPrintf( S_ERROR "sceMp3TermResource returned 0x%08X\n", status );
|
||||||
|
|
||||||
|
status = sceUtilityUnloadModule( PSP_MODULE_AV_MP3 );
|
||||||
|
if ( status < 0 )
|
||||||
|
Con_DPrintf( S_ERROR "sceUtilityUnloadModule(PSP_MODULE_AV_MP3) returned 0x%08X\n", status );
|
||||||
|
|
||||||
|
status = sceUtilityUnloadModule( PSP_MODULE_AV_AVCODEC );
|
||||||
|
if ( status < 0 )
|
||||||
|
Con_DPrintf( S_ERROR "sceUtilityUnloadModule(PSP_MODULE_AV_AVCODEC) returned 0x%08X\n", status );
|
||||||
|
|
||||||
|
psp_audiolib_init = false;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_Init( void )
|
||||||
|
{
|
||||||
|
SceUID kamID;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
// disable fpu exceptions (division by zero and etc...)
|
||||||
|
pspSdkDisableFPUExceptions();
|
||||||
|
|
||||||
|
// exit callback thread
|
||||||
|
Platform_SetupCallbacks();
|
||||||
|
|
||||||
|
// set max cpu/gpu frequency
|
||||||
|
scePowerSetClockFrequency( 333, 333, 166 );
|
||||||
|
|
||||||
|
// set max VRAM
|
||||||
|
kamID = Platform_LoadModule( "ka.prx", 1, 0, NULL );
|
||||||
|
if( kamID >= 0 )
|
||||||
|
{
|
||||||
|
result = kaGeEdramGetHwSize();
|
||||||
|
if( result > 0 )
|
||||||
|
result = kaGeEdramSetSize( result );
|
||||||
|
Platform_UnloadModule( kamID, &result );
|
||||||
|
}
|
||||||
|
|
||||||
|
Platform_InitAudioLibs();
|
||||||
|
|
||||||
|
// P5 Ram init
|
||||||
|
P5Ram_Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Platform_Shutdown( void )
|
||||||
|
{
|
||||||
|
P5Ram_Shutdown();
|
||||||
|
Platform_ShutdownAudioLibs();
|
||||||
|
#if XASH_PROFILING
|
||||||
|
gprof_cleanup();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
384
engine/platform/psp/vid_psp.c
Normal file
384
engine/platform/psp/vid_psp.c
Normal file
@@ -0,0 +1,384 @@
|
|||||||
|
/*
|
||||||
|
vid_psp.c - PSP video component
|
||||||
|
Copyright (C) 2021 Sergey Galushko
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
#if XASH_VIDEO == VIDEO_PSP
|
||||||
|
|
||||||
|
#if !XASH_DEDICATED
|
||||||
|
#include <pspkernel.h>
|
||||||
|
#include <pspdisplay.h>
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
#include "client.h"
|
||||||
|
#include "mod_local.h"
|
||||||
|
#include "input.h"
|
||||||
|
#include "vid_common.h"
|
||||||
|
|
||||||
|
// Set frame buffer
|
||||||
|
#define PSP_FB_WIDTH 480
|
||||||
|
#define PSP_FB_HEIGHT 272
|
||||||
|
#define PSP_FB_BWIDTH 512
|
||||||
|
#define PSP_FB_FORMAT PSP_DISPLAY_PIXEL_FORMAT_565 //4444,5551,565,8888
|
||||||
|
|
||||||
|
#if PSP_FB_FORMAT == PSP_DISPLAY_PIXEL_FORMAT_4444
|
||||||
|
#define PSP_FB_BPP 2
|
||||||
|
#elif PSP_FB_FORMAT == PSP_DISPLAY_PIXEL_FORMAT_5551
|
||||||
|
#define PSP_FB_BPP 2
|
||||||
|
#elif PSP_FB_FORMAT == PSP_DISPLAY_PIXEL_FORMAT_565
|
||||||
|
#define PSP_FB_BPP 2
|
||||||
|
#elif PSP_FB_FORMAT == PSP_DISPLAY_PIXEL_FORMAT_8888
|
||||||
|
#define PSP_FB_BPP 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// Set up screen scaling
|
||||||
|
#define PSP_WIDTH_AR 30
|
||||||
|
#define PSP_HEIGHT_AR 17
|
||||||
|
#define PSP_MIN_MAR 12
|
||||||
|
#define PSP_MAX_MAR 16
|
||||||
|
#define PSP_MIN_MAR_W (PSP_WIDTH_AR * PSP_MIN_MAR)
|
||||||
|
#define PSP_MIN_MAR_H (PSP_HEIGHT_AR * PSP_MIN_MAR)
|
||||||
|
#define PSP_MAX_MAR_W (PSP_WIDTH_AR * PSP_MAX_MAR)
|
||||||
|
#define PSP_MAX_MAR_H (PSP_HEIGHT_AR * PSP_MAX_MAR)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static qboolean vsync;
|
||||||
|
#if 1
|
||||||
|
static vidmode_t vidmodes[] = { "480x272", PSP_FB_WIDTH, PSP_FB_HEIGHT};
|
||||||
|
static int num_vidmodes = 1;
|
||||||
|
#else
|
||||||
|
static vidmode_t *vidmodes = NULL;
|
||||||
|
static int num_vidmodes = 0;
|
||||||
|
#endif
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
int in_width, in_height;
|
||||||
|
int out_width, out_height;
|
||||||
|
#endif
|
||||||
|
void *draw_buffer;
|
||||||
|
void *disp_buffer;
|
||||||
|
}vid_psp;
|
||||||
|
|
||||||
|
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b )
|
||||||
|
{
|
||||||
|
*stride = PSP_FB_BWIDTH;
|
||||||
|
*r = 31;
|
||||||
|
*g = 63 << 5;
|
||||||
|
*b = 31 << 11;
|
||||||
|
*bpp = 2;
|
||||||
|
|
||||||
|
vid_psp.draw_buffer = (void*)malloc( PSP_FB_HEIGHT * PSP_FB_BWIDTH * PSP_FB_BPP );
|
||||||
|
if( !vid_psp.draw_buffer )
|
||||||
|
Host_Error( "Memory allocation failled! (vid_psp.draw_buffer)\n");
|
||||||
|
|
||||||
|
vid_psp.disp_buffer = (void*)malloc( PSP_FB_HEIGHT * PSP_FB_BWIDTH * PSP_FB_BPP );
|
||||||
|
if( !vid_psp.disp_buffer )
|
||||||
|
Host_Error( "Memory allocation failled! (vid_psp.disp_buffer)\n");
|
||||||
|
|
||||||
|
sceDisplaySetMode(0, PSP_FB_WIDTH, PSP_FB_HEIGHT);
|
||||||
|
sceDisplaySetFrameBuf(vid_psp.disp_buffer, PSP_FB_BWIDTH, PSP_FB_FORMAT, 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *SW_LockBuffer( void )
|
||||||
|
{
|
||||||
|
return vid_psp.draw_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SW_UnlockBuffer( void )
|
||||||
|
{
|
||||||
|
void* p_swap = vid_psp.disp_buffer;
|
||||||
|
vid_psp.disp_buffer = vid_psp.draw_buffer;
|
||||||
|
vid_psp.draw_buffer = p_swap;
|
||||||
|
|
||||||
|
sceKernelDcacheWritebackInvalidateAll();
|
||||||
|
sceDisplaySetFrameBuf(vid_psp.disp_buffer, PSP_FB_BWIDTH, PSP_FB_FORMAT, PSP_DISPLAY_SETBUF_NEXTFRAME);
|
||||||
|
|
||||||
|
if ( vsync )
|
||||||
|
{
|
||||||
|
sceDisplayWaitVblankStart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int R_MaxVideoModes( void )
|
||||||
|
{
|
||||||
|
return num_vidmodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
vidmode_t *R_GetVideoMode( int num )
|
||||||
|
{
|
||||||
|
if( !vidmodes || num < 0 || num >= R_MaxVideoModes() )
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vidmodes + num;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
static void R_InitVideoModes( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
vidmodes = Mem_Malloc( host.mempool, (PSP_MAX_MAR - PSP_MIN_MAR) * sizeof( vidmode_t ) );
|
||||||
|
|
||||||
|
// from smallest to largest
|
||||||
|
for(i = PSP_MIN_MAR ; i <= PSP_MAX_MAR; i++ )
|
||||||
|
{
|
||||||
|
vidmodes[num_vidmodes].width = PSP_WIDTH_AR * i;
|
||||||
|
vidmodes[num_vidmodes].height = PSP_HEIGHT_AR * i;
|
||||||
|
vidmodes[num_vidmodes].desc =
|
||||||
|
copystring( va( "%ix%i", vidmodes[num_vidmodes].width, vidmodes[num_vidmodes].height ));
|
||||||
|
|
||||||
|
num_vidmodes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void R_FreeVideoModes( void )
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if(!vidmodes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( i = 0; i < num_vidmodes; i++ )
|
||||||
|
Mem_Free( (char*)vidmodes[i].desc );
|
||||||
|
Mem_Free( vidmodes );
|
||||||
|
|
||||||
|
vidmodes = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
=================
|
||||||
|
GL_GetProcAddress
|
||||||
|
=================
|
||||||
|
*/
|
||||||
|
void *GL_GetProcAddress( const char *name )
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
===============
|
||||||
|
GL_UpdateSwapInterval
|
||||||
|
===============
|
||||||
|
*/
|
||||||
|
void GL_UpdateSwapInterval( void )
|
||||||
|
{
|
||||||
|
// disable VSync while level is loading
|
||||||
|
if( cls.state < ca_active )
|
||||||
|
{
|
||||||
|
// setup vsync here
|
||||||
|
vsync = false;
|
||||||
|
SetBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||||
|
}
|
||||||
|
else if( FBitSet( gl_vsync->flags, FCVAR_CHANGED ))
|
||||||
|
{
|
||||||
|
ClearBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||||
|
vsync = (gl_vsync->value > 0) ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static qboolean VID_SetScreenResolution( int width, int height )
|
||||||
|
{
|
||||||
|
int render_w = width, render_h = height;
|
||||||
|
uint rotate = vid_rotate->value;
|
||||||
|
|
||||||
|
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale->value, vid_scale->value ) )
|
||||||
|
{
|
||||||
|
if( rotate & 1 )
|
||||||
|
{
|
||||||
|
int swap = render_w;
|
||||||
|
|
||||||
|
render_w = render_h;
|
||||||
|
render_h = swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
render_h /= vid_scale->value;
|
||||||
|
render_w /= vid_scale->value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_Printf( S_WARN "failed to setup screen transform\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
R_SaveVideoMode( width, height, render_w, render_h );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GL_SwapBuffers( void )
|
||||||
|
{
|
||||||
|
if ( vsync ) sceDisplayWaitVblankStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
int GL_SetAttribute( int attr, int val )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GL_GetAttribute( int attr, int *val )
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
R_Init_Video
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
qboolean R_Init_Video( const int type )
|
||||||
|
{
|
||||||
|
string safe;
|
||||||
|
qboolean retval;
|
||||||
|
|
||||||
|
refState.desktopBitsPixel = ( PSP_FB_BPP * 8 );
|
||||||
|
|
||||||
|
VID_StartupGamma();
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case REF_SOFTWARE:
|
||||||
|
glw_state.software = true;
|
||||||
|
break;
|
||||||
|
case REF_GL:
|
||||||
|
if( !glw_state.safe && Sys_GetParmFromCmdLine( "-safegl", safe ) )
|
||||||
|
glw_state.safe = bound( SAFE_NO, Q_atoi( safe ), SAFE_DONTCARE );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Host_Error( "Can't initialize unknown context type %d!\n", type );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !(retval = VID_SetMode()) )
|
||||||
|
{
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case REF_GL:
|
||||||
|
// refdll also can check extensions
|
||||||
|
ref.dllFuncs.GL_InitExtensions();
|
||||||
|
break;
|
||||||
|
case REF_SOFTWARE:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
R_InitVideoModes();
|
||||||
|
#endif
|
||||||
|
host.renderinfo_changed = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
|
||||||
|
{
|
||||||
|
Con_Reportf( "R_ChangeDisplaySettings: Setting video mode to %dx%d %s\n", width, height, fullscreen ? "fullscreen" : "windowed" );
|
||||||
|
|
||||||
|
refState.fullScreen = fullscreen;
|
||||||
|
|
||||||
|
if( !VID_SetScreenResolution( width, height ) )
|
||||||
|
return rserr_invalid_fullscreen;
|
||||||
|
|
||||||
|
return rserr_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
VID_SetMode
|
||||||
|
|
||||||
|
Set the described video mode
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
qboolean VID_SetMode( void )
|
||||||
|
{
|
||||||
|
qboolean fullscreen = false;
|
||||||
|
int iScreenWidth, iScreenHeight;
|
||||||
|
rserr_t err;
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
iScreenWidth = PSP_FB_WIDTH;
|
||||||
|
iScreenHeight = PSP_FB_HEIGHT;
|
||||||
|
#else
|
||||||
|
vid_psp.out_width = PSP_FB_WIDTH;
|
||||||
|
vid_psp.out_height = PSP_FB_HEIGHT;
|
||||||
|
|
||||||
|
iScreenWidth = Cvar_VariableInteger( "width" );
|
||||||
|
iScreenHeight = Cvar_VariableInteger( "height" );
|
||||||
|
|
||||||
|
if( iScreenWidth < PSP_MIN_MAR_W ||
|
||||||
|
iScreenHeight < PSP_MIN_MAR_H ) // trying to get resolution automatically by default
|
||||||
|
{
|
||||||
|
iScreenWidth = PSP_MIN_MAR_W;
|
||||||
|
iScreenHeight = PSP_MIN_MAR_H;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( iScreenWidth > PSP_MAX_MAR_W ||
|
||||||
|
iScreenHeight > PSP_MAX_MAR_H ) // trying to get resolution automatically by default
|
||||||
|
{
|
||||||
|
iScreenWidth = PSP_MAX_MAR_W;
|
||||||
|
iScreenHeight = PSP_MAX_MAR_H;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if( !FBitSet( vid_fullscreen->flags, FCVAR_CHANGED ) )
|
||||||
|
Cvar_SetValue( "fullscreen", DEFAULT_FULLSCREEN );
|
||||||
|
else
|
||||||
|
ClearBits( vid_fullscreen->flags, FCVAR_CHANGED );
|
||||||
|
|
||||||
|
SetBits( gl_vsync->flags, FCVAR_CHANGED );
|
||||||
|
fullscreen = true;//Cvar_VariableInteger("fullscreen") != 0;
|
||||||
|
|
||||||
|
if(( err = R_ChangeDisplaySettings( iScreenWidth, iScreenHeight, fullscreen )) == rserr_ok )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
vid_psp.in_width = iScreenWidth;
|
||||||
|
vid_psp.in_height = iScreenHeight;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
==================
|
||||||
|
R_Free_Video
|
||||||
|
==================
|
||||||
|
*/
|
||||||
|
void R_Free_Video( void )
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
R_FreeVideoModes();
|
||||||
|
#endif
|
||||||
|
ref.dllFuncs.GL_ClearExtensions();
|
||||||
|
if( glw_state.software )
|
||||||
|
{
|
||||||
|
if( vid_psp.draw_buffer )
|
||||||
|
free( vid_psp.draw_buffer );
|
||||||
|
if( vid_psp.disp_buffer )
|
||||||
|
free( vid_psp.disp_buffer );
|
||||||
|
|
||||||
|
vid_psp.draw_buffer = NULL;
|
||||||
|
vid_psp.disp_buffer = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // XASH_DEDICATED
|
||||||
|
#endif // XASH_VIDEO
|
||||||
@@ -843,13 +843,10 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
|
|||||||
return false;
|
return false;
|
||||||
GL_SetupAttributes(); // re-choose attributes
|
GL_SetupAttributes(); // re-choose attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
VID_StartupGamma();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !GL_UpdateContext( ))
|
if( !GL_UpdateContext( ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
#else // SDL_VERSION_ATLEAST( 2, 0, 0 )
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ GNU General Public License for more details.
|
|||||||
#include "r_efx.h"
|
#include "r_efx.h"
|
||||||
#include "com_image.h"
|
#include "com_image.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
#include "common/protocol.h"
|
||||||
|
|
||||||
// RefAPI changelog:
|
// RefAPI changelog:
|
||||||
// 1. Initial release
|
// 1. Initial release
|
||||||
@@ -38,7 +39,11 @@ GNU General Public License for more details.
|
|||||||
// Removed previously unused calls
|
// Removed previously unused calls
|
||||||
// Simplified remapping calls
|
// Simplified remapping calls
|
||||||
// GetRefAPI is now expected to return REF_API_VERSION
|
// GetRefAPI is now expected to return REF_API_VERSION
|
||||||
#define REF_API_VERSION 5
|
// 6. Removed timing from ref_globals_t.
|
||||||
|
// Renderers are supposed to migrate to ref_client_t/ref_host_t using PARM_GET_CLIENT_PTR and PARM_GET_HOST_PTR
|
||||||
|
// Removed functions to get internal engine structions. Use PARM_GET_*_PTR instead.
|
||||||
|
// 7. Gamma fixes.
|
||||||
|
#define REF_API_VERSION 7
|
||||||
|
|
||||||
|
|
||||||
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
|
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
|
||||||
@@ -94,11 +99,6 @@ typedef struct ref_globals_s
|
|||||||
{
|
{
|
||||||
qboolean developer;
|
qboolean developer;
|
||||||
|
|
||||||
float time; // cl.time
|
|
||||||
float oldtime; // cl.oldtime
|
|
||||||
double realtime; // host.realtime
|
|
||||||
double frametime; // host.frametime
|
|
||||||
|
|
||||||
// viewport width and height
|
// viewport width and height
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@@ -120,6 +120,26 @@ typedef struct ref_globals_s
|
|||||||
int desktopBitsPixel;
|
int desktopBitsPixel;
|
||||||
} ref_globals_t;
|
} ref_globals_t;
|
||||||
|
|
||||||
|
typedef struct ref_client_s
|
||||||
|
{
|
||||||
|
double time;
|
||||||
|
double oldtime;
|
||||||
|
int viewentity;
|
||||||
|
int playernum;
|
||||||
|
int maxclients;
|
||||||
|
int nummodels;
|
||||||
|
model_t *models[MAX_MODELS+1];
|
||||||
|
qboolean paused;
|
||||||
|
vec3_t simorg;
|
||||||
|
} ref_client_t;
|
||||||
|
|
||||||
|
typedef struct ref_host_s
|
||||||
|
{
|
||||||
|
double realtime;
|
||||||
|
double frametime;
|
||||||
|
int features;
|
||||||
|
} ref_host_t;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
GL_KEEP_UNIT = -1,
|
GL_KEEP_UNIT = -1,
|
||||||
@@ -251,17 +271,18 @@ typedef enum
|
|||||||
PARM_DEV_OVERVIEW = -1,
|
PARM_DEV_OVERVIEW = -1,
|
||||||
PARM_THIRDPERSON = -2,
|
PARM_THIRDPERSON = -2,
|
||||||
PARM_QUAKE_COMPATIBLE = -3,
|
PARM_QUAKE_COMPATIBLE = -3,
|
||||||
PARM_PLAYER_INDEX = -4, // cl.playernum + 1
|
PARM_GET_CLIENT_PTR = -4, // ref_client_t
|
||||||
PARM_VIEWENT_INDEX = -5, // cl.viewentity
|
PARM_GET_HOST_PTR = -5, // ref_host_t
|
||||||
PARM_CONNSTATE = -6, // cls.state
|
PARM_CONNSTATE = -6, // cls.state
|
||||||
PARM_PLAYING_DEMO = -7, // cls.demoplayback
|
PARM_PLAYING_DEMO = -7, // cls.demoplayback
|
||||||
PARM_WATER_LEVEL = -8, // cl.local.water_level
|
PARM_WATER_LEVEL = -8, // cl.local.water_level
|
||||||
PARM_MAX_CLIENTS = -9, // cl.maxclients
|
PARM_GET_WORLD_PTR = -9, // world
|
||||||
PARM_LOCAL_HEALTH = -10, // cl.local.health
|
PARM_LOCAL_HEALTH = -10, // cl.local.health
|
||||||
PARM_LOCAL_GAME = -11,
|
PARM_LOCAL_GAME = -11,
|
||||||
PARM_NUMENTITIES = -12, // local game only
|
PARM_NUMENTITIES = -12, // local game only
|
||||||
PARM_NUMMODELS = -13, // cl.nummodels
|
PARM_GET_MOVEVARS_PTR = -13, // clgame.movevars
|
||||||
PARM_WORLD_VERSION = -14,
|
PARM_GET_PALETTE_PTR = -14, // clgame.palette
|
||||||
|
PARM_GET_VIEWENT_PTR = -15, // clgame.viewent
|
||||||
} ref_parm_e;
|
} ref_parm_e;
|
||||||
|
|
||||||
typedef struct ref_api_s
|
typedef struct ref_api_s
|
||||||
@@ -304,7 +325,6 @@ typedef struct ref_api_s
|
|||||||
void (*CL_DrawCenterPrint)( void );
|
void (*CL_DrawCenterPrint)( void );
|
||||||
|
|
||||||
// entity management
|
// entity management
|
||||||
struct cl_entity_s *(*GetViewModel)( void );
|
|
||||||
struct cl_entity_s *(*R_BeamGetEntity)( int index );
|
struct cl_entity_s *(*R_BeamGetEntity)( int index );
|
||||||
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
|
struct cl_entity_s *(*CL_GetWaterEntity)( const vec3_t p );
|
||||||
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
|
qboolean (*CL_AddVisibleEntity)( cl_entity_t *ent, int entityType );
|
||||||
@@ -312,7 +332,6 @@ typedef struct ref_api_s
|
|||||||
// brushes
|
// brushes
|
||||||
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
int (*Mod_SampleSizeForFace)( const struct msurface_s *surf );
|
||||||
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
qboolean (*Mod_BoxVisible)( const vec3_t mins, const vec3_t maxs, const byte *visbits );
|
||||||
struct world_static_s *(*GetWorld)( void ); // returns &world
|
|
||||||
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
|
mleaf_t *(*Mod_PointInLeaf)( const vec3_t p, mnode_t *node );
|
||||||
void (*Mod_CreatePolygonsForHull)( int hullnum );
|
void (*Mod_CreatePolygonsForHull)( int hullnum );
|
||||||
|
|
||||||
@@ -332,7 +351,6 @@ typedef struct ref_api_s
|
|||||||
// model management
|
// model management
|
||||||
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
|
model_t *(*Mod_ForName)( const char *name, qboolean crash, qboolean trackCRC );
|
||||||
void *(*Mod_Extradata)( int type, model_t *model );
|
void *(*Mod_Extradata)( int type, model_t *model );
|
||||||
struct model_s **(*pfnGetModels)( void );
|
|
||||||
|
|
||||||
// remap
|
// remap
|
||||||
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
|
qboolean (*CL_EntitySetRemapColors)( cl_entity_t *e, model_t *mod, int top, int bottom );
|
||||||
@@ -345,8 +363,6 @@ typedef struct ref_api_s
|
|||||||
float (*COM_RandomFloat)( float rmin, float rmax );
|
float (*COM_RandomFloat)( float rmin, float rmax );
|
||||||
int (*COM_RandomLong)( int rmin, int rmax );
|
int (*COM_RandomLong)( int rmin, int rmax );
|
||||||
struct screenfade_s *(*GetScreenFade)( void );
|
struct screenfade_s *(*GetScreenFade)( void );
|
||||||
void (*GetPredictedOrigin)( vec3_t v );
|
|
||||||
color24 *(*CL_GetPaletteColor)( void ); // clgame.palette[color]
|
|
||||||
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
|
void (*CL_GetScreenInfo)( int *width, int *height ); // clgame.scrInfo, ptrs may be NULL
|
||||||
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
|
void (*SetLocalLightLevel)( int level ); // cl.local.light_level
|
||||||
int (*Sys_CheckParm)( const char *flag );
|
int (*Sys_CheckParm)( const char *flag );
|
||||||
@@ -389,9 +405,11 @@ typedef struct ref_api_s
|
|||||||
void (*SW_UnlockBuffer)( void );
|
void (*SW_UnlockBuffer)( void );
|
||||||
|
|
||||||
// gamma
|
// gamma
|
||||||
void (*BuildGammaTable)( float lightgamma, float brightness );
|
byte (*LightToTexGamma)( byte ); // software gamma support
|
||||||
byte (*LightToTexGamma)( byte color ); // software gamma support
|
uint (*LightToTexGammaEx)( uint ); // software gamma support
|
||||||
qboolean (*R_DoResetGamma)( void );
|
byte (*TextureToGamma)( byte );
|
||||||
|
uint (*ScreenGammaTable)( uint );
|
||||||
|
uint (*LinearGammaTable)( uint );
|
||||||
|
|
||||||
// renderapi
|
// renderapi
|
||||||
lightstyle_t* (*GetLightStyle)( int number );
|
lightstyle_t* (*GetLightStyle)( int number );
|
||||||
@@ -407,7 +425,6 @@ typedef struct ref_api_s
|
|||||||
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
|
struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehull, int ignore_pe );
|
||||||
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
|
struct pmtrace_s *(*EV_VisTraceLine )( float *start, float *end, int flags );
|
||||||
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
|
struct pmtrace_s (*CL_TraceLine)( vec3_t start, vec3_t end, int flags );
|
||||||
struct movevars_s *(*pfnGetMoveVars)( void );
|
|
||||||
|
|
||||||
// imagelib
|
// imagelib
|
||||||
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
|
void (*Image_AddCmdFlags)( uint flags ); // used to check if hardware dxt is supported
|
||||||
@@ -429,6 +446,11 @@ typedef struct ref_api_s
|
|||||||
|
|
||||||
// filesystem exports
|
// filesystem exports
|
||||||
fs_api_t *fsapi;
|
fs_api_t *fsapi;
|
||||||
|
|
||||||
|
#if XASH_PSP
|
||||||
|
void *(*P5Ram_Alloc)( size_t size, int clear );
|
||||||
|
void (*P5Ram_Free)( void *ptr );
|
||||||
|
#endif
|
||||||
} ref_api_t;
|
} ref_api_t;
|
||||||
|
|
||||||
struct mip_s;
|
struct mip_s;
|
||||||
@@ -449,6 +471,7 @@ typedef struct ref_interface_s
|
|||||||
void (*GL_ClearExtensions)( void );
|
void (*GL_ClearExtensions)( void );
|
||||||
|
|
||||||
// scene rendering
|
// scene rendering
|
||||||
|
void (*R_GammaChanged)( qboolean do_reset_gamma );
|
||||||
void (*R_BeginFrame)( qboolean clearScene );
|
void (*R_BeginFrame)( qboolean clearScene );
|
||||||
void (*R_RenderScene)( void );
|
void (*R_RenderScene)( void );
|
||||||
void (*R_EndFrame)( void );
|
void (*R_EndFrame)( void );
|
||||||
@@ -637,6 +660,8 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
|
|||||||
#define ENGINE_SHARED_CVAR_LIST( f ) \
|
#define ENGINE_SHARED_CVAR_LIST( f ) \
|
||||||
ENGINE_SHARED_CVAR_NAME( f, vid_gamma, gamma ) \
|
ENGINE_SHARED_CVAR_NAME( f, vid_gamma, gamma ) \
|
||||||
ENGINE_SHARED_CVAR_NAME( f, vid_brightness, brightness ) \
|
ENGINE_SHARED_CVAR_NAME( f, vid_brightness, brightness ) \
|
||||||
|
ENGINE_SHARED_CVAR_NAME( f, v_lightgamma, lightgamma ) \
|
||||||
|
ENGINE_SHARED_CVAR_NAME( f, v_direct, direct ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_showtextures ) \
|
ENGINE_SHARED_CVAR( f, r_showtextures ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_speeds ) \
|
ENGINE_SHARED_CVAR( f, r_speeds ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_fullbright ) \
|
ENGINE_SHARED_CVAR( f, r_fullbright ) \
|
||||||
@@ -658,7 +683,6 @@ typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t*
|
|||||||
ENGINE_SHARED_CVAR( f, r_sprite_lighting ) \
|
ENGINE_SHARED_CVAR( f, r_sprite_lighting ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_drawviewmodel ) \
|
ENGINE_SHARED_CVAR( f, r_drawviewmodel ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_glowshellfreq ) \
|
ENGINE_SHARED_CVAR( f, r_glowshellfreq ) \
|
||||||
ENGINE_SHARED_CVAR( f, r_lighting_modulate ) \
|
|
||||||
|
|
||||||
#define DECLARE_ENGINE_SHARED_CVAR_LIST() \
|
#define DECLARE_ENGINE_SHARED_CVAR_LIST() \
|
||||||
ENGINE_SHARED_CVAR_LIST( DECLARE_ENGINE_SHARED_CVAR )
|
ENGINE_SHARED_CVAR_LIST( DECLARE_ENGINE_SHARED_CVAR )
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ extern int SV_UPDATE_BACKUP;
|
|||||||
#define GROUP_OP_AND 0
|
#define GROUP_OP_AND 0
|
||||||
#define GROUP_OP_NAND 1
|
#define GROUP_OP_NAND 1
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#if defined( NDEBUG )
|
||||||
#define SV_IsValidEdict( e ) ( e && !e->free )
|
#define SV_IsValidEdict( e ) ( e && !e->free )
|
||||||
#else
|
#else
|
||||||
#define SV_IsValidEdict( e ) SV_CheckEdict( e, __FILE__, __LINE__ )
|
#define SV_IsValidEdict( e ) SV_CheckEdict( e, __FILE__, __LINE__ )
|
||||||
@@ -509,7 +509,13 @@ qboolean CRC32_MapFile( dword *crcvalue, const char *filename, qboolean multipla
|
|||||||
qboolean SV_InitGame( void );
|
qboolean SV_InitGame( void );
|
||||||
void SV_ActivateServer( int runPhysics );
|
void SV_ActivateServer( int runPhysics );
|
||||||
qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background );
|
qboolean SV_SpawnServer( const char *server, const char *startspot, qboolean background );
|
||||||
model_t *SV_ModelHandle( int modelindex );
|
static inline model_t *GAME_EXPORT SV_ModelHandle( int modelindex )
|
||||||
|
{
|
||||||
|
if( unlikely( modelindex < 0 || modelindex >= MAX_MODELS ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return sv.models[modelindex];
|
||||||
|
}
|
||||||
void SV_DeactivateServer( void );
|
void SV_DeactivateServer( void );
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -648,10 +654,17 @@ void SV_RestartAmbientSounds( void );
|
|||||||
void SV_RestartDecals( void );
|
void SV_RestartDecals( void );
|
||||||
void SV_RestartStaticEnts( void );
|
void SV_RestartStaticEnts( void );
|
||||||
int pfnDropToFloor( edict_t* e );
|
int pfnDropToFloor( edict_t* e );
|
||||||
edict_t *SV_EdictNum( int n );
|
|
||||||
void SV_SetModel( edict_t *ent, const char *name );
|
void SV_SetModel( edict_t *ent, const char *name );
|
||||||
int pfnDecalIndex( const char *m );
|
int pfnDecalIndex( const char *m );
|
||||||
|
|
||||||
|
static inline edict_t *SV_EdictNum( int n )
|
||||||
|
{
|
||||||
|
if( unlikely( n < 0 || n >= GI->max_edicts ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &svgame.edicts[n];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// sv_log.c
|
// sv_log.c
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -39,13 +39,6 @@ static vec3_t viewPoint[MAX_CLIENTS];
|
|||||||
typedef void (__cdecl *LINK_ENTITY_FUNC)( entvars_t *pev );
|
typedef void (__cdecl *LINK_ENTITY_FUNC)( entvars_t *pev );
|
||||||
typedef void (__stdcall *GIVEFNPTRSTODLL)( enginefuncs_t* engfuncs, globalvars_t *pGlobals );
|
typedef void (__stdcall *GIVEFNPTRSTODLL)( enginefuncs_t* engfuncs, globalvars_t *pGlobals );
|
||||||
|
|
||||||
edict_t *SV_EdictNum( int n )
|
|
||||||
{
|
|
||||||
if(( n >= 0 ) && ( n < GI->max_edicts ))
|
|
||||||
return svgame.edicts + n;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
qboolean SV_CheckEdict( const edict_t *e, const char *file, const int line )
|
qboolean SV_CheckEdict( const edict_t *e, const char *file, const int line )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -262,20 +262,6 @@ int GAME_EXPORT SV_GenericIndex( const char *filename )
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
================
|
|
||||||
SV_ModelHandle
|
|
||||||
|
|
||||||
get model by handle
|
|
||||||
================
|
|
||||||
*/
|
|
||||||
model_t *GAME_EXPORT SV_ModelHandle( int modelindex )
|
|
||||||
{
|
|
||||||
if( modelindex < 0 || modelindex >= MAX_MODELS )
|
|
||||||
return NULL;
|
|
||||||
return sv.models[modelindex];
|
|
||||||
}
|
|
||||||
|
|
||||||
static resourcetype_t SV_DetermineResourceType( const char *filename )
|
static resourcetype_t SV_DetermineResourceType( const char *filename )
|
||||||
{
|
{
|
||||||
if( !Q_strncmp( filename, DEFAULT_SOUNDPATH, sizeof( DEFAULT_SOUNDPATH ) - 1 ) && Sound_SupportedFileFormat( COM_FileExtension( filename )))
|
if( !Q_strncmp( filename, DEFAULT_SOUNDPATH, sizeof( DEFAULT_SOUNDPATH ) - 1 ) && Sound_SupportedFileFormat( COM_FileExtension( filename )))
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ CVAR_DEFINE( public_server, "public", "0", 0, "change server type from private t
|
|||||||
CVAR_DEFINE_AUTO( sv_novis, "0", 0, "force to ignore server visibility" ); // disable server culling entities by vis
|
CVAR_DEFINE_AUTO( sv_novis, "0", 0, "force to ignore server visibility" ); // disable server culling entities by vis
|
||||||
CVAR_DEFINE( sv_pausable, "pausable", "1", FCVAR_SERVER, "allow players to pause or not" );
|
CVAR_DEFINE( sv_pausable, "pausable", "1", FCVAR_SERVER, "allow players to pause or not" );
|
||||||
static CVAR_DEFINE_AUTO( timeout, "125", FCVAR_SERVER, "connection timeout" ); // seconds without any message
|
static CVAR_DEFINE_AUTO( timeout, "125", FCVAR_SERVER, "connection timeout" ); // seconds without any message
|
||||||
CVAR_DEFINE( sv_lighting_modulate, "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "lightstyles modulate scale" );
|
|
||||||
CVAR_DEFINE( sv_maxclients, "maxplayers", "1", FCVAR_LATCH, "server max capacity" );
|
CVAR_DEFINE( sv_maxclients, "maxplayers", "1", FCVAR_LATCH, "server max capacity" );
|
||||||
CVAR_DEFINE_AUTO( sv_check_errors, "0", FCVAR_ARCHIVE, "check edicts for errors" );
|
CVAR_DEFINE_AUTO( sv_check_errors, "0", FCVAR_ARCHIVE, "check edicts for errors" );
|
||||||
CVAR_DEFINE_AUTO( sv_reconnect_limit, "3", FCVAR_ARCHIVE, "max reconnect attempts" ); // minimum seconds between connect messages
|
CVAR_DEFINE_AUTO( sv_reconnect_limit, "3", FCVAR_ARCHIVE, "max reconnect attempts" ); // minimum seconds between connect messages
|
||||||
@@ -919,7 +918,6 @@ void SV_Init( void )
|
|||||||
Cvar_RegisterVariable( &sv_maxclients );
|
Cvar_RegisterVariable( &sv_maxclients );
|
||||||
Cvar_RegisterVariable( &sv_check_errors );
|
Cvar_RegisterVariable( &sv_check_errors );
|
||||||
Cvar_RegisterVariable( &public_server );
|
Cvar_RegisterVariable( &public_server );
|
||||||
Cvar_RegisterVariable( &sv_lighting_modulate );
|
|
||||||
Cvar_RegisterVariable( &sv_reconnect_limit );
|
Cvar_RegisterVariable( &sv_reconnect_limit );
|
||||||
Cvar_RegisterVariable( &sv_failuretime );
|
Cvar_RegisterVariable( &sv_failuretime );
|
||||||
Cvar_RegisterVariable( &sv_unlag );
|
Cvar_RegisterVariable( &sv_unlag );
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user