Exemple #1
0
static void allocate_memory (void)
{
	if (allocated_chipmem != prefs_chipmem_size) 
	{
	if (chipmemory)
	    mapped_free (chipmemory);
	chipmemory = 0;

	allocated_chipmem = prefs_chipmem_size;
	chipmem_mask = allocated_chipmem - 1;

	chipmemory = (uae_u8 *)mapped_malloc (allocated_chipmem, "chip");

	if (chipmemory == 0) {
	    write_log ("Fatal error: out of memory for chipmem.\n");
	    allocated_chipmem = 0;
		}	 
		else do_put_mem_long ((uae_u32 *)(chipmemory + 4), swab_l(0));
    }

    if (savestate_state == STATE_RESTORE)
    {
	    fseek (savestate_file, chip_filepos, SEEK_SET);
#ifdef USE_LIB7Z
	    void *tmp=malloc(compressed_size);
	    int outSize=allocated_chipmem;
	    int inSize=compressed_size;
	    SRes res;
	    fread (tmp, 1, compressed_size, savestate_file);
	    res=Lzma_Decode((Byte *)chipmemory, (size_t *)&outSize, (const Byte *)tmp, (size_t *)&inSize);
	    free(tmp);
	    if(res != SZ_OK)
	    {
		   allocated_chipmem=compressed_size;
	    	   fseek (savestate_file, chip_filepos, SEEK_SET);
	    }
	    if(res != SZ_OK)
#endif
	    fread (chipmemory, 1, allocated_chipmem, savestate_file);
	    if (allocated_bogomem > 0)
	    {
		    fseek (savestate_file, bogo_filepos, SEEK_SET);
		    fread (bogomemory, 1, allocated_bogomem, savestate_file);
	    }
    }

    chipmem_bank.baseaddr = chipmemory;
    bogomem_bank.baseaddr = bogomemory;
    chipmemory_word=(uae_u16 *)chipmemory;
}
Exemple #2
0
size_t file_num_lines(const char* filename)
{
	mapped_t* mapped=mapped_load_readonly(filename);
	if(mapped==NULL)
	{
		warn("file_num_lines(%s), failed", filename);
		return 0;
	}
	char* data = (char*)mapped->data;
	size_t i;
	size_t counter=0;
	for(i=0;i<mapped->length;i++)
	{
		if(data[i]=='\n')counter++;
	}
	mapped_free(mapped);
	return counter;
}
Exemple #3
0
static void allocate_memory (void)
{
    if (allocated_chipmem != prefs_chipmem_size) {
	if (chipmemory)
	    mapped_free (chipmemory);
	chipmemory = 0;

	allocated_chipmem = prefs_chipmem_size;
	chipmem_mask = allocated_chipmem - 1;

	chipmemory = mapped_malloc (allocated_chipmem, "chip");

	if (chipmemory == 0) {
	    write_log ("Fatal error: out of memory for chipmem.\n");
	    allocated_chipmem = 0;
	} else
	    do_put_mem_long ((uae_u32 *)(chipmemory + 4), swab_l(0));
    }

    chipmem_bank.baseaddr = chipmemory;
    bogomem_bank.baseaddr = bogomemory;
    chipmemory_word=(uae_u16 *)chipmemory;
}
Exemple #4
0
static void allocate_memory (void)
{
    if (allocated_chipmem != currprefs.chipmem_size) {
	uae_u32 memsize;
	if (chipmemory)
	    mapped_free (chipmemory);
	chipmemory = 0;

	memsize = allocated_chipmem = currprefs.chipmem_size;
	chipmem_mask = allocated_chipmem - 1;

	if (memsize < 0x100000)
	    memsize = 0x100000;
	chipmemory = mapped_malloc (memsize, "chip");
	if (chipmemory == 0) {
	    printf ("Fatal error: out of memory for chipmem.\n");
	    allocated_chipmem = 0;
	} else {
	    need_hardreset = 1;
	    if (memsize != allocated_chipmem)
		memset (chipmemory + allocated_chipmem, 0xff, memsize - allocated_chipmem);
	}
    }

    chipmem_full_mask = allocated_chipmem - 1;
    if ((currprefs.chipset_mask & CSMASK_ECS_AGNUS) && allocated_chipmem < 0x100000)
	chipmem_full_mask = 0x100000 - 1;

    if (allocated_bogomem != currprefs.bogomem_size) {
	if (bogomemory)
	    mapped_free (bogomemory);
	bogomemory = 0;

	allocated_bogomem = currprefs.bogomem_size;
	bogomem_mask = allocated_bogomem - 1;

	if (allocated_bogomem) {
	    bogomemory = mapped_malloc (allocated_bogomem, "bogo");
	    if (bogomemory == 0) {
		printf ("Out of memory for bogomem.\n");
		allocated_bogomem = 0;
	    }
	}
	need_hardreset = 1;
    }

    if (allocated_a3000lmem != currprefs.mbresmem_low_size) {
	if (a3000lmemory)
	    mapped_free (a3000lmemory);
	a3000lmemory = 0;

	allocated_a3000lmem = currprefs.mbresmem_low_size;
	a3000lmem_mask = allocated_a3000lmem - 1;
	a3000lmem_start = 0x08000000 - allocated_a3000lmem;
	if (allocated_a3000lmem) {
	    a3000lmemory = mapped_malloc (allocated_a3000lmem, "ramsey_low");
	    if (a3000lmemory == 0) {
		printf ("Out of memory for a3000lowmem.\n");
		allocated_a3000lmem = 0;
	    }
	}
	need_hardreset = 1;
    }

    if (allocated_a3000hmem != currprefs.mbresmem_high_size) {
	if (a3000hmemory)
	    mapped_free (a3000hmemory);
	a3000hmemory = 0;

	allocated_a3000hmem = currprefs.mbresmem_high_size;
	a3000hmem_mask = allocated_a3000hmem - 1;
	a3000hmem_start = 0x08000000;
	if (allocated_a3000hmem) {
	    a3000hmemory = mapped_malloc (allocated_a3000hmem, "ramsey_high");
	    if (a3000hmemory == 0) {
		printf ("Out of memory for a3000highmem.\n");
		allocated_a3000hmem = 0;
	    }
	}
	need_hardreset = 1;
    }

    if (savestate_state == STATE_RESTORE) {
	restore_ram (chip_filepos, chipmemory);
	if (allocated_bogomem > 0) {
	    restore_ram (bogo_filepos, bogomemory);
	}
	if (allocated_a3000lmem > 0)
	    restore_ram (a3000lmem_filepos, a3000lmemory);
	if (allocated_a3000hmem > 0)
	    restore_ram (a3000hmem_filepos, a3000hmemory);
    }
    chipmem_bank.baseaddr = chipmemory;
    bogomem_bank.baseaddr = bogomemory;
    a3000lmem_bank.baseaddr = a3000lmemory;
    a3000hmem_bank.baseaddr = a3000hmemory;
}