Exemplo n.º 1
0
static BOOL doInit ( HINSTANCE hInstance, int nCmdShow )
{	
	WNDCLASS            wc;
   
    // Set up and register window class
    wc.style		 = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc	 = ( WNDPROC ) WindowProc;
    wc.cbClsExtra	 = 0;
    wc.cbWndExtra	 = sizeof ( DWORD );
    wc.hInstance	 = hInstance;
    wc.hIcon		 = NULL;
    wc.hCursor		 = LoadCursor ( NULL, IDC_ARROW );
    wc.hbrBackground = ( HBRUSH ) GetStockObject ( BLACK_BRUSH );
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = "CSG";
    
	if ( !RegisterClass ( &wc ) )
		return FALSE;

    int ScreenWidth	 = GetSystemMetrics ( SM_CXSCREEN );
    int ScreenHeight = GetSystemMetrics ( SM_CYSCREEN );

    // Create a window and display
	HWND hWnd;
    hWnd = CreateWindow( "CSG",
                        "DB Pro CSG",
						//WS_VISIBLE|WS_OVERLAPPED,
						WS_OVERLAPPED,
						0,
						0,
						10,
						10,
                        NULL,
                        NULL,
                        hInstance,
                        NULL );

    if ( !hWnd )
		return FALSE;

	//ShowWindow ( hWnd, nCmdShow );

    UpdateWindow ( hWnd );

	Init_DX ( hWnd );
	hwnd = hWnd;
	SetupFont    ( );
	InitPolygons ( );

	return TRUE;
	
}
Exemplo n.º 2
0
static void LoadScene(SCNHANDLE scene, int entry) {
	uint	i;
	TP_INIT init;
	const SCENE_STRUC	*ss;
	const ENTRANCE_STRUC	*es;

	// Scene handle
	SceneHandle = scene;		// Save scene handle in case of Save_Scene()
	LockMem(SceneHandle);		// Make sure scene is loaded
	LockScene(SceneHandle);		// Prevent current scene from being discarded

	if (TinselV2) {
		// CdPlay() stuff
		byte *cptr = FindChunk(scene, CHUNK_CDPLAY_FILENUM);
		assert(cptr);
		i = READ_LE_UINT32(cptr);
		assert(i < 512);
		cptr = FindChunk(scene, CHUNK_CDPLAY_FILENAME);
		assert(cptr);
		SetCdPlaySceneDetails(i, (const char *)cptr);
	}

	// Find scene structure
	ss = GetSceneStruc(FindChunk(scene, CHUNK_SCENE));
	assert(ss != NULL);

	if (TinselV2) {
		// Handle to scene description
		newestScene = FROM_LE_32(ss->hSceneDesc);

		// Music stuff
		char *cptr = (char *)FindChunk(scene, CHUNK_MUSIC_FILENAME);
		assert(cptr);
		_vm->_pcmMusic->setMusicSceneDetails(FROM_LE_32(ss->hMusicScript),
			FROM_LE_32(ss->hMusicSegment), cptr);
	}

	if (entry == NO_ENTRY_NUM) {
		// Restoring scene

		// Initialise all the polygons for this scene
		InitPolygons(FROM_LE_32(ss->hPoly), FROM_LE_32(ss->numPoly), true);

		// Initialise the actors for this scene
		StartTaggedActors(FROM_LE_32(ss->hTaggedActor), FROM_LE_32(ss->numTaggedActor), false);

		if (TinselV2)
			// Returning from cutscene
			SendSceneTinselProcess(RESTORE);

	} else {
		// Genuine new scene

		// Initialise all the polygons for this scene
		InitPolygons(FROM_LE_32(ss->hPoly), FROM_LE_32(ss->numPoly), false);

		// Initialise the actors for this scene
		StartTaggedActors(FROM_LE_32(ss->hTaggedActor), FROM_LE_32(ss->numTaggedActor), true);

		// Run the appropriate entrance code (if any)
		es = (const ENTRANCE_STRUC *)LockMem(FROM_LE_32(ss->hEntrance));
		for (i = 0; i < FROM_LE_32(ss->numEntrance); i++) {
			if (FROM_LE_32(es->eNumber) == (uint)entry) {
				if (es->hScript) {
					init.event = STARTUP;
					init.hTinselCode = es->hScript;

					g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init));
				}
				break;
			}

			// Move to next entrance
			if (TinselV2)
				++es;
			else
				es = (const ENTRANCE_STRUC *)((const byte *)es + 8);

		}

		if (i == FROM_LE_32(ss->numEntrance))
			error("Non-existant scene entry number");

		if (ss->hSceneScript) {
			init.event = STARTUP;
			init.hTinselCode = ss->hSceneScript;

			g_scheduler->createProcess(PID_TCODE, SceneTinselProcess, &init, sizeof(init));
		}
	}

	// Default refer type
	SetDefaultRefer(FROM_LE_32(ss->defRefer));

	// Scene's processes
	SceneProcesses(FROM_LE_32(ss->numProcess), FROM_LE_32(ss->hProcess));
}