summaryrefslogtreecommitdiff
path: root/utils/xbox/xbox_loader/xbox_loader.h
blob: b37b2d526388e14a288a8e0f6f19e378acd7590b (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//	XBOX_LOADER.H
//
//	Master Include
//=====================================================================================//

#pragma once

#include <xtl.h>
#include <XBApp.h>
#include <XBFont.h>
#include <XBHelp.h>
#include <xgraphics.h>
#include <xfont.h>
#include <xmv.h>
#include <xbdm.h>
#include <math.h>
#include "XBResource.h"
#include "xmvhelper.h"
#include "toollib.h"
#include "scriplib.h"
#include "loader.h"
#include "jcalg1.h"
#include "xbox/xbox_launch.h"

#define XBOX_FORENSIC_LOG

#define SCREEN_WIDTH			640
#define SCREEN_HEIGHT			480
#define MAX_FILES				500
#define MAX_SLIDESHOW_TEXTURES	9

#define LEGAL_DISPLAY_TIME		6000
#define LOADINGBAR_UPTIME		500.0f	// slid up or down
#define LOADINGBAR_SLIDETIME	1500.0f	// progress speed
#define LOADINGBAR_WAITTIME		500.0f	// delay after up to begin slide
#define SLIDESHOW_SLIDETIME		7000
#define SLIDESHOW_FLIPTIME		1000

#define LEGAL_MAIN				0
#define LEGAL_SOURCE			1

#define FOOTER_W				512

#define SEGMENT_W				10
#define SEGMENT_GAP				1
#define SEGMENT_COUNT			26

#define PROGRESS_Y				405
#define PROGRESS_W				(SEGMENT_COUNT*(SEGMENT_W+SEGMENT_GAP))
#define PROGRESS_H				15
#define PROGRESS_X				124

#define PROGRESS_FOOTER_COLOR	0x88FFFFFF
#define PROGRESS_INSET_COLOR	0xFF222222
#define PROGRESS_SEGMENT_COLOR	0xFFCC6C00
#define PROGRESS_TEXT_COLOR		0xFFFFFFFF

//-----------------------------------------------------------------------------
// Main class to run this application. Most functionality is inherited
// from the CXBApplication base class.
//-----------------------------------------------------------------------------
class CXBoxLoader : public CXBApplication
{
public:
    CXBoxLoader();

	virtual HRESULT Initialize( void );
    virtual HRESULT Render( void );
    virtual HRESULT FrameMove( void );

	void			DrawRect( int x, int y, int w, int h, DWORD color );
	void			DrawLegals();
	void			DrawDebug();
	BOOL			PlayVideoFrame();
    HRESULT			StartVideo( const CHAR* strFilename, bool bFromMemory, bool bFatalOnError );
	void			StopVideo();
	bool			StartInstall( void );
	bool			LoadInstallScript( void );
	D3DTexture		*LoadTexture( int resourceID );
	HRESULT			LoadFont( CXBFont *pFont, int resourceID ); 
	void			DrawTexture( D3DTexture *pD3DTexture, int x, int y, int w, int h, int color );
	void			StartLegalScreen( int legal );
	void			DrawProgressBar();
	void			DrawLoadingMarquee();
	void			DrawSlideshow();
	bool			VerifyInstall();
	void			StartDashboard( bool bGotoMemory );
	void			LoadLogFile();
	void			DrawLog();
	void			FatalMediaError();
	void			LaunchHL2( unsigned int contextCode );
	void			TickVideo();

private:
	IDirect3DTexture8	*m_pLastMovieFrame;
	D3DTexture			*m_pFooterTexture;
	D3DTexture			*m_pLoadingIconTexture;
	D3DTexture			*m_pMainLegalTexture;
	D3DTexture			*m_pSourceLegalTexture;
	D3DTexture			*m_pLegalTexture;
	D3DTexture			*m_pSlideShowTextures[MAX_SLIDESHOW_TEXTURES];

    CXMVPlayer			m_player;

	D3DVertexBuffer		*m_pVB;
	CXBPackedResource	m_xprResource;

	CXBFont				m_Font;

	int					m_contextCode;

	char				*m_fileSrc[MAX_FILES];
	char				*m_fileDest[MAX_FILES];
	xCompressHeader		*m_fileCompressionHeaders[MAX_FILES];
	DWORD				m_fileDestSizes[MAX_FILES];
	int					m_numFiles;

	bool				m_bAllowAttractAbort;
	bool				m_bDrawLoading;
	bool				m_bDrawProgress;
	bool				m_bDrawDebug;
	bool				m_bLaunch;
	DWORD				m_dwLoading;
	bool				m_bDrawLegal;
	HANDLE				m_installThread;
	DWORD				m_LegalTime;
	int					m_State;
	DWORD				m_LoadingBarStartTime;
	DWORD				m_LoadingBarEndTime;
	DWORD				m_LegalStartTime;
	bool				m_bInstallComplete;
	int					m_Version;
	int					m_FrameCounter;
	int					m_MovieCount;
	bool				m_bMovieErrorIsFatal;
	bool				m_bCaptureLastMovieFrame;
	DWORD				m_SlideShowStartTime;
	bool				m_bDrawSlideShow;
	int					m_SlideShowCount;
	bool				m_bFinalSlide;
	char				*m_pLogData;
	XFONT*				m_pDefaultTrueTypeFont;
};

struct CopyStats_t
{
	char				m_srcFilename[MAX_PATH];
	char				m_dstFilename[MAX_PATH];
	DWORD				m_readSize;
	DWORD				m_writeSize;
	DWORD				m_bytesCopied;
	DWORD				m_totalReadTime;
	DWORD				m_totalWriteTime;
	DWORD				m_totalReadSize;
	DWORD				m_totalWriteSize;
	DWORD				m_bufferReadSize;
	DWORD				m_bufferWriteSize;
	DWORD				m_bufferReadTime;
	DWORD				m_bufferWriteTime;
	DWORD				m_inflateSize;
	DWORD				m_inflateTime;
	DWORD				m_copyTime;
	DWORD				m_copyErrors;
	DWORD				m_numReadBuffers;
	DWORD				m_numWriteBuffers;
};

extern bool CopyFileOverlapped( const char *pSrc, const char *pDest, xCompressHeader *pxcHeader, CopyStats_t *pCopyStats );
extern bool CreateFilePath( const char *inPath );