This commit is contained in:
nephacks
2025-06-04 03:22:50 +02:00
parent f234f23848
commit f12416cffd
14243 changed files with 6446499 additions and 26 deletions

68
launcher_main/ExportC.py Normal file
View File

@ -0,0 +1,68 @@
# Export from maya directly into simple vertex / index buffer for direct rendering
# Usage: just run the script below on a selected mesh object. it'll print vertex and index buffers
import sys
import math
import os
import StringIO
import maya.OpenMaya as OpenMaya
import maya.OpenMayaMPx as OpenMayaMPx
selList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(selList)
selListIter = OpenMaya.MItSelectionList(selList)
listVertices = []
listFaces = []
while not selListIter.isDone():
dagPath = OpenMaya.MDagPath()
component = OpenMaya.MObject()
selListIter.getDagPath(dagPath, component)
rot = OpenMaya.MQuaternion()
dagTransform = dagPath.transform()
if( dagTransform.apiType() == OpenMaya.MFn.kTransform ):
xformFn = OpenMaya.MFnTransform(dagTransform)
xform = xformFn.transformation().asRotateMatrix()
xformFn.getRotation( rot )
else:
xform = OpenMaya.MMatrix()
xform.setToIdentity()
dagPath.extendToShape()
if (dagPath.apiType() == OpenMaya.MFn.kMesh):
mesh = dagPath.node()
meshFn = OpenMaya.MFnMesh(mesh)
vertIter = OpenMaya.MItMeshVertex( dagPath, component )
print "// ", vertIter.count(), " verts in ", dagPath.partialPathName()
print "ErrorRenderLoop::Vertex_t g_verts_%s[%d] = {" % (dagPath.partialPathName(), vertIter.count())
while not vertIter.isDone():
vertPos = OpenMaya.MVector(vertIter.position()).rotateBy(rot)
vertColor = OpenMaya.MColor(1,1,1,1)
vertNormal = OpenMaya.MVector()
vertIter.getNormal( vertNormal )
if( vertIter.hasColor() ):
vertIter.getColor( vertColor )
vertNormal = vertNormal.rotateBy(rot)
print "{%.3f,%.3f,%.3f, %.3f,%.3f,%.3f, 0x%02X%02X%02X%02X }," % (vertPos.x,vertPos.y,vertPos.z, vertNormal.x, vertNormal.y, vertNormal.z, vertColor.r*255, vertColor.g*255,vertColor.b*255, vertColor.a*255 )
vertIter.next()
print "};"
faceIter = OpenMaya.MItMeshPolygon(dagPath,component)
print "// ", faceIter.count(), " triangles"
print "uint16_t g_tris_%s[%d][3] = {" % ( dagPath.partialPathName(), faceIter.count() )
faceCount = 0
while not faceIter.isDone():
faceVerts = OpenMaya.MIntArray()
faceIter.getVertices( faceVerts )
print ("" if faceCount == 0 else ", "), "{ ", ", ".join( str(x) for x in faceVerts ), " }"
faceCount = faceCount + 1
faceIter.next()
print "};"
selListIter.next()

View File

@ -0,0 +1,10 @@
// ----------------------------------------- //
// File generated by VPC //
// ----------------------------------------- //
Source file: F:\csgo_64\cstrike15_src\launcher_main\main.cpp
Debug output file: F:\csgo_64\cstrike15_src\launcher_main\main.cpp
Release output file: F:\csgo_64\cstrike15_src\launcher_main\main.cpp
Containing unity file:
PCH file:

View File

