summaryrefslogtreecommitdiff
path: root/common/xbox/xbox_core.h
blob: b109a1967dc4888a7756cd95c306f39b95bb11a6 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: XBox Core definitions
//
//=============================================================================
#pragma once

#define XBOX_DONTCARE					0		// for functions with don't care params

#define XBX_MAX_DPORTS					4
#define XBX_MAX_BUTTONSAMPLE			32768
#define XBX_MAX_ANALOGSAMPLE			255
#define XBX_MAX_MESSAGE					2048
#define XBX_MAX_PATH					MAX_PATH
#define XBX_MAX_RCMDLENGTH				256
#define XBX_MAX_RCMDNAMELEN				32
#define XBX_HDD_CLUSTERSIZE				16384

// could be dvd or hdd, actual device depends on source of xex launch
#define XBX_DVD_DRIVE					"D:\\"
#define XBX_BOOT_DRIVE					"D:\\"

#define XBX_IOTHREAD_STACKSIZE			32768
#define XBX_IOTHREAD_PRIORITY			THREAD_PRIORITY_HIGHEST

// scale by screen dimension to get an inset
#define XBOX_MINBORDERSAFE				0.05f
#define XBOX_MAXBORDERSAFE				0.075f

#define	XBX_CALCSIG_TYPE				XCALCSIG_FLAG_NON_ROAMABLE
#define XBX_INVALID_STORAGE_ID			((DWORD)-1)
#define XBX_STORAGE_DECLINED			((DWORD)-2)
#define XBX_INVALID_USER_ID				((DWORD)-1)

#define XBX_USER_SETTINGS_CONTAINER_DRIVE	"CFG"

// Path to our running executable
#define XBX_XEX_BASE_FILENAME			"default.xex"
#define XBX_XEX_PATH					XBX_BOOT_DRIVE XBX_XEX_BASE_FILENAME

#define XBX_CLR_DEFAULT					0xFF000000
#define XBX_CLR_WARNING					0x0000FFFF
#define XBX_CLR_ERROR					0x000000FF

// disk space requirements
#define XBX_SAVEGAME_BYTES				( 1024 * 1024 * 2 )
#define XBX_CONFIGFILE_BYTES			( 1024 * 100 )
#define XBX_USER_STATS_BYTES			( 1024 * 28 )
#define XBX_USER_SETTINGS_BYTES			( XBX_CONFIGFILE_BYTES + XBX_USER_STATS_BYTES )

#define XBX_PERSISTENT_BYTES_NEEDED		( XBX_SAVEGAME_BYTES * 10 )	// 8 save games, 1 autosave, 1 autosavedangerous

#define XMAKECOLOR( r, g, b )			((unsigned int)(((unsigned char)(r)|((unsigned int)((unsigned char)(g))<<8))|(((unsigned int)(unsigned char)(b))<<16)))

#define MAKE_NON_SRGB_FMT(x)			((D3DFORMAT)( ((unsigned int)(x)) & ~(D3DFORMAT_SIGNX_MASK | D3DFORMAT_SIGNY_MASK | D3DFORMAT_SIGNZ_MASK)))
#define IS_D3DFORMAT_SRGB( x )			( MAKESRGBFMT(x) == (x) )

typedef enum
{
	XEV_NULL,
	XEV_REMOTECMD,
	XEV_QUIT,
	XEV_LISTENER_NOTIFICATION,
} xevent_e;

typedef struct xevent_s
{
	xevent_e	event;
	int			arg1;
	int			arg2;
	int			arg3;
} xevent_t;

typedef enum
{
	XK_NULL,
	XK_BUTTON_UP,
	XK_BUTTON_DOWN,
	XK_BUTTON_LEFT,
	XK_BUTTON_RIGHT,
	XK_BUTTON_START,
	XK_BUTTON_BACK,
	XK_BUTTON_STICK1,
	XK_BUTTON_STICK2,
	XK_BUTTON_A,
	XK_BUTTON_B,
	XK_BUTTON_X,
	XK_BUTTON_Y,
	XK_BUTTON_LEFT_SHOULDER,
	XK_BUTTON_RIGHT_SHOULDER,
	XK_BUTTON_LTRIGGER,
	XK_BUTTON_RTRIGGER,
	XK_STICK1_UP,
	XK_STICK1_DOWN,
	XK_STICK1_LEFT,
	XK_STICK1_RIGHT,
	XK_STICK2_UP,
	XK_STICK2_DOWN,
	XK_STICK2_LEFT,
	XK_STICK2_RIGHT,
	XK_MAX_KEYS,
} xKey_t;

typedef struct
{
	const char	*pName;
	const char	*pGroupName;
	const char	*pFormatName;
	int			size;
	int			width;
	int			height;
	int			depth;
	int			numLevels;
	int			binds;
	int			refCount;
	int			sRGB;
	int			edram;
	int			procedural;
	int			fallback;
	int			final;
	int			failed;
} xTextureList_t;

typedef struct
{
	const char	*pName;
	const char	*pShaderName;
	int			refCount;
} xMaterialList_t;

typedef struct
{
	char		name[MAX_PATH];
	char		formatName[32];
	int			rate;
	int			bits;
	int			channels;
	int			looped;
	int			dataSize;
	int			numSamples;
	int			streamed;
} xSoundList_t;

typedef struct
{
	float	position[3];
	float	angle[3];
	char	mapPath[256];
	char	savePath[256];
	int		build;
	int		skill;
} xMapInfo_t;

/******************************************************************************
	XBOX_SYSTEM.CPP
******************************************************************************/
#if defined( PLATFORM_H )

// redirect debugging output through xbox debug channel
#define OutputDebugStringA		XBX_OutputDebugStringA

// Messages
PLATFORM_INTERFACE	void		XBX_Error( const char* format, ... );
PLATFORM_INTERFACE	void		XBX_OutputDebugStringA( LPCSTR lpOutputString );

// Event handling
PLATFORM_INTERFACE  bool		XBX_NotifyCreateListener( ULONG64 categories );
PLATFORM_INTERFACE	void		XBX_QueueEvent( xevent_e event, int arg1, int arg2, int arg3 );
PLATFORM_INTERFACE	void		XBX_ProcessEvents( void );

// Accessors
PLATFORM_INTERFACE	const char* XBX_GetLanguageString( void );
PLATFORM_INTERFACE	bool		XBX_IsLocalized( void );
PLATFORM_INTERFACE	DWORD		XBX_GetStorageDeviceId( void );
PLATFORM_INTERFACE	void		XBX_SetStorageDeviceId( DWORD id );
PLATFORM_INTERFACE	DWORD		XBX_GetPrimaryUserId( void );
PLATFORM_INTERFACE	void		XBX_SetPrimaryUserId( DWORD id );
PLATFORM_INTERFACE  XNKID		XBX_GetInviteSessionId( void );
PLATFORM_INTERFACE	void		XBX_SetInviteSessionId( XNKID nSessionId );
PLATFORM_INTERFACE  DWORD		XBX_GetInvitedUserId( void );
PLATFORM_INTERFACE	void		XBX_SetInvitedUserId( DWORD nUserId );

#endif