Exemple #1
0
void TileChunks::Set(glm::ivec2 index, Tile* val)
{
    glm::ivec2 chunkI = TileIToChunkI(index);
    TileChunk* chunk = chunks.TryGet(chunkI);

    if (!chunk) {
        chunk = CreateChunkAt(chunkI, 0);
    }

    index -= chunk->OriginTileIndex();

    chunk->Set(index, val);

}
int create_all_translation_caches()
	{
	TInt minsize = ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE + BIOS_TRANSLATION_CACHE_SIZE;
        TInt maxsize = ROM_TRANSLATION_CACHE_SIZE + RAM_TRANSLATION_CACHE_SIZE + BIOS_TRANSLATION_CACHE_SIZE + 3 * 4096;
	
	RProcess process;
	TModuleMemoryInfo  info;
	
	TInt error = process.GetMemoryInfo( info );
	if( error )
		return error;
	
	TUint32 programAddr = 0x10000000;//(TUint32) info.iCodeBase;
	programAddr += info.iCodeSize;
	
        TUint32 destAddr = programAddr - KDistanceFromCodeSection;
	
	g_code_chunk = new RChunk();

	TInt err = CreateChunkAt(destAddr,minsize, maxsize );
	
	TUint32 dynamiaddr = (TUint32) g_code_chunk->Base();
	
    DEBUG("CREATING HEAPS");
	g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, minsize, 1, maxsize );
	if( g_code_heap != NULL )
	    {
	    DEBUG("ROM HEAP SUCCESS!");
	    rom_translation_cache = (u8*) g_code_heap->Alloc( ROM_TRANSLATION_CACHE_SIZE );
	    ram_translation_cache = (u8*) g_code_heap->Alloc( RAM_TRANSLATION_CACHE_SIZE );
	    bios_translation_cache = (u8*) g_code_heap->Alloc( BIOS_TRANSLATION_CACHE_SIZE );
	    if( rom_translation_cache == NULL)
	        DEBUG("ROM ALLOC FAIL!");
	    if( ram_translation_cache == NULL)
	        DEBUG("RAM ALLOC FAIL!");
	    if( bios_translation_cache == NULL)
	        DEBUG("BIOS ALLOC FAIL!");
	    }
	
	DEBUG("EVERYTHING DONE IN MEMORY HANDLING");
	
	rom_translation_ptr = rom_translation_cache;
	ram_translation_ptr = ram_translation_cache;
    bios_translation_ptr = bios_translation_cache;
    
    return 0;
	}