@ -0,0 +1,818 @@
//========= Copyright (c) 2010, Valve Corporation, All rights reserved. ============//
/* SCE CONFIDENTIAL */
/* PlayStation(R)3 Programmer Tool Runtime Library 350.001 */
/* Copyright (C) 2009 Sony Computer Entertainment Inc. */
/* All Rights Reserved. */
/* File: main.cpp
* Description:
* simple graphics to show how to use libgcm
*
*/
#include "errorrenderloop.h"
#include <ppu_intrinsics.h>
#define ARRAYSIZE( ARRAY ) ( sizeof( ARRAY ) / sizeof( ( ARRAY )[0] ) )
#ifdef _DEBUG
#define CELL_GCMUTIL_ASSERT(X) do{ if( !( X ) ) {printf( "Assert(%s)\n%s:%d\n", #X, __FILE__, __LINE__ ); __builtin_snpause(); } }while(0)
#define CELL_GCMUTIL_CHECK_ASSERT(X) CELL_GCMUTIL_ASSERT( X == CELL_OK )
#define CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(X) CELL_GCMUTIL_ASSERT(X != 0 )
#else
#define CELL_GCMUTIL_ASSERT(X)
#define CELL_GCMUTIL_CHECK_ASSERT(X) (X)
#define CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(X) (void)(X)
#endif
// For exit routine
static void sysutil_exit_callback(uint64_t status, uint64_t param, void* userdata);
extern uint32_t _binary_errorshader_vpo_start;
extern uint32_t _binary_errorshader_vpo_end;
extern uint32_t _binary_errorshader_fpo_start;
extern uint32_t _binary_errorshader_fpo_end;
PS3_GcmSharedData g_gcmSharedData;
using namespace cell::Gcm;
ErrorRenderLoop::ErrorRenderLoop()
{
m_keepRunning = true;
m_nLocalMemHeap = 0;
vertex_program_ptr =
(unsigned char *)&_binary_errorshader_vpo_start;
fragment_program_ptr =
(unsigned char *)&_binary_errorshader_fpo_start;
frame_index = 0;
}
/* local memory allocation */
void *ErrorRenderLoop::localMemoryAlloc(const uint32_t size)
{
uint32_t allocated_size = (size + 1023) & (~1023);
uint32_t base = m_nLocalMemHeap;
m_nLocalMemHeap += allocated_size;
return (void*)base;
}
void *ErrorRenderLoop::localMemoryAlign(const uint32_t alignment,
const uint32_t size)
{
m_nLocalMemHeap = (m_nLocalMemHeap + alignment-1) & (~(alignment-1));
return (void*)localMemoryAlloc(size);
}
void ErrorRenderLoop::setRenderTarget(const uint32_t Index)
{
CellGcmSurface sf;
sf.colorFormat = CELL_GCM_SURFACE_A8R8G8B8;
sf.colorTarget = CELL_GCM_SURFACE_TARGET_0;
sf.colorLocation[0] = CELL_GCM_LOCATION_LOCAL;
sf.colorOffset[0] = color_offset[Index];
sf.colorPitch[0] = color_pitch;
sf.colorLocation[1] = CELL_GCM_LOCATION_LOCAL;
sf.colorLocation[2] = CELL_GCM_LOCATION_LOCAL;
sf.colorLocation[3] = CELL_GCM_LOCATION_LOCAL;
sf.colorOffset[1] = 0;
sf.colorOffset[2] = 0;
sf.colorOffset[3] = 0;
sf.colorPitch[1] = 64;
sf.colorPitch[2] = 64;
sf.colorPitch[3] = 64;
sf.depthFormat = CELL_GCM_SURFACE_Z24S8;
sf.depthLocation = CELL_GCM_LOCATION_LOCAL;
sf.depthOffset = depth_offset;
sf.depthPitch = depth_pitch;
sf.type = CELL_GCM_SURFACE_PITCH;
sf.antialias = CELL_GCM_SURFACE_CENTER_1;
sf.width = display_width;
sf.height = display_height;
sf.x = 0;
sf.y = 0;
cellGcmSetSurface(&sf);
//cellGcmSetAntiAliasingControl(CELL_GCM_TRUE, CELL_GCM_FALSE, CELL_GCM_FALSE, 0xffff);
}
/* wait until flip */
static void waitFlip(void)
{
while (cellGcmGetFlipStatus()!=0){
sys_timer_usleep(300);
}
cellGcmResetFlipStatus();
}
void ErrorRenderLoop::flip(void)
{
static int first=1;
// wait until the previous flip executed
if (first!=1) waitFlip();
else cellGcmResetFlipStatus();
if(cellGcmSetFlip(frame_index) != CELL_OK) return;
cellGcmFlush();
// resend status
setDrawEnv();
setRenderState();
cellGcmSetWaitFlip();
// New render target
frame_index = (frame_index+1)%COLOR_BUFFER_NUM;
setRenderTarget(frame_index);
first=0;
}
void ErrorRenderLoop::initShader(void)
{
vertex_program = (CGprogram)vertex_program_ptr;
fragment_program = (CGprogram)fragment_program_ptr;
// init
cellGcmCgInitProgram(vertex_program);
cellGcmCgInitProgram(fragment_program);
uint32_t ucode_size;
void *ucode;
cellGcmCgGetUCode(fragment_program, &ucode, &ucode_size);
// 64B alignment required
void *ret = localMemoryAlign(64, ucode_size);
fragment_program_ucode = ret;
memcpy(fragment_program_ucode, ucode, ucode_size);
cellGcmCgGetUCode(vertex_program, &ucode, &ucode_size);
vertex_program_ucode = ucode;
}
static void buildProjection(float *M,
const float top,
const float bottom,
const float left,
const float right,
const float near,
const float far)
{
memset(M, 0, 16*sizeof(float));
M[0*4+0] = (2.0f*near) / (right - left);
M[1*4+1] = (2.0f*near) / (bottom - top);
float A = (right + left) / (right - left);
float B = (top + bottom) / (top - bottom);
float C = -(far + near) / (far - near);
float D = -(2.0f*far*near) / (far - near);
M[0*4 + 2] = A;
M[1*4 + 2] = B;
M[2*4 + 2] = C;
M[3*4 + 2] = -1.0f;
M[2*4 + 3] = D;
}
static void matrixMul(float *Dest, float *A, float *B)
{
for (int i=0; i < 4; i++) {
for (int j=0; j < 4; j++) {
Dest[i*4+j]
= A[i*4+0]*B[0*4+j]
+ A[i*4+1]*B[1*4+j]
+ A[i*4+2]*B[2*4+j]
+ A[i*4+3]*B[3*4+j];
}
}
}
static void matrixTranslate(float *M,
const float x,
const float y,
const float z)
{
memset(M, 0, sizeof(float)*16);
M[0*4+3] = x;
M[1*4+3] = y;
M[2*4+3] = z;
M[0*4+0] = 1.0f;
M[1*4+1] = 1.0f;
M[2*4+2] = 1.0f;
M[3*4+3] = 1.0f;
}
/*
static void unitMatrix(float *M)
{
M[0*4+0] = 1.0f;
M[0*4+1] = 0.0f;
M[0*4+2] = 0.0f;
M[0*4+3] = 0.0f;
M[1*4+0] = 0.0f;
M[1*4+1] = 1.0f;
M[1*4+2] = 0.0f;
M[1*4+3] = 0.0f;
M[2*4+0] = 0.0f;
M[2*4+1] = 0.0f;
M[2*4+2] = 1.0f;
M[2*4+3] = 0.0f;
M[3*4+0] = 0.0f;
M[3*4+1] = 0.0f;
M[3*4+2] = 0.0f;
M[3*4+3] = 1.0f;
}
*/
#define CB_SIZE (0x10000)
int32_t ErrorRenderLoop::initDisplay(void)
{
uint32_t color_depth=4; // ARGB8
uint32_t z_depth=4; // COMPONENT24
void *color_base_addr;
void *depth_base_addr;
void *color_addr[COLOR_BUFFER_NUM];
void *depth_addr;
CellVideoOutResolution resolution;
// display initialize
// read the current video status
// INITIAL DISPLAY MODE HAS TO BE SET BY RUNNING SETMONITOR.SELF
CellVideoOutState videoState;
CELL_GCMUTIL_CHECK_ASSERT(cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &videoState));
CELL_GCMUTIL_CHECK_ASSERT(cellVideoOutGetResolution(videoState.displayMode.resolutionId, &resolution));
display_width = resolution.width;
display_height = resolution.height;
color_pitch = display_width*color_depth;
depth_pitch = display_width*z_depth;
uint32_t color_size = color_pitch*display_height;
uint32_t depth_size = depth_pitch*display_height;
CellVideoOutConfiguration videocfg;
memset(&videocfg, 0, sizeof(CellVideoOutConfiguration));
videocfg.resolutionId = videoState.displayMode.resolutionId;
videocfg.format = CELL_VIDEO_OUT_BUFFER_COLOR_FORMAT_X8R8G8B8;
videocfg.pitch = color_pitch;
// set video out configuration with waitForEvent set to 0 (4th parameter)
CELL_GCMUTIL_CHECK_ASSERT(cellVideoOutConfigure(CELL_VIDEO_OUT_PRIMARY, &videocfg, NULL, 0));
CELL_GCMUTIL_CHECK_ASSERT(cellVideoOutGetState(CELL_VIDEO_OUT_PRIMARY, 0, &videoState));
switch (videoState.displayMode.aspect){
case CELL_VIDEO_OUT_ASPECT_4_3:
display_aspect_ratio=4.0f/3.0f;
break;
case CELL_VIDEO_OUT_ASPECT_16_9:
display_aspect_ratio=16.0f/9.0f;
break;
default:
printf("unknown aspect ratio %x\n", videoState.displayMode.aspect);
display_aspect_ratio=16.0f/9.0f;
}
cellGcmSetFlipMode(CELL_GCM_DISPLAY_VSYNC);
// get config
CellGcmConfig config;
cellGcmGetConfiguration(&config);
// buffer memory allocation
m_nLocalMemHeap = (uint32_t)config.localAddress;
color_base_addr = localMemoryAlign(64, COLOR_BUFFER_NUM*color_size);
for (int i = 0; i < COLOR_BUFFER_NUM; i++) {
color_addr[i]= (void *)((uint32_t)color_base_addr+ (i*color_size));
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(color_addr[i], &color_offset[i]));
}
// regist surface
for (int i = 0; i < COLOR_BUFFER_NUM; i++) {
CELL_GCMUTIL_CHECK_ASSERT(cellGcmSetDisplayBuffer(i, color_offset[i], color_pitch, display_width, display_height));
}
depth_base_addr = localMemoryAlign(64, depth_size);
depth_addr = depth_base_addr;
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(depth_addr, &depth_offset));
return 0;
}
// 65 verts in polySurfaceShape1
ErrorRenderLoop::Vertex_t g_verts_polySurfaceShape1[65] = {
{0.287,2.232,-0.144, 0.398,0.702,-0.590, 0xFFFF5FFF },
{-0.287,2.232,-0.144, -0.404,0.699,-0.590, 0xFFFF00FF },
{-1.634,-0.134,-0.134, -0.808,-0.006,-0.588, 0xFFFF00FF },
{-1.366,-0.598,-0.134, -0.413,-0.695,-0.589, 0xFFFF00FF },
{1.345,-0.635,-0.155, 0.400,-0.700,-0.592, 0xFFFF00FF },
{1.655,-0.097,-0.155, 0.806,0.001,-0.592, 0xFFFF00FF },
{0.287,2.232,0.144, 0.455,0.835,0.308, 0xFFFF5FFF },
{-0.287,2.232,0.144, -0.462,0.832,0.309, 0xFFFF5FFF },
{-1.634,-0.134,0.134, -0.937,-0.034,0.347, 0xFFFF00FF },
{-1.366,-0.598,0.134, -0.484,-0.795,0.367, 0xFFFF5FFF },
{1.345,-0.635,0.155, 0.470,-0.802,0.369, 0xFFFF5FFF },
{1.655,-0.097,0.155, 0.937,-0.027,0.348, 0xFFFF00FF },
{0.000,0.500,-0.257, -0.007,0.000,-1.000, 0xFFFF00FF },
{0.000,0.274,0.422, 0.000,0.962,0.272, 0xFF0076FF },
{0.000,-0.085,0.422, 0.000,-0.962,0.272, 0xFF0076FF },
{-0.173,0.094,0.422, -0.964,0.000,0.266, 0xFF0076FF },
{0.173,0.094,0.422, 0.964,0.000,0.266, 0xFF0076FF },
{-0.058,0.445,0.422, -0.592,-0.698,0.404, 0xFF0076FF },
{0.058,0.445,0.422, 0.591,-0.698,0.404, 0xFF0076FF },
{0.002,2.002,0.422, 0.019,0.915,0.403, 0xFF0000FF },
{0.173,1.774,0.422, 0.871,0.278,0.405, 0xFF0000FF },
{-0.172,1.789,0.422, -0.864,0.296,0.407, 0xFF0000FF },
{0.088,0.787,0.422, 0.963,-0.084,0.256, 0xFF0076FF },
{-0.088,0.787,0.422, -0.963,-0.082,0.256, 0xFF0076FF },
{0.124,1.192,0.422, 0.949,-0.082,0.304, 0xFF0000FF },
{-0.123,1.192,0.422, -0.950,-0.081,0.302, 0xFF0000FF },
{0.161,1.597,0.422, 0.935,-0.070,0.347, 0xFF0000FF },
{-0.159,1.597,0.422, -0.936,-0.071,0.345, 0xFF0000FF },
{0.000,0.274,0.349, 0.000,0.818,-0.575, 0xFFFFFFFF },
{-0.173,0.094,0.349, -0.815,0.000,-0.579, 0xFFFFFFFF },
{0.000,-0.085,0.349, 0.000,-0.818,-0.575, 0xFF0076FF },
{0.173,0.094,0.349, 0.815,0.000,-0.579, 0xFF0076FF },
{0.173,1.774,0.349, 0.739,0.219,-0.637, 0xFFFFFFFF },
{0.002,2.002,0.349, 0.018,0.825,-0.566, 0xFFFFFFFF },
{-0.172,1.789,0.349, -0.738,0.235,-0.633, 0xFFFFFFFF },
{0.058,0.445,0.349, 0.549,-0.600,-0.582, 0xFFFFFFFF },
{0.088,0.787,0.349, 0.704,-0.063,-0.707, 0xFFFFFFFF },
{-0.088,0.787,0.349, -0.704,-0.062,-0.707, 0xFFFFFFFF },
{0.124,1.192,0.349, 0.704,-0.063,-0.707, 0xFFFFFFFF },
{-0.123,1.192,0.349, -0.704,-0.062,-0.707, 0xFFFFFFFF },
{0.161,1.597,0.349, 0.708,-0.055,-0.704, 0xFFFFFFFF },
{-0.159,1.597,0.349, -0.707,-0.056,-0.705, 0xFFFFFFFF },
{-0.058,0.445,0.349, -0.549,-0.600,-0.582, 0xFFFFFFFF },
{0.280,2.195,0.188, 0.318,0.461,0.828, 0xFFFF5FFF },
{-0.279,2.195,0.188, -0.323,0.457,0.829, 0xFFFF5FFF },
{0.000,0.508,0.298, -0.007,0.000,1.000, 0xFFFF00FF },
{-1.591,-0.110,0.178, -0.535,0.082,0.841, 0xFFFF00FF },
{-1.331,-0.561,0.178, -0.213,-0.432,0.877, 0xFFFF5FFF },
{1.310,-0.597,0.199, 0.199,-0.432,0.880, 0xFFFF5FFF },
{1.612,-0.074,0.199, 0.529,0.089,0.844, 0xFFFF00FF },
{-0.150,1.762,0.445, -0.414,0.061,0.908, 0xFF0000FF },
{0.150,1.747,0.445, 0.414,0.057,0.909, 0xFF0000FF },
{0.002,1.965,0.445, 0.016,0.404,0.915, 0xFF0000FF },
{-0.076,0.808,0.445, -0.498,-0.043,0.866, 0xFF0076FF },
{0.050,0.482,0.445, 0.464,-0.229,0.856, 0xFF0076FF },
{0.077,0.808,0.445, 0.497,-0.043,0.866, 0xFF0076FF },
{-0.107,1.194,0.445, -0.459,-0.037,0.888, 0xFF0000FF },
{0.108,1.194,0.445, 0.457,-0.037,0.888, 0xFF0000FF },
{-0.138,1.580,0.445, -0.423,-0.034,0.905, 0xFF0000FF },
{0.140,1.580,0.445, 0.422,-0.034,0.906, 0xFF0000FF },
{-0.050,0.482,0.445, -0.464,-0.229,0.856, 0xFF0076FF },
{0.000,-0.067,0.447, 0.000,-0.599,0.800, 0xFF0076FF },
{0.000,0.255,0.447, 0.000,0.599,0.800, 0xFF0076FF },
{-0.155,0.094,0.447, -0.603,0.000,0.798, 0xFF0076FF },
{0.155,0.094,0.447, 0.603,0.000,0.798, 0xFF0076FF },
};
// 118 triangles
uint16_t g_tris_polySurfaceShape1[118][3] = {
{ 0, 1, 6 }
, { 6, 1, 7 }
, { 1, 2, 7 }
, { 7, 2, 8 }
, { 2, 3, 8 }
, { 8, 3, 9 }
, { 3, 4, 9 }
, { 9, 4, 10 }
, { 4, 5, 10 }
, { 10, 5, 11 }
, { 5, 0, 11 }
, { 11, 0, 6 }
, { 1, 0, 12 }
, { 2, 1, 12 }
, { 3, 2, 12 }
, { 4, 3, 12 }
, { 5, 4, 12 }
, { 0, 5, 12 }
, { 43, 44, 45 }
, { 44, 46, 45 }
, { 46, 47, 45 }
, { 47, 48, 45 }
, { 48, 49, 45 }
, { 49, 43, 45 }
, { 28, 30, 29 }
, { 30, 28, 31 }
, { 32, 34, 33 }
, { 35, 37, 36 }
, { 36, 39, 38 }
, { 38, 41, 40 }
, { 34, 40, 41 }
, { 40, 34, 32 }
, { 37, 35, 42 }
, { 39, 36, 37 }
, { 41, 38, 39 }
, { 62, 63, 61 }
, { 61, 64, 62 }
, { 51, 52, 50 }
, { 54, 55, 53 }
, { 55, 57, 56 }
, { 57, 59, 58 }
, { 50, 58, 59 }
, { 59, 51, 50 }
, { 53, 60, 54 }
, { 56, 53, 55 }
, { 58, 56, 57 }
, { 13, 28, 15 }
, { 28, 29, 15 }
, { 15, 29, 14 }
, { 29, 30, 14 }
, { 14, 30, 16 }
, { 30, 31, 16 }
, { 16, 31, 13 }
, { 31, 28, 13 }
, { 20, 32, 19 }
, { 32, 33, 19 }
, { 19, 33, 21 }
, { 33, 34, 21 }
, { 18, 35, 22 }
, { 35, 36, 22 }
, { 22, 36, 24 }
, { 36, 38, 24 }
, { 24, 38, 26 }
, { 38, 40, 26 }
, { 21, 34, 27 }
, { 34, 41, 27 }
, { 26, 40, 20 }
, { 40, 32, 20 }
, { 23, 37, 17 }
, { 37, 42, 17 }
, { 17, 42, 18 }
, { 42, 35, 18 }
, { 25, 39, 23 }
, { 39, 37, 23 }
, { 27, 41, 25 }
, { 41, 39, 25 }
, { 7, 44, 6 }
, { 6, 44, 43 }
, { 8, 46, 7 }
, { 7, 46, 44 }
, { 9, 47, 8 }
, { 8, 47, 46 }
, { 9, 10, 47 }
, { 47, 10, 48 }
, { 10, 11, 48 }
, { 48, 11, 49 }
, { 11, 6, 49 }
, { 49, 6, 43 }
, { 19, 21, 52 }
, { 21, 50, 52 }
, { 19, 52, 20 }
, { 52, 51, 20 }
, { 18, 22, 54 }
, { 22, 55, 54 }
, { 22, 24, 55 }
, { 24, 57, 55 }
, { 26, 59, 24 }
, { 59, 57, 24 }
, { 21, 27, 50 }
, { 27, 58, 50 }
, { 20, 51, 26 }
, { 51, 59, 26 }
, { 18, 54, 17 }
, { 54, 60, 17 }
, { 17, 60, 23 }
, { 60, 53, 23 }
, { 23, 53, 25 }
, { 53, 56, 25 }
, { 27, 25, 58 }
, { 25, 56, 58 }
, { 14, 61, 15 }
, { 61, 63, 15 }
, { 13, 15, 62 }
, { 15, 63, 62 }
, { 13, 62, 16 }
, { 62, 64, 16 }
, { 14, 16, 61 }
, { 16, 64, 61 }
};
void ErrorRenderLoop::setDrawEnv(void)
{
cellGcmSetColorMask(CELL_GCM_COLOR_MASK_B|
CELL_GCM_COLOR_MASK_G|
CELL_GCM_COLOR_MASK_R|
CELL_GCM_COLOR_MASK_A);
cellGcmSetColorMaskMrt(0);
uint16_t x,y,w,h;
float min, max;
float scale[4],offset[4];
x = 0;
y = 0;
w = display_width;
h = display_height;
min = 0.0f;
max = 1.0f;
scale[0] = w * 0.5f;
scale[1] = h * -0.5f;
scale[2] = (max - min) * 0.5f;
scale[3] = 0.0f;
offset[0] = x + scale[0];
offset[1] = y + h * 0.5f;
offset[2] = (max + min) * 0.5f;
offset[3] = 0.0f;
cellGcmSetViewport(x, y, w, h, min, max, scale, offset);
cellGcmSetClearColor((64<<0)|(64<<8)|(64<<16)|(64<<24));
cellGcmSetDepthTestEnable(CELL_GCM_TRUE);
cellGcmSetDepthFunc(CELL_GCM_LESS);
}
void ErrorRenderLoop::setRenderState(void)
{
cellGcmSetVertexProgram(vertex_program, vertex_program_ucode);
cellGcmSetVertexDataArray(position_index,
0,
sizeof(Vertex_t),
3,
CELL_GCM_VERTEX_F,
CELL_GCM_LOCATION_LOCAL,
m_nVertPositionOffset);
cellGcmSetVertexDataArray(normal_index,
0,
sizeof(Vertex_t),
3,
CELL_GCM_VERTEX_F,
CELL_GCM_LOCATION_LOCAL,
m_nVertNormalOffset);
cellGcmSetVertexDataArray(color_index,
0,
sizeof(Vertex_t),
4,
CELL_GCM_VERTEX_UB,
CELL_GCM_LOCATION_LOCAL,
m_nVertColorOffset );
cellGcmSetFragmentProgram(fragment_program, fragment_offset);
}
void AngleMatrix( float yaw, float pitch, float roll, float matrix[16] )
{
float sy = sinf(yaw),cy = cosf( yaw ),sp = sinf( pitch ),cp = cosf( pitch ),sr = sinf( roll ),cr = cosf( roll );
// matrix = (YAW * PITCH) * ROLL
matrix[0*4+0] = cp*cy;
matrix[1*4+0] = cp*sy;
matrix[2*4+0] = -sp;
// NOTE: Do not optimize this to reduce multiplies! optimizer bug will screw this up.
matrix[0*4+1] = sr*sp*cy+cr*-sy;
matrix[1*4+1] = sr*sp*sy+cr*cy;
matrix[2*4+1] = sr*cp;
matrix[0*4+2] = (cr*sp*cy+-sr*-sy);
matrix[1*4+2] = (cr*sp*sy+-sr*cy);
matrix[2*4+2] = cr*cp;
matrix[0*4+3] = 0.0f;
matrix[1*4+3] = 0.0f;
matrix[2*4+3] = 0.0f;
matrix[3*4+0] = 0;
matrix[3*4+1] = 0;
matrix[3*4+2] = 0;
matrix[3*4+3] = 1;
}
// call this AFTER setRenderState and setRenderObject
void ErrorRenderLoop::setTransforms(float *M)
{
// transform
float P[16];
float V[16];
float VP[16];
// projection
buildProjection(P, -1.0f, 1.0f, -1.0f, 1.0f, 1.0, 10000.0f);
// 16:9 scale or 4:3 scale
matrixTranslate(V, 0.0f, 0.0f, -4.0);
V[0*4 + 0] = 1.0f / display_aspect_ratio;
V[1*4 + 1] = 1.0f;
// model view
matrixMul(VP, P, V);
matrixMul(MVP, VP, M);
cellGcmSetVertexProgramParameter(model_view_projection, MVP);
}
int32_t ErrorRenderLoop::setRenderObject(void)
{
void *ret = localMemoryAlign(128, sizeof(Vertex_t) * ARRAYSIZE( g_verts_polySurfaceShape1 ) );
m_pVertexBuffer = (Vertex_t*)ret;
memcpy( m_pVertexBuffer, g_verts_polySurfaceShape1, sizeof( g_verts_polySurfaceShape1 ) );
m_pIndexBuffer = (uint16_t *)localMemoryAlign( 128, sizeof( uint16_t ) * ARRAYSIZE( g_tris_polySurfaceShape1 ) * 3 );
memcpy( m_pIndexBuffer, g_tris_polySurfaceShape1, sizeof( g_tris_polySurfaceShape1 ) );
model_view_projection = cellGcmCgGetNamedParameter(vertex_program, "modelViewProj");
CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(model_view_projection);
CGparameter position = cellGcmCgGetNamedParameter(vertex_program, "position");
CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(position);
CGparameter normal = cellGcmCgGetNamedParameter(vertex_program, "normal");
CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(normal);
CGparameter color = cellGcmCgGetNamedParameter(vertex_program, "color");
CELL_GCMUTIL_CG_PARAMETER_CHECK_ASSERT(color);
// get Vertex Attribute index
position_index = cellGcmCgGetParameterResource(vertex_program, position) - CG_ATTR0;
normal_index = cellGcmCgGetParameterResource(vertex_program, normal) - CG_ATTR0;
color_index = cellGcmCgGetParameterResource(vertex_program, color) - CG_ATTR0;
// fragment program offset
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(fragment_program_ucode, &fragment_offset));
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(&m_pVertexBuffer->x, &m_nVertPositionOffset));
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(&m_pVertexBuffer->nx, &m_nVertNormalOffset));
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(&m_pVertexBuffer->rgba, &m_nVertColorOffset));
CELL_GCMUTIL_CHECK_ASSERT(cellGcmAddressToOffset(m_pIndexBuffer, &m_nIndexBufferLocalMemoryOffset));
return 0;
}
const uint32_t g_nInitCmdBuffer = 0x1000;
int32_t SimpleContextCallback( struct CellGcmContextData *pData, uint32_t nSize )
{
*pData->current = CELL_GCM_JUMP( g_nInitCmdBuffer );
__sync();
CellGcmControl * pControlRegister = cellGcmGetControlRegister();
pControlRegister->put = g_nInitCmdBuffer;
do
{
sys_timer_usleep( 60 );
} while ( pControlRegister->get != g_nInitCmdBuffer );
pData->current = pData->begin;
return CELL_OK;
}
int ErrorRenderLoop::Run( void )
{
// Exit routines
{
// register sysutil exit callback
CELL_GCMUTIL_CHECK_ASSERT( cellSysutilRegisterCallback( 0, sysutil_exit_callback, this ) );
CELL_GCMUTIL_CHECK_ASSERT( cellSysutilCheckCallback() );
if ( !m_keepRunning )
return 0;
}
if( g_gcmSharedData.m_pIoMemory )
{
// GCM has already been initialized, no need to reinitialize it.
// But we have to drive RSX to our new command buffer
const uint32_t nCmdBufferOverfetchSlack = 1024;
//printf( "Entering Error Render Loop, reusing IO memory @%p size 0x%X; initial ctx={%p,%p,%p;fn=%p}\n", g_gcmSharedData.m_pIoMemory, g_gcmSharedData.m_nIoMemorySize, gCellGcmCurrentContext->begin, gCellGcmCurrentContext->current, gCellGcmCurrentContext->end, gCellGcmCurrentContext->callback );
cellGcmSetCurrentBuffer(
// start command buffer right after initialization fixed command buffer (always the first 4 k of IO memory)
( uint32_t* )( uint32_t( g_gcmSharedData.m_pIoMemory ) + g_nInitCmdBuffer ),
// the size is all of IO memory, minus initialization command buffer, minus overfetch amount in the end of command buffer to avoid a crash,
// minus 4 bytes to insert a JUMP to the start of command buffer when we run out of space
g_gcmSharedData.m_nIoMemorySize - nCmdBufferOverfetchSlack - g_nInitCmdBuffer - sizeof( uint32_t ) );
CellGcmContextData *pCurrentContext = gCellGcmCurrentContext;
pCurrentContext->callback = SimpleContextCallback;
CellGcmControl * pControlRegister = cellGcmGetControlRegister();
uint32_t nPut = pControlRegister->put;
uint32_t * pCurrentCmd = ( uint32_t* )( uint32_t( g_gcmSharedData.m_pIoMemory ) + nPut );
pCurrentContext->current = pCurrentCmd; // de facto current
// #ifndef _CERT
// if ( pControlRegister->put != g_nInitCmdBuffer || gCellGcmCurrentContext->current != ( uint32_t* )( uint32_t( g_gcmSharedData.m_pIoMemory ) + g_nInitCmdBuffer ) )
// {
// __builtin_snpause();
// }
// #endif
}
else
{
sys_addr_t allocatedAddress = NULL;
int smaResult = sys_memory_allocate( 1 * 1024 * 1024, SYS_MEMORY_PAGE_SIZE_1M, &allocatedAddress );
if( smaResult != CELL_OK )
return smaResult;
void* host_addr = (void*)allocatedAddress;
printf( "Entering Error Render loop, IO memory @%p...\n", host_addr );
CELL_GCMUTIL_ASSERT(host_addr != NULL);
CELL_GCMUTIL_CHECK_ASSERT(cellGcmInit(CB_SIZE, HOST_SIZE, host_addr));
}
if (initDisplay()!=0) return -1;
initShader();
setDrawEnv();
if (setRenderObject())
return -1;
setRenderState();
// 1st time
setRenderTarget(frame_index);
// rendering loop
CELL_GCMUTIL_ASSERT(m_keepRunning);
float flTime = 0;
uint32_t nFrames = 0;
while (m_keepRunning) {
// check system event
CELL_GCMUTIL_CHECK_ASSERT( cellSysutilCheckCallback() );
// clear frame buffer
cellGcmSetClearSurface(
CELL_GCM_CLEAR_Z |
CELL_GCM_CLEAR_R |
CELL_GCM_CLEAR_G |
CELL_GCM_CLEAR_B |
CELL_GCM_CLEAR_A
);
float tm[16];
AngleMatrix(0.1f * sinf( flTime * 0.5f ), 0.5f * sinf( flTime * 0.45f ), 0.1f * sinf( flTime*0.02f ), tm);
setTransforms(tm);
// set draw command
if( flTime > 4.0f )
{
cellGcmSetDrawIndexArray(CELL_GCM_PRIMITIVE_TRIANGLES, 3 * ARRAYSIZE( g_tris_polySurfaceShape1 ), CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16, CELL_GCM_LOCATION_LOCAL, m_nIndexBufferLocalMemoryOffset );
}
// start reading the command buffer
flip();
flTime += 1/60.0f;
nFrames ++;
}
printf( "Exiting Error Render loop, %u frames rendered", nFrames );
cellSysutilUnregisterCallback( 0 );
// Let RSX wait for final flip
cellGcmSetWaitFlip();
// Let PPU wait for all commands done (include waitFlip)
cellGcmFinish(1);
// let's just leak this memory to avoid problems due to initializing GCM in different places, it doesn't matter
//sys_memory_free( g_gcmSharedData.m_pIoMemory );
printf(".\n");
return 0;
}
void sysutil_exit_callback(uint64_t status, uint64_t param, void* userdata)
{
(void) param;
(void) userdata;
switch(status) {
case CELL_SYSUTIL_REQUEST_EXITGAME:
((ErrorRenderLoop*)userdata)->m_keepRunning = false;
break;
case CELL_SYSUTIL_DRAWING_BEGIN:
case CELL_SYSUTIL_DRAWING_END:
case CELL_SYSUTIL_SYSTEM_MENU_OPEN:
case CELL_SYSUTIL_SYSTEM_MENU_CLOSE:
case CELL_SYSUTIL_BGMPLAYBACK_PLAY:
case CELL_SYSUTIL_BGMPLAYBACK_STOP:
default:
break;
}
}

