Exemplo n.º 1
0
void MEM_ListMemoryBlocks( MEMORY_BLOCK *p_pMemoryBlock )
{
#if defined ( DEBUG ) || defined ( DEVELOPMENT )
	PMEMORY_BLOCK_HEADER pBlock = p_pMemoryBlock->pFirstBlock;

	LOG_Debug( "Memory block dump" );
	LOG_Debug( "\tFree: %ld", MEM_GetFreeMemoryBlockSize( p_pMemoryBlock ) );
	LOG_Debug( "\tUsed: %ld", MEM_GetUsedMemoryBlockSize( p_pMemoryBlock ) );

	while( pBlock )
	{
#endif /* DEBUG || DEVELOPMENT */

#if defined ( DEBUG )
		LOG_Debug( "\t%s | %s: %ld", pBlock->Name,
			( pBlock->Flags & MEM_BLOCK_FLAG_FREE ) ? "FREE" : "USED",
			pBlock->Size );
#elif defined ( DEVELOPMENT )
		LOG_Debug( "\t%s: %ld",
			( pBlock->Flags & MEM_BLOCK_FLAG_FREE ) ? "FREE" : "USED",
			pBlock->Size );
#endif /* DEBUG */

#if defined ( DEBUG ) || defined ( DEVELOPMENT )
		pBlock = pBlock->pNext;
	}
#endif /* DEBUG || DEVELOPMENT */

}
Exemplo n.º 2
0
void MEM_ListMemoryBlocks( MEMORY_BLOCK *p_pBlock )
{
#if defined ( DEBUG )
	MEMORY_BLOCK_HEADER *pBlock = p_pBlock->pFirstBlock;

	LOG_Debug( "Memory block dump" );
	LOG_Debug( "\tFree: %ld", MEM_GetFreeBlockSize( p_pBlock ) );
	LOG_Debug( "\tUsed: %ld", MEM_GetUsedBlockSize( p_pBlock ) );

	while( pBlock )
	{
		LOG_Debug( "\t%s | %s: %ld", pBlock->Name,
			( pBlock->Flags & MEM_BLOCK_FREE ) ? "FREE" : "USED",
			pBlock->Size );

		pBlock = pBlock->pNext;
	}
#elif defined ( DEVELOPMENT )
	MEMORY_BLOCK_HEADER *pBlock = p_pBlock->pFirstBlock;

	LOG_Debug( "Memory block dump\n" );
	LOG_Debug( "\tFree: %ld\n", MEM_GetFreeBlockSize( p_pBlock ) );
	LOG_Debug( "\tUsed: %ld\n", MEM_GetUsedBlockSize( p_pBlock ) );

	while( pBlock )
	{
		LOG_Debug( "\t%s: %ld\n",
			( pBlock->Flags & MEM_BLOCK_FREE ) ? "FREE" : "USED",
			pBlock->Size );

		pBlock = pBlock->pNext;
	}
#endif /* DEBUG */
}
Exemplo n.º 3
0
Sint32 MEM_InitialiseMemoryBlock( PMEMORY_BLOCK p_pMemoryBlock,
	void *p_pMemoryPointer, size_t p_Size, Uint8 p_Alignment,
	const char *p_pName )
{
	if( p_pMemoryPointer == NULL )
	{
		LOG_Debug( "NULL MEMORY POINTER!" );

		return MEM_FATALERROR;
	}

	if( p_pMemoryBlock == NULL )
	{
		LOG_Debug( "NULL MEMORY BLOCK!" );

		return MEM_FATALERROR;
	}

	p_pMemoryBlock->Alignment = p_Alignment;
	p_pMemoryBlock->StructAlignment = sizeof( size_t );
	p_pMemoryBlock->PaddedHeaderSize = MEM_Align(
		sizeof( MEMORY_BLOCK_HEADER ), sizeof( size_t ) );
	p_pMemoryBlock->pAllocatedBlock = p_pMemoryPointer;
	p_pMemoryBlock->AllocatedSize = p_Size;

	p_pMemoryBlock->pFirstBlock =
		( PMEMORY_BLOCK_HEADER )p_pMemoryBlock->pAllocatedBlock;
	p_pMemoryBlock->pFirstBlock->Size = p_pMemoryBlock->AllocatedSize;
	p_pMemoryBlock->pFirstBlock->Flags = MEM_BLOCK_FLAG_FREE;
	p_pMemoryBlock->pFirstBlock->pNext = NULL;

#if defined ( DEBUG )
	memset( p_pMemoryBlock->pFirstBlock->Name, '\0',
		sizeof( p_pMemoryBlock->pFirstBlock->Name ) );

	if( strlen( p_pName ) >=
		( sizeof( p_pMemoryBlock->pFirstBlock->Name ) - 1 ) )
	{
		memcpy( p_pMemoryBlock->pFirstBlock->Name, p_pName, 63 );
	}
	else
	{
		memcpy( p_pMemoryBlock->pFirstBlock->Name, p_pName,
			strlen( p_pName ) );
	}
#endif /* DEBUG */

	return MEM_OK;
}
Exemplo n.º 4
0
Sint32 HW_GetConsoleID( PHW_CONSOLEID p_pConsoleID )
{
	if( syCfgGetIndividualID( p_pConsoleID->ConsoleID ) != SYD_CFG_IID_OK )
	{
		LOG_Debug( "Failed to acquire the console's ID" );

		memset( p_pConsoleID->ConsoleID, 0,
			sizeof( p_pConsoleID->ConsoleID ) );
		memset( p_pConsoleID->ConsoleIDString, '\0',
			sizeof( p_pConsoleID->ConsoleIDString ) );

		return HW_FATALERROR;
	}

	sprintf( p_pConsoleID->ConsoleIDString, "%02X%02X%02X%02X%02X%02X",
		( unsigned char )p_pConsoleID->ConsoleID[ 0 ],
		( unsigned char )p_pConsoleID->ConsoleID[ 1 ],
		( unsigned char )p_pConsoleID->ConsoleID[ 2 ],
		( unsigned char )p_pConsoleID->ConsoleID[ 3 ],
		( unsigned char )p_pConsoleID->ConsoleID[ 4 ],
		( unsigned char )p_pConsoleID->ConsoleID[ 5 ] );

	p_pConsoleID->ConsoleIDString[ ( SYD_CFG_IID_SIZE * 2 ) ] = '\0';

	return HW_OK;
}
Exemplo n.º 5
0
GDFS FS_OpenFile( char *p_pFilePath )
{
	char *pFileName;
	char FileName[ GDD_FS_FNAMESIZE ];
	char FilePath[ 256 ];
	GDFS_DIRREC Directory;
	static Uint32 DirectoryBuffer[ GDFS_DIRREC_SIZE( 64 ) ];
	GDFS File;

	/* Save the direcotry used before entering */
	Directory = gdFsCreateDirhn( DirectoryBuffer, 64 );
	gdFsLoadDir( ".", Directory );

	/* For an absolute path, begin with the root directory */
	if( p_pFilePath[ 0 ] == '/' )
	{
		gdFsSetDir( g_RootDirectory );
	}

	/* Don't modify the input file path */
	strncpy( FilePath, p_pFilePath, strlen( p_pFilePath ) );
	FilePath[ strlen( p_pFilePath ) ] = '\0';

	/* Break the path down for GDFS to consume */
	pFileName = strtok( FilePath, "/" );

	File = NULL;

	while( pFileName != NULL )
	{
		GDFS_DIRINFO FileInformation;
		strcpy( FileName, pFileName );

		if( gdFsGetDirInfo( pFileName, &FileInformation ) != GDD_ERR_OK )
		{
			LOG_Debug( "FILE: \"%s\" invalid", FileName );

			goto OpenFileEnd;
		}

		if( FileInformation.flag & GDD_FF_DIRECTORY )
		{
			gdFsChangeDir( FileName );
		}

		pFileName = strtok( NULL, "/" );
	}

	File = gdFsOpen( FileName, NULL );

OpenFileEnd:
	/* Restore the directory used before entering the function */
	gdFsSetDir( Directory );

	return File;
}
    void CloudReconnectWorker::processNotification( AbsOptCloudClientWorker::TypeId tId, const AbsOptCloudClientWorker::BufferType& data )
    {
      LOG_Debug(core, "Process event message type notification ...");
      IUccSessionListener::TypeId typeId(tId);

      // Here we need to verify if the notification correspond to uccReconnectRequest.
      if( typeId == gvr::communication::ucc::UccMessageCloudReconnect::GetTypeId() )
      {
        doReconnect(data);
      }
    }
