Skip to content

Commit

Permalink
First merge attempt (many PSP tunings are missing, as they are outdat…
Browse files Browse the repository at this point in the history
…ed now)
  • Loading branch information
a1batross committed Jan 18, 2024
2 parents 7d8ea61 + cae351f commit 8044646
Show file tree
Hide file tree
Showing 112 changed files with 32,227 additions and 240 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ This repository contains our fork of HLSDK and restored source code for some of
* Clone this repostory:
`$ 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
#### Windows (Visual Studio)
0) Open command line
Expand All @@ -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)
2) Compile: `./waf build`
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.
12 changes: 9 additions & 3 deletions common/backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,40 @@ GNU General Public License for more details.
#define VIDEO_SDL 1
#define VIDEO_FBDEV 3
#define VIDEO_DOS 4
#define VIDEO_PSP 5

// audio backends (XASH_SOUND)
#define SOUND_NULL 0
#define SOUND_SDL 1
#define SOUND_ALSA 3
#define SOUND_PSP 4

// input (XASH_INPUT)
#define INPUT_NULL 0
#define INPUT_SDL 1
#define INPUT_EVDEV 3
#define INPUT_PSP 4

// timer (XASH_TIMER)
#define TIMER_NULL 0 // not used
#define TIMER_SDL 1
#define TIMER_POSIX 2
#define TIMER_WIN32 3
#define TIMER_DOS 4
#define TIMER_PSP 5

// messageboxes (XASH_MESSAGEBOX)
#define MSGBOX_STDERR 0
#define MSGBOX_SDL 1
#define MSGBOX_WIN32 3
#define MSGBOX_NSWITCH 4
#define MSGBOX_PSP 5

// library loading (XASH_LIB)
#define LIB_NULL 0
#define LIB_POSIX 1
#define LIB_WIN32 2
#define LIB_NULL 0
#define LIB_POSIX 1
#define LIB_WIN32 2
#define LIB_STATIC 3
#define LIB_PSP 4

#endif /* BACKENDS_H */
5 changes: 5 additions & 0 deletions common/com_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_SRGB \
|| type == PF_KTX2_RAW )
#define ImageIND( type ) (type == PF_INDEXED_32 || type == PF_INDEXED_24)

typedef enum
{
Expand All @@ -33,6 +34,10 @@ typedef enum
PF_BGRA_32, // big endian RGBA (MacOS)
PF_RGB_24, // uncompressed dds or another 24-bit image
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_DXT1, // s3tc DXT1/BC1 format
PF_DXT3, // s3tc DXT3/BC2 format
Expand Down
17 changes: 16 additions & 1 deletion common/com_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ typedef struct
int flags; // sky or slime, no lightmap or 256 subdivision
} 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
{
struct glpoly_s *next;
Expand All @@ -135,7 +150,7 @@ typedef struct glpoly_s
int flags; // for SURF_UNDERWATER
float verts[4][VERTEXSIZE]; // variable sized (xyz s1t1 s2t2)
} glpoly_t;

#endif
typedef struct mnode_s
{
// common with leaf
Expand Down
44 changes: 43 additions & 1 deletion common/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ SETUP BACKENDS DEFINITIONS

// usually only 10-20 fds availiable
#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 // XASH_DEDICATED
Expand Down Expand Up @@ -105,14 +129,16 @@ SETUP BACKENDS DEFINITIONS
#endif // !XASH_WIN32
#endif

#ifdef XASH_STATIC_LIBS
#if defined(XASH_STATIC_LIBS) && !XASH_PSP
#define XASH_LIB LIB_STATIC
#define XASH_INTERNAL_GAMELIBS
#define XASH_ALLOW_SAVERESTORE_OFFSETS
#elif XASH_WIN32
#define XASH_LIB LIB_WIN32
#elif XASH_POSIX
#define XASH_LIB LIB_POSIX
#elif XASH_PSP
#define XASH_LIB LIB_PSP
#endif

//
Expand Down Expand Up @@ -193,4 +219,20 @@ Default build-depended cvar and constant values
#define DEFAULT_MAX_EDICTS 1200 // was 900 before HL25
#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
14 changes: 13 additions & 1 deletion common/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ GNU General Public License for more details.
#include <sys/syslimits.h>
#define OS_LIB_EXT "dylib"
#define OPEN_COMMAND "open"
#else
#elif XASH_PSP
#define OS_LIB_EXT "prx"
#else
#define OS_LIB_EXT "so"
#define OPEN_COMMAND "xdg-open"
#endif
Expand Down Expand Up @@ -55,6 +57,16 @@ GNU General Public License for more details.
#define _mkdir( x ) mkdir( x, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH )
#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* HINSTANCE;

Expand Down
5 changes: 5 additions & 0 deletions common/render_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ typedef enum
TF_TEXTURE_3D = (1<<20), // this is GL_TEXTURE_3D
TF_ATLAS_PAGE = (1<<21), // bit who indicate lightmap page or deluxemap page
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
#endif
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_NOCOMPARE = (1<<27), // disable comparing for depth textures
Expand Down
14 changes: 14 additions & 0 deletions common/xash3d_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,22 @@ typedef int sound_t;
typedef float vec_t;
typedef vec_t vec2_t[2];
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 quat_t[4];
#endif
typedef byte rgba_t[4]; // 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 matrix4x4[4][4];
#endif

#if XASH_64BIT
typedef uint32_t poolhandle_t;
Expand Down Expand Up @@ -194,13 +204,17 @@ typedef void *(*pfnCreateInterface_t)( const char *, int * );
// config strings are a general means of communication from
// the server to all connected clients.
// each config string can be at most CS_SIZE characters.
#if XASH_PSP
#define MAX_QPATH 48
#else
#if XASH_LOW_MEMORY == 0
#define MAX_QPATH 64 // max length of a game pathname
#elif XASH_LOW_MEMORY == 2
#define MAX_QPATH 32 // should be enough for singleplayer
#elif XASH_LOW_MEMORY == 1
#define MAX_QPATH 48
#endif
#endif
#define MAX_OSPATH 260 // max length of a filesystem pathname
#define CS_SIZE 64 // size of one config string
#define CS_TIME 16 // size of time string
Expand Down
12 changes: 0 additions & 12 deletions engine/client/cl_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ GNU General Public License for more details.

// #define STUDIO_INTERPOLATION_FIX

/*
==================
CL_IsPlayerIndex
detect player entity
==================
*/
qboolean CL_IsPlayerIndex( int idx )
{
return ( idx >= 1 && idx <= cl.maxclients );
}

/*
=========================================================================
Expand Down
38 changes: 1 addition & 37 deletions engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

/*
====================
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
Expand Down Expand Up @@ -939,7 +904,7 @@ void CL_DrawCrosshair( void )
VectorAdd( refState.viewangles, cl.crosshairangle, angles );
AngleVectors( angles, forward, NULL, NULL );
VectorAdd( refState.vieworg, forward, point );
ref.dllFuncs.WorldToScreen( point, screen );
gTriApi.WorldToScreen( point, screen );

x += ( clgame.viewport[2] >> 1 ) * screen[0] + 0.5f;
y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f;
Expand Down Expand Up @@ -1084,7 +1049,6 @@ void CL_ClearWorld( void )

world.max_recursion = 0;

clgame.ds.cullMode = TRI_FRONT;
clgame.numStatics = 0;
}

Expand Down
12 changes: 6 additions & 6 deletions engine/client/cl_netgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ NetGraph_FillRGBA shortcut
*/
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 );
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top, 0 );
ref.dllFuncs.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, 0 );
gTriApi.Vertex3f( rect->left + rect->right, rect->top, 0 );
gTriApi.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
gTriApi.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
}

/*
Expand Down Expand Up @@ -691,7 +691,7 @@ void SCR_DrawNetGraph( void )

ref.dllFuncs.End();
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.RenderMode( kRenderNormal );
}
}

Expand Down
Loading

0 comments on commit 8044646

Please sign in to comment.