View File

@ -0,0 +1,87 @@
//========= Copyright 2010, Valve Corporation, All rights reserved. ============//
#ifndef ERRORRENDERLOOP_HDR
#define ERRORRENDERLOOP_HDR
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/timer.h>
#include <sys/return_code.h>
#include <cell/gcm.h>
#include <stddef.h>
#include <math.h>
#include <sys/memory.h>
#include <sysutil/sysutil_sysparam.h>
#include "ps3/ps3_helpers.h"
class ErrorRenderLoop
{
public:
typedef struct
{
float x, y, z;
float nx, ny, nz;
uint32_t rgba;
} Vertex_t;
ErrorRenderLoop();
int Run( void );
protected:
void *localMemoryAlloc(const uint32_t size) ;
void *localMemoryAlign(const uint32_t alignment,
const uint32_t size);
void setRenderState(void);
void setDrawEnv(void);
int32_t setRenderObject(void);
int32_t initDisplay(void);
void initShader(void);
void setRenderTarget(const uint32_t Index);
void flip(void);
void setVertex(Vertex_t* vertex_buffer);
void setTransforms(float *tm);
public:
/* double buffering */
enum ConstEnum_t{ COLOR_BUFFER_NUM = 2, HOST_SIZE = (1*1024*1024) };
bool m_keepRunning;
uint32_t m_nLocalMemHeap;
uint32_t display_width;
uint32_t display_height;
float display_aspect_ratio;
uint32_t color_pitch;
uint32_t depth_pitch;
uint32_t color_offset[COLOR_BUFFER_NUM];
uint32_t depth_offset;
uint32_t frame_index;
unsigned char *vertex_program_ptr;
unsigned char *fragment_program_ptr;
CGprogram vertex_program;
CGprogram fragment_program;
CGparameter model_view_projection;
void *vertex_program_ucode;
void *fragment_program_ucode;
uint32_t fragment_offset;
uint32_t m_nVertPositionOffset, m_nVertNormalOffset, m_nVertColorOffset, m_nIndexBufferLocalMemoryOffset;
uint32_t color_index ;
uint32_t position_index ;
uint32_t normal_index;
float MVP[16];
Vertex_t *m_pVertexBuffer;
uint16_t *m_pIndexBuffer;
};
extern PS3_GcmSharedData g_gcmSharedData;
#endif

