src/state.c

changeset 60
96f3df0b3cbb
parent 55
ba6b8e570062
child 62
c895256b528d
     1.1 --- a/src/state.c	Tue Dec 28 16:59:40 2010 +0000
     1.2 +++ b/src/state.c	Tue Dec 28 17:23:04 2010 +0000
     1.3 @@ -8,8 +8,8 @@
     1.4  int state_init(size_t ramsize)
     1.5  {
     1.6  	// Free RAM if it's allocated
     1.7 -	if (state.ram != NULL)
     1.8 -		free(state.ram);
     1.9 +	if (state.base_ram != NULL)
    1.10 +		free(state.base_ram);
    1.11  
    1.12  	// Initialise hardware registers
    1.13  	state.romlmap = false;
    1.14 @@ -18,10 +18,10 @@
    1.15  	// Basically: 512KiB minimum, 4MiB maximum, in increments of 512KiB.
    1.16  	if ((ramsize < 512*1024) || ((ramsize % (512*1024)) != 0))
    1.17  		return -1;
    1.18 -	state.ram = malloc(ramsize);
    1.19 -	if (state.ram == NULL)
    1.20 +	state.base_ram = malloc(ramsize);
    1.21 +	if (state.base_ram == NULL)
    1.22  		return -2;
    1.23 -	state.ram_size = ramsize;
    1.24 +	state.base_ram_size = ramsize;
    1.25  
    1.26  	// Load ROMs
    1.27  	FILE *r14c, *r15c;
    1.28 @@ -81,9 +81,9 @@
    1.29  
    1.30  void state_done()
    1.31  {
    1.32 -	if (state.ram != NULL) {
    1.33 -		free(state.ram);
    1.34 -		state.ram = NULL;
    1.35 +	if (state.base_ram != NULL) {
    1.36 +		free(state.base_ram);
    1.37 +		state.base_ram = NULL;
    1.38  	}
    1.39  	
    1.40  	// Deinitialise the disc controller