src/main.c

changeset 11
67bf6abb6e79
parent 10
dbf4ba9563c9
child 12
0c5bddf0289e
     1.1 --- a/src/main.c	Sun Nov 28 22:01:45 2010 +0000
     1.2 +++ b/src/main.c	Sun Nov 28 22:04:14 2010 +0000
     1.3 @@ -40,11 +40,13 @@
     1.4  	// Initialise hardware registers
     1.5  	state.romlmap = false;
     1.6  
     1.7 -	// Allocate RAM
     1.8 -	// TODO: make sure ram size selection is valid (512K, 1MB, 1.5MB, 2MB, 2.5MB, 3MB or 4MB)!
     1.9 +	// Allocate RAM, making sure the user has specified a valid RAM amount first
    1.10 +	// Basically: 512KiB minimum, 4MiB maximum, in increments of 512KiB.
    1.11 +	if ((state.ram_size < 512*1024) || ((state.ram_size % (512*1024)) != 0))
    1.12 +		return -1;
    1.13  	state.ram = malloc(state.ram_size);
    1.14  	if (state.ram == NULL)
    1.15 -		return -1;
    1.16 +		return -2;
    1.17  
    1.18  	// Load ROMs
    1.19  	FILE *r14c, *r15c;