View File

@ -0,0 +1,16 @@
/* SCE CONFIDENTIAL */
/* PlayStation(R)3 Programmer Tool Runtime Library 350.001 */
/* Copyright (C) 2006 Sony Computer Entertainment Inc. */
/* All Rights Reserved. */
void main
(
float4 color_in : COLOR,
float4 normal_in : TEX0,
out float4 color_out : COLOR
)
{
color_out = color_in * max( 0.15, 0.15 + ( dot( normalize( normal_in ), float4( 0.577,0.577,-0.577,0 ) ) ) )
//+ float4( 0.2 * abs( normal_in.xyz ), 0 )
;
}

View File

@ -0,0 +1,24 @@
/* SCE CONFIDENTIAL */
/* PlayStation(R)3 Programmer Tool Runtime Library 350.001 */
/* Copyright (C) 2006 Sony Computer Entertainment Inc. */
/* All Rights Reserved. */
void main
(
float3 position : POSITION,
float3 normal : NORMAL,
float4 color : COLOR,
uniform float4x4 modelViewProj,
out float4 oPosition : POSITION0,
out float4 oNormal : TEX0,
out float4 oColor : COLOR
)
{
oPosition = mul(modelViewProj, float4( position, 1 ) );
oNormal = mul(modelViewProj, float4( normal, 0 ) );
oColor = color;
}

BIN
launcher_main/excl.mb Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,72 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_LAUNCHER ICON DISCARDABLE "..\\launcher\\res\\launcher.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,179 @@
//-----------------------------------------------------------------------------
// LAUNCHER_MAIN.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$Macro SRCDIR ".."
$Macro OUTBINDIR "$SRCDIR\..\game"
// Must be built explicitly as "default" in order to build a compliant submittable Disc.
// Renames will not work.
$Macro OUTBINNAME "default"
$Macro OUTBINNAME "csgo" [$WIN32]
$Macro OUTBINNAME "csgo_win64" [$WIN64]
$Macro OUTBINNAME "csgo_osx" [$OSX32]
$Macro OUTBINNAME "csgo_osx64" [$OSX64]
$Macro OUTBINNAME "csgo_linux" [$LINUX32]
$Macro OUTBINNAME "csgo_linux64" [$LINUX64]
$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Macro DEMOSUFFIX "_demo\" [$DEMO]
$MacroEmptyString DEMOSUFFIX "empty" [!$DEMO]
$Macro "PS3MEMOVERRIDE" "--wrap=abort --wrap=malloc --wrap=calloc --wrap=memalign --wrap=realloc --wrap=reallocalign --wrap=malloc_usable_size --wrap=malloc_stats --wrap=free"
$CustomBuildStep "fp"
{
$CommandLine "$(SCE_PS3_ROOT)\host-win32\Cg\bin\sce-cgc -quiet -profile sce_fp_rsx -o &quot;$(InputName).fpo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;$(SCE_PS3_ROOT)\host-win32\ppu\bin\ppu-lv2-objcopy -I binary -O elf64-powerpc-celloslv2 -B powerpc &quot;$(InputName).fpo&quot; &quot;$(IntDir)\$(InputName).fp.ppu.o&quot;"
$Description "Fragment Program $(InputFileName) produces $(InputName).fpo produces $(InputName).fp.ppu.o"
$Outputs "$(InputName).fpo;$(IntDir)\$(InputName).fp.ppu.o"
}
$CustomBuildStep "vp"
{
$CommandLine "$(SCE_PS3_ROOT)\host-win32\Cg\bin\sce-cgc -quiet -profile sce_vp_rsx -o &quot;$(InputName).vpo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;$(SCE_PS3_ROOT)\host-win32\ppu\bin\ppu-lv2-objcopy -I binary -O elf64-powerpc-celloslv2 -B powerpc &quot;$(InputName).vpo&quot; &quot;$(IntDir)\$(InputName).vp.ppu.o&quot;"
$Description "Vertex Program $(InputFileName) produces $(InputName).vpo produces $(InputName).vp.ppu.o"
$Outputs "$(InputName).vpo;$(IntDir)\$(InputName).vp.ppu.o"
}
$Configuration
{
$Compiler
{
$ForceIncludes " "
$PreprocessorDefinitions "$BASE;RATINGSBUILD" [$RATINGSBUILD]
}
$Compiler [$PS3 && !$CERT]
{
$ForcedUsingFiles "?DbgSaveProj&#x0D;?DbgElfArgs=-dev -game csgo&#x0D;?FileServDir=$(SolutionDir)..&#x0D;?HomeDir=$(SolutionDir).."
$AdditionalIncludeDirectories "$BASE;&quot;$(SN_PS3_PATH)/ppu/include&quot;"
}
$Linker [$WIN32]
{
$EnableLargeAddresses "Support Addresses Larger Than 2 Gigabytes (/LARGEADDRESSAWARE)"
$FixedBaseAddress "Generate a relocation section (/FIXED:NO)"
}
$SNCLinker [$PS3]
{
// General
$AdditionalDependencies "$BASE libsysutil_game_stub.a libsysutil_stub.a"
// Command Line
$AdditionalOptions "$BASE $PS3MEMOVERRIDE"
}
$Compiler [$PS3]
{
$PreprocessorDefinitions "$BASE;PS3MEMOVERRIDEWRAP;PS3MAINELF"
$AdditionalIncludeDirectories "$BASE;$SRCDIR\common;$SRCDIR\public"
}
$Xbox360ImageConversion [$X360]
{
// General
$AdditionalSections "5841125A=$SRCDIR\common\xlast_$VPCGAME\$VPCGAME.spa"
$ProjectDefaults "$SRCDIR\common\xlast_$VPCGAME$DEMOSUFFIX\$VPCGAME.xml"
}
$ConsoleDeployment [$X360]
{
$DeploymentRoot "xe:\$VPCGAME$DEMOSUFFIX"
}
$PreBuildEvent [$WINDOWS]
{
$CommandLine "if EXIST $OUTBINDIR\$OUTBINNAME.exe for /f $QUOTEdelims=$QUOTE %%A in ('attrib $QUOTE$OUTBINDIR\$OUTBINNAME.exe$QUOTE') do set valveTmpIsReadOnly=$QUOTE%%A$QUOTE" "\n" \
"set valveTmpIsReadOnlyLetter=%valveTmpIsReadOnly:~6,1%" "\n" \
"if $QUOTE%valveTmpIsReadOnlyLetter%$QUOTE==$QUOTER$QUOTE del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n"
}
$PreLinkEvent [$PS3]
{
$CommandLine "call .\$(IntDir)\errorshader.vp.bat" "\n" \
"call .\$(IntDir)\errorshader.fp.bat" "\n"
}
$PostBuildEvent [$X360]
{
// inherit and add
$CommandLine "$BASE" \
"call $SRCDIR\vpc_scripts\valve_xbcp_wrapper.cmd $(TargetDir)$(TargetName).xex xE:\$VPCGAME$DEMOSUFFIX\default.xex" "\n"
}
$PostBuildEvent [$WINDOWS]
{
// override with specific behavior
$CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$OUTBINNAME.exe $SRCDIR" "\n" \
"call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$OUTBINNAME.pdb $SRCDIR" "\n" \
"copy $(TargetPath) $OUTBINDIR\$OUTBINNAME.exe" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
"if exist $(TargetDir)$(TargetName).map copy $(TargetDir)$(TargetName).map $OUTBINDIR\$OUTBINNAME.map" "\n" \
"if exist $(TargetDir)$(TargetName).pdb copy $(TargetDir)$(TargetName).pdb $OUTBINDIR\$OUTBINNAME.pdb" "\n" \
"call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$OUTBINNAME.dat $SRCDIR" "\n" \
"$OUTBINDIR\bin\newdat $OUTBINDIR\$OUTBINNAME.exe" "\n" \
"goto BuildEventOK" "\n" \
":BuildEventFailed" "\n" \
"echo *** ERROR! PostBuildStep FAILED for $(ProjectName)! EXE or DLL is probably running. ***" "\n" \
"del /q $(TargetPath)" "\n" \
"exit 1" "\n" \
":BuildEventOK" "\n"
$Description "Publishing to $OUTBINDIR"
$ExcludedFromBuild "No"
}
$Linker [$PS3]
{
$AdditionalDependencies "$BASE &quot;$(SN_PS3_PATH)/ppu/lib/sn/libsn.a&quot; &quot;$(SN_PS3_PATH)/ppu/lib/sn/libsntuner.a&quot;"
}
}
$Project
{
$Folder "Source Files"
{
-$File "$SRCDIR\public\tier0\memoverride.cpp" [!$PS3]
}
$Folder "Link Libraries"
{
-$File "$LIBPUBLIC\tier0.lib" [$WINDOWS||$LINUX]
-$File "$LIBPUBLIC\tier1.lib" [$WINDOWS||$LINUX]
-$File "$LIBPUBLIC\vstdlib.lib" [$WINDOWS||$LINUX]
-$File "$LIBPUBLIC\$_IMPLIB_PREFIXtier0$_IMPLIB_EXT" [$POSIX]
-$File "$LIBPUBLIC\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [$POSIX]
-$File "$LIBPUBLIC\tier1$_IMPLIB_EXT" [$POSIX]
-$File "$LIBPUBLIC\tier0_360.lib" [$X360]
-$File "$LIBPUBLIC\tier1_360.lib" [$X360]
-$File "$LIBPUBLIC\vstdlib_360.lib" [$X360]
}
}
$Project "launcher_main"
{
$Folder "Source Files"
{
$File "$SRCDIR\public\ps3_pathinfo.h"
$File "main.cpp"
$File "errorrenderloop.cpp" [$PS3]
$File "errorrenderloop.h" [$PS3]
$File "errorshader.vp" [$PS3]
$File "errorshader.fp" [$PS3]
$File "ps3_pathinfo.cpp" [$PS3]
}
$Folder "Resources" [$WINDOWS]
{
$File "launcher_main.rc"
$File "$SRCDIR\launcher\res\launcher.ico"
}
}

View File

@ -0,0 +1,13 @@
"vpc_cache"
{
"CacheVersion" "1"
"win32"
{
"CRCFile" "launcher_main.vcxproj.vpc_crc"
"OutputFiles"
{
"0" "launcher_main.vcxproj"
"1" "launcher_main.vcxproj.filters"
}
}
}

985
launcher_main/main.cpp Normal file
View File

@ -0,0 +1,985 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: A redirection tool that allows the DLLs to reside elsewhere.
//
//=====================================================================================//
#if defined( _WIN32 ) && !defined( _X360 )
#include <windows.h>
#include <stdio.h>
#include <assert.h>
#include <direct.h>
#endif
#if defined( _X360 )
#define _XBOX
#include <xtl.h>
#include <xbdm.h>
#undef _XBOX
#include <stdio.h>
#include <assert.h>
#include "xbox\xbox_core.h"
#include "xbox\xbox_launch.h"
#elif defined( SN_TARGET_PS3 )
#include "../public/ps3_pathinfo.h"
#include <stddef.h>
#include <cell/fios/fios_common.h>
#include <cell/fios/fios_memory.h>
#include <cell/fios/fios_configuration.h>
#include <cell/fios/fios_time.h>
#include <sys/tty.h>
#include <sys/ppu_thread.h>
#include "tier0/vprof_sn.h"
#include "errorrenderloop.h"
//#if defined( VPROF_SN_LEVEL )
#include "sn/libsntuner.h"
#include "libsn.h"
//#endif
#endif
#ifdef POSIX
#include <stdio.h>
#include <stdlib.h>
#ifndef SN_TARGET_PS3
#include <dlfcn.h>
#endif // SN_TARGET_PS3
#include <limits.h>
#include <string.h>
#define MAX_PATH PATH_MAX
#endif
#include "tier0/platform.h"
#include "tier0/basetypes.h"
#if defined( VPCGAME )
#define _VPCGAME_STRING_HACK2(x) #x
#define _VPCGAME_STRING_HACK1(x) _VPCGAME_STRING_HACK2(x)
#define VPCGAME_STRING _VPCGAME_STRING_HACK1(VPCGAME)
#endif
#ifdef WIN32
typedef int (*LauncherMain_t)( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow );
#elif POSIX
typedef int (*LauncherMain_t)( int argc, char **argv );
#else
#error
#endif
#ifdef WIN32
// hinting the nvidia driver to use the dedicated graphics card in an optimus configuration
// for more info, see: http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
extern "C" { _declspec( dllexport ) DWORD NvOptimusEnablement = 0x00000001; }
// same thing for AMD GPUs using v13.35 or newer drivers
extern "C" { __declspec( dllexport ) int AmdPowerXpressRequestHighPerformance = 1; }
#endif
//-----------------------------------------------------------------------------
// Purpose: Return the directory where this .exe is running from
// Output : char
//-----------------------------------------------------------------------------
#if !defined( _X360 )
#ifdef WIN32
static char *GetBaseDir( const char *pszBuffer )
{
static char basedir[ MAX_PATH ];
char szBuffer[ MAX_PATH ];
size_t j;
char *pBuffer = NULL;
strcpy( szBuffer, pszBuffer );
pBuffer = strrchr( szBuffer,'\\' );
if ( pBuffer )
{
*(pBuffer+1) = '\0';
}
strcpy( basedir, szBuffer );
j = strlen( basedir );
if (j > 0)
{
if ( ( basedir[ j-1 ] == '\\' ) ||
( basedir[ j-1 ] == '/' ) )
{
basedir[ j-1 ] = 0;
}
}
return basedir;
}
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
// Must add 'bin' to the path....
char* pPath = getenv("PATH");
// Use the .EXE name to determine the root directory
char moduleName[ MAX_PATH ];
char szBuffer[4096];
if ( !GetModuleFileName( hInstance, moduleName, MAX_PATH ) )
{
MessageBox( 0, "Failed calling GetModuleFileName", "Launcher Error", MB_OK );
return 0;
}
// Get the root directory the .exe is in
char* pRootDir = GetBaseDir( moduleName );
const char* pBinPath =
#ifdef _WIN64
"\\x64"
#else
""
#endif
;
#ifdef _DEBUG
int len =
#endif
_snprintf( szBuffer, sizeof( szBuffer ), "PATH=%s\\bin%s\\;%s", pRootDir, pBinPath, pPath );
szBuffer[sizeof( szBuffer ) - 1] = '\0';
assert( len < sizeof( szBuffer ) );
_putenv( szBuffer );
// Assemble the full path to our "launcher.dll"
_snprintf( szBuffer, sizeof( szBuffer ), "%s\\bin%s\\launcher.dll", pRootDir, pBinPath );
szBuffer[sizeof( szBuffer ) - 1] = '\0';
// STEAM OK ... filesystem not mounted yet
#if defined(_X360)
HINSTANCE launcher = LoadLibrary( szBuffer );
#else
HINSTANCE launcher = LoadLibraryEx( szBuffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
#endif
if ( !launcher )
{
char *pszError;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&pszError, 0, NULL);
char szBuf[1024];
_snprintf(szBuf, sizeof( szBuf ), "Failed to load the launcher DLL:\n\n%s", pszError);
szBuf[sizeof( szBuf ) - 1] = '\0';
MessageBox( 0, szBuf, "Launcher Error", MB_OK );
LocalFree(pszError);
return 0;
}
LauncherMain_t main = (LauncherMain_t)GetProcAddress( launcher, "LauncherMain" );
return main( hInstance, hPrevInstance, lpCmdLine, nCmdShow );
}
#elif defined( SN_TARGET_PS3 )
#if defined( __GCC__ )
#define COMPILER_GCC
#elif defined( __SNC__ )
#define COMPILER_SNC
#endif
#include "../public/tls_ps3.h"
#include "sys/process.h"
// We need to avoid printf before we
// configure our custom memory allocator
#define printf(...) ((void)0)
#include "../common/ps3/ps3_helpers.h"
#ifdef APPCHANGELISTVERSION
// write the changelist number into the executable so that the GUID changes between builds.
// previously, setting the version number via the SYS_MODULE_INFO was good enough to do
// this, but not after sdk 350.
volatile unsigned int clnumber = APPCHANGELISTVERSION;
__attribute__ ((noinline)) void DummyFuncForUpdatingGUIDs( char *pOut )
{
sprintf( pOut, "%x", clnumber );
}
#else // absent appchangelistversion, invent one
volatile unsigned int clnumber = 0;
#define DUMMY_VER_STRING __DATE__ " " __TIME__
volatile char dummyVersionDateString[] = DUMMY_VER_STRING "\n";
__attribute__ ((noinline)) void DummyFuncForUpdatingGUIDs( char *pOut )
{
sprintf( pOut, DUMMY_VER_STRING );
}
#undef DUMMY_VER_STRING
#endif
// 1 Mb stack is maximum allowed for the main thread
// and we will make good use of it
SYS_PROCESS_PARAM( 1000, 1 * 1024 * 1024 )
/////////////////////////////////////////////////////////////////////////////////////////////////////
// All thread-local storage must reside in the ELF and be exported for PRXes to use it
/////////////////////////////////////////////////////////////////////////////////////////////////////
__thread TLSGlobals gTLSGlobals =
{
// TLS values/flags
/*nThreadLocalStateIndex*/ 0,
/*TLSValues*/ { NULL },
/*TLSFlags*/ { false },
/*bWaitObjectsCreated*/ false,
/*WaitObjectsSemaphore*/ 0,
/*pCurThread*/ NULL,
/*nThreadID*/ 0,
// Engine TLS data (zip/console/splitslot)
/*uiEngineZipLastErrorZ*/ 0,
/*bEngineConsoleIsInSpew*/ false,
/*pEngineSplitSlot*/ NULL,
// Malloc debugging TLS data
/*pMallocDbgInfoStack*/ NULL,
/*nMallocDbgInfoStackDepth*/ 0,
// Filesystem read filename buffer
/*pFileSystemReadFilename*/ NULL,
// Material system render context
/*pMaterialSystemRenderContext*/ NULL,
// Physics virtual mesh frame locks
/*pPhysicsVirtualMeshFrameLocks*/ NULL,
/*bNormalQuitRequested*/ false
};
TLSGlobals *GetTLSGlobals_ELF() { return &gTLSGlobals; }
extern CPs3ContentPathInfo g_Ps3GameDataPathInfo;
template< typename BaseStruct >
struct PS3MainParameters : public BaseStruct
{
PS3MainParameters() { memset( this, 0, sizeof( BaseStruct ) ); BaseStruct::cbSize = sizeof( BaseStruct ); }
};
struct PS3_Launch_t
{
explicit PS3_Launch_t( char const *szPrxName, PS3_PrxLoadParametersBase_t *pParams ) :
m_szPrxName( szPrxName ), m_pPrxParams( pParams )
{
m_iResult = PS3_PrxLoad( m_szPrxName, m_pPrxParams );
if ( m_iResult < CELL_OK )
{
printf( "ERROR: %s PRX load failed: 0x%08x\n", m_szPrxName, m_iResult );
}
else
{
printf( "Loaded: %s (0x%08x)\n", m_szPrxName, m_iResult );
}
}
char const *m_szPrxName;
PS3_PrxLoadParametersBase_t *m_pPrxParams;
int m_iResult;
};
static const char *LauncherMainSPRXPath( const char *modulename, char *buf, int buflen = CELL_GAME_PATH_MAX ) // formats a path to the module. returns a pointer to the buf param for convenience.
{
snprintf( buf, buflen, "%s/%s" DLL_EXT_STRING, g_Ps3GameDataPathInfo.PrxPath(), modulename );
return buf;
}
#if defined( SN_TARGET_PS3 )
void TunerMarkerPush( const char * pName )
{
//#if defined( VPROF_SN_LEVEL )
snPushMarker( pName );
//#endif
}
void TunerMarkerPop()
{
//#if defined( VPROF_SN_LEVEL )
snPopMarker();
//#endif
}
// this is debug-only counter; never use it for anything other than debugging!
uint64_t g_nDebugSwapBufferCount = 0;
void TunerSwapBufferMarker()
{
// this dummy function is only required as a patch-through for Tuner that attaches to the game after the game has been started, as a convenience funciton/
// it must be called at every frame boundary (presumably at/after psglSwap )
g_nDebugSwapBufferCount++;
}
#endif
PS3_PrxModuleEntry_t *g_pPrxModulesList = NULL;
PS3_PrxModuleEntry_t ** PS3_PrxGetModulesList() { return &g_pPrxModulesList; }
void TestThreadProc( uint64_t id )
{
printf( "Hello from PPU thread %lld\n", id );
sys_ppu_thread_exit( id );
}
void TestThreads( int nLevel = 0)
{
printf("testing threads\n");
const int numThreads = 20;
sys_ppu_thread_t id[numThreads];
for( int i = 0;i < numThreads; ++i )
{
if( nLevel > 0 )
TestThreads( nLevel - 1 );
if( CELL_OK != sys_ppu_thread_create( &id[i], TestThreadProc, i, 1001, 64*1024, SYS_PPU_THREAD_CREATE_JOINABLE, "SimpleThread" ) )
{
printf("ERROR: cannot create thread\n");
return;
}
}
for( int i = 0;i < numThreads; ++i )
{
uint64_t res;
sys_ppu_thread_join( id[i], &res );
if( res != i )
{
printf("ERROR: invalid thread return value\n");
return;
}
}
}
int MainImpl( int argc, char *argv[] )
{
// #ifdef _CERT // possibly enable it for ship to disable command line cheating?
#if 0
// Disable command line support for shipping unless -certcmdline specified
if ( ( argc > 1 ) && !strcmp( argv[1], "-certcmdline" ) )
{
argc = 1;
}
#endif
// this is the very first timing message, before tier0 is even initialized and we can use any
// logging or timing facilities; this is the baseline to measure loading times
cell::fios::abstime_t fiosLaunchTime = cell::fios::FIOSGetCurrentTime();
#ifndef _CERT
{
double flTime = cell::fios::FIOSAbstimeToMicroseconds( fiosLaunchTime ) * 1e-6;
char buffer[4096];
int nMessageSize = snprintf(buffer, sizeof(buffer), "--------------------------------------\n 0.0000 / %8.4f : launcher_main(", flTime );
for( int i = 0;i < argc && nMessageSize < sizeof(buffer)-4; ++i )
{
// add delimiters
if( i > 0 )
buffer[nMessageSize++] = ',';
nMessageSize += snprintf( buffer + nMessageSize, sizeof(buffer) - nMessageSize, " \"%s\"", argv[i] );
}
nMessageSize += snprintf(buffer + nMessageSize, sizeof(buffer) - nMessageSize, " )\n" );
unsigned wrote;
sys_tty_write( SYS_TTYP6, buffer, nMessageSize, &wrote );
}
#endif
// this is a dummy operation to force the compiler to not elide the
// changelist GUID. It's really necessary, because otherwise the compiler
// will notice the function isn't called, and elide it, and the GUID string,
// altogether. Because the compiler "can't" know what argc will be, it has
// to compile in the function call here. This is the only way to guarantee
// that different builds will have different GUIDs, because we don't often
// change launcher_main between versions, and the PRXes don't get individual
// GUIDs in the dump.
// Don't pass in more than one million commandline
// parameters or this will corrupt the one millionth.
if ( argc > 100000000 )
{
DummyFuncForUpdatingGUIDs( argv[100000000] );
}
char path[CELL_GAME_PATH_MAX];
bool bDevHddCfgOnly = false;
bool bRunLauncherMain = true;
bool bSupportPathLegacyArgs = true;
bool bEnableMlaa = true;
#ifdef HDD_BOOT
unsigned int uiInitFlags = CPs3ContentPathInfo::INIT_PRX_ON_HDD | CPs3ContentPathInfo::INIT_IMAGE_ON_HDD;
#else
unsigned int uiInitFlags = CPs3ContentPathInfo::INIT_RETAIL_MODE; // assume that if no arguments are specified we are going to run in retail mode
#endif
// uncomment the following in order to allow starting game in /app_home from XMB (shortcutting creating disk image)
// uiInitFlags = CPs3ContentPathInfo::INIT_PRX_APP_HOME | CPs3ContentPathInfo::INIT_IMAGE_APP_HOME;
for ( int k = 0; k < argc; ++ k )
{
if( !strcmp( "-noMlaa", argv[k] ) )
{
bEnableMlaa = false;
}
else if ( !strcmp( "-errorrenderloop", argv[k] ) )
{
return -1;
}
else if ( !strcmp( "-devhddcfgonly", argv[k] ) )
{
bDevHddCfgOnly = true;
}
else if ( !strcmp( "-nolaunchermain", argv[k] ) )
{
bRunLauncherMain = false;
}
else if ( !strcmp( "-syscacheclear", argv[k] ) )
{
uiInitFlags |= CPs3ContentPathInfo::INIT_SYS_CACHE_CLEAR;
}
else if ( !strncmp( "-path_retail", argv[k], 12 ) )
{
bSupportPathLegacyArgs = false;
if ( argv[k][12] )
uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
}
else if ( !strncmp( "-path_prx_", argv[k], 10 ) )
{
char chPrxPathMode = argv[k][10];
switch ( chPrxPathMode )
{
case 'h': uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_ON_HDD; break;
case 'b': uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_ON_BDVD; break;
case 'a': uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_APP_HOME; break;
}
}
else if ( !strncmp( "-path_img_", argv[k], 10 ) )
{
char chPrxPathMode = argv[k][10];
switch ( chPrxPathMode )
{
case 'h': uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_ON_HDD; break;
case 'b': uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_ON_BDVD; break;
case 'a': uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_APP_HOME; break;
}
}
// LEGACY PARAMETERS because people are used to running with them (need to clean up some time later)
else if ( bSupportPathLegacyArgs && !strcmp( "-dev", argv[k] ) )
{
uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_APP_HOME;
uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_APP_HOME;
}
else if ( bSupportPathLegacyArgs && !strcmp( "-ps3hd", argv[k] ) )
{
uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_ON_HDD;
uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_APP_HOME;
}
else if ( bSupportPathLegacyArgs && !strcmp( "-nops3hd", argv[k] ) )
{
uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_APP_HOME;
uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_APP_HOME;
}
else if ( bSupportPathLegacyArgs && !strcmp( "-dev_bdvd", argv[k] ) )
{
uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
uiInitFlags |= CPs3ContentPathInfo::INIT_IMAGE_ON_BDVD;
uiInitFlags |= CPs3ContentPathInfo::INIT_PRX_APP_HOME;
}
// END LEGACY PARAMETERS
}
// uncomment the following to hard code for Eurogamer (as if running -dev)
#ifdef _PS3
// uiInitFlags &=~CPs3ContentPathInfo::INIT_RETAIL_MODE;
#endif
int iPathInfoInitResult = g_Ps3GameDataPathInfo.Init( uiInitFlags );
if ( iPathInfoInitResult < 0 )
return iPathInfoInitResult;
if ( bDevHddCfgOnly )
return 0;
PS3MainParameters< PS3_LoadTier0_Parameters_t > tier0;
tier0.pfnGetTlsGlobals = GetTLSGlobals_ELF;
tier0.pPS3PathInfo = &g_Ps3GameDataPathInfo;
tier0.fiosLaunchTime = fiosLaunchTime;
tier0.nCLNumber = clnumber;
tier0.pfnPushMarker = TunerMarkerPush;
tier0.pfnPopMarker = TunerMarkerPop;
tier0.pfnSwapBufferMarker = TunerSwapBufferMarker;
tier0.ppPrxModulesList = PS3_PrxGetModulesList();
tier0.m_pGcmSharedData = &g_gcmSharedData;
#ifndef _CERT
tier0.snRawSPULockHandler = snRawSPULockHandler;
tier0.snRawSPUUnlockHandler = snRawSPUUnlockHandler;
tier0.snRawSPUNotifyCreation = snRawSPUNotifyCreation;
tier0.snRawSPUNotifyDestruction = snRawSPUNotifyDestruction;
tier0.snRawSPUNotifyElfLoad = snRawSPUNotifyElfLoad;
tier0.snRawSPUNotifyElfLoadNoWait = snRawSPUNotifyElfLoadNoWait;
tier0.snRawSPUNotifyElfLoadAbs = snRawSPUNotifyElfLoadAbs;
tier0.snRawSPUNotifyElfLoadAbsNoWait = snRawSPUNotifyElfLoadAbsNoWait;
tier0.snRawSPUNotifySPUStopped = snRawSPUNotifySPUStopped;
tier0.snRawSPUNotifySPUStarted = snRawSPUNotifySPUStarted;
#endif
(void)bEnableMlaa; // we'll use it if we need to init GCM and start rendering right away
/*
g_gcmSharedData.m_nIoMemorySize = bEnableMlaa ? 5 * 1024 * 1024 : 1 * 1024 * 1024;
sys_addr_t pIoAddress = NULL;
int nError = sys_memory_allocate( g_gcmSharedData.m_nIoMemorySize, SYS_MEMORY_PAGE_SIZE_1M, &pIoAddress );
if( CELL_OK != nError || !pIoAddress )
{
// cannot allocate IO memory
return -2;
}
int32 result = cellGcmInit( m_nCmdSize, m_nIoSize, m_pIoAddress );
if ( result < CELL_OK )
return result;
g_gcmSharedData.m_pIoMemory = ( void* )pIoAddress;
*/
PS3_Launch_t tier0Launch( LauncherMainSPRXPath( "tier0", path ), &tier0 );
if( tier0Launch.m_iResult < CELL_OK )
{
return -1;
}
int iAppRetCode = 0;
PS3MainParameters< PS3_PrxLoadParametersBase_t > vstdlib;
PS3_Launch_t vstdlibLaunch( LauncherMainSPRXPath( "vstdlib", path ), &vstdlib );
if( vstdlibLaunch.m_iResult >= CELL_OK )
{
#ifndef NO_STEAM
PS3MainParameters< PS3_PrxLoadParametersBase_t > steamapi;
PS3_Launch_t steamapiLaunch( LauncherMainSPRXPath( "steam_api", path ), &steamapi );
if ( steamapiLaunch.m_iResult >= CELL_OK )
{
#endif
PS3MainParameters< PS3_LoadLauncher_Parameters_t > launcher;
PS3_Launch_t launcherLaunch( LauncherMainSPRXPath( "launcher", path ), &launcher );
if ( launcher.pfnLauncherMain )
{
printf( "Launching...\n" );
iAppRetCode = bRunLauncherMain ? (*launcher.pfnLauncherMain)( argc, argv ) : 0;
printf( "Shutting down...\n" );
launcher.pfnLauncherShutdown();
}
else
{
printf( "ERROR: failed to obtain LauncherMain entry point!\n" );
}
PS3_PrxUnload( launcher.sysPrxId );
#ifndef NO_STEAM
PS3_PrxUnload( steamapi.sysPrxId );
}
#endif
PS3_PrxUnload( vstdlib.sysPrxId );
}
// Before tier0 unloads make sure that there are no modules remaining loaded
#if !defined( _CERT )
for ( PS3_PrxModuleEntry_t *pEntry = *PS3_PrxGetModulesList(); pEntry; pEntry = pEntry->pNextModule )
{
if ( strstr( pEntry->chName, "/tier0" DLL_EXT_STRING ) )
continue;
unsigned int dummy;
char const *szWarnMsg = "EXITING WITH PRX MODULE: ";
sys_tty_write( SYS_TTYP6, szWarnMsg, strlen( szWarnMsg ), &dummy );
sys_tty_write( SYS_TTYP6, pEntry->chName, strlen( pEntry->chName ), &dummy );
szWarnMsg = "\n";
sys_tty_write( SYS_TTYP6, szWarnMsg, strlen( szWarnMsg ), &dummy );
}
#endif
tier0.pfnTier0Shutdown();
PS3_PrxUnload( tier0.sysPrxId );
return iAppRetCode;
}
int main( int argc, char *argv[] )
{
// Init LibSn
#ifndef _CERT
snInit();
#endif
int nReturn = MainImpl( argc, argv );
#ifndef _PS3
// if( !gTLSGlobals.bNormalQuitRequested )
// {
// printf("no normal quit requested, starting error render loop\n");
// ErrorRenderLoop loop;
// loop.Run();
// printf("Error render loop finished\n");
// }
#endif
#if !defined( _CERT )
if ( 1 )
{
unsigned int dummy;
char const *szWarnMsg =
(*PS3_PrxGetModulesList())
? "------- WARNING: RETURNING FROM MAIN WITH PRX MODULES RUNNING --------\n"
: "--------------------------------BYE-----------------------------------\n";
sys_tty_write( SYS_TTYP6, szWarnMsg, strlen( szWarnMsg ), &dummy );
}
#endif
return nReturn;
}
#elif defined (POSIX)
int main( int argc, char *argv[] )
{
#ifdef PLATFORM_64BITS
#ifdef OSX
const char *pLauncherPath = "bin/osx64/launcher" DLL_EXT_STRING;
#else
const char *pLauncherPath = "bin/linux64/launcher" DLL_EXT_STRING;
#endif
#else
const char *pLauncherPath = "bin/launcher" DLL_EXT_STRING;
#endif
void *launcher = dlopen( pLauncherPath, RTLD_NOW );
if ( !launcher )
{
printf( "Failed to load the launcher (%s)\n", dlerror() );
while(1);
return 0;
}
LauncherMain_t main = (LauncherMain_t)dlsym( launcher, "LauncherMain" );
if ( !main )
{
printf( "Failed to load the launcher entry proc\n" );
while(1);
return 0;
}
return main( argc, argv );
}
#else
#error
#endif // WIN32 || POSIX
#else // X360
//-----------------------------------------------------------------------------
// 360 Quick and dirty command line parsing. Returns true if key found,
// false otherwise. Caller can optionally get next argument.
//-----------------------------------------------------------------------------
bool ParseCommandLineArg( const char *pCmdLine, const char* pKey, char* pValueBuff = NULL, int valueBuffSize = 0 )
{
int keyLen = (int)strlen( pKey );
const char* pArg = pCmdLine;
for ( ;; )
{
// scan for match
pArg = strstr( (char*)pArg, pKey );
if ( !pArg )
{
return false;
}
// found, but could be a substring
if ( pArg[keyLen] == '\0' || pArg[keyLen] == ' ' )
{
// exact match
break;
}
pArg += keyLen;
}
if ( pValueBuff )
{
// caller wants next token
// skip past key and whitespace
pArg += keyLen;
while ( *pArg == ' ' )
{
pArg++;
}
int i;
for ( i=0; i<valueBuffSize; i++ )
{
pValueBuff[i] = *pArg;
if ( *pArg == '\0' || *pArg == ' ' )
break;
pArg++;
}
pValueBuff[i] = '\0';
}
return true;
}
//-----------------------------------------------------------------------------
// 360 Quick and dirty command line arg stripping.
//-----------------------------------------------------------------------------
void StripCommandLineArg( const char *pCmdLine, char *pNewCmdLine, const char *pStripArg )
{
// cannot operate in place
assert( pCmdLine != pNewCmdLine );
int numTotal = strlen( pCmdLine ) + 1;
const char* pArg = strstr( pCmdLine, pStripArg );
if ( !pArg )
{
strcpy( pNewCmdLine, pCmdLine );
return;
}
int numDiscard = strlen( pStripArg );
while ( pArg[numDiscard] && ( pArg[numDiscard] != '-' && pArg[numDiscard] != '+' ) )
{
// eat whitespace up to the next argument
numDiscard++;
}
memcpy( pNewCmdLine, pCmdLine, pArg - pCmdLine );
memcpy( pNewCmdLine + ( pArg - pCmdLine ), (void*)&pArg[numDiscard], numTotal - ( pArg + numDiscard - pCmdLine ) );
// ensure we don't leave any trailing whitespace, occurs if last arg is stripped
int len = strlen( pNewCmdLine );
while ( len > 0 && pNewCmdLine[len-1] == ' ' )
{
len--;
}
pNewCmdLine[len] = '\0';
}
//-----------------------------------------------------------------------------
// 360 Conditional spew
//-----------------------------------------------------------------------------
void Spew( const char *pFormat, ... )
{
#if defined( _DEBUG )
char msg[2048];
va_list argptr;
va_start( argptr, pFormat );
vsprintf( msg, pFormat, argptr );
va_end( argptr );
OutputDebugString( msg );
#endif
}
//-----------------------------------------------------------------------------
// Get the new entry point and command line
//-----------------------------------------------------------------------------
LauncherMain_t GetLaunchEntryPoint( char *pNewCommandLine )
{
HMODULE hModule;
char *pCmdLine;
// determine source of our invocation, internal or external
// a valid launch payload will have an embedded command line
// command line could be from internal restart in dev or retail mode
CXboxLaunch xboxLaunch;
int payloadSize;
unsigned int launchID;
char *pPayload;
bool bInternalRestart = xboxLaunch.GetLaunchData( &launchID, (void**)&pPayload, &payloadSize );
if ( !bInternalRestart || !payloadSize || launchID != VALVE_LAUNCH_ID )
{
// could be first time, get command line from system
pCmdLine = GetCommandLine();
if ( !stricmp( pCmdLine, "\"default.xex\"" ) )
{
// matches retail xex and no arguments, mut be first time retail launch
pCmdLine = "default.xex";
#if defined( _MEMTEST )
pCmdLine = "default.xex +mat_picmip 2";
#endif
}
}
else
{
// get embedded command line from payload
pCmdLine = pPayload;
}
int launchFlags = 0;
if ( launchID == VALVE_LAUNCH_ID )
{
launchFlags = xboxLaunch.GetLaunchFlags();
}
#if !defined( _CERT )
if ( launchFlags & LF_ISDEBUGGING )
{
while ( !DmIsDebuggerPresent() )
{
}
Sleep( 1000 );
Spew( "Resuming debug session.\n" );
}
#endif
// unforunately, the xbox erases its internal store upon first fetch
// must re-establish it so the payload that contains other data (past command line) can be accessed by the game
// the launch data will be owned by tier0 and supplied to game
if ( launchID == VALVE_LAUNCH_ID )
{
xboxLaunch.SetLaunchData( pPayload, payloadSize, launchFlags );
}
#if defined( _DEMO )
else if ( pPayload && payloadSize )
{
// not our data
// restore the launch data as expected
xboxLaunch.SetLaunchData( pPayload, payloadSize, LF_UNKNOWNDATA );
}
#endif
#if defined( _DEMO )
// the demo version cannot trust launch environment
// Kiosk or Magazines launch in unpredictable ways with unknown paths
// MUST slam the command line!!!
#if !defined( _CERT )
// take the command line as specified by the debugger
if ( !DmIsDebuggerPresent() )
{
pCmdLine = "default.xex";
}
#else
pCmdLine = "default.xex";
#endif
#endif
// The 360 has no paths and therefore the xex must reside in the same location as the dlls.
// Only the xex must reside locally, on the box, but the dlls can be mounted from the remote share.
// Resolve all known implicitly loaded dlls to be explicitly loaded now to allow their remote location.
const char *pImplicitDLLs[] =
{
"tier0_360.dll",
"vstdlib_360.dll",
"vxbdm_360.dll",
"launcher_360.dll",
};
// Corresponds to pImplicitDLLs. A dll load failure is only an error if that dll is tagged as required.
const bool bDllRequired[] =
{
true, // tier0
true, // vstdlib
false, // vxbdm
true, // ???
};
char gameName[32];
if ( !ParseCommandLineArg( pCmdLine, "-game", gameName, sizeof( gameName ) ) )
{
#if defined( VPCGAME_STRING )
strcpy( gameName, VPCGAME_STRING );
#endif
}
else
{
// sanitize a possible absolute game path back to expected game name
char *pSlash = strrchr( gameName, '\\' );
if ( pSlash )
{
memcpy( gameName, pSlash+1, strlen( pSlash+1 )+1 );
}
}
// resolve which application gets launched
// default is to application
pImplicitDLLs[ARRAYSIZE( pImplicitDLLs )-1] = "launcher_360.dll";
// the base path is the where the game is predominantly anchored
// game runs from dvd only
// this can only be the d: by definition on the xbox
const char *pBasePath = "d:";
// load all the dlls specified
char dllPath[MAX_PATH];
for ( int i=0; i<ARRAYSIZE( pImplicitDLLs ); i++ )
{
hModule = NULL;
sprintf( dllPath, "%s\\bin\\%s", pBasePath, pImplicitDLLs[i] );
hModule = LoadLibrary( dllPath );
if ( !hModule && bDllRequired[i] )
{
Spew( "FATAL: Failed to load dll: '%s'\n", dllPath );
return NULL;
}
}
char cleanCommandLine[1024];
char tempCommandLine[1024];
StripCommandLineArg( pCmdLine, tempCommandLine, "-basedir" );
StripCommandLineArg( tempCommandLine, cleanCommandLine, "-game" );
// HACK: For ratings build, unlock everything. Remove this for later testing
const char *pAdditionalArgs = "";
#if defined( RATINGSBUILD )
pAdditionalArgs = "-dev -unlockchapters mp_mark_all_maps_complete";
#endif
// set the alternate command line
sprintf( pNewCommandLine, "%s -basedir %s -game %s\\%s %s", cleanCommandLine, pBasePath, pBasePath, gameName, pAdditionalArgs );
// the 'main' export is guaranteed to be at ordinal 1
// the library is already loaded, this just causes a lookup that will resolve against the shortname
const char *pLaunchDllName = pImplicitDLLs[ARRAYSIZE( pImplicitDLLs )-1];
hModule = LoadLibrary( pLaunchDllName );
LauncherMain_t main = (LauncherMain_t)GetProcAddress( hModule, (LPSTR)1 );
if ( !main )
{
Spew( "FATAL: 'LauncherMain' entry point not found in %s\n", pLaunchDllName );
return NULL;
}
return main;
}
//-----------------------------------------------------------------------------
// 360 Application Entry Point.
//-----------------------------------------------------------------------------
VOID __cdecl main()
{
char newCmdLine[1024];
LauncherMain_t newMain = GetLaunchEntryPoint( newCmdLine );
if ( newMain )
{
// 360 has no concept of instances, spoof one
newMain( (HINSTANCE)1, (HINSTANCE)0, (LPSTR)newCmdLine, 0 );
}
}
#endif

View File

@ -0,0 +1,421 @@
//===== Copyright <20> 1996-2010, Valve Corporation, All rights reserved. ======//
//
// Purpose: Utility class for discovering and caching path info on the PS3.
//
// $NoKeywords: $
//===========================================================================//
#ifndef SN_TARGET_PS3
#error You're compiling this file on the wrong platform!
#endif
#include <stdlib.h>
#include <string.h>
#include <cell/sysmodule.h>
#include "../public/ps3_pathinfo.h"
#include <sys/tty.h>
#include "errorrenderloop.h"
#include <np.h>
// statically defined because not available in LauncherMain:
#ifndef DBG_H
static void LocalError( const char *fmt, ... )
{
va_list args;
va_start(args, fmt);
vprintf( fmt, args );
ErrorRenderLoop loop;
loop.Run();
exit(1);
}
static void AssertMsg( bool cond, const char *complaint )
{
if (!cond)
{
LocalError(complaint);
}
}
#else
#define LocalError Error
#endif
#define CheckError( x, str ) if ( x < 0 ) { LocalError( "%s: %s\n", str, GetSonyErrorString( x ) ); return x; }
#ifndef _CERT
#define DiagnosticStringMode 1
#define DiagnosticString( x ) do { unsigned int dummy; sys_tty_write( SYS_TTYP15, x, strlen( x ), &dummy ); } while(0)
#else
#define DiagnosticString( x ) ((void)0)
#endif
CPs3ContentPathInfo g_Ps3GameDataPathInfo;
CPs3ContentPathInfo::CPs3ContentPathInfo() :
m_bInitialized(false),
m_nHDDFreeSizeKb( 0 ),
m_nBootType( 0 ),
m_nBootAttribs( 0 ),
m_gameParentalLevel( 0 ),
m_gameResolution( 0 ),
m_gameSoundFormat( 0 )
{
#define GAME_INIT( x ) memset( x, 0, sizeof( x ) )
GAME_INIT( m_gameTitle );
GAME_INIT( m_gameTitleID );
GAME_INIT( m_gameAppVer );
GAME_INIT( m_gamePatchAppVer );
GAME_INIT( m_gameContentPath );
GAME_INIT( m_gamePatchContentPath );
GAME_INIT( m_gameBasePath );
GAME_INIT( m_gamePatchBasePath );
GAME_INIT( m_gameExesPath );
GAME_INIT( m_gameHDDataPath );
GAME_INIT( m_gameImageDataPath );
GAME_INIT( m_gameSystemCachePath );
GAME_INIT( m_gameSavesShadowPath );
#undef GAME_INIT
}
const char *GetSonyErrorString( int errorcode ) ; /// return a description for a CELL_GAME_ERROR code
int CPs3ContentPathInfo::Init( unsigned int uiFlagsMask )
{
AssertMsg( !m_bInitialized, "CPs3ContentPathInfo is being initialized twice!\n" );
/////////////////////////////////////////////////////////////////////////
//
// load sysutil NP
//
//////////////////////////////////////////////////////////////////////////
// we'll need to haul libsysutil into memory ( CELL_SYSMODULE_SYSUTIL_NP )
{
int suc = cellSysmoduleLoadModule( CELL_SYSMODULE_SYSUTIL_NP );
if ( suc != CELL_OK )
{
LocalError( "Failed to load sysutil_np: %s\n", GetSonyErrorString(suc) );
return suc;
}
}
/////////////////////////////////////////////////////////////////////////
//
// load sysutil GAME
//
//////////////////////////////////////////////////////////////////////////
// we'll need to haul libsysutil into memory ( CELL_SYSMODULE_SYSUTIL_GAME )
bool bSysModuleIsLoaded = cellSysmoduleIsLoaded( CELL_SYSMODULE_SYSUTIL_GAME ) == CELL_SYSMODULE_LOADED ;
// if this assert trips, then:
// 1) look at where the sysutil_game module is loaded to make sure it still needs to be loaded at this point (maybe you can dump it to save memory)
// 2) if it's being taken care of somewhere else, we don't need to load the module here.
AssertMsg( !bSysModuleIsLoaded, "The SYSUTIL_GAME module is already loaded -- revist load order logic in CPs3ContentPathInfo::Init()\n");
if ( !bSysModuleIsLoaded )
{
int suc = cellSysmoduleLoadModule( CELL_SYSMODULE_SYSUTIL_GAME );
if ( suc != CELL_OK )
{
LocalError( "Failed to load sysutil_game: %s\n", GetSonyErrorString(suc) );
return suc;
}
}
//////////////////////////////////////////////////////////////////////////
//
// cellGameBootCheck
//
//////////////////////////////////////////////////////////////////////////
// get the base to the content directory.
CellGameContentSize size; // For game content of a disc boot game, sizeKB and sysSizeKB take no meaning <20> please do not use them
memset(&size, 0, sizeof(CellGameContentSize));
char bootdir[CELL_GAME_DIRNAME_SIZE] = {0};
int success = cellGameBootCheck( &m_nBootType, &m_nBootAttribs, &size, bootdir );
if ( success != CELL_GAME_RET_OK )
{
LocalError("cellGameBootCheck failed (line %d, code %d): %s\n", __LINE__, success, GetSonyErrorString(success) );
return success;
}
#if DiagnosticStringMode
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_DEBUG ) { DiagnosticString( "GAME BOOT: DEBUG MODE\n" ); }
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_APP_HOME ) { DiagnosticString( "GAME BOOT: HOSTFS MODE (app_home)\n" ); }
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_PATCH ) { DiagnosticString( "GAME BOOT: PATCH MODE\n" ); }
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_INVITE_MESSAGE ) { DiagnosticString( "GAME BOOT: INVITE MESSAGE\n" ); }
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_CUSTOM_DATA_MESSAGE ) { DiagnosticString( "GAME BOOT: CUSTOM DATA MESSAGE\n" ); }
DiagnosticString( "BOOT DIR " ); DiagnosticString( bootdir ); DiagnosticString( "\n" );
#endif
m_bInitialized = true;
m_nHDDFreeSizeKb = size.hddFreeSizeKB;
//////////////////////////////////////////////////////////////////////////
//
// cellGameContentPermit
//
//////////////////////////////////////////////////////////////////////////
if ( !( uiFlagsMask & INIT_RETAIL_MODE ) )
{
DiagnosticString( "BOOT INFO USING NON-RETAIL BOOT\n" );
//
// BOOT MODE required: PARAM.SFO
//
success = cellGameGetParamString( CELL_GAME_PARAMID_TITLE, m_gameTitle, sizeof( m_gameTitle ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_TITLE )" );
success = cellGameGetParamString( CELL_GAME_PARAMID_TITLE_ID, m_gameTitleID, sizeof( m_gameTitleID ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_TITLE_ID )" );
success = cellGameGetParamString( CELL_GAME_PARAMID_APP_VER, m_gameAppVer, sizeof( m_gameAppVer ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_APP_VER )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_PARENTAL_LEVEL, &m_gameParentalLevel ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_PARENTAL_LEVEL )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_RESOLUTION, &m_gameResolution ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_RESOLUTION )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_SOUND_FORMAT, &m_gameSoundFormat ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_SOUND_FORMAT )" );
// Access /app_home/...
success = cellGameContentPermit( m_gameContentPath, m_gameBasePath ) ;
DiagnosticString( "BOOT ROOT " ); DiagnosticString( m_gameContentPath ); DiagnosticString( "\n" );
DiagnosticString( "BOOT USR " ); DiagnosticString( m_gameBasePath ); DiagnosticString( "\n" );
// when running the game from the debugger, the data path returned by ContentPermit contains
// HOSTFS formatted path like /app_home/D:\perforce\...
// Perform the fixup to conform to disk image layout
if ( (m_nBootAttribs & CELL_GAME_ATTRIBUTE_DEBUG) && !strncmp( m_gameBasePath, "/app_home", sizeof( "/app_home" ) - 1 ) )
{
snprintf( m_gameContentPath, sizeof( m_gameContentPath ) - 1, "/app_home/PS3_GAME" );
snprintf( m_gameBasePath, sizeof( m_gameBasePath ) - 1, "/app_home/PS3_GAME/USRDIR" );
DiagnosticString( "BOOT ROOT/ " ); DiagnosticString( m_gameContentPath ); DiagnosticString( "\n" );
DiagnosticString( "BOOT USR// " ); DiagnosticString( m_gameBasePath ); DiagnosticString( "\n" );
}
}
else
{
if ( m_nBootType != CELL_GAME_GAMETYPE_DISC )
{
LocalError("Only disk boot is supported in RETAIL mode! (bootmode=%d)\n", m_nBootType );
return -1;
}
// Finish access to boot executable
{
char tmp_contentInfoPath[CELL_GAME_PATH_MAX] = {0};
char tmp_usrdirPath[CELL_GAME_PATH_MAX] = {0};
success = cellGameContentPermit( tmp_contentInfoPath, tmp_usrdirPath ); // must call this to allow mounting of BDVD
DiagnosticString( "BOOT ROOT " ); DiagnosticString( tmp_contentInfoPath ); DiagnosticString( "\n" );
DiagnosticString( "BOOT USR " ); DiagnosticString( tmp_usrdirPath ); DiagnosticString( "\n" );
}
// in RETAIL mode we always have our assets on BDVD
success = cellGameDataCheck( m_nBootType, NULL, &size);
if ( success == CELL_GAME_RET_OK )
{
//
// BOOT MODE required: PARAM.SFO
//
success = cellGameGetParamString( CELL_GAME_PARAMID_TITLE, m_gameTitle, sizeof( m_gameTitle ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_TITLE )" );
success = cellGameGetParamString( CELL_GAME_PARAMID_TITLE_ID, m_gameTitleID, sizeof( m_gameTitleID ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_TITLE_ID )" );
success = cellGameGetParamString( CELL_GAME_PARAMID_APP_VER, m_gameAppVer, sizeof( m_gameAppVer ) ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_APP_VER )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_PARENTAL_LEVEL, &m_gameParentalLevel ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_PARENTAL_LEVEL )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_RESOLUTION, &m_gameResolution ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_RESOLUTION )" );
success = cellGameGetParamInt( CELL_GAME_PARAMID_SOUND_FORMAT, &m_gameSoundFormat ); CheckError( success, "PARAM.SFO getParam( CELL_GAME_PARAMID_SOUND_FORMAT )" );
// Access BDVD:
success = cellGameContentPermit( m_gameContentPath, m_gameBasePath ) ;
}
else
{
LocalError("cellGameDataCheck failed (line %d, code %d): %s\n", __LINE__, success, GetSonyErrorString(success) );
return success;
}
}
DiagnosticString( "-----------PARAM.SFO----------" );
DiagnosticString( "\nTITLE " ); DiagnosticString( m_gameTitle );
DiagnosticString( "\nTITLE ID " ); DiagnosticString( m_gameTitleID );
DiagnosticString( "\nAPP_VER " ); DiagnosticString( m_gameAppVer );
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_PATCH )
{
CellGameContentSize cgcs;
memset( &cgcs, 0, sizeof(CellGameContentSize) );
success = cellGamePatchCheck( &cgcs, NULL );
if ( success == CELL_GAME_RET_OK )
{
success = cellGameGetParamString( CELL_GAME_PARAMID_APP_VER, m_gamePatchAppVer, sizeof( m_gamePatchAppVer ) ); CheckError( success, "PARAM.SFO PATCH getParam( CELL_GAME_PARAMID_APP_VER )" );
DiagnosticString( "\nAPP_VER****" ); DiagnosticString( m_gamePatchAppVer );
success = cellGameContentPermit( m_gamePatchContentPath, m_gamePatchBasePath ) ;
}
else
{
LocalError("cellGamePatchCheck failed (line %d, code %d): %s\n", __LINE__, success, GetSonyErrorString(success) );
return success;
}
}
DiagnosticString( "\n------------------------------\n" );
//////////////////////////////////////////////////////////////////////////
//
// filesystem path setup
//
//////////////////////////////////////////////////////////////////////////
DiagnosticString( "----------FILESYSTEM----------" );
DiagnosticString( "\nPS3_GAME " ); DiagnosticString( m_gameContentPath );
DiagnosticString( "\nUSRDIR " ); DiagnosticString( m_gameBasePath );
if ( m_nBootAttribs & CELL_GAME_ATTRIBUTE_PATCH )
{
DiagnosticString( "\nPS3_GAME***" ); DiagnosticString( m_gamePatchContentPath );
DiagnosticString( "\nUSRDIR*****" ); DiagnosticString( m_gamePatchBasePath );
}
#if 0
// Get the game data directory on the hard disk.
success = cellGameDataCheck( CELL_GAME_GAMETYPE_GAMEDATA, m_gameTitleID, &size );
if ( success == CELL_GAME_RET_NONE )
{
CellGameSetInitParams init; memset( &init, 0, sizeof( init ) );
memcpy( init.title, m_gameTitle, sizeof( m_gameTitle ) );
memcpy( init.titleId, m_gameTitleID, sizeof( m_gameTitleID ) );
memcpy( init.version, m_gameAppVer, sizeof( m_gameAppVer ) );
char tmp_contentInfoPath[CELL_GAME_PATH_MAX] = {0};
char tmp_usrdirPath[CELL_GAME_PATH_MAX] = {0};
success = cellGameCreateGameData( &init, tmp_contentInfoPath, tmp_usrdirPath );
DiagnosticString( "\nTMP_GAME " ); DiagnosticString( tmp_contentInfoPath );
DiagnosticString( "\nTMP_USRD " ); DiagnosticString( tmp_usrdirPath );
}
char contentInfoPath[256];
if ( success == CELL_GAME_RET_OK )
{
success = cellGameContentPermit( contentInfoPath, m_gameHDDataPath );
}
#else
snprintf( m_gameHDDataPath, sizeof( m_gameHDDataPath ), "/dev_hdd0/game/NPUB30589/USRDIR" );
//snprintf( m_gameHDDataPath, sizeof( m_gameHDDataPath ), "/dev_hdd0/game/BLUS30732/USRDIR" );
#endif
DiagnosticString( "\nHDD_PATH " ); DiagnosticString( m_gameHDDataPath );
// Mount system cache
if ( success >= CELL_GAME_RET_OK )
{
CellSysCacheParam sysCacheParams;
memset( &sysCacheParams, 0, sizeof( CellSysCacheParam ) );
memcpy( sysCacheParams.cacheId, GetWWMASTER_TitleID(), 10 );
success = cellSysCacheMount( &sysCacheParams );
if ( success >= CELL_GAME_RET_OK )
{
memcpy( m_gameSystemCachePath, sysCacheParams.getCachePath, sizeof( m_gameSystemCachePath ) );
if ( uiFlagsMask & INIT_SYS_CACHE_CLEAR )
cellSysCacheClear();
}
}
DiagnosticString( "\nSYS_CACH " ); DiagnosticString( m_gameSystemCachePath );
// Determine where image files (maps, zips, etc.) are located:
snprintf( m_gameImageDataPath, sizeof( m_gameImageDataPath ), m_gameBasePath );
if ( uiFlagsMask & INIT_IMAGE_APP_HOME )
snprintf( m_gameImageDataPath, sizeof( m_gameImageDataPath ), "/app_home/PS3_GAME/USRDIR" );
else if ( uiFlagsMask & INIT_IMAGE_ON_HDD )
snprintf( m_gameImageDataPath, sizeof( m_gameImageDataPath ), m_gameHDDataPath );
else if ( uiFlagsMask & INIT_IMAGE_ON_BDVD )
snprintf( m_gameImageDataPath, sizeof( m_gameImageDataPath ), "/dev_bdvd/PS3_GAME/USRDIR" );
DiagnosticString( "\nIMAGE_PATH " ); DiagnosticString( m_gameImageDataPath );
// Determine where PRX files are located:
snprintf( m_gameExesPath, sizeof( m_gameExesPath ), "%s/bin", m_gameBasePath );
if ( uiFlagsMask & INIT_PRX_APP_HOME )
snprintf( m_gameExesPath, sizeof( m_gameExesPath ), "/app_home/PS3_GAME/USRDIR/bin" );
else if ( uiFlagsMask & INIT_PRX_ON_HDD )
snprintf( m_gameExesPath, sizeof( m_gameExesPath ), "%s/bin", m_gameHDDataPath );
else if ( uiFlagsMask & INIT_PRX_ON_BDVD )
snprintf( m_gameExesPath, sizeof( m_gameExesPath ), "/dev_bdvd/PS3_GAME/USRDIR/bin" );
DiagnosticString( "\nPRX_PATH " ); DiagnosticString( m_gameExesPath );
DiagnosticString( "\n------------------------------\n" );
// we cache the saves to a local directory -- keep that info here so it's in a uniform
// place accessible from everywhere.
strncpy( m_gameSavesShadowPath, m_gameSystemCachePath, sizeof(m_gameSavesShadowPath) );
strncat( m_gameSavesShadowPath, "/tempsave/", sizeof(m_gameSavesShadowPath) );
//////////////////////////////////////////////////////////////////////////
//
// finished
//
//////////////////////////////////////////////////////////////////////////
if ( !bSysModuleIsLoaded ) // actually this means it wasn't loaded when we got into the function
{
cellSysmoduleUnloadModule( CELL_SYSMODULE_SYSUTIL_GAME );
}
return success;
}
const char *GetSonyErrorString( int errorcode )
{
switch( errorcode )
{
case CELL_GAME_RET_OK:
return "CELL_GAME_RET_OK";
case CELL_GAME_ERROR_ACCESS_ERROR:
return "HDD access error";
case CELL_GAME_ERROR_BUSY:
return "The call of an access preparing function was repeated";
case CELL_GAME_ERROR_IN_SHUTDOWN:
return "Processing cannot be executed because application termination is being processed";
case CELL_GAME_ERROR_INTERNAL:
return "Fatal error occurred in the utility";
case CELL_GAME_ERROR_PARAM:
return "There is an error in the argument (application bug)";
case CELL_GAME_ERROR_BOOTPATH:
return "Pathname of booted program file is too long" ;
case CELL_SYSMODULE_ERROR_UNKNOWN:
return "Tried to load an unknown PRX";
case CELL_SYSMODULE_ERROR_FATAL:
return "Sysmodule PRX load failed";
case CELL_GAME_ERROR_BROKEN:
return "The specified game content is corrupted";
default:
return "Unknown error code";
}
}
/* The boot attributes member of CPs3ContentPathInfo is some combination of:
CELL_GAME_ATTRIBUTE_PATCH Booted from a patch (only for a disc boot game)
CELL_GAME_ATTRIBUTE_APP_HOME Booted from the host machine (development machine only)
CELL_GAME_ATTRIBUTE_DEBUG Booted from the debugger (development machine only)
CELL_GAME_ATTRIBUTE_XMBBUY Rebooted from the game purchasing feature of the NP DRM utility
CELL_GAME_ATTRIBUTE_COMMERCE2_BROWSER Rebooted from the store browsing feature of the NP IN-GAME commerce 2 utility
CELL_GAME_ATTRIBUTE_INVITE_MESSAGE Booted from the game boot invitation message of the NP basic utility
CELL_GAME_ATTRIBUTE_CUSTOM_DATA_MESSAGE Booted from a message with a custom data attachment of the NP basic utility
CELL_GAME_ATTRIBUTE_WEB_BROWSER Booted from the full browser feature of the web browser utility
*/

23
launcher_main/resource.h Normal file
View File

@ -0,0 +1,23 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by launcher_main.rc
//
#define IDI_LAUNCHER 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

2
launcher_main/vsi.nul Normal file
View File

@ -0,0 +1,2 @@
SN Visual Studio Integration
IMPORTANT: Do not remove the custom build step for this file