Exemplo n.º 7
0
Sint32 MEM_Initialise( PNATIVE_MEMORY_FREESTAT p_pNativeMemoryFreeStat )
{
	syMallocInit( MEM_HEAP_AREA, MEM_HEAP_SIZE );
	syMallocStat( &p_pNativeMemoryFreeStat->Free,
		&p_pNativeMemoryFreeStat->BiggestFree );

#if defined ( DEBUG )
	LOG_Debug( "Memory initialised with a heap of %ld bytes",
		p_pNativeMemoryFreeStat->Free );
#endif /* DEBUG */

	return MEM_OK;
}
Exemplo n.º 8
0
int MEM_Initialise( PMEMORY_FREESTAT p_pMemoryFree )
{
	syMallocInit( MEM_HEAP_AREA, MEM_HEAP_SIZE );
	syMallocStat( &p_pMemoryFree->Free, &p_pMemoryFree->BiggestFree );

#if defined ( DEBUG )
	{
		LOG_Debug( "Memory initialised with a heap of %ld bytes",
			p_pMemoryFree->Free );
	}
#endif /* DEBUG */

	return 0;
}
Exemplo n.º 9
0
void GDFSErrorCallback( void *p_pObject, long p_Error )
{
	LOG_Debug( "OK" );
	if( ( p_Error == GDD_ERR_TRAYOPEND ) ||
		( p_Error == GDD_ERR_UNITATTENT ) )
	{
#if defined ( DCJAM_BUILD_DEBUG )
		return;
#else
		/* Hard reset.  Maybe this callback should be set from main? */
		HW_Terminate( );
		HW_Reboot( );
#endif /* DCJAM_BUILD_DEBUG */
	}
}
Exemplo n.º 10
0
static int MMS_Load( void *p_pArgs )
{
	PMAINMENU pArguments = p_pArgs;
	KMPACKEDARGB TextColour;
	KMPACKEDARGB HighlightColour;
	MENU_ITEM MenuItems[ 4 ];
	SELECTION_HIGHLIGHT_STRING SelectionHighlight;

	TextColour.dwPacked = 0xFFFFFFFF;
	HighlightColour.dwPacked = 0xFF00FF00;

	MainMenuState.pGlyphSet = GSM_GetGlyphSet(
		MainMenuState.Base.pGameStateManager, GSM_GLYPH_SET_GUI_1 );

	MenuItems[ 0 ].pName = "SINGLE PLAYER [COMING 20XX]";
	MenuItems[ 0 ].Function = NULL;

	MenuItems[ 1 ].pName = "MULTI PLAYER";
	MenuItems[ 1 ].Function = LaunchMultiPlayer;

	MenuItems[ 2 ].pName = "OPTIONS";
	MenuItems[ 2 ].Function = NULL;

	MenuItems[ 3 ].pName = "RESET TO BOOTROM";
	MenuItems[ 3 ].Function = &BootROM;

	SelectionHighlight.Base.Type = SELECTION_HIGHLIGHT_TYPE_STRING;
	SelectionHighlight.Base.HighlightColour = HighlightColour;
	SelectionHighlight.pString = "$ ";

	if( MNU_Initialise( &MainMenuState.Menu, MenuItems, 4, &SelectionHighlight,
		GSM_GetGlyphSet( MainMenuState.Base.pGameStateManager,
			GSM_GLYPH_SET_GUI_1 ), TextColour, MENU_ITEM_ALIGNMENT_LEFT,
		MainMenuState.Base.pGameStateManager->MemoryBlocks.pSystemMemory ) !=
		0 )
	{
		LOG_Debug( "MMS_Load <ERROR> Failed to initialise the menu\n" );

		return 1;
	}

	return 0;
}
Exemplo n.º 11
0
static void MPG_ProcessQueuedPackets( void )
{
    while( QUE_IsEmpty( &MultiPlayerGameState.PacketQueue ) == false )
    {
        PPACKET pPacket;

        LOG_Debug( "Processing packet\n" );
        /* This will be used for testing with different latencies, though it's
         * not yet enabled, this is a reminder */

        pPacket = QUE_GetFront( &MultiPlayerGameState.PacketQueue );
        MPG_ProcessPacket( &pPacket->Message, &pPacket->Address );

        /* Free up the memory used by the packet */
        MSG_DestroyNetworkMessage( &pPacket->Message );

        QUE_Dequeue( &MultiPlayerGameState.PacketQueue, NULL );
    }
}
Exemplo n.º 12
0
int NCL_Initialise( PNETWORK_CLIENT p_pClient, const char *p_pServerIP,
	const Uint16 p_ServerPort )
{
	p_pClient->ID = 0;
	
	if( NET_CreateSocketUDP( &p_pClient->Socket ) != 0 )
	{
		LOG_Debug( "Failed to create a UDP socket" );

		return 1;
	}

	NET_CreateSocketAddress( &p_pClient->SocketAddress,
		inet_addr( p_pServerIP ), htons( p_ServerPort ) );

	NET_BindSocketUDP( &p_pClient->Socket, &p_pClient->SocketAddress );

	return 0;
}
Exemplo n.º 13
0
static void MPG_ReadIncomingPackets( void )
{
    static Uint8 PacketMemory[ 1400 ];
    static size_t PacketSize = sizeof( PacketMemory );
    PACKET NetworkPacket;
    int ReceivedPackets = 0;
    int TotalReadBytes = 0;
    NETWORK_MESSAGE NetworkMessage;

    MSG_CreateNetworkMessage( &NetworkMessage, PacketMemory, PacketSize,
                              MultiPlayerGameState.Base.pGameStateManager->MemoryBlocks.
                              pSystemMemory );

    while( ReceivedPackets < MAX_PACKETS_PER_UPDATE )
    {
        int ReadBytes = NET_SocketReceiveFrom(
                            &MultiPlayerGameState.Client.Socket, PacketMemory,
                            PacketSize, &NetworkPacket.Address );

        if( ReadBytes == 0 )
        {
            /* Nothing to read */
            break;
        }
        else if( ReadBytes > 0 )
        {
            MSG_CopyNetworkMessage( &NetworkPacket.Message, &NetworkMessage,
                                    ReadBytes );
            ++ReceivedPackets;
            TotalReadBytes += ReadBytes;

            QUE_Enqueue( &MultiPlayerGameState.PacketQueue, &NetworkPacket );
        }
        else
        {
            LOG_Debug( "MPG_ReadIncomingPackets <ERROR> Unknown read "
                       "error\n" );
        }
    }
}
Exemplo n.º 14
0
bool MEM_CreateMemoryBlockHeader( PMEMORY_BLOCK_HEADER p_pMemoryBlockHeader,
	bool p_Free, size_t p_TotalSize, size_t p_DataSize )
{
	Uint8 *pPadding = ( Uint8 * )p_pMemoryBlockHeader;
	PMEMORY_BLOCK_FOOTER pFooter;

	if( p_DataSize > p_TotalSize )
	{
		LOG_Debug( "Data size greater than total size" );

		return false;
	}

	p_pMemoryBlockHeader->Flags = 0;

	if( p_Free == true )
	{
		p_pMemoryBlockHeader->Flags |= MEM_BLOCK_FLAG_FREE;
	}

	p_pMemoryBlockHeader->Size = p_TotalSize;
	p_pMemoryBlockHeader->DataOffset = p_TotalSize - p_DataSize;

	pPadding += p_pMemoryBlockHeader->DataOffset;
	pPadding -= sizeof( MEMORY_BLOCK_FOOTER );

	pFooter = ( PMEMORY_BLOCK_FOOTER )pPadding;
	pFooter->Padding = ( Uint8 )( p_pMemoryBlockHeader->DataOffset -
		( sizeof( MEMORY_BLOCK_HEADER ) + sizeof( MEMORY_BLOCK_FOOTER ) ) );
	pFooter->Magic = MEM_MAGIC8;

#if defined ( DEBUG )
	p_pMemoryBlockHeader->CRC = 0;
#endif /* DEBUG */

	return true;
}
Exemplo n.º 15
0
int TXT_CreateGlyphSetFromFile( char *p_pFileName, GLYPHSET *p_pGlyphSet,
	PMEMORY_BLOCK p_pMemoryBlock )
{
	GDFS FileHandle;
	long FileBlocks;
	char *pFileContents;
	char *pLine;
	char Token[ 256 ];
	char *pLineChar;
	size_t FilePosition = 0;
	BMF_CHUNK Chunk;
	Sint32 FileSize;

	if( !( FileHandle = FS_OpenFile( p_pFileName ) ) )
	{
		LOG_Debug( "Failed to open glyph file" );

		return 1;
	}

	gdFsGetFileSize( FileHandle, &FileSize );

	gdFsGetFileSctSize( FileHandle, &FileBlocks );

	pFileContents = MEM_AllocateFromBlock( p_pMemoryBlock, FileBlocks * 2048,
		p_pFileName );

	if( gdFsReqRd32( FileHandle, FileBlocks, pFileContents ) < 0 )
	{
		LOG_Debug( "Could not load the glyph file into memory" );

		return 1;
	}

	while( gdFsGetStat( FileHandle ) != GDD_STAT_COMPLETE )
	{
	}

	gdFsClose( FileHandle );

	if( ( pFileContents[ 0 ] != 'B' ) ||
		( pFileContents[ 1 ] != 'M' ) ||
		( pFileContents[ 2 ] != 'F' ) ||
		( pFileContents[ 3 ] != 0x03 ) )
	{
		MEM_FreeFromBlock( p_pMemoryBlock, pFileContents );

		LOG_Debug( "Font file is not a binary file" );

		return 1;
	}

	FilePosition = 4;

	while( FilePosition != FileSize )
	{
		size_t TestSize = sizeof( BMF_CHAR );
		Sint32 Size = 0;
		memcpy( &Chunk, &pFileContents[ FilePosition ], sizeof( BMF_CHUNK ) );
		/* Very ugly code */
		Size = ( Chunk.Size[ 0 ] );
		Size |= ( Chunk.Size[ 1 ] << 8 );
		Size |= ( ( Chunk.Size[ 2 ] ) << 16 );
		Size |= ( ( Chunk.Size[ 3 ] ) << 24 );

		FilePosition += sizeof( BMF_CHUNK );

		switch( Chunk.ID )
		{
			case BMF_ID_COMMON:
			{
				BMF_COMMON Common;

				memcpy( &Common, &pFileContents[ FilePosition ],
					BMF_COMMON_PACKED_SIZE );

				FilePosition += BMF_COMMON_PACKED_SIZE;

				p_pGlyphSet->LineHeight = Common.LineHeight;
				p_pGlyphSet->BaseLine = Common.BaseLine;
				p_pGlyphSet->Width = Common.Width;
				p_pGlyphSet->Height = Common.Height;

				break;
			}
			case BMF_ID_CHARS:
			{
				size_t CharCount = Size / sizeof( BMF_CHAR );
				size_t CharIndex;

				for( CharIndex = 0; CharIndex < CharCount; ++CharIndex )
				{
					BMF_CHAR Char;

					memcpy( &Char, &pFileContents[ FilePosition ],
						sizeof( BMF_CHAR ) );

					p_pGlyphSet->Glyphs[ Char.ID ].X = Char.X;
					p_pGlyphSet->Glyphs[ Char.ID ].Y = Char.Y;
					p_pGlyphSet->Glyphs[ Char.ID ].Width = Char.Width;
					p_pGlyphSet->Glyphs[ Char.ID ].Height = Char.Height;
					p_pGlyphSet->Glyphs[ Char.ID ].XOffset = Char.XOffset;
					p_pGlyphSet->Glyphs[ Char.ID ].YOffset = Char.YOffset;
					p_pGlyphSet->Glyphs[ Char.ID ].XAdvance = Char.XAdvance;

					FilePosition += sizeof( BMF_CHAR );
				}
				break;
			}
			default:
			{
				FilePosition += Size;
				break;
			}
		}
	}

	MEM_FreeFromBlock( p_pMemoryBlock, pFileContents );
	MEM_GarbageCollectMemoryBlock( p_pMemoryBlock );

	return 0;
}
Exemplo n.º 16
0
Sint32 FS_Initialise( void )
{
	Uint8 *pWork, *pDirectory;
	Sint32 Error, Itr;
	Uint32 RootDirectoryBuffer[ GDFS_DIRREC_SIZE( 64 ) ];

	pWork =
		( Uint8 * )( ( ( Uint32 )g_GDFSWork & 0xFFFFFFE0 ) + 0x20 );
	pDirectory =
		( Uint8 * )( ( ( Uint32 )g_GDFSHandleTable & 0xFFFFFFE0 ) + 0x20 );
	
	for( Itr = GDROM_RETRY_COUNT; Itr > 0; --Itr )
	{
		Error = gdFsInit( GDROM_MAX_OPEN_FILES, pWork, GDROM_BUFFER_COUNT,
			pDirectory );

		if( ( Error == GDD_ERR_TRAYOPEND ) ||
			( Error == GDD_ERR_UNITATTENT ) )
		{
			/* Debug builds are allowed to have their tray open */
#if defined ( DCJAM_BUILD_DEBUG )
			LOG_Debug( "Warning - GD ROM drive door open" );
			break;
#else
			return FS_FATALERROR;
#endif /* DCJAM_BUILD_DEBUG */
		}
		else if( Error == GDD_ERR_OK )
		{
			break;
		}
		else if( Error == GDD_ERR_NOTREADY )
		{
			LOG_Debug( "Warning - GD ROM drive not ready" );
#if defined ( DCJAM_BUILD_DEBUG )
			break;
#endif
		}
		else
		{
			LOG_Debug( "GD ROM Error code: %d", Error );
		}
	}

	if( Itr == 0 )
	{
		return FS_DRIVEERROR;
	}

	gdFsEntryErrFuncAll( GDFSErrorCallback, NULL );
	
	g_RootDirectory = gdFsCreateDirhn( RootDirectoryBuffer, 64 );
	gdFsLoadDir( ".", g_RootDirectory );

#if defined ( DCJAM_BUILD_DEBUG )
	LOG_Debug( "Initialised GD-ROM | Maximum open files: %d | Open buffer "
		"count: %d", GDROM_MAX_OPEN_FILES, GDROM_BUFFER_COUNT );
	LOG_Debug( "%s", GDD_VERSION_STR );
#endif /* DCJAM_BUILD_DEBUG */

	return FS_OK;
}
static int GLS_Update( void *p_pArgs )
{
	static Uint8 MessageBuffer[ 1400 ];
	static size_t MessageBufferLength = sizeof( MessageBuffer );

	if( GameListServerState.Base.Paused == false )
	{
		switch( GameListServerState.ServerListState )
		{
			case SERVERLIST_STATE_RESOLVING_DOMAIN:
			{
				switch( GameListServerState.DNSRequest.Status )
				{
					case DNS_REQUEST_POLLING:
					{
						break;
					}
					case DNS_REQUEST_RESOLVED:
					{
						NETWORK_MESSAGE Message;
						struct in_addr Address;
						Address.s_addr = GameListServerState.DNSRequest.IP;

						NCL_Initialise( &GameListServerState.Client,
							inet_ntoa( Address ), 50001 );

						MSG_CreateNetworkMessage( &Message, MessageBuffer,
							MessageBufferLength,
							GameListServerState.Base.pGameStateManager->
								MemoryBlocks.pSystemMemory );

						MSG_WriteUInt32( &Message, PACKET_TYPE_LISTREQUEST );
						MSG_WriteInt32( &Message, 0 );
						MSG_WriteUInt16( &Message, 0 );

						NCL_SendMessage( &GameListServerState.Client,
							&Message );

						GameListServerState.ServerListState =
							SERVERLIST_STATE_CONNECTING;

						break;
					}
					case DNS_REQUEST_FAILED:
					{
						/* Could not resolve the domain name, tell the user,
						 * allow for a retry */
						break;
					}
					default:
					{
					}
				}

				break;
			}
			case SERVERLIST_STATE_CONNECTING:
			{
				GameListServerState.StateTimer =
					syTmrCountToMicro( syTmrDiffCount(
						GameListServerState.StateTimerStart,
						syTmrGetCount( ) ) );

				if( GameListServerState.StateTimer >= 2000000UL )
				{
					NETWORK_MESSAGE Message;

					MSG_CreateNetworkMessage( &Message, MessageBuffer,
						MessageBufferLength,
						GameListServerState.Base.pGameStateManager->
							MemoryBlocks.pSystemMemory );

					MSG_WriteUInt32( &Message, PACKET_TYPE_LISTREQUEST );
					MSG_WriteInt32( &Message, 0 );
					MSG_WriteUInt16( &Message, 0 );

					NCL_SendMessage( &GameListServerState.Client,
						&Message );

					MSG_DestroyNetworkMessage( &Message );

					GameListServerState.StateTimerStart = syTmrGetCount( );

					++GameListServerState.StateMessageTries;
				}

				if( GameListServerState.StateMessageTries > 10 )
				{
					LOG_Debug( "Unable to connect to game server\n" );
					LOG_Debug( "Popping GLS state\n" );
					GSM_PopState( GameListServerState.Base.pGameStateManager );
				}

				break;
			}
			case SERVERLIST_STATE_GETSERVERLIST:
			{
				break;
			}
			case SERVERLIST_STATE_DISPLAYSERVERLIST:
			{
				if( g_Peripherals[ 0 ].press & PDD_DGT_KU )
				{
					if( GameListServerState.ServerCount > 0 )
					{
						if( GameListServerState.SelectedServer == 0 )
						{
							GameListServerState.SelectedServer =
								GameListServerState.ServerCount - 1;
						}
						else
						{
							--GameListServerState.SelectedServer;
						}
					}
				}

				if( g_Peripherals[ 0 ].press & PDD_DGT_KD )
				{
					if( GameListServerState.ServerCount > 0 )
					{
						if( GameListServerState.SelectedServer == 
							( GameListServerState.ServerCount - 1 ) )
						{
							GameListServerState.SelectedServer = 0;
						}
						else
						{
							++GameListServerState.SelectedServer;
						}
					}
				}

				if( g_Peripherals[ 0 ].press & PDD_DGT_TX )
				{
					NETWORK_MESSAGE Message;

					MSG_CreateNetworkMessage( &Message, MessageBuffer,
						MessageBufferLength,
						GameListServerState.Base.pGameStateManager->
							MemoryBlocks.pSystemMemory );

					MSG_WriteUInt32( &Message, PACKET_TYPE_LISTREQUEST );
					MSG_WriteInt32( &Message, 0 );
					MSG_WriteUInt16( &Message, 0 );

					NCL_SendMessage( &GameListServerState.Client,
						&Message );

					MSG_DestroyNetworkMessage( &Message );
				}

				if( g_Peripherals[ 0 ].press & PDD_DGT_TA )
				{
					/* Push the multi player game state onto the stack */
					MULTIPLAYER_GAME_ARGS StateArgs;

					PGAMESERVER pGameServer = ARY_GetItem(
						&GameListServerState.Servers,
						GameListServerState.SelectedServer );

					StateArgs.IP = pGameServer->IP;
					StateArgs.Port = ntohs( pGameServer->Port );

					GSM_PushState( GameListServerState.Base.pGameStateManager,
						GAME_STATE_MULTIPLAYER_GAME, &StateArgs, NULL );

					GameListServerState.ServerListState =
						SERVERLIST_STATE_CONNECTING;
				}

				break;
			}
			default:
			{
				LOG_Debug( "Unknown server list state\n" );
				break;
			}
		}

		GLS_ProcessIncomingPackets( );

		NET_Update( );

		if( g_Peripherals[ 0 ].press & PDD_DGT_TB )
		{
			LOG_Debug( "Popping GLS state\n" );
			GSM_PopState( GameListServerState.Base.pGameStateManager );
		}
	}

	return 0;
}
static int GLS_Render( void *p_pArgs )
{
	KMPACKEDARGB TextColour = 0xFFFFFFFF;
	float TextLength;
	PGLYPHSET pGlyphSet;

	if( GameListServerState.Base.Paused == false )
	{
		char InfoString[ 128 ] = { '\0' };

		pGlyphSet = GSM_GetGlyphSet(
			GameListServerState.Base.pGameStateManager, GSM_GLYPH_SET_GUI_1 );

		REN_Clear( );

		switch( GameListServerState.ServerListState )
		{
			case SERVERLIST_STATE_RESOLVING_DOMAIN:
			{
#if defined ( DEBUG )
				TXT_RenderString( pGlyphSet, &TextColour, 320.0f,
					240.0f + ( ( float )pGlyphSet->LineHeight ),
					GameListServerState.DNSRequest.Domain );
#endif /* ( DEBUG ) */

				if( GameListServerState.DNSRequest.Status ==
					DNS_REQUEST_POLLING )
				{
					sprintf( InfoString, "RESOLVING %s", LIST_SERVER_DOMAIN );
				}
				else if( GameListServerState.DNSRequest.Status ==
					DNS_REQUEST_RESOLVED )
				{
					sprintf( InfoString, "RESOLVED %s", LIST_SERVER_DOMAIN );
#if defined ( DEBUG )
					TXT_RenderString( pGlyphSet, &TextColour, 320.0f,
						240.0f + ( ( float )pGlyphSet->LineHeight * 2.0f ),
						GameListServerState.DNSRequest.IPAddress );
#endif /* DEBUG */
				}
				else if( GameListServerState.DNSRequest.Status ==
					DNS_REQUEST_FAILED )
				{
					sprintf( InfoString, "FAILED TO RESOLVE %s",
						LIST_SERVER_DOMAIN );
				}
				else
				{
					sprintf( InfoString, "UNKNOWN ERROR RESOLVING %s",
						LIST_SERVER_DOMAIN );
				}

				break;
			}
			case SERVERLIST_STATE_CONNECTING:
			{
				sprintf( InfoString, "CONNECTING [ATTEMPT #%lu]",
					GameListServerState.StateMessageTries );

				TXT_MeasureString( pGlyphSet, "[B] back", &TextLength );
				TXT_RenderString( pGlyphSet, &TextColour,
					640.0f - 64.0f - TextLength,
					480.0f - ( 32.0f + ( float )pGlyphSet->LineHeight ),
					"[B] back" );

				break;
			}
			case SERVERLIST_STATE_GETSERVERLIST:
			{
				sprintf( InfoString, "GETTING SERVER LIST" );

				TXT_MeasureString( pGlyphSet, "[B] back",
					&TextLength );
				TXT_RenderString( pGlyphSet, &TextColour,
					640.0f - 64.0f - TextLength,
					480.0f - ( 32.0f + ( float )pGlyphSet->LineHeight ),
					"[B] back" );

				break;
			}
			case SERVERLIST_STATE_DISPLAYSERVERLIST:
			{
				size_t Servers, Index;
				char IPPort[ 32 ];

				TXT_MeasureString( pGlyphSet, "SERVER LIST", &TextLength );
				TXT_RenderString( pGlyphSet, &TextColour,
					320.0f - ( TextLength * 0.5f ), 32.0f, "SERVER LIST" );

				Servers = ARY_GetCount( &GameListServerState.Servers );

				for( Index = 0; Index < Servers; ++Index )
				{
					PGAMESERVER GameServer;
					struct in_addr Address;

					if( GameListServerState.SelectedServer == Index )
					{
						TextColour.dwPacked = 0xFF00FF00;
					}
					else
					{
						TextColour.dwPacked = 0xFFFFFFFF;
					}

					GameServer = ARY_GetItem( &GameListServerState.Servers,
						Index );

					Address.s_addr = GameServer->IP;

					sprintf( IPPort, "%s:%u", inet_ntoa( Address ),
						ntohs( GameServer->Port ) );

					TXT_RenderString( pGlyphSet, &TextColour, 32.0f,
						96.0f + ( ( float )pGlyphSet->LineHeight * Index ),
						IPPort );
				}

				TextColour.dwPacked = 0xFFFFFFFF;

				TXT_MeasureString( pGlyphSet,
					"[X] update    [Y] filter    [A] join    [B] back",
					&TextLength );
				TXT_RenderString( pGlyphSet, &TextColour,
					320.0f - ( TextLength * 0.5f ),
					480.0f - ( 32.0f + ( float )pGlyphSet->LineHeight ),
					"[X] update    [Y] filter    [A] join    [B] back" );

				break;
			}
			default:
			{
				LOG_Debug( "Unknown server list state\n" );
				break;
			}
		}

#if defined ( DEBUG )
		{
			char NetString[ 80 ];
			sprintf( NetString, "Open interfaces: %d", NET_GetIfaceOpen( ) );
			TXT_RenderString( pGlyphSet, &TextColour, 0.0f, 0.0f, NetString );

			sprintf( NetString, "Open devices: %d", NET_GetDevOpen( ) );
			TXT_RenderString( pGlyphSet, &TextColour, 0.0f, 20.0f, NetString );
		}
#endif /* DEBUG */

		TXT_MeasureString( pGlyphSet, InfoString, &TextLength );
		TXT_RenderString( pGlyphSet, &TextColour,
			320.0f - ( TextLength * 0.5f ), 240.0f, InfoString );

		REN_SwapBuffers( );
	}

	return 0;
}
static void GLS_ProcessPacket( PNETWORK_MESSAGE p_pMessage,
	PSOCKET_ADDRESS p_pAddress )
{
	Uint32 PacketType;

	PacketType = MSG_ReadUInt32( p_pMessage );

	switch( PacketType )
	{
		case PACKET_TYPE_LISTRESPONSE:
		{
			/* Extract the list of servers */
			size_t Servers = ( p_pMessage->MaxSize - sizeof( Uint32 ) ) /
				GAMESERVER_PACKET_SIZE;
			size_t Index;
			GAMESERVER_PACKET GameServerPacket;
			GAMESERVER GameServer;

			GameListServerState.ServerListState =
				SERVERLIST_STATE_GETSERVERLIST;

			for( Index = 0; Index < Servers; ++Index )
			{
				MSG_Read( p_pMessage, &GameServerPacket,
					GAMESERVER_PACKET_SIZE );
				
				if( GameServerPacket.IP != 0 && GameServerPacket.Port != 0 )
				{
					/*LOG_Debug( "Server: 0x%08X:0x%04X\n", GameServerPacket.IP,
						GameServerPacket.Port );*/
					if( GameServerPacket.IP == 0xFFFFFFFF &&
						GameServerPacket.Port == 0xFFFF )
					{
						ARY_Clear( &GameListServerState.Servers );
						GameListServerState.ServerCount = 0;

						continue;
					}

					GameServer.IP = GameServerPacket.IP;
					GameServer.Port = GameServerPacket.Port;

					ARY_Append( &GameListServerState.Servers, &GameServer );
				}
				else
				{
					GameListServerState.ServerListState =
						SERVERLIST_STATE_DISPLAYSERVERLIST;
				}
			}

			GameListServerState.ServerCount =
				ARY_GetCount( &GameListServerState.Servers );

			/* Reset the connection attempt counter */
			GameListServerState.StateMessageTries = 0;

			break;
		}
		default:
		{
			LOG_Debug( "Unknown packet type received: 0x%08X\n", PacketType );
			break;
		}
	}
}
 void CloudReconnectWorker::doUnsubscriptions( )
 {
   // Here we need to unsubscribe to all events.
   LOG_Debug(core, "Un-subscribe to all type messages...");
   m_pUccSession->unsubscribe(*this);
 }
 void CloudReconnectWorker::doSubscriptions( )
 {
   // Here we need to subscribe to a specific event reconnect that will received from the ucc session.
   LOG_Debug(core, "Subscribe to all type messages...");
   m_pUccSession->subscribe(*this,gvr::communication::ucc::UccMessageCloudReconnect::GetTypeId());
 }
 void CloudReconnectWorker::sessionEvent( IUccSessionListener::StatusType status )
 {
   LOG_Debug(core, "Enqueue a new status notification...");
   enqueueNotification ( status );
 }
 void CloudReconnectWorker::sessionEvent( IUccSessionListener::BufferType const & buffer, IUccSessionListener::TypeId const & typeId, IUccSessionListener::KeyType const & keyType)
 {
   LOG_Debug(core, "Enqueue a new message notification...");
   enqueueNotification ( typeId, buffer );
 }
 CloudReconnectWorker::~CloudReconnectWorker()
 {
   stop();
   LOG_Debug(core, "Stopping CloudReconnectWorker...");
 }
 CloudReconnectWorker::CloudReconnectWorker( UccSession & uccSession, SpotSession & spotSession, CloudStatus & cloudStatus):
     AbsOptCloudClientWorker("CloudReconnectWorker"), m_pUccSession(&uccSession), m_pSpotSession(&spotSession), m_cloudStatus(cloudStatus)
 {
   start();
   LOG_Debug(core, "Starting CloudReconnectWorker...");
 }
Exemplo n.º 26
0
Sint32 HW_Initialise( KMBPPMODE p_BPP, SYE_CBL *p_pCableType,
	PNATIVE_MEMORY_FREESTAT p_pMemoryFreeStat )
{
	KMDISPLAYMODE DisplayMode;

	switch( syCblCheck( ) )
	{
		case SYE_CBL_NTSC:
		{
			DisplayMode = KM_DSPMODE_NTSCNI640x480;

			break;
		}
		case SYE_CBL_PAL:
		{
			if( p_pCableType )
			{
				( *p_pCableType ) = SYE_CBL_PAL;
			}

			DisplayMode = KM_DSPMODE_PALNI640x480EXT;

			break;
		}
		case SYE_CBL_VGA:
		{
			DisplayMode = KM_DSPMODE_VGA;

			break;
		}
		default:
		{
			HW_Reboot( );
		}
	}

	set_imask( 15 );

	/* Initialise the CPU, G1 bus, interrupt controller, cache, and timer */
	syHwInit( );
	MEM_Initialise( p_pMemoryFreeStat );
	syStartGlobalConstructor( );
	kmInitDevice( KM_DREAMCAST );

	/* No antialiasing, dither if 16-BPP is enabled */
	kmSetDisplayMode( DisplayMode, p_BPP, KM_DITHER, KM_AAMODE );
	kmSetWaitVsyncCount( 1 );
	
	/* Initialise the interrupt controller and libraries required for after the
	 * graphics library is initialised */
	syHwInit2( );

	PER_Initialise( );

	/* Start the real-time clock */
	syRtcInit( );

	set_imask( 0 );

	if( FS_Initialise( ) != FS_OK )
	{
		LOG_Debug( "Failed to initialise the file system" );

		return HW_FATALERROR;
	}

	if( syCblCheck( ) == SYE_CBL_PAL )
	{
		kmSetPALEXTCallback( PALExtCallback, NULL );
		kmSetDisplayMode( DisplayMode, p_BPP, KM_DITHER, KM_AAMODE );
	}

	return HW_OK;
}
Exemplo n.º 27
0
int TEX_LoadTexture( PTEXTURE p_pTexture, const char *p_pFileName,
	PMEMORY_BLOCK p_pMemoryBlock )
{
	GDFS FileHandle;
	long FileBlocks;
	PKMDWORD pTexture;
	GLOBAL_INDEX GlobalIndex;
	PVRT_HEADER PVRTHeader;
	Sint32 TextureOffset = 0;
	Sint32 FileSize = 0;
	Sint32 DataOffset = 0;

	if( !( FileHandle = FS_OpenFile( p_pFileName ) ) )
	{
		LOG_Debug( "Failed to open texture: %s", p_pFileName );

		return 1;
	}

	gdFsGetFileSize( FileHandle, &FileSize );
	gdFsGetFileSctSize( FileHandle, &FileBlocks );

	pTexture = MEM_AllocateFromBlock( p_pMemoryBlock, FileBlocks * 2048,
		p_pFileName );

	gdFsReqRd32( FileHandle, FileBlocks, pTexture );
	
	while( gdFsGetStat( FileHandle ) != GDD_STAT_COMPLETE )
	{
	}

	gdFsClose( FileHandle );

	FileSize /= 4;

	while( TextureOffset < FileSize )
	{
		/* GBIX */
		if( pTexture[ TextureOffset ] == 0x58494247 )
		{
			memcpy( &GlobalIndex, &pTexture[ TextureOffset ],
				sizeof( GlobalIndex ) );
			DataOffset += ( sizeof( GLOBAL_INDEX ) + GlobalIndex.Size ) / 4;
			TextureOffset += ( sizeof( GLOBAL_INDEX ) + GlobalIndex.Size ) / 4;
		}

		/* PVRT */
		if( pTexture[ TextureOffset ] == 0x54525650 )
		{
			memcpy( &PVRTHeader, &pTexture[ TextureOffset / 4 ],
				sizeof( PVRTHeader ) );

			DataOffset += sizeof( PVRT_HEADER ) / 4;
			TextureOffset +=
				( ( sizeof( Uint32 ) * 2 ) + PVRTHeader.Size ) / 4;

			p_pTexture->Width = PVRTHeader.Width;
			p_pTexture->Height = PVRTHeader.Height;
			p_pTexture->Flags = PVRTHeader.Flags;
		}
	}

	kmCreateTextureSurface( &p_pTexture->SurfaceDescription,
		p_pTexture->Width, p_pTexture->Height, p_pTexture->Flags );

	kmLoadTexture( &p_pTexture->SurfaceDescription, pTexture + DataOffset );

	while( kmQueryFinishLastTextureDMA( ) != KMSTATUS_SUCCESS )
	{
	}

	MEM_FreeFromBlock( p_pMemoryBlock, pTexture );

	return 